javascript - Import data from Excel and use in Chart.js -
well, i've learned how render html graphics tag canvas recently. filling in data manually little painful ... wanted know if possible data straight excel spreadsheet using javascript. code far ...
<div> <canvas class="line-chart"></canvas> <script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.5.0/chart.min.js"></script> <script> var ctx = document.getelementsbyclassname("line-chart"); var dia = ["dia 1", "dia 2", "dia 3", "dia 4", "dia 5", "dia 6"]; //seta os dias var real = [60,30,65,59,58,49]; //seta os dados grafico 1 var meta = [30,45,62,47,55,11]; //seta os dados grafico 2 //type, data, options var chartgraph = new chart (ctx, { type: 'line', //line, bar, radar, doughnut (pizza), polararea data: { labels: dia, datasets: [{ label: "oee real (%) ", data: real, borderwidth: 6, bordercolor: 'rgba(146,242,42,0.85)', background: 'transparent', }, { label: "oee meta (%)", data: meta, borderwidth: 6, bordercolor: 'rgba(207,0,15,0.85)', background: 'transparent', }, ]}, options: { title: { display: true, fontsize: 20, text: "encartuchamento 05" }, scales: { yaxes: [{ ticks: { max: 100, min: 0, } }] }, } }); </script> </div>
Comments
Post a Comment