Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cadbaa3
Added influxdb adapter
benFlightStats Aug 28, 2014
d26f989
clean up
benFlightStats Aug 28, 2014
21b901a
Fixed a couple of bugs.
benFlightStats Sep 2, 2014
d727334
Added length and xscale. still need to fix axis.
benFlightStats Sep 20, 2014
7ef2b5f
add horiz scaling
benFlightStats Sep 24, 2014
39143ff
remove files
benFlightStats Sep 24, 2014
20a2da8
clean untracked files
benFlightStats Sep 24, 2014
dad3395
Delete workspace.xml
benFlightStats Sep 24, 2014
85f6586
Delete vcs.xml
benFlightStats Sep 24, 2014
b0ff48f
Delete modules.xml
benFlightStats Sep 24, 2014
68031d6
Delete misc.xml
benFlightStats Sep 24, 2014
9b63967
Delete encodings.xml
benFlightStats Sep 24, 2014
f6f4013
Delete compiler.xml
benFlightStats Sep 24, 2014
548e354
Delete .name
benFlightStats Sep 24, 2014
9e38548
Delete scope_settings.xml
benFlightStats Sep 24, 2014
31e86ca
Delete profiles_settings.xml
benFlightStats Sep 24, 2014
6e05270
clean up names
benFlightStats Sep 24, 2014
dfc9642
Merge branch 'feature/scale_width' of https://github.com/benFlightSta…
benFlightStats Sep 24, 2014
1cc3235
Delete workspace.xml
benFlightStats Sep 24, 2014
af754e0
Merge pull request #1 from benFlightStats/feature/scale_width
benFlightStats Sep 24, 2014
1a7b51e
Added length and xscale. still need to fix axis.
benFlightStats Sep 28, 2014
c3f5f61
Merge pull request #2 from benFlightStats/bug/axis_rule_metric_not_tr…
benFlightStats Sep 29, 2014
941269d
add bower
benFlightStats Sep 29, 2014
5ba0d74
Merge branch 'master' of https://github.com/benFlightStats/cubism
benFlightStats Sep 29, 2014
a1bbcf5
Delete workspace.xml
benFlightStats Sep 29, 2014
f5a99b2
Make influx 1.0 compatible
JHK Jun 23, 2017
87e4ecc
Provide cubism.v1.js and cleanups
JHK Jun 23, 2017
b6ea9d4
Merge pull request #3 from JHK/master
benFlightStats Jun 27, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added length and xscale. still need to fix axis.
  • Loading branch information
benFlightStats committed Sep 20, 2014
commit d727334034a4f895cd8f3d889ccbedbdc5fd2cf1
18 changes: 15 additions & 3 deletions cubism.v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ cubism.context = function() {
var context = new cubism_context,
step = 1e4, // ten seconds, in milliseconds
size = 1440, // four hours at ten seconds, in pixels
length = 1440,
start0, stop0, // the start and stop for the previous change event
start1, stop1, // the start and stop for the next prepare event
serverDelay = 5e3,
clientDelay = 5e3,
event = d3.dispatch("prepare", "beforechange", "change", "focus"),
scale = context.scale = d3.time.scale().range([0, size]),
timeout,
xScale,
focus;

function update() {
xScale = size / length >= 1 ? size / length : 1;
var now = Date.now();
stop0 = new Date(Math.floor((now - serverDelay - clientDelay) / step) * step);
start0 = new Date(stop0 - size * step);
Expand All @@ -43,6 +46,9 @@ cubism.context = function() {
return context;
}

context.xScale = function(){
return xScale;
}
context.start = function() {
if (timeout) clearTimeout(timeout);
var delay = +stop1 + serverDelay - Date.now();
Expand Down Expand Up @@ -90,6 +96,11 @@ cubism.context = function() {
return update();
};

context.length = function(_) {
if (!arguments.length) return length;
length = +_;
return update();
};
// The server delay is the amount of time we wait for the server to compute a
// metric. This delay may result from clock skew or from delays collecting
// metrics from various hosts. Defaults to 4 seconds.
Expand Down Expand Up @@ -783,9 +794,10 @@ cubism_metricPrototype.divide = cubism_metricOperator("/", function(left, right)
});
cubism_contextPrototype.horizon = function() {
var context = this,
xScale = context.xScale(),
mode = "offset",
buffer = document.createElement("canvas"),
width = buffer.width = context.size(),
width = buffer.width = context.size() * xScale,
height = buffer.height = 30,
scale = d3.scale.linear().interpolate(d3.interpolateRound),
metric = cubism_identity,
Expand Down Expand Up @@ -875,7 +887,7 @@ cubism_contextPrototype.horizon = function() {
y1 = metric_.valueAt(i);
if (y1 <= 0) { negative = true; continue; }
if (y1 === undefined) continue;
canvas.fillRect(i, y1 = scale(y1), 1, y0 - y1);
canvas.fillRect(i*xScale, y1 = scale(y1), xScale, y0 - y1);
}
}

Expand All @@ -898,7 +910,7 @@ cubism_contextPrototype.horizon = function() {
for (var i = i0, n = width, y1; i < n; ++i) {
y1 = metric_.valueAt(i);
if (y1 >= 0) continue;
canvas.fillRect(i, scale(-y1), 1, y0 - scale(-y1));
canvas.fillRect(i*xScale, scale(-y1), xScale, y0 - scale(-y1));
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ cubism.context = function() {
var context = new cubism_context,
step = 1e4, // ten seconds, in milliseconds
size = 1440, // four hours at ten seconds, in pixels
length = 1440,
start0, stop0, // the start and stop for the previous change event
start1, stop1, // the start and stop for the next prepare event
serverDelay = 5e3,
clientDelay = 5e3,
event = d3.dispatch("prepare", "beforechange", "change", "focus"),
scale = context.scale = d3.time.scale().range([0, size]),
timeout,
xScale,
focus;

function update() {
xScale = size / length >= 1 ? size / length : 1;
var now = Date.now();
stop0 = new Date(Math.floor((now - serverDelay - clientDelay) / step) * step);
start0 = new Date(stop0 - size * step);
Expand All @@ -21,6 +24,9 @@ cubism.context = function() {
return context;
}

context.xScale = function(){
return xScale;
}
context.start = function() {
if (timeout) clearTimeout(timeout);
var delay = +stop1 + serverDelay - Date.now();
Expand Down Expand Up @@ -68,6 +74,11 @@ cubism.context = function() {
return update();
};

context.length = function(_) {
if (!arguments.length) return length;
length = +_;
return update();
};
// The server delay is the amount of time we wait for the server to compute a
// metric. This delay may result from clock skew or from delays collecting
// metrics from various hosts. Defaults to 4 seconds.
Expand Down
7 changes: 4 additions & 3 deletions src/horizon.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
cubism_contextPrototype.horizon = function() {
var context = this,
xScale = context.xScale(),
mode = "offset",
buffer = document.createElement("canvas"),
width = buffer.width = context.size(),
width = buffer.width = context.size() * xScale,
height = buffer.height = 30,
scale = d3.scale.linear().interpolate(d3.interpolateRound),
metric = cubism_identity,
Expand Down Expand Up @@ -92,7 +93,7 @@ cubism_contextPrototype.horizon = function() {
y1 = metric_.valueAt(i);
if (y1 <= 0) { negative = true; continue; }
if (y1 === undefined) continue;
canvas.fillRect(i, y1 = scale(y1), 1, y0 - y1);
canvas.fillRect(i*xScale, y1 = scale(y1), xScale, y0 - y1);
}
}

Expand All @@ -115,7 +116,7 @@ cubism_contextPrototype.horizon = function() {
for (var i = i0, n = width, y1; i < n; ++i) {
y1 = metric_.valueAt(i);
if (y1 >= 0) continue;
canvas.fillRect(i, scale(-y1), 1, y0 - scale(-y1));
canvas.fillRect(i*xScale, scale(-y1), xScale, y0 - scale(-y1));
}
}
}
Expand Down