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

Setting graph width in pixels from dashboards.js metrics #69

Closed
Borillion opened this issue Dec 31, 2015 · 8 comments
Closed

Setting graph width in pixels from dashboards.js metrics #69

Borillion opened this issue Dec 31, 2015 · 8 comments

Comments

@Borillion
Copy link

When setting the width as 500px in the metrics its not being obeyed, <svg width="375" ...
Am I doing this wrong?

dashboard.js snippet

  "metrics": 
    [
      {
        "alias":"Carbon Statistics",
        "targets": ["sumSeries(carbon.agents.localhost_localdomain-a.cpuUsage)",
                    "sumSeries(carbon.agents.localhost_localdomain-a.memUsage)"],
        "renderer":"line",
        "interpolation":"cardinal",
    "unstack":"true",
       "height":"500", 
 **--->"width":"500"<---**
        }
    ]

......
<div class="span4" id="graph-0">
      <h2>Carbon Statistics <span class="pull-right graph-summary"><span></span></span></h2>
      <div class="chart rickshaw_graph">
**->  <svg width="357" height="500"> <--**
              <path class="path" ....
@gingerlime
Copy link

Not entirely sure why it doesn't work, because these parameters are simply passed over to Rickshaw, which should support it. Perhaps I need to update the version of Rickshaw, but it hasn't been updated in a while as far as I can tell.

I think the best way to set the width is by controlling the html element, via css. This falls back on the element width and should automatically adjust correctly.

@gingerlime
Copy link

I updated giraffe to use the latest version of rickshaw. Could you check if it makes a difference?

@Borillion
Copy link
Author

So I went ahead and cloned the new code. It doesn't seem to read or set the width in rickshaw.
I am looking through the code to figure out how this works. Do you happen to recall how
class="chart rickshaw_graph" is created? rickshaw_graph is in the css. I am however not seeing "chart" anywhere. Thanks for the help gingerlime, much appreciated!

@Borillion
Copy link
Author

So on line 281 in giraffe.js it has "width: $("" + anchor + " .chart").width()," changing that to "width: metric.width || 300," fixes the issue. Would you like to go ahead and update your giraffe.coffee/giraffe.js ?
It does not appear to have ties to css here.

@gingerlime
Copy link

You're referring to the compiled javascript. The source files is giraffe.coffee. However, this is the code that picks the width from the CSS element, which makes sense to me more than relying on passing the width via javascript. Any particular reason why you prefer to pass the width instead of set it based on the container element CSS ?

@gingerlime
Copy link

just pushed a change that should fix this. Would be great if you could test and let me know if it works for you. Thanks for reporting this.

@Borillion
Copy link
Author

Sorry took a while to get back gingerlime, it works great! Thanks for the help.

@gingerlime
Copy link

Thanks for reporting this and for testing and letting me know. Glad to hear it's working now :)

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