License(s)
dygraphs uses:
- - rgbcolor.js (Public Domain)
- - strftime.js (BSD License)
- excanvas.js (Apache License)
- YUI compressor (BSD License)
- JsDoc Toolkit (MIT license)
Linter uses:
- JSHint (modified MIT license; prevents evil)
-rgbcolor: http://www.phpied.com/rgb-color-parser-in-javascript/
-strftime: http://tech.bluesmoon.info/2008/04/strftime-in-javascript.html
excanvas: http://code.google.com/p/explorercanvas/
yui compressor: http://developer.yahoo.com/yui/compressor/
jsdoc toolkit: http://code.google.com/p/jsdoc-toolkit/
/**
* Format a date as 2000/01/23
- * @param {number} date_ms Millis since epoch.
+ * @param {number} dateMillis Millis since epoch.
* @return {string} The date formatted as YYYY-MM-DD.
*/
-Util.formatDate = function(date_ms) {
- var zeropad = function(x) { if (x < 10) return "0" + x; else return "" + x; };
- var d = new Date(date_ms);
-
- // Get the year:
- var year = "" + d.getFullYear();
- // Get a 0 padded month string
- var month = zeropad(d.getMonth() + 1); //months are 0-offset, sigh
- // Get a 0 padded day string
- var day = zeropad(d.getDate());
-
- return year + "/" + month + "/" + day;
+Util.formatDate = function(dateMillis) {
+ return Dygraph.dateString_(dateMillis).slice(0, 10); // 10 == "YYYY/MM/DD".length
};
<p>dygraphs is available under the MIT license, included in LICENSE.txt.</p>
<pre>dygraphs uses:
- - rgbcolor.js (Public Domain)
- - strftime.js (BSD License)
- excanvas.js (Apache License)
- YUI compressor (BSD License)
- JsDoc Toolkit (MIT license)
- stacktrace.js is public domain
automated tests use:
- - auto_tests/lib/jquery-1.4.2.js (MIT & GPL2)
+ - auto_tests/lib/jquery-1.4.2.js (MIT & GPL2)
- auto_tests/lib/Asserts.js (Apache 2.0 License)
- auto-tests/lib/JsTestDriver-1.3.3cjar (Apache 2.0 License
Linter uses:
- JSHint (modified MIT license; prevents evil)
-rgbcolor: http://www.phpied.com/rgb-color-parser-in-javascript/
-strftime: http://tech.bluesmoon.info/2008/04/strftime-in-javascript.html
excanvas: http://code.google.com/p/explorercanvas/
yui compressor: http://developer.yahoo.com/yui/compressor/
jsdoc toolkit: http://code.google.com/p/jsdoc-toolkit/
ctx.arc(canvasx, canvasy, radius, 0, 2 * Math.PI, false);
ctx.fill();
}
- // For more shapes, include extras/stars.js
+ // For more shapes, include extras/shapes.js
};
/**
/**
* Converts any valid CSS color (hex, rgb(), named color) to an RGB tuple.
*
- * @param {!string} color_str Any valid CSS color string.
+ * @param {!string} colorStr Any valid CSS color string.
* @return {{r:number,g:number,b:number}} Parsed RGB tuple.
* @private
*/
-Dygraph.toRGB_ = function(color_str) {
+Dygraph.toRGB_ = function(colorStr) {
// TODO(danvk): cache color parses to avoid repeated DOM manipulation.
var div = document.createElement('div');
- div.style.backgroundColor = color_str;
+ div.style.backgroundColor = colorStr;
div.style.visibility = 'hidden';
document.body.appendChild(div);
- var rgb_str = window.getComputedStyle(div).backgroundColor;
+ var rgbStr = window.getComputedStyle(div).backgroundColor;
document.body.removeChild(div);
- var bits = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(rgb_str);
+ var bits = /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/.exec(rgbStr);
return {
r: parseInt(bits[1], 10),
g: parseInt(bits[2], 10),
+++ /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();
- }
-});
-
-});
--- /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();
+ }
+});
+
+});
dygraph-gviz.js \
dygraph-interaction-model.js \
dygraph-tickers.js \
-rgbcolor/rgbcolor.js \
-strftime/strftime-min.js \
dashed-canvas.js \
dygraph-plugin-base.js \
plugins/annotations.js \
# This list needs to be kept in sync w/ the one in dygraph-dev.js
# and the one in generate-combined.sh.
load:
- - strftime/strftime-min.js
- - rgbcolor/rgbcolor.js
- dashed-canvas.js
- dygraph-layout.js
- dygraph-canvas.js
find . -path ./.git -prune -o -print | xargs chmod a+rX
# Copy everything to the site.
- rsync -avzr gallery strftime rgbcolor common tests jsdoc experimental plugins $site \
+ rsync -avzr gallery common tests jsdoc experimental plugins $site \
&& \
rsync -avzr --copy-links dashed-canvas.js stacktrace.js dygraph*.js gadget.xml excanvas.js thumbnail.png screenshot.png $temp_dir/* $site/
else
<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>
+ <script type="text/javascript" src="../extras/shapes.js"></script>
</head>
<body>
<div id="mixed-error" class="chart"></div>
<script type="text/javascript">
+ // Darken a color
+ function darkenColor(colorStr) {
+ // Defined in dygraph-utils.js
+ var color = Dygraph.toRGB_(colorStr);
+ color.r = Math.floor((255 + color.r) / 2);
+ color.g = Math.floor((255 + color.g) / 2);
+ color.b = Math.floor((255 + color.b) / 2);
+ return 'rgb(' + color.r + ',' + color.g + ',' + color.b + ')';
+ }
// This function draws bars for a single series. See
// multiColumnBarPlotter below for a plotter which can draw multi-series
var points = e.points;
var y_bottom = e.dygraph.toDomYCoord(0);
- // The RGBColorParser class is provided by rgbcolor.js, which is
- // packed in with dygraphs.
- var color = new RGBColorParser(e.color);
- color.r = Math.floor((255 + color.r) / 2);
- color.g = Math.floor((255 + color.g) / 2);
- color.b = Math.floor((255 + color.b) / 2);
- ctx.fillStyle = color.toRGB();
+ ctx.fillStyle = darkenColor(e.color);
// Find the minimum separation between x-values.
// This determines the bar width.
var fillColors = [];
var strokeColors = g.getColors();
for (var i = 0; i < strokeColors.length; i++) {
- var color = new RGBColorParser(strokeColors[i]);
- color.r = Math.floor((255 + color.r) / 2);
- color.g = Math.floor((255 + color.g) / 2);
- color.b = Math.floor((255 + color.b) / 2);
- fillColors.push(color.toRGB());
+ fillColors.push(darkenColor(strokeColors[i]));
}
for (var j = 0; j < sets.length; j++) {