class BarChartJSONView(BaseColumnsHighChartsView):
def get_title(self):
return "Testing bar charts"
def get_labels(self):
return ['Africa', 'America', 'Asia', 'Europe', 'Oceania']
def get_yUnit(self):
return "What is this?!"
def get_providers(self):
return ["Year 1800", "Year 1900", "Year 2000"]
def get_data(self):
return [[107, 31, 635, 203, 2], [133, 156, 947, 408, 6], [1052, 954, 4250, 740, 38]]
path('chartJSON', views.BarChartJSONView.as_view(), name='bar_chart_json'),
<script type="text/javascript">
$.get('{% url "accounts:bar_chart_json" %}', function(data) {
var ctx = $("#myChart").get(0).getContext("2d");
new Chart(ctx, {
type: 'bar', data: data
});
});
</script>
Line chart works fine, but just a simple change to implement a bar chart just returns a grid with 1.0 max on Y axis.
My view:
My url:
Template:
Line chart works fine, but just a simple change to implement a bar chart just returns a grid with 1.0 max on Y axis.