でグローバルにローカル変数を変換する? 私はイベントをブラッシングした後、フィルタリングされたデータを使用したいです。この機能外の他のいくつかのコードで これはd3.js(またはJavaScript)と私の最初のプロジェクトですので、質問は多くの意味がありません場合はごめんなさい私はグローバル変数として<strong>data_subset</strong>(<em>pc0.on(「ブラシ」、機能(data_subset)</em>)を作ることができますd3.js
サンプルコード:
d3.csv('data/cars.csv', function(data) {
pc0 = d3.parcoords()("#example0")
.data(data)
.bundlingStrength(0) // set bundling strength
.smoothness(0)
.bundleDimension("cylinders")
.showControlPoints(false)
.hideAxis(["name"])
.render()
.brushMode("1D-axes")
.reorderable()
.interactive();
// create data table, row hover highlighting
var grid0 = d3.divgrid();
d3.select("#grid0")
.datum(data.slice(0,5))
.call(grid0)
.selectAll(".row")
.on({
"mouseover": function(d0) { pc0.highlight([d0]) },
"mouseout": pc0.unhighlight
});
// update data table on brush event
pc0.on("brush", function(data_subset) {
d3.select("#grid")
.datum(data_subset.slice(0,5))
.call(grid0)
.selectAll(".row")
.on({
"mouseover": function(data_subset) { pc0.highlight([data_subset]) },
"mouseout": pc0.unhighlight
});
});
あなたはそれを割り当てることによって、何がグローバル作ることができます'window'オブジェクトに渡します。それは、世界の国家が悪いことを認識していると確信していますので、あまり使用しないでください! –