我有一个雷达图显示(几乎)想要的。唯一的问题是,比例尺应该上升到20,但是,如下所示,突出显示的点是17,不在图表中。如何缩放比例,以便最大点将为20,并且所显示的突出显示的点将在图表内?



我当前的代码是:

var radarChartData = {
    labels: ["ATT", "SPD", "POW", "DEF", "STA", "TEC"],
    datasets: [ {
        scaleOverride: true,
        scaleSteps: 5,
        scaleStepWidth: 5,
        scaleStartValue: 0,
        pointLabelFontSize: 16,
        fillColor: "rgba(0,120,0,0.2)",
        strokeColor: "rgba(0,120,0,1)",
        pointColor: "rgba(10,10,10,1)",
        pointStrokeColor: "#ccc",
        pointHighlightFill: "#333",
        pointHighlightStroke: "rgba(255,255,0,1)",
        data: [12,15,17,16,11,13]
    } ]
};


我以为将更改此设置的是scaleStepsscaleStepWidthscaleStartValue选项,但似乎并没有影响它。

编辑:它似乎并不影响另一组数据...



如您所见,图表中确实包含17的值。此代码是:

var radarChartData = {
    labels: ["ATT", "SPD", "POW", "DEF", "STA", "TEC"],
    datasets: [ {
        scaleOverride: true,
        scaleSteps: 5,
        scaleStepWidth: 5,
        scaleStartValue: 0,
        pointLabelFontSize: 16,
        fillColor: "rgba(0,120,0,0.2)",
        strokeColor: "rgba(0,120,0,1)",
        pointColor: "rgba(10,10,10,1)",
        pointStrokeColor: "#ccc",
        pointHighlightFill: "#333",
        pointHighlightStroke: "rgba(255,255,0,1)",
        data: [19,17,15,6,16,15]
    } ]
};


2和有什么区别?第二个ATT的值为19,但它位于图表中就可以了。

最佳答案

好的,我发现需要将scaleStepsscaleStepWidthscaleStart移到新的Radar图表的声明中,如下所示,而不是移动到数据集中。

window.onload = function(){
var ctx = document.getElementById("radarCanvas").getContext("2d");
window.myRadar = new Chart(ctx).Radar(radarChartData, {
responsive: false,
    pointDot:false,
    showTooltips: false,
    scaleOverride: true,
    scaleSteps: 4,
    scaleStepWidth: 5,
    scaleStartValue: 0
}); }


有关工作示例,请参见http://jsfiddle.net/7p8ffvqx/

09-11 07:51