};
var secondCallback = function(g, seriesName, ctx, canvasx, canvasy, color, radius) {
results.y2[seriesName] = 1;
- Dygraph.Circles.TRIANGLE(g, seriesName, ctx, canvasx, canvasy, color, radius);
+ Dygraph.Circles.DEFAULT(g, seriesName, ctx, canvasx, canvasy, color, radius);
};
g = new Dygraph(
};
var secondCallback = function(g, seriesName, ctx, canvasx, canvasy, color, radius) {
results.y2[seriesName] = 1;
- Dygraph.Circles.TRIANGLE(g, seriesName, ctx, canvasx, canvasy, color, radius);
+ Dygraph.Circles.DEFAULT(g, seriesName, ctx, canvasx, canvasy, color, radius);
};
g = new Dygraph(
/**
* Find the coordinates of an object relative to the top left of the page.
+ *
* TODO(danvk): change obj type from Node -> !Node
* @param {Node} obj
* @return {{x:number,y:number}}
return requiresNewPoints;
};
-/**
- * @param {!CanvasRenderingContext2D} ctx the canvas context
- * @param {number} sides the number of sides in the shape.
- * @param {number} radius the radius of the image.
- * @param {number} cx center x coordate
- * @param {number} cy center y coordinate
- * @param {number=} rotationRadians the shift of the initial angle, in radians.
- * @param {number=} delta the angle shift for each line. If missing, creates a
- * regular polygon.
- * @private
- */
-Dygraph.regularShape_ = function(
- ctx, sides, radius, cx, cy, rotationRadians, delta) {
- rotationRadians = rotationRadians || 0;
- delta = delta || Math.PI * 2 / sides;
-
- ctx.beginPath();
- var initialAngle = rotationRadians;
- var angle = initialAngle;
-
- var computeCoordinates = function() {
- var x = cx + (Math.sin(angle) * radius);
- var y = cy + (-Math.cos(angle) * radius);
- return [x, y];
- };
-
- var initialCoordinates = computeCoordinates();
- var x = initialCoordinates[0];
- var y = initialCoordinates[1];
- ctx.moveTo(x, y);
-
- for (var idx = 0; idx < sides; idx++) {
- angle = (idx == sides - 1) ? initialAngle : (angle + delta);
- var coords = computeCoordinates();
- ctx.lineTo(coords[0], coords[1]);
- }
- ctx.fill();
- ctx.stroke();
-};
-
-/**
- * TODO(danvk): be more specific on the return type.
- * @param {number} sides
- * @param {number=} rotationRadians
- * @param {number=} delta
- * @return {Function}
- * @private
- */
-Dygraph.shapeFunction_ = function(sides, rotationRadians, delta) {
- return function(g, name, ctx, cx, cy, color, radius) {
- ctx.strokeStyle = color;
- ctx.fillStyle = "white";
- Dygraph.regularShape_(ctx, sides, radius, cx, cy, rotationRadians, delta);
- };
-};
-
+// For more, include extras/stars.js
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 : Dygraph.shapeFunction_(3),
- SQUARE : Dygraph.shapeFunction_(4, Math.PI / 4),
- DIAMOND : Dygraph.shapeFunction_(4),
- PENTAGON : Dygraph.shapeFunction_(5),
- HEXAGON : Dygraph.shapeFunction_(6),
- CIRCLE : function(g, name, ctx, cx, cy, color, radius) {
- ctx.beginPath();
- ctx.strokeStyle = color;
- ctx.fillStyle = "white";
- ctx.arc(cx, cy, radius, 0, 2 * Math.PI, false);
- ctx.fill();
- ctx.stroke();
- },
- STAR : Dygraph.shapeFunction_(5, 0, 4 * Math.PI / 5),
- PLUS : function(g, name, ctx, cx, cy, color, radius) {
- ctx.strokeStyle = color;
-
- ctx.beginPath();
- ctx.moveTo(cx + radius, cy);
- ctx.lineTo(cx - radius, cy);
- ctx.closePath();
- ctx.stroke();
-
- ctx.beginPath();
- ctx.moveTo(cx, cy + radius);
- ctx.lineTo(cx, cy - radius);
- ctx.closePath();
- ctx.stroke();
- },
- EX : function(g, name, ctx, cx, cy, color, radius) {
- ctx.strokeStyle = color;
-
- ctx.beginPath();
- ctx.moveTo(cx + radius, cy + radius);
- ctx.lineTo(cx - radius, cy - radius);
- ctx.closePath();
- ctx.stroke();
-
- ctx.beginPath();
- ctx.moveTo(cx + radius, cy - radius);
- ctx.lineTo(cx - radius, cy + radius);
- ctx.closePath();
- ctx.stroke();
}
};
this.warn("Unable to add default annotation CSS rule; display may be off.");
};
-
-// Older pages may still use this name.
-var DateGraph = Dygraph;
--- /dev/null
+/**
+ * @license
+ * Copyright 2011 Dan Vanderkam (danvdk@gmail.com)
+ * MIT-licensed (http://opensource.org/licenses/MIT)
+ */
+
+/**
+ * @fileoverview
+ * Including this file will add several additional shapes to Dygraph.Circles
+ * which can be passed to drawPointCallback.
+ * See tests/custom-circles.html for usage.
+ */
+
+(function() {
+
+/**
+ * @param {!CanvasRenderingContext2D} ctx the canvas context
+ * @param {number} sides the number of sides in the shape.
+ * @param {number} radius the radius of the image.
+ * @param {number} cx center x coordate
+ * @param {number} cy center y coordinate
+ * @param {number=} rotationRadians the shift of the initial angle, in radians.
+ * @param {number=} delta the angle shift for each line. If missing, creates a
+ * regular polygon.
+ */
+var regularShape = function(
+ ctx, sides, radius, cx, cy, rotationRadians, delta) {
+ rotationRadians = rotationRadians || 0;
+ delta = delta || Math.PI * 2 / sides;
+
+ ctx.beginPath();
+ var initialAngle = rotationRadians;
+ var angle = initialAngle;
+
+ var computeCoordinates = function() {
+ var x = cx + (Math.sin(angle) * radius);
+ var y = cy + (-Math.cos(angle) * radius);
+ return [x, y];
+ };
+
+ var initialCoordinates = computeCoordinates();
+ var x = initialCoordinates[0];
+ var y = initialCoordinates[1];
+ ctx.moveTo(x, y);
+
+ for (var idx = 0; idx < sides; idx++) {
+ angle = (idx == sides - 1) ? initialAngle : (angle + delta);
+ var coords = computeCoordinates();
+ ctx.lineTo(coords[0], coords[1]);
+ }
+ ctx.fill();
+ ctx.stroke();
+};
+
+/**
+ * TODO(danvk): be more specific on the return type.
+ * @param {number} sides
+ * @param {number=} rotationRadians
+ * @param {number=} delta
+ * @return {Function}
+ * @private
+ */
+var shapeFunction = function(sides, rotationRadians, delta) {
+ return function(g, name, ctx, cx, cy, color, radius) {
+ ctx.strokeStyle = color;
+ ctx.fillStyle = "white";
+ regularShape(ctx, sides, radius, cx, cy, rotationRadians, delta);
+ };
+};
+
+Dygraph.update(Dygraph.Circles, {
+ TRIANGLE : shapeFunction(3),
+ SQUARE : shapeFunction(4, Math.PI / 4),
+ DIAMOND : shapeFunction(4),
+ PENTAGON : shapeFunction(5),
+ HEXAGON : shapeFunction(6),
+ CIRCLE : function(g, name, ctx, cx, cy, color, radius) {
+ ctx.beginPath();
+ ctx.strokeStyle = color;
+ ctx.fillStyle = "white";
+ ctx.arc(cx, cy, radius, 0, 2 * Math.PI, false);
+ ctx.fill();
+ ctx.stroke();
+ },
+ STAR : shapeFunction(5, 0, 4 * Math.PI / 5),
+ PLUS : function(g, name, ctx, cx, cy, color, radius) {
+ ctx.strokeStyle = color;
+
+ ctx.beginPath();
+ ctx.moveTo(cx + radius, cy);
+ ctx.lineTo(cx - radius, cy);
+ ctx.closePath();
+ ctx.stroke();
+
+ ctx.beginPath();
+ ctx.moveTo(cx, cy + radius);
+ ctx.lineTo(cx, cy - radius);
+ ctx.closePath();
+ ctx.stroke();
+ },
+ EX : function(g, name, ctx, cx, cy, color, radius) {
+ ctx.strokeStyle = color;
+
+ ctx.beginPath();
+ ctx.moveTo(cx + radius, cy + radius);
+ ctx.lineTo(cx - radius, cy - radius);
+ ctx.closePath();
+ ctx.stroke();
+
+ ctx.beginPath();
+ ctx.moveTo(cx + radius, cy - radius);
+ ctx.lineTo(cx - radius, cy + radius);
+ ctx.closePath();
+ ctx.stroke();
+ }
+});
+
+});
<script type="text/javascript" src="dygraph-combined.js"></script>
-->
<script type="text/javascript" src="../dygraph-dev.js"></script>
+ <script type="text/javascript" src="../extras/stars.js"></script>
</head>
<body>
--- /dev/null
+<!doctype html>
+<html>
+ <head>
+ <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
+ <title>Exported Symbols test</title>
+ <!--[if IE]>
+ <script type="text/javascript" src="../excanvas.js"></script>
+ <![endif]-->
+ </head>
+ <body>
+ <p>This page lists the set of symbols that dygraphs exports.</p>
+ <ol id="list">
+ </ol>
+
+ <script type="text/javascript">
+ var windowProps = {};
+ var newProps = [];
+ var k, i, html;
+ for (k in window) {
+ windowProps[k] = true;
+ }
+ </script>
+ <script type="text/javascript" src="../dygraph-dev.js"></script>
+ <script type="text/javascript">
+ for (k in window) {
+ if (!windowProps.hasOwnProperty(k)) {
+ newProps.push(k);
+ }
+ }
+ newProps.sort();
+ html = '';
+ for (i = 0; i < newProps.length; i++) {
+ html += '<li>' + newProps[i] + '</li>\n';
+ }
+ document.getElementById('list').innerHTML = html;
+ </script>
+ </body>
+</html>