]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Update samples to no longer use old functions and instead modify the data directly 1478/head
authorEvert Timberg <evert.timberg@gmail.com>
Tue, 22 Sep 2015 01:00:58 +0000 (21:00 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Tue, 22 Sep 2015 01:00:58 +0000 (21:00 -0400)
samples/bar.html
samples/combo-time-scale.html
samples/doughnut.html
samples/line-logarithmic.html
samples/line-scale-override.html
samples/line-time-scale.html
samples/line-x-axis-filter.html
samples/line.html
samples/pie.html
samples/polar-area.html
samples/radar.html

index 526fd8e5a2d076d4737a7d0f0a6c5198cc05d63e..bb8c884c7ee2b3eeeb7d345b8d5137d50c9c93a5 100644 (file)
                 newDataset.data.push(randomScalingFactor());
             }
 
-            window.myBar.addDataset(newDataset, 1);
+            barChartData.datasets.push(newDataset);
+            window.myBar.update();
             updateLegend();
         });
 
                 barChartData.labels.push('data #' + barChartData.labels.length);
 
                 for (var index = 0; index < barChartData.datasets.length; ++index) {
-                    window.myBar.addData(randomScalingFactor(), index);
+                    //window.myBar.addData(randomScalingFactor(), index);
+                    barChartData.datasets[index].data.push(randomScalingFactor());
                 }
 
+                window.myBar.update();
                 updateLegend();
             }
         });
 
         $('#removeDataset').click(function() {
-            window.myBar.removeDataset(0);
+            barChartData.datasets.splice(0, 1);
+            window.myBar.update();
             updateLegend();
         });
 
             barChartData.labels.splice(-1, 1); // remove the label first
 
             barChartData.datasets.forEach(function(dataset, datasetIndex) {
-                window.myBar.removeData(datasetIndex, -1);
+                dataset.data.pop();
             });
+
+            window.myBar.update();
             updateLegend();
         });
 
index 548202e2cad25457eb7bb077bcb53c8c99e3a0c4..081683eed8bd5f0ef6d5ad669606cc32fcc70520 100644 (file)
                 newDataset.data.push(randomScalingFactor());
             }
 
-            window.myLine.addDataset(newDataset);
+            config.data.datasets.push(newDataset);
+            window.myLine.update();
             updateLegend();
         });
 
                 );
 
                 for (var index = 0; index < config.data.datasets.length; ++index) {
-                    window.myLine.addData(randomScalingFactor(), index);
+                    config.data.datasets[index].data.push(randomScalingFactor());
                 }
 
+                window.myLine.update();
                 updateLegend();
             }
         });
 
         $('#removeDataset').click(function() {
-            window.myLine.removeDataset(0);
+            config.data.datasets.splice(0, 1);
+            window.myLine.update();
             updateLegend();
         });
 
             config.data.labels.splice(-1, 1); // remove the label first
 
             config.data.datasets.forEach(function(dataset, datasetIndex) {
-                window.myLine.removeData(datasetIndex, -1);
+                config.data.datasets[datasetIndex].data.pop();
             });
 
+            window.myLine.update();
             updateLegend();
         });
     </script>
index ae6bbc9e585926dff21e1862bab45bbd9047aec8..728c8847ae80f8525cbff856174ccfd5aecdd4e0 100644 (file)
             newDataset.backgroundColor.push(randomColor(0.7));
         }
 
-        window.myDoughnut.addDataset(newDataset);
+        config.data.datasets.push(newDataset);
+        window.myDoughnut.update();
         updateLegend();
     });
 
             config.data.labels.push('data #' + config.data.labels.length);
 
             $.each(config.data.datasets, function(index, dataset) {
-                window.myDoughnut.addData(randomScalingFactor(), index, dataset.data.length, randomColor(0.7));
+                dataset.data.push(randomScalingFactor());
+                dataset.backgroundColor.push(randomColor(0.7));
             });
 
+            window.myDoughnut.update();
             updateLegend();
         }
     });
 
     $('#removeDataset').click(function() {
-        window.myDoughnut.removeDataset(0);
+        config.data.datasets.splice(0, 1);
+        window.myDoughnut.update();
         updateLegend();
     });
 
         config.data.labels.splice(-1, 1); // remove the label first
 
         config.data.datasets.forEach(function(dataset, datasetIndex) {
-            window.myDoughnut.removeData(datasetIndex, -1);
+            dataset.data.pop();
+            dataset.backgroundColor.pop();
         });
 
+        window.myDoughnut.update();
         updateLegend();
     });
     </script>
index 21159e6ee86a79d7389a5d82587c6977c5543dc6..61349901069da8a19b89a76570ce6dae25ddbd60 100644 (file)
             newDataset.data.push(randomScalingFactor());
         }
 
-        window.myLine.addDataset(newDataset);
+        config.data.datasets.push(newDataset);
+        window.myLine.update();
         updateLegend();
     });
 
             config.data.labels.push('dataset #' + config.data.labels.length);
 
             for (var index = 0; index < config.data.datasets.length; ++index) {
-                window.myLine.addData(randomScalingFactor(), index);
+                config.data.datasets[index].data.push(randomScalingFactor());
             }
 
+            window.myLine.update();
             updateLegend();
         }
     });
 
     $('#removeDataset').click(function() {
-        window.myLine.removeDataset(0);
+        config.data.datasets.splice(0, 1);
+        window.myLine.update();
         updateLegend();
     });
 
         config.data.labels.splice(-1, 1); // remove the label first
 
         config.data.datasets.forEach(function(dataset, datasetIndex) {
-            window.myLine.removeData(datasetIndex, -1);
+            dataset.data.pop();
         });
 
+        window.myLine.update();
         updateLegend();
     });
     </script>
index 6603b5c043db17da7e4b765c89dc0a5b98e4c3ca..a92b14a1bae5122f6bd8d627d4faf27b25d2e446 100644 (file)
             newDataset.data.push(randomScalingFactor());
         }
 
-        window.myLine.addDataset(newDataset);
+        config.data.datasets.push(newDataset);
+        window.myLine.update();
     });
 
     $('#addData').click(function() {
             config.data.labels.push('dataset #' + config.data.labels.length);
 
             for (var index = 0; index < config.data.datasets.length; ++index) {
-                window.myLine.addData(randomScalingFactor(), index);
+                config.data.datasets[index].data.push(randomScalingFactor());
             }
+
+            window.myLine.update();
         }
     });
 
     $('#removeDataset').click(function() {
-        window.myLine.removeDataset(0);
+        config.data.datasets.splice(0, 1);
+        window.myLine.update();
     });
 
     $('#removeData').click(function() {
         config.data.labels.splice(-1, 1); // remove the label first
 
         config.data.datasets.forEach(function(dataset, datasetIndex) {
-            window.myLine.removeData(datasetIndex, -1);
+            dataset.data.pop();
         });
+
+        window.myLine.update();
     });
     </script>
 </body>
index 3fc97b52be5fa280c4a43400479e950d8a12af60..124c9d9c7ccd0c6c9a7a563cd57adb36a8a0bb3a 100644 (file)
                 newDataset.data.push(randomScalingFactor());
             }
 
-            window.myLine.addDataset(newDataset);
+            config.data.datasets.push(newDataset);
+            window.myLine.update();
             updateLegend();
         });
 
                 );
 
                 for (var index = 0; index < config.data.datasets.length; ++index) {
-                    window.myLine.addData(randomScalingFactor(), index);
+                    config.data.datasets[index].data.push(randomScalingFactor());
                 }
 
+                window.myLine.update();
                 updateLegend();
             }
         });
 
         $('#removeDataset').click(function() {
-            window.myLine.removeDataset(0);
+            config.data.datasets.splice(0, 1);
+            window.myLine.update();
             updateLegend();
         });
 
             config.data.labels.splice(-1, 1); // remove the label first
 
             config.data.datasets.forEach(function(dataset, datasetIndex) {
-                window.myLine.removeData(datasetIndex, -1);
+                dataset.data.pop();
             });
 
+            window.myLine.update();
             updateLegend();
         });
     </script>
index 71a1b8844a3d63022e04518c0a3fd71c5626c6c3..05d18d73dfa4eacb82e2bc4cac99c13361e16283 100644 (file)
             newDataset.data.push(randomScalingFactor());
         }
 
-        window.myLine.addDataset(newDataset);
+        config.data.datasets.push(newDataset);
+        window.myLine.update();
     });
 
     $('#addData').click(function() {
             config.data.labels.push('dataset #' + config.data.labels.length);
 
             for (var index = 0; index < config.data.datasets.length; ++index) {
-                window.myLine.addData(randomScalingFactor(), index);
+                config.data.datasets[index].data.push(randomScalingFactor());
             }
+
+            window.myLine.update();
         }
     });
 
     $('#removeDataset').click(function() {
-        window.myLine.removeDataset(0);
+        config.data.datasets.splice(0, 1);
+        window.myLine.update();
     });
 
     $('#removeData').click(function() {
         config.data.labels.splice(-1, 1); // remove the label first
 
         config.data.datasets.forEach(function(dataset, datasetIndex) {
-            window.myLine.removeData(datasetIndex, -1);
+            dataset.data.pop();
         });
+
+        window.myLine.update();
     });
     </script>
 </body>
index 19270288856e23cbacc7230df713b399889409d4..6d6816e51cc47af3e99fc6b9d2bc4e45cddb0448 100644 (file)
             newDataset.data.push(randomScalingFactor());
         }
 
-        window.myLine.addDataset(newDataset);
+        config.data.datasets.push(newDataset);
+        window.myLine.update();
         updateLegend();
     });
 
         if (config.data.datasets.length > 0) {
             config.data.labels.push('dataset #' + config.data.labels.length);
 
-            for (var index = 0; index < config.data.datasets.length; ++index) {
-                window.myLine.addData(randomScalingFactor(), index);
-            }
+            $.each(config.data.datasets, function(i, dataset) {
+                dataset.data.push(randomScalingFactor());
+            });
 
+            window.myLine.update();
             updateLegend();
         }
     });
 
     $('#removeDataset').click(function() {
-        window.myLine.removeDataset(0);
+        config.data.datasets.splice(0, 1);
+        window.myLine.update();
         updateLegend();
     });
 
         config.data.labels.splice(-1, 1); // remove the label first
 
         config.data.datasets.forEach(function(dataset, datasetIndex) {
-            window.myLine.removeData(datasetIndex, -1);
+            dataset.data.pop();
         });
 
+        window.myLine.update();
         updateLegend();
     });
     </script>
index 571efb03787de6bc42e8d76a154ef097e67aa87c..3d05fc20c1967c2f3790fcdce8b7d426adb076e5 100644 (file)
             data: [randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor()]
         };
 
-        window.myPie.addDataset(newDataset);
+        config.data.datasets.push(newDataset);
+        window.myPie.update();
     });
 
     $('#removeDataset').click(function() {
-        window.myPie.removeDataset(0);
+        config.data.datasets.splice(0, 1);
+        window.myPie.update();
     });
     </script>
 </body>
index 89915530bc9793550d41f9315f59b181d8348cd3..678aac69c692815dc00dfd533dafccd327435cff 100644 (file)
         if (config.data.datasets.length > 0) {
             config.data.labels.push('dataset #' + config.data.labels.length);
 
-            for (var index = 0; index < config.data.datasets.length; ++index) {
-                config.data.datasets[index].backgroundColor.push(randomColor());
-                window.myPolarArea.addData(randomScalingFactor(), index);
-            }
+            $.each(config.data.datasets, function(i, dataset) {
+                dataset.backgroundColor.push(randomColor());
+                dataset.data.push(randomScalingFactor());
+            });
 
+            window.myPolarArea.update();
             updateLegend();
         }
     });
 
     $('#removeData').click(function() {
-        config.data.labels.splice(-1, 1); // remove the label first
+        config.data.labels.pop(); // remove the label first
 
-        config.data.datasets.forEach(function(dataset, datasetIndex) {
-            dataset.backgroundColor.splice(-1, 1);
-            window.myPolarArea.removeData(datasetIndex, -1);
+        $.each(config.data.datasets, function(i, dataset) {
+            dataset.backgroundColor.pop();
+            dataset.data.pop();
         });
 
+        window.myPolarArea.update();
         updateLegend();
     });
     </script>
index 80b544e0d12787576c41cc22c5e8ca922c6f4a8e..c9b559aef9e160388bcde1c28c2f51610014f7d6 100644 (file)
@@ -16,7 +16,7 @@
     <button id="removeDataset">Remove Dataset</button>
     <button id="addData">Add Data</button>
     <button id="removeData">Remove Data</button>
-    ]<div>
+    <div>
         <h3>Legend</h3>
         <div id="legendContainer">
             
@@ -97,7 +97,8 @@
             newDataset.data.push(randomScalingFactor());
         }
 
-        window.myRadar.addDataset(newDataset);
+        config.data.datasets.push(newDataset);
+        window.myRadar.update();
         updateLegend();
     });
 
         if (config.data.datasets.length > 0) {
             config.data.labels.push('dataset #' + config.data.labels.length);
 
-            for (var index = 0; index < config.data.datasets.length; ++index) {
-                window.myRadar.addData(randomScalingFactor(), index);
-            }
+            $.each(config.data.datasets, function (i, dataset) {
+                dataset.data.push(randomScalingFactor());
+            });
 
+            window.myRadar.update();
             updateLegend();
         }
     });
 
     $('#removeDataset').click(function() {
-        window.myRadar.removeDataset(0);
+        config.data.datasets.splice(0, 1);
+        window.myRadar.update();
         updateLegend();
     });
 
     $('#removeData').click(function() {
-        config.data.labels.splice(-1, 1); // remove the label first
+        config.data.labels.pop(); // remove the label first
 
-        config.data.datasets.forEach(function(dataset, datasetIndex) {
-            window.myRadar.removeData(datasetIndex, -1);
+        $.each(config.data.datasets, function(i, dataset) {
+            dataset.data.pop();
         });
 
+        window.myRadar.update();
         updateLegend();
     });
     </script>