From e0e985cb8ac4c284dc369ed903ac4d065271e8c5 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sun, 25 Jul 2021 10:01:22 -0700 Subject: [PATCH] fix: color indexing --- src/components/Chart.tsx | 4 ++-- src/components/Voronoi.tsx | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/Chart.tsx b/src/components/Chart.tsx index c53f2ba2..98342312 100644 --- a/src/components/Chart.tsx +++ b/src/components/Chart.tsx @@ -526,7 +526,7 @@ function ChartInner({ const base = { color: getOptions().defaultColors[ - series.index % (getOptions().defaultColors.length - 1) + series.index % getOptions().defaultColors.length ], } @@ -544,7 +544,7 @@ function ChartInner({ ...series[datum.seriesIndex]?.style, color: getOptions().defaultColors[ - datum.seriesIndex % (getOptions().defaultColors.length - 1) + datum.seriesIndex % getOptions().defaultColors.length ], } diff --git a/src/components/Voronoi.tsx b/src/components/Voronoi.tsx index 0747bf61..d5357044 100644 --- a/src/components/Voronoi.tsx +++ b/src/components/Voronoi.tsx @@ -71,7 +71,10 @@ function PrimaryVoronoi({ return React.useMemo(() => { const columns = series[0].datums - .filter(datum => { + .filter((datum, i, all) => { + if (all.findIndex(d => d.primaryValue === datum.primaryValue) !== i) { + return false + } const primaryValue = datum.primaryValue return primaryValue !== 'undefined' && primaryValue !== null }) @@ -203,8 +206,8 @@ function PrimaryVoronoi({ > {columns.map((column, i) => { return ( - - {column.datumBoundaries.map(datumBoundary => { + + {column.datumBoundaries.map((datumBoundary, i) => { const x1 = !primaryAxis.isVertical ? column.primaryStart : datumBoundary.secondaryStart @@ -229,7 +232,7 @@ function PrimaryVoronoi({ return ( ({ /> ) })} - + ) })}