Chart JS手册条形图YAxis

时间:2018-03-18 19:46:05

标签: chart.js

我正在开发一个使用1-10的评级的项目。 ChartJs中的自动缩放导致数据由于不在范围内而未显示的问题。

如何删除条形图yxais的自动缩放并手动将比例设置为1-10?

<canvas id="bar-chart-grouped" width="800" height="350"></canvas>
<script>
    new Chart(document.getElementById("bar-chart-grouped"), {
    type: 'bar',
    data: {
      labels: [{% for result in results %}
                  "{{result.title}}",
              {% endfor %}],
      datasets: [
        {
          label: "Rating",
          backgroundColor: "#3e95cd",
          data: [{% for result in results %}
                  "{{result.w_average}}",
              {% endfor %}]
        }, {
          label: "My Rating",
          backgroundColor: "#3cba9f",
          data: [{% for result in results %}
                  "{{result.rating}}",
              {% endfor %}]
        }
      ]
    },
    options: {
      title: {
        display: true,
        text: 'Movie Ratings'
      }
    }
    });
</script>

0 个答案:

没有答案