[Chartjs]-How to plot date/time on X but display only dates in Chart.js?

1👍

http://www.chartjs.org/docs/latest/axes/cartesian/time.html#ticks-source
http://www.chartjs.org/docs/latest/axes/labelling.html#scale-title-configuration

You could try changing

ticks: {
   source:'data',
},

… to source:'auto' which auto-truncates tick labels for you, and just see what that looks like …

The time-scale display format for X-axis is described here, so you can format it to whatever Moment.js time format you want, e.g. 'YYYY-mm-dd:

 xAxes: [{
                type: 'time',
                time: {
                    displayFormats: {
                        quarter: 'MMM YYYY'
                    }
                }
            }]

… Though it looks like maybe you have that in there already. Is it not showing any x-axis ticks? Is it showing any errors?

Or you could try following this example to override the callback method for a custom ‘tick’ if you want to include something besides the date/time. Their example was to append a dollar sign before all the values. If you only want to deal w/date-time then the above solution ought to be enough.

Leave a comment