Skip to content

Commit

Permalink
fix: color indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed Jul 25, 2021
1 parent 52b871b commit e0e985c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/Chart.tsx
Expand Up @@ -526,7 +526,7 @@ function ChartInner<TDatum>({
const base = {
color:
getOptions().defaultColors[
series.index % (getOptions().defaultColors.length - 1)
series.index % getOptions().defaultColors.length
],
}

Expand All @@ -544,7 +544,7 @@ function ChartInner<TDatum>({
...series[datum.seriesIndex]?.style,
color:
getOptions().defaultColors[
datum.seriesIndex % (getOptions().defaultColors.length - 1)
datum.seriesIndex % getOptions().defaultColors.length
],
}

Expand Down
13 changes: 8 additions & 5 deletions src/components/Voronoi.tsx
Expand Up @@ -71,7 +71,10 @@ function PrimaryVoronoi<TDatum>({

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
})
Expand Down Expand Up @@ -203,8 +206,8 @@ function PrimaryVoronoi<TDatum>({
>
{columns.map((column, i) => {
return (
<React.Fragment key={`${column.primaryPx}_${i}`}>
{column.datumBoundaries.map(datumBoundary => {
<g key={`${column.primaryPx}_${i}`}>
{column.datumBoundaries.map((datumBoundary, i) => {
const x1 = !primaryAxis.isVertical
? column.primaryStart
: datumBoundary.secondaryStart
Expand All @@ -229,7 +232,7 @@ function PrimaryVoronoi<TDatum>({
return (
<rect
{...{
key: `${column.primaryPx}_${datumBoundary.datum.seriesIndex}`,
key: i,
x,
y,
width,
Expand All @@ -248,7 +251,7 @@ function PrimaryVoronoi<TDatum>({
/>
)
})}
</React.Fragment>
</g>
)
})}
</g>
Expand Down

1 comment on commit e0e985c

@vercel
Copy link

@vercel vercel bot commented on e0e985c Jul 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.