<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ZingSoft Demo</title>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,100' rel='stylesheet' type='text/css'>
<script nonce="undefined" src="https://cdn.zingchart.com/zingchart.min.js"></script>
<style>
.chart--container {
height: 100%;
width: 100%;
min-height: 530px;
}
.zc-ref {
display: none;
}
</style>
</head>
<body>
<div id="myChart" class="chart--container"><a class="zc-ref" href="https://www.zingchart.com/">Powered by ZingChart</a></div>
<script>
ZC.LICENSE = ["569d52cefae586f634c54f86dc99e6a9", "b55b025e438fa8a98e32482b5f768ff5"];
let 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;
}
let sineVal = 20;
let bReduce = false;
let threshold = 20;
let aActual = makePlot(200, 20, 30);
let aMin = JSON.parse(JSON.stringify(aActual));
let aMax = JSON.parse(JSON.stringify(aMin));
let m2 = 32;
let maxValue = 120;
setInterval(() => {
if ((sineVal < -threshold) || (sineVal > threshold)) {
bReduce = !bReduce;
threshold += 30;
if (threshold >= maxValue) {
maxValue += 100;
zingchart.exec('myChart', 'modify', {
data: {
scaleY: {
values: '-' + maxValue + ':' + maxValue + ':10'
}
}
})
}
}
sineVal = (bReduce) ? --sineVal : ++sineVal;
m2 -= 0.2;
aActual = makePlot(200, 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];
}
}
// Update values
zingchart.exec('myChart', 'setseriesdata', {
data: [{
text: 'Actual',
values: aActual,
backgroundColor: '#FFFF8D',
lineColor: '#FFFF8D',
lineWidth: '2px',
shadowColor: 'transparent'
},
{
text: 'Min',
values: aMin,
backgroundColor: '#448AFF',
lineColor: '#448AFF',
lineWidth: '2px',
shadowColor: 'transparent'
},
{
text: 'Max',
values: aMax,
backgroundColor: '#FF5252',
lineColor: '#FF5252',
lineWidth: '2px',
shadowColor: 'transparent'
}
]
});
}, 60);
let chartConfig = {
type: 'area',
title: {
text: 'Min / Max Area Demo',
backgroundColor: 'transparent',
fontFamily: 'Roboto',
fontSize: '18px'
},
legend: {
adjustLayout: false,
align: 'center',
backgroundColor: 'transparent',
borderColor: 'transparent',
fontSize: '10px',
item: {
markerStyle: 'circle'
},
layout: 'float',
shadowColor: 'transparent',
toggleAction: 'remove',
verticalAlign: 'bottom'
},
plot: {
marker: {
visible: false
},
maxTrackers: 0
},
scaleX: {
visible: false
},
scaleY: {
values: '-120:120:10'
},
// Data dynamically generated
series: [{
values: []
}, {
values: []
}, {
values: []
}]
};
zingchart.render({
id: 'myChart',
data: chartConfig,
height: '100%',
width: '100%',
});
</script>
</body>
</html>
let 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;
}
let sineVal = 20;
let bReduce = false;
let threshold = 20;
let aActual = makePlot(200, 20, 30);
let aMin = JSON.parse(JSON.stringify(aActual));
let aMax = JSON.parse(JSON.stringify(aMin));
let m2 = 32;
let maxValue = 120;
setInterval(() => {
if ((sineVal < -threshold) || (sineVal > threshold)) {
bReduce = !bReduce;
threshold += 30;
if (threshold >= maxValue) {
maxValue += 100;
zingchart.exec('myChart', 'modify', {
data: {
scaleY: {
values: '-' + maxValue + ':' + maxValue + ':10'
}
}
})
}
}
sineVal = (bReduce) ? --sineVal : ++sineVal;
m2 -= 0.2;
aActual = makePlot(200, 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];
}
}
// Update values
zingchart.exec('myChart', 'setseriesdata', {
data: [
{
text: 'Actual',
values: aActual,
backgroundColor: '#FFFF8D',
lineColor: '#FFFF8D',
lineWidth: '2px',
shadowColor: 'transparent'
},
{
text: 'Min',
values: aMin,
backgroundColor: '#448AFF',
lineColor: '#448AFF',
lineWidth: '2px',
shadowColor: 'transparent'
},
{
text: 'Max',
values: aMax,
backgroundColor: '#FF5252',
lineColor: '#FF5252',
lineWidth: '2px',
shadowColor: 'transparent'
}
]
});
}, 60);
let chartConfig = {
type: 'area',
title: {
text: 'Min / Max Area Demo',
backgroundColor: 'transparent',
fontFamily: 'Roboto',
fontSize: '18px'
},
legend: {
adjustLayout: false,
align: 'center',
backgroundColor: 'transparent',
borderColor: 'transparent',
fontSize: '10px',
item: {
markerStyle: 'circle'
},
layout: 'float',
shadowColor: 'transparent',
toggleAction: 'remove',
verticalAlign: 'bottom'
},
plot: {
marker: {
visible: false
},
maxTrackers: 0
},
scaleX: {
visible: false
},
scaleY: {
values: '-120:120:10'
},
// Data dynamically generated
series: [{values: []}, {values: []}, {values: []}]
};
zingchart.render({
id: 'myChart',
data: chartConfig,
height: '100%',
width: '100%',
});