0

我需要更新数据点的X 和 Y 坐标click event并将其移动到绘图上的新位置。

代码

var sample_data = [
  {"value": 100, "weight": .45, "type": "alpha"},
  {"value": 70, "weight": .60, "type": "beta"},
  {"value": 40, "weight": 0.80, "type": "gamma"},
  {"value": 15, "weight": .32, "type": "delta"}
];

$(function(){
  var visualization = d3plus.viz()
                            .container("#dv-container")
                            .data(sample_data)
                            .type("scatter")
                            .id("type")
                            .x("value")
                            .y("weight")
                            .height(400)
                            .width(600)
                            .draw();

  $("#btnUpdate").click(function(){
    //update the value of first data point
    sample_data[0].value = 50;
    sample_data[0].weight = 0.5;

    //this is where I need help to update the chart
  });
});

小提琴

4

1 回答 1

2

重绘 visualization.data(sample_data).draw();按钮单击:

 $("#btnUpdate").click(function(){
        //update the value of first data point
        sample_data[0].value = 50;
        sample_data[0].weight = 0.5;
        //redraw
        visualization.data(sample_data).draw();
    });

工作代码在这里

于 2016-08-08T08:06:46.883 回答