ChartJS 隐藏ng2图表中未使用的轴

lp0sw83n  于 2023-11-18  发布在  Chart.js
关注(0)|答案(2)|浏览(182)

我使用两个Y轴(右和左)当我隐藏其中一个的所有使用的数据集时,刻度(轴标签)变为1到-1。
我想隐藏轴或标签时,它不使用,任何想法?
隐藏前:Both Y Axes used
隐藏后:Right Y-Axis Changed - Not used
选项>缩放:

yAxes: [
            {type: "linear", id: "y-axis-0", display: true, position: "right",gridLines:{display: false},
            scaleLabel:{display: true, labelString: 'mBar'}},
            {type: "linear", id: "y-axis-1", display: true, position: "left",ticks: {beginAtZero:true},
            scaleLabel:{display: true, labelString: 'Knots/°C'} }
          ]

字符串
文件里什么都没找到。

kyxcudwk

kyxcudwk1#

If you want to remove the x axis and y axis data so to do that you need 
        to use scales and put in bar-chart-demo.ts file and inside export
          class you have to paste like that what  i mentioned below 
             and it worked . 

 public barChartOptions:any = {
  scaleShowVerticalLines: false,
     animation: false,
     scaledisplay:false,
     responsive: true,

scales: {
   xAxes: [
    {
        display: false
    }
  ],
   yAxes: [
      {
        display: false
    }
]
}

   };``

字符串

gmol1639

gmol16392#

您可以在代码中隐藏轴。只需添加一个angular on-mouseover事件,并使用negation!条件将显示设置为true/false:

scales: {
    xAxes: [
        {
            display: false
        }
    ],
    yAxes: [
        {
            display: false
        }
    ]
}

字符串

相关问题