Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
VladLasitsa committed Jan 21, 2022
1 parent daa5aaa commit 67194be
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/plugins/charts/public/services/palettes/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ function findColorSegment(

// what about values in range
const index = colors.findIndex((c, i) => comparison(value, rangeMin + (1 + i) * step) <= 0);
return colors[index] || colors[colors.length - 1];
return (
colors[index] ||
(value > rangeMin + colors.length * step ? colors[colors.length - 1] : colors[0])
);
}

function findColorsByStops(
Expand All @@ -31,7 +34,7 @@ function findColorsByStops(
stops: number[]
) {
const index = stops.findIndex((s) => comparison(value, s) < 0);
return colors[index] || colors[colors.length - 1];
return colors[index] || value > stops[stops.length - 1] ? colors[colors.length - 1] : colors[0];
}

function getNormalizedValueByRange(
Expand Down

0 comments on commit 67194be

Please sign in to comment.