我正在做一个信息可视化项目,目前正在尝试向滑块添加值。然而,到目前为止它还没有发挥作用。滑块本身工作正常,但网页中的滑块下方似乎没有任何价值。我想在滑块下有诸如 2021-12-15 之类的日期,如何使它工作?这是我到目前为止工作的代码,在此先感谢!
<div class="slidecontainer">
<input type="range" min="1" max="12" value="12" class="slider" id="mySlider">
</div>
<script>
var slider = document.getElementById("mySlider");
var output = document.getElementById("demo");
output.innerHTML = slider.value; // Display the default slider value
// Update the current slider value (each time you drag the slider handle)
slider.oninput = function() {
output.innerHTML = this.value;
}
</script>
function slider_Update(binNumber) {
new_date = formatTime(new Date("2008-"+binNumber+"-01"));
let checked_group = ".";
let count = 1;
// For each checkbox:
d3.selectAll(".checkbox").each(function(d){
const cb = d3.select(this);
const grp = cb.property("value");
//console.log(cb.property("checked")+" "+cb.property("value"));
// If the box is check, add to checked_group, else hide
if(cb.property("checked")){
if(count===1){
checked_group += grp;
count++;
//console.log(checked_group+" count: "+count);
}else{
checked_group += ",."+grp;
//count++;
//console.log(checked_group+" count: "+count);
}
}
})
//change opacity for created group
update_Worldmap(checked_group);
update_BarPlot();
}
//Slider source
//https://www.d3-graph-gallery.com/graph/density_slider.html
// Listen to the slider
d3.select("#mySlider").on("change", function(d){
selectedValue = this.value
slider_Update(selectedValue)
//console.log("from mySldier select: "+selectedValue)
})