Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Dashed gridlines in Chart.js version 4.x

How can I make dashed gridlines in Chart.js? I know about the borderDash property, but this doesn’t work for me, and in the documentation I don’t find anything about this.

scales: {
   y: {
     grid: {
        drawTicks: false,
        borderDash:[5,5], //thid don't work
        display: true
     }
   }
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Since version 4, the border is a specific config node of the axes.

See Migration guide: https://www.chartjs.org/docs/latest/migration/v4-migration.html#specific-changes

Your config should be:

scales: {
   y: {
     border: {
       dash: [5, 5],
       display: true
     } 
     grid: {
        drawTicks: false,
        display: true
     }
   }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading