From 1b53fdfdba4fb765937cc61fe94681821b172aa7 Mon Sep 17 00:00:00 2001 From: Pieter Verschaffelt Date: Tue, 9 Jan 2024 14:54:22 +0100 Subject: [PATCH] Also report level to ColorProvider function --- src/visualizations/treeview/Treeview.ts | 2 +- src/visualizations/treeview/TreeviewSettings.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/visualizations/treeview/Treeview.ts b/src/visualizations/treeview/Treeview.ts index b8b811a..f39f9af 100644 --- a/src/visualizations/treeview/Treeview.ts +++ b/src/visualizations/treeview/Treeview.ts @@ -111,7 +111,7 @@ export default class Treeview { this.root.data.setSelected(true); const updateColor = (d: HPN, 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); diff --git a/src/visualizations/treeview/TreeviewSettings.ts b/src/visualizations/treeview/TreeviewSettings.ts index 0b0977b..7bdde1c 100644 --- a/src/visualizations/treeview/TreeviewSettings.ts +++ b/src/visualizations/treeview/TreeviewSettings.ts @@ -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