From 27aec0cc0e696d380981e3adbe0c25dc1ef747af Mon Sep 17 00:00:00 2001 From: cnavarreteliz Date: Thu, 20 Dec 2018 15:57:23 -0300 Subject: [PATCH 1/2] fixes weird legend behavior --- src/Viz.js | 4 ++-- src/_drawLegend.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Viz.js b/src/Viz.js index 97f9f8e..0172d6a 100644 --- a/src/Viz.js +++ b/src/Viz.js @@ -275,7 +275,7 @@ export default class Viz extends BaseClass { .map(g => !d || d.__d3plus__ && !d.data ? undefined : g(d.__d3plus__ ? d.data : d, d.__d3plus__ ? d.i : i)) .filter(g => g !== undefined && g !== null && g.constructor !== Array); - this._drawLabel = (d, i) => { + this._drawLabel = (d, i, legend = false) => { if (!d) return ""; while (d.__d3plus__ && d.data) { d = d.data; @@ -283,7 +283,7 @@ export default class Viz extends BaseClass { } if (this._label) return this._label(d, i); const l = that._ids(d, i).slice(0, this._drawDepth + 1); - return l[l.length - 1]; + return legend ? l[0] : l[l.length - 1]; }; // set the default timeFilter if it has not been specified diff --git a/src/_drawLegend.js b/src/_drawLegend.js index d5b640a..03de28b 100644 --- a/src/_drawLegend.js +++ b/src/_drawLegend.js @@ -7,7 +7,7 @@ import {configPrep, elem, merge} from "d3plus-common"; @private */ export function legendLabel(d, i) { - const l = this._drawLabel(d, i); + const l = this._drawLabel(d, i, true); return l instanceof Array ? l.join(", ") : l; } From 1f845a37ab163a4c9b6d025493b52ce718292a9c Mon Sep 17 00:00:00 2001 From: cnavarreteliz Date: Thu, 3 Jan 2019 11:15:15 -0300 Subject: [PATCH 2/2] fixes weird behavior using depth and custom colors for other levels --- src/Viz.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Viz.js b/src/Viz.js index 0172d6a..8d2d11a 100644 --- a/src/Viz.js +++ b/src/Viz.js @@ -283,7 +283,7 @@ export default class Viz extends BaseClass { } if (this._label) return this._label(d, i); const l = that._ids(d, i).slice(0, this._drawDepth + 1); - return legend ? l[0] : l[l.length - 1]; + return legend ? l[this._depth ? l.length - 1 : 0] : l[l.length - 1]; }; // set the default timeFilter if it has not been specified