Skip to content

Commit e0e985c

Browse files
committed
fix: color indexing
1 parent 52b871b commit e0e985c

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/components/Chart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ function ChartInner<TDatum>({
526526
const base = {
527527
color:
528528
getOptions().defaultColors[
529-
series.index % (getOptions().defaultColors.length - 1)
529+
series.index % getOptions().defaultColors.length
530530
],
531531
}
532532

@@ -544,7 +544,7 @@ function ChartInner<TDatum>({
544544
...series[datum.seriesIndex]?.style,
545545
color:
546546
getOptions().defaultColors[
547-
datum.seriesIndex % (getOptions().defaultColors.length - 1)
547+
datum.seriesIndex % getOptions().defaultColors.length
548548
],
549549
}
550550

src/components/Voronoi.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ function PrimaryVoronoi<TDatum>({
7171

7272
return React.useMemo(() => {
7373
const columns = series[0].datums
74-
.filter(datum => {
74+
.filter((datum, i, all) => {
75+
if (all.findIndex(d => d.primaryValue === datum.primaryValue) !== i) {
76+
return false
77+
}
7578
const primaryValue = datum.primaryValue
7679
return primaryValue !== 'undefined' && primaryValue !== null
7780
})
@@ -203,8 +206,8 @@ function PrimaryVoronoi<TDatum>({
203206
>
204207
{columns.map((column, i) => {
205208
return (
206-
<React.Fragment key={`${column.primaryPx}_${i}`}>
207-
{column.datumBoundaries.map(datumBoundary => {
209+
<g key={`${column.primaryPx}_${i}`}>
210+
{column.datumBoundaries.map((datumBoundary, i) => {
208211
const x1 = !primaryAxis.isVertical
209212
? column.primaryStart
210213
: datumBoundary.secondaryStart
@@ -229,7 +232,7 @@ function PrimaryVoronoi<TDatum>({
229232
return (
230233
<rect
231234
{...{
232-
key: `${column.primaryPx}_${datumBoundary.datum.seriesIndex}`,
235+
key: i,
233236
x,
234237
y,
235238
width,
@@ -248,7 +251,7 @@ function PrimaryVoronoi<TDatum>({
248251
/>
249252
)
250253
})}
251-
</React.Fragment>
254+
</g>
252255
)
253256
})}
254257
</g>

0 commit comments

Comments
 (0)