如何使用 Vue.js 在 Chart.js 中添加 Y 轴标签?

时间:2021-06-04 09:19:00

标签: vue.js chart.js vue-chartjs

我想添加字符串 '$' y 轴值的比例。 enter image description here

我的代码:

 fillData() {
  this.datacollection = {
    labels: this.time,
    datasets: [
      {
        label: 'PNL ($)',
        backgroundColor: 'rgba(0,80,0,0.2)',
        borderColor: 'lightgreen',
        pointBackgroundColor: 'green',
        borderWidth: 1,
        pointBorderColor: 'green',
        data: this.PNL,
        steppedLine: true,
        // fill: false,
      },
    ],
    options: {
      scales: {
        y: {
          ticks: {
            // Include a dollar sign in the ticks
            callback: (value) => value + '$',
          },
        },
      },
    },

Y 轴应该是这个 10$

0 个答案:

没有答案
相关问题