@aquera/nile-visualization 2.9.44 → 2.9.45

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 CHANGED
@@ -36,6 +36,9 @@ 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.45 (November 19, 2026)
40
+ - Nile Chart: `type: 'grid'` charts take a `columnChooser` option (`true`, or `{ title, tooltip, icon, showCount, showReset, resetLabel, indicator, placement }`). It adds a column-settings icon to the chart header, after any `header-actions` content and before the built-in icons, that opens a `nile-floating-panel` of column checkboxes with a visible/total count and a Reset action; a dot on the icon shows while columns are hidden. Toggles fire the grid's `nile-column-visibility-change`, and a new `config.columnVisibility` re-seeds the panel. Needs `nile-floating-panel`, `nile-checkbox` and `nile-glyph` loaded on the page; column locks need `@aquera/nile-data-grid` 0.9.7. New CSS parts `column-chooser-trigger`, `column-chooser-glyph`, `column-chooser-indicator`. `ChartGridConfigType` and `NileChartColumnChooserConfig` are exported. Off unless set (UIF-1428)
41
+
39
42
  #### Version 2.9.44 (November 18, 2026)
40
43
  - Nile Charts: Long x-axis labels no longer rotate and shrink the plot. `xAxisLabelMode` (`truncate` by default, or `wrap`), `xAxisLabelMaxWidth` (default 80) and `xAxisLabelRotation` control how they fit, and a clipped label shows its full name in a tooltip (UIF-1426)
41
44
  - Nile Charts: Lite tooltips in the charts are capped at `--ng-width-64` (256px) wide and 250px tall and scroll beyond that; the chart header title and subtitle tooltips now use `nile-lite-tooltip`, so they need `@aquera/nile-elements` loaded on the page (UIF-1426)
@@ -6,7 +6,7 @@ export { NileBarChart } from './nile-bar-chart/index.js';
6
6
  export type { BarChartSeriesData } from './nile-bar-chart/index.js';
7
7
  export { NilePieChart } from './nile-pie-chart/index.js';
8
8
  export type { PieChartSeriesData } from './nile-pie-chart/index.js';
9
- export type { LegendConfig, LegendNavigationConfig, LegendTitleConfig, LegendAccessibilityConfig, ChartSpacingConfig, CSSObject, } from './internal/types/index.js';
9
+ export type { LegendConfig, LegendNavigationConfig, LegendTitleConfig, LegendAccessibilityConfig, ChartSpacingConfig, CSSObject, ChartGridConfigType, NileChartColumnChooserConfig, } from './internal/types/index.js';
10
10
  export { NileTrendlineChart } from './nile-trendline-chart/index.js';
11
11
  export type { TrendlineSeriesData, ForecastConfig } from './nile-trendline-chart/index.js';
12
12
  export { NileAnomalyChart } from './nile-anomaly-chart/index.js';
@@ -36,6 +36,28 @@ export interface ChartGridConfigType {
36
36
  columnVisibility?: VisibilityState;
37
37
  rowSelection?: RowSelectionState;
38
38
  columnOrder?: ColumnOrderState;
39
+ /** Adds a column-settings icon to the chart header that opens a show/hide panel for the columns. */
40
+ columnChooser?: boolean | NileChartColumnChooserConfig;
39
41
  height?: string;
40
42
  options?: Options;
41
43
  }
44
+ export interface NileChartColumnChooserConfig {
45
+ /** Defaults to true when the object is given. */
46
+ enabled?: boolean;
47
+ /** Panel heading. Defaults to 'Show columns'. */
48
+ title?: string;
49
+ /** Trigger tooltip and base of its aria-label. Defaults to 'Choose columns'. */
50
+ tooltip?: string;
51
+ /** nile-glyph name for the trigger. Defaults to 'ng-columns-3-cog'. */
52
+ icon?: string;
53
+ /** Shows "visible/total" next to the heading. Defaults to true. */
54
+ showCount?: boolean;
55
+ /** Shows the action that makes every column visible. Defaults to true. */
56
+ showReset?: boolean;
57
+ /** Defaults to 'Reset'. */
58
+ resetLabel?: string;
59
+ /** Shows a dot on the trigger while any column is hidden. Defaults to true. */
60
+ indicator?: boolean;
61
+ /** Defaults to 'bottom-end'. */
62
+ placement?: 'bottom-end' | 'bottom-start' | 'bottom';
63
+ }
@@ -18,6 +18,7 @@ export type { ChartGaugeConfigType } from './chart-gauge-config.type.js';
18
18
  export type { ChartWaterfallConfigType } from './chart-waterfall-config.type.js';
19
19
  export type { ChartClusterConfigType } from './chart-cluster-config.type.js';
20
20
  export type { ChartStackedConfigType } from './chart-stacked-config.type.js';
21
+ export type { ChartGridConfigType, NileChartColumnChooserConfig, } from './chart-grid-config.type.js';
21
22
  export type { ChartHistogramConfigType } from './chart-histogram-config.type.js';
22
23
  export type { ChartBellcurveConfigType } from './chart-bellcurve-config.type.js';
23
24
  export type { ChartBoxplotConfigType } from './chart-boxplot-config.type.js';
@@ -0,0 +1,33 @@
1
+ import type { TemplateResult } from 'lit';
2
+ import type { NileChartColumnChooserConfig } from '../internal/types/chart-grid-config.type.js';
3
+ export type ColumnVisibility = Record<string, boolean>;
4
+ export interface ResolvedColumnChooser {
5
+ title: string;
6
+ tooltip: string;
7
+ icon: string;
8
+ showCount: boolean;
9
+ showReset: boolean;
10
+ resetLabel: string;
11
+ indicator: boolean;
12
+ placement: 'bottom-end' | 'bottom-start' | 'bottom';
13
+ }
14
+ export interface ChooserEntry {
15
+ id: string;
16
+ label: string;
17
+ locked: boolean;
18
+ group: string | null;
19
+ }
20
+ export declare const COLUMN_CHOOSER_PANEL_CLASS = "nile-chart-column-chooser";
21
+ export declare function resolveColumnChooser(option: boolean | NileChartColumnChooserConfig | undefined | null): ResolvedColumnChooser | null;
22
+ export declare function chooserEntries(columns: unknown[], columnOrder?: string[]): ChooserEntry[];
23
+ export declare function isColumnVisible(entry: ChooserEntry, visibility: ColumnVisibility): boolean;
24
+ export interface ColumnChooserRenderOptions {
25
+ chooser: ResolvedColumnChooser;
26
+ entries: ChooserEntry[];
27
+ visibility: ColumnVisibility;
28
+ onToggle: (id: string, visible: boolean) => void;
29
+ onReset: () => void;
30
+ onShow: (e: Event) => void;
31
+ onHide: (e: Event) => void;
32
+ }
33
+ export declare function renderColumnChooser(opts: ColumnChooserRenderOptions): TemplateResult;
@@ -0,0 +1,133 @@
1
+ import { html, nothing } from 'lit';
2
+ export const COLUMN_CHOOSER_PANEL_CLASS = 'nile-chart-column-chooser';
3
+ export function resolveColumnChooser(option) {
4
+ if (!option)
5
+ return null;
6
+ const o = option === true ? {} : option;
7
+ if (o.enabled === false)
8
+ return null;
9
+ return {
10
+ title: o.title ?? 'Show columns',
11
+ tooltip: o.tooltip ?? 'Choose columns',
12
+ icon: o.icon ?? 'ng-columns-3-cog',
13
+ showCount: o.showCount !== false,
14
+ showReset: o.showReset !== false,
15
+ resetLabel: o.resetLabel ?? 'Reset',
16
+ indicator: o.indicator !== false,
17
+ placement: o.placement ?? 'bottom-end',
18
+ };
19
+ }
20
+ function labelOf(col) {
21
+ if (typeof col.header === 'string' && col.header.trim())
22
+ return col.header;
23
+ if (col.chooserLabel)
24
+ return col.chooserLabel;
25
+ return col.id;
26
+ }
27
+ export function chooserEntries(columns, columnOrder = []) {
28
+ const entries = [];
29
+ const walk = (cols, group) => {
30
+ for (const col of cols) {
31
+ if (col.columns?.length) {
32
+ walk(col.columns, labelOf(col));
33
+ }
34
+ else if (col.type !== 'checkbox') {
35
+ entries.push({
36
+ id: col.id,
37
+ label: labelOf(col),
38
+ locked: col.enableHiding === false,
39
+ group,
40
+ });
41
+ }
42
+ }
43
+ };
44
+ walk((columns ?? []), null);
45
+ if (columnOrder.length === 0)
46
+ return entries;
47
+ const rank = new Map(columnOrder.map((id, i) => [id, i]));
48
+ return entries
49
+ .map((e, i) => ({ e, i }))
50
+ .sort((a, b) => (rank.get(a.e.id) ?? columnOrder.length + a.i) -
51
+ (rank.get(b.e.id) ?? columnOrder.length + b.i))
52
+ .map((x) => x.e);
53
+ }
54
+ export function isColumnVisible(entry, visibility) {
55
+ return entry.locked || visibility[entry.id] !== false;
56
+ }
57
+ export function renderColumnChooser(opts) {
58
+ const { chooser, entries, visibility } = opts;
59
+ const shown = entries.filter((e) => isColumnVisible(e, visibility)).length;
60
+ const total = entries.length;
61
+ const label = `${chooser.tooltip} (${shown} of ${total} shown)`;
62
+ const filtered = shown < total;
63
+ let lastGroup = null;
64
+ const rows = entries.map((entry) => {
65
+ const visible = isColumnVisible(entry, visibility);
66
+ const heading = entry.group && entry.group !== lastGroup
67
+ ? html `<div class="nile-chart-column-chooser-group" role="presentation">
68
+ ${entry.group}
69
+ </div>`
70
+ : nothing;
71
+ lastGroup = entry.group;
72
+ const disabled = entry.locked || (visible && shown <= 1);
73
+ return html `${heading}<nile-checkbox
74
+ class="nile-chart-column-chooser-option"
75
+ data-column-id=${entry.id}
76
+ .checked=${visible}
77
+ .disabled=${disabled}
78
+ @nile-change=${(e) => opts.onToggle(entry.id, e.detail.checked)}
79
+ >${entry.label}</nile-checkbox
80
+ >`;
81
+ });
82
+ // nile-floating-panel re-parents its children, so each direct child must be a static element.
83
+ return html `<nile-floating-panel
84
+ class="nile-chart-column-chooser-anchor"
85
+ placement=${chooser.placement}
86
+ arrow="none"
87
+ .distance=${6}
88
+ .panelClass=${COLUMN_CHOOSER_PANEL_CLASS}
89
+ @nile-after-show=${opts.onShow}
90
+ @nile-hide=${opts.onHide}
91
+ >
92
+ <button
93
+ type="button"
94
+ class="nile-chart-menu-trigger nile-chart-column-chooser-trigger"
95
+ part="column-chooser-trigger"
96
+ aria-label=${label}
97
+ title=${label}
98
+ >
99
+ <nile-glyph
100
+ name=${chooser.icon}
101
+ method="stroke"
102
+ size="16"
103
+ color="currentColor"
104
+ part="column-chooser-glyph"
105
+ ></nile-glyph>
106
+ ${chooser.indicator && filtered
107
+ ? html `<span
108
+ class="nile-chart-column-chooser-indicator"
109
+ part="column-chooser-indicator"
110
+ aria-hidden="true"
111
+ ></span>`
112
+ : nothing}
113
+ </button>
114
+ <span slot="title" class="nile-chart-column-chooser-title"
115
+ >${chooser.title}${chooser.showCount
116
+ ? html `<span class="nile-chart-column-chooser-count">${shown}/${total}</span>`
117
+ : nothing}</span
118
+ >
119
+ <button
120
+ type="button"
121
+ slot="action"
122
+ class="nile-chart-column-chooser-reset"
123
+ ?hidden=${!chooser.showReset}
124
+ @click=${opts.onReset}
125
+ >
126
+ ${chooser.resetLabel}
127
+ </button>
128
+ <div class="nile-chart-column-chooser-list" role="group" aria-label=${chooser.title}>
129
+ ${rows}
130
+ </div>
131
+ </nile-floating-panel>`;
132
+ }
133
+ //# sourceMappingURL=nile-chart-column-chooser.js.map
@@ -0,0 +1,2 @@
1
+ import './nile-chart';
2
+ import '@aquera/nile-data-grid';
@@ -0,0 +1,244 @@
1
+ var _a;
2
+ import { expect, fixture, aTimeout, html } from '@open-wc/testing';
3
+ import './nile-chart';
4
+ import '@aquera/nile-data-grid';
5
+ // TanStack Table reads process.env when it builds a table; the test browser has no process.
6
+ (_a = window).process ?? (_a.process = { env: { NODE_ENV: 'production' } });
7
+ const settle = async (el) => {
8
+ await el.updateComplete;
9
+ await el.updateComplete;
10
+ await new Promise(requestAnimationFrame);
11
+ };
12
+ const COLUMNS = [
13
+ { id: 'select', header: '', accessorKey: 'select', type: 'checkbox' },
14
+ { id: 'id', header: 'ID', accessorKey: 'id', enableHiding: false },
15
+ { id: 'name', header: 'Name', accessorKey: 'name', enableHiding: false },
16
+ { id: 'role', header: 'Role', accessorKey: 'role' },
17
+ { id: 'dept', header: 'Dept', accessorKey: 'dept' },
18
+ { id: 'email', header: 'Email', accessorKey: 'email' },
19
+ { id: 'phone', header: 'Phone', accessorKey: 'phone' },
20
+ { id: 'city', header: 'City', accessorKey: 'city' },
21
+ { id: 'status', header: 'Status', accessorKey: 'status' },
22
+ ];
23
+ const DATA = [
24
+ {
25
+ id: 1,
26
+ name: 'Ada',
27
+ role: 'Eng',
28
+ dept: 'R&D',
29
+ email: 'a@x.co',
30
+ phone: '1',
31
+ city: 'NY',
32
+ status: 'on',
33
+ },
34
+ {
35
+ id: 2,
36
+ name: 'Grace',
37
+ role: 'Adm',
38
+ dept: 'Navy',
39
+ email: 'g@x.co',
40
+ phone: '2',
41
+ city: 'DC',
42
+ status: 'off',
43
+ },
44
+ ];
45
+ const gridConfig = (extra = {}) => ({
46
+ type: 'grid',
47
+ data: DATA,
48
+ columns: COLUMNS,
49
+ columnChooser: true,
50
+ ...extra,
51
+ });
52
+ const make = async (config) => {
53
+ const el = await fixture(html `<nile-chart></nile-chart>`);
54
+ if (config)
55
+ el.config = config;
56
+ await settle(el);
57
+ return el;
58
+ };
59
+ const root = (el) => el.shadowRoot;
60
+ const trigger = (el) => root(el).querySelector('button[part~="column-chooser-trigger"]');
61
+ const innerGrid = (el) => root(el).querySelector('nile-data-grid');
62
+ const openPanel = async (el) => {
63
+ trigger(el).click();
64
+ await settle(el);
65
+ await aTimeout(50);
66
+ };
67
+ // nile-floating-panel re-parents its content to document.body on open; in the
68
+ // headless runner it may stay in the chart's shadow root — look in both.
69
+ const panelQueryAll = (el, sel) => {
70
+ const inBody = Array.from(document.querySelectorAll(sel));
71
+ return inBody.length ? inBody : Array.from(root(el).querySelectorAll(sel));
72
+ };
73
+ const panelQuery = (el, sel) => document.querySelector(sel) ?? root(el).querySelector(sel);
74
+ const listedCheckboxes = (el) => panelQueryAll(el, '.nile-chart-column-chooser-list nile-checkbox');
75
+ const checkboxFor = (el, id) => panelQuery(el, `.nile-chart-column-chooser-list nile-checkbox[data-column-id="${id}"]`);
76
+ describe('NileChart column chooser', () => {
77
+ describe('trigger presence', () => {
78
+ it('1. no trigger when columnChooser is absent', async () => {
79
+ const el = await make(gridConfig({ columnChooser: undefined }));
80
+ expect(trigger(el)).to.be.null;
81
+ });
82
+ it('2. no trigger when columnChooser is false', async () => {
83
+ const el = await make(gridConfig({ columnChooser: false }));
84
+ expect(trigger(el)).to.be.null;
85
+ });
86
+ it('3. renders a trigger with glyph when columnChooser is true', async () => {
87
+ const el = await make(gridConfig());
88
+ const btn = trigger(el);
89
+ expect(btn).to.exist;
90
+ expect(btn.querySelector('nile-glyph[part~="column-chooser-glyph"]')).to.exist;
91
+ });
92
+ it('4. ignored for non-grid types', async () => {
93
+ const el = await make({
94
+ type: 'line',
95
+ data: [{ name: 'A', data: [1, 2, 3] }],
96
+ categories: ['x', 'y', 'z'],
97
+ columnChooser: true,
98
+ });
99
+ expect(trigger(el)).to.be.null;
100
+ });
101
+ it('5. trigger lives in the header actions group', async () => {
102
+ const el = await make(gridConfig());
103
+ const actions = root(el).querySelector('.nile-chart-header-actions');
104
+ expect(actions).to.exist;
105
+ expect(actions.contains(trigger(el))).to.be.true;
106
+ });
107
+ it('6. trigger is positioned after the header-actions slot', async () => {
108
+ const el = await make(gridConfig());
109
+ const actions = root(el).querySelector('.nile-chart-header-actions');
110
+ const slot = actions.querySelector('slot[name="header-actions"]');
111
+ const btn = trigger(el);
112
+ expect(slot.compareDocumentPosition(btn) & Node.DOCUMENT_POSITION_FOLLOWING).to.be.greaterThan(0);
113
+ });
114
+ it('7. header renders for the chooser even with no title', async () => {
115
+ const el = await make(gridConfig());
116
+ expect(root(el).querySelector('.nile-chart-header')).to.exist;
117
+ });
118
+ it('8. slotting header-actions content keeps the trigger', async () => {
119
+ const el = await fixture(html `<nile-chart><button slot="header-actions">Export</button></nile-chart>`);
120
+ el.config = gridConfig();
121
+ await settle(el);
122
+ expect(trigger(el)).to.exist;
123
+ });
124
+ });
125
+ describe('floating panel', () => {
126
+ it('9. trigger is wrapped by a floating panel with the chooser panel-class', async () => {
127
+ const el = await make(gridConfig());
128
+ const panels = Array.from(root(el).querySelectorAll('nile-floating-panel'));
129
+ const panel = panels.find((p) => p.contains(trigger(el)));
130
+ expect(panel, 'floating panel wrapping the trigger').to.exist;
131
+ const panelClass = panel.panelClass ?? panel.getAttribute('panel-class');
132
+ expect(panelClass).to.equal('nile-chart-column-chooser');
133
+ });
134
+ it('10. opening lists one checkbox per hideable column', async () => {
135
+ const el = await make(gridConfig());
136
+ await openPanel(el);
137
+ const boxes = listedCheckboxes(el);
138
+ expect(boxes.length).to.equal(8);
139
+ });
140
+ it('11. row-selection (checkbox) columns are not listed', async () => {
141
+ const el = await make(gridConfig());
142
+ await openPanel(el);
143
+ expect(checkboxFor(el, 'select')).to.be.null;
144
+ });
145
+ });
146
+ describe('labels and locked state', () => {
147
+ it('12. function header falls back to chooserLabel', async () => {
148
+ const el = await make(gridConfig({
149
+ columns: [
150
+ { id: 'id', header: 'ID', accessorKey: 'id' },
151
+ { id: 'r', header: () => 'x', accessorKey: 'r', chooserLabel: 'Custom' },
152
+ ],
153
+ }));
154
+ await openPanel(el);
155
+ expect(checkboxFor(el, 'r').textContent).to.contain('Custom');
156
+ });
157
+ it('13. enableHiding:false columns are checked and disabled', async () => {
158
+ const el = await make(gridConfig());
159
+ await openPanel(el);
160
+ const idBox = checkboxFor(el, 'id');
161
+ expect(idBox.checked).to.be.true;
162
+ expect(idBox.disabled).to.be.true;
163
+ });
164
+ it('14. last visible column checkbox is disabled', async () => {
165
+ const el = await make(gridConfig({
166
+ columns: [
167
+ { id: 'only', header: 'Only', accessorKey: 'only' },
168
+ { id: 'b', header: 'B', accessorKey: 'b' },
169
+ ],
170
+ columnVisibility: { b: false },
171
+ }));
172
+ await openPanel(el);
173
+ expect(checkboxFor(el, 'only').disabled).to.be.true;
174
+ });
175
+ });
176
+ describe('count and indicator', () => {
177
+ it('15. count reflects visible / total', async () => {
178
+ const el = await make(gridConfig({ columnVisibility: { role: false, dept: false } }));
179
+ await openPanel(el);
180
+ const count = panelQuery(el, '.nile-chart-column-chooser-count');
181
+ expect(count.textContent.replace(/\s/g, '')).to.equal('6/8');
182
+ });
183
+ it('16. no indicator when nothing is hidden', async () => {
184
+ const el = await make(gridConfig());
185
+ expect(root(el).querySelector('[part~="column-chooser-indicator"]')).to.be.null;
186
+ });
187
+ it('17. indicator shown when a column is hidden', async () => {
188
+ const el = await make(gridConfig({ columnVisibility: { role: false } }));
189
+ expect(root(el).querySelector('[part~="column-chooser-indicator"]')).to.exist;
190
+ });
191
+ it('18. aria-label reports shown / total', async () => {
192
+ const el = await make(gridConfig({ columnVisibility: { role: false, dept: false } }));
193
+ expect(trigger(el).getAttribute('aria-label')).to.equal('Choose columns (6 of 8 shown)');
194
+ });
195
+ });
196
+ describe('toggling', () => {
197
+ it('19. unchecking hides exactly that column and fires one event', async () => {
198
+ const el = await make(gridConfig());
199
+ await openPanel(el);
200
+ let events = 0;
201
+ el.addEventListener('nile-column-visibility-change', () => (events += 1));
202
+ const box = checkboxFor(el, 'role');
203
+ box.checked = false;
204
+ box.dispatchEvent(new CustomEvent('nile-change', {
205
+ detail: { checked: false },
206
+ bubbles: true,
207
+ composed: true,
208
+ }));
209
+ await settle(el);
210
+ expect(innerGrid(el).columnVisibility.role).to.equal(false);
211
+ expect(events).to.equal(1);
212
+ });
213
+ it('20. reset shows all columns and fires one event', async () => {
214
+ const el = await make(gridConfig({ columnVisibility: { role: false, dept: false } }));
215
+ await openPanel(el);
216
+ let events = 0;
217
+ el.addEventListener('nile-column-visibility-change', () => (events += 1));
218
+ const reset = panelQuery(el, 'button.nile-chart-column-chooser-reset');
219
+ reset.click();
220
+ await settle(el);
221
+ const vis = innerGrid(el).columnVisibility;
222
+ expect(Object.values(vis).some((v) => v === false)).to.be.false;
223
+ expect(events).to.equal(1);
224
+ });
225
+ it('21. locked column cannot be hidden from the grid', async () => {
226
+ const el = await make(gridConfig({ columnVisibility: { id: false } }));
227
+ await settle(el);
228
+ expect(innerGrid(el).columnVisibility.id).to.not.equal(undefined);
229
+ await openPanel(el);
230
+ expect(checkboxFor(el, 'id').checked).to.be.true;
231
+ });
232
+ });
233
+ describe('re-seeding', () => {
234
+ it('22. replacing config columnVisibility re-seeds grid and checkboxes', async () => {
235
+ const el = await make(gridConfig());
236
+ el.config = gridConfig({ columnVisibility: { role: false } });
237
+ await settle(el);
238
+ expect(innerGrid(el).columnVisibility.role).to.equal(false);
239
+ await openPanel(el);
240
+ expect(checkboxFor(el, 'role').checked).to.be.false;
241
+ });
242
+ });
243
+ });
244
+ //# sourceMappingURL=nile-chart-column-chooser.test.js.map
@@ -80,17 +80,77 @@ const MENU_OVERRIDE_CSS = `
80
80
  user-select: none;
81
81
  }
82
82
  `;
83
- export function injectGlobalChartMenuOverrides() {
84
- if (typeof document === 'undefined')
85
- return;
86
- const STYLE_ID = 'nile-chart-actions-menu-overrides';
87
- if (document.getElementById(STYLE_ID))
83
+ const COLUMN_CHOOSER_CSS = `
84
+ .nile-chart-column-chooser .nile-chart-column-chooser-title {
85
+ display: inline-flex;
86
+ align-items: baseline;
87
+ gap: var(--nile-spacing-xs, var(--ng-spacing-xs, 4px));
88
+ }
89
+
90
+ .nile-chart-column-chooser .nile-chart-column-chooser-count {
91
+ font-weight: var(--nile-font-weight-regular, var(--ng-font-weight-regular));
92
+ color: var(--nile-colors-neutral-500, var(--ng-colors-text-quaternary-500));
93
+ }
94
+
95
+ .nile-chart-column-chooser .nile-chart-column-chooser-list {
96
+ display: flex;
97
+ flex-direction: column;
98
+ gap: var(--nile-spacing-10px, var(--ng-spacing-2-5, 10px));
99
+ width: var(--nile-width-200px, var(--ng-height-200px));
100
+ max-height: 60vh;
101
+ overflow-y: auto;
102
+ /* inset so the checkbox focus ring isn't clipped by the scroll container */
103
+ padding: var(--nile-spacing-xs, var(--ng-spacing-xs, 4px));
104
+ margin: 0 calc(-1 * var(--nile-spacing-xs, var(--ng-spacing-xs, 4px)));
105
+ }
106
+
107
+ .nile-chart-column-chooser .nile-chart-column-chooser-option {
108
+ align-self: flex-start;
109
+ }
110
+
111
+ .nile-chart-column-chooser .nile-chart-column-chooser-group {
112
+ font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
113
+ font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));
114
+ font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));
115
+ color: var(--nile-colors-neutral-500, var(--ng-colors-text-tertiary-600));
116
+ padding-top: var(--nile-spacing-xs, var(--ng-spacing-xs, 4px));
117
+ user-select: none;
118
+ }
119
+
120
+ .nile-chart-column-chooser .nile-chart-column-chooser-reset {
121
+ padding: 0;
122
+ border: none;
123
+ background: none;
124
+ cursor: pointer;
125
+ font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
126
+ font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
127
+ font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-semibold));
128
+ color: var(--nile-colors-primary-600, var(--ng-colors-text-brand-tertiary-600));
129
+ }
130
+
131
+ .nile-chart-column-chooser .nile-chart-column-chooser-reset:focus-visible {
132
+ outline: var(--nile-border-width-2, var(--ng-stroke-width-2)) solid var(--nile-colors-primary-600, var(--ng-colors-fg-brand-primary-600));
133
+ outline-offset: var(--nile-spacing-1px, var(--ng-outline-offset-1));
134
+ }
135
+
136
+ .nile-chart-column-chooser .nile-chart-column-chooser-reset[hidden] {
137
+ display: none;
138
+ }
139
+ `;
140
+ function injectGlobalStyle(id, cssText) {
141
+ if (document.getElementById(id))
88
142
  return;
89
143
  const style = document.createElement('style');
90
- style.id = STYLE_ID;
91
- style.textContent = MENU_OVERRIDE_CSS;
144
+ style.id = id;
145
+ style.textContent = cssText;
92
146
  document.head?.appendChild(style);
93
147
  }
148
+ export function injectGlobalChartMenuOverrides() {
149
+ if (typeof document === 'undefined')
150
+ return;
151
+ injectGlobalStyle('nile-chart-actions-menu-overrides', MENU_OVERRIDE_CSS);
152
+ injectGlobalStyle('nile-chart-column-chooser-styles', COLUMN_CHOOSER_CSS);
153
+ }
94
154
  injectGlobalChartMenuOverrides();
95
155
  export const styles = css `
96
156
  :host {
@@ -495,6 +555,24 @@ export const styles = css `
495
555
  transition: background var(--nile-transition-duration-short, var(--ng-transition-duration-fast)) ease, color var(--nile-transition-duration-short, var(--ng-transition-duration-fast)) ease;
496
556
  }
497
557
 
558
+ .nile-chart-column-chooser-anchor {
559
+ display: inline-flex;
560
+ }
561
+
562
+ .nile-chart-column-chooser-trigger {
563
+ position: relative;
564
+ }
565
+
566
+ .nile-chart-column-chooser-indicator {
567
+ position: absolute;
568
+ top: var(--nile-spacing-2px, var(--ng-spacing-xxs, 2px));
569
+ right: var(--nile-spacing-2px, var(--ng-spacing-xxs, 2px));
570
+ width: var(--nile-width-6px, var(--ng-height-6px));
571
+ height: var(--nile-height-6px, var(--ng-height-6px));
572
+ border-radius: var(--nile-radius-full, var(--ng-radius-full));
573
+ background: var(--nile-colors-primary-600, var(--ng-colors-fg-brand-primary-600));
574
+ }
575
+
498
576
  .nile-chart-menu-trigger:hover {
499
577
  background: transparent;
500
578
  color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));
@@ -73,6 +73,9 @@ import '../nile-ai-panel/index.js';
73
73
  * @csspart ai-trigger-glyph - Glyph inside the "Ask AI" button.
74
74
  * @csspart ai-panel - The AI chat panel overlay.
75
75
  * @csspart ai-panel-content - The nile-ai-panel element inside the overlay.
76
+ * @csspart column-chooser-trigger - The column-chooser button (grid charts with `columnChooser`).
77
+ * @csspart column-chooser-glyph - Glyph inside the column-chooser button.
78
+ * @csspart column-chooser-indicator - Dot on the column-chooser button while any column is hidden.
76
79
  * @csspart menu-anchor - The actions-menu dropdown anchor.
77
80
  * @csspart menu-trigger - The actions-menu trigger button.
78
81
  * @csspart menu-trigger-glyph - Glyph inside the actions-menu trigger.
@@ -157,6 +160,8 @@ export declare class NileChart extends NileElement {
157
160
  private hasHeaderSlotContent;
158
161
  /** True when elements are projected into `header-actions` (used to show the header row). */
159
162
  private hasHeaderActionsSlot;
163
+ private gridColumnVisibility;
164
+ private gridColumnVisibilitySeed;
160
165
  private aiPanel;
161
166
  private masterDetailChart;
162
167
  /** True while the inner master-detail chart is zoomed — drives the header
@@ -250,6 +255,14 @@ export declare class NileChart extends NileElement {
250
255
  /** Direct children with `slot=` — header row renders on first paint before slot assignment runs. */
251
256
  private lightDomHasSlot;
252
257
  private shouldShowHeader;
258
+ private get gridConfig();
259
+ private get columnChooser();
260
+ private get gridElement();
261
+ /** Seeds from `config.columnVisibility` whenever the app passes a new object; user toggles live here in between. */
262
+ private resolveGridColumnVisibility;
263
+ private onGridColumnVisibilityChange;
264
+ private onGridColumnOrderChange;
265
+ private renderColumnChooserTrigger;
253
266
  private buildExportingOptions;
254
267
  /** Ensures exporting modules are loaded and the chart's exporting/fullscreen instances exist. */
255
268
  private ensureExporting;
@@ -8,6 +8,7 @@ import { styles, injectGlobalChartMenuOverrides } from './nile-chart.css.js';
8
8
  import { HIGHCHARTS_PASSTHROUGH_KEYS } from '../internal/types/index.js';
9
9
  import { nileChartConfig } from './nile-chart-config-builder.js';
10
10
  import { renderChartSkeleton } from './nile-chart-skeleton.js';
11
+ import { COLUMN_CHOOSER_PANEL_CLASS, chooserEntries, renderColumnChooser, resolveColumnChooser, } from './nile-chart-column-chooser.js';
11
12
  import { isChartEmpty, renderChartEmptyState, syncChartEmptyTruncation } from './nile-chart-empty.js';
12
13
  import { convertConfig } from '../internal/utils/chart-adapters.js';
13
14
  import { deepMerge } from '../internal/utils/deep-merge.js';
@@ -144,6 +145,9 @@ function chartTypeLabel(type) {
144
145
  * @csspart ai-trigger-glyph - Glyph inside the "Ask AI" button.
145
146
  * @csspart ai-panel - The AI chat panel overlay.
146
147
  * @csspart ai-panel-content - The nile-ai-panel element inside the overlay.
148
+ * @csspart column-chooser-trigger - The column-chooser button (grid charts with `columnChooser`).
149
+ * @csspart column-chooser-glyph - Glyph inside the column-chooser button.
150
+ * @csspart column-chooser-indicator - Dot on the column-chooser button while any column is hidden.
147
151
  * @csspart menu-anchor - The actions-menu dropdown anchor.
148
152
  * @csspart menu-trigger - The actions-menu trigger button.
149
153
  * @csspart menu-trigger-glyph - Glyph inside the actions-menu trigger.
@@ -229,6 +233,8 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
229
233
  this.hasHeaderSlotContent = false;
230
234
  /** True when elements are projected into `header-actions` (used to show the header row). */
231
235
  this.hasHeaderActionsSlot = false;
236
+ this.gridColumnVisibility = DEFAULT_GRID_COLUMN_VISIBILITY;
237
+ this.gridColumnVisibilitySeed = undefined;
232
238
  /** True while the inner master-detail chart is zoomed — drives the header
233
239
  * "Reset zoom" button. Reflected from the chart's `nile-master-detail-zoom`. */
234
240
  this.masterZoomed = false;
@@ -286,6 +292,13 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
286
292
  this.gridLineStrengthFromConfig = false;
287
293
  this._emptyEl = null;
288
294
  this._emptyObs = null;
295
+ this.onGridColumnVisibilityChange = (e) => {
296
+ this.gridColumnVisibility = e.detail.columnVisibility;
297
+ this.requestUpdate();
298
+ };
299
+ this.onGridColumnOrderChange = () => {
300
+ this.requestUpdate();
301
+ };
289
302
  /** The x-axis label the tooltip belongs to. */
290
303
  this._axisLabelActive = null;
291
304
  /** Shows the full name for a clipped label; uses mousemove because some browsers never fire mouseover here. */
@@ -692,7 +705,57 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
692
705
  this.lightDomHasSlot('header') ||
693
706
  this.lightDomHasSlot('header-actions') ||
694
707
  hasBuiltinActions ||
695
- this.showResetZoom);
708
+ this.showResetZoom ||
709
+ !!this.columnChooser);
710
+ }
711
+ get gridConfig() {
712
+ return this.activeConfig?.type === 'grid'
713
+ ? this.activeConfig
714
+ : null;
715
+ }
716
+ get columnChooser() {
717
+ return resolveColumnChooser(this.gridConfig?.columnChooser);
718
+ }
719
+ get gridElement() {
720
+ return this.shadowRoot?.querySelector('nile-data-grid.nile-chart-grid') ?? null;
721
+ }
722
+ /** Seeds from `config.columnVisibility` whenever the app passes a new object; user toggles live here in between. */
723
+ resolveGridColumnVisibility(config) {
724
+ const source = config.columnVisibility ?? DEFAULT_GRID_COLUMN_VISIBILITY;
725
+ if (source !== this.gridColumnVisibilitySeed) {
726
+ this.gridColumnVisibilitySeed = source;
727
+ this.gridColumnVisibility = source;
728
+ }
729
+ return this.gridColumnVisibility;
730
+ }
731
+ renderColumnChooserTrigger() {
732
+ const chooser = this.columnChooser;
733
+ const config = this.gridConfig;
734
+ if (!chooser || !config)
735
+ return nothing;
736
+ if (this.loading || config.loading)
737
+ return nothing;
738
+ const grid = this.gridElement;
739
+ const order = grid?.columnOrder?.length ? grid.columnOrder : config.columnOrder ?? [];
740
+ return renderColumnChooser({
741
+ chooser,
742
+ entries: chooserEntries(config.columns, order),
743
+ visibility: this.resolveGridColumnVisibility(config),
744
+ onToggle: (id, visible) => this.gridElement?.toggleColumnVisibility(id, visible),
745
+ onReset: () => this.gridElement?.showAllColumns(),
746
+ onShow: () => {
747
+ const first = document.querySelector(`.${COLUMN_CHOOSER_PANEL_CLASS} nile-checkbox:not([disabled])`);
748
+ first?.focus();
749
+ },
750
+ onHide: () => {
751
+ const panel = document.querySelector(`.${COLUMN_CHOOSER_PANEL_CLASS}`);
752
+ if (panel && panel.contains(document.activeElement)) {
753
+ this.shadowRoot
754
+ ?.querySelector('.nile-chart-column-chooser-trigger')
755
+ ?.focus();
756
+ }
757
+ },
758
+ });
696
759
  }
697
760
  buildExportingOptions() {
698
761
  return { exporting: { enabled: true, buttons: { contextButton: { enabled: false } } } };
@@ -991,6 +1054,7 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
991
1054
  </div>
992
1055
  <div class="nile-chart-header-actions" part="header-actions">
993
1056
  <slot name="header-actions" @slotchange=${this.onHeaderActionsSlotChange}></slot>
1057
+ ${this.renderColumnChooserTrigger()}
994
1058
  ${this.showResetZoom
995
1059
  ? html `<nile-tooltip content="Reset zoom" placement="top" part="reset-zoom-tooltip">
996
1060
  <button
@@ -2416,10 +2480,12 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
2416
2480
  .columnResizeDirection=${config.columnResizeDirection ?? 'ltr'}
2417
2481
  .columnSizing=${config.columnSizing ?? DEFAULT_GRID_COLUMN_SIZING}
2418
2482
  .columnPinning=${config.columnPinning ?? DEFAULT_GRID_COLUMN_PINNING}
2419
- .columnVisibility=${config.columnVisibility ?? DEFAULT_GRID_COLUMN_VISIBILITY}
2483
+ .columnVisibility=${this.resolveGridColumnVisibility(config)}
2420
2484
  .rowSelection=${config.rowSelection ?? DEFAULT_GRID_ROW_SELECTION}
2421
2485
  .columnOrder=${config.columnOrder ?? DEFAULT_GRID_COLUMN_ORDER}
2422
2486
  style=${gridChrome}
2487
+ @nile-column-visibility-change=${this.onGridColumnVisibilityChange}
2488
+ @nile-column-order-change=${this.onGridColumnOrderChange}
2423
2489
  ></nile-data-grid>`;
2424
2490
  }
2425
2491
  case 'filter': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aquera/nile-visualization",
3
- "version": "2.9.44",
3
+ "version": "2.9.45",
4
4
  "description": "A visualization Library for the Nile Design System",
5
5
  "license": "MIT",
6
6
  "author": "Aquera Inc",