Skip to content

Commit

Permalink
Merge pull request danvk#280 from danvk/kill-code
Browse files Browse the repository at this point in the history
Kill code
  • Loading branch information
danvk committed Oct 18, 2013
2 parents 70d47e7 + 4d9f1cb commit ee60939
Show file tree
Hide file tree
Showing 31 changed files with 321 additions and 1,558 deletions.
4 changes: 0 additions & 4 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ community, please follow the guide at http://dygraphs.com/changes.html.

License(s)
dygraphs uses:
- rgbcolor.js (Public Domain)
- strftime.js (BSD License)
- excanvas.js (Apache License)
- YUI compressor (BSD License)
- JsDoc Toolkit (MIT license)
Expand All @@ -64,8 +62,6 @@ automated tests use:
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/
Expand Down
17 changes: 9 additions & 8 deletions auto_tests/misc/local.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

var DygraphsLocalTester = function() {
this.tc = null; // Selected test case
this.name = null;
Expand Down Expand Up @@ -32,7 +34,6 @@ DygraphsLocalTester.prototype.overrideWarn = function() {
}
throw 'Warnings not permitted: ' + msg;
}
Dygraph.prototype.warn = Dygraph.warn;
};

DygraphsLocalTester.prototype.processVariables = function() {
Expand Down Expand Up @@ -76,12 +77,12 @@ DygraphsLocalTester.prototype.createAnchor = function(href, id, text) {
var a = document.createElement('a');
a.href = href;
a.id = id;
a.innerText = text;
a.textContent = text;
return a;
}

DygraphsLocalTester.prototype.createResultsDiv = function(summary, durationms) {
div = document.createElement('div');
var div = document.createElement('div');
div.id='results';

var body = document.getElementsByTagName('body')[0];
Expand Down Expand Up @@ -147,7 +148,7 @@ DygraphsLocalTester.prototype.postResults = function(summary, durationms) {

var tdResult = document.createElement('td');
tdResult.setAttribute('class', 'outcome');
tdResult.innerText = result.result ? 'pass' : 'fail';
tdResult.textContent = result.result ? 'pass' : 'fail';
tr.appendChild(tdResult);

var tdName = document.createElement('td');
Expand All @@ -159,7 +160,7 @@ DygraphsLocalTester.prototype.postResults = function(summary, durationms) {
tr.appendChild(tdName);

var tdDuration = document.createElement('td');
tdDuration.innerText = result.duration + ' ms';
tdDuration.textContent = result.duration + ' ms';
tr.appendChild(tdDuration);

if (result.e) {
Expand Down Expand Up @@ -194,20 +195,20 @@ DygraphsLocalTester.prototype.listTests = function() {
var createLink = function(parent, title, url) {
var li = createAttached('li', parent);
var a = createAttached('a', li);
a.innerHTML = title;
a.textContent = title;
a.href = url;
return li;
}
if (this.tc == null) {
description.innerHTML = 'Test cases:';
description.textContent = 'Test cases:';
var testCases = getAllTestCases();
createLink(list, '(run all tests)', document.URL + '?command=runAllTests');
for (var idx in testCases) {
var entryName = testCases[idx].name;
createLink(list, entryName, document.URL + '?testCaseName=' + entryName);
}
} else {
description.innerHTML = 'Tests for ' + name;
description.textContent = 'Tests for ' + name;
var names = this.tc.getTestNames();
createLink(list, 'Run All Tests', document.URL + '&command=runAllTests');
for (var idx in names) {
Expand Down
5 changes: 3 additions & 2 deletions auto_tests/tests/DygraphOps.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ DygraphOps.dispatchDoubleClick = function(g, custom) {
* type, screenX, screenY, clientX, clientY.
*/
DygraphOps.createOptsForPoint_ = function(g, type, x, y) {
var pageX = Dygraph.findPosX(g.canvas_) + x;
var pageY = Dygraph.findPosY(g.canvas_) + y;
var pos = Dygraph.findPos(g.canvas_);
var pageX = pos.x + x;
var pageY = pos.y + y;

return {
type : type,
Expand Down
8 changes: 8 additions & 0 deletions auto_tests/tests/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,11 @@ Util.overrideXMLHttpRequest = function(data) {
return FakeXMLHttpRequest;
};

/**
* Format a date as 2000/01/23
* @param {number} dateMillis Millis since epoch.
* @return {string} The date formatted as YYYY-MM-DD.
*/
Util.formatDate = function(dateMillis) {
return Dygraph.dateString_(dateMillis).slice(0, 10); // 10 == "YYYY/MM/DD".length
};
4 changes: 2 additions & 2 deletions auto_tests/tests/axis_labels-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedDateAxisLabelFormatter = fu
assertEquals('number', typeof(granularity));
assertEquals('function', typeof(opts));
assertEquals('[Dygraph graph]', dg.toString());
return 'x' + x.strftime('%Y/%m/%d');
return 'x' + Util.formatDate(x);
},
yAxisLabelFormatter: function(y, granularity, opts, dg) {
assertEquals('number', typeof(y));
Expand Down Expand Up @@ -159,7 +159,7 @@ DeprecatedAxisLabelsTestCase.prototype.testDeprecatedDateValueFormatter = functi
assertEquals('function', typeof(opts));
assertEquals('string', typeof(series_name));
assertEquals('[Dygraph graph]', dg.toString());
return 'x' + new Date(x).strftime('%Y/%m/%d');
return 'x' + Util.formatDate(x);
},
yValueFormatter: function(y, opts, series_name, dg) {
assertEquals('number', typeof(y));
Expand Down
4 changes: 2 additions & 2 deletions auto_tests/tests/axis_labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ AxisLabelsTestCase.prototype.testDateAxisLabelFormatter = function () {
assertEquals('number', typeof(granularity));
assertEquals('function', typeof(opts));
assertEquals('[Dygraph graph]', dg.toString());
return 'x' + x.strftime('%Y/%m/%d');
return 'x' + Util.formatDate(x);
}
},
y : {
Expand Down Expand Up @@ -292,7 +292,7 @@ AxisLabelsTestCase.prototype.testDateValueFormatter = function () {
assertEquals('function', typeof(opts));
assertEquals('string', typeof(series_name));
assertEquals('[Dygraph graph]', dg.toString());
return 'x' + new Date(x).strftime('%Y/%m/%d');
return 'x' + Util.formatDate(x);
}
},
y : {
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/tests/multiple_axes-old.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ MultipleAxesOldTestCase.prototype.testOldDrawPointCallback = function() {
};
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(
Expand Down
2 changes: 1 addition & 1 deletion auto_tests/tests/multiple_axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ MultipleAxesTestCase.prototype.testDrawPointCallback = function() {
};
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(
Expand Down
6 changes: 6 additions & 0 deletions auto_tests/tests/utils_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ UtilsTestCase.prototype.testIterator_no_args = function() {
assertNull(iter.next());
};

UtilsTestCase.prototype.testToRGB = function() {
assertEquals({r: 255, g: 200, b: 150}, Dygraph.toRGB_('rgb(255,200,150)'));
assertEquals({r: 255, g: 200, b: 150}, Dygraph.toRGB_('#FFC896'));
assertEquals({r: 255, g: 0, b: 0}, Dygraph.toRGB_('red'));
};

/*
UtilsTestCase.prototype.testDateSet = function() {
var base = new Date(1383455100000);
Expand Down
6 changes: 1 addition & 5 deletions docs/legal.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@ <h2>Legal Information</h2>
<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 &amp; 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/
Expand Down
8 changes: 4 additions & 4 deletions dygraph-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

/*jshint globalstrict: true */
/*global Dygraph:false,RGBColorParser:false */
/*global Dygraph:false */
"use strict";


Expand Down Expand Up @@ -586,7 +586,7 @@ DygraphCanvasRenderer._errorPlotter = function(e) {

var fillGraph = g.getBooleanOption("fillGraph", setName);
if (fillGraph) {
g.warn("Can't use fillGraph option with error bars");
Dygraph.warn("Can't use fillGraph option with error bars");
}

var ctx = e.drawingContext;
Expand All @@ -606,7 +606,7 @@ DygraphCanvasRenderer._errorPlotter = function(e) {
var prevY = NaN;
var prevYs = [-1, -1];
// should be same color as the lines but only 15% opaque.
var rgb = new RGBColorParser(color);
var rgb = Dygraph.toRGB_(color);
var err_color =
'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + fillAlpha + ')';
ctx.fillStyle = err_color;
Expand Down Expand Up @@ -732,7 +732,7 @@ DygraphCanvasRenderer._fillPlotter = function(e) {
var prevYs = [-1, -1];
var newYs;
// should be same color as the lines but only 15% opaque.
var rgb = new RGBColorParser(color);
var rgb = Dygraph.toRGB_(color);
var err_color =
'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + fillAlpha + ')';
ctx.fillStyle = err_color;
Expand Down
2 changes: 0 additions & 2 deletions dygraph-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
// This list needs to be kept in sync w/ the one in generate-combined.sh
// and the one in jsTestDriver.conf.
var source_files = [
"strftime/strftime-min.js",
"rgbcolor/rgbcolor.js",
"stacktrace.js",
"dashed-canvas.js",
"dygraph-options.js",
Expand Down
12 changes: 6 additions & 6 deletions dygraph-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ DygraphLayout.prototype.setAnnotations = function(ann) {
for (var i = 0; i < ann.length; i++) {
var a = {};
if (!ann[i].xval && ann[i].x === undefined) {
this.dygraph_.error("Annotations must have an 'x' property");
Dygraph.error("Annotations must have an 'x' property");
return;
}
if (ann[i].icon &&
!(ann[i].hasOwnProperty('width') &&
ann[i].hasOwnProperty('height'))) {
this.dygraph_.error("Must set width and height when setting " +
"annotation.icon property");
Dygraph.error("Must set width and height when setting " +
"annotation.icon property");
return;
}
Dygraph.update(a, ann[i]);
Expand Down Expand Up @@ -199,9 +199,9 @@ DygraphLayout.prototype._evaluateLimits = function() {
axis.ylogrange = Dygraph.log10(axis.maxyval) - Dygraph.log10(axis.minyval);
axis.ylogscale = (axis.ylogrange !== 0 ? 1.0 / axis.ylogrange : 1.0);
if (!isFinite(axis.ylogrange) || isNaN(axis.ylogrange)) {
axis.g.error('axis ' + i + ' of graph at ' + axis.g +
' can\'t be displayed in log scale for range [' +
axis.minyval + ' - ' + axis.maxyval + ']');
Dygraph.error('axis ' + i + ' of graph at ' + axis.g +
' can\'t be displayed in log scale for range [' +
axis.minyval + ' - ' + axis.maxyval + ']');
}
}
}
Expand Down
Loading

0 comments on commit ee60939

Please sign in to comment.