ruby-on-railsrubyrubygemschart.jschartkick

Support for dark and light mode in ChartKick


Chat JS seems to be offering dark and light mode support according to this GitHub PR: https://github.com/chartjs/Chart.js/pull/8685

The question is, how to call colorMode: "auto" in ChartKick as ChartJS default is none...


Solution

  • The mr got closed, so there is no colorMode option in chart.js. To achieve a dark/light mode you will need to adjust all of the colors yourself.

    The main colors you want to adjust are data.datasets[datasetIndex].backgroundColor and options.scales[scaleId].grid.color. That will make most of your chart be visible on light and dark