Skip to content

Commit

Permalink
Merge pull request #3 from danvk/master
Browse files Browse the repository at this point in the history
Get last version
  • Loading branch information
manufitoussi committed Jan 30, 2013
2 parents 547dc58 + edef826 commit 90ccd1c
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 80 deletions.
4 changes: 2 additions & 2 deletions closure-todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ x dygraph-tickers.js
x dygraph-options-reference.js
x dygraph-utils.js
x dashed-canvas.js
- dygraph-plugin-base.js
- dygraph-plugin-install.js

Plugins:
- plugins/annotations.js
- plugins/axes.js
- plugins/base.js
- plugins/chart-labels.js
- plugins/grid.js
- plugins/install.js
- plugins/legend.js

Here's a command that can be used to build dygraphs using the closure
Expand Down
7 changes: 7 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,13 @@ <h2 id="ie">Internet Explorer Compatibility</h2>

<p>Most browsers will ignore the trailing comma, but it will break under IE.</p>

<p>You may also need to delay instantiating any dygraphs until after the DOM
content is ready, as there have been some <a
href="https://groups.google.com/d/topic/dygraphs-users/qPX4Syx2kz8/discussion">reports</a>
that excanvas won't work until this happens. If you're using jQuery, this
means drawing your charts inside of a <code>$(function() { ... })</code>
block.</p>

<h2 id="gviz">GViz Data</h2>

<p>The <a
Expand Down
4 changes: 2 additions & 2 deletions dygraph-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"dygraph-gviz.js",
"dygraph-interaction-model.js",
"dygraph-tickers.js",
"plugins/base.js",
"dygraph-plugin-base.js",
"plugins/annotations.js",
"plugins/axes.js",
"plugins/chart-labels.js",
"plugins/grid.js",
"plugins/legend.js",
"plugins/range-selector.js",
"plugins/install.js",
"dygraph-plugin-install.js",
"dygraph-options-reference.js" // Shouldn't be included in generate-combined.sh
];

Expand Down
6 changes: 3 additions & 3 deletions dygraph-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ DygraphOptions.prototype.reparseSeries = function() {
*/
DygraphOptions.prototype.get = function(name) {
var result = this.getGlobalUser_(name);
if (result != null) {
if (result !== null) {
return result;
}
return this.getGlobalDefault_(name);
Expand Down Expand Up @@ -237,7 +237,7 @@ DygraphOptions.prototype.getForAxis = function(name, axis) {
// Since axis can be a number or a string, straighten everything out here.
if (typeof(axis) == 'number') {
axisIdx = axis;
axisString = axisIdx == 0 ? "y" : "y2";
axisString = axisIdx === 0 ? "y" : "y2";
} else {
if (axis == "y1") { axis = "y"; } // Standardize on 'y'. Is this bad? I think so.
if (axis == "y") {
Expand All @@ -264,7 +264,7 @@ DygraphOptions.prototype.getForAxis = function(name, axis) {

// User-specified global options second.
var result = this.getGlobalUser_(name);
if (result != null) {
if (result !== null) {
return result;
}

Expand Down
4 changes: 4 additions & 0 deletions dygraph-plugin-base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*global Dygraph:false */

// Namespace for plugins. Load this before plugins/*.js files.
Dygraph.Plugins = {};
1 change: 0 additions & 1 deletion plugins/install.js → dygraph-plugin-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// This is most relevant for plugins which register a layout event, e.g.
// Axes, Legend and ChartLabels.

// TODO(danvk): move this into the top-level directory. Only plugins here.
Dygraph.PLUGINS.push(
Dygraph.Plugins.Legend,
Dygraph.Plugins.Axes,
Expand Down
48 changes: 26 additions & 22 deletions dygraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -956,23 +956,27 @@ Dygraph.prototype.createInterface_ = function() {

var dygraph = this;

this.mouseMoveHandler = function(e) {
dygraph.mouseMove_(e);
};
this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler);
// Don't recreate and register the handlers on subsequent calls.
// This happens when the graph is resized.
if (!this.mouseMoveHandler_) {
this.mouseMoveHandler_ = function(e) {
dygraph.mouseMove_(e);
};
this.addEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler_);

this.mouseOutHandler = function(e) {
dygraph.mouseOut_(e);
};
this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler);
this.mouseOutHandler_ = function(e) {
dygraph.mouseOut_(e);
};
this.addEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler_);

this.resizeHandler = function(e) {
dygraph.resize();
};
this.resizeHandler_ = function(e) {
dygraph.resize();
};

// Update when the window is resized.
// TODO(danvk): drop frames depending on complexity of the chart.
this.addEvent(window, 'resize', this.resizeHandler);
// Update when the window is resized.
// TODO(danvk): drop frames depending on complexity of the chart.
this.addEvent(window, 'resize', this.resizeHandler_);
}
};

/**
Expand All @@ -998,9 +1002,14 @@ Dygraph.prototype.destroy = function() {
this.registeredEvents_ = [];

// remove mouse event handlers (This may not be necessary anymore)
Dygraph.removeEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler);
Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler);
Dygraph.removeEvent(this.mouseEventElement_, 'mouseout', this.mouseOutHandler_);
Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseMoveHandler_);
Dygraph.removeEvent(this.mouseEventElement_, 'mousemove', this.mouseUpHandler_);

// remove window handlers
Dygraph.removeEvent(window,'resize',this.resizeHandler_);
this.resizeHandler_ = null;

removeRecursive(this.maindiv_);

var nullOut = function(obj) {
Expand All @@ -1010,9 +1019,6 @@ Dygraph.prototype.destroy = function() {
}
}
};
// remove event handlers
Dygraph.removeEvent(window,'resize',this.resizeHandler);
this.resizeHandler = null;
// These may not all be necessary, but it can't hurt...
nullOut(this.layout_);
nullOut(this.plotter_);
Expand Down Expand Up @@ -2361,9 +2367,7 @@ Dygraph.prototype.drawGraph_ = function() {

if (this.attr_("timingName")) {
var end = new Date();
if (console) {
console.log(this.attr_("timingName") + " - drawGraph: " + (end - start) + "ms");
}
Dygraph.info(this.attr_("timingName") + " - drawGraph: " + (end - start) + "ms");
}
};

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions file-size-stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ dygraph-tickers.js \
rgbcolor/rgbcolor.js \
strftime/strftime-min.js \
dashed-canvas.js \
plugins/base.js \
dygraph-plugin-base.js \
plugins/annotations.js \
plugins/axes.js \
plugins/range-selector.js \
plugins/chart-labels.js \
plugins/grid.js \
plugins/legend.js \
plugins/install.js \
dygraph-plugin-install.js \
; do
base_size=$(cat $file | wc -c)
cat $file \
Expand Down
90 changes: 58 additions & 32 deletions generate-combined.sh
Original file line number Diff line number Diff line change
@@ -1,39 +1,65 @@
#!/bin/bash
# Generates a single JS file that's easier to include.

GetSources () {
# This list needs to be kept in sync w/ the one in dygraph-dev.js
# and the one in jsTestDriver.conf. Order matters, except for the plugins.
for F in \
strftime/strftime-min.js \
rgbcolor/rgbcolor.js \
stacktrace.js \
dashed-canvas.js \
dygraph-options.js \
dygraph-layout.js \
dygraph-canvas.js \
dygraph.js \
dygraph-utils.js \
dygraph-gviz.js \
dygraph-interaction-model.js \
dygraph-tickers.js \
dygraph-plugin-base.js \
plugins/*.js \
dygraph-plugin-install.js
do
echo "$F"
done
}

# Pack all the JS together.
CatSources () {
GetSources \
| xargs cat \
| perl -ne 'print unless m,REMOVE_FOR_COMBINED,..m,/REMOVE_FOR_COMBINED,'
}

# This list needs to be kept in sync w/ the one in dygraph-dev.js
# and the one in jsTestDriver.conf.
cat \
strftime/strftime-min.js \
rgbcolor/rgbcolor.js \
stacktrace.js \
dashed-canvas.js \
dygraph-options.js \
dygraph-layout.js \
dygraph-canvas.js \
dygraph.js \
dygraph-utils.js \
dygraph-gviz.js \
dygraph-interaction-model.js \
dygraph-tickers.js \
plugins/base.js \
plugins/annotations.js \
plugins/axes.js \
plugins/chart-labels.js \
plugins/grid.js \
plugins/legend.js \
plugins/range-selector.js \
plugins/install.js \
| perl -ne 'print unless m,REMOVE_FOR_COMBINED,..m,/REMOVE_FOR_COMBINED,' \
> /tmp/dygraph.js
Copyright () {
echo '/*! @license Copyright 2011 Dan Vanderkam (danvdk@gmail.com) MIT-licensed (http://opensource.org/licenses/MIT) */'
}

java -jar yuicompressor-2.4.2.jar /tmp/dygraph.js \
> /tmp/dygraph-packed.js
CatCompressed () {
Copyright
CatSources \
| java -jar yuicompressor-2.4.2.jar --type js
}

(
echo '/*! @license Copyright 2011 Dan Vanderkam (danvdk@gmail.com) MIT-licensed (http://opensource.org/licenses/MIT) */'
cat /tmp/dygraph-packed.js
) > dygraph-combined.js
chmod a+r dygraph-combined.js
ACTION="${1:-update}"
case "$ACTION" in
ls)
GetSources
;;
cat)
Copyright
CatSources
;;
compress*|cat_compress*)
CatCompressed
;;
update)
CatCompressed > dygraph-combined.js
chmod a+r dygraph-combined.js
;;
*)
echo >&2 "Unknown action '$ACTION'"
exit 1
;;
esac
12 changes: 3 additions & 9 deletions jsTestDriver.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ load:
- dygraph-tickers.js
- dygraph-dev.js
- excanvas.js
# NOTE: we can't do plugins/*.js because the order is important.
- plugins/base.js
- plugins/annotations.js
- plugins/axes.js
- plugins/range-selector.js
- plugins/chart-labels.js
- plugins/grid.js
- plugins/legend.js
- plugins/install.js
- dygraph-plugin-base.js
- plugins/*.js
- dygraph-plugin-install.js
- auto_tests/tests/*.js
3 changes: 2 additions & 1 deletion phantom-driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ RunAllAutoTests(function(num_failing, num_passing) {
if (num_failing !== 0) {
console.log('FAIL');
phantom.exit();
} else {
console.log('PASS');
}
console.log('PASS');
phantom.exit();

// This is not yet reliable enough to be useful:
Expand Down
6 changes: 0 additions & 6 deletions plugins/base.js

This file was deleted.

48 changes: 48 additions & 0 deletions tests/css-positioning.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7; IE=EmulateIE9">
<title>demo</title>
<!--[if IE]>
<script type="text/javascript" src="../excanvas.js"></script>
<![endif]-->
<script type="text/javascript" src="../dygraph-dev.js"></script>
<style>
html, body {
/*
max-width: 800px;
height: 100%;
margin-right: auto;
*/
margin-left: 100px;
}
</style>
</head>
<body>
<p>Mouseovers should work as expected (dots should align with mouse)</p>
<div id="demodiv"></div>

<script type="text/javascript">
g = new Dygraph(
document.getElementById("demodiv"),
function() {
var zp = function(x) { if (x < 10) return "0"+x; else return x; };
var r = "date,parabola,line,another line,sine wave\n";
for (var i=1; i<=31; i++) {
r += "200610" + zp(i);
r += "," + 10*(i*(31-i));
r += "," + 10*(8*i);
r += "," + 10*(250 - 8*i);
r += "," + 10*(125 + 125 * Math.sin(0.3*i));
r += "\n";
}
return r;
},
{
labelsKMB: true,
legend: 'always'
}
);
</script>
</body>
</html>

0 comments on commit 90ccd1c

Please sign in to comment.