<small id='8hEER'></small><noframes id='8hEER'>

  • <tfoot id='8hEER'></tfoot>

    <i id='8hEER'><tr id='8hEER'><dt id='8hEER'><q id='8hEER'><span id='8hEER'><b id='8hEER'><form id='8hEER'><ins id='8hEER'></ins><ul id='8hEER'></ul><sub id='8hEER'></sub></form><legend id='8hEER'></legend><bdo id='8hEER'><pre id='8hEER'><center id='8hEER'></center></pre></bdo></b><th id='8hEER'></th></span></q></dt></tr></i><div id='8hEER'><tfoot id='8hEER'></tfoot><dl id='8hEER'><fieldset id='8hEER'></fieldset></dl></div>
      <bdo id='8hEER'></bdo><ul id='8hEER'></ul>

        <legend id='8hEER'><style id='8hEER'><dir id='8hEER'><q id='8hEER'></q></dir></style></legend>

        如何在 Chart.js 2 中设置轴的步长?

        How to set axes#39; step size in Chart.js 2?(如何在 Chart.js 2 中设置轴的步长?)
          <i id='dom72'><tr id='dom72'><dt id='dom72'><q id='dom72'><span id='dom72'><b id='dom72'><form id='dom72'><ins id='dom72'></ins><ul id='dom72'></ul><sub id='dom72'></sub></form><legend id='dom72'></legend><bdo id='dom72'><pre id='dom72'><center id='dom72'></center></pre></bdo></b><th id='dom72'></th></span></q></dt></tr></i><div id='dom72'><tfoot id='dom72'></tfoot><dl id='dom72'><fieldset id='dom72'></fieldset></dl></div>
            <bdo id='dom72'></bdo><ul id='dom72'></ul>
              <tbody id='dom72'></tbody>
            <tfoot id='dom72'></tfoot>

                • <legend id='dom72'><style id='dom72'><dir id='dom72'><q id='dom72'></q></dir></style></legend>

                  <small id='dom72'></small><noframes id='dom72'>

                  本文介绍了如何在 Chart.js 2 中设置轴的步长?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用带有 3 个 Y 轴的 chart.js 创建了一个简单的折线图:https://codepen.io/anon/pen/dZVgKw

                  I created a simple line chart using chart.js with 3 Y axes: https://codepen.io/anon/pen/dZVgKw

                  如您所见,最后一个是从 10 到 20,中间没有任何数字.如何在此处设置步长?

                  As you can see, the last one is going from 10 to 20 without any number between. How can I set step size here?

                  这就是我添加斧头的方式:

                  This is how I add an axe:

                  {
                    id: 'C',
                    type: 'linear',
                    position: 'left',
                    ticks: {
                      max: 10,
                      min: 20,
                    },
                  }
                  

                  谢谢.

                  推荐答案

                  如何在此处设置步长?

                  How can I set step size here?

                  直接来自样本(线性比例,步长):

                  通过设置 stepSize 值.

                  scales: {
                    xAxes: [{
                      display: true,
                      scaleLabel: {
                        display: true,
                        labelString: 'Month'
                      }
                    }],
                    yAxes: [{
                      display: true,
                      scaleLabel: {
                        display: true,
                        labelString: 'Value'
                      },
                      ticks: {
                        min: 0,
                        max: 100,
                  
                        // forces step size to be 5 units
                        stepSize: 5 // <----- This prop sets the stepSize
                      }
                    }]
                  }
                  

                  这是一个活生生的例子:

                  Here's a live example:

                  var ctx = document.getElementById('chartJSContainer').getContext('2d')
                  
                  new Chart(ctx, {
                    type: 'line',
                    data: {
                      labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
                      datasets: [
                        {
                          label: '# of Votes',
                          data: [12, 19, 3, 5, 2, 3],
                          borderWidth: 1
                        },  
                        {
                          label: '# of Points',
                          data: [7, 11, 5, 8, 3, 7],
                          borderWidth: 1
                        }
                      ]
                    },
                    options: {
                      scales: {
                        yAxes: [{
                          ticks: {
                            reverse: false,
                            stepSize: 3
                          },
                        }]
                      }
                    }
                  })

                  <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.js"></script>
                  <body>
                      <canvas id="chartJSContainer" width="600" height="400"></canvas>
                  </body>

                  这篇关于如何在 Chart.js 2 中设置轴的步长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ChartJS Version 3 - common legend for multiple line charts(ChartJS 版本 3 - 多个折线图的常用图例)
                  Charts.js scales yaxes ticks min max doesnt work(Charts.js 缩放 yaxes 刻度 min max 不起作用)
                  How to expand the slice of donut chart in chartjs?(如何在chartjs中扩展圆环图的切片?)
                  Chart.js yAxes Ticks stepSize not working (fiddle)(Chart.js yAxes Ticks stepSize 不起作用(小提琴))
                  Rounded corners on chartJS v.2 - bar charts (with negative values)(chartJS v.2 上的圆角 - 条形图(带负值))
                  How to hide value in Chart JS bar(如何在 Chart JS 栏中隐藏值)
                    <tbody id='5zG0A'></tbody>

                  <tfoot id='5zG0A'></tfoot>
                • <small id='5zG0A'></small><noframes id='5zG0A'>

                  • <bdo id='5zG0A'></bdo><ul id='5zG0A'></ul>
                  • <i id='5zG0A'><tr id='5zG0A'><dt id='5zG0A'><q id='5zG0A'><span id='5zG0A'><b id='5zG0A'><form id='5zG0A'><ins id='5zG0A'></ins><ul id='5zG0A'></ul><sub id='5zG0A'></sub></form><legend id='5zG0A'></legend><bdo id='5zG0A'><pre id='5zG0A'><center id='5zG0A'></center></pre></bdo></b><th id='5zG0A'></th></span></q></dt></tr></i><div id='5zG0A'><tfoot id='5zG0A'></tfoot><dl id='5zG0A'><fieldset id='5zG0A'></fieldset></dl></div>

                            <legend id='5zG0A'><style id='5zG0A'><dir id='5zG0A'><q id='5zG0A'></q></dir></style></legend>