feat: render highlighted series last

This commit is contained in:
Vyacheslav Matyukhin 2022-05-07 01:56:20 +04:00
parent 7b1ccc2252
commit da66ea05f8
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C

View File

@ -278,13 +278,22 @@ export const HistoryChart: React.FC<Props> = ({ question }) => {
/> />
{[...Array(MAX_LINES).keys()] {[...Array(MAX_LINES).keys()]
.reverse() // affects svg render order, we want to render largest datasets on top of others .reverse() // affects svg render order, we want to render largest datasets on top of others
.filter((i) => i !== highlight)
.map((i) => .map((i) =>
getVictoryGroup({ getVictoryGroup({
data: dataSets[i], data: dataSets[i],
i, i,
highlight: i === highlight, highlight: false,
}) })
)} )}
{highlight === undefined
? null
: // render highlighted series on top of everything else
getVictoryGroup({
data: dataSets[highlight],
i: highlight,
highlight: true,
})}
</VictoryChart> </VictoryChart>
<Legend <Legend
items={dataSetsNames.map((name, i) => ({ name, color: colors[i] }))} items={dataSetsNames.map((name, i) => ({ name, color: colors[i] }))}