Inspired by the tutorial at , I am working on a time-based visualization. I am currently using version "d3": "^5.4.0". Here is the code snippet:
d3.json('http://127.0.0.1:5000', function (err, data) {
if (err) throw err;
// Create a month property value based on time
// used to filter against.
data.features = data.features.map(function (d) {
d.properties.month = new Date(d.properties.time).getMonth();
return d;
});
map.addSource('visits', {
'type': 'geojson',
'data': data
});
map.addLayer({
'id': 'visits-circles',
'type': 'circle',
'source': 'visits',
'paint': {
'circle-color': [
'interpolate',
['linear'],
['get', 'name'],
6, '#FCA107',
8, '#7F3121'
],
'circle-opacity': 0.75,
'circle-radius': [
'interpolate',
['linear'],
['get', 'name'],
6, 20,
8, 40
]
}
});
map.addLayer({
'id': 'visits-labels',
'type': 'symbol',
'source': 'visits',
'layout': {
'text-field': ['concat', ['to-string', ['get', 'name']], 'm'],
'text-font': ['Open Sans Bold', 'Arial Unicode MS Bold'],
'text-size': 12
},
'paint': {
'text-color': 'rgba(0,0,0,0.5)'
}
});
// Set filter to first month of the year
// 0 = January
filterBy(0);
document.getElementById('slider').addEventListener('input', function (e) {
var month = parseInt(e.target.value, 10);
filterBy(month);
});
Despite following the same approach with my data URL, I am encountering error messages.
Error TS2559: Type '(err: any, data: any) => void' has no properties in common with type 'RequestInit'. Error TS2339: Property 'value' does not exist on type 'EventTarget'.
Any suggestions on how to resolve this issue?