How can I decrease the number of bars to display according to the month we are?
Ec: Currently our month is 11 (Nov), so I would like to see only the top 10 columns of the chart.
Before assembling the graph, you have to think about how and what it will show, since a graph is based on values, that is, it is a visual representation of values passed by the user, data coming from request HTTP , or even a JSON file.
By getting the data, the first thing you should do is to manipulate it so that it is in the form you want to display on the chart. Example:
In conclusion, first mount all your strategy, from what the chart will look like, how it will look, how it will be viewed, and then you will pick up the data, filter it, and then move on to the chart.
I hope I have helped.
I did something similar in highcharts. just put a function that will act as a data manipulator before being delivered to the charts.
Then in this function you check the month and use the rule you want.
something like
var data = function (array) {
var ret = [];
var mes = new Date().getMonth(); // janeiro é 0
for(var k in array){
if(k < mes){
ret.push(array[k]);
}
}
return ret;
} (array);
This way you make a filter, and since January is 0, November is 10, and the variable k goes through its array q assuming it is 1 for each month it goes from 0 to 11. Then the condition k < mes perfectly.
I hope to have helped a little