Chartjs-Chart.js styling questions

0👍

As described here in the docs you can see you can color the gridLines for example: https://www.chartjs.org/docs/master/axes/styling.html#grid-line-configuration.

Please take a second good look at the documentation and the examples (https://www.chartjs.org/docs/master/samples/bar/vertical.html) because everything you wanted is documented and most things are also in examples

Live example:

var options = {
  type: 'line',
  data: {
    labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
    datasets: [{
      label: '# of Votes',
      data: [12, 19, 3, 5, 2, 3],
      borderWidth: 1,
      borderColor: 'red',
      backgroundColor: 'red',
      radius: 0
    }]
  },
  options: {
    scales: {
      x: {
        ticks: {
          color: 'yellow'
        },
        grid: {
          color: 'blue'
        }
      },
      y: {
        ticks: {
          color: 'purple'
        },
        grid: {
          color: 'green'
        }
      }
    }
  }
}

var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);
<body>
  <canvas id="chartJSContainer" width="600" height="400"></canvas>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.4.0/chart.js"></script>
</body>

Leave a comment