Skip to content

Commit

Permalink
bugfix/viz colors (#981)
Browse files Browse the repository at this point in the history
* you need to put hex numbers in quotes in yaml

* allow for split limits smaller than number of colours
  • Loading branch information
adrianmroz-allegro committed Dec 1, 2022
1 parent fb456f3 commit 86fe572
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
22 changes: 11 additions & 11 deletions docs/configuration-customizations.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ For example, we can override main color and use [Tableu10](https://www.tableau.c
```yaml
customizaiton:
visualizationColors:
main: #829aa3
main: "#829aa3"
series:
- #4e79a7
- #f28e2c
- #e15759
- #76b7b2
- #59a14f
- #edc949
- #af7aa1
- #ff9da7
- #9c755f
- #bab0ab
- "#4e79a7"
- "#f28e2c"
- "#e15759"
- "#76b7b2"
- "#59a14f"
- "#edc949"
- "#af7aa1"
- "#ff9da7"
- "#9c755f"
- "#bab0ab"
```

By default, Turnilo uses 10 different colors for series. But it is possible to define more and Turnilo will adjust necessary split limits.
Expand Down
9 changes: 7 additions & 2 deletions src/common/utils/rules/split-adjustments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ import { thread } from "../functional/functional";

export function adjustColorSplit(split: Split, dimension: Dimension, series: SeriesList, visualizationColors: VisualizationColors): Split {
const colorsCount = visualizationColors.series.length;
const availableLimits = new Set([
// TODO: This magic 5 will disappear in #756
5,
Math.min(split.limit, colorsCount),
colorsCount
]);
return thread(
split,
adjustSort(dimension, series),
// TODO: This magic 5 will disappear in #756
adjustFiniteLimit([5, colorsCount], colorsCount)
adjustFiniteLimit([...availableLimits], colorsCount)
);
}

Expand Down

0 comments on commit 86fe572

Please sign in to comment.