Permalink
Browse files

Merge branch 'master' of git://github.com/danvk/dygraphs

Conflicts:
	dygraph.js
  • Loading branch information...
2 parents d4139cd + 029da4b commit 8d34158cad7690d8ba23c863eafe804ff66d94dd Nikhil Kasinadhuni committed Mar 11, 2010
Showing with 15 additions and 10 deletions.
  1. +1 −1 dygraph-combined.js
  2. +7 −6 dygraph.js
  3. +1 −2 tests/callback.html
  4. +6 −1 tests/labelsKMB.html
View
Oops, something went wrong.
View
@@ -94,7 +94,7 @@ Dygraph.DEFAULT_ATTRS = {
labelsKMG2: false,
showLabelsOnHighlight: true,
- yValueFormatter: null,
+ yValueFormatter: function(x) { return Dygraph.round_(x, 2); },
strokeWidth: 1.0,
@@ -902,9 +902,10 @@ Dygraph.prototype.mouseMove_ = function(event) {
this.selPoints_ = [];
var cumulative_sum = 0; // used only if we have a stackedGraph.
var l = points.length;
+ var isStacked = this.attr_("stackedGraph");
for (var i = l - 1; i >= 0; i--) {
if (points[i].xval == lastx) {
- if (!this.attr_("stackedGraph")) {
+ if (!isStacked) {
this.selPoints_.unshift(points[i]);
} else {
// Clone the point, since we need to 'unstack' it below. Stacked points
@@ -968,7 +969,7 @@ Dygraph.prototype.updateSelection_ = function() {
}
var point = this.selPoints_[i];
var c = new RGBColor(this.colors_[i%clen]);
- var yval = fmtFunc ? fmtFunc(point.yval) : this.round_(point.yval, 2);
+ var yval = fmtFunc(point.yval);
replace += " <b><font color='" + c.toHex() + "'>"
+ point.name + "</font></b>:"
+ yval;
@@ -1123,7 +1124,7 @@ Dygraph.dateString_ = function(date, self) {
* @return {Number} The rounded number
* @private
*/
-Dygraph.prototype.round_ = function(num, places) {
+Dygraph.round_ = function(num, places) {
var shift = Math.pow(10, places);
return Math.round(num * shift)/shift;
};
@@ -1399,13 +1400,13 @@ Dygraph.numericTicks = function(minV, maxV, self) {
for (var i = 0; i < nTicks; i++) {
var tickV = low_val + i * scale;
var absTickV = Math.abs(tickV);
- var label = self.round_(tickV, 2);
+ var label = Dygraph.round_(tickV, 2);
if (k_labels.length) {
// Round up to an appropriate unit.
var n = k*k*k*k;
for (var j = 3; j >= 0; j--, n /= k) {
if (absTickV >= n) {
- label = self.round_(tickV / n, 1) + k_labels[j];
+ label = Dygraph.round_(tickV / n, 1) + k_labels[j];
break;
}
}
View
@@ -28,7 +28,7 @@
<input type="checkbox" id="highlight" checked><label for="highlight"> Show 'highlight' events</label>
<input type="checkbox" id="showLabels" checked
onclick='g.updateOptions({showLabelsOnHighlight: this.checked});'>
- <label for="highlight"> Show Labels on highlight</label>
+ <label for="showLabels"> Show Labels on highlight</label>
<div id="status" style="width:100%; height:200px;"></div>
<script type="text/javascript">
@@ -57,7 +57,6 @@
rollPeriod: 7,
showRoller: true,
errorBars: true,
- showLabelsOnHighlight: true,
highlightCallback: function(e, x, pts) {
if (document.getElementById('highlight').checked) {
@@ -22,6 +22,11 @@
'M', 'B', etc. labels.</p>
<script type="text/javascript">
+ function round(num, places) {
+ var shift = Math.pow(10, places);
+ return Math.round(num * shift)/shift;
+ };
+
var data = [];
for (var i = 0, n = 1; i < 43; i++, n *= 2) {
data.push([i, n]);
@@ -34,7 +39,7 @@
var magnitude = Math.floor(String(Math.floor(v)).length / 3);
if (magnitude > suffixes.length - 1)
magnitude = suffixes.length - 1;
- return String(g.round_(v / Math.pow(10, magnitude * 3), 2)) +
+ return String(round(v / Math.pow(10, magnitude * 3), 2)) +
suffixes[magnitude];
}

0 comments on commit 8d34158

Please sign in to comment.