@aquera/nile-visualization 2.9.16 → 2.9.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/src/internal/types/chart-grid-config.type.d.ts +22 -2
- package/dist/src/nile-chart/nile-chart-config.d.ts +28 -11
- package/dist/src/nile-chart/nile-chart.css.js +5 -2
- package/dist/src/nile-chart/nile-chart.js +35 -0
- package/dist/src/nile-column-drilldown-chart/nile-column-drilldown-chart.d.ts +11 -0
- package/dist/src/nile-column-drilldown-chart/nile-column-drilldown-chart.js +165 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,6 +36,12 @@ To run a local development server that serves the basic demo located in `demo/in
|
|
|
36
36
|
|
|
37
37
|
In this section, you can find the updates for each release of `nile-visualization`. It's a good practice to maintain detailed release notes to help users and developers understand what changes have been made from one version to another and how these changes might affect their projects.
|
|
38
38
|
|
|
39
|
+
#### Version 2.9.18 (June 10, 2026)
|
|
40
|
+
- Nile Chart: Exposed the full `<nile-data-grid>` property surface through `<nile-chart>` — every public grid property is forwarded when using `type: 'grid'`(UIF-1260)
|
|
41
|
+
|
|
42
|
+
#### Version 2.9.17 (June 04, 2026)
|
|
43
|
+
- Nile Chart: Fixed the drilldown navigation issue and added pagination in nile-chart data-grid (UIF-1255)
|
|
44
|
+
|
|
39
45
|
#### Version 2.9.16 (June 03, 2026)
|
|
40
46
|
- Nile Chart: Added Portal Property in Menu. (UIF-1253)
|
|
41
47
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Options } from 'highcharts';
|
|
2
|
-
import type { NileDataGridColumn } from '@aquera/nile-data-grid';
|
|
3
|
-
/** Tabular grid variant of `<nile-chart>`, renders a `<nile-data-grid>`. */
|
|
2
|
+
import type { NileDataGridColumn, ColumnResizeMode, ColumnResizeDirection, ColumnSizingState, ColumnPinningState, VisibilityState, RowSelectionState, ColumnOrderState, PaginationState } from '@aquera/nile-data-grid';
|
|
4
3
|
export interface ChartGridConfigType {
|
|
5
4
|
type: 'grid';
|
|
6
5
|
data: unknown[];
|
|
@@ -8,10 +7,31 @@ export interface ChartGridConfigType {
|
|
|
8
7
|
loading?: boolean;
|
|
9
8
|
striped?: boolean;
|
|
10
9
|
hoverable?: boolean;
|
|
10
|
+
variant?: 'default' | 'sleek' | 'sleek-condensed';
|
|
11
11
|
stickyHeader?: boolean;
|
|
12
|
+
stickyPinnedHeader?: boolean;
|
|
12
13
|
emptyMessage?: string;
|
|
13
14
|
loadingMessage?: string;
|
|
15
|
+
loadingRows?: number;
|
|
14
16
|
noMatchMessage?: string;
|
|
17
|
+
paginationEnabled?: boolean;
|
|
18
|
+
pagination?: PaginationState;
|
|
19
|
+
pageSizeOptions?: number[];
|
|
20
|
+
virtualized?: boolean;
|
|
21
|
+
estimatedRowHeight?: number;
|
|
22
|
+
overscan?: number;
|
|
23
|
+
scrollEndThreshold?: number;
|
|
24
|
+
maxHeight?: string;
|
|
25
|
+
columnResizingEnabled?: boolean;
|
|
26
|
+
columnReorderingEnabled?: boolean;
|
|
27
|
+
rowReorderingEnabled?: boolean;
|
|
28
|
+
columnResizeMode?: ColumnResizeMode;
|
|
29
|
+
columnResizeDirection?: ColumnResizeDirection;
|
|
30
|
+
columnSizing?: ColumnSizingState;
|
|
31
|
+
columnPinning?: ColumnPinningState;
|
|
32
|
+
columnVisibility?: VisibilityState;
|
|
33
|
+
rowSelection?: RowSelectionState;
|
|
34
|
+
columnOrder?: ColumnOrderState;
|
|
15
35
|
height?: string;
|
|
16
36
|
options?: Options;
|
|
17
37
|
}
|
|
@@ -17,7 +17,7 @@ import type { GaugeBand } from '../nile-gauge-chart/nile-gauge-chart.js';
|
|
|
17
17
|
import type { WaterfallDataPoint } from '../nile-waterfall-chart/nile-waterfall-chart.js';
|
|
18
18
|
import type { KpiVariant, KpiValueFormat, KpiNumberSystem, SparklineType, TrendDirection } from '../nile-kpi-chart/nile-kpi-chart.js';
|
|
19
19
|
import type { MapChartDataPoint } from '../nile-map-chart/nile-map-chart.js';
|
|
20
|
-
import type { NileDataGridColumn } from '@aquera/nile-data-grid';
|
|
20
|
+
import type { NileDataGridColumn, ColumnResizeMode, ColumnResizeDirection, ColumnSizingState, ColumnPinningState, VisibilityState, RowSelectionState, ColumnOrderState, PaginationState } from '@aquera/nile-data-grid';
|
|
21
21
|
import type { StackedChartSeriesData } from '../nile-stacked-chart/nile-stacked-chart.js';
|
|
22
22
|
import type { ClusterChartSeriesData } from '../nile-cluster-chart/nile-cluster-chart.js';
|
|
23
23
|
import type { HistogramSamples } from '../nile-histogram-chart/nile-histogram-chart.js';
|
|
@@ -138,14 +138,10 @@ export interface NileChartMenuConfig {
|
|
|
138
138
|
items?: NileChartMenuItem[];
|
|
139
139
|
}
|
|
140
140
|
export interface NileAiConfig {
|
|
141
|
-
/** Show the AI chat icon on the chart. Default: false. */
|
|
142
141
|
enabled?: boolean;
|
|
143
|
-
/** Placeholder text for the chat input. */
|
|
144
142
|
placeholder?: string;
|
|
145
|
-
/** Initial assistant message shown when the chat panel opens. */
|
|
146
143
|
welcomeMessage?: string;
|
|
147
144
|
}
|
|
148
|
-
/** Fields shared by every chart config (card chrome, styling, loading). */
|
|
149
145
|
export interface NileChartConfigBase {
|
|
150
146
|
chartTitle?: string;
|
|
151
147
|
chartSubtitle?: string;
|
|
@@ -155,17 +151,11 @@ export interface NileChartConfigBase {
|
|
|
155
151
|
options?: import('highcharts').Options;
|
|
156
152
|
summary?: string;
|
|
157
153
|
toggleLabel?: string;
|
|
158
|
-
/** Chart types the user can switch to. Shows type-switch UI when set. */
|
|
159
154
|
switchableTypes?: ChartType[];
|
|
160
|
-
/** How to aggregate bar-like data when converting to pie. Default: 'by-category'. */
|
|
161
155
|
switchAggregation?: SwitchAggregation;
|
|
162
|
-
/** AI chat configuration. When ai.enabled is true, shows the allsearch icon. */
|
|
163
156
|
ai?: NileAiConfig;
|
|
164
|
-
/** Controls the built-in actions menu in the chart header. */
|
|
165
157
|
menu?: NileChartMenuConfig;
|
|
166
|
-
/** Custom items appended at the bottom of the chart actions menu. */
|
|
167
158
|
menuItems?: NileChartMenuItem[];
|
|
168
|
-
/** Legend configuration — full Highcharts legend surface. */
|
|
169
159
|
legend?: LegendConfig;
|
|
170
160
|
chartBg?: string;
|
|
171
161
|
chartBorderRadius?: string | number;
|
|
@@ -263,16 +253,43 @@ export interface NileMapChartConfig extends NileChartConfigBase {
|
|
|
263
253
|
seriesType?: 'map' | 'mapline' | 'mappoint' | 'mapbubble' | 'tiledwebmap';
|
|
264
254
|
zoom?: boolean;
|
|
265
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* Tabular grid variant of `<nile-chart>` — renders a `<nile-data-grid>` and
|
|
258
|
+
* exposes its full public property surface.
|
|
259
|
+
*
|
|
260
|
+
* Use `type: 'grid'`.
|
|
261
|
+
*/
|
|
266
262
|
export interface NileGridChartConfig extends NileChartConfigBase {
|
|
267
263
|
type: 'grid';
|
|
268
264
|
data: unknown[];
|
|
269
265
|
columns: NileDataGridColumn[];
|
|
270
266
|
striped?: boolean;
|
|
271
267
|
hoverable?: boolean;
|
|
268
|
+
variant?: 'default' | 'sleek' | 'sleek-condensed';
|
|
272
269
|
stickyHeader?: boolean;
|
|
270
|
+
stickyPinnedHeader?: boolean;
|
|
273
271
|
emptyMessage?: string;
|
|
274
272
|
loadingMessage?: string;
|
|
273
|
+
loadingRows?: number;
|
|
275
274
|
noMatchMessage?: string;
|
|
275
|
+
paginationEnabled?: boolean;
|
|
276
|
+
pagination?: PaginationState;
|
|
277
|
+
pageSizeOptions?: number[];
|
|
278
|
+
virtualized?: boolean;
|
|
279
|
+
estimatedRowHeight?: number;
|
|
280
|
+
overscan?: number;
|
|
281
|
+
scrollEndThreshold?: number;
|
|
282
|
+
maxHeight?: string;
|
|
283
|
+
columnResizingEnabled?: boolean;
|
|
284
|
+
columnReorderingEnabled?: boolean;
|
|
285
|
+
rowReorderingEnabled?: boolean;
|
|
286
|
+
columnResizeMode?: ColumnResizeMode;
|
|
287
|
+
columnResizeDirection?: ColumnResizeDirection;
|
|
288
|
+
columnSizing?: ColumnSizingState;
|
|
289
|
+
columnPinning?: ColumnPinningState;
|
|
290
|
+
columnVisibility?: VisibilityState;
|
|
291
|
+
rowSelection?: RowSelectionState;
|
|
292
|
+
columnOrder?: ColumnOrderState;
|
|
276
293
|
}
|
|
277
294
|
export interface NileTrendlineChartConfig extends NileChartConfigBase {
|
|
278
295
|
type: 'trendline';
|
|
@@ -252,7 +252,7 @@ export const styles = css `
|
|
|
252
252
|
|
|
253
253
|
.nile-chart-card--grid .nile-chart-inner {
|
|
254
254
|
overflow: visible;
|
|
255
|
-
contain:
|
|
255
|
+
contain: content;
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
|
|
@@ -895,7 +895,10 @@ export const styles = css `
|
|
|
895
895
|
flex-direction: column;
|
|
896
896
|
gap: var(--nile-spacing-sm, var(--ng-spacing-sm));
|
|
897
897
|
flex: 1 1 auto;
|
|
898
|
-
|
|
898
|
+
/* Grid cards put their height on <nile-data-grid>, which isn't rendered
|
|
899
|
+
while loading — so without a min-height the skeleton rows collapse to
|
|
900
|
+
nothing. Give it a floor so the head + rows lay out properly. */
|
|
901
|
+
min-height: 240px;
|
|
899
902
|
}
|
|
900
903
|
.nile-chart-skeleton-grid-head,
|
|
901
904
|
.nile-chart-skeleton-grid-row {
|
|
@@ -100,6 +100,15 @@ const CORE_CHART_LABELS = {
|
|
|
100
100
|
kpi: 'KPI',
|
|
101
101
|
grid: 'Grid',
|
|
102
102
|
};
|
|
103
|
+
const DEFAULT_GRID_PAGINATION = { pageIndex: 0, pageSize: 10 };
|
|
104
|
+
const DEFAULT_GRID_PAGE_SIZE_OPTIONS = [5, 10, 20, 50];
|
|
105
|
+
// Stable default references for the grid's controlled-state props, so passing
|
|
106
|
+
// nothing doesn't create a fresh object each render (which would churn the grid).
|
|
107
|
+
const DEFAULT_GRID_COLUMN_SIZING = {};
|
|
108
|
+
const DEFAULT_GRID_COLUMN_PINNING = { left: [], right: [] };
|
|
109
|
+
const DEFAULT_GRID_COLUMN_VISIBILITY = {};
|
|
110
|
+
const DEFAULT_GRID_ROW_SELECTION = {};
|
|
111
|
+
const DEFAULT_GRID_COLUMN_ORDER = [];
|
|
103
112
|
function chartTypeLabel(type) {
|
|
104
113
|
const hit = CORE_CHART_LABELS[type];
|
|
105
114
|
if (hit)
|
|
@@ -1721,6 +1730,11 @@ let NileChart = class NileChart extends NileElement {
|
|
|
1721
1730
|
'--nile-data-grid-border-color:transparent;' +
|
|
1722
1731
|
'--nile-data-grid-shadow:none;' +
|
|
1723
1732
|
(config.height ? `height:${config.height};` : '');
|
|
1733
|
+
// Every public <nile-data-grid> property is forwarded here. Optional
|
|
1734
|
+
// props fall back to the grid's own defaults so an omitted value never
|
|
1735
|
+
// clobbers them. The grid's events (nile-sort-change, nile-pagination-change,
|
|
1736
|
+
// nile-row-selection-change, …) are composed + bubbling, so they cross the
|
|
1737
|
+
// shadow boundary and reach listeners on <nile-chart> without re-emitting.
|
|
1724
1738
|
return html `<nile-data-grid
|
|
1725
1739
|
class="nile-chart-grid"
|
|
1726
1740
|
.data=${config.data}
|
|
@@ -1728,10 +1742,31 @@ let NileChart = class NileChart extends NileElement {
|
|
|
1728
1742
|
.loading=${config.loading ?? false}
|
|
1729
1743
|
.striped=${config.striped ?? false}
|
|
1730
1744
|
.hoverable=${config.hoverable ?? false}
|
|
1745
|
+
.variant=${config.variant ?? 'default'}
|
|
1731
1746
|
.stickyHeader=${config.stickyHeader ?? false}
|
|
1747
|
+
.stickyPinnedHeader=${config.stickyPinnedHeader ?? false}
|
|
1732
1748
|
.emptyMessage=${config.emptyMessage ?? 'No data'}
|
|
1733
1749
|
.loadingMessage=${config.loadingMessage ?? 'Loading…'}
|
|
1750
|
+
.loadingRows=${config.loadingRows ?? 5}
|
|
1734
1751
|
.noMatchMessage=${config.noMatchMessage ?? 'No matching rows'}
|
|
1752
|
+
.paginationEnabled=${config.paginationEnabled ?? false}
|
|
1753
|
+
.pagination=${config.pagination ?? DEFAULT_GRID_PAGINATION}
|
|
1754
|
+
.pageSizeOptions=${config.pageSizeOptions ?? DEFAULT_GRID_PAGE_SIZE_OPTIONS}
|
|
1755
|
+
.virtualized=${config.virtualized ?? false}
|
|
1756
|
+
.estimatedRowHeight=${config.estimatedRowHeight ?? 44}
|
|
1757
|
+
.overscan=${config.overscan ?? 10}
|
|
1758
|
+
.scrollEndThreshold=${config.scrollEndThreshold ?? 200}
|
|
1759
|
+
.maxHeight=${config.maxHeight ?? null}
|
|
1760
|
+
.columnResizingEnabled=${config.columnResizingEnabled ?? false}
|
|
1761
|
+
.columnReorderingEnabled=${config.columnReorderingEnabled ?? false}
|
|
1762
|
+
.rowReorderingEnabled=${config.rowReorderingEnabled ?? false}
|
|
1763
|
+
.columnResizeMode=${config.columnResizeMode ?? 'onChange'}
|
|
1764
|
+
.columnResizeDirection=${config.columnResizeDirection ?? 'ltr'}
|
|
1765
|
+
.columnSizing=${config.columnSizing ?? DEFAULT_GRID_COLUMN_SIZING}
|
|
1766
|
+
.columnPinning=${config.columnPinning ?? DEFAULT_GRID_COLUMN_PINNING}
|
|
1767
|
+
.columnVisibility=${config.columnVisibility ?? DEFAULT_GRID_COLUMN_VISIBILITY}
|
|
1768
|
+
.rowSelection=${config.rowSelection ?? DEFAULT_GRID_ROW_SELECTION}
|
|
1769
|
+
.columnOrder=${config.columnOrder ?? DEFAULT_GRID_COLUMN_ORDER}
|
|
1735
1770
|
style=${gridChrome}
|
|
1736
1771
|
></nile-data-grid>`;
|
|
1737
1772
|
}
|
|
@@ -21,6 +21,13 @@ export declare class NileColumnDrilldownChart extends NileElement {
|
|
|
21
21
|
private _hc;
|
|
22
22
|
private chart;
|
|
23
23
|
private resizeObserver;
|
|
24
|
+
private _bcCollapsed;
|
|
25
|
+
private _bcTooltip;
|
|
26
|
+
private _bcLastText;
|
|
27
|
+
private _bcWidth;
|
|
28
|
+
private _bcPathKey;
|
|
29
|
+
private _bcExpandTimer;
|
|
30
|
+
private _bcMeasuring;
|
|
24
31
|
private chartContainer;
|
|
25
32
|
config: SeparatedChartConfigInputType | null;
|
|
26
33
|
chartTitle: string;
|
|
@@ -53,6 +60,10 @@ export declare class NileColumnDrilldownChart extends NileElement {
|
|
|
53
60
|
protected firstUpdated(): void;
|
|
54
61
|
protected updated(changedProperties: PropertyValues): void;
|
|
55
62
|
private setupResizeObserver;
|
|
63
|
+
private breadcrumbNames;
|
|
64
|
+
private syncBreadcrumbCollapse;
|
|
65
|
+
private ensureBcTooltip;
|
|
66
|
+
private applyBreadcrumbTooltips;
|
|
56
67
|
private buildOptions;
|
|
57
68
|
private initChart;
|
|
58
69
|
private destroyChart;
|
|
@@ -6,12 +6,29 @@ import { applySeparatedChartConfig } from '../internal/separated-chart-config.js
|
|
|
6
6
|
import { getHighcharts } from '../internal/highcharts-provider.js';
|
|
7
7
|
import { deepMerge } from '../internal/utils.js';
|
|
8
8
|
import { styles } from './nile-column-drilldown-chart.css.js';
|
|
9
|
+
import { tooltipCss } from '../nile-chart/nile-chart.css.js';
|
|
10
|
+
let _bcTooltipStylesInjected = false;
|
|
11
|
+
function ensureBcTooltipStyles() {
|
|
12
|
+
if (_bcTooltipStylesInjected || typeof document === 'undefined')
|
|
13
|
+
return;
|
|
14
|
+
const style = document.createElement('style');
|
|
15
|
+
style.dataset['nilechart'] = '';
|
|
16
|
+
style.textContent = tooltipCss;
|
|
17
|
+
document.head.appendChild(style);
|
|
18
|
+
_bcTooltipStylesInjected = true;
|
|
19
|
+
}
|
|
9
20
|
let NileColumnDrilldownChart = class NileColumnDrilldownChart extends NileElement {
|
|
10
21
|
constructor() {
|
|
11
22
|
super(...arguments);
|
|
12
23
|
this._hc = null;
|
|
13
24
|
this.chart = null;
|
|
14
25
|
this.resizeObserver = null;
|
|
26
|
+
this._bcCollapsed = false;
|
|
27
|
+
this._bcTooltip = null;
|
|
28
|
+
this._bcLastText = '';
|
|
29
|
+
this._bcWidth = 0;
|
|
30
|
+
this._bcPathKey = '';
|
|
31
|
+
this._bcMeasuring = false;
|
|
15
32
|
this.config = null;
|
|
16
33
|
this.chartTitle = '';
|
|
17
34
|
this.chartSubtitle = '';
|
|
@@ -73,6 +90,9 @@ let NileColumnDrilldownChart = class NileColumnDrilldownChart extends NileElemen
|
|
|
73
90
|
this.destroyChart();
|
|
74
91
|
this.resizeObserver?.disconnect();
|
|
75
92
|
this.resizeObserver = null;
|
|
93
|
+
this._bcTooltip?.remove();
|
|
94
|
+
this._bcTooltip = null;
|
|
95
|
+
clearTimeout(this._bcExpandTimer);
|
|
76
96
|
}
|
|
77
97
|
firstUpdated() {
|
|
78
98
|
this._syncCssVars();
|
|
@@ -120,6 +140,130 @@ let NileColumnDrilldownChart = class NileColumnDrilldownChart extends NileElemen
|
|
|
120
140
|
this.resizeObserver = new ResizeObserver(() => this.chart?.reflow());
|
|
121
141
|
this.resizeObserver.observe(this.chartContainer);
|
|
122
142
|
}
|
|
143
|
+
breadcrumbNames(chart) {
|
|
144
|
+
const list = chart.breadcrumbs?.list ?? [];
|
|
145
|
+
return list.map(b => b.levelOptions?.name || this.seriesName || 'Series');
|
|
146
|
+
}
|
|
147
|
+
syncBreadcrumbCollapse(chart) {
|
|
148
|
+
const bc = chart.breadcrumbs;
|
|
149
|
+
const list = bc?.list ?? [];
|
|
150
|
+
if (!bc || list.length < 2 || !bc.group)
|
|
151
|
+
return;
|
|
152
|
+
const names = this.breadcrumbNames(chart);
|
|
153
|
+
const fullLast = names[names.length - 1];
|
|
154
|
+
const pathKey = names.join('/');
|
|
155
|
+
const limit = chart.chartWidth - 8;
|
|
156
|
+
let collapsed = this._bcCollapsed;
|
|
157
|
+
let lastText = this._bcLastText || fullLast;
|
|
158
|
+
const widthGrew = chart.chartWidth > this._bcWidth;
|
|
159
|
+
const pathChanged = pathKey !== this._bcPathKey;
|
|
160
|
+
this._bcWidth = chart.chartWidth;
|
|
161
|
+
this._bcPathKey = pathKey;
|
|
162
|
+
if (pathChanged) {
|
|
163
|
+
collapsed = false;
|
|
164
|
+
lastText = fullLast;
|
|
165
|
+
}
|
|
166
|
+
else if (widthGrew) {
|
|
167
|
+
if (collapsed) {
|
|
168
|
+
clearTimeout(this._bcExpandTimer);
|
|
169
|
+
this._bcExpandTimer = setTimeout(() => {
|
|
170
|
+
const liveBc = this.chart === chart ? chart.breadcrumbs : null;
|
|
171
|
+
if (!liveBc || (liveBc.list?.length ?? 0) < 2 || !this._bcCollapsed)
|
|
172
|
+
return;
|
|
173
|
+
const liveNames = this.breadcrumbNames(chart);
|
|
174
|
+
this._bcMeasuring = true;
|
|
175
|
+
this._bcCollapsed = false;
|
|
176
|
+
this._bcLastText = liveNames[liveNames.length - 1];
|
|
177
|
+
liveBc.group?.attr({ opacity: 0 });
|
|
178
|
+
liveBc.update({});
|
|
179
|
+
chart.redraw(false);
|
|
180
|
+
}, 200);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const box = bc.group.getBBox();
|
|
185
|
+
const right = (bc.group.translateX ?? 0) + box.x + box.width;
|
|
186
|
+
const overflow = right - limit;
|
|
187
|
+
if (overflow > 0) {
|
|
188
|
+
if (!collapsed) {
|
|
189
|
+
collapsed = true;
|
|
190
|
+
lastText = fullLast;
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
const levels = Object.keys(bc.elementList ?? {}).map(Number);
|
|
194
|
+
const lastButton = levels.length ? bc.elementList[Math.max(...levels)]?.button : null;
|
|
195
|
+
const buttonWidth = lastButton?.getBBox()?.width ?? 60;
|
|
196
|
+
const avgCharWidth = Math.max(4, buttonWidth / Math.max(1, lastText.length));
|
|
197
|
+
const removeCount = Math.ceil(overflow / avgCharWidth) + 1;
|
|
198
|
+
const base = lastText.endsWith('…') ? lastText.slice(0, -1) : lastText;
|
|
199
|
+
lastText = `${base.slice(0, Math.max(1, base.length - removeCount))}…`;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (collapsed === this._bcCollapsed && lastText === this._bcLastText) {
|
|
204
|
+
if (this._bcMeasuring) {
|
|
205
|
+
this._bcMeasuring = false;
|
|
206
|
+
bc.group.attr({ opacity: 1 });
|
|
207
|
+
}
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
this._bcCollapsed = collapsed;
|
|
211
|
+
this._bcLastText = lastText;
|
|
212
|
+
requestAnimationFrame(() => {
|
|
213
|
+
const liveBc = this.chart === chart ? chart.breadcrumbs : null;
|
|
214
|
+
if (!liveBc)
|
|
215
|
+
return;
|
|
216
|
+
liveBc.update({}); // marks breadcrumbs dirty → re-runs the formatter on redraw
|
|
217
|
+
chart.redraw(false);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
ensureBcTooltip() {
|
|
221
|
+
if (!this._bcTooltip || !this._bcTooltip.isConnected) {
|
|
222
|
+
ensureBcTooltipStyles();
|
|
223
|
+
const tip = document.createElement('div');
|
|
224
|
+
tip.className = 'nile-chart-header-tooltip';
|
|
225
|
+
document.body.appendChild(tip); // on body — never clipped by the chart card
|
|
226
|
+
this._bcTooltip = tip;
|
|
227
|
+
}
|
|
228
|
+
return this._bcTooltip;
|
|
229
|
+
}
|
|
230
|
+
applyBreadcrumbTooltips(chart) {
|
|
231
|
+
const bc = chart.breadcrumbs;
|
|
232
|
+
if (!bc || (bc.list?.length ?? 0) < 2 || !this._bcCollapsed) {
|
|
233
|
+
if (this._bcTooltip)
|
|
234
|
+
this._bcTooltip.style.display = 'none';
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
for (const key of Object.keys(bc.elementList ?? {})) {
|
|
238
|
+
const buttonEl = bc.elementList[key]?.button?.element;
|
|
239
|
+
if (!buttonEl || buttonEl.__nileBcTooltipBound)
|
|
240
|
+
continue;
|
|
241
|
+
buttonEl.__nileBcTooltipBound = true;
|
|
242
|
+
const level = Number(key);
|
|
243
|
+
buttonEl.addEventListener('mouseenter', () => {
|
|
244
|
+
if (!this._bcCollapsed || !this.chart)
|
|
245
|
+
return;
|
|
246
|
+
const list = this.chart.breadcrumbs?.list ?? [];
|
|
247
|
+
const idx = list.findIndex(b => b.level === level);
|
|
248
|
+
if (idx < 0)
|
|
249
|
+
return;
|
|
250
|
+
const name = this.breadcrumbNames(this.chart)[idx];
|
|
251
|
+
const isLast = idx === list.length - 1;
|
|
252
|
+
if (isLast && this._bcLastText === name)
|
|
253
|
+
return;
|
|
254
|
+
const tip = this.ensureBcTooltip();
|
|
255
|
+
const buttonRect = buttonEl.getBoundingClientRect();
|
|
256
|
+
tip.textContent = name;
|
|
257
|
+
tip.style.left = `${buttonRect.left + buttonRect.width / 2}px`;
|
|
258
|
+
tip.style.top = `${buttonRect.top}px`;
|
|
259
|
+
tip.style.display = 'block';
|
|
260
|
+
});
|
|
261
|
+
buttonEl.addEventListener('mouseleave', () => {
|
|
262
|
+
if (this._bcTooltip)
|
|
263
|
+
this._bcTooltip.style.display = 'none';
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
123
267
|
buildOptions() {
|
|
124
268
|
const self = this;
|
|
125
269
|
const drilldown = {
|
|
@@ -129,9 +273,29 @@ let NileColumnDrilldownChart = class NileColumnDrilldownChart extends NileElemen
|
|
|
129
273
|
name: ds.name,
|
|
130
274
|
data: ds.data.map(d => ({ name: d.name, y: d.y })),
|
|
131
275
|
})),
|
|
276
|
+
breadcrumbs: {
|
|
277
|
+
formatter(breadcrumb) {
|
|
278
|
+
const name = breadcrumb?.levelOptions?.name || self.seriesName || 'Series';
|
|
279
|
+
const list = self.chart?.breadcrumbs?.list ?? [];
|
|
280
|
+
const isLast = !list.length || breadcrumb.level === list[list.length - 1].level;
|
|
281
|
+
if (!self._bcCollapsed)
|
|
282
|
+
return name;
|
|
283
|
+
if (!isLast)
|
|
284
|
+
return '..';
|
|
285
|
+
const stored = self._bcLastText;
|
|
286
|
+
return stored && name.startsWith(stored.replace(/…$/, '')) ? stored : name;
|
|
287
|
+
},
|
|
288
|
+
},
|
|
132
289
|
};
|
|
133
290
|
return deepMerge({
|
|
134
|
-
chart: { type: 'column', ...(this.height ? { height: this.height } : {})
|
|
291
|
+
chart: { type: 'column', ...(this.height ? { height: this.height } : {}),
|
|
292
|
+
events: {
|
|
293
|
+
render() {
|
|
294
|
+
self.syncBreadcrumbCollapse(this);
|
|
295
|
+
self.applyBreadcrumbTooltips(this);
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
},
|
|
135
299
|
title: { text: this.chartTitle || undefined },
|
|
136
300
|
subtitle: { text: this.chartSubtitle || undefined },
|
|
137
301
|
xAxis: { type: 'category' },
|