give timeline constructor a 'methods' arg

This commit is contained in:
Lachlan Kermode
2018-12-04 11:21:31 +00:00
parent b1fd81f772
commit a47fbd95e2
3 changed files with 12 additions and 12 deletions

View File

@@ -44,6 +44,7 @@ class Dashboard extends React.Component {
}
handleSelect(selected) {
console.log(selected)
if (selected) {
let eventsToSelect = selected.map(event => this.getEventById(event.id));
const parser = this.props.ui.tools.parser;

View File

@@ -22,15 +22,18 @@ class Timeline extends React.Component {
selected: this.props.selected,
language: this.props.language,
select: this.props.select,
filter: this.props.filter,
getCategoryColor: this.props.getCategoryColor
}
const ui = {
tools: this.props.tools,
dom: this.props.dom
}
this.timeline = new TimelineLogic(app, ui);
const methods = {
filter: this.props.filter,
getCategoryColor: this.props.getCategoryColor
}
this.timeline = new TimelineLogic(app, ui, methods);
this.timeline.update(domain, app);
this.timeline.render(domain);
}

View File

@@ -10,7 +10,7 @@ import {
import esLocale from '../data/es-MX.json';
import copy from '../data/copy.json';
export default function(app, ui) {
export default function(app, ui, methods) {
d3.timeFormatDefaultLocale(esLocale);
const formatterWithYear = ui.tools.formatterWithYear;
const parser = ui.tools.parser;
@@ -55,10 +55,6 @@ export default function(app, ui) {
let selected = [];
let timerange = app.timerange;
const timeFilter = app.filter;
const getCategoryLabel = app.getCategoryLabel;
const getCategoryColor = app.getCategoryColor;
// Drag behavior
let dragPos0;
let transitionDuration = 500;
@@ -223,7 +219,7 @@ export default function(app, ui) {
})
.on('end', () => {
toggleTransition(true);
timeFilter(scale.x.domain());
methods.filter(scale.x.domain());
});
/*
@@ -285,7 +281,7 @@ export default function(app, ui) {
* @param {object} eventPoint data object
*/
function getEventPointFillColor(eventPoint) {
return getCategoryColor(eventPoint.category);
return methods.getCategoryColor(eventPoint.category);
}
/**
@@ -357,7 +353,7 @@ export default function(app, ui) {
const domainF = d3.timeMinute.offset(newCentralTime, zoom.duration / 2);
scale.x.domain([domain0, domainF]);
timeFilter(scale.x.domain());
methods.filter(scale.x.domain());
}
/**
@@ -380,7 +376,7 @@ export default function(app, ui) {
}
scale.x.domain([domain0, domainF]);
timeFilter(scale.x.domain());
methods.filter(scale.x.domain());
}
function toggleTransition(isTransition) {