fix lint errors

This commit is contained in:
Franc Camps-Febrer
2019-02-01 12:23:11 -05:00
parent 6906adc258
commit 4af0c9c2ef
8 changed files with 67 additions and 62 deletions

View File

@@ -2,15 +2,13 @@ import React from 'react'
import { Portal } from 'react-portal'
function MapEvents ({ getCategoryColor, categories, projectPoint, styleLocation, narrative, onSelect, svg, locations }) {
function getCoordinatesForPercent(radius, percent) {
const x = radius * Math.cos(2 * Math.PI * percent);
const y = radius * Math.sin(2 * Math.PI * percent);
return [x, y];
function getCoordinatesForPercent (radius, percent) {
const x = radius * Math.cos(2 * Math.PI * percent)
const y = radius * Math.sin(2 * Math.PI * percent)
return [x, y]
}
function renderLocationSlicesByCategory(location) {
function renderLocationSlicesByCategory (location) {
const locCategory = location.events.length > 0 ? location.events[0].category : 'default'
const customStyles = styleLocation ? styleLocation(location) : null
const extraStyles = customStyles[0]
@@ -25,7 +23,7 @@ function MapEvents ({ getCategoryColor, categories, projectPoint, styleLocation,
const colorSlices = location.events.map(e => getCategoryColor(e.category))
let cumulativeAngleSweep = 0;
let cumulativeAngleSweep = 0
return (
<React.Fragment>
@@ -34,22 +32,22 @@ function MapEvents ({ getCategoryColor, categories, projectPoint, styleLocation,
// Based on the number of events in each location,
// create a slice per event filled with its category color
const [startX, startY] = getCoordinatesForPercent(r, cumulativeAngleSweep);
cumulativeAngleSweep = (idx + 1) / colorSlices.length;
const [endX, endY] = getCoordinatesForPercent(r, cumulativeAngleSweep);
const [startX, startY] = getCoordinatesForPercent(r, cumulativeAngleSweep)
cumulativeAngleSweep = (idx + 1) / colorSlices.length
const [endX, endY] = getCoordinatesForPercent(r, cumulativeAngleSweep)
// if the slices are less than 2, take the long arc
const largeArcFlag = (colorSlices.length === 1) ? 1 : 0;
const largeArcFlag = (colorSlices.length === 1) ? 1 : 0
// create an array and join it just for code readability
const arc = [
`M ${startX} ${startY}`, // Move
`M ${startX} ${startY}`, // Move
`A ${r} ${r} 0 ${largeArcFlag} 1 ${endX} ${endY}`, // Arc
`L 0 0 `, // Line
`L ${startX} ${startY} Z`, // Line
].join(' ');
`L 0 0 `, // Line
`L ${startX} ${startY} Z` // Line
].join(' ')
const extraStyles = ({
...styles,
@@ -65,9 +63,9 @@ function MapEvents ({ getCategoryColor, categories, projectPoint, styleLocation,
/>
)
})}
</React.Fragment>
)
)
}
function renderLocation (location) {
@@ -79,8 +77,7 @@ function MapEvents ({ getCategoryColor, categories, projectPoint, styleLocation,
longitude: '32.2'
}
*/
const { x, y } = projectPoint([location.latitude, location.longitude])
const { x, y } = projectPoint([location.latitude, location.longitude])
// in narrative mode, only render events in narrative
if (narrative) {
@@ -100,7 +97,7 @@ function MapEvents ({ getCategoryColor, categories, projectPoint, styleLocation,
<g
className='location'
transform={`translate(${x}, ${y})`}
onClick={() => onSelect(location.events)}
onClick={() => onSelect(location.events)}
>
{renderLocationSlicesByCategory(location)}
{extraRender ? extraRender() : null}

View File

@@ -1,7 +1,7 @@
import React from 'react'
import { Portal } from 'react-portal'
import { concatStatic } from 'rxjs/operator/concat';
import { single } from 'rxjs/operator/single';
// import { concatStatic } from 'rxjs/operator/concat'
// import { single } from 'rxjs/operator/single'
function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives, projectPoint }) {
function getNarrativeStyle (narrativeId) {
@@ -66,22 +66,22 @@ function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives,
const theta = Math.atan2(p2.y - p1.y, p2.x - p1.x) // Angle of narrative step line
const alpha = Math.atan2(1, 2) // Angle of arrow overture
const edge = 10 // Arrow edge length
const offset = (distance < 24) ? distance / 2 : 24;
const offset = (distance < 24) ? distance / 2 : 24
// Arrow corners
const coord0 = {
x: p2.x - offset * Math.cos(theta),
y: p2.y - offset * Math.sin(theta)
}
}
const coord1 = {
x: coord0.x - edge * Math.cos(-theta - alpha),
y: coord0.y + edge * Math.sin(-theta - alpha)
}
}
const coord2 = {
x: coord0.x - edge * Math.cos(-theta + alpha),
y: coord0.y + edge * Math.sin(-theta + alpha)
}
}
return (<path
className='narrative-step-arrow'
d={`
@@ -92,9 +92,9 @@ function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives,
style={{
...styles,
fillOpacity: styles.strokeOpacity,
fill: styles.stroke,
fill: styles.stroke
}}
></path>)
/>)
}
function _renderNarrativeStep (p1, p2, styles) {
@@ -102,25 +102,25 @@ function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives,
return (
<g>
<line
className='narrative-step'
x1={p1.x}
x2={p2.x}
y1={p1.y}
y2={p2.y}
markerStart='none'
onClick={n => onSelectNarrative(n)}
style={{
strokeWidth,
strokeDasharray,
strokeOpacity,
stroke
}}
/>
{(stroke !== 'none')
? _renderNarrativeStepArrow(p1, p2, styles)
: ''
}
<line
className='narrative-step'
x1={p1.x}
x2={p2.x}
y1={p1.y}
y2={p2.y}
markerStart='none'
onClick={n => onSelectNarrative(n)}
style={{
strokeWidth,
strokeDasharray,
strokeOpacity,
stroke
}}
/>
{(stroke !== 'none')
? _renderNarrativeStepArrow(p1, p2, styles)
: ''
}
</g>
)
}

View File

@@ -20,7 +20,7 @@ class MapSelectedEvents extends React.Component {
stroke-linejoin='round'
stroke-dasharray={styles ? styles['stroke-dasharray'] : '2,2'}
fill='none'
d={`M0,0a${r},${r} 0 1,0 ${r*2},0 a${r},${r} 0 1,0 -${r*2},0 `}
d={`M0,0a${r},${r} 0 1,0 ${r * 2},0 a${r},${r} 0 1,0 -${r * 2},0 `}
/>
</g>
)