Drill-down column chart
How do I make an drill-down column chart?
What is a drill-down column chart? How do you make a drill-down column chart? This script and codes were developed by Otto Garcia on 02 December 2022, Friday.
Drill-down column chart - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Drill-down column chart</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/serial.js"></script>
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<div id="chartdiv"></div> <script src="js/index.js"></script>
</body>
</html>
Drill-down column chart - Script Codes CSS Codes
#chartdiv { width: 100%; height: 500px;
}
Drill-down column chart - Script Codes JS Codes
var chartData = [ { "category": 2016, "income": 5.2, "url": "#", "description": "click to drill-down", "months": [{ "category": "Enero", "income": 1, "TipoAduana": [ { "category": "Febrero", "income": 2,"NombreAduana":"Central de Aviación","ValorUsd":0.0,"Volumen":0.0,"Anio":2016,"Producto":null,"TipoAduana":"Aérea","Criterio":"Exportaciones","NombreMes":"Febrero","Porcentaje":0} ] }, { "category": "Febrero", "income": 2 }, { "category": "Marzo", "income": 1 }, { "category": "Abril", "income": 3 }, { "category": "Mayo", "income": 2.5 }, { "category": "Junio", "income": 1.1 }, { "category": "Julio", "income": 2.9 }, { "category": "Agosto", "income": 3.5 }, { "category": "Septiembre", "income": 3.1 }, { "category": "Octubre", "income": 1.1 }, { "category": "Noviembre", "income": 1 }, { "category": "Diciembre", "income": 3 }]
}, { "category": 2017, "income": 6.1, "url": "#", "description": "click to drill-down", "months": [{ "category": "Enero", "income": 1 }, { "category": "Febrero", "income": 2 }, { "category": "Marzo", "income": 1 }, { "category": "Abril", "income": 3 }, { "category": "Mayo", "income": 2.5 }, { "category": "Junio", "income": 1.1 }, { "category": "Julio", "income": 2.9 }, { "category": "Agosto", "income": 3.5 }, { "category": "Septiembre", "income": 3.1 }, { "category": "Octubre", "income": 1.1 }, { "category": "Noviembre", "income": 1, }, { "category": "Diciembre", "income": 3 }]
}];
var chart = AmCharts.makeChart("chartdiv", { "type": "serial", "creditsPosition": "top-right", "autoMargins": false, "marginLeft": 30, "marginRight": 8, "marginTop": 10, "marginBottom": 26, "titles": [{ "text": "Yearly data" }], "dataProvider": chartData, "startDuration": 1, "graphs": [{ "alphaField": "alpha", "balloonText": "<span style='font-size:13px;'>[[title]] in [[category]]:<b>[[value]]</b> [[additional]]</span> <br>[[description]]", "dashLengthField": "dashLengthColumn", "fillAlphas": 1, "title": "Income", "type": "column", "valueField": "income", "urlField": "url" }], "categoryField": "category", "categoryAxis": { "gridPosition": "start", "axisAlpha": 0, "tickLength": 0 }
});
chart.addListener("clickGraphItem", function(event) { if ('object' === typeof event.item.dataContext.months) { // set the monthly data for the clicked month event.chart.dataProvider = event.item.dataContext.months; // update the chart title event.chart.titles[0].text = event.item.dataContext.category + ' monthly data'; // let's add a label to go back to yearly data event.chart.addLabel( 35, 20, "< Regresar", undefined, 15, undefined, undefined, undefined, true, 'javascript:resetChart();'); // validate the new data and make the chart animate again event.chart.validateData(); event.chart.animateAgain(); }
if ('object' === typeof event.item.dataContext.TipoAduana) { // set the monthly data for the clicked month event.chart.dataProvider = event.item.dataContext.TipoAduana; // update the chart title event.chart.titles[0].text = event.item.dataContext.category + ' monthly data'; // let's add a label to go back to yearly data event.chart.addLabel( 35, 20, "< Regresar", undefined, 15, undefined, undefined, undefined, true, 'javascript:resetChart();'); // validate the new data and make the chart animate again event.chart.validateData(); event.chart.animateAgain(); }
});
chart.addListener("clickGraphItem", function(event) { if ('object' === typeof event.item.dataContext.months) { // set the monthly data for the clicked month event.chart.dataProvider = event.item.dataContext.subdata; // update the chart title event.chart.titles[1].text = event.item.dataContext.category + ' monthly data'; // let's add a label to go back to yearly data event.chart.addLabel( 35, 20, "< Regresar", undefined, 15, undefined, undefined, undefined, true, 'javascript:resetChart();'); // validate the new data and make the chart animate again event.chart.validateData(); event.chart.animateAgain(); }
});
// function which resets the chart back to yearly data
function resetChart() { chart.dataProvider = chartData; chart.titles[0].text = 'Yearly data'; // remove the "Go back" label chart.allLabels = []; chart.validateData(); chart.animateAgain();
}
Developer | Otto Garcia |
Username | good886 |
Uploaded | December 02, 2022 |
Rating | 3 |
Size | 2,655 Kb |
Views | 10,120 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
3D Pie Chart - MATRIZ GENERACION ENERGIA | 1,944 Kb |
Automatically create a table of chart data on load | 2,879 Kb |
Tipo de Aduana | 2,142 Kb |
Map with dynamic Pie charts | 3,892 Kb |
Google Map Amcharts | 2,301 Kb |
Time-line map with jQuery UI slider | 5,010 Kb |
Map usa select state | 2,120 Kb |
MAPS GOOGLE MAPS | 2,314 Kb |
Capitals map | 3,079 Kb |
Loading external CSV data for bubble map | 4,720 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Twitch JSON API | Jvhti | 2,808 Kb |
Css or Czz.. | Judag | 4,111 Kb |
Border image | JohnRiordan | 2,120 Kb |
TweetBox with React JS | J0zelito | 3,325 Kb |
A Pen by Final Boss tommyb9 | FBtommyb9 | 55,354 Kb |
CSS3 Diamond | Rendro | 1,960 Kb |
Responsive Section hover effect to show content | Berdejitendra | 2,540 Kb |
BSP Dungeon Generation | Xgundam05 | 5,326 Kb |
A Pen by Paul Sullivan | Pwsm50 | 2,349 Kb |
Animate a paper plane along an SVG path, looking ahead | PotatoDie | 3,734 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!