Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support lineMode=staircase for flot #2

Open
client9 opened this issue Feb 18, 2013 · 3 comments
Open

support lineMode=staircase for flot #2

client9 opened this issue Feb 18, 2013 · 3 comments

Comments

@client9
Copy link

client9 commented Feb 18, 2013

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 }}
                 }
             };
@Dieterbe
Copy link

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

@client9
Copy link
Author

client9 commented Apr 23, 2013

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.

@Dieterbe
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants