@aquera/nile-visualization 0.1.0 → 0.2.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 (188) hide show
  1. package/dist/src/index.d.ts +27 -2
  2. package/dist/src/index.js +15 -0
  3. package/dist/src/internal/highcharts-provider.js +45 -0
  4. package/dist/src/internal/separated-chart-config.d.ts +5 -0
  5. package/dist/src/internal/separated-chart-config.js +16 -0
  6. package/dist/src/internal/types/ai-config.type.d.ts +9 -0
  7. package/dist/src/internal/types/ai-config.type.js +2 -0
  8. package/dist/src/internal/types/all-chart-config.type.d.ts +8 -0
  9. package/dist/src/internal/types/all-chart-config.type.js +2 -0
  10. package/dist/src/internal/types/aq-config.type.d.ts +13 -0
  11. package/dist/src/internal/types/aq-config.type.js +2 -0
  12. package/dist/src/internal/types/chart-anomaly-config.type.d.ts +13 -0
  13. package/dist/src/internal/types/chart-anomaly-config.type.js +2 -0
  14. package/dist/src/internal/types/chart-area-config.type.d.ts +13 -0
  15. package/dist/src/internal/types/chart-area-config.type.js +2 -0
  16. package/dist/src/internal/types/chart-bar-config.type.d.ts +12 -0
  17. package/dist/src/internal/types/chart-bar-config.type.js +2 -0
  18. package/dist/src/internal/types/chart-bellcurve-config.type.d.ts +19 -0
  19. package/dist/src/internal/types/chart-bellcurve-config.type.js +2 -0
  20. package/dist/src/internal/types/chart-boxplot-config.type.d.ts +15 -0
  21. package/dist/src/internal/types/chart-boxplot-config.type.js +2 -0
  22. package/dist/src/internal/types/chart-bubble-config.type.d.ts +12 -0
  23. package/dist/src/internal/types/chart-bubble-config.type.js +2 -0
  24. package/dist/src/internal/types/chart-cluster-config.type.d.ts +15 -0
  25. package/dist/src/internal/types/chart-cluster-config.type.js +2 -0
  26. package/dist/src/internal/types/chart-column-config.type.d.ts +12 -0
  27. package/dist/src/internal/types/chart-column-config.type.js +2 -0
  28. package/dist/src/internal/types/chart-config.type.d.ts +16 -0
  29. package/dist/src/internal/types/chart-config.type.js +2 -0
  30. package/dist/src/internal/types/chart-donut-config.type.d.ts +14 -0
  31. package/dist/src/internal/types/chart-donut-config.type.js +2 -0
  32. package/dist/src/internal/types/chart-dumbbell-config.type.d.ts +16 -0
  33. package/dist/src/internal/types/chart-dumbbell-config.type.js +2 -0
  34. package/dist/src/internal/types/chart-fan-config.type.d.ts +17 -0
  35. package/dist/src/internal/types/chart-fan-config.type.js +2 -0
  36. package/dist/src/internal/types/chart-flame-config.type.d.ts +14 -0
  37. package/dist/src/internal/types/chart-flame-config.type.js +2 -0
  38. package/dist/src/internal/types/chart-funnel-config.type.d.ts +12 -0
  39. package/dist/src/internal/types/chart-funnel-config.type.js +2 -0
  40. package/dist/src/internal/types/chart-gauge-config.type.d.ts +14 -0
  41. package/dist/src/internal/types/chart-gauge-config.type.js +2 -0
  42. package/dist/src/internal/types/chart-histogram-config.type.d.ts +19 -0
  43. package/dist/src/internal/types/chart-histogram-config.type.js +2 -0
  44. package/dist/src/internal/types/chart-kpi-config.type.d.ts +21 -0
  45. package/dist/src/internal/types/chart-kpi-config.type.js +2 -0
  46. package/dist/src/internal/types/chart-line-config.type.d.ts +12 -0
  47. package/dist/src/internal/types/chart-line-config.type.js +2 -0
  48. package/dist/src/internal/types/chart-pie-config.type.d.ts +13 -0
  49. package/dist/src/internal/types/chart-pie-config.type.js +2 -0
  50. package/dist/src/internal/types/chart-radar-config.type.d.ts +12 -0
  51. package/dist/src/internal/types/chart-radar-config.type.js +2 -0
  52. package/dist/src/internal/types/chart-scatter-config.type.d.ts +12 -0
  53. package/dist/src/internal/types/chart-scatter-config.type.js +2 -0
  54. package/dist/src/internal/types/chart-spiderweb-config.type.d.ts +12 -0
  55. package/dist/src/internal/types/chart-spiderweb-config.type.js +2 -0
  56. package/dist/src/internal/types/chart-spline-config.type.d.ts +12 -0
  57. package/dist/src/internal/types/chart-spline-config.type.js +2 -0
  58. package/dist/src/internal/types/chart-stacked-config.type.d.ts +15 -0
  59. package/dist/src/internal/types/chart-stacked-config.type.js +2 -0
  60. package/dist/src/internal/types/chart-timeline-config.type.d.ts +15 -0
  61. package/dist/src/internal/types/chart-timeline-config.type.js +2 -0
  62. package/dist/src/internal/types/chart-trendline-config.type.d.ts +13 -0
  63. package/dist/src/internal/types/chart-trendline-config.type.js +2 -0
  64. package/dist/src/internal/types/chart-waterfall-config.type.d.ts +11 -0
  65. package/dist/src/internal/types/chart-waterfall-config.type.js +2 -0
  66. package/dist/src/internal/types/index.d.ts +35 -0
  67. package/dist/src/internal/types/index.js +2 -0
  68. package/dist/src/internal/types/nile-ai-widgets-config-input.type.d.ts +23 -0
  69. package/dist/src/internal/types/nile-ai-widgets-config-input.type.js +2 -0
  70. package/dist/src/internal/types/nile-chart-config-input.type.d.ts +7 -0
  71. package/dist/src/internal/types/nile-chart-config-input.type.js +2 -0
  72. package/dist/src/internal/types/primitive-chart-config.type.d.ts +16 -0
  73. package/dist/src/internal/types/primitive-chart-config.type.js +2 -0
  74. package/dist/src/internal/types/separated-chart-config-input.type.d.ts +7 -0
  75. package/dist/src/internal/types/separated-chart-config-input.type.js +2 -0
  76. package/dist/src/internal/types/switchable-config.type.d.ts +8 -0
  77. package/dist/src/internal/types/switchable-config.type.js +2 -0
  78. package/dist/src/nile-ai-panel/index.d.ts +1 -0
  79. package/dist/src/nile-ai-panel/nile-ai-panel.d.ts +8 -1
  80. package/dist/src/nile-ai-panel/nile-ai-panel.js +34 -0
  81. package/dist/src/nile-ai-sender/index.d.ts +1 -0
  82. package/dist/src/nile-ai-sender/nile-ai-sender.d.ts +8 -1
  83. package/dist/src/nile-ai-sender/nile-ai-sender.js +30 -0
  84. package/dist/src/nile-anomaly-chart/nile-anomaly-chart.d.ts +6 -0
  85. package/dist/src/nile-anomaly-chart/nile-anomaly-chart.js +41 -0
  86. package/dist/src/nile-area-chart/nile-area-chart.d.ts +6 -0
  87. package/dist/src/nile-area-chart/nile-area-chart.js +41 -0
  88. package/dist/src/nile-bar-chart/nile-bar-chart.d.ts +6 -0
  89. package/dist/src/nile-bar-chart/nile-bar-chart.js +40 -1
  90. package/dist/src/nile-bellcurve-chart/index.d.ts +2 -0
  91. package/dist/src/nile-bellcurve-chart/index.js +2 -0
  92. package/dist/src/nile-bellcurve-chart/nile-bellcurve-chart.css.d.ts +1 -0
  93. package/dist/src/nile-bellcurve-chart/nile-bellcurve-chart.css.js +28 -0
  94. package/dist/src/nile-bellcurve-chart/nile-bellcurve-chart.d.ts +49 -0
  95. package/dist/src/nile-bellcurve-chart/nile-bellcurve-chart.js +258 -0
  96. package/dist/src/nile-boxplot-chart/index.d.ts +2 -0
  97. package/dist/src/nile-boxplot-chart/index.js +2 -0
  98. package/dist/src/nile-boxplot-chart/nile-boxplot-chart.css.d.ts +1 -0
  99. package/dist/src/nile-boxplot-chart/nile-boxplot-chart.css.js +28 -0
  100. package/dist/src/nile-boxplot-chart/nile-boxplot-chart.d.ts +58 -0
  101. package/dist/src/nile-boxplot-chart/nile-boxplot-chart.js +235 -0
  102. package/dist/src/nile-bubble-chart/nile-bubble-chart.d.ts +6 -0
  103. package/dist/src/nile-bubble-chart/nile-bubble-chart.js +39 -0
  104. package/dist/src/nile-chart/index.d.ts +3 -1
  105. package/dist/src/nile-chart/index.js +1 -0
  106. package/dist/src/nile-chart/nile-chart-config-builder.d.ts +4 -0
  107. package/dist/src/nile-chart/nile-chart-config-builder.js +13 -0
  108. package/dist/src/nile-chart/nile-chart-config.d.ts +76 -2
  109. package/dist/src/nile-chart/nile-chart.d.ts +16 -2
  110. package/dist/src/nile-chart/nile-chart.js +144 -14
  111. package/dist/src/nile-cluster-chart/index.d.ts +2 -0
  112. package/dist/src/nile-cluster-chart/index.js +2 -0
  113. package/dist/src/nile-cluster-chart/nile-cluster-chart.css.d.ts +1 -0
  114. package/dist/src/nile-cluster-chart/nile-cluster-chart.css.js +28 -0
  115. package/dist/src/nile-cluster-chart/nile-cluster-chart.d.ts +46 -0
  116. package/dist/src/nile-cluster-chart/nile-cluster-chart.js +196 -0
  117. package/dist/src/nile-column-chart/nile-column-chart.d.ts +6 -0
  118. package/dist/src/nile-column-chart/nile-column-chart.js +39 -0
  119. package/dist/src/nile-donut-chart/nile-donut-chart.d.ts +6 -0
  120. package/dist/src/nile-donut-chart/nile-donut-chart.js +43 -0
  121. package/dist/src/nile-dumbbell-chart/index.d.ts +2 -0
  122. package/dist/src/nile-dumbbell-chart/index.js +2 -0
  123. package/dist/src/nile-dumbbell-chart/nile-dumbbell-chart.css.d.ts +1 -0
  124. package/dist/src/nile-dumbbell-chart/nile-dumbbell-chart.css.js +28 -0
  125. package/dist/src/nile-dumbbell-chart/nile-dumbbell-chart.d.ts +50 -0
  126. package/dist/src/nile-dumbbell-chart/nile-dumbbell-chart.js +217 -0
  127. package/dist/src/nile-fan-chart/index.d.ts +2 -0
  128. package/dist/src/nile-fan-chart/index.js +2 -0
  129. package/dist/src/nile-fan-chart/nile-fan-chart.css.d.ts +1 -0
  130. package/dist/src/nile-fan-chart/nile-fan-chart.css.js +28 -0
  131. package/dist/src/nile-fan-chart/nile-fan-chart.d.ts +65 -0
  132. package/dist/src/nile-fan-chart/nile-fan-chart.js +257 -0
  133. package/dist/src/nile-flame-chart/index.d.ts +2 -0
  134. package/dist/src/nile-flame-chart/index.js +2 -0
  135. package/dist/src/nile-flame-chart/nile-flame-chart.css.d.ts +1 -0
  136. package/dist/src/nile-flame-chart/nile-flame-chart.css.js +28 -0
  137. package/dist/src/nile-flame-chart/nile-flame-chart.d.ts +60 -0
  138. package/dist/src/nile-flame-chart/nile-flame-chart.js +311 -0
  139. package/dist/src/nile-funnel-chart/index.d.ts +2 -0
  140. package/dist/src/nile-funnel-chart/index.js +2 -0
  141. package/dist/src/nile-funnel-chart/nile-funnel-chart.css.d.ts +1 -0
  142. package/dist/src/nile-funnel-chart/nile-funnel-chart.css.js +28 -0
  143. package/dist/src/nile-funnel-chart/nile-funnel-chart.d.ts +42 -0
  144. package/dist/src/nile-funnel-chart/nile-funnel-chart.js +189 -0
  145. package/dist/src/nile-gauge-chart/nile-gauge-chart.d.ts +6 -0
  146. package/dist/src/nile-gauge-chart/nile-gauge-chart.js +43 -0
  147. package/dist/src/nile-histogram-chart/index.d.ts +2 -0
  148. package/dist/src/nile-histogram-chart/index.js +2 -0
  149. package/dist/src/nile-histogram-chart/nile-histogram-chart.css.d.ts +1 -0
  150. package/dist/src/nile-histogram-chart/nile-histogram-chart.css.js +28 -0
  151. package/dist/src/nile-histogram-chart/nile-histogram-chart.d.ts +53 -0
  152. package/dist/src/nile-histogram-chart/nile-histogram-chart.js +263 -0
  153. package/dist/src/nile-kpi-chart/index.d.ts +1 -1
  154. package/dist/src/nile-kpi-chart/nile-kpi-chart.d.ts +32 -0
  155. package/dist/src/nile-kpi-chart/nile-kpi-chart.js +60 -0
  156. package/dist/src/nile-line-chart/nile-line-chart.d.ts +6 -0
  157. package/dist/src/nile-line-chart/nile-line-chart.js +39 -0
  158. package/dist/src/nile-pie-chart/nile-pie-chart.d.ts +6 -0
  159. package/dist/src/nile-pie-chart/nile-pie-chart.js +41 -0
  160. package/dist/src/nile-radar-chart/nile-radar-chart.d.ts +6 -0
  161. package/dist/src/nile-radar-chart/nile-radar-chart.js +39 -0
  162. package/dist/src/nile-scatter-chart/nile-scatter-chart.d.ts +6 -0
  163. package/dist/src/nile-scatter-chart/nile-scatter-chart.js +39 -0
  164. package/dist/src/nile-spiderweb-chart/index.d.ts +2 -0
  165. package/dist/src/nile-spiderweb-chart/index.js +2 -0
  166. package/dist/src/nile-spiderweb-chart/nile-spiderweb-chart.css.d.ts +1 -0
  167. package/dist/src/nile-spiderweb-chart/nile-spiderweb-chart.css.js +28 -0
  168. package/dist/src/nile-spiderweb-chart/nile-spiderweb-chart.d.ts +46 -0
  169. package/dist/src/nile-spiderweb-chart/nile-spiderweb-chart.js +191 -0
  170. package/dist/src/nile-spline-chart/nile-spline-chart.d.ts +6 -0
  171. package/dist/src/nile-spline-chart/nile-spline-chart.js +39 -0
  172. package/dist/src/nile-stacked-chart/index.d.ts +2 -0
  173. package/dist/src/nile-stacked-chart/index.js +2 -0
  174. package/dist/src/nile-stacked-chart/nile-stacked-chart.css.d.ts +1 -0
  175. package/dist/src/nile-stacked-chart/nile-stacked-chart.css.js +28 -0
  176. package/dist/src/nile-stacked-chart/nile-stacked-chart.d.ts +47 -0
  177. package/dist/src/nile-stacked-chart/nile-stacked-chart.js +216 -0
  178. package/dist/src/nile-timeline-chart/index.d.ts +2 -0
  179. package/dist/src/nile-timeline-chart/index.js +2 -0
  180. package/dist/src/nile-timeline-chart/nile-timeline-chart.css.d.ts +1 -0
  181. package/dist/src/nile-timeline-chart/nile-timeline-chart.css.js +28 -0
  182. package/dist/src/nile-timeline-chart/nile-timeline-chart.d.ts +58 -0
  183. package/dist/src/nile-timeline-chart/nile-timeline-chart.js +239 -0
  184. package/dist/src/nile-trendline-chart/nile-trendline-chart.d.ts +6 -0
  185. package/dist/src/nile-trendline-chart/nile-trendline-chart.js +41 -0
  186. package/dist/src/nile-waterfall-chart/nile-waterfall-chart.d.ts +6 -0
  187. package/dist/src/nile-waterfall-chart/nile-waterfall-chart.js +37 -0
  188. package/package.json +12 -1
@@ -0,0 +1,216 @@
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-stacked-chart.css.js';
9
+ let NileStackedChart = class NileStackedChart 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.data = [];
20
+ this.categories = [];
21
+ this.options = {};
22
+ this.loading = false;
23
+ this.height = '400px';
24
+ this.yAxisTitle = '';
25
+ this.showLegend = true;
26
+ /** `normal` = stacked values; `percent` = 100% proportional stacks. */
27
+ this.stackMode = 'normal';
28
+ this.pointPadding = 0.05;
29
+ }
30
+ /** Apply `{ chart, aq }` config to individual properties. */
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
+ 'data',
56
+ 'categories',
57
+ 'chartTitle',
58
+ 'chartSubtitle',
59
+ 'options',
60
+ 'height',
61
+ 'yAxisTitle',
62
+ 'loading',
63
+ 'showLegend',
64
+ 'stackMode',
65
+ 'pointPadding',
66
+ ];
67
+ if (!props.some(p => changedProperties.has(p)))
68
+ return;
69
+ if (this.loading) {
70
+ this.destroyChart();
71
+ return;
72
+ }
73
+ if (this.chart) {
74
+ this.chart.update(this.buildOptions(), true, true);
75
+ }
76
+ else {
77
+ this.initChart();
78
+ }
79
+ }
80
+ setupResizeObserver() {
81
+ if (!this.chartContainer)
82
+ return;
83
+ this.resizeObserver = new ResizeObserver(() => {
84
+ this.chart?.reflow();
85
+ });
86
+ this.resizeObserver.observe(this.chartContainer);
87
+ }
88
+ stacking() {
89
+ return this.stackMode === 'percent' ? 'percent' : 'normal';
90
+ }
91
+ buildOptions() {
92
+ const self = this;
93
+ const stack = this.stacking();
94
+ const percentAxis = stack === 'percent'
95
+ ? {
96
+ min: 0,
97
+ max: 100,
98
+ title: { text: this.yAxisTitle || undefined },
99
+ labels: { format: '{value}%' },
100
+ }
101
+ : {
102
+ min: 0,
103
+ title: { text: this.yAxisTitle || undefined },
104
+ };
105
+ return deepMerge({
106
+ chart: { type: 'column', height: this.height },
107
+ title: { text: this.chartTitle || undefined },
108
+ subtitle: { text: this.chartSubtitle || undefined },
109
+ xAxis: { categories: this.categories },
110
+ yAxis: percentAxis,
111
+ legend: { enabled: this.showLegend },
112
+ tooltip: {
113
+ shared: true,
114
+ headerFormat: '<b>{point.key}</b><br/>',
115
+ },
116
+ plotOptions: {
117
+ column: {
118
+ stacking: stack,
119
+ grouping: false,
120
+ pointPadding: this.pointPadding,
121
+ borderWidth: 0,
122
+ borderRadius: 2,
123
+ dataLabels: { enabled: false },
124
+ },
125
+ series: {
126
+ cursor: 'pointer',
127
+ point: {
128
+ events: {
129
+ click() {
130
+ self.emit('nile-chart-click', {
131
+ point: this,
132
+ category: this.category,
133
+ value: this.y,
134
+ seriesName: this.series.name,
135
+ percentage: this.percentage,
136
+ });
137
+ },
138
+ },
139
+ },
140
+ },
141
+ },
142
+ series: this.data.map(s => ({
143
+ type: 'column',
144
+ name: s.name,
145
+ data: s.data,
146
+ color: s.color,
147
+ })),
148
+ credits: { enabled: false },
149
+ }, this.options);
150
+ }
151
+ async initChart() {
152
+ if (this.loading || !this.chartContainer)
153
+ return;
154
+ if (!this._hc)
155
+ this._hc = await getHighcharts();
156
+ this.chart = this._hc.chart(this.chartContainer, this.buildOptions());
157
+ this.emit('nile-chart-ready', { chart: this.chart });
158
+ }
159
+ destroyChart() {
160
+ if (this.chart) {
161
+ this.chart.destroy();
162
+ this.chart = null;
163
+ }
164
+ }
165
+ render() {
166
+ if (this.loading) {
167
+ return html `<div class="chart-loading" style="height:${this.height}">Loading...</div>`;
168
+ }
169
+ return html `<div class="chart-container"></div>`;
170
+ }
171
+ };
172
+ NileStackedChart.styles = styles;
173
+ __decorate([
174
+ query('.chart-container')
175
+ ], NileStackedChart.prototype, "chartContainer", void 0);
176
+ __decorate([
177
+ property({ type: Object })
178
+ ], NileStackedChart.prototype, "config", void 0);
179
+ __decorate([
180
+ property({ type: String, attribute: 'chart-title' })
181
+ ], NileStackedChart.prototype, "chartTitle", void 0);
182
+ __decorate([
183
+ property({ type: String, attribute: 'chart-subtitle' })
184
+ ], NileStackedChart.prototype, "chartSubtitle", void 0);
185
+ __decorate([
186
+ property({ type: Array })
187
+ ], NileStackedChart.prototype, "data", void 0);
188
+ __decorate([
189
+ property({ type: Array })
190
+ ], NileStackedChart.prototype, "categories", void 0);
191
+ __decorate([
192
+ property({ type: Object })
193
+ ], NileStackedChart.prototype, "options", void 0);
194
+ __decorate([
195
+ property({ type: Boolean, reflect: true })
196
+ ], NileStackedChart.prototype, "loading", void 0);
197
+ __decorate([
198
+ property({ type: String })
199
+ ], NileStackedChart.prototype, "height", void 0);
200
+ __decorate([
201
+ property({ type: String, attribute: 'y-axis-title' })
202
+ ], NileStackedChart.prototype, "yAxisTitle", void 0);
203
+ __decorate([
204
+ property({ type: Boolean, attribute: 'show-legend' })
205
+ ], NileStackedChart.prototype, "showLegend", void 0);
206
+ __decorate([
207
+ property({ type: String, attribute: 'stack-mode' })
208
+ ], NileStackedChart.prototype, "stackMode", void 0);
209
+ __decorate([
210
+ property({ type: Number, attribute: 'point-padding' })
211
+ ], NileStackedChart.prototype, "pointPadding", void 0);
212
+ NileStackedChart = __decorate([
213
+ customElement('nile-stacked-chart')
214
+ ], NileStackedChart);
215
+ export { NileStackedChart };
216
+ //# sourceMappingURL=nile-stacked-chart.js.map
@@ -0,0 +1,2 @@
1
+ export { NileTimelineChart } from './nile-timeline-chart.js';
2
+ export type { TimelineEvent } from './nile-timeline-chart.js';
@@ -0,0 +1,2 @@
1
+ export { NileTimelineChart } from './nile-timeline-chart.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,28 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `
3
+ :host {
4
+ display: block;
5
+ width: 100%;
6
+ position: relative;
7
+ }
8
+
9
+ :host([hidden]) {
10
+ display: none;
11
+ }
12
+
13
+ .chart-container {
14
+ width: 100%;
15
+ min-height: var(--nile-height-200px, var(--ng-height-200px));
16
+ }
17
+
18
+ .chart-loading {
19
+ display: flex;
20
+ align-items: center;
21
+ justify-content: center;
22
+ min-height: inherit;
23
+ color: var(--nile-colors-neutral-700, var(--ng-colors-text-secondary-700));
24
+ font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
25
+ font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
26
+ }
27
+ `;
28
+ //# sourceMappingURL=nile-timeline-chart.css.js.map
@@ -0,0 +1,58 @@
1
+ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
2
+ import type Highcharts from 'highcharts';
3
+ import NileElement from '../internal/nile-element.js';
4
+ import type { SeparatedChartConfigInputType } from '../internal/types/separated-chart-config-input.type.js';
5
+ export interface TimelineEvent {
6
+ /** Shown on axis / tooltip header (e.g. date string). */
7
+ name: string;
8
+ /** Short label on the timeline. */
9
+ label: string;
10
+ /** Longer copy; tooltip uses this by default. */
11
+ description?: string;
12
+ /** Unix timestamp (ms) when `datetime-axis` is true; omit for evenly spaced events. */
13
+ x?: number;
14
+ color?: string;
15
+ }
16
+ export declare class NileTimelineChart extends NileElement {
17
+ static styles: CSSResultGroup;
18
+ private _hc;
19
+ private chart;
20
+ private resizeObserver;
21
+ private chartContainer;
22
+ /** Full chart configuration. Accepts separated `{ chart, aq }` input. */
23
+ config: SeparatedChartConfigInputType | null;
24
+ chartTitle: string;
25
+ chartSubtitle: string;
26
+ data: TimelineEvent[];
27
+ options: Highcharts.Options;
28
+ loading: boolean;
29
+ height: string;
30
+ seriesName: string;
31
+ /**
32
+ * When true (default), `x` on each event is a Unix ms timestamp and the axis is `datetime`.
33
+ * When false, events are spaced evenly (no `x` required).
34
+ */
35
+ datetimeAxis: boolean;
36
+ /** Vertical timeline (categories on the horizontal edge). */
37
+ inverted: boolean;
38
+ /** Alternate data-label sides along the line. */
39
+ alternateLabels: boolean;
40
+ showLegend: boolean;
41
+ /** Apply `{ chart, aq }` config to individual properties. */
42
+ private applyConfig;
43
+ connectedCallback(): void;
44
+ disconnectedCallback(): void;
45
+ protected firstUpdated(): void;
46
+ protected updated(changedProperties: PropertyValues): void;
47
+ private setupResizeObserver;
48
+ private mapData;
49
+ private buildOptions;
50
+ private initChart;
51
+ private destroyChart;
52
+ render(): TemplateResult;
53
+ }
54
+ declare global {
55
+ interface HTMLElementTagNameMap {
56
+ 'nile-timeline-chart': NileTimelineChart;
57
+ }
58
+ }
@@ -0,0 +1,239 @@
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-timeline-chart.css.js';
9
+ let NileTimelineChart = class NileTimelineChart 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.data = [];
20
+ this.options = {};
21
+ this.loading = false;
22
+ this.height = '420px';
23
+ this.seriesName = '';
24
+ /**
25
+ * When true (default), `x` on each event is a Unix ms timestamp and the axis is `datetime`.
26
+ * When false, events are spaced evenly (no `x` required).
27
+ */
28
+ this.datetimeAxis = true;
29
+ /** Vertical timeline (categories on the horizontal edge). */
30
+ this.inverted = false;
31
+ /** Alternate data-label sides along the line. */
32
+ this.alternateLabels = true;
33
+ this.showLegend = false;
34
+ }
35
+ /** Apply `{ chart, aq }` config to individual properties. */
36
+ applyConfig(cfg) {
37
+ applySeparatedChartConfig(this, cfg);
38
+ }
39
+ connectedCallback() {
40
+ super.connectedCallback();
41
+ if (this.config)
42
+ this.applyConfig(this.config);
43
+ }
44
+ disconnectedCallback() {
45
+ super.disconnectedCallback();
46
+ this.destroyChart();
47
+ this.resizeObserver?.disconnect();
48
+ this.resizeObserver = null;
49
+ }
50
+ firstUpdated() {
51
+ this.initChart();
52
+ this.setupResizeObserver();
53
+ }
54
+ updated(changedProperties) {
55
+ if (changedProperties.has('config') && this.config) {
56
+ this.applyConfig(this.config);
57
+ return;
58
+ }
59
+ const props = [
60
+ 'data',
61
+ 'chartTitle',
62
+ 'chartSubtitle',
63
+ 'options',
64
+ 'height',
65
+ 'seriesName',
66
+ 'datetimeAxis',
67
+ 'inverted',
68
+ 'alternateLabels',
69
+ 'showLegend',
70
+ 'loading',
71
+ ];
72
+ if (!props.some(p => changedProperties.has(p)))
73
+ return;
74
+ if (this.loading) {
75
+ this.destroyChart();
76
+ return;
77
+ }
78
+ if (this.chart) {
79
+ this.chart.update(this.buildOptions(), true, true);
80
+ }
81
+ else {
82
+ this.initChart();
83
+ }
84
+ }
85
+ setupResizeObserver() {
86
+ if (!this.chartContainer)
87
+ return;
88
+ this.resizeObserver = new ResizeObserver(() => {
89
+ this.chart?.reflow();
90
+ });
91
+ this.resizeObserver.observe(this.chartContainer);
92
+ }
93
+ mapData() {
94
+ return this.data.map(d => {
95
+ const row = {
96
+ name: d.name,
97
+ label: d.label,
98
+ description: d.description ?? d.label,
99
+ };
100
+ if (d.color)
101
+ row.color = d.color;
102
+ if (this.datetimeAxis && d.x != null)
103
+ row.x = d.x;
104
+ return row;
105
+ });
106
+ }
107
+ buildOptions() {
108
+ const self = this;
109
+ const dlFormat = this.datetimeAxis
110
+ ? '<span style="font-weight:600;color:#334155">{point.x:%e %b %Y}</span><br/>{point.label}'
111
+ : '<span style="font-weight:600;color:#334155">{point.name}</span><br/>{point.label}';
112
+ return deepMerge({
113
+ chart: {
114
+ type: 'timeline',
115
+ height: this.height,
116
+ inverted: this.inverted,
117
+ },
118
+ title: { text: this.chartTitle || undefined },
119
+ subtitle: { text: this.chartSubtitle || undefined },
120
+ legend: { enabled: this.showLegend },
121
+ tooltip: {
122
+ headerFormat: '',
123
+ pointFormat: '<span style="color:{point.color}">●</span> <b>{point.label}</b><br/>{point.description}',
124
+ },
125
+ xAxis: {
126
+ type: this.datetimeAxis ? 'datetime' : 'linear',
127
+ visible: false,
128
+ },
129
+ yAxis: {
130
+ visible: false,
131
+ title: { text: undefined },
132
+ labels: { enabled: false },
133
+ },
134
+ plotOptions: {
135
+ timeline: {
136
+ cursor: 'pointer',
137
+ dataLabels: {
138
+ allowOverlap: false,
139
+ alternate: this.alternateLabels,
140
+ format: dlFormat,
141
+ },
142
+ marker: {
143
+ symbol: 'circle',
144
+ radius: 6,
145
+ lineWidth: 2,
146
+ lineColor: '#ffffff',
147
+ },
148
+ point: {
149
+ events: {
150
+ click() {
151
+ self.emit('nile-chart-click', {
152
+ point: this,
153
+ name: this.name,
154
+ label: this.label,
155
+ description: this.description,
156
+ x: this.x,
157
+ seriesName: this.series.name,
158
+ });
159
+ },
160
+ },
161
+ },
162
+ },
163
+ },
164
+ series: [
165
+ {
166
+ type: 'timeline',
167
+ name: this.seriesName || 'Timeline',
168
+ data: this.mapData(),
169
+ },
170
+ ],
171
+ credits: { enabled: false },
172
+ }, this.options);
173
+ }
174
+ async initChart() {
175
+ if (this.loading || !this.chartContainer)
176
+ return;
177
+ if (!this._hc)
178
+ this._hc = await getHighcharts();
179
+ this.chart = this._hc.chart(this.chartContainer, this.buildOptions());
180
+ this.emit('nile-chart-ready', { chart: this.chart });
181
+ }
182
+ destroyChart() {
183
+ if (this.chart) {
184
+ this.chart.destroy();
185
+ this.chart = null;
186
+ }
187
+ }
188
+ render() {
189
+ if (this.loading) {
190
+ return html `<div class="chart-loading" style="height:${this.height}">Loading...</div>`;
191
+ }
192
+ return html `<div class="chart-container"></div>`;
193
+ }
194
+ };
195
+ NileTimelineChart.styles = styles;
196
+ __decorate([
197
+ query('.chart-container')
198
+ ], NileTimelineChart.prototype, "chartContainer", void 0);
199
+ __decorate([
200
+ property({ type: Object })
201
+ ], NileTimelineChart.prototype, "config", void 0);
202
+ __decorate([
203
+ property({ type: String, attribute: 'chart-title' })
204
+ ], NileTimelineChart.prototype, "chartTitle", void 0);
205
+ __decorate([
206
+ property({ type: String, attribute: 'chart-subtitle' })
207
+ ], NileTimelineChart.prototype, "chartSubtitle", void 0);
208
+ __decorate([
209
+ property({ type: Array })
210
+ ], NileTimelineChart.prototype, "data", void 0);
211
+ __decorate([
212
+ property({ type: Object })
213
+ ], NileTimelineChart.prototype, "options", void 0);
214
+ __decorate([
215
+ property({ type: Boolean, reflect: true })
216
+ ], NileTimelineChart.prototype, "loading", void 0);
217
+ __decorate([
218
+ property({ type: String })
219
+ ], NileTimelineChart.prototype, "height", void 0);
220
+ __decorate([
221
+ property({ type: String, attribute: 'series-name' })
222
+ ], NileTimelineChart.prototype, "seriesName", void 0);
223
+ __decorate([
224
+ property({ type: Boolean, attribute: 'datetime-axis' })
225
+ ], NileTimelineChart.prototype, "datetimeAxis", void 0);
226
+ __decorate([
227
+ property({ type: Boolean, reflect: true })
228
+ ], NileTimelineChart.prototype, "inverted", void 0);
229
+ __decorate([
230
+ property({ type: Boolean, attribute: 'alternate-labels' })
231
+ ], NileTimelineChart.prototype, "alternateLabels", void 0);
232
+ __decorate([
233
+ property({ type: Boolean, attribute: 'show-legend' })
234
+ ], NileTimelineChart.prototype, "showLegend", void 0);
235
+ NileTimelineChart = __decorate([
236
+ customElement('nile-timeline-chart')
237
+ ], NileTimelineChart);
238
+ export { NileTimelineChart };
239
+ //# sourceMappingURL=nile-timeline-chart.js.map
@@ -1,6 +1,7 @@
1
1
  import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
2
2
  import type Highcharts from 'highcharts';
3
3
  import NileElement from '../internal/nile-element.js';
4
+ import type { NileChartConfigInputType } from '../internal/types/index.js';
4
5
  export interface TrendlineSeriesData {
5
6
  name: string;
6
7
  data: number[];
@@ -20,6 +21,8 @@ export declare class NileTrendlineChart extends NileElement {
20
21
  private chart;
21
22
  private resizeObserver;
22
23
  private chartContainer;
24
+ /** Full chart configuration. Accepts separated { chart, aq } input. */
25
+ config: NileChartConfigInputType | null;
23
26
  /** The chart title displayed above the chart. */
24
27
  chartTitle: string;
25
28
  /** The subtitle displayed below the title. */
@@ -38,6 +41,9 @@ export declare class NileTrendlineChart extends NileElement {
38
41
  height: string;
39
42
  /** Y-axis title text. */
40
43
  yAxisTitle: string;
44
+ /** Apply { chart, aq } config to individual properties. */
45
+ private applyConfig;
46
+ connectedCallback(): void;
41
47
  disconnectedCallback(): void;
42
48
  protected firstUpdated(): void;
43
49
  protected updated(changedProperties: PropertyValues): void;
@@ -11,6 +11,8 @@ let NileTrendlineChart = class NileTrendlineChart extends NileElement {
11
11
  this._hc = null;
12
12
  this.chart = null;
13
13
  this.resizeObserver = null;
14
+ /** Full chart configuration. Accepts separated { chart, aq } input. */
15
+ this.config = null;
14
16
  /** The chart title displayed above the chart. */
15
17
  this.chartTitle = '';
16
18
  /** The subtitle displayed below the title. */
@@ -30,6 +32,38 @@ let NileTrendlineChart = class NileTrendlineChart extends NileElement {
30
32
  /** Y-axis title text. */
31
33
  this.yAxisTitle = '';
32
34
  }
35
+ /** Apply { chart, aq } config to individual properties. */
36
+ applyConfig(cfg) {
37
+ const { chart: c, aq } = cfg;
38
+ if (c) {
39
+ const trend = c;
40
+ if (trend.data)
41
+ this.data = trend.data;
42
+ if (trend.categories)
43
+ this.categories = trend.categories;
44
+ if (trend.yAxisTitle)
45
+ this.yAxisTitle = trend.yAxisTitle;
46
+ if (trend.height)
47
+ this.height = trend.height;
48
+ if (trend.loading !== undefined)
49
+ this.loading = trend.loading;
50
+ if (trend.options)
51
+ this.options = trend.options;
52
+ if (trend.forecast)
53
+ this.forecast = trend.forecast;
54
+ }
55
+ if (aq) {
56
+ if (aq.chartTitle)
57
+ this.chartTitle = aq.chartTitle;
58
+ if (aq.chartSubtitle)
59
+ this.chartSubtitle = aq.chartSubtitle;
60
+ }
61
+ }
62
+ connectedCallback() {
63
+ super.connectedCallback();
64
+ if (this.config)
65
+ this.applyConfig(this.config);
66
+ }
33
67
  disconnectedCallback() {
34
68
  super.disconnectedCallback();
35
69
  this.destroyChart();
@@ -41,6 +75,10 @@ let NileTrendlineChart = class NileTrendlineChart extends NileElement {
41
75
  this.setupResizeObserver();
42
76
  }
43
77
  updated(changedProperties) {
78
+ if (changedProperties.has('config') && this.config) {
79
+ this.applyConfig(this.config);
80
+ return;
81
+ }
44
82
  const chartProps = [
45
83
  'data',
46
84
  'categories',
@@ -212,6 +250,9 @@ NileTrendlineChart.styles = styles;
212
250
  __decorate([
213
251
  query('.chart-container')
214
252
  ], NileTrendlineChart.prototype, "chartContainer", void 0);
253
+ __decorate([
254
+ property({ type: Object })
255
+ ], NileTrendlineChart.prototype, "config", void 0);
215
256
  __decorate([
216
257
  property({ type: String, attribute: 'chart-title' })
217
258
  ], NileTrendlineChart.prototype, "chartTitle", void 0);
@@ -1,6 +1,7 @@
1
1
  import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
2
2
  import type Highcharts from 'highcharts';
3
3
  import NileElement from '../internal/nile-element.js';
4
+ import type { NileChartConfigInputType } from '../internal/types/index.js';
4
5
  export interface WaterfallDataPoint {
5
6
  name: string;
6
7
  y: number;
@@ -14,6 +15,8 @@ export declare class NileWaterfallChart extends NileElement {
14
15
  private chart;
15
16
  private resizeObserver;
16
17
  private chartContainer;
18
+ /** Full chart configuration. Accepts separated { chart, aq } input. */
19
+ config: NileChartConfigInputType | null;
17
20
  chartTitle: string;
18
21
  chartSubtitle: string;
19
22
  data: WaterfallDataPoint[];
@@ -21,6 +24,9 @@ export declare class NileWaterfallChart extends NileElement {
21
24
  loading: boolean;
22
25
  height: string;
23
26
  yAxisTitle: string;
27
+ /** Apply { chart, aq } config to individual properties. */
28
+ private applyConfig;
29
+ connectedCallback(): void;
24
30
  disconnectedCallback(): void;
25
31
  protected firstUpdated(): void;
26
32
  protected updated(changedProperties: PropertyValues): void;