Skip to content

Commit

Permalink
fix(line): change points ordering on stacked lines (#1060)
Browse files Browse the repository at this point in the history
  • Loading branch information
phacks committed Jul 31, 2020
1 parent fb4aef0 commit c10edbf
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 79 deletions.
22 changes: 12 additions & 10 deletions packages/line/src/Lines.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ import PropTypes from 'prop-types'
import LinesItem from './LinesItem'

const Lines = ({ lines, lineGenerator, lineWidth }) => {
return lines.map(({ id, data, color }) => (
<LinesItem
key={id}
id={id}
points={data.map(d => d.position)}
lineGenerator={lineGenerator}
color={color}
thickness={lineWidth}
/>
))
return lines
.reverse()
.map(({ id, data, color }) => (
<LinesItem
key={id}
id={id}
points={data.map(d => d.position)}
lineGenerator={lineGenerator}
color={color}
thickness={lineWidth}
/>
))
}

Lines.propTypes = {
Expand Down
6 changes: 5 additions & 1 deletion packages/line/src/Points.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ const Points = ({ points, symbol, size, borderWidth, enableLabel, label, labelYO
const theme = useTheme()
const getLabel = getLabelGenerator(label)

const mappedPoints = points.map(point => {
/**
* We reverse the `points` array so that points from the lower lines in stacked lines
* graph are drawn on top. See https://github.com/plouc/nivo/issues/1051.
*/
const mappedPoints = points.reverse().map(point => {
const mappedPoint = {
id: point.id,
x: point.x,
Expand Down
Loading

0 comments on commit c10edbf

Please sign in to comment.