Thursday, February 28, 2019

javascript - Assign default text to select menu d3

I have a select menu that updates a graph .on('change') using d3.



I am trying to get the select menu to have a default text value 'Select from me'.




But when the .on('change') is triggered I don't want this value to update the graph. The way I have it now when you choose to select the default text 'Select from me' it tries to update the graph based on this value.



So is there a way to disable this from acting as an option?



D3 CODE



var select = d3.select('#select').append('select');

select.append('option').text('Select from me');


select.attr( 'id', 'select-menu' )
.on( 'change', updateGraph )
.selectAll( 'option' )
.data( dataNest )
.enter().append( 'option' )
.attr( 'value', function (d) {return d.key; } )
.text( function (d) { return d.key; } );

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...