【问题标题】:Chart js - Vue-ChartJs - Options and ticks not working for xAxisChart js - Vue-ChartJs - 选项和刻度不适用于 xAxis
【发布时间】:2020-04-25 10:05:40
【问题描述】:

我正在努力使用 ChartJs 和 VueChartJs 来自定义我的图表选项。

我希望我的 xAxis 样式为“正常”,并且我希望我的刻度步数为 5,所以这是我的不工作代码:

        scales:{
          xAxes: [{
            ticks: {
              stepSize: 5,
              fontStyle: 'normal'
            },
            scaleLabel: {
              display: true,
              labelString: 'min'
            } }],
          yAxes: [{
            display: true,
            ticks: {
              beginAtZero: true,
              maxTicksLimit: 5,
              stepSize: 5000,
              mirror: true }
            }]
        },

看起来 yAxis 运行良好,而 xAxis 不想遵循所有规则。

你们知道我做错了什么吗?

提前感谢您的帮助!

【问题讨论】:

    标签: vue.js vue-chartjs


    【解决方案1】:

    stepSize 在线性轴上工作,如果你想使用你应该将 xAxe 声明为线性,那么你还应该为你的线性刻度设置一个最小值和一个最大值,以使其正常工作。

    应该这样做:

            xAxes: [{
              type: 'linear',
              ticks: {
                  max: 40,
                  min: 0,
                  stepSize: 5
              },
              scaleLabel: {
                display: true,
                labelString: 'min'
              }
            }],
    

    【讨论】:

    • 嗨,Yuri,请回答。我尝试了您的解决方案,但没有奏效。我还尝试添加一个最小值,一个最大值等......这似乎是另一个问题
    • 我已经用您的设置对其进行了测试,它已得到纠正,现在应该可以正常工作了;)
    • Thks,这是我的解决方案!非常感谢
    猜你喜欢
    • 1970-01-01
    • 2022-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-30
    • 2021-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多