<!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 {
width: 100%;
height: 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 chartData = [{
values: [115],
text: 'Segment 1'
},
{
values: [95],
text: 'Segment 2'
},
{
values: [92],
text: 'Segment 3'
},
{
values: [86],
text: 'Segment 4'
},
{
values: [79],
text: 'Segment 5'
},
{
values: [68],
text: 'Segment 6'
},
{
values: [63],
text: 'Segment 7'
},
{
values: [40],
text: 'Segment 8'
}
];
let chartConfig = {
type: 'pie',
globals: {
fontFamily: 'sans-serif'
},
backgroundColor: '#fff',
palette: ['#0099CC', '#007E33', '#FF8800', '#CC0000', '#33b5e5', '#00C851', '#ffbb33', '#ff4444'],
legend: {
marginRight: '60px',
alpha: 0.1,
borderWidth: '0px',
highlightPlot: true,
item: {
fontColor: '#373a3c',
fontSize: '12px'
},
toggleAction: 'remove',
verticalAlign: 'middle',
width: '100px'
},
plot: {
valueBox: {
fontColor: '#fff'
},
detach: false,
highlightState: {
borderColor: '#000',
borderWidth: '2px'
},
refAngle: 270
},
labels: [{
text: 'Hold SHIFT to detach multiple slices',
fontColor: '#373a3c',
fontSize: '14px',
textAlign: 'left'
}],
tooltip: {
borderColor: '#373a3c',
borderWidth: '2px',
placement: 'node:out'
},
series: chartData
};
zingchart.render({
id: 'myChart',
data: chartConfig,
height: '100%',
width: '100%',
});
zingchart.node_click = (p) => {
let SHIFT_ACTIVE = p.ev.shiftKey;
let sliceData = chartData[p.plotindex];
let isOpen = (sliceData.hasOwnProperty('offset-r')) ? (sliceData['offset-r'] !== 0) : false;
if (isOpen) {
sliceData['offset-r'] = 0;
} else {
if (!SHIFT_ACTIVE) {
for (let i = 0; i < chartData.length; i++) {
chartData[i]['offset-r'] = 0;
}
}
sliceData['offset-r'] = 20;
}
zingchart.exec('myChart', 'setdata', {
data: chartConfig
});
}
</script>
</body>
</html>
let chartData = [
{
values: [115],
text: 'Segment 1'
},
{
values: [95],
text: 'Segment 2'
},
{
values: [92],
text: 'Segment 3'
},
{
values: [86],
text: 'Segment 4'
},
{
values: [79],
text: 'Segment 5'
},
{
values: [68],
text: 'Segment 6'
},
{
values: [63],
text: 'Segment 7'
},
{
values: [40],
text: 'Segment 8'
}
];
let chartConfig = {
type: 'pie',
globals: {
fontFamily: 'sans-serif'
},
backgroundColor: '#fff',
palette: ['#0099CC', '#007E33', '#FF8800', '#CC0000', '#33b5e5', '#00C851', '#ffbb33', '#ff4444'],
legend: {
marginRight: '60px',
alpha: 0.1,
borderWidth: '0px',
highlightPlot: true,
item: {
fontColor: '#373a3c',
fontSize: '12px'
},
toggleAction: 'remove',
verticalAlign: 'middle',
width: '100px'
},
plot: {
valueBox: {
fontColor: '#fff'
},
detach: false,
highlightState: {
borderColor: '#000',
borderWidth: '2px'
},
refAngle: 270
},
labels: [
{
text: 'Hold SHIFT to detach multiple slices',
fontColor: '#373a3c',
fontSize: '14px',
textAlign: 'left'
}
],
tooltip: {
borderColor: '#373a3c',
borderWidth: '2px',
placement: 'node:out'
},
series: chartData
};
zingchart.render({
id: 'myChart',
data: chartConfig,
height: '100%',
width: '100%',
});
zingchart.node_click = (p) => {
let SHIFT_ACTIVE = p.ev.shiftKey;
let sliceData = chartData[p.plotindex];
let isOpen = (sliceData.hasOwnProperty('offset-r')) ? (sliceData['offset-r'] !== 0) : false;
if (isOpen) {
sliceData['offset-r'] = 0;
}
else {
if (!SHIFT_ACTIVE) {
for (let i = 0; i < chartData.length; i++) {
chartData[i]['offset-r'] = 0;
}
}
sliceData['offset-r'] = 20;
}
zingchart.exec('myChart', 'setdata', {
data: chartConfig
});
}