<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>ZingSoft Demo</title> <script nonce="undefined" src="https://cdn.zingchart.com/zingchart.min.js"></script> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } #myChart { height: 100%; width: 100%; min-height: 150px; } .zc-ref { display: none; } #myChart button { position: absolute; top: 15px; left: 10px; z-index: 1000; } </style> </head> <body> <div id="myChart"> <a class="zc-ref" href="https://www.zingchart.com">Powered by ZingChart</a> <button onclick="window.parent.location.reload()">Reload Data</button> </div> <script> ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"]; // make the AJAX request var oReq = new XMLHttpRequest(); oReq.addEventListener("load", renderFirstPlotInChart); oReq.open("GET", "https://zingchart-rest-api.glitch.me/api/data/getAllPlots/JSON"); oReq.send(); // define chart JSON var myConfig = { type: 'bar', title: { text: 'Rendering Multiple Plots With All Client Side Parsing', mediaRules: [{ maxWidth: 500, visible: false }] }, plot: { // barWidth: 25, // this will prevent users from noticing the barwidth changing animation: { effect: 4, method: 2, sequence: 2, }, // add animation to make the chart look alive }, legend: {}, scaleY: { values: '0:300:100' // this will prevent users from noticing the scale repaint }, series: [] }; /* * callback for GET request is when we will render the chart */ function renderFirstPlotInChart() { var docs = JSON.parse(this.responseText); var seriesArray = []; var returnArray = []; for (var key in docs) { // loop through documents let plotId = docs[key].type; let plotValue = docs[key].temp; if (!seriesArray[plotId]) { seriesArray[plotId] = { text: plotId, values: [] }; returnArray.push(seriesArray[plotId]); // assign reference into return array } seriesArray[plotId].values.push(plotValue); // assign value to array } myConfig.series = returnArray; zingchart.render({ id: 'myChart', data: myConfig, height: '100%', width: '100%' }); } </script> </body> </html>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>ZingSoft Demo</title> <script src="https://cdn.zingchart.com/zingchart.min.js"></script> </head> <body> <div id="myChart"> <a class="zc-ref" href="https://www.zingchart.com">Powered by ZingChart</a> <button onclick="window.parent.location.reload()">Reload Data</button> </div> </body> </html>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; } #myChart { height: 100%; width: 100%; min-height: 150px; } .zc-ref { display: none; } #myChart button { position: absolute; top: 15px; left: 10px; z-index: 1000; }
// make the AJAX request var oReq = new XMLHttpRequest(); oReq.addEventListener("load", renderFirstPlotInChart); oReq.open("GET", "https://zingchart-rest-api.glitch.me/api/data/getAllPlots/JSON"); oReq.send(); // define chart JSON var myConfig = { type: 'bar', title: { text: 'Rendering Multiple Plots With All Client Side Parsing', mediaRules: [{ maxWidth: 500, visible: false }] }, plot: { // barWidth: 25, // this will prevent users from noticing the barwidth changing animation: { effect: 4, method: 2, sequence: 2, }, // add animation to make the chart look alive }, legend: {}, scaleY: { values: '0:300:100' // this will prevent users from noticing the scale repaint }, series: [] }; /* * callback for GET request is when we will render the chart */ function renderFirstPlotInChart() { var docs = JSON.parse(this.responseText); var seriesArray = []; var returnArray = []; for (var key in docs) { // loop through documents let plotId = docs[key].type; let plotValue = docs[key].temp; if (!seriesArray[plotId]) { seriesArray[plotId] = { text: plotId, values: [] }; returnArray.push(seriesArray[plotId]); // assign reference into return array } seriesArray[plotId].values.push(plotValue); // assign value to array } myConfig.series = returnArray; zingchart.render({ id: 'myChart', data: myConfig, height: '100%', width: '100%' }); }