Well I’ve been having some troubles with these
def inicio(request): query = Clients.objects.raw('SELECT DISTINCT Id_Compra,MONTH(Fecha) as DateF FROM `HypermedialAPP_clients` WHERE Medio = "Facebook"') for qwe in query : print(qwe.DateF) #Result of print [2,1,3] so I got 3 months Jan,Feb,March qweDate = qwe.DateF query_countFB = Clients.objects.raw('SELECT DISTINCT Id_Compra,COUNT(*) as MaxFB FROM `HypermedialAPP_clients` WHERE Medio = "Facebook" and MONTH(Fecha) = %s GROUP BY Id_Compra', [qwe.DateF]) for zxc in query_countFB: print (zxc.MaxFB) #Result of print [1,1,1] so I buy 3 things in 3 months, one on each one zxc_counted = zxc.MaxFB context = { "zxc_counted" : zxc.MaxFB, } return render(request,"inicio.html",context)
but all it’s ok but when I finally do the next on the Series
<script type="text/javascript"> Highcharts.chart('container', { chart: { type: 'column' }, title: { text: 'Monthly Average Rainfall' }, subtitle: { text: 'Source: WorldClimate.com' }, xAxis: { categories: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ], crosshair: true }, yAxis: { min: 0, title: { text: 'Rainfall (mm)' } }, tooltip: { headerFormat: '<span style="font-size:10px">{point.key}</span><table>', pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' + '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>', footerFormat: '</table>', shared: true, useHTML: true }, plotOptions: { column: { pointPadding: 0.2, borderWidth: 0 } }, series: [{ name: 'Facebook', data: [ {%for zxc in query_countFB%} {{zxc.MaxFB}}, {%endfor%} ] }, { name: 'WhatsApp', data: [83.6,83.6] }, { name: 'MercadoLibre', data: [48.9] }, { name: 'MediosFisicos', data: [42.4] },{ name: 'WooCommerce', data: [42.4] } ] }); </script>
as You can see is only getting 1 bar purchase of the 3 months , I mean there would be 1 purchase on each month: January Febrary and March of Facebook bar
in order to get more info maybe here is the SQL query’s
Help Please I don’t know why is missing the other 2 purhcase of Feb and March