I want to make a graph chart from highcharts that count how much products have been sold from past 12 months.
For example: today is Jan, 7th
assume my sql table like this:
DATE SOLD
feb-6 5
feb-8 7
mar-10 15
mar-30 1
apr-1 6
and so on..
so the sql must produce like this: feb = 12, mar = 16, apr = .... and so on until this month. anybody can help me? coz i have no idea how to write the correct sql code.
this is my javascript:
$(document).ready(function() {
options = {
chart: {renderTo: 'chart', type: 'line', marginRight: 130, marginBottom: 25},
credits: {enabled: false},
title: {text: 'Sales Performance', x: -20},
xAxis: {categories: [{}]},
yAxis: {title: {text: 'sold'}, plotLines: [{value: 0,width: 1,color: '#808080'}]},
legend: {layout: 'vertical', align: 'right', verticalAlign: 'top', x: -10, y: 100, borderWidth: 0},
tooltip: {
formatter: function() {
var s = '<b>'+ this.x +'</b>';
$.each(this.points, function(i, point) {
s += '<br/>'+point.series.name+': '+point.y;
});
return s;
},
shared: true
},
series: [{},{}]
};
$.ajax({
url: "generate_graph",
data: 'date='+dateText,
type: 'post',
dataType: "json",
success: function(data){
options.xAxis.categories = data.categories;
options.series[0].name = data.name;
options.series[0].data = data.value;
var chart = new Highcharts.Chart(options);
}
});
})