highlightFill for chartJS中的雷达图表

时间:2015-07-04 01:50:51

标签: javascript chart.js

chartJS中的条形图可以使用highlightFill属性更改高亮显示的填充颜色:

http://www.chartjs.org/docs/#bar-chart-data-structure

var data = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
    {
        label: "My First dataset",
        fillColor: "rgba(220,220,220,0.5)",
        strokeColor: "rgba(220,220,220,0.8)",
        highlightFill: "rgba(220,220,220,0.75)",
        highlightStroke: "rgba(220,220,220,1)",
        data: [65, 59, 80, 81, 56, 55, 40]
    },
    {
        label: "My Second dataset",
        fillColor: "rgba(151,187,205,0.5)",
        strokeColor: "rgba(151,187,205,0.8)",
        highlightFill: "rgba(151,187,205,0.75)",
        highlightStroke: "rgba(151,187,205,1)",
        data: [28, 48, 40, 19, 86, 27, 90]
    }
]};
然而,雷达图没有这样的属性:

var data = {
    labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
    datasets: [
        {
            label: "My First dataset",
            fillColor: "rgba(220,220,220,0.2)",
            strokeColor: "rgba(220,220,220,1)",
            pointColor: "rgba(220,220,220,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(220,220,220,1)",
            data: [65, 59, 90, 81, 56, 55, 40]
        },
        {
            label: "My Second dataset",
            fillColor: "rgba(151,187,205,0.2)",
            strokeColor: "rgba(151,187,205,1)",
            pointColor: "rgba(151,187,205,1)",
            pointStrokeColor: "#fff",
            pointHighlightFill: "#fff",
            pointHighlightStroke: "rgba(151,187,205,1)",
            data: [28, 48, 40, 19, 96, 27, 100]
        }
    ]
};

关于如何扩展雷达图以便能够使用该属性的任何想法?

1 个答案:

答案 0 :(得分:1)

雷达图与条形图的不同之处在于, 区域实际上是整个系列(对于条形图,它是单个数据点)。

当您获得雷达工具提示时,您会想到它所代表的图表的哪个区域,您会发现它基本上只代表从中心辐射的2个点。系列的2个点之间的区域实际上是在它们之间共享的。突出一半的区域也不会很好看。

enter image description here

除此之外,一个雷达图表系列可以被第二个完全覆盖的事实,我无法想到一个非混乱的方式来为雷达图表设置悬停突出显示(想想如何你会突出显示折线图区域 - 你不是。你只是为了一个点而这样做)

enter image description here