jeudi 7 juillet 2016

Chart.js - Line charts: draw points between grid lines


I'm creating line charts using Chart.js version 2.1.3.

I want to center labels and points between grid lines on the x axis (like in bar charts).

For labels, I use the option 'offsetGridLines' that offset labels from grid lines:

scales: {
    xAxes: [{
        gridLines: {
            offsetGridLines: true
        }
    }],
    ...

Nevertheless, I can't found a convenient solution to center points.

Here is my initial example (labels placed between grid lines): https://jsfiddle.net/24aotbnc/1/.

And here is my non-elegant solution that creates an empty dataset of type 'bar' and removes it after chart creation (points are drawn between gridlines): https://jsfiddle.net/24aotbnc/2/

Can someone provide a better solution? Thanks.


Aucun commentaire:

Enregistrer un commentaire