reactive_pokemon_hp = {
num_types_selected;
var width = 400,
height = 250;
var pokemon = d3.csvParse(`name,type,hp,attack,defense
Pikachu,Electric,35,55,40
Squirtle,Water,44,48,65
Weedle,Bug,40,35,30
Spearow,Normal,40,60,30
Sandshrew,Ground,50,75,85
Vulpix,Fire,38,41,40
Jigglypuff,Normal,115,45,20
Venomoth,Bug,70,65,60
Meowth,Normal,40,45,35
Poliwag,Water,40,50,40
Psyduck,Water,50,52,48
Golem,Rock,80,120,130
Charmander,Fire,39,52,43
Krabby,Water,30,105,90
Bulbasaur,Grass,45,49,49`);
var xScale = d3.scaleBand()
.domain(d3.range(pokemon.length))
.rangeRound([0, width])
.padding(0.05);
var yScale = d3.scaleLinear()
.domain([0, d3.max((pokemon.map(d => d.hp)).map(function(d) { return +d; }))])
.range([0, height]);
const svg = d3.select(DOM.svg(width, height));
//if the element selected, e.g. water is in the column, color that much of the column in a different color
svg.selectAll("rect")
.data(pokemon)
.enter().append("rect")
.attr("x", (d, i) => xScale(i))
.attr("y", d => height - yScale(d.hp))
.attr("width", xScale.bandwidth())
.attr("height", d => yScale(d.hp))
if (num_types_selected==1){
svg.selectAll("rect").filter(function(d){return (types_entries[types_entries][0] == d.type);})
.attr("fill", "red")
}
else if(num_types_selected==2){
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[0]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[1]][0] == d.type);})
.attr("fill", "red")
}
else if(num_types_selected==3){
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[0]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[1]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[2]][0] == d.type);})
.attr("fill", "red")
}
else if(num_types_selected==4){
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[0]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[1]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[2]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[3]][0] == d.type);})
.attr("fill", "red")
}
else if(num_types_selected==5){
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[0]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[1]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[2]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[3]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[4]][0] == d.type);})
.attr("fill", "red")
}
else if(num_types_selected==6){
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[0]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[1]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[2]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[3]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[4]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[5]][0] == d.type);})
.attr("fill", "red")
}
else if(num_types_selected==7){
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[0]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[1]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[2]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[3]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[4]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[5]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[6]][0] == d.type);})
.attr("fill", "red")
}
else if(num_types_selected==8){
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[0]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[1]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[2]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[3]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[4]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[5]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[6]][0] == d.type);})
.attr("fill", "red")
svg.selectAll("rect").filter(function(d){return (types_entries[types_selection[7]][0] == d.type);})
.attr("fill", "red")
}
console.log(types_entries, types_entries)
// .attr("fill", "red")
console.log(types_selection, types_entries)
return svg.node();
}