From: Evert Timberg Date: Fri, 13 Nov 2015 15:01:38 +0000 (-0500) Subject: Update line sample to change the entire data object X-Git-Tag: 2.0.0-beta1~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1646%2Fhead;p=thirdparty%2FChart.js.git Update line sample to change the entire data object --- diff --git a/samples/line.html b/samples/line.html index 45cd9229c..0647173b4 100644 --- a/samples/line.html +++ b/samples/line.html @@ -19,6 +19,7 @@

+ @@ -147,6 +148,32 @@ updateLegend(); }); + $('#changeDataObject').click(function() { + config.data = { + labels: ["July", "August", "September", "October", "November", "December"], + datasets: [{ + label: "My First dataset", + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + fill: false, + }, { + label: "My Second dataset", + fill: false, + data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()], + }] + }; + + $.each(config.data.datasets, function(i, dataset) { + dataset.borderColor = randomColor(0.4); + dataset.backgroundColor = randomColor(0.5); + dataset.pointBorderColor = randomColor(0.7); + dataset.pointBackgroundColor = randomColor(0.5); + dataset.pointBorderWidth = 1; + }); + + // Update the chart + window.myLine.update(); + }); + $('#addDataset').click(function() { var newDataset = { label: 'Dataset ' + config.data.datasets.length,