timeserieswidget
timeserieswidget copied to clipboard
support lineMode=staircase for flot
nice project!
It is likely I'm Doing This Wrong, so I'm not doing a full branch.
But this patch adds staircase mode to Flot.
--- a/jquery.tswidget.js
+++ b/jquery.tswidget.js
@@ -166,6 +166,12 @@ function find_definition (target_graphite, options) {
if(resp_graphite.length == 0 ) {
console.warn("no data in graphite response");
}
+
+ var lineMode = false;
+ if ('lineMode' in options && options['lineMode'] == 'staircase') {
+ lineMode = true;
+ }
+
for (var res_i = 0; res_i < resp_graphite.length; res_i++) {
var target = find_definition(resp_graphite[res_i], options);
target.label = target.name // flot wants 'label'
@@ -184,11 +190,11 @@ function find_definition (target_graphite, options) {
// default config state modifiers (you can override them in your config objects)
var states = {
'stacked': {
- 'series': {'stack': true, 'lines': {'show': true, 'lineWidth': 0, 'fill': 1}},
+ 'series': {'stack': true, 'lines': {'show': true, 'lineWidth': 0, 'fill': 1, 'steps': lineMode}},
},
'lines': {
// flot lib wants 0 or null. not false o_O
- 'series': {'stack': null, 'lines': { 'show': true, 'lineWidth': 0.6, 'fill': false }}
+ 'series': {'stack': null, 'lines': { 'show': true, 'lineWidth': 0.6, 'fill': false, 'steps': lineMode }}
}
};