簡體   English   中英

將自定義數據比例添加到Chart.js

[英]Add custom data scale to Chart.js

我在Chart.js中使用基本圖表-我想知道是否有可能在軸上使用自定義比例 ,因此例如,我希望將數據點繪制在0-10數據比例上。 這可能嗎?

<canvas id="myChart" width="150" height="150"></canvas>
<script>
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
    type: 'radar',
    data: {
        labels: ["Staying well", "Looking after yourself", "Where you live", "Feeling safe and being listened to", "Making decisions and managing money", "How you feel"],

        datasets: [{
            label: "Careplan",
            backgroundColor: "rgba(179,181,198,0.2)",
            borderColor: "rgba(179,181,198,1)",
            pointBackgroundColor: "rgba(179,181,198,1)",
            pointBorderColor: "#fff",
            pointHoverBackgroundColor: "#fff",
            pointHoverBorderColor: "rgba(179,181,198,1)",
            data: [5, 8, 9, 4, 6, 6, 5]
        }]
    },
});
</script>

這里查看我的問題並回答

您需要設置scaleStepsscaleStepWidthscaleStartValue 在上面的示例中是:

scaleSteps: 4,
scaleStepWidth: 5,
scaleStartValue: 0

其中總共有20條帶有4行。 您可以使用這些值來獲得所需的效果。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM