@aquera/nile-visualization 0.3.0 → 0.4.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 (43) hide show
  1. package/dist/src/index.d.ts +7 -1
  2. package/dist/src/index.js +3 -0
  3. package/dist/src/internal/chart-adapters.js +86 -0
  4. package/dist/src/internal/highcharts-provider.js +27 -0
  5. package/dist/src/internal/types/all-chart-config.type.d.ts +2 -4
  6. package/dist/src/internal/types/chart-config.type.d.ts +3 -2
  7. package/dist/src/internal/types/chart-donut-config.type.d.ts +2 -0
  8. package/dist/src/internal/types/chart-heatmap-config.type.d.ts +19 -0
  9. package/dist/src/internal/types/chart-heatmap-config.type.js +2 -0
  10. package/dist/src/internal/types/chart-line-column-config.type.d.ts +14 -0
  11. package/dist/src/internal/types/chart-line-column-config.type.js +2 -0
  12. package/dist/src/internal/types/chart-organization-config.type.d.ts +13 -0
  13. package/dist/src/internal/types/chart-organization-config.type.js +2 -0
  14. package/dist/src/internal/types/index.d.ts +3 -0
  15. package/dist/src/internal/types/primitive-chart-config.type.d.ts +4 -1
  16. package/dist/src/nile-bellcurve-chart/nile-bellcurve-chart.js +3 -1
  17. package/dist/src/nile-chart/index.d.ts +1 -1
  18. package/dist/src/nile-chart/nile-chart-config.d.ts +36 -96
  19. package/dist/src/nile-chart/nile-chart.css.js +1 -1
  20. package/dist/src/nile-chart/nile-chart.d.ts +36 -0
  21. package/dist/src/nile-chart/nile-chart.js +412 -5
  22. package/dist/src/nile-donut-chart/nile-donut-chart.d.ts +2 -0
  23. package/dist/src/nile-donut-chart/nile-donut-chart.js +16 -1
  24. package/dist/src/nile-heatmap-chart/index.d.ts +2 -0
  25. package/dist/src/nile-heatmap-chart/index.js +2 -0
  26. package/dist/src/nile-heatmap-chart/nile-heatmap-chart.css.d.ts +1 -0
  27. package/dist/src/nile-heatmap-chart/nile-heatmap-chart.css.js +28 -0
  28. package/dist/src/nile-heatmap-chart/nile-heatmap-chart.d.ts +49 -0
  29. package/dist/src/nile-heatmap-chart/nile-heatmap-chart.js +259 -0
  30. package/dist/src/nile-histogram-chart/nile-histogram-chart.js +3 -1
  31. package/dist/src/nile-line-column-chart/index.d.ts +2 -0
  32. package/dist/src/nile-line-column-chart/index.js +2 -0
  33. package/dist/src/nile-line-column-chart/nile-line-column-chart.css.d.ts +1 -0
  34. package/dist/src/nile-line-column-chart/nile-line-column-chart.css.js +28 -0
  35. package/dist/src/nile-line-column-chart/nile-line-column-chart.d.ts +42 -0
  36. package/dist/src/nile-line-column-chart/nile-line-column-chart.js +205 -0
  37. package/dist/src/nile-organization-chart/index.d.ts +2 -0
  38. package/dist/src/nile-organization-chart/index.js +2 -0
  39. package/dist/src/nile-organization-chart/nile-organization-chart.css.d.ts +1 -0
  40. package/dist/src/nile-organization-chart/nile-organization-chart.css.js +28 -0
  41. package/dist/src/nile-organization-chart/nile-organization-chart.d.ts +57 -0
  42. package/dist/src/nile-organization-chart/nile-organization-chart.js +206 -0
  43. package/package.json +4 -1
@@ -0,0 +1,206 @@
1
+ import { __decorate } from "tslib";
2
+ import { customElement, property, query } from 'lit/decorators.js';
3
+ import { html } from 'lit';
4
+ import { getHighcharts } from '../internal/highcharts-provider.js';
5
+ import NileElement from '../internal/nile-element.js';
6
+ import { applySeparatedChartConfig } from '../internal/separated-chart-config.js';
7
+ import { deepMerge } from '../internal/utils.js';
8
+ import { styles } from './nile-organization-chart.css.js';
9
+ let NileOrganizationChart = class NileOrganizationChart extends NileElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this._hc = null;
13
+ this.chart = null;
14
+ this.resizeObserver = null;
15
+ /** Full chart configuration. Accepts separated `{ chart, aq }` input. */
16
+ this.config = null;
17
+ this.chartTitle = '';
18
+ this.chartSubtitle = '';
19
+ this.nodes = [];
20
+ this.links = [];
21
+ this.options = {};
22
+ this.loading = false;
23
+ this.height = '480px';
24
+ this.seriesName = '';
25
+ /**
26
+ * When true (default), the chart flows top-down — typical for org charts in Highcharts.
27
+ * Set false for a horizontal layout.
28
+ */
29
+ this.inverted = true;
30
+ }
31
+ applyConfig(cfg) {
32
+ applySeparatedChartConfig(this, cfg);
33
+ }
34
+ connectedCallback() {
35
+ super.connectedCallback();
36
+ if (this.config)
37
+ this.applyConfig(this.config);
38
+ }
39
+ disconnectedCallback() {
40
+ super.disconnectedCallback();
41
+ this.destroyChart();
42
+ this.resizeObserver?.disconnect();
43
+ this.resizeObserver = null;
44
+ }
45
+ firstUpdated() {
46
+ this.initChart();
47
+ this.setupResizeObserver();
48
+ }
49
+ updated(changedProperties) {
50
+ if (changedProperties.has('config') && this.config) {
51
+ this.applyConfig(this.config);
52
+ return;
53
+ }
54
+ const props = [
55
+ 'nodes',
56
+ 'links',
57
+ 'chartTitle',
58
+ 'chartSubtitle',
59
+ 'options',
60
+ 'height',
61
+ 'seriesName',
62
+ 'inverted',
63
+ 'loading',
64
+ ];
65
+ if (!props.some(p => changedProperties.has(p)))
66
+ return;
67
+ if (this.loading) {
68
+ this.destroyChart();
69
+ return;
70
+ }
71
+ if (this.chart) {
72
+ this.chart.update(this.buildOptions(), true, true);
73
+ }
74
+ else {
75
+ this.initChart();
76
+ }
77
+ }
78
+ setupResizeObserver() {
79
+ if (!this.chartContainer)
80
+ return;
81
+ this.resizeObserver = new ResizeObserver(() => {
82
+ this.chart?.reflow();
83
+ });
84
+ this.resizeObserver.observe(this.chartContainer);
85
+ }
86
+ buildOptions() {
87
+ const self = this;
88
+ const data = this.links.map(l => [l.from, l.to]);
89
+ const nodeOpts = this.nodes.map(n => {
90
+ const { id, title, name, description, image, color, layout } = n;
91
+ return {
92
+ id,
93
+ title,
94
+ name,
95
+ description,
96
+ image,
97
+ color,
98
+ ...(layout ? { layout } : {}),
99
+ };
100
+ });
101
+ return deepMerge({
102
+ chart: {
103
+ height: this.height,
104
+ inverted: this.inverted,
105
+ },
106
+ title: { text: this.chartTitle || undefined },
107
+ subtitle: { text: this.chartSubtitle || undefined },
108
+ tooltip: {
109
+ outside: true,
110
+ },
111
+ plotOptions: {
112
+ organization: {
113
+ dataLabels: {
114
+ color: '#1e293b',
115
+ },
116
+ },
117
+ series: {
118
+ cursor: 'pointer',
119
+ point: {
120
+ events: {
121
+ click() {
122
+ const fromN = this.fromNode;
123
+ const toN = this.toNode;
124
+ self.emit('nile-chart-click', {
125
+ point: this,
126
+ fromId: fromN?.id,
127
+ toId: toN?.id,
128
+ seriesName: this.series.name,
129
+ });
130
+ },
131
+ },
132
+ },
133
+ },
134
+ },
135
+ series: [
136
+ {
137
+ type: 'organization',
138
+ name: this.seriesName || this.chartTitle || 'Organization',
139
+ keys: ['from', 'to'],
140
+ data,
141
+ nodes: nodeOpts,
142
+ },
143
+ ],
144
+ credits: { enabled: false },
145
+ }, this.options);
146
+ }
147
+ async initChart() {
148
+ if (this.loading || !this.chartContainer)
149
+ return;
150
+ if (!this._hc)
151
+ this._hc = await getHighcharts();
152
+ this.chart = this._hc.chart(this.chartContainer, this.buildOptions());
153
+ this.emit('nile-chart-ready', { chart: this.chart });
154
+ }
155
+ destroyChart() {
156
+ if (this.chart) {
157
+ this.chart.destroy();
158
+ this.chart = null;
159
+ }
160
+ }
161
+ render() {
162
+ if (this.loading) {
163
+ return html `<div class="chart-loading" style="height:${this.height}">Loading...</div>`;
164
+ }
165
+ return html `<div class="chart-container"></div>`;
166
+ }
167
+ };
168
+ NileOrganizationChart.styles = styles;
169
+ __decorate([
170
+ query('.chart-container')
171
+ ], NileOrganizationChart.prototype, "chartContainer", void 0);
172
+ __decorate([
173
+ property({ type: Object })
174
+ ], NileOrganizationChart.prototype, "config", void 0);
175
+ __decorate([
176
+ property({ type: String, attribute: 'chart-title' })
177
+ ], NileOrganizationChart.prototype, "chartTitle", void 0);
178
+ __decorate([
179
+ property({ type: String, attribute: 'chart-subtitle' })
180
+ ], NileOrganizationChart.prototype, "chartSubtitle", void 0);
181
+ __decorate([
182
+ property({ type: Array })
183
+ ], NileOrganizationChart.prototype, "nodes", void 0);
184
+ __decorate([
185
+ property({ type: Array })
186
+ ], NileOrganizationChart.prototype, "links", void 0);
187
+ __decorate([
188
+ property({ type: Object })
189
+ ], NileOrganizationChart.prototype, "options", void 0);
190
+ __decorate([
191
+ property({ type: Boolean, reflect: true })
192
+ ], NileOrganizationChart.prototype, "loading", void 0);
193
+ __decorate([
194
+ property({ type: String })
195
+ ], NileOrganizationChart.prototype, "height", void 0);
196
+ __decorate([
197
+ property({ type: String, attribute: 'series-name' })
198
+ ], NileOrganizationChart.prototype, "seriesName", void 0);
199
+ __decorate([
200
+ property({ type: Boolean, attribute: 'inverted' })
201
+ ], NileOrganizationChart.prototype, "inverted", void 0);
202
+ NileOrganizationChart = __decorate([
203
+ customElement('nile-organization-chart')
204
+ ], NileOrganizationChart);
205
+ export { NileOrganizationChart };
206
+ //# sourceMappingURL=nile-organization-chart.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aquera/nile-visualization",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "A visualization Library for the Nile Design System",
5
5
  "license": "MIT",
6
6
  "author": "Aquera Inc",
@@ -30,6 +30,9 @@
30
30
  "./nile-gauge-chart": "./dist/src/nile-gauge-chart/index.js",
31
31
  "./nile-waterfall-chart": "./dist/src/nile-waterfall-chart/index.js",
32
32
  "./nile-funnel-chart": "./dist/src/nile-funnel-chart/index.js",
33
+ "./nile-organization-chart": "./dist/src/nile-organization-chart/index.js",
34
+ "./nile-line-column-chart": "./dist/src/nile-line-column-chart/index.js",
35
+ "./nile-heatmap-chart": "./dist/src/nile-heatmap-chart/index.js",
33
36
  "./nile-flame-chart": "./dist/src/nile-flame-chart/index.js",
34
37
  "./nile-spiderweb-chart": "./dist/src/nile-spiderweb-chart/index.js",
35
38
  "./nile-trendline-chart": "./dist/src/nile-trendline-chart/index.js",