<!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>
.chart--container {
min-height: 530px;
width: 100%;
height: 100%;
}
.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 gauge = 355;
let labelsArray = [];
for (let i = 0; i <= 500; i++) {
if (i === 0) {
labelsArray.push('$0');
} else if (i === 500) {
labelsArray.push('$500k');
} else {
labelsArray.push('');
}
}
let chartConfig = {
type: 'gauge',
title: {
text: 'Actual Sales vs Target',
fontWeight: 400
},
plot: {
size: '100%',
valueBox: {
placement: 'center',
text: 'Actual Sales vs Target<br>$%vk',
fontSize: 24,
offsetY: 50,
fontWeight: 400,
color: '#0F1418'
}
},
plotarea: {
marginTop: '80px',
},
scaleR: {
aperture: 180,
ring: {
size: 75,
rules: [{
rule: `%v >= 0 && %v <= ${gauge}`,
backgroundColor: '#FFA300'
}]
},
values: '0:500:1',
center: {
size: 10,
backgroundColor: '#011CFF',
borderColor: 'none'
},
labels: labelsArray,
item: {
fontColor: '#0F1418',
fontSize: '24px',
fontWeight: '400',
offsetR: '-65px',
offsetY: '20px', //To adjust the placement of your scale labels.
},
tick: {
visible: false
}
},
series: [{
values: [355],
csize: '10%',
size: '90%',
indicator: [10, 0, 0, 0, 0],
backgroundColor: '#011CFF', //Needle Color
}, ]
};
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min); //The maximum is exclusive and the minimum is inclusive
}
let intervalId = window.setInterval(function() {
// call your function here
gauge = getRandomInt(0, 500);
zingchart.exec('myChart', 'setdata', {
'data': {
type: 'gauge',
title: {
text: 'Actual Sales vs Target',
fontWeight: 400
},
plotarea: {
marginTop: '80px'
},
plot: {
size: '100%',
valueBox: {
placement: 'center',
text: 'Actual Sales vs Target<br>$%vk',
fontSize: 24,
offsetY: 50,
fontWeight: 400,
color: '#0F1418'
}
},
scaleR: {
aperture: 180,
ring: {
size: 75,
rules: [{
rule: `%v >= 0 && %v <= ${gauge}`,
backgroundColor: '#FFA300'
}]
},
values: '0:500:1',
center: {
size: 10,
backgroundColor: '#011CFF',
borderColor: 'none'
},
labels: labelsArray,
item: {
fontColor: '#0F1418',
fontSize: '24px',
fontWeight: '400',
offsetR: '-65px',
offsetY: '20px', //To adjust the placement of your scale labels.
},
tick: {
visible: false
}
},
series: [{
values: [gauge],
csize: '10%',
size: '90%',
indicator: [10, 0, 0, 0, 0],
backgroundColor: '#011CFF', //Needle Color
}, ]
}
});
}, 1000);
zingchart.render({
id: 'myChart',
data: chartConfig,
height: '100%',
width: '100%'
});
</script>
</body>
</html>
let gauge = 355;
let labelsArray = [];
for (let i = 0; i <= 500; i++) {
if (i === 0) {
labelsArray.push('$0');
} else if (i === 500) {
labelsArray.push('$500k');
} else {
labelsArray.push('');
}
}
let chartConfig = {
type: 'gauge',
title: {
text: 'Actual Sales vs Target',
fontWeight: 400
},
plot: {
size: '100%',
valueBox: {
placement: 'center',
text: 'Actual Sales vs Target<br>$%vk',
fontSize: 24,
offsetY: 50,
fontWeight: 400,
color: '#0F1418'
}
},
plotarea: {
marginTop: '80px',
},
scaleR: {
aperture: 180,
ring: {
size: 75,
rules: [{
rule: `%v >= 0 && %v <= ${gauge}`,
backgroundColor: '#FFA300'
}]
},
values: '0:500:1',
center: {
size: 10,
backgroundColor: '#011CFF',
borderColor: 'none'
},
labels: labelsArray,
item: {
fontColor: '#0F1418',
fontSize: '24px',
fontWeight: '400',
offsetR: '-65px',
offsetY: '20px', //To adjust the placement of your scale labels.
},
tick: {
visible: false
}
},
series: [{
values: [355],
csize: '10%',
size: '90%',
indicator: [10, 0, 0, 0, 0],
backgroundColor: '#011CFF', //Needle Color
}, ]
};
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min) + min); //The maximum is exclusive and the minimum is inclusive
}
let intervalId = window.setInterval(function() {
// call your function here
gauge = getRandomInt(0, 500);
zingchart.exec('myChart', 'setdata', {
'data': {
type: 'gauge',
title: {
text: 'Actual Sales vs Target',
fontWeight: 400
},
plotarea: {
marginTop: '80px'
},
plot: {
size: '100%',
valueBox: {
placement: 'center',
text: 'Actual Sales vs Target<br>$%vk',
fontSize: 24,
offsetY: 50,
fontWeight: 400,
color: '#0F1418'
}
},
scaleR: {
aperture: 180,
ring: {
size: 75,
rules: [{
rule: `%v >= 0 && %v <= ${gauge}`,
backgroundColor: '#FFA300'
}]
},
values: '0:500:1',
center: {
size: 10,
backgroundColor: '#011CFF',
borderColor: 'none'
},
labels: labelsArray,
item: {
fontColor: '#0F1418',
fontSize: '24px',
fontWeight: '400',
offsetR: '-65px',
offsetY: '20px', //To adjust the placement of your scale labels.
},
tick: {
visible: false
}
},
series: [{
values: [gauge],
csize: '10%',
size: '90%',
indicator: [10, 0, 0, 0, 0],
backgroundColor: '#011CFF', //Needle Color
}, ]
}
});
}, 1000);
zingchart.render({
id: 'myChart',
data: chartConfig,
height: '100%',
width: '100%'
});