gpt4 book ai didi

javascript - 将自定义数据比例添加到 Chart.js

转载 作者:行者123 更新时间:2023-11-30 15:59:16 24 4
gpt4 key购买 nike

我在 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>

最佳答案

查看我的问答HERE

您需要设置scaleStepsscaleStepWidthscaleStartValue。在上面的例子中是:

scaleSteps: 4,
scaleStepWidth: 5,
scaleStartValue: 0

总共有 20 个,有 4 行通过。您可以尝试使用这些值来获得所需的效果。

关于javascript - 将自定义数据比例添加到 Chart.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38015572/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com