From 5b83a82c35353417084ec1ef95c72e27e2d9a24b Mon Sep 17 00:00:00 2001 From: Lachie Kermode Date: Fri, 30 Nov 2018 18:46:17 +0000 Subject: [PATCH] wip: categoryGroups -> categories --- src/components/Dashboard.jsx | 36 +++++++++++++++--------------------- src/components/Timeline.jsx | 16 ++++++---------- src/js/map/map.js | 2 +- src/js/timeline/timeline.js | 11 ++++++----- src/selectors/index.js | 2 +- src/store/initial.js | 12 ++++-------- 6 files changed, 33 insertions(+), 46 deletions(-) diff --git a/src/components/Dashboard.jsx b/src/components/Dashboard.jsx index cb617a3..0318648 100644 --- a/src/components/Dashboard.jsx +++ b/src/components/Dashboard.jsx @@ -92,21 +92,20 @@ class Dashboard extends React.Component { } } - getCategoryGroup(category) { - const cat = this.props.domain.categories.find(t => t.category === category) - if (cat) return cat.group; - return 'other'; + // getCategoryGroup(category) { + // const cat = this.props.domain.categories.find(t => t.category === category) + // if (cat) return cat.group; + // return 'other'; + // } + + getCategoryColor(category) { + return this.props.ui.style.categories[category]; } - getCategoryGroupColor(category) { - const group = this.getCategoryGroup(category); - return this.props.ui.style.groupColors[group]; - } - - getCategoryLabel(category) { - const categories = this.props.domain.categories; - return categories.find(t => t.category === category).category_label; - } + // getCategoryLabel(category) { + // const categories = this.props.domain.categories; + // return categories.find(t => t.category === category).category_label; + // } getNarrativeLinks(event) { const narrative = this.props.domain.narratives.find(nv => nv.key === event.narrative); @@ -169,14 +168,12 @@ class Dashboard extends React.Component { highlight={this.handleHighlight} toggle={this.handleToggle} getNarrativeLinks={event => this.getNarrativeLinks(event)} - getCategoryGroup={category => this.getCategoryGroup(category)} - getCategoryGroupColor={category => this.getCategoryGroupColor(category)} - getCategoryLabel={category => this.getCategoryLabel(category)} + getCategoryColor={category => this.getCategoryColor(category)} /> item)} narratives={this.props.domain.narratives} - categoryGroups={this.props.domain.categoryGroups} + categories={this.props.domain.categories} timerange={this.props.app.filters.timerange} selected={this.props.app.selected} @@ -189,9 +186,7 @@ class Dashboard extends React.Component { filter={this.handleTimeFilter} highlight={this.handleHighlight} toggle={() => this.handleToggle('TOGGLE_CARDSTACK')} - getCategoryGroup={category => this.getCategoryGroup(category)} - getCategoryGroupColor={category => this.getCategoryGroupColor(category)} - getCategoryLabel={category => this.getCategoryLabel(category)} + getCategoryColor={category => this.getCategoryColor(category)} /> { - const groupLen = this.props.categoryGroups.length + return this.props.categories.map((label) => { + const groupLen = this.props.categories.length return (
{label}
); }); } diff --git a/src/js/map/map.js b/src/js/map/map.js index d940169..1d42691 100644 --- a/src/js/map/map.js +++ b/src/js/map/map.js @@ -195,7 +195,7 @@ Stop and start the development process in terminal after you have added your tok unmarkPoint(); app.selected.forEach(eventPoint => { if (isNotNullNorUndefined(eventPoint) && isNotNullNorUndefined(eventPoint.location)) { - if (eventPoint.latitude && eventPoint.longitude) { + if (eventPoint.latitude && eventPoint.latitude !== "" && eventPoint.longitude && eventPoint.longitude !== "") { const location = new L.LatLng(eventPoint.latitude, eventPoint.longitude); eventCircleMarkers[eventPoint.id] = L.circleMarker(location, { radius: 32, diff --git a/src/js/timeline/timeline.js b/src/js/timeline/timeline.js index f29b20d..774e483 100644 --- a/src/js/timeline/timeline.js +++ b/src/js/timeline/timeline.js @@ -597,20 +597,21 @@ export default function(app, ui) { * @param {Object} app: Redux state app subtree */ function updateAxis(domain) { - categoryGroups = domain.categoryGroups - const groupStep = (106 - 30) / categoryGroups.length; - let groupYs = Array.apply(null, Array(categoryGroups.length)); + console.log(domain) + const categories = domain.categories + const groupStep = (106 - 30) / categories.length; + let groupYs = Array.apply(null, Array(categories.length)); groupYs = groupYs.map((g, i) => { return 30 + i * groupStep; }); scale.y = d3.scaleOrdinal() - .domain(categoryGroups) + .domain(categories) .range(groupYs); axis.y = d3.axisLeft(scale.y) - .tickValues(categoryGroups); + .tickValues(categories); } function update(domain, app) { diff --git a/src/selectors/index.js b/src/selectors/index.js index 329ff3e..bd1315f 100644 --- a/src/selectors/index.js +++ b/src/selectors/index.js @@ -151,7 +151,7 @@ export const selectLocations = createSelector( export const selectCategories = createSelector( [getCategories], (categories) => { - return Object.values(categories); + return categories.map(v => v.category); } ); diff --git a/src/store/initial.js b/src/store/initial.js index a1d5103..78ac9fb 100644 --- a/src/store/initial.js +++ b/src/store/initial.js @@ -72,17 +72,13 @@ const initial = { GREEN: "#4FF2F2",//"rgb(0, 158, 86)", }, - groupColors: { - category_group00: "#FF0000", - category_group01: "#226b22", - category_group02: "#671f6f", - category_group03: "#0000bf", - category_group04: "#d3ce2a", + palette: d3.schemeCategory10, + + categories: { + default: 'red', other: "#FF0000" }, - palette: d3.schemeCategory10, - narratives: { default: { style: 'dotted', // ['dotted', 'solid']