本文介绍了D3数据更新Boxplot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更新3 svgs(BoxPlots)。在下面的代码中,var svg包含3个svgs的数组,并且 _data _ 已更新为正确的记录数。我遵循,但看不到我做错了什么。

I am trying to update 3 svgs (BoxPlots). In the following code the var svg contains an array of the 3 svgs and the _data_ has been updated to the correct number of records. I follow the BoxPlot Example , but cannot see what I am doing wrong.

$('#Records li a').click(function(){

$('#Records li a ').click(function() {

    var id =  event.target.id;
    var idparts = id.split("_");
    var numrec =  idparts[1];

    d3.json("./php/connection2.php?numrecs="+numrec, function (error, csv) {
        d3.json("./php/connection2.php?numrecs="+numrec, function (error, csv) {
        var chart = d3.box()
            .whiskers(iqr(1.5))
            .width(width)
            .height(height);
        var numericArray = createdata(csv);
        chart.domain([min, max]);
        var svg = d3.selectAll("svg")
        svg.data(numericArray).call(chart.duration(1000));


    });

    $('#RecordsDropdown').removeClass("open");
    return false;

});
});

}); });

Ive也试过:
.....

Ive also tried:.....

thisdata=numericArray;
            var svg = d3.selectAll("svg");
            svg.data(thisdata);
            svg.call(chart.duration(1000));
            //updatedata(svg);

尝试创建新离群值时收到此错误

I am getting this error when it tries to create new outliers

Uncaught Error: NotFoundError: DOM Exception 8


推荐答案

我发现如果你在box.js中删除行〜158的insert(text):

I found that if you remove the insert("text") at line ~158 in box.js:

//change this:
//outlier.enter().insert("circle", "text")
// to this:
outlier.enter().insert("circle")

这将阻止

Uncaught Error: NotFoundError: DOM Exception 8

我不得不改变的唯一的其他事情是确保它附加新异常值在g我的盒子图,当我打电话给它动画。

The only other thing that I had to change was to make sure that it appended the new outlier in the g of my box plot when I called it to animate it. Otherwise they'll be off a bit.

var svg = d3.selectAll(".box" + Attr + sample + " g")
    .data(data);
    svg.call(chart.duration(1000));

我不知道文字是什么。

这篇关于D3数据更新Boxplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 04:30