mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 13:28:36 +03:00
wip: categories working with timeline
have removed map for the time being, as it was interrupting the timeline render. will return it in next commit
This commit is contained in:
@@ -13,7 +13,7 @@ export default function(newApp, ui, methods) {
|
||||
const domain = {
|
||||
locations: [],
|
||||
narratives: [],
|
||||
categoryGroups: [],
|
||||
categories: [],
|
||||
sites: []
|
||||
}
|
||||
const app = {
|
||||
@@ -23,7 +23,7 @@ export default function(newApp, ui, methods) {
|
||||
}
|
||||
|
||||
const getCategoryGroup = methods.getCategoryGroup;
|
||||
const getCategoryGroupColor = methods.getCategoryGroupColor;
|
||||
const getCategoryColor = methods.getCategoryColor;
|
||||
const select = methods.select;
|
||||
const groupColors = ui.groupColors;
|
||||
const narrativeProps = ui.narratives;
|
||||
@@ -227,27 +227,27 @@ Stop and start the development process in terminal after you have added your tok
|
||||
*/
|
||||
|
||||
function getLocationEventsDistribution(location) {
|
||||
const eventsHere = {};
|
||||
const categoryGroups = domain.categoryGroups;
|
||||
categoryGroups.sort((a, b) => {
|
||||
// const eventsHere = {};
|
||||
const categories = domain.categories;
|
||||
categories.sort((a, b) => {
|
||||
return (+a.slice(-2) > +b.slice(-2));
|
||||
});
|
||||
categoryGroups.forEach(group => {
|
||||
categories.forEach(group => {
|
||||
eventsHere[group] = 0
|
||||
});
|
||||
|
||||
location.events.forEach((event) => {
|
||||
const group = getCategoryGroup(event.category);
|
||||
eventsHere[group] += 1;
|
||||
});
|
||||
// location.events.forEach((event) => {
|
||||
// const group = getCategoryGroup(event.category);
|
||||
// eventsHere[group] += 1;
|
||||
// });
|
||||
|
||||
let i = 0;
|
||||
const events = [];
|
||||
|
||||
while (i < categoryGroups.length) {
|
||||
let eventsCount = eventsHere[categoryGroups[i]];
|
||||
for (let j = i + 1; j < categoryGroups.length; j++) {
|
||||
eventsCount += eventsHere[categoryGroups[j]];
|
||||
while (i < categories.length) {
|
||||
let eventsCount = eventsHere[categories[i]];
|
||||
for (let j = i + 1; j < categories.length; j++) {
|
||||
eventsCount += eventsHere[categories[j]];
|
||||
}
|
||||
events.push(eventsCount);
|
||||
i++;
|
||||
@@ -281,7 +281,8 @@ Stop and start the development process in terminal after you have added your tok
|
||||
select(location.events);
|
||||
});
|
||||
|
||||
const eventsDom = g.selectAll('.location').selectAll('.location-event-marker')
|
||||
const eventsDom = g.selectAll('.location')
|
||||
.selectAll('.location-event-marker')
|
||||
.data((d, i) => getLocationEventsDistribution(domain.locations[i]),
|
||||
(d, i) => 'location-' + i);
|
||||
|
||||
@@ -298,7 +299,7 @@ Stop and start the development process in terminal after you have added your tok
|
||||
eventsDom
|
||||
.enter().append('circle')
|
||||
.attr('class', 'location-event-marker')
|
||||
.style('fill', (d, i) => groupColors[domain.categoryGroups[i]])
|
||||
.style('fill', (d, i) => groupColors[domain.categories[i]])
|
||||
.transition()
|
||||
.duration(500)
|
||||
.attr('r', d => (d) ? Math.sqrt(16 * d) + 3 : 0);
|
||||
@@ -391,7 +392,7 @@ Stop and start the development process in terminal after you have added your tok
|
||||
if (hash(domain) !== hash(newDomain)) {
|
||||
domain.locations = newDomain.locations;
|
||||
domain.narratives = newDomain.narratives;
|
||||
domain.categoryGroups = newDomain.categoryGroups;
|
||||
domain.categories = newDomain.categories;
|
||||
domain.sites = newDomain.sites;
|
||||
renderDomain();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user