I have a chart in my django based project wher I need to display two series of data (previsions and consommations) over the twelve months of the year
The problem is that when my data doesnt start from january (for example) , I still have to display january with empty data
This works for one of the series (prvisiosns) but not the other meaning that previsions start frm february as it should be but consommations start from january in the chart althought its data is starting from february
please take a look at my code below speacially the section {% block graph_data %}
Here is my code:
<script type="text/javascript">
$(document).ready(function() {
{% if data %}
var chart = new Highcharts.Chart({
chart: {
renderTo: 'graph',
{% block graph_type %}defaultSeriesType: 'column',{% endblock %}
marginRight: 125,
marginBottom: 25
},
title: {
text: '{% block graph_title %}Consommation{% endblock %}',
x: -20 //center
},
xAxis: {
{% block graph_xaxis %}
categories: [{% for i in xaxis %}'{{ i|title }}'{% if not forloop.last %},{% endif %}{% endfor %}]
{% endblock %},
},
yAxis: {
title: {
text: 'Consommation (MWh)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
{% block tooltip %}
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +'{% block graph_tooltip_unite %}{% endblock %}: '+ this.y.toFixed(2) +' MWh';
}
},
{% endblock %}
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: 20,
y: 100,
borderWidth: 0
},
series: [
{% block graph_data %}
{
name: 'Consommations',
data: [
{% for h in data|dictsort:"date__mois" %}
{{ h.quantite|safe }}/1000
{% if not forloop.last %},{% endif %}
{% endfor %}
]
}
{% if user.profil.is_gold %}
,{
name: 'Prévisions',
data: [
{% for h in previsions|dictsort:"mois" %}
{{ h.mwh|safe }}
{% if not forloop.last %},{% endif %}
{% endfor %}
]
}
{% endif %}
{% endblock %}
]
});
{% else %}
{% if request.POST %}
$('#graph').html('<div class="aucune_donnee">Aucune donnée disponible pour les critères sélectionnés.</div>');
{% endif %}
{% endif %}
var blanco = "<div class='blanco'></div>";
$("#graph").append(blanco);
});
This is driving me crazy since a week but I can see whats the problem, but it's my frist time with highcharts..so any help would be greatly appreciated,Thanks