Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ChartJS - Draw chart with label by month, data by day

I'd like to draw a line chart by Chartjs with data by day, but label by month.

If label is displayed by day, then there are a lot of points. So, I'd like to display label by month instead of by day. For example:

enter image description here

Someone could teach me how to do that?

Thank you.

like image 946
user4557573 Avatar asked Apr 28 '15 16:04

user4557573


1 Answers

Just config your xAxes->time property as:
unit: 'month'

xAxes: [{
  type: 'time',
  position: 'bottom',
  time: {
    displayFormats: {'day': 'MM/YY'},
    tooltipFormat: 'DD/MM/YY',
    unit: 'month',
   }
}],
like image 64
David Merino Avatar answered Oct 22 '22 19:10

David Merino