Shopify / dashing

The exceptionally handsome dashboard framework in Ruby and Coffeescript.
http://shopify.github.com/dashing/
MIT License
10.98k stars 1.18k forks source link

Add a way to graph the results of a job that only returns a single data point #699

Open cweagans opened 8 years ago

cweagans commented 8 years ago

It would be awesome if I could generate a graph from a job that only returns a single data point. As a contrived example, if I have a job that retrieves my Hacker News karma every hour, it would be useful to generate a graph of the last n values without having to have the Hacker News API support retrieving historical values (which it doesn't). This is probably much more useful for a dashboard that's more oriented toward tracking social stats, since server monitoring and the like is likely to have historical value tracking anyway.

terraboops commented 8 years ago

Make the job collect an array of hashes with values for x and y...

Please close this and direct support requests to Stack Overflow.

cweagans commented 8 years ago

Not really a support request. I know how I could implement support for this in my jobs - it would be fairly straightforward to do this on my own. I'm saying that it's a reasonably common need, and that having some generic, built-in way to do this inside of Dashing would be helpful, so this is therefore a feature request.

terraboops commented 8 years ago

It would be easy to fork that widget and make one that accumulates values in the client... However, you won't persist those values to the history unless you're passing an array to {{send_event}}. If the values aren't persisted to history and only in the client, they'll be lost when you refresh. I would recommend that you instead create an array inside your job and accumulate values in it and send them out to the clients. You might also want to think about whether that array should have a maximum size.

The default Convergence job implements the behaviour I am describing, out of the box with a fresh project: https://github.com/Shopify/dashing/blob/a4a4564f760bb1bcd541366186cd46488d5a569b/templates/project/jobs/convergence.rb

I'm not sure why we want a more generic way to create arrays than what ruby provides. The upcoming release of Dashing under Puma is also multithreaded, so access to the collection in this generic function you're proposing would need to be synchronized. I don't want to do that, unless it's for a good reason.