Thanks for Mike Machado@machadolab!! This plugin is developed based on Google Column Chart the gentleman developed.
A Dashing widget to show a Google Line Chart on a dashboard.
Copy the google_line.coffee, google_line.html and google_line.scss file to into /widgets/google_line directory.
Add the following to the dashboard layout file:
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
</script>Then to include the widget on the dashboard, add the following item to your dashboard file:
<li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
<div data-id="mychart" data-view="GoogleLine" data-title="My Chart"></div>
</li>The following options can be added to the <div> of the chart object (defaults in parenthesis):
data-title- (no title) Title of the chartdata-colors- (Googles default colors) A comma separated list of colors to use for the chart barsdata-legend_position- (right) Position of the legend. One of 'bottom', 'left', 'in', 'none', 'right' or 'top'data-vaxis_format- (auto) A format string for numeric axis labels. One of 'none', 'decimal', 'scientific', 'currency', 'percent', 'short', 'long'data-curve_type- (none) Controls the curve of the lines when the line width is not zero. One of 'none', 'function'
The following would show vertical axis values in percent. e.g. 0.4 -> 40% , remove the legend and smooth the angles of the line:
<li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
<div data-id="mychart" data-view="GoogleLine" data-legend_position="none" data-vaxis_format="percent" data-curve_type="function" data-title="My Chart"></div>
</li>To send data to the chart, use send_event to send an item called points with a two dimensional array.
Make sure the first "row" in the array is an array of headers for the data.
For example:
send_event('mychart', points: [
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
])
How do I change the background color on the widget?