@aquera/nile-visualization 0.5.0 → 0.7.0

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.
Files changed (44) hide show
  1. package/dist/src/index.d.ts +8 -2
  2. package/dist/src/index.js +3 -0
  3. package/dist/src/internal/dashboard-adapters.d.ts +13 -0
  4. package/dist/src/internal/dashboard-adapters.js +123 -0
  5. package/dist/src/internal/highcharts-provider.js +27 -0
  6. package/dist/src/internal/types/chart-config.type.d.ts +2 -1
  7. package/dist/src/internal/types/chart-map-config.type.d.ts +29 -0
  8. package/dist/src/internal/types/chart-map-config.type.js +2 -0
  9. package/dist/src/internal/types/dashboard-config.type.d.ts +8 -0
  10. package/dist/src/internal/types/dashboard-config.type.js +2 -0
  11. package/dist/src/internal/types/index.d.ts +1 -0
  12. package/dist/src/internal/types/nile-chart-config-input.type.d.ts +6 -2
  13. package/dist/src/internal/types/widget-config.type.d.ts +23 -0
  14. package/dist/src/internal/types/widget-config.type.js +2 -0
  15. package/dist/src/internal/types/widget-layout.type.d.ts +11 -0
  16. package/dist/src/internal/types/widget-layout.type.js +2 -0
  17. package/dist/src/nile-chart/index.d.ts +2 -2
  18. package/dist/src/nile-chart/nile-chart-config-builder.js +2 -1
  19. package/dist/src/nile-chart/nile-chart-config.d.ts +119 -30
  20. package/dist/src/nile-chart/nile-chart.css.js +20 -6
  21. package/dist/src/nile-chart/nile-chart.d.ts +11 -0
  22. package/dist/src/nile-chart/nile-chart.js +39 -2
  23. package/dist/src/nile-dashboard-viewer/index.d.ts +2 -0
  24. package/dist/src/nile-dashboard-viewer/index.js +2 -0
  25. package/dist/src/nile-dashboard-viewer/nile-dashboard-viewer.css.d.ts +1 -0
  26. package/dist/src/nile-dashboard-viewer/nile-dashboard-viewer.css.js +29 -0
  27. package/dist/src/nile-dashboard-viewer/nile-dashboard-viewer.d.ts +43 -0
  28. package/dist/src/nile-dashboard-viewer/nile-dashboard-viewer.js +84 -0
  29. package/dist/src/nile-kpi-chart/nile-kpi-chart.css.js +19 -11
  30. package/dist/src/nile-kpi-chart/nile-kpi-chart.d.ts +8 -2
  31. package/dist/src/nile-kpi-chart/nile-kpi-chart.js +43 -9
  32. package/dist/src/nile-map-chart/index.d.ts +2 -0
  33. package/dist/src/nile-map-chart/index.js +2 -0
  34. package/dist/src/nile-map-chart/nile-map-chart.css.d.ts +1 -0
  35. package/dist/src/nile-map-chart/nile-map-chart.css.js +28 -0
  36. package/dist/src/nile-map-chart/nile-map-chart.d.ts +74 -0
  37. package/dist/src/nile-map-chart/nile-map-chart.js +263 -0
  38. package/dist/src/nile-widget-viewer/index.d.ts +3 -0
  39. package/dist/src/nile-widget-viewer/index.js +2 -0
  40. package/dist/src/nile-widget-viewer/nile-widget-viewer.css.d.ts +1 -0
  41. package/dist/src/nile-widget-viewer/nile-widget-viewer.css.js +20 -0
  42. package/dist/src/nile-widget-viewer/nile-widget-viewer.d.ts +33 -0
  43. package/dist/src/nile-widget-viewer/nile-widget-viewer.js +50 -0
  44. package/package.json +4 -2
@@ -0,0 +1,263 @@
1
+ import { __decorate } from "tslib";
2
+ import { customElement, property, query } from 'lit/decorators.js';
3
+ import { html } from 'lit';
4
+ import NileElement from '../internal/nile-element.js';
5
+ import { getHighcharts } from '../internal/highcharts-provider.js';
6
+ import { deepMerge } from '../internal/utils.js';
7
+ import { styles } from './nile-map-chart.css.js';
8
+ let NileMapChart = class NileMapChart extends NileElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this._hc = null;
12
+ this.chart = null;
13
+ this.resizeObserver = null;
14
+ /** Full chart configuration. Accepts separated { chart, aq } input. */
15
+ this.config = null;
16
+ /** The chart title displayed above the chart. */
17
+ this.chartTitle = '';
18
+ /** The subtitle displayed below the title. */
19
+ this.chartSubtitle = '';
20
+ /**
21
+ * Array of data points. Each point should have a value and a key matching the
22
+ * map topology (e.g. `{ 'hc-key': 'us-ca', value: 42 }`).
23
+ */
24
+ this.data = [];
25
+ /**
26
+ * GeoJSON or Highcharts topology object describing the map shapes.
27
+ * Obtain from https://code.highcharts.com/mapdata/ or supply your own.
28
+ */
29
+ this.mapData = null;
30
+ /**
31
+ * How to join `data` with `mapData`. Defaults to `['hc-key', 'hc-key']`.
32
+ * Pass a single string to match by that property name on both sides,
33
+ * or a two-element array `[mapKey, dataKey]` for different key names.
34
+ */
35
+ this.joinBy = ['hc-key', 'hc-key'];
36
+ /** Deep-merge override object for full Highcharts options. */
37
+ this.options = {};
38
+ /** Whether to show a loading indicator instead of the chart. */
39
+ this.loading = false;
40
+ /** CSS height for the chart container. */
41
+ this.height = '500px';
42
+ /** Enable mouse-wheel zoom, double-click zoom, and +/− zoom buttons. Default: true. */
43
+ this.zoom = true;
44
+ /**
45
+ * Type of the primary map series.
46
+ * - `'map'` (default) — choropleth/filled regions
47
+ * - `'mapline'` — line/route overlay
48
+ * - `'mappoint'` — scatter points on map
49
+ * - `'mapbubble'` — sized bubbles on map
50
+ * For multi-series or `tiledwebmap`, pass `options.series` directly (it replaces the default series).
51
+ */
52
+ this.seriesType = 'map';
53
+ }
54
+ /** Apply { chart, aq } config to individual properties. */
55
+ applyConfig(cfg) {
56
+ const { chart: c, aq } = cfg;
57
+ if (c) {
58
+ const map = c;
59
+ if (map.data)
60
+ this.data = map.data;
61
+ if (map.mapData)
62
+ this.mapData = map.mapData;
63
+ if (map.joinBy !== undefined)
64
+ this.joinBy = map.joinBy;
65
+ if (map.seriesType)
66
+ this.seriesType = map.seriesType;
67
+ if (map.height)
68
+ this.height = map.height;
69
+ if (map.loading !== undefined)
70
+ this.loading = map.loading;
71
+ if (map.zoom !== undefined)
72
+ this.zoom = map.zoom;
73
+ if (map.options)
74
+ this.options = map.options;
75
+ }
76
+ if (aq) {
77
+ if (aq.chartTitle)
78
+ this.chartTitle = aq.chartTitle;
79
+ if (aq.chartSubtitle)
80
+ this.chartSubtitle = aq.chartSubtitle;
81
+ }
82
+ }
83
+ connectedCallback() {
84
+ super.connectedCallback();
85
+ if (this.config)
86
+ this.applyConfig(this.config);
87
+ }
88
+ disconnectedCallback() {
89
+ super.disconnectedCallback();
90
+ this.destroyChart();
91
+ this.resizeObserver?.disconnect();
92
+ this.resizeObserver = null;
93
+ }
94
+ firstUpdated() {
95
+ // If config was set synchronously before the first render (common when the
96
+ // consumer assigns `.config = {...}` immediately after the element is in the
97
+ // DOM), connectedCallback will have missed it. Apply it here so buildOptions()
98
+ // has the full options—including series type, mapView, and projection—before
99
+ // Highcharts is ever initialised.
100
+ if (this.config)
101
+ this.applyConfig(this.config);
102
+ this.initChart();
103
+ this.setupResizeObserver();
104
+ }
105
+ updated(changedProperties) {
106
+ if (changedProperties.has('config') && this.config) {
107
+ this.applyConfig(this.config);
108
+ return;
109
+ }
110
+ const chartProps = [
111
+ 'data',
112
+ 'mapData',
113
+ 'joinBy',
114
+ 'chartTitle',
115
+ 'chartSubtitle',
116
+ 'options',
117
+ 'height',
118
+ 'loading',
119
+ 'zoom',
120
+ 'seriesType',
121
+ ];
122
+ const needsUpdate = chartProps.some(p => changedProperties.has(p));
123
+ if (!needsUpdate)
124
+ return;
125
+ if (this.loading) {
126
+ this.destroyChart();
127
+ return;
128
+ }
129
+ if (this.chart) {
130
+ this.chart.update(this.buildOptions(), true, true);
131
+ }
132
+ else {
133
+ this.initChart();
134
+ }
135
+ }
136
+ setupResizeObserver() {
137
+ if (!this.chartContainer)
138
+ return;
139
+ this.resizeObserver = new ResizeObserver(() => {
140
+ this.chart?.reflow();
141
+ });
142
+ this.resizeObserver.observe(this.chartContainer);
143
+ }
144
+ buildOptions() {
145
+ const self = this;
146
+ const defaults = {
147
+ chart: {
148
+ height: this.height,
149
+ },
150
+ title: {
151
+ text: this.chartTitle || undefined,
152
+ },
153
+ subtitle: {
154
+ text: this.chartSubtitle || undefined,
155
+ },
156
+ colorAxis: {
157
+ min: 0,
158
+ },
159
+ legend: {
160
+ enabled: true,
161
+ },
162
+ mapNavigation: {
163
+ enabled: this.zoom,
164
+ enableMouseWheelZoom: this.zoom,
165
+ enableDoubleClickZoom: this.zoom,
166
+ enableDoubleClickZoomTo: false,
167
+ buttonOptions: {
168
+ alignTo: 'spacingBox',
169
+ },
170
+ },
171
+ series: this.seriesType !== 'tiledwebmap' ? [
172
+ {
173
+ type: this.seriesType,
174
+ data: this.data,
175
+ mapData: this.mapData ?? undefined,
176
+ joinBy: this.joinBy,
177
+ cursor: 'pointer',
178
+ point: {
179
+ events: {
180
+ click() {
181
+ self.emit('nile-chart-click', {
182
+ point: this,
183
+ name: this.name,
184
+ value: this.value,
185
+ key: this['hc-key'],
186
+ });
187
+ },
188
+ },
189
+ },
190
+ },
191
+ ] : [],
192
+ credits: {
193
+ enabled: false,
194
+ },
195
+ };
196
+ return deepMerge(defaults, this.options);
197
+ }
198
+ async initChart() {
199
+ if (this.loading || !this.chartContainer)
200
+ return;
201
+ if (!this._hc)
202
+ this._hc = await getHighcharts();
203
+ // Highcharts Maps module adds mapChart(); fall back to chart() if unavailable.
204
+ const hcAny = this._hc;
205
+ const factory = typeof hcAny.mapChart === 'function' ? hcAny.mapChart : hcAny.chart;
206
+ this.chart = factory(this.chartContainer, this.buildOptions());
207
+ this.emit('nile-chart-ready', { chart: this.chart });
208
+ }
209
+ destroyChart() {
210
+ if (this.chart) {
211
+ this.chart.destroy();
212
+ this.chart = null;
213
+ }
214
+ }
215
+ render() {
216
+ if (this.loading) {
217
+ return html `<div class="chart-loading" style="height:${this.height}">Loading...</div>`;
218
+ }
219
+ return html `<div class="chart-container"></div>`;
220
+ }
221
+ };
222
+ NileMapChart.styles = styles;
223
+ __decorate([
224
+ query('.chart-container')
225
+ ], NileMapChart.prototype, "chartContainer", void 0);
226
+ __decorate([
227
+ property({ type: Object })
228
+ ], NileMapChart.prototype, "config", void 0);
229
+ __decorate([
230
+ property({ type: String, attribute: 'chart-title' })
231
+ ], NileMapChart.prototype, "chartTitle", void 0);
232
+ __decorate([
233
+ property({ type: String, attribute: 'chart-subtitle' })
234
+ ], NileMapChart.prototype, "chartSubtitle", void 0);
235
+ __decorate([
236
+ property({ type: Array })
237
+ ], NileMapChart.prototype, "data", void 0);
238
+ __decorate([
239
+ property({ type: Object })
240
+ ], NileMapChart.prototype, "mapData", void 0);
241
+ __decorate([
242
+ property({ type: Array })
243
+ ], NileMapChart.prototype, "joinBy", void 0);
244
+ __decorate([
245
+ property({ type: Object })
246
+ ], NileMapChart.prototype, "options", void 0);
247
+ __decorate([
248
+ property({ type: Boolean, reflect: true })
249
+ ], NileMapChart.prototype, "loading", void 0);
250
+ __decorate([
251
+ property({ type: String })
252
+ ], NileMapChart.prototype, "height", void 0);
253
+ __decorate([
254
+ property({ type: Boolean })
255
+ ], NileMapChart.prototype, "zoom", void 0);
256
+ __decorate([
257
+ property({ type: String })
258
+ ], NileMapChart.prototype, "seriesType", void 0);
259
+ NileMapChart = __decorate([
260
+ customElement('nile-map-chart')
261
+ ], NileMapChart);
262
+ export { NileMapChart };
263
+ //# sourceMappingURL=nile-map-chart.js.map
@@ -0,0 +1,3 @@
1
+ export { NileWidgetViewer } from './nile-widget-viewer.js';
2
+ export type { NileWidgetConfig, NileWidgetChartConfig, NileWidgetKpiConfig, } from '../internal/types/widget-config.type.js';
3
+ export type { WidgetLayout } from '../internal/types/widget-layout.type.js';
@@ -0,0 +1,2 @@
1
+ export { NileWidgetViewer } from './nile-widget-viewer.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,20 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `
3
+ :host {
4
+ display: block;
5
+ width: 100%;
6
+ height: 100%;
7
+ }
8
+
9
+ :host([hidden]) {
10
+ display: none;
11
+ }
12
+
13
+ nile-chart,
14
+ nile-kpi-chart {
15
+ display: block;
16
+ width: 100%;
17
+ height: 100%;
18
+ }
19
+ `;
20
+ //# sourceMappingURL=nile-widget-viewer.css.js.map
@@ -0,0 +1,33 @@
1
+ import { nothing } from 'lit';
2
+ import type { CSSResultGroup, TemplateResult } from 'lit';
3
+ import NileElement from '../internal/nile-element.js';
4
+ import type { NileWidgetConfig } from '../internal/types/widget-config.type.js';
5
+ import '../nile-chart/index.js';
6
+ import '../nile-kpi-chart/index.js';
7
+ /**
8
+ * Renders a single dashboard widget — either a `<nile-chart>` or a `<nile-kpi-chart>` —
9
+ * based on the discriminated `type` field of the config.
10
+ *
11
+ * @example
12
+ * ```html
13
+ * <nile-widget-viewer></nile-widget-viewer>
14
+ * ```
15
+ * ```js
16
+ * el.config = {
17
+ * type: 'chart',
18
+ * layout: { x: 0, y: 0, w: 6, h: 4 },
19
+ * nileConfig: { chart: { type: 'pie', data: [...] }, aq: { chartTitle: 'My Chart' } }
20
+ * };
21
+ * ```
22
+ */
23
+ export declare class NileWidgetViewer extends NileElement {
24
+ static styles: CSSResultGroup;
25
+ /** Widget configuration. Discriminated on `type`: `'chart'` or `'kpi'`. */
26
+ config: NileWidgetConfig | null;
27
+ render(): TemplateResult | typeof nothing;
28
+ }
29
+ declare global {
30
+ interface HTMLElementTagNameMap {
31
+ 'nile-widget-viewer': NileWidgetViewer;
32
+ }
33
+ }
@@ -0,0 +1,50 @@
1
+ import { __decorate } from "tslib";
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { html, nothing } from 'lit';
4
+ import NileElement from '../internal/nile-element.js';
5
+ import { styles } from './nile-widget-viewer.css.js';
6
+ import '../nile-chart/index.js';
7
+ import '../nile-kpi-chart/index.js';
8
+ /**
9
+ * Renders a single dashboard widget — either a `<nile-chart>` or a `<nile-kpi-chart>` —
10
+ * based on the discriminated `type` field of the config.
11
+ *
12
+ * @example
13
+ * ```html
14
+ * <nile-widget-viewer></nile-widget-viewer>
15
+ * ```
16
+ * ```js
17
+ * el.config = {
18
+ * type: 'chart',
19
+ * layout: { x: 0, y: 0, w: 6, h: 4 },
20
+ * nileConfig: { chart: { type: 'pie', data: [...] }, aq: { chartTitle: 'My Chart' } }
21
+ * };
22
+ * ```
23
+ */
24
+ let NileWidgetViewer = class NileWidgetViewer extends NileElement {
25
+ constructor() {
26
+ super(...arguments);
27
+ /** Widget configuration. Discriminated on `type`: `'chart'` or `'kpi'`. */
28
+ this.config = null;
29
+ }
30
+ render() {
31
+ if (!this.config)
32
+ return nothing;
33
+ if (this.config.type === 'chart') {
34
+ return html `<nile-chart .config=${this.config.nileConfig}></nile-chart>`;
35
+ }
36
+ if (this.config.type === 'kpi') {
37
+ return html `<nile-kpi-chart .config=${this.config.nileConfig}></nile-kpi-chart>`;
38
+ }
39
+ return nothing;
40
+ }
41
+ };
42
+ NileWidgetViewer.styles = styles;
43
+ __decorate([
44
+ property({ type: Object })
45
+ ], NileWidgetViewer.prototype, "config", void 0);
46
+ NileWidgetViewer = __decorate([
47
+ customElement('nile-widget-viewer')
48
+ ], NileWidgetViewer);
49
+ export { NileWidgetViewer };
50
+ //# sourceMappingURL=nile-widget-viewer.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aquera/nile-visualization",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "A visualization Library for the Nile Design System",
5
5
  "license": "MIT",
6
6
  "author": "Aquera Inc",
@@ -40,7 +40,9 @@
40
40
  "./nile-ai-sender": "./dist/src/nile-ai-sender/index.js",
41
41
  "./nile-ai-panel": "./dist/src/nile-ai-panel/index.js",
42
42
  "./nile-kpi-chart": "./dist/src/nile-kpi-chart/index.js",
43
- "./nile-chart": "./dist/src/nile-chart/index.js"
43
+ "./nile-chart": "./dist/src/nile-chart/index.js",
44
+ "./nile-widget-viewer": "./dist/src/nile-widget-viewer/index.js",
45
+ "./nile-dashboard-viewer": "./dist/src/nile-dashboard-viewer/index.js"
44
46
  },
45
47
  "files": [
46
48
  "dist/src/**/*.js",