Skip to content

Commit

Permalink
Fix colors of visualizations with more than 10 items (#7051)
Browse files Browse the repository at this point in the history
* Fix visualizations colors for more than 10 items
---------

Signed-off-by: Eva Millán <evamillan@bitergia.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Co-authored-by: Anan Zhuang <ananzh@amazon.com>
Co-authored-by: Ashwin P Chandran <ashwinpc@amazon.com>
  • Loading branch information
4 people authored Jun 27, 2024
1 parent 170ac61 commit e6aa9d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7051.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Fix colors of the visualizations with more than 10 items ([#7051](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7051))
6 changes: 4 additions & 2 deletions src/plugins/charts/public/services/colors/mapped_colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ export class MappedColors {
});

// Choose colors from euiPaletteColorBlind and filter out any already assigned to keys
const rotations = Math.ceil(keys.length / 10);
const colorPalette = euiPaletteColorBlind({
rotations: Math.ceil(keys.length / 10),
direction: 'both',
rotations,
direction: rotations === 2 ? 'lighter' : 'both',
order: rotations > 2 ? 'middle-out' : 'append',
})
.filter((color) => !alreadyUsedColors.includes(color.toLowerCase()))
.slice(0, keysToMap.length);
Expand Down

0 comments on commit e6aa9d6

Please sign in to comment.