私はこのフィドルhttps://jsfiddle.net/fbpnzy9u/で与えられているようにディンプルバーチャートの凡例を使ってチャートのデータをフィルタリングしています。dimple.js凡例でデータをフィルタリングするとエラーが発生します
var svg = dimple.newSvg("#chartContainer", 590, 400);
var data = [
{ Animal: "Cats", Value: (Math.random() * 1000000) },
{ Animal: "Dogs", Value: (Math.random() * 1000000) },
{ Animal: "Mice", Value: (Math.random() * 1000000) }
];
var myChart = new dimple.chart(svg, data);
myChart.setBounds(60, 30, 510, 305)
var x = myChart.addCategoryAxis("x", "Animal");
x.addOrderRule(["Cats", "Dogs", "Mice"]);
myChart.addMeasureAxis("y", "Value");
myChart.addSeries("Animal", dimple.plot.bar);
var legend = myChart.addLegend(500,10,100, 100, "right");
myChart.draw();
d3.select("#btn").on("click", function() {
myChart.data = [
{ Animal: "Cats", Value: (Math.random() * 1000000) },
{ Animal: "Dogs", Value: (Math.random() * 1000000) },
{ Animal: "Mice", Value: (Math.random() * 1000000) }
];
myChart.draw(1000);
});
// filter
myChart.legends = [];
// Get a unique list of y values to use when filtering
var filterValues = dimple.getUniqueValues(data, "Animal");
// Get all the rectangles from our now orphaned legend
legend.shapes.selectAll('rect').on("click", function (e) {
// This indicates whether the item is already visible or not
var hide = false;
var newFilters = [];
//If the filters contain the clicked shape hide it
filterValues.forEach(function (f) {
if (f === e.aggField.slice(-1)[0]) {
hide = true;
} else {
newFilters.push(f);
}
});
if (hide) {
d3.select(this).style("opacity", 0.2);
} else {
newFilters.push(e.aggField.slice(-1)[0]);
d3.select(this).style("opacity", 0.8);
}
// // Update the filters
filterValues = newFilters;
//Filter the data
myChart.data = dimple.filterData(data, "Animal", filterValues);
myChart.draw(800);
});
期待通りのフィルタリングが発生したものの、それはコンソールにD3エラーがスローされます。 エラー:属性X:予想される長さ、「NaNの」
任意のアイデアこのエラーを引き起こす可能性のあるものになど?
エマは、おそらくGoogle Chromeでしか表示されないように見えます。私はIEで試してみましたが、コンソールにそのエラーが表示されていませんでした。 – mtkilic
私はそれを見るでしょう。先端に感謝します。 – Emma
あなたは本当にその問題の原因を理解しましたか?もしあなたが私たちと共有してください。ありがとうございました – mtkilic