0

I have a Chart.js bar chart, and I want some of the horizontal labels to be bolded/underlined. I am working with this example: https://www.chartjs.org/docs/latest/samples/bar/horizontal.html. The config is pasted below. How would I make the label for one particular month (e.g., February) be a different style (e.g., bolded/underlined)?

const config = {
  type: 'bar',
  data: data,
  options: {
    indexAxis: 'y',
    // Elements options apply to all of the options unless overridden in a dataset
    // In this case, we are setting the border of each horizontal bar to be 2px wide
    elements: {
      bar: {
        borderWidth: 2,
      }
    },
    responsive: true,
    plugins: {
      legend: {
        position: 'right',
      },
      title: {
        display: true,
        text: 'Chart.js Horizontal Bar Chart'
      }
    }
  },
};
Software Dev
  • 910
  • 3
  • 10
  • 27
  • This answer explains how to do it with Chart.js v2.9: https://stackoverflow.com/a/65463614/2358409 - with a few changes, it should also work for Chart.js v4. – uminder Jan 26 '23 at 15:43
  • See my answer here: https://stackoverflow.com/questions/75316500/chart-js-customize-individual-vertical-axis-labels/75341542#75341542 – Badacadabra Feb 03 '23 at 22:33

0 Answers0