ich den Code unter einem Drop-Down für die Erstellung von:d3.js Dropdown-Menü - wählen verwandten Knoten
var arrayOfGroups = [];
function makearray(){
node.each(function(d){
if(arrayOfGroups.indexOf(d.group) < 0){
arrayOfGroups.push(d.group)
}
})
console.log(arrayOfGroups)
return arrayOfGroups;
}
var newArray = makearray();
var container = document.getElementById('selectContainer')
var dropdown = creatSelectDropDown('thisDropdown', newArray);
dropdown.onchange = function(event) {
console.log(event)
node.style('stroke', 'white')
.style('stroke-width', '1px');
node.filter(function(d) {
return d.group == event.id;
})
.each(function(d) {
console.log(d)
console.log('d')
})
.style('stroke', 'red')
.style('stroke-width', '5px')
}
container.appendChild(dropdown)
function creatSelectDropDown(id, array) {
var dropdown = document.createElement("select");
dropdown.id = id;
for (var i = 0; i < array.length; i++) {
var option = document.createElement("option");
option.text = array[i];
option.id = array[i];
dropdown.options.add(option);
}
return dropdown;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
Dieser Code wählt Knoten, das Problem ist, dass ich diesen Code will aus den Knoten wählen zu ihrer ID und das ist, was ich es nicht funktionieren lassen konnte und es hat nur eine Option, die undefiniert ist. Ich möchte es mir ein paar andere Optionen wie map1 zeigen, map2 usw., und ich habe die Daten unter:
var thisData = {
\t "nodes" : [{
\t \t \t "id" : "C47676",
\t \t \t "name" : "name1",
\t \t \t "x" : 1209,
\t \t \t "y" : 41
\t \t }, {
\t \t \t "id" : "C58435",
\t \t \t "name" : "name2",
\t \t \t "x" : 483,
\t \t \t "y" : 227
\t \t }, {
.
.
.
}],
\t "links" : [{
\t \t \t "id" : "K14724 ",
\t \t \t "name" : "name3",
\t \t \t "x1" : 983,
\t \t \t "y1" : 461,
\t \t \t "x2" : 983,
\t \t \t "y2" : 524,
\t \t \t "x3" : 985,
\t \t \t "y3" : 524,
\t \t \t "x4" : 985,
\t \t \t "y4" : 461
\t \t }, {
\t \t \t "id" : "K85944 ",
\t \t \t "name" : "name4",
\t \t \t "x1" : 983,
\t \t \t "y1" : 524,
\t \t \t "x2" : 983,
\t \t \t "y2" : 525,
\t \t \t "x3" : 985,
\t \t \t "y3" : 525,
\t \t \t "x4" : 985,
\t \t \t "y4" : 524
\t \t }, {
.
.
.
}]};
Frage ist: Ich brauche Hilfe, die die Knoten entsprechend ihrer ID wählen das funktioniert nicht und ich brauche einige Optionen wie map1, map2 undefined. Gibt es eine Idee, die helfen kann?
es hebt jeden einzelnen Knoten nicht die eine verwandte –
wie kann es ?? ID soll eindeutig sein. Stellen Sie eine Geige auf und zeigen Sie mir schlecht. – thatOneGuy
das ist genau das, was ich nicht bekommen habe, änderte ich auch ID, egal was ich wähle markiert alle Knoten –