Skip to content

Commit

Permalink
Also report level to ColorProvider function
Browse files Browse the repository at this point in the history
  • Loading branch information
pverscha committed Jan 9, 2024
1 parent 807a02c commit 1b53fdf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/visualizations/treeview/Treeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default class Treeview {
this.root.data.setSelected(true);

const updateColor = (d: HPN<TreeviewNode>, level: number) => {
d.data.setColor(this.settings.colorProvider(d.data));
d.data.setColor(this.settings.colorProvider(d.data, level));
if (level < this.settings.colorProviderLevels && d.children) {
for (const child of d.children) {
updateColor(child, level + 1);
Expand Down
3 changes: 2 additions & 1 deletion src/visualizations/treeview/TreeviewSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@ export default class TreeviewSettings extends Settings {
* nodes up until the level in the tree specified by the parameter "colorProviderLevels".
*
* @param d A TreeviewNode for which the corresponding color should be computed.
* @param level The depth in the tree at which this node is situated.
* @return The color associated with the given node.
*/
colorProvider: (d: TreeviewNode) => string = (d: TreeviewNode) => defaultColorScale(d.name);
colorProvider: (d: TreeviewNode, level?: number) => string = (d: TreeviewNode) => defaultColorScale(d.name);

/**
* Returns the label that should be displayed for a specific node (the label corresponds to the text shown in the
Expand Down

0 comments on commit 1b53fdf

Please sign in to comment.