Multi-graph widget for Shopify's dashing to display a comparison style graph (or stacked with a minor modification). Obviously, this is an example that is built heavily on the existing graph widget that is provided with dashing. This widget provides a more clear framework for expanding the graph for multiple series (or nodes) of data. After seeing the example code, it should be fairly easy to expand to 3 or more overlaid graphs (although colors might get tricky). And really, this is just a slightly greater use of the cool rickshaw graphs.
To use this widget:
- copy
mgraph.coffee
,mgraph.html
andmgraph.scss
into a new/widgets/mgraph
folder - copy
multitest.rb
into your/jobs
folder
Then include the widget in a dashboard, by adding the following snippet to your dashboard layout file:
- For a nice 2 tile-wide widget:
<li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
<div data-id="multitest" data-view="Mgraph" data-title="Multi Convergence" style="background-color:#ff9618"></div>
</li>
@alexminnaar
Hey I modified the file as
class Dashing.Mgraph extends Dashing.Widget
@Accessor 'current', ->
return @get('displayedValue') if @get('displayedValue')
points = @get('points')
if points
points[0][points[0].length - 1].y + ' / ' + points[1][points[1].length - 1].y + ' / ' + points[2][points[2].length - 1].y
ready: ->
container = $(@node).parent()
# Gross hacks. Let's fix this.
width = (Dashing.widget_base_dimensions[0] * container.data("sizex")) + Dashing.widget_margins[0] * 2 * (container.data("sizex") - 1)
height = (Dashing.widget_base_dimensions[1] * container.data("sizey"))
@graph = new Rickshaw.Graph(
element: @node
width: width
height: height
renderer: 'area'
stroke: true
series: [
{
color: "#fff",
data: [{x:0, y:0}]
},
{
color: "#222",
data: [{x:0, y:0}]
},
{
color: "#333",
data: [{x:0, y:0}]
}
]
)
onData: (data) ->
if @graph
@graph.series[0].data = data.points[0]
@graph.series[1].data = data.points[1]
@graph.series[2].data = data.points[2]
And its working fine.
PS: Try restarting the dashing service