更新d3.js雷达图

时间:2015-03-20 12:04:59

标签: javascript d3.js

我是D3的新手,想知道如何更新以下图表:JSFiddle。这是一个非常庞大的代码,所以我对下一步该做什么感到很遗憾。

它只在控制台中打印“here”。

function update() {
    console.log("here");
    var json = [
        [
            {"axis":"A","value":0},
            {"axis":"B","value":0},
            {"axis":"C","value":0},
            {"axis":"D","value":0},
            {"axis":"E","value":0},
            {"axis":"F","value":0},
            {"axis":"G","value":0},
            {"axis":"H","value":0},
            {"axis":"I","value":0}
        ]
    ];
    drawRadarChart('#chart-radar', wMaior, wMaior);
};

1 个答案:

答案 0 :(得分:0)

您的数据存储在您已定义的变量json中。您可以将新数据保存在此变量中并更新图表。尝试更改功能更新():

function update() {
    console.log("here");
    json = [
        [
            {"axis":"A","value":0},
            {"axis":"B","value":0},
            {"axis":"C","value":0},
            {"axis":"D","value":0},
            {"axis":"E","value":0},
            {"axis":"F","value":0},
            {"axis":"G","value":0},
            {"axis":"H","value":0},
            {"axis":"I","value":0}
        ]
    ];
    drawRadarChart('#chart-radar', wMaior, wMaior);
};

这样您就会得到一个新的空图表,因为值为0。