@aquera/nile-visualization 2.9.42 → 2.9.44
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 +7 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/internal/echarts/translate-config.js +42 -2
- package/dist/src/internal/types/chart-master-detail-config.type.d.ts +7 -2
- package/dist/src/internal/utils/lite-tooltip.d.ts +5 -0
- package/dist/src/internal/utils/lite-tooltip.js +18 -0
- package/dist/src/nile-chart/nile-chart-config.d.ts +7 -2
- package/dist/src/nile-chart/nile-chart-empty.js +13 -3
- package/dist/src/nile-chart/nile-chart.css.js +12 -0
- package/dist/src/nile-chart/nile-chart.d.ts +29 -5
- package/dist/src/nile-chart/nile-chart.js +193 -69
- package/dist/src/nile-kpi-chart/nile-kpi-chart.js +10 -6
- package/dist/src/nile-master-detail-chart/index.d.ts +1 -1
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.d.ts +24 -1
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.js +92 -38
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.test.d.ts +2 -0
- package/dist/src/nile-master-detail-chart/nile-master-detail-chart.test.js +262 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { customElement, property, query, state } from 'lit/decorators.js';
|
|
|
4
4
|
import { html, nothing } from 'lit';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
6
|
import NileElement from '../internal/base/nile-element.js';
|
|
7
|
-
import { styles,
|
|
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';
|
|
@@ -12,6 +12,7 @@ import { isChartEmpty, renderChartEmptyState, syncChartEmptyTruncation } from '.
|
|
|
12
12
|
import { convertConfig } from '../internal/utils/chart-adapters.js';
|
|
13
13
|
import { deepMerge } from '../internal/utils/deep-merge.js';
|
|
14
14
|
import { initNileChartExporting, getHighcharts } from '../internal/utils/highcharts-provider.js';
|
|
15
|
+
import { LITE_TOOLTIP_MAX_WIDTH, limitLiteTooltipHeight } from '../internal/utils/lite-tooltip.js';
|
|
15
16
|
import { getECharts, translateToECharts, EngineNotMigratedError, ECHARTS_MIGRATED_TYPES } from '../internal/echarts/index.js';
|
|
16
17
|
import { getAxisExtremes, setAxisExtremes, } from '../internal/utils/chart-runtime.js';
|
|
17
18
|
import { resolveColorPaletteColors } from '../internal/color-palettes/index.js';
|
|
@@ -124,16 +125,6 @@ function chartTypeLabel(type) {
|
|
|
124
125
|
.replace(/-/g, ' ')
|
|
125
126
|
.replace(/\b\w/g, ch => ch.toUpperCase());
|
|
126
127
|
}
|
|
127
|
-
let _headerTooltipStylesInjected = false;
|
|
128
|
-
function ensureHeaderTooltipStyles() {
|
|
129
|
-
if (_headerTooltipStylesInjected || typeof document === 'undefined')
|
|
130
|
-
return;
|
|
131
|
-
const style = document.createElement('style');
|
|
132
|
-
style.dataset['nilechart'] = '';
|
|
133
|
-
style.textContent = tooltipCss;
|
|
134
|
-
document.head.appendChild(style);
|
|
135
|
-
_headerTooltipStylesInjected = true;
|
|
136
|
-
}
|
|
137
128
|
/**
|
|
138
129
|
* Universal chart wrapper. Renders a card with an optional header (titles +
|
|
139
130
|
* actions) and the active chart type below.
|
|
@@ -166,7 +157,8 @@ function ensureHeaderTooltipStyles() {
|
|
|
166
157
|
let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
167
158
|
constructor() {
|
|
168
159
|
super(...arguments);
|
|
169
|
-
|
|
160
|
+
/** The nile-lite-tooltip shown for a clipped x-axis label. */
|
|
161
|
+
this._axisTipEl = null;
|
|
170
162
|
this._headerResizeObs = null;
|
|
171
163
|
/** Full chart configuration. Accepts flat NileChartConfig or separated { chart, aq } input. */
|
|
172
164
|
this.config = null;
|
|
@@ -210,6 +202,12 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
210
202
|
* Usage: `<nile-chart chart-type="pie" />` plus `config.chart` with series data only.
|
|
211
203
|
*/
|
|
212
204
|
this.chartTypeAttr = '';
|
|
205
|
+
/** Long x-axis labels: `truncate` (ellipsis) or `wrap`, at `xAxisLabelMaxWidth`. */
|
|
206
|
+
this.xAxisLabelMode = 'truncate';
|
|
207
|
+
/** Max width in px of an x-axis label before it truncates or wraps. */
|
|
208
|
+
this.xAxisLabelMaxWidth = 80;
|
|
209
|
+
/** Rotation in degrees of x-axis labels (e.g. `-45`); `0` keeps them flat. */
|
|
210
|
+
this.xAxisLabelRotation = 0;
|
|
213
211
|
/** Summary/insight text — shown as the AI panel's opening message when the chat is opened. */
|
|
214
212
|
this.summary = '';
|
|
215
213
|
this.aiBorder = false;
|
|
@@ -288,15 +286,38 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
288
286
|
this.gridLineStrengthFromConfig = false;
|
|
289
287
|
this._emptyEl = null;
|
|
290
288
|
this._emptyObs = null;
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
this.
|
|
295
|
-
const el = e.
|
|
296
|
-
if (el
|
|
289
|
+
/** The x-axis label the tooltip belongs to. */
|
|
290
|
+
this._axisLabelActive = null;
|
|
291
|
+
/** Shows the full name for a clipped label; uses mousemove because some browsers never fire mouseover here. */
|
|
292
|
+
this._onAxisLabelMove = (e) => {
|
|
293
|
+
const el = this._axisLabelFrom(e) ?? this._axisLabelAt(e);
|
|
294
|
+
if (el === this._axisLabelActive)
|
|
295
|
+
return;
|
|
296
|
+
this._axisLabelActive = el;
|
|
297
|
+
if (el && el.scrollWidth > el.clientWidth) {
|
|
298
|
+
this._cancelAxisTipHide();
|
|
299
|
+
this._showAxisLabelTip(el);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
this._scheduleAxisTipHide();
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
this._axisTipHideTimer = null;
|
|
306
|
+
this._onAxisViewportMove = () => {
|
|
307
|
+
this._axisLabelActive = null;
|
|
308
|
+
this._hideAxisLabelTip();
|
|
309
|
+
};
|
|
310
|
+
this._onAxisLabelOut = (e) => {
|
|
311
|
+
if (!this._axisLabelFrom(e))
|
|
297
312
|
return;
|
|
298
|
-
|
|
299
|
-
this.
|
|
313
|
+
this._axisLabelActive = null;
|
|
314
|
+
this._scheduleAxisTipHide();
|
|
315
|
+
};
|
|
316
|
+
this._onAxisLabelLeave = () => {
|
|
317
|
+
if (!this._axisLabelActive)
|
|
318
|
+
return;
|
|
319
|
+
this._axisLabelActive = null;
|
|
320
|
+
this._scheduleAxisTipHide();
|
|
300
321
|
};
|
|
301
322
|
// ── ECharts engine path (NILE-005) ──────────────────────────────
|
|
302
323
|
this._echart = null;
|
|
@@ -370,16 +391,13 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
370
391
|
}
|
|
371
392
|
connectedCallback() {
|
|
372
393
|
super.connectedCallback();
|
|
373
|
-
ensureHeaderTooltipStyles();
|
|
374
394
|
injectGlobalChartMenuOverrides();
|
|
375
|
-
const tip = document.createElement('div');
|
|
376
|
-
tip.className = 'nile-chart-header-tooltip';
|
|
377
|
-
tip.setAttribute('role', 'tooltip');
|
|
378
|
-
document.body.appendChild(tip);
|
|
379
|
-
this._headerTipEl = tip;
|
|
380
395
|
document.addEventListener('click', this.handleOutsideClick);
|
|
381
396
|
this.addEventListener('nile-chart-ready', this.handleChartReady);
|
|
382
397
|
this.addEventListener('dblclick', this._onDoubleTap);
|
|
398
|
+
this.addEventListener('mousemove', this._onAxisLabelMove);
|
|
399
|
+
this.addEventListener('mouseout', this._onAxisLabelOut);
|
|
400
|
+
this.addEventListener('mouseleave', this._onAxisLabelLeave);
|
|
383
401
|
initNileChartExporting();
|
|
384
402
|
// Pick up config set before element upgrade (e.g. Angular ngAfterViewInit)
|
|
385
403
|
if (this.config && !this.resolvedConfig) {
|
|
@@ -393,9 +411,11 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
393
411
|
document.removeEventListener('click', this.handleOutsideClick);
|
|
394
412
|
this.removeEventListener('nile-chart-ready', this.handleChartReady);
|
|
395
413
|
this.removeEventListener('dblclick', this._onDoubleTap);
|
|
396
|
-
this.
|
|
397
|
-
this.
|
|
398
|
-
this.
|
|
414
|
+
this.removeEventListener('mousemove', this._onAxisLabelMove);
|
|
415
|
+
this.removeEventListener('mouseout', this._onAxisLabelOut);
|
|
416
|
+
this.removeEventListener('mouseleave', this._onAxisLabelLeave);
|
|
417
|
+
this._hideAxisLabelTip();
|
|
418
|
+
this._removeAxisTip(true);
|
|
399
419
|
this._headerResizeObs?.disconnect();
|
|
400
420
|
this._headerResizeObs = null;
|
|
401
421
|
this._emptyObs?.disconnect();
|
|
@@ -814,40 +834,13 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
814
834
|
<slot name="nile-ai-trigger-after"></slot>
|
|
815
835
|
`;
|
|
816
836
|
}
|
|
817
|
-
_showHeaderTip(text, x, y, anchorHeight = 0) {
|
|
818
|
-
if (!this._headerTipEl)
|
|
819
|
-
return;
|
|
820
|
-
this._headerTipEl.textContent = text;
|
|
821
|
-
this._headerTipEl.style.left = `${x}px`;
|
|
822
|
-
this._headerTipEl.style.top = `${y}px`;
|
|
823
|
-
this._headerTipEl.style.display = 'block';
|
|
824
|
-
window.addEventListener('scroll', this._onViewportMove, { capture: true, passive: true });
|
|
825
|
-
window.addEventListener('resize', this._onViewportMove, { passive: true });
|
|
826
|
-
// Keep the tooltip inside the viewport; the arrow keeps pointing at the anchor.
|
|
827
|
-
const margin = 8;
|
|
828
|
-
const half = this._headerTipEl.offsetWidth / 2;
|
|
829
|
-
const cx = Math.min(Math.max(x, half + margin), Math.max(half + margin, window.innerWidth - half - margin));
|
|
830
|
-
this._headerTipEl.style.left = `${cx}px`;
|
|
831
|
-
this._headerTipEl.style.setProperty('--tip-arrow-x', `${half + x - cx}px`);
|
|
832
|
-
// Not enough room above the anchor: drop below it instead.
|
|
833
|
-
const above = y - this._headerTipEl.offsetHeight - 10 >= margin;
|
|
834
|
-
this._headerTipEl.classList.toggle('below', !above);
|
|
835
|
-
if (!above)
|
|
836
|
-
this._headerTipEl.style.top = `${y + anchorHeight}px`;
|
|
837
|
-
}
|
|
838
|
-
_hideHeaderTip() {
|
|
839
|
-
if (this._headerTipEl)
|
|
840
|
-
this._headerTipEl.style.display = 'none';
|
|
841
|
-
window.removeEventListener('scroll', this._onViewportMove, true);
|
|
842
|
-
window.removeEventListener('resize', this._onViewportMove);
|
|
843
|
-
}
|
|
844
837
|
/** Info icon beside the header title. Tooltip, focus and ARIA live on the wrapper, not the glyph. */
|
|
845
838
|
renderHeaderInfo() {
|
|
846
839
|
const info = String(this.headerInfo('chartInfo') ?? '');
|
|
847
840
|
if (!info)
|
|
848
841
|
return nothing;
|
|
849
842
|
const size = this.headerInfo('chartInfoIconSize');
|
|
850
|
-
return html `<nile-lite-tooltip class="nile-chart-header-info-tip" content=${info} placement="top"><span
|
|
843
|
+
return html `<nile-lite-tooltip class="nile-chart-header-info-tip" content=${info} placement="top" .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} interactive @nile-show=${limitLiteTooltipHeight}><span
|
|
851
844
|
class="nile-chart-header-info"
|
|
852
845
|
part="header-info"
|
|
853
846
|
role="img"
|
|
@@ -860,24 +853,118 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
860
853
|
color=${this.headerInfo('chartInfoIconColor') || 'currentColor'}
|
|
861
854
|
></nile-glyph></span></nile-lite-tooltip>`;
|
|
862
855
|
}
|
|
856
|
+
/** The x-axis label span in the event's composed path, if any. */
|
|
857
|
+
_axisLabelFrom(e) {
|
|
858
|
+
const hit = e.composedPath().find((n) => n instanceof HTMLElement && n.classList.contains('nile-axis-label'));
|
|
859
|
+
return hit ?? null;
|
|
860
|
+
}
|
|
861
|
+
/** Finds an unrotated label by pointer coordinates, since some browsers report the wrong event target. */
|
|
862
|
+
_axisLabelAt(e) {
|
|
863
|
+
const m = e;
|
|
864
|
+
if (typeof m.clientX !== 'number')
|
|
865
|
+
return null;
|
|
866
|
+
const svg = e.composedPath().find((n) => n instanceof Element && n.classList.contains('highcharts-root'));
|
|
867
|
+
if (!svg)
|
|
868
|
+
return null;
|
|
869
|
+
for (const el of Array.from(svg.querySelectorAll('.nile-axis-label'))) {
|
|
870
|
+
const r = el.getBoundingClientRect();
|
|
871
|
+
const rotated = r.height > el.offsetHeight + 4 || r.width > el.offsetWidth + 4;
|
|
872
|
+
if (rotated)
|
|
873
|
+
continue; // rotated boxes are much larger than the text; their span target is reliable
|
|
874
|
+
if (m.clientX >= r.left && m.clientX <= r.right && m.clientY >= r.top && m.clientY <= r.bottom)
|
|
875
|
+
return el;
|
|
876
|
+
}
|
|
877
|
+
return null;
|
|
878
|
+
}
|
|
879
|
+
_showAxisLabelTip(el) {
|
|
880
|
+
const text = el.textContent ?? '';
|
|
881
|
+
const rect = el.getBoundingClientRect();
|
|
882
|
+
// A rotated label's box is taller than its text, so aim at its centre.
|
|
883
|
+
const rotated = rect.height > el.offsetHeight + 4 || rect.width > el.offsetWidth + 4;
|
|
884
|
+
if (!customElements.get('nile-lite-tooltip'))
|
|
885
|
+
return;
|
|
886
|
+
// A fresh tooltip per label: reopening a shared one inside its fade-out shows nothing.
|
|
887
|
+
this._removeAxisTip(true);
|
|
888
|
+
const tip = document.createElement('nile-lite-tooltip');
|
|
889
|
+
tip.setAttribute('placement', 'top');
|
|
890
|
+
tip.setAttribute('trigger', 'manual');
|
|
891
|
+
tip.maxWidth = LITE_TOOLTIP_MAX_WIDTH;
|
|
892
|
+
tip.addEventListener('nile-show', limitLiteTooltipHeight);
|
|
893
|
+
const anchor = document.createElement('div');
|
|
894
|
+
anchor.setAttribute('aria-hidden', 'true');
|
|
895
|
+
anchor.style.cssText = 'position:fixed;pointer-events:none;visibility:hidden;';
|
|
896
|
+
anchor.style.left = `${rotated ? rect.left + rect.width / 2 : rect.left}px`;
|
|
897
|
+
anchor.style.top = `${rotated ? rect.top + rect.height / 2 : rect.top}px`;
|
|
898
|
+
anchor.style.width = rotated ? '1px' : `${rect.width}px`;
|
|
899
|
+
anchor.style.height = rotated ? '1px' : `${rect.height}px`;
|
|
900
|
+
tip.appendChild(anchor);
|
|
901
|
+
document.body.appendChild(tip);
|
|
902
|
+
tip.content = text;
|
|
903
|
+
this._axisTipEl = tip;
|
|
904
|
+
// Open after the first render; opening at creation shows nothing.
|
|
905
|
+
void tip.updateComplete?.then(() => {
|
|
906
|
+
if (this._axisTipEl === tip)
|
|
907
|
+
tip.open = true;
|
|
908
|
+
});
|
|
909
|
+
// The anchor uses viewport coordinates and is placed once, so close on scroll/resize.
|
|
910
|
+
window.addEventListener('scroll', this._onAxisViewportMove, { capture: true, passive: true });
|
|
911
|
+
window.addEventListener('resize', this._onAxisViewportMove, { passive: true });
|
|
912
|
+
}
|
|
913
|
+
_cancelAxisTipHide() {
|
|
914
|
+
if (this._axisTipHideTimer !== null) {
|
|
915
|
+
window.clearTimeout(this._axisTipHideTimer);
|
|
916
|
+
this._axisTipHideTimer = null;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
/** Brief grace period so crossing the gap between two labels doesn't close and reopen the tooltip. */
|
|
920
|
+
_scheduleAxisTipHide() {
|
|
921
|
+
this._cancelAxisTipHide();
|
|
922
|
+
this._axisTipHideTimer = window.setTimeout(() => {
|
|
923
|
+
this._axisTipHideTimer = null;
|
|
924
|
+
this._hideAxisLabelTip();
|
|
925
|
+
}, 120);
|
|
926
|
+
}
|
|
927
|
+
/** Drop the current label tooltip: instantly, or after letting it fade out. */
|
|
928
|
+
_removeAxisTip(instant) {
|
|
929
|
+
const tip = this._axisTipEl;
|
|
930
|
+
this._axisTipEl = null;
|
|
931
|
+
if (!tip)
|
|
932
|
+
return;
|
|
933
|
+
if (instant) {
|
|
934
|
+
tip.remove();
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
tip.open = false;
|
|
938
|
+
window.setTimeout(() => tip.remove(), 300);
|
|
939
|
+
}
|
|
940
|
+
_hideAxisLabelTip() {
|
|
941
|
+
this._cancelAxisTipHide();
|
|
942
|
+
this._removeAxisTip(false);
|
|
943
|
+
window.removeEventListener('scroll', this._onAxisViewportMove, true);
|
|
944
|
+
window.removeEventListener('resize', this._onAxisViewportMove);
|
|
945
|
+
}
|
|
863
946
|
_syncHeaderTruncationA11y() {
|
|
864
947
|
const root = this.shadowRoot;
|
|
865
948
|
if (!root)
|
|
866
949
|
return;
|
|
867
|
-
for (const
|
|
868
|
-
const el = root.querySelector(
|
|
950
|
+
for (const kind of ['title', 'subtitle']) {
|
|
951
|
+
const el = root.querySelector(`.nile-chart-header-${kind}`);
|
|
869
952
|
if (!el)
|
|
870
953
|
continue;
|
|
954
|
+
const tip = root.querySelector(`.nile-chart-header-tip[data-header-tip="${kind}"]`);
|
|
871
955
|
const truncated = el.scrollWidth > el.clientWidth;
|
|
872
|
-
if (truncated)
|
|
956
|
+
if (truncated)
|
|
873
957
|
el.setAttribute('tabindex', '0');
|
|
874
|
-
|
|
875
|
-
else {
|
|
958
|
+
else
|
|
876
959
|
el.removeAttribute('tabindex');
|
|
877
|
-
|
|
878
|
-
|
|
960
|
+
if (tip)
|
|
961
|
+
tip.disabled = !truncated;
|
|
879
962
|
}
|
|
880
963
|
}
|
|
964
|
+
/** Header title or subtitle, wrapped in a lite tooltip that only enables once the text is clipped. */
|
|
965
|
+
renderHeaderText(kind, text, fontSize) {
|
|
966
|
+
return html `<nile-lite-tooltip class="nile-chart-header-tip" data-header-tip=${kind} content=${text} placement="top" .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} disabled><p class="nile-chart-header-${kind}" part="header-${kind}" style=${fontSize ? `font-size:${fontSize}` : nothing}>${text}</p></nile-lite-tooltip>`;
|
|
967
|
+
}
|
|
881
968
|
renderHeader() {
|
|
882
969
|
if (!this.shouldShowHeader())
|
|
883
970
|
return nothing;
|
|
@@ -895,10 +982,10 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
895
982
|
? html `
|
|
896
983
|
${title
|
|
897
984
|
? this.headerInfo('chartInfo')
|
|
898
|
-
? html `<div class="nile-chart-header-title-row" part="header-title-row">${
|
|
899
|
-
:
|
|
985
|
+
? html `<div class="nile-chart-header-title-row" part="header-title-row">${this.renderHeaderText('title', title, titleFontSize)}${this.renderHeaderInfo()}</div>`
|
|
986
|
+
: this.renderHeaderText('title', title, titleFontSize)
|
|
900
987
|
: nothing}
|
|
901
|
-
${subtitle ?
|
|
988
|
+
${subtitle ? this.renderHeaderText('subtitle', subtitle, subtitleFontSize) : nothing}
|
|
902
989
|
`
|
|
903
990
|
: nothing}
|
|
904
991
|
</div>
|
|
@@ -1003,6 +1090,32 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1003
1090
|
const { show, ...rest } = config.legend;
|
|
1004
1091
|
legendOptions.legend = { enabled: show ?? true, ...rest };
|
|
1005
1092
|
}
|
|
1093
|
+
const truncate = this.xAxisLabelMode !== 'wrap';
|
|
1094
|
+
const maxWidth = this.xAxisLabelMaxWidth;
|
|
1095
|
+
const labelOptions = {
|
|
1096
|
+
xAxis: {
|
|
1097
|
+
labels: {
|
|
1098
|
+
rotation: this.xAxisLabelRotation,
|
|
1099
|
+
// HTML labels allow the hover tooltip; defaultLabelFormatter keeps numeric/datetime axes formatted.
|
|
1100
|
+
useHTML: true,
|
|
1101
|
+
formatter() {
|
|
1102
|
+
const text = String(this.axis.defaultLabelFormatter.call(this));
|
|
1103
|
+
const esc = text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
1104
|
+
// text-overflow isn't inherited, so the clipping styles go on the span.
|
|
1105
|
+
const clip = truncate
|
|
1106
|
+
? `display:inline-block;max-width:min(${maxWidth}px,100%);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:top;`
|
|
1107
|
+
: '';
|
|
1108
|
+
return `<span class="nile-axis-label" style="${clip}">${esc}</span>`;
|
|
1109
|
+
},
|
|
1110
|
+
style: {
|
|
1111
|
+
width: `${this.xAxisLabelMaxWidth}px`,
|
|
1112
|
+
...(this.xAxisLabelMode === 'wrap'
|
|
1113
|
+
? { whiteSpace: 'normal', textOverflow: 'clip' }
|
|
1114
|
+
: { whiteSpace: 'nowrap', textOverflow: 'ellipsis' }),
|
|
1115
|
+
},
|
|
1116
|
+
},
|
|
1117
|
+
},
|
|
1118
|
+
};
|
|
1006
1119
|
const spacingOptions = {};
|
|
1007
1120
|
if (config.chartSpacing) {
|
|
1008
1121
|
const { top, right, bottom, left } = config.chartSpacing;
|
|
@@ -1044,7 +1157,7 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1044
1157
|
const paletteOptions = paletteColors ? { colors: paletteColors } : {};
|
|
1045
1158
|
// Precedence (later wins): raw options → passthrough fields → legend →
|
|
1046
1159
|
// spacing → palette → title suppression → exporting.
|
|
1047
|
-
const mergedOptions = deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(config.options ?? {}, passthroughOptions), legendOptions), spacingOptions), paletteOptions), noTitle), this.buildExportingOptions());
|
|
1160
|
+
const mergedOptions = deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(deepMerge(labelOptions, config.options ?? {}), passthroughOptions), legendOptions), spacingOptions), paletteOptions), noTitle), this.buildExportingOptions());
|
|
1048
1161
|
switch (config.type) {
|
|
1049
1162
|
case 'bar':
|
|
1050
1163
|
return html `<nile-bar-chart
|
|
@@ -1568,7 +1681,9 @@ let NileChart = NileChart_1 = class NileChart extends NileElement {
|
|
|
1568
1681
|
></nile-timeline-chart>`;
|
|
1569
1682
|
case 'master-detail':
|
|
1570
1683
|
return html `<nile-master-detail-chart
|
|
1571
|
-
.data=${config.data}
|
|
1684
|
+
.data=${config.data ?? []}
|
|
1685
|
+
.series=${config.series ?? []}
|
|
1686
|
+
.stacking=${config.stacking ?? ''}
|
|
1572
1687
|
.height=${this.hasAttribute('fit') ? null : (config.height ?? '100%')}
|
|
1573
1688
|
.seriesName=${config.seriesName ?? ''}
|
|
1574
1689
|
.seriesColor=${config.seriesColor ?? ''}
|
|
@@ -2419,6 +2534,15 @@ __decorate([
|
|
|
2419
2534
|
__decorate([
|
|
2420
2535
|
property({ type: String, attribute: 'chart-type' })
|
|
2421
2536
|
], NileChart.prototype, "chartTypeAttr", void 0);
|
|
2537
|
+
__decorate([
|
|
2538
|
+
property({ type: String, attribute: true })
|
|
2539
|
+
], NileChart.prototype, "xAxisLabelMode", void 0);
|
|
2540
|
+
__decorate([
|
|
2541
|
+
property({ type: Number, attribute: true })
|
|
2542
|
+
], NileChart.prototype, "xAxisLabelMaxWidth", void 0);
|
|
2543
|
+
__decorate([
|
|
2544
|
+
property({ type: Number, attribute: true })
|
|
2545
|
+
], NileChart.prototype, "xAxisLabelRotation", void 0);
|
|
2422
2546
|
__decorate([
|
|
2423
2547
|
property({ type: String })
|
|
2424
2548
|
], NileChart.prototype, "summary", void 0);
|
|
@@ -5,6 +5,7 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
|
5
5
|
import NileElement from '../internal/base/nile-element.js';
|
|
6
6
|
import { getHighcharts } from '../internal/utils/highcharts-provider.js';
|
|
7
7
|
import { styles, tooltipCss } from './nile-kpi-chart.css.js';
|
|
8
|
+
import { LITE_TOOLTIP_MAX_WIDTH, limitLiteTooltipHeight } from '../internal/utils/lite-tooltip.js';
|
|
8
9
|
// Inject tooltip styles into document.head once per page load.
|
|
9
10
|
let _tooltipStylesInjected = false;
|
|
10
11
|
function ensureTooltipStyles() {
|
|
@@ -1254,6 +1255,9 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1254
1255
|
return nothing;
|
|
1255
1256
|
const [vertical, side] = (typeof this.valueInfoPlacement === 'string' ? this.valueInfoPlacement : 'top-right').split('-');
|
|
1256
1257
|
return html `<nile-lite-tooltip
|
|
1258
|
+
.maxWidth=${LITE_TOOLTIP_MAX_WIDTH}
|
|
1259
|
+
@nile-show=${limitLiteTooltipHeight}
|
|
1260
|
+
interactive
|
|
1257
1261
|
class="kpi-info-tip kpi-info--${vertical === 'bottom' || vertical === 'center' ? vertical : 'top'} kpi-info--${side === 'left' ? 'left' : 'right'}"
|
|
1258
1262
|
content=${this.valueInfo}
|
|
1259
1263
|
placement="top"
|
|
@@ -1302,7 +1306,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1302
1306
|
const dir = this.trendDirection;
|
|
1303
1307
|
const formatted = Math.abs(this.trendValue).toFixed(1) + '%';
|
|
1304
1308
|
const trendAriaLabel = `Trend ${dir === 'up' ? 'up' : dir === 'down' ? 'down' : 'neutral'} ${formatted}${this.trendLabel ? ' ' + this.trendLabel : ''}`.trim();
|
|
1305
|
-
return html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="trend" content=${this._trendTooltipText()} placement="top" disabled><span
|
|
1309
|
+
return html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" data-kpi-tip="trend" content=${this._trendTooltipText()} placement="top" disabled><span
|
|
1306
1310
|
class="kpi-trend kpi-trend--${dir}"
|
|
1307
1311
|
tabindex="0"
|
|
1308
1312
|
role="button"
|
|
@@ -1369,7 +1373,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1369
1373
|
*/
|
|
1370
1374
|
renderHeaderRow(extra, trendRow) {
|
|
1371
1375
|
return html `<div class="kpi-header">
|
|
1372
|
-
${this.label ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="label" content=${this.label} placement="top" disabled><p
|
|
1376
|
+
${this.label ? html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" data-kpi-tip="label" content=${this.label} placement="top" disabled><p
|
|
1373
1377
|
class="kpi-label"
|
|
1374
1378
|
tabindex="0"
|
|
1375
1379
|
><span class="kpi-label-text">${this.label}</span></p></nile-lite-tooltip>` : nothing}
|
|
@@ -1405,7 +1409,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1405
1409
|
<span class="kpi-value-group">
|
|
1406
1410
|
${infoLeft ? this.renderValueInfo() : nothing}
|
|
1407
1411
|
${showTooltip
|
|
1408
|
-
? html `<nile-lite-tooltip class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
|
|
1412
|
+
? html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
|
|
1409
1413
|
: valueEl}
|
|
1410
1414
|
${infoLeft ? nothing : this.renderValueInfo()}
|
|
1411
1415
|
</span>
|
|
@@ -1413,7 +1417,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1413
1417
|
|
|
1414
1418
|
${this.renderForecast()}
|
|
1415
1419
|
|
|
1416
|
-
${this.description ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
|
|
1420
|
+
${this.description ? html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
|
|
1417
1421
|
class="kpi-description"
|
|
1418
1422
|
tabindex="0"
|
|
1419
1423
|
>${this.description}</p></nile-lite-tooltip>` : nothing}
|
|
@@ -1447,7 +1451,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1447
1451
|
<span class="kpi-value-group">
|
|
1448
1452
|
${infoLeft ? this.renderValueInfo() : nothing}
|
|
1449
1453
|
${showTooltip
|
|
1450
|
-
? html `<nile-lite-tooltip class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
|
|
1454
|
+
? html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
|
|
1451
1455
|
: valueEl}
|
|
1452
1456
|
${infoLeft ? nothing : this.renderValueInfo()}
|
|
1453
1457
|
</span>
|
|
@@ -1459,7 +1463,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
|
|
|
1459
1463
|
|
|
1460
1464
|
${this.renderForecast()}
|
|
1461
1465
|
|
|
1462
|
-
${this.description ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
|
|
1466
|
+
${this.description ? html `<nile-lite-tooltip .maxWidth=${LITE_TOOLTIP_MAX_WIDTH} @nile-show=${limitLiteTooltipHeight} class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
|
|
1463
1467
|
class="kpi-description"
|
|
1464
1468
|
tabindex="0"
|
|
1465
1469
|
>${this.description}</p></nile-lite-tooltip>` : nothing}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NileMasterDetailChart } from './nile-master-detail-chart.js';
|
|
2
|
-
export type { MasterDetailPoint, MasterDetailSeriesType } from './nile-master-detail-chart.js';
|
|
2
|
+
export type { MasterDetailPoint, MasterDetailSeries, MasterDetailSeriesType, MasterDetailStacking } from './nile-master-detail-chart.js';
|
|
@@ -8,6 +8,15 @@ export interface MasterDetailPoint {
|
|
|
8
8
|
x: number;
|
|
9
9
|
y: number;
|
|
10
10
|
}
|
|
11
|
+
/** One named series for the multi-series form (`series` property). */
|
|
12
|
+
export interface MasterDetailSeries {
|
|
13
|
+
name: string;
|
|
14
|
+
data: MasterDetailPoint[];
|
|
15
|
+
color?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const MASTER_DETAIL_STACKING: readonly ["normal", "percent"];
|
|
18
|
+
/** `''` (or any unknown value) means no stacking. */
|
|
19
|
+
export type MasterDetailStacking = (typeof MASTER_DETAIL_STACKING)[number] | '';
|
|
11
20
|
export declare const MASTER_DETAIL_SERIES_TYPES: readonly ["area", "line", "spline", "areaspline", "column", "bar"];
|
|
12
21
|
export type MasterDetailSeriesType = (typeof MASTER_DETAIL_SERIES_TYPES)[number];
|
|
13
22
|
export declare const MASTER_DETAIL_X_AXIS_TYPES: readonly ["datetime", "linear", "logarithmic", "category"];
|
|
@@ -30,6 +39,13 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
30
39
|
data: MasterDetailPoint[];
|
|
31
40
|
seriesName: string;
|
|
32
41
|
seriesColor: string;
|
|
42
|
+
/**
|
|
43
|
+
* Several named series. When non-empty it replaces `data` / `seriesName` /
|
|
44
|
+
* `seriesColor`. Series should share x values so stacks line up.
|
|
45
|
+
*/
|
|
46
|
+
series: MasterDetailSeries[];
|
|
47
|
+
/** Stack the series on both panes: `normal`, `percent`, or `''` for none. */
|
|
48
|
+
stacking: MasterDetailStacking;
|
|
33
49
|
detailType: MasterDetailSeriesType;
|
|
34
50
|
masterType: MasterDetailSeriesType;
|
|
35
51
|
masterOnly: boolean;
|
|
@@ -70,7 +86,14 @@ export declare class NileMasterDetailChart extends NileElement {
|
|
|
70
86
|
protected firstUpdated(): void;
|
|
71
87
|
protected updated(changedProperties: PropertyValues): void;
|
|
72
88
|
private setupResizeObserver;
|
|
73
|
-
|
|
89
|
+
/** `series` when given, else one series built from `data` / `seriesName` / `seriesColor`. */
|
|
90
|
+
private get _seriesList();
|
|
91
|
+
private get _isMultiSeries();
|
|
92
|
+
private get _stackingMode();
|
|
93
|
+
/** Sorted, de-duplicated x values across every series. */
|
|
94
|
+
private _allXs;
|
|
95
|
+
private mapPoints;
|
|
96
|
+
private buildSeries;
|
|
74
97
|
private dataExtremes;
|
|
75
98
|
private pointStep;
|
|
76
99
|
private get _isCategoricalMaster();
|