<!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>
.zc-body {
background: #272822;
}
.chart--container {
height: 100%;
width: 100%;
min-height: 530px;
}
.zc-ref {
display: none;
}
</style>
</head>
<body>
<div id="myChart" class="chart--container">
<a href="https://www.zingchart.com/" rel="noopener" class="zc-ref">Powered by ZingChart</a>
</div>
<script>
ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"]; // Define theme
zingchart.THEME = 'classic';
// Constants
let sineVal = 20;
let bReduce = false;
let threshold = 20;
let aActual = makePlot(300, 20, 30);
let aMin = JSON.parse(JSON.stringify(aActual));
let aMax = JSON.parse(JSON.stringify(aMin));
let m2 = 32;
let maxValue = 120;
// INIT DATA
// -----------------------------
let myConfig = {
type: 'area',
backgroundColor: '#272822',
title: {
text: 'Min / Max Area Demo',
backgroundColor: 'transparent',
fontFamily: 'Roboto',
fontSize: '18px',
},
legend: {
backgroundColor: 'transparent',
borderColor: 'transparent',
fontSize: '10px',
layout: 'float',
margin: '88% auto auto auto',
shadowColor: 'transparent',
toggleAction: 'remove',
item: {
markerStyle: 'circle',
fontColor: '#ffffff',
},
},
plotarea: {
backgroundColor: '#272822',
},
scaleX: {
visible: false,
},
scaleY: {
values: '-120:120:10',
item: {
fontColor: '#DDD',
},
lineColor: '#DDD',
refLine: {
lineColor: '#DDD',
},
tick: {
lineColor: '#DDD',
},
},
series: [{
values: []
}, {
values: []
}, {
values: []
}],
};
// RENDER CHART
// -----------------------------
zingchart.render({
id: 'myChart',
data: myConfig,
height: '560px',
width: '1000px',
});
// UPDATE CHART INTERVAL
// -----------------------------
setInterval(function() {
if (sineVal < -threshold || sineVal > threshold) {
bReduce = !bReduce;
threshold += 50;
if (threshold >= maxValue) {
maxValue += 100;
zingchart.exec('myChart', 'modify', {
data: {
scaleY: {
values: '-' + maxValue + ':' + maxValue + ':10',
},
},
});
}
}
sineVal = bReduce ? --sineVal : ++sineVal;
m2 -= 0.2;
aActual = makePlot(300, sineVal, m2);
//Loops through the actual and compares values in the min and max arrays.
for (let i = 0; i < aActual.length; i++) {
if (aActual[i] > aMax[i]) {
aMax[i] = aActual[i];
}
if (aActual[i] < aMin[i]) {
aMin[i] = aActual[i];
}
}
zingchart.exec('myChart', 'setseriesdata', {
data: [{
text: 'Actual',
values: aActual,
backgroundColor: '#e2e2e2',
lineColor: '#e2e2e2',
lineWidth: '2px',
shadowColor: 'transparent',
},
{
text: 'Min',
values: aMin,
lineColor: '#1fbff3',
lineWidth: '2px',
shadowColor: 'transparent',
},
{
text: 'Max',
values: aMax,
lineColor: '#f01400',
lineWidth: '2px',
shadowColor: 'transparent',
},
],
});
}, 60);
// HELPER FNS
// -----------------------------
function makePlot(nodes, s, m2) {
let m1 = 22,
values = [];
for (let n = 0; n < nodes + 1; n++) {
let v =
s *
Math.exp(Math.abs(n - nodes / 2) / nodes) *
Math.sin(n / (nodes / m1)) *
Math.cos(n / (nodes / m2));
v = parseFloat(v.toFixed(2));
values.push(v);
}
return values;
}
</script>
</body>
</html>
// Define theme
zingchart.THEME = 'classic';
// Constants
let sineVal = 20;
let bReduce = false;
let threshold = 20;
let aActual = makePlot(300, 20, 30);
let aMin = JSON.parse(JSON.stringify(aActual));
let aMax = JSON.parse(JSON.stringify(aMin));
let m2 = 32;
let maxValue = 120;
// INIT DATA
// -----------------------------
let myConfig = {
type: 'area',
backgroundColor: '#272822',
title: {
text: 'Min / Max Area Demo',
backgroundColor: 'transparent',
fontFamily: 'Roboto',
fontSize: '18px',
},
legend: {
backgroundColor: 'transparent',
borderColor: 'transparent',
fontSize: '10px',
layout: 'float',
margin: '88% auto auto auto',
shadowColor: 'transparent',
toggleAction: 'remove',
item: {
markerStyle: 'circle',
fontColor: '#ffffff',
},
},
plotarea: {
backgroundColor: '#272822',
},
scaleX: {
visible: false,
},
scaleY: {
values: '-120:120:10',
item: {
fontColor: '#DDD',
},
lineColor: '#DDD',
refLine: {
lineColor: '#DDD',
},
tick: {
lineColor: '#DDD',
},
},
series: [{ values: [] }, { values: [] }, { values: [] }],
};
// RENDER CHART
// -----------------------------
zingchart.render({
id: 'myChart',
data: myConfig,
height: '560px',
width: '1000px',
});
// UPDATE CHART INTERVAL
// -----------------------------
setInterval(function () {
if (sineVal < -threshold || sineVal > threshold) {
bReduce = !bReduce;
threshold += 50;
if (threshold >= maxValue) {
maxValue += 100;
zingchart.exec('myChart', 'modify', {
data: {
scaleY: {
values: '-' + maxValue + ':' + maxValue + ':10',
},
},
});
}
}
sineVal = bReduce ? --sineVal : ++sineVal;
m2 -= 0.2;
aActual = makePlot(300, sineVal, m2);
//Loops through the actual and compares values in the min and max arrays.
for (let i = 0; i < aActual.length; i++) {
if (aActual[i] > aMax[i]) {
aMax[i] = aActual[i];
}
if (aActual[i] < aMin[i]) {
aMin[i] = aActual[i];
}
}
zingchart.exec('myChart', 'setseriesdata', {
data: [
{
text: 'Actual',
values: aActual,
backgroundColor: '#e2e2e2',
lineColor: '#e2e2e2',
lineWidth: '2px',
shadowColor: 'transparent',
},
{
text: 'Min',
values: aMin,
lineColor: '#1fbff3',
lineWidth: '2px',
shadowColor: 'transparent',
},
{
text: 'Max',
values: aMax,
lineColor: '#f01400',
lineWidth: '2px',
shadowColor: 'transparent',
},
],
});
}, 60);
// HELPER FNS
// -----------------------------
function makePlot(nodes, s, m2) {
let m1 = 22,
values = [];
for (let n = 0; n < nodes + 1; n++) {
let v =
s *
Math.exp(Math.abs(n - nodes / 2) / nodes) *
Math.sin(n / (nodes / m1)) *
Math.cos(n / (nodes / m2));
v = parseFloat(v.toFixed(2));
values.push(v);
}
return values;
}