-Dygraph.Circles = {
- DEFAULT : function(g, name, ctx, canvasx, canvasy, color, radius) {
- ctx.beginPath();
- ctx.fillStyle = color;
- ctx.arc(canvasx, canvasy, radius, 0, 2 * Math.PI, false);
- ctx.fill();
- },
- TRIANGLE : function(g, name, ctx, cx, cy, color, radius) {
- ctx.lineWidth = 1;
- ctx.strokeStyle = color;
- new Dygraph.RegularShape_(3).draw(ctx, cx, cy, radius);
- },
- SQUARE : function(g, name, ctx, cx, cy, color, radius) {
- ctx.lineWidth = 1;
- ctx.strokeStyle = color;
- new Dygraph.RegularShape_(4, Math.PI / 4).draw(ctx, cx, cy, radius);
- },
- DIAMOND : function(g, name, ctx, cx, cy, color, radius) {
- ctx.lineWidth = 1;
- ctx.strokeStyle = color;
- new Dygraph.RegularShape_(4).draw(ctx, cx, cy, radius);
- },
- PENTAGON : function(g, name, ctx, cx, cy, color, radius) {
- ctx.lineWidth = 1;
- ctx.strokeStyle = color;
- new Dygraph.RegularShape_(5).draw(ctx, cx, cy, radius);
- },
- HEXAGON : function(g, name, ctx, cx, cy, color, radius) {
- ctx.lineWidth = 1;
- ctx.strokeStyle = color;
- new Dygraph.RegularShape_(6).draw(ctx, cx, cy, radius);
- },
- CIRCLE : function(g, name, ctx, cx, cy, color, radius) {
- ctx.beginPath();
- ctx.strokeStyle = color;
- ctx.arc(cx, cy, radius, 0, 2 * Math.PI, false);
- ctx.stroke();
- },
- STAR : function(g, name, ctx, cx, cy, color, radius) {
- ctx.lineWidth = 1;
- ctx.strokeStyle = color;
- new Dygraph.RegularShape_(5, 0, 4 * Math.PI / 5).draw(ctx, cx, cy, radius);
- },
- PLUS : function(g, name, ctx, cx, cy, color, radius) {
- ctx.lineWidth = 1;
- ctx.strokeStyle = color;
+/**
+ * This is like calling d.setSeconds(), d.setMinutes(), etc, except that it
+ * adjusts for time zone changes to keep the date/time parts consistent.
+ *
+ * For example, d.getSeconds(), d.getMinutes() and d.getHours() will all be
+ * the same before/after you call setDateSameTZ(d, {ms: 0}). The same is not
+ * true if you call d.setMilliseconds(0).
+ *
+ * @type {function(!Date, Object.<number>)}
+ */
+Dygraph.setDateSameTZ = function(d, parts) {
+ var tz = d.getTimezoneOffset();
+ for (var k in parts) {
+ if (!parts.hasOwnProperty(k)) continue;
+ var setter = Dygraph.dateSetters[k];
+ if (!setter) throw "Invalid setter: " + k;
+ setter.call(d, parts[k]);
+ if (d.getTimezoneOffset() != tz) {
+ d.setTime(d.getTime() + (tz - d.getTimezoneOffset()) * 60 * 1000);
+ }
+ }
+};