如何在D3.js中绘制地图投影上的点,并使用范围滑块过滤数据
How to plot points on a map projection in D3.js and filter the data using range sliders?
以下是我尝试使用的代码的当前状态。http://jaskirat.me/uploads/DataVis/map_projection/这些点被映射到上个月发生的地震。我想要顶部的滑块根据日期范围过滤点。
我该怎么做?以下是创建点的函数。
function createPoints() {
svg.selectAll(".symbol")
.data(centroid.features.sort(function(d) {
return d.properties.mag;
}))
.enter().append("path")
.attr("fill", "rgba(0, 140, 200, 0.5)")
//INTERACTION
.on("mouseover", function(d, i) {
d3.select(this)
.attr("fill", "red");
// Tooltip
var tooltipX = parseFloat(d3.select(this).attr("x")) + 10;
var tooltipY = parseFloat(d3.select(this).attr("y")) + 10;
svg.append("text")
.attr("fill", "rgba(0, 140, 200, 1)")
.attr("x", 100)
.attr("y", height - 200)
.text("PLACE : " + d.properties.place)
.attr("id", "tooltip")
.append("tspan")
.attr("x", 100)
.attr("dy", 20)
.text("LAT : " + d.geometry.coordinates[0])
.append("tspan")
.attr("x", 100)
.attr("dy", 20)
.text("LON : " + d.geometry.coordinates[1]);
})
.on("mouseout", function(d) {
d3.select(this)
.attr("fill", "rgba(0, 140, 200, 0.5)")
d3.select("#tooltip").remove();
})
.attr("d", path.pointRadius(function(d) { // XY Coordinates calculated by .pointRadius
return radius(d.properties.mag);
}));
}
我修改了如下代码
queue()
.defer(d3.json, "world-110m.json")
.defer(d3.json, "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson")
.await(ready);
function ready(error, world, centroid) {
var minVal = 0;
var maxVal = 0;
d3.select('#slider1').call(d3.slider().axis(true).min(0).max(30).step(1).value([5, 10]).on("slide", function(evt, value) {
d3.select('#slider1textmin').text(value[0]);
d3.select('#slider1textmax').text(value[1]);
minVal = value[0];
maxVal = value[1];
refreshPoints();
}));
function refreshPoints() {
svg.selectAll("g.symbol").remove();
console.log("remove");
// createPoints();
}
我需要弄清楚如何在滑块移动时删除点。可能语法不正确。
相关文章:
- JS表单提交"无法使用Chrome数据保护程序加载此页面.尝试重新加载页面.调试信息:POST CISmtuK
- 下载使用POST数据动态生成的文件
- 使用外部数据创建仪表板(谷歌电子表格)-JavaScript
- 在javascript中使用json数据导致问题
- 使用JSON数据检索AJAX外部成功函数
- Angularjs使用父数据的单键多值进行筛选
- 如何在D3.js中绘制地图投影上的点,并使用范围滑块过滤数据
- 如何使用.log数据文件显示EXT-js网格
- 使用json数据更改视频标签中的src属性
- 使用范围滑块和查询
- 使用AngularJs数据绑定的三元运算符显示图像
- 敲除:如何使用可见数据绑定可见来隐藏段落标记
- 如何使用输入数据加载新的extjs图表
- 用Javascript编辑范围数据(时间序列)
- 如何使用代码点火器使用Bootstarp数据表搜索数据嵌套表数据
- 自定义筛选器不'我不使用django数据表视图创建的ajax.data.Json
- 在php中的同一网页上检索所选下拉项的值,并使用其他数据将其发布到其他表单
- 在同一html页面中使用不同数据复制图表/图形
- 我可以使用什么数据结构来存储和检索离散值的范围
- AngularJS使用范围变量解析JSON数据