简体   繁体   中英

react-chartjs-2 hiding axis label

I'm trying to hide yAxis labels. I tried display: false property, but that didn't work. My code below:

export const options = {
  responsive: true,
  interaction: { includeInvisible: true, intersect: false },
  tooltip: {
    backgroundColor: "rgba(0, 0, 0, 0.3)",
    displayColors: false,
    multiKeyBackground: "rgba(0, 0, 0, 0)",
  },
  scale: {
    y1: {
      min: 0,
      ticks: {
        count: 5,
      },
      grid: { borderDash: [3], color: "rgb(126,126,126)", tickLength: 0 },
    },
    y2: {
      display: false,
      position: "right",
      max: Math.max(...BTCPrices.map((el) => el.Volume)) * 10,
      ticks: {
        count: 5,
      },
    },
    x: {
      ticks: {},
    },
  },
  plugins: {
    legend: {
      display: false,
    },
  },
};

here's the image describing the problem Thanks for helping!

This is because your config is not getting picked up, you putted your scale config in the options.scale namespace white it needs to be configured in the options.scales so you need to add an extra s at the end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM