简体   繁体   English

react-chartjs-2 隐藏轴 label

[英]react-chartjs-2 hiding axis label

I'm trying to hide yAxis labels.我正在尝试隐藏 yAxis 标签。 I tried display: false property, but that didn't work.我尝试了display: false属性,但这没有用。 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这是因为您的配置没有被拾取,您将 scale 配置放在options.scale命名空间 white 它需要在options.scales中配置,因此您需要在末尾添加一个额外s

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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