Sha256: 14ad70ba116a1fcc2921264ca946c2fe45e6ffc49d44dacd0dcbd43b5b661609
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
Dasht.chart_init = function(el, options) { var chart = $(el).find(".chart"); var chart_el = chart.get()[0]; var old_data = 0; Dasht.fill_tile(chart); // Create some empty values. var labels = []; var data = []; for (var i = 0; i < options.periods; i++) { labels.push(""); data.push(0); } // Create the chart. var chart_data = { labels: labels, datasets: [ { fillColor: "rgba(255,255,255,0.2)", strokeColor: "rgba(255,255,255,0.4)", data: data } ] }; var chart_options = { showScale: false, showTooltips: false, pointDot : false } var ctx = $(".chart").get(0).getContext("2d"); var chart = new Chart(ctx).Line(chart_data, chart_options); // Handle value updates. setTimeout(function() { Dasht.get_value(options, function(new_data) { if (_.isEqual(old_data, new_data)) return; // Update chart. for (var i = 0; i < options.periods; i++) { chart.datasets[0].points[i].value = new_data[i]; } chart.update(); old_data = new_data; }); }, 1000); }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dasht-0.1.0 | assets/plugins/chart.js |