<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ZingSoft Demo</title>
<script src="https://cdn.zingchart.com/zingchart.min.js"></script>
<style>
.zc-body {
background: linear-gradient(45deg, #00d2ff, #3a7bd5) no-repeat;
}
.chart--container {
height: 100%;
width: 100%;
min-height: 530px;
}
.zc-ref {
display: none;
}
</style>
</head>
<body class="zc-body">
<div id="myChart">
<a href="https://www.zingchart.com/" rel="noopener" class="zc-ref">Powered by ZingChart</a>
</div>
<script>
ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"];
// DEFINE CHART
// -----------------------------
// Main chart render location
var chartId = 'myChart';
// INFO
// -----------------------------
var info = {
0: {
amount: 430,
counter: 0,
values: [],
period: 0.2,
lineColor: '#28c6ff',
height: 120
},
1: {
amount: 450,
counter: 0,
values: [],
period: 0.05,
lineColor: '#16bbff',
height: 90
},
2: {
amount: 400,
counter: 20,
values: [],
period: 0.2,
lineColor: '#16eaff',
height: 40
}
}
// CHART CONFIG
// -----------------------------
var myConfig = {
type: "line",
backgroundColor: 'transparent',
scaleY: {
visible: false,
values: "50:300:1"
},
scaleX: {
visible: false
},
plotarea: {
margin: 20
},
plot: {
tooltip: {
visible: false
},
maxTrackers: 0,
maxNodes: 0,
aspect: 'spline',
marker: {
visible: false,
borderColor: "#00AEF1",
backgroundColor: "#47ccff"
}
},
series: [{
values: info[0].values,
lineColor: info[0].lineColor
}, {
values: info[1].values,
lineColor: info[1].lineColor,
}, {
values: info[2].values,
lineColor: info[2].lineColor,
}]
};
// RENDER CHART
// -----------------------------
zingchart.render({
id: chartId,
data: myConfig,
height: 560,
width: '100%'
});
// UPDATE CHART INTERVAL
// -----------------------------
makeData(info[0]);
makeData(info[1]);
makeData(info[2]);
setInterval(function() {
var nextVal = getNextValue(info[0]);
info[0].values.shift();
info[0].values.push(nextVal);
var nextVal = getNextValue(info[1]);
info[1].values.shift();
info[1].values.push(nextVal);
var nextVal = getNextValue(info[2]);
info[2].values.shift();
info[2].values.push(nextVal);
zingchart.exec(chartId, 'setseriesdata', {
graphid: 0,
data: [{
values: info[0].values,
lineColor: info[0].lineColor
}, {
values: info[1].values,
lineColor: info[1].lineColor
}, {
values: info[2].values,
lineColor: info[2].lineColor
}]
});
}, 20)
// HELPER FNS
// -----------------------------
function makeData(data) {
var increase = data.period * Math.PI / 20;
for (var i = 0; i < data.amount; i++) {
data.values.push(180 - Math.sin(data.counter) * data.height);
data.counter += increase;
}
}
function getNextValue(data) {
var increase = data.period * Math.PI / 20;
var value = (180 - Math.sin(data.counter) * data.height);
data.counter += increase;
return value;
}
</script>
</body>
</html>
// DEFINE CHART
// -----------------------------
// Main chart render location
var chartId = 'myChart';
// INFO
// -----------------------------
var info = {
0: {
amount: 430,
counter: 0,
values: [],
period: 0.2,
lineColor: '#28c6ff',
height: 120
},
1: {
amount: 450,
counter: 0,
values: [],
period: 0.05,
lineColor: '#16bbff',
height: 90
},
2: {
amount: 400,
counter: 20,
values: [],
period: 0.2,
lineColor: '#16eaff',
height: 40
}
}
// CHART CONFIG
// -----------------------------
var myConfig = {
type: "line",
backgroundColor: 'transparent',
scaleY: {
visible: false,
values: "50:300:1"
},
scaleX: {
visible: false
},
plotarea: {
margin: 20
},
plot: {
tooltip: {
visible: false
},
maxTrackers: 0,
maxNodes: 0,
aspect: 'spline',
marker: {
visible: false,
borderColor: "#00AEF1",
backgroundColor: "#47ccff"
}
},
series: [{
values: info[0].values,
lineColor: info[0].lineColor
}, {
values: info[1].values,
lineColor: info[1].lineColor,
}, {
values: info[2].values,
lineColor: info[2].lineColor,
}]
};
// RENDER CHART
// -----------------------------
zingchart.render({
id: chartId,
data: myConfig,
height: 560,
width: '100%'
});
// UPDATE CHART INTERVAL
// -----------------------------
makeData(info[0]);
makeData(info[1]);
makeData(info[2]);
setInterval(function() {
var nextVal = getNextValue(info[0]);
info[0].values.shift();
info[0].values.push(nextVal);
var nextVal = getNextValue(info[1]);
info[1].values.shift();
info[1].values.push(nextVal);
var nextVal = getNextValue(info[2]);
info[2].values.shift();
info[2].values.push(nextVal);
zingchart.exec(chartId, 'setseriesdata', {
graphid: 0,
data: [{
values: info[0].values,
lineColor: info[0].lineColor
}, {
values: info[1].values,
lineColor: info[1].lineColor
}, {
values: info[2].values,
lineColor: info[2].lineColor
}]
});
}, 20)
// HELPER FNS
// -----------------------------
function makeData(data) {
var increase = data.period * Math.PI / 20;
for (var i = 0; i < data.amount; i++) {
data.values.push(180 - Math.sin(data.counter) * data.height);
data.counter += increase;
}
}
function getNextValue(data) {
var increase = data.period * Math.PI / 20;
var value = (180 - Math.sin(data.counter) * data.height);
data.counter += increase;
return value;
}