projects
/
dygraphs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Decent optimziation by precomputing hasNext, saves about 3%
[dygraphs.git]
/
dygraph-tickers.js
diff --git
a/dygraph-tickers.js
b/dygraph-tickers.js
index
b91b82f
..
b9815fe
100644
(file)
--- a/
dygraph-tickers.js
+++ b/
dygraph-tickers.js
@@
-170,12
+170,12
@@
Dygraph.numericTicks = function(a, b, pixels, opts, dygraph, vals) {
var k_labels = [];
if (opts("labelsKMB")) {
k = 1000;
var k_labels = [];
if (opts("labelsKMB")) {
k = 1000;
- k_labels = [ "K", "M", "B", "T" ];
+ k_labels = [ "K", "M", "B", "T"
, "Q"
];
}
if (opts("labelsKMG2")) {
if (k) Dygraph.warn("Setting both labelsKMB and labelsKMG2. Pick one!");
k = 1024;
}
if (opts("labelsKMG2")) {
if (k) Dygraph.warn("Setting both labelsKMB and labelsKMG2. Pick one!");
k = 1024;
- k_labels = [ "k", "M", "G", "T" ];
+ k_labels = [ "k", "M", "G", "T"
, "P", "E"
];
}
var formatter = opts('axisLabelFormatter');
}
var formatter = opts('axisLabelFormatter');
@@
-190,8
+190,8
@@
Dygraph.numericTicks = function(a, b, pixels, opts, dygraph, vals) {
if (k_labels.length > 0) {
// TODO(danvk): should this be integrated into the axisLabelFormatter?
// Round up to an appropriate unit.
if (k_labels.length > 0) {
// TODO(danvk): should this be integrated into the axisLabelFormatter?
// Round up to an appropriate unit.
- var n =
k*k*k*k
;
- for (j =
3
; j >= 0; j--, n /= k) {
+ var n =
Math.pow(k, k_labels.length)
;
+ for (j =
k_labels.length - 1
; j >= 0; j--, n /= k) {
if (absTickV >= n) {
label = Dygraph.round_(tickV / n, opts('digitsAfterDecimal')) +
k_labels[j];
if (absTickV >= n) {
label = Dygraph.round_(tickV / n, opts('digitsAfterDecimal')) +
k_labels[j];
@@
-331,6
+331,7
@@
Dygraph.getDateAxis = function(start_time, end_time, granularity, opts, dg) {
// for this granularity.
var g = spacing / 1000;
var d = new Date(start_time);
// for this granularity.
var g = spacing / 1000;
var d = new Date(start_time);
+ d.setMilliseconds(0);
var x;
if (g <= 60) { // seconds
x = d.getSeconds(); d.setSeconds(x - x % g);
var x;
if (g <= 60) { // seconds
x = d.getSeconds(); d.setSeconds(x - x % g);