Skip to content
The Chat Archive
wizardlm-70b Arena Human Preference 55K

in chartjs bar chart, currently the grid lines are left and right to the bars, i want…

  1. User

    in chartjs bar chart, currently the grid lines are left and right to the bars, i want them to be centered at the bars.. so basically as if the lines are inside the bars

  2. Assistant

    To center grid lines at the bars in a Chart.js bar chart, you can follow these steps:

    1. Add the bar plugin to the chart options.
    2. To align the grid lines, set the grid property of the bar options.

    Here's an example of how to do this:

    new Chart(document.getElementById('myChart'), {
      type: 'bar',
      data: {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [{
          label: '# of Votes',
          data: [12, 19, 3, 5, 2, 3],
          backgroundColor: [
            'rgba(255, 99, 132, 0.2)',
            'rgba(54, 162, 235, 0.2)',
            'rgba(255, 206, 86, 0.2)',
            'rgba(75, 192, 192, 0.2)',
            'rgba(153, 102, 255, 0.2)',
            'rgba(255, 159, 64, 0.2)'
          ],
          borderColor: [
            'rgba(255, 99, 132, 1)',
            'rgba(54, 162, 235, 1)',
            'rgba(255, 206, 86, 1)',
            'rgba(75, 192, 192, 1)',
            'rgba(153, 102, 255, 1)',
            'rgba(255, 159, 64, 1)'
          ],
          borderWidth: 1
        }]
      },
      options: {
        scales: {
          x: {
            ticks: {
              beginAtZero: true
    

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.