timeserieswidget icon indicating copy to clipboard operation
timeserieswidget copied to clipboard

support lineMode=staircase for flot

Open client9 opened this issue 12 years ago • 3 comments

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 }}
                 }
             };

client9 avatar Feb 18 '13 06:02 client9

I couldn't find any mention of "linemode" in the flot documentation? can you explain more what you're trying to do?

Dieterbe avatar Apr 22 '13 15:04 Dieterbe

http://graphite.readthedocs.org/en/0.9.10/render_api.html#linemode

is the same as

"steps" in blots https://github.com/flot/flot/blob/master/API.md

For lines, "steps" specifies whether two adjacent data points are connected with a straight (possibly diagonal) line or with first a horizontal and then a vertical line. Note that this transforms the data by adding extra points.

(more or less)

On 2013/04/23, at 0:55, Dieter Plaetinck [email protected] wrote:

I couldn't find any mention of "linemode" in the flot documentation? can you explain more what you're trying to do?

$B!=(B Reply to this email directly or view it on GitHub.

client9 avatar Apr 23 '13 07:04 client9

right, now I get it. Your approach actually looks pretty right, but i would set steps = true, not lineMode, in that first branch, because we're setting flot options based on graphite options. it's awkward to use graphite terminology in the actual flot config.

Dieterbe avatar Apr 23 '13 14:04 Dieterbe