• Demos
    • JavaScript Charts
    • JavaScript StockCharts
  • Download/NPM
    • Download CanvasJS
    • Install via NPM
  • Integrations
    Front End Technology Samples
    • React Charts
    • Angular Charts
    • Vue.js Charts New!
    • jQuery Charts
    • Dashboards
    Server Side Technology Samples
    • PHP Charts
    • Python Charts New!
    • ASP.NET MVC Charts
    • Spring MVC Charts
    • JSP Charts
  • License
  • Blog
  • Docs
    • Chart Documentation
    • StockChart Documentation
  • Support Forum
    • Chart Support
    • StockChart Support
  • My Account
My Account
  • KEY FEATURES
    • Basic Chart
    • Chart with Animation
    • Chart with Zooming/Panning
    • Multi Series Chart
    • Chart with Multiple Axes
    • Chart with Logarithmic Axis
    • Chart with JSON Data
    • Dynamic Chart
    • Drilldown Chart
    • Responsive Chart
    • Synchronized Charts
  • LINE CHARTS
    • Line Chart
    • Dashed Line Chart
    • Multi Series Line Chart
    • Spline Chart
    • Multi Series Spline Chart
    • Step Line Chart
    • Multi Series Step Line Chart
  • BAR CHARTS
    • Bar Chart with Category Axis
    • Multi Series Bar Chart
    • Stacked Bar Chart
    • Stacked Bar 100% Chart
  • COLUMN CHARTS
    • Column Chart with Category Axis
    • Column Chart in Dark Theme
    • Multi Series Column Chart
    • Stacked Column Chart
    • Stacked Column 100% Chart
  • PIE & DOUGHNUT CHARTS
    • Pie Chart
    • Doughnut Chart
    • Doughnut Chart in Dark Theme
  • AREA CHARTS
    • Area Chart with Markers
    • Multi Series Area Chart
    • Spline Area Chart
    • Multi Series Spline Area Chart
    • Step Area Chart
    • Stacked Area Chart
    • Stacked Area 100% Chart
  • RANGE CHARTS
    • Range Column Chart
    • Multi Series Range Column Chart
    • Range Bar Chart
    • Multi Series Range Bar Chart
    • Range Area Chart
    • Multi Series Range Area Chart
    • Range Spline Area Chart
    • Multi Series Range Spline Area Chart
  • BUBBLE & SCATTER CHARTS
    • Bubble Chart with 3-Dimensional Data
    • Bubble Chart in Dark Theme
    • Scatter Chart
    • Multi Series Scatter Chart
  • FUNNEL & PYRAMID CHARTS
    • Funnel Chart with Index Labels
    • Funnel Chart without Neck
    • Pyramid Chart
  • FINANCIAL CHARTS
    • Candlestick Chart
    • Candlestick Chart from JSON Data
    • OHLC Chart
    • OHLC Chart from JSON Data
    • Box & Whisker Chart
    • Waterfall Chart
  • COMBINATION CHARTS
    • Pareto Chart
    • Error Bar Chart
    • Combination of Range Area & Line Chart
    • Combination of Candlestick & Line chart
  • DYNAMIC CHARTS
    • Dynamic Line Chart
    • Dynamic Column Chart
  • DATA BINDING
    • Chart with Data from CSV
    • Chart with Data from Database
    • Chart with Date-Time Axis from Database
  • JAVASCRIPT, JQUERY, REACT, ANGULAR, VUE.JS
    • JavaScript Charts
    • jQuery Charts
    • React Charts
    • Angular Charts
    • Vue.js Charts
  • SERVER SIDE TECHNOLOGIES
    • ASP.NET MVC Charts
    • PHP Charts
    • Spring MVC Charts
    • JSP Charts

Python Drilldown Charts using Django

Download Python Django Chart Samples
  • Python Django Chart Samples
  • JavaScript Chart Samples
  • React Chart Samples
  • Angular Chart Samples
  • Vue.js Chart Samples
  • jQuery Chart Samples
  • PHP Chart Samples
  • ASP.NET Chart Samples
  • JSP Chart Samples
  • Spring MVC Chart Samples
  • Dashboard Samples
  • JavaScript StockChart Samples

Python Drilldown Charts are used to expand & analyze data in more depth. For example, you can drilldown year to months, month to days & so on. Example shows Drilldown Chart built using Django MVT framework along with source code that you can try out locally.

  • Template
  • View
<!— index.html —>
{% load static %}
<!DOCTYPE HTML>
<html>
<head>
<title>CanvasJS Python Charts</title>
<script>
window.onload = function () {
 
var totalVisitors = 883000;
var visitorsData = {
	"New vs Returning Visitors": [{
		click: visitorsChartDrilldownHandler,
		cursor: "pointer",
		explodeOnClick: false,
		innerRadius: "75%",
		legendMarkerType: "square",
		name: "New vs Returning Visitors",
		radius: "100%",
		showInLegend: true,
		startAngle: 90,
		type: "doughnut",
		dataPoints: {{ new_vs_returning_visitors|safe }}
	}],
	"New Visitors": [{
		color: "#DF7970",
		name: "New Visitors",
		type: "column",
		xValueType: "dateTime",
		dataPoints: {{ new_visitors|safe }}
	}],
	"Returning Visitors": [{
		color: "#4C9CA0",
		name: "Returning Visitors",
		type: "column",
		xValueType: "dateTime",
		dataPoints: {{ returning_visitors|safe }}
	}]
};
 
var newVSReturningVisitorsOptions = {
	animationEnabled: true,
	theme: "light2",
	title: {
		text: "New VS Returning Visitors"
	},
	subtitles: [{
		text: "Click on Any Segment to Drilldown",
		backgroundColor: "#4C9CA0",
		fontSize: 16,
		fontColor: "white",
		padding: 5
	}],
	legend: {
		fontFamily: "calibri",
		fontSize: 14,
		itemTextFormatter: function (e) {
			return e.dataPoint.name + ": " + Math.round(e.dataPoint.y / totalVisitors * 100) + "%";
		}
	},
	data: []
};
 
var visitorsDrilldownedChartOptions = {
	animationEnabled: true,
	theme: "light2",
	axisX: {
		labelFontColor: "#717171",
		lineColor: "#a2a2a2",
		tickColor: "#a2a2a2"
	},
	axisY: {
		gridThickness: 0,
		includeZero: false,
		labelFontColor: "#717171",
		lineColor: "#a2a2a2",
		tickColor: "#a2a2a2",
		lineThickness: 1
	},
	data: []
};
 
var chart = new CanvasJS.Chart("chartContainer", newVSReturningVisitorsOptions);
chart.options.data = visitorsData["New vs Returning Visitors"];
chart.render();
 
function visitorsChartDrilldownHandler(e) {
	chart = new CanvasJS.Chart("chartContainer", visitorsDrilldownedChartOptions);
	chart.options.data = visitorsData[e.dataPoint.name];
	chart.options.title = { text: e.dataPoint.name }
	chart.render();
	$("#backButton").toggleClass("invisible");
}
 
$("#backButton").click(function () {
	$(this).toggleClass("invisible");
	chart = new CanvasJS.Chart("chartContainer", newVSReturningVisitorsOptions);
	chart.options.data = visitorsData["New vs Returning Visitors"];
	chart.render();
});
 
}
</script>
<style>
#backButton {
	border-radius: 4px;
	padding: 8px;
	border: none;
	font-size: 16px;
	background-color: #4C9CA0;
	color: white;
	position: absolute;
	top: 10px;
	right: 10px;
	cursor: pointer;
}
 
.invisible {
	display: none;
}
</style>
</head>
<body>
    <div id="chartContainer" style="height: 360px; width: 100%;"></div>
    <button class="btn invisible" id="backButton">&lt; Back</button>
    <script src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
    <script src="{% static 'canvasjs.min.js' %}"></script>
</body>
</html>                              
from django.shortcuts import render

def index(request):
    new_visitors = [
        { "x": 1609439400000, "y": 33000 },
        { "x": 1612117800000, "y": 35960 },
        { "x": 1614537000000, "y": 42160 },
        { "x": 1617215400000, "y": 42240 },
        { "x": 1619807400000, "y": 43200 },
        { "x": 1622485800000, "y": 40600 },
        { "x": 1625077800000, "y": 42560 },
        { "x": 1627756200000, "y": 44280 },
        { "x": 1630434600000, "y": 44800 },
        { "x": 1633026600000, "y": 48720 },
        { "x": 1635705000000, "y": 50840 },
        { "x": 1638297000000, "y": 51600 },
    ]
    returning_visitors = [
        { "x": 1609439400000, "y": 22000 },
        { "x": 1612117800000, "y": 26040 },
        { "x": 1614537000000, "y": 25840 },
        { "x": 1617215400000, "y": 23760 },
        { "x": 1619807400000, "y": 28800 },
        { "x": 1622485800000, "y": 29400 },
        { "x": 1625077800000, "y": 33440 },
        { "x": 1627756200000, "y": 37720 },
        { "x": 1630434600000, "y": 35200 },
        { "x": 1633026600000, "y": 35280 },
        { "x": 1635705000000, "y": 31160 },
        { "x": 1638297000000, "y": 34400 },
    ]
    new_vs_returning_visitors = [
        { "name": "New Visitors", "y": 519960, "color": "#DF7970" },
        { "name": "Returning Visitors", "y": 363040, "color": "#4C9CA0" },
    ]

    return render(request, 'index.html', { "new_visitors" : new_visitors, "returning_visitors": returning_visitors, "new_vs_returning_visitors": new_vs_returning_visitors })                        

Chart Customizations

Setting explodeOnClick to false disables exploding of datapoint on click. Type of the chart can be changed to 'line', 'column', 'pie', etc. by changing type property in dataseries level. The radius and innerRadius of Doughnut chart can also be customized

Quick Links

  • Chart Docs
  • StockChart Docs
  • About Us
  • FAQs

Server Side Technologies

  • ASP.NET MVC Charts
  • PHP Charts
  • JSP Charts
  • Spring MVC Charts

Front Side Technologies

  • JavaScript Charts
  • jQuery Charts
  • React Charts
  • Angular Charts
  • JavaScript StockCharts

Contact

  • Fenopix, Inc.
  • 2093 Philadelphia Pike,
  • #5678, Claymont,
  • Delaware 19703
  • United States Of America

©2025 Fenopix Privacy Policy Cookies Policy Careers