NPashaP / Viz

BSD 3-Clause "New" or "Revised" License
106 stars 39 forks source link

Update function issue! #21

Open Smmw opened 6 years ago

Smmw commented 6 years ago

This is the graph before update image After I click "A" it will update the graph, then image This is the code I made for update

`var bp = viz.biPartite()
    .height(580)
    .width(chartContainer.width() - 230)
    .keyPrimary(d=>d.group)
    .keySecondary(d=>d.subgroup)
    .value(d=>d.count)
    .data(data);

g.call(bp);

g.selectAll(".viz-biPartite-mainBar")
    .on("mouseover", mouseover)
    .on("mouseout", mouseout)
    .on("click", mouseClick);

g.selectAll(".viz-biPartite-mainBar")
    .append("text")
    .attr("class","label")
    .attr("x", d => (d.part == "primary" ? -30 : 30))
    .attr("y", d => +6)
    .text(d => d.key)
    .attr("text-anchor", d => (d.part == "primary" ? "end" : "start"));

g.selectAll(".viz-biPartite-mainBar")
    .append("text")
    .attr("class", "perc")
    .attr("x", d => (d.part == "primary" ? -100 : 80))
    .attr("y", d => +6)
    .text(function (d) { return d3.format("0.0%")(d.percent) })
    .attr("text-anchor", d => (d.part == "primary" ? "end" : "start"));

function mouseClick(d){
    childChartsId.forEach( function (data) {
        if(data.group === d.key){
            sendRequest("/api/mongodb/findByID", "data", JSON.stringify(new queryObject("analysis_charts_data", data.chartId)), function (chartsData) {
                // executeFunctionByName(chartsData.functionName, chartsData, $(".resultUserCharts"));
                // g.call(bp.data(chartsData.data));                    
                bp.update(chartsData.data);
            });
        }
    })
}`

Is this a BUG?

d3 version: 4.12.2 viz version: 1.4.0

Thanks!