mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-11 21:08:36 +03:00
* Fixed bug: when all child filters unselected, turn off parent as well * Refactored placement of onSelectFilter to be in Layout; working logic for updating coloring sets * Linting fixes and removal of console logs * Added separate component for colored markers which clusters and events will use; working calculation of color percentages based off of coloringset * Working colors for clusters; need to implement for individual points as well * Adding two new features to select whether to color by association or by category (can't do both) * Working colors for filter list panel; text and checkbox change according to colorset groupings * Working timeline events with coloring algorithm * Handle select acts different on map when we don't render all points and only filter through clusters; can fix this by not filtering before passing in locations to events in map * Removed extraneous prop * Working point count on hover again; numbers were showing up below the colored markers * Linting fixes and minor refactor of calculateColorPercentage for linting to ass * Comments and more linting fixes * add dev command for windows subsystem for linux * return default styles for category toggles * dynamically filter out timelines * calibrate styling * further calibrations * correct contrast * lint Co-authored-by: efarooqui <efarooqui@pandora.com> Co-authored-by: Lachlan Kermode <lachiekermode@gmail.com>
85 lines
1.9 KiB
JavaScript
85 lines
1.9 KiB
JavaScript
import React from 'react'
|
|
import * as d3 from 'd3'
|
|
|
|
const TEXT_HEIGHT = 15
|
|
|
|
class TimelineAxis extends React.Component {
|
|
constructor () {
|
|
super()
|
|
this.xAxis0Ref = React.createRef()
|
|
this.xAxis1Ref = React.createRef()
|
|
this.state = {
|
|
isInitialized: false
|
|
}
|
|
}
|
|
|
|
componentDidUpdate () {
|
|
let fstFmt, sndFmt
|
|
|
|
// 10yrs
|
|
if (this.props.extent > 5256000) {
|
|
fstFmt = '%Y'
|
|
sndFmt = ''
|
|
// 1yr
|
|
} else if (this.props.extent > 43200) {
|
|
sndFmt = '%d %b'
|
|
fstFmt = ''
|
|
} else {
|
|
sndFmt = '%d %b'
|
|
fstFmt = '%H:%M'
|
|
}
|
|
|
|
let { marginTop, contentHeight } = this.props.dims
|
|
if (this.props.scaleX) {
|
|
this.x0 =
|
|
d3.axisBottom(this.props.scaleX)
|
|
.ticks(10)
|
|
.tickPadding(0)
|
|
.tickSize(contentHeight - TEXT_HEIGHT - marginTop)
|
|
.tickFormat(d3.timeFormat(fstFmt))
|
|
|
|
this.x1 =
|
|
d3.axisBottom(this.props.scaleX)
|
|
.ticks(10)
|
|
.tickPadding(marginTop)
|
|
.tickSize(0)
|
|
.tickFormat(d3.timeFormat(sndFmt))
|
|
|
|
if (!this.state.isInitialized) this.setState({ isInitialized: true })
|
|
}
|
|
|
|
if (this.state.isInitialized) {
|
|
d3.select(this.xAxis0Ref.current)
|
|
.transition()
|
|
.duration(this.props.transitionDuration)
|
|
.call(this.x0)
|
|
|
|
d3.select(this.xAxis1Ref.current)
|
|
.transition()
|
|
.duration(this.props.transitionDuration)
|
|
.call(this.x1)
|
|
}
|
|
}
|
|
|
|
render () {
|
|
return (
|
|
<React.Fragment>
|
|
<g
|
|
ref={this.xAxis0Ref}
|
|
transform={`translate(0, ${this.props.dims.marginTop})`}
|
|
clipPath={`url(#clip)`}
|
|
className={`axis xAxis`}
|
|
/>
|
|
<g
|
|
ref={this.xAxis1Ref}
|
|
transform={`translate(0, ${this.props.dims.marginTop})`}
|
|
clipPath={`url(#clip)`}
|
|
className={`axis xAxis`}
|
|
/>
|
|
</React.Fragment>
|
|
)
|
|
}
|
|
}
|
|
|
|
export default TimelineAxis
|