<!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: #fff;
}
.chart--container {
height: 100%;
width: 100%;
min-height: 530px;
}
.zc-ref {
display: none;
}
</style>
</head>
<body class="zc-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"];
zingchart.MODULESDIR = 'https://cdn.zingchart.com/modules/';
zingchart.loadModules('maps,maps-world-countries');
let chartConfig = {
shapes: [{
type: 'zingchart.maps',
options: {
name: 'world.countries',
label: {
visible: false,
},
style: {
backgroundColor: '#cccccc',
hoverState: {
alpha: 0.32,
},
items: {
USA: {
backgroundColor: '#0D47A1',
cursor: 'pointer',
label: {
visible: true,
fontColor: '#ffffff',
},
tooltip: {
text: 'Click on USA to drilldown into states',
},
},
BRA: {
backgroundColor: '#4CAF50',
cursor: 'pointer',
label: {
visible: true,
fontColor: '#ffffff',
},
tooltip: {
text: 'Click on Brazil to drilldown into states',
},
},
IND: {
backgroundColor: '#FF6F00',
cursor: 'pointer',
label: {
visible: true,
fontColor: '#ffffff',
},
tooltip: {
text: 'Click on India to drilldown into states',
},
},
},
},
},
}, ],
};
zingchart.render({
id: 'myChart',
data: chartConfig,
});
let drilldownConfig;
drilldownConfig = {
shapes: [{
type: 'zingchart.maps',
options: {
name: '',
},
},
{
id: 'back_button',
type: 'rectangle',
backgroundColor: '#C4C4C4',
cursor: 'hand',
height: '25px',
hoverState: {
borderWidth: '1px',
borderColor: '#000',
},
label: {
text: 'Back To World Countries',
},
padding: '5px',
width: '155px',
x: '100px',
y: '20px',
},
],
};
zingchart.loadModules('maps-usa, maps-bra, maps-ind');
zingchart.bind('myChart', 'shape_click', function(e) {
let newMapId = String(e.shapeid).toLowerCase();
if (newMapId == 'back_button') {
console.log('here');
zingchart.exec('myChart', 'reload');
return;
}
if (hasDrilldownData(newMapId)) {
drilldownConfig.shapes[0].options.name = newMapId;
zingchart.exec('myChart', 'setdata', {
data: drilldownConfig,
});
}
});
function hasDrilldownData(newMapId) {
let drillDownCountries = ['usa', 'bra', 'ind'];
for (let i = 0; i < drillDownCountries.length; i++) {
if (newMapId === drillDownCountries[i]) return true;
}
return false;
}
</script>
</body>
</html>
zingchart.MODULESDIR = 'https://cdn.zingchart.com/modules/';
zingchart.loadModules('maps,maps-world-countries');
let chartConfig = {
shapes: [
{
type: 'zingchart.maps',
options: {
name: 'world.countries',
label: {
visible: false,
},
style: {
backgroundColor: '#cccccc',
hoverState: {
alpha: 0.32,
},
items: {
USA: {
backgroundColor: '#0D47A1',
cursor: 'pointer',
label: {
visible: true,
fontColor: '#ffffff',
},
tooltip: {
text: 'Click on USA to drilldown into states',
},
},
BRA: {
backgroundColor: '#4CAF50',
cursor: 'pointer',
label: {
visible: true,
fontColor: '#ffffff',
},
tooltip: {
text: 'Click on Brazil to drilldown into states',
},
},
IND: {
backgroundColor: '#FF6F00',
cursor: 'pointer',
label: {
visible: true,
fontColor: '#ffffff',
},
tooltip: {
text: 'Click on India to drilldown into states',
},
},
},
},
},
},
],
};
zingchart.render({
id: 'myChart',
data: chartConfig,
});
let drilldownConfig;
drilldownConfig = {
shapes: [
{
type: 'zingchart.maps',
options: {
name: '',
},
},
{
id: 'back_button',
type: 'rectangle',
backgroundColor: '#C4C4C4',
cursor: 'hand',
height: '25px',
hoverState: {
borderWidth: '1px',
borderColor: '#000',
},
label: {
text: 'Back To World Countries',
},
padding: '5px',
width: '155px',
x: '100px',
y: '20px',
},
],
};
zingchart.loadModules('maps-usa, maps-bra, maps-ind');
zingchart.bind('myChart', 'shape_click', function (e) {
let newMapId = String(e.shapeid).toLowerCase();
if (newMapId == 'back_button') {
console.log('here');
zingchart.exec('myChart', 'reload');
return;
}
if (hasDrilldownData(newMapId)) {
drilldownConfig.shapes[0].options.name = newMapId;
zingchart.exec('myChart', 'setdata', {
data: drilldownConfig,
});
}
});
function hasDrilldownData(newMapId) {
let drillDownCountries = ['usa', 'bra', 'ind'];
for (let i = 0; i < drillDownCountries.length; i++) {
if (newMapId === drillDownCountries[i]) return true;
}
return false;
}