Why won't the axes on my D3 SVG figure update?

后端 未结 2 1121
谎友^
谎友^ 2021-01-17 00:26

I have a simple D3 scatterplot that I switch among displaying several different attributes of my data, but while I can get the data points to change (and to transition as I

2条回答
  •  执笔经年
    2021-01-17 00:52

    I'm not familiar with how you structured your code, but I would basically put everything that happens with the database inside the d3.csv callback function, so the final part, regarding the functionality of the text, would have the update of the x and y axis with the updated domain, like:

    d3.csv{
    //select the text then add the onclick event
    .on("click" function () {
    x.domain(d3.extent(dataset, function (d) { return /* your updated value here */); })).nice();
    //select the x-axis and then add this:
            .transition()
            .duration(1500)
            .call(xAxis);
    //then do the same for the y axis
    };}
    

    The critical step is to make sure that you select the axes correctly.

提交回复
热议问题