%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 49.231.201.246 / Your IP : 216.73.216.149 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/11585/cwd/html/ppaobm/vendor/bower-asset/chartjs/samples/charts/bar/ |
Upload File : |
<!doctype html> <html> <head> <title>Horizontal Bar Chart</title> <script src="../../../dist/Chart.min.js"></script> <script src="../../utils.js"></script> <style> canvas { -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; } </style> </head> <body> <div id="container" style="width: 75%;"> <canvas id="canvas"></canvas> </div> <button id="randomizeData">Randomize Data</button> <button id="addDataset">Add Dataset</button> <button id="removeDataset">Remove Dataset</button> <button id="addData">Add Data</button> <button id="removeData">Remove Data</button> <script> var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; var color = Chart.helpers.color; var horizontalBarChartData = { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets: [{ label: 'Dataset 1', backgroundColor: color(window.chartColors.red).alpha(0.5).rgbString(), borderColor: window.chartColors.red, borderWidth: 1, data: [ randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor() ] }, { label: 'Dataset 2', backgroundColor: color(window.chartColors.blue).alpha(0.5).rgbString(), borderColor: window.chartColors.blue, data: [ randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor(), randomScalingFactor() ] }] }; window.onload = function() { var ctx = document.getElementById('canvas').getContext('2d'); window.myHorizontalBar = new Chart(ctx, { type: 'horizontalBar', data: horizontalBarChartData, options: { // Elements options apply to all of the options unless overridden in a dataset // In this case, we are setting the border of each horizontal bar to be 2px wide elements: { rectangle: { borderWidth: 2, } }, responsive: true, legend: { position: 'right', }, title: { display: true, text: 'Chart.js Horizontal Bar Chart' } } }); }; document.getElementById('randomizeData').addEventListener('click', function() { var zero = Math.random() < 0.2 ? true : false; horizontalBarChartData.datasets.forEach(function(dataset) { dataset.data = dataset.data.map(function() { return zero ? 0.0 : randomScalingFactor(); }); }); window.myHorizontalBar.update(); }); var colorNames = Object.keys(window.chartColors); document.getElementById('addDataset').addEventListener('click', function() { var colorName = colorNames[horizontalBarChartData.datasets.length % colorNames.length]; var dsColor = window.chartColors[colorName]; var newDataset = { label: 'Dataset ' + (horizontalBarChartData.datasets.length + 1), backgroundColor: color(dsColor).alpha(0.5).rgbString(), borderColor: dsColor, data: [] }; for (var index = 0; index < horizontalBarChartData.labels.length; ++index) { newDataset.data.push(randomScalingFactor()); } horizontalBarChartData.datasets.push(newDataset); window.myHorizontalBar.update(); }); document.getElementById('addData').addEventListener('click', function() { if (horizontalBarChartData.datasets.length > 0) { var month = MONTHS[horizontalBarChartData.labels.length % MONTHS.length]; horizontalBarChartData.labels.push(month); for (var index = 0; index < horizontalBarChartData.datasets.length; ++index) { horizontalBarChartData.datasets[index].data.push(randomScalingFactor()); } window.myHorizontalBar.update(); } }); document.getElementById('removeDataset').addEventListener('click', function() { horizontalBarChartData.datasets.pop(); window.myHorizontalBar.update(); }); document.getElementById('removeData').addEventListener('click', function() { horizontalBarChartData.labels.splice(-1, 1); // remove the label first horizontalBarChartData.datasets.forEach(function(dataset) { dataset.data.pop(); }); window.myHorizontalBar.update(); }); </script> </body> </html>