@aquera/nile-visualization 0.2.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 (170) hide show
  1. package/dist/src/index.d.ts +37 -1
  2. package/dist/src/index.js +19 -0
  3. package/dist/src/internal/chart-adapters.js +86 -0
  4. package/dist/src/internal/highcharts-provider.js +72 -0
  5. package/dist/src/internal/types/all-chart-config.type.d.ts +2 -4
  6. package/dist/src/internal/types/chart-area-config.type.d.ts +4 -0
  7. package/dist/src/internal/types/chart-area-negative-config.type.d.ts +13 -0
  8. package/dist/src/internal/types/chart-area-negative-config.type.js +2 -0
  9. package/dist/src/internal/types/chart-area-range-config.type.d.ts +12 -0
  10. package/dist/src/internal/types/chart-area-range-config.type.js +2 -0
  11. package/dist/src/internal/types/chart-area-spline-config.type.d.ts +13 -0
  12. package/dist/src/internal/types/chart-area-spline-config.type.js +2 -0
  13. package/dist/src/internal/types/chart-column-drilldown-config.type.d.ts +13 -0
  14. package/dist/src/internal/types/chart-column-drilldown-config.type.js +2 -0
  15. package/dist/src/internal/types/chart-column-pyramid-config.type.d.ts +11 -0
  16. package/dist/src/internal/types/chart-column-pyramid-config.type.js +2 -0
  17. package/dist/src/internal/types/chart-column-range-config.type.d.ts +12 -0
  18. package/dist/src/internal/types/chart-column-range-config.type.js +2 -0
  19. package/dist/src/internal/types/chart-config.type.d.ts +3 -2
  20. package/dist/src/internal/types/chart-donut-config.type.d.ts +2 -0
  21. package/dist/src/internal/types/chart-dumbbell-lower-config.type.d.ts +5 -0
  22. package/dist/src/internal/types/chart-dumbbell-lower-config.type.js +2 -0
  23. package/dist/src/internal/types/chart-dumbbell-upper-config.type.d.ts +5 -0
  24. package/dist/src/internal/types/chart-dumbbell-upper-config.type.js +2 -0
  25. package/dist/src/internal/types/chart-euler-config.type.d.ts +10 -0
  26. package/dist/src/internal/types/chart-euler-config.type.js +2 -0
  27. package/dist/src/internal/types/chart-heatmap-config.type.d.ts +19 -0
  28. package/dist/src/internal/types/chart-heatmap-config.type.js +2 -0
  29. package/dist/src/internal/types/chart-line-column-config.type.d.ts +14 -0
  30. package/dist/src/internal/types/chart-line-column-config.type.js +2 -0
  31. package/dist/src/internal/types/chart-lollipop-config.type.d.ts +11 -0
  32. package/dist/src/internal/types/chart-lollipop-config.type.js +2 -0
  33. package/dist/src/internal/types/chart-organization-config.type.d.ts +13 -0
  34. package/dist/src/internal/types/chart-organization-config.type.js +2 -0
  35. package/dist/src/internal/types/chart-polygon-config.type.d.ts +12 -0
  36. package/dist/src/internal/types/chart-polygon-config.type.js +2 -0
  37. package/dist/src/internal/types/chart-radial-bar-config.type.d.ts +16 -0
  38. package/dist/src/internal/types/chart-radial-bar-config.type.js +2 -0
  39. package/dist/src/internal/types/chart-variable-pie-config.type.d.ts +13 -0
  40. package/dist/src/internal/types/chart-variable-pie-config.type.js +2 -0
  41. package/dist/src/internal/types/chart-vector-config.type.d.ts +13 -0
  42. package/dist/src/internal/types/chart-vector-config.type.js +2 -0
  43. package/dist/src/internal/types/chart-xrange-config.type.d.ts +13 -0
  44. package/dist/src/internal/types/chart-xrange-config.type.js +2 -0
  45. package/dist/src/internal/types/index.d.ts +19 -1
  46. package/dist/src/internal/types/primitive-chart-config.type.d.ts +20 -1
  47. package/dist/src/nile-area-negative-chart/index.d.ts +2 -0
  48. package/dist/src/nile-area-negative-chart/index.js +2 -0
  49. package/dist/src/nile-area-negative-chart/nile-area-negative-chart.css.d.ts +1 -0
  50. package/dist/src/nile-area-negative-chart/nile-area-negative-chart.css.js +28 -0
  51. package/dist/src/nile-area-negative-chart/nile-area-negative-chart.d.ts +42 -0
  52. package/dist/src/nile-area-negative-chart/nile-area-negative-chart.js +178 -0
  53. package/dist/src/nile-area-range-chart/index.d.ts +2 -0
  54. package/dist/src/nile-area-range-chart/index.js +2 -0
  55. package/dist/src/nile-area-range-chart/nile-area-range-chart.css.d.ts +1 -0
  56. package/dist/src/nile-area-range-chart/nile-area-range-chart.css.js +28 -0
  57. package/dist/src/nile-area-range-chart/nile-area-range-chart.d.ts +41 -0
  58. package/dist/src/nile-area-range-chart/nile-area-range-chart.js +173 -0
  59. package/dist/src/nile-area-spline-chart/index.d.ts +2 -0
  60. package/dist/src/nile-area-spline-chart/index.js +2 -0
  61. package/dist/src/nile-area-spline-chart/nile-area-spline-chart.css.d.ts +1 -0
  62. package/dist/src/nile-area-spline-chart/nile-area-spline-chart.css.js +28 -0
  63. package/dist/src/nile-area-spline-chart/nile-area-spline-chart.d.ts +41 -0
  64. package/dist/src/nile-area-spline-chart/nile-area-spline-chart.js +174 -0
  65. package/dist/src/nile-bellcurve-chart/nile-bellcurve-chart.js +3 -1
  66. package/dist/src/nile-chart/index.d.ts +1 -1
  67. package/dist/src/nile-chart/nile-chart-config.d.ts +36 -96
  68. package/dist/src/nile-chart/nile-chart.css.js +1 -1
  69. package/dist/src/nile-chart/nile-chart.d.ts +36 -0
  70. package/dist/src/nile-chart/nile-chart.js +412 -5
  71. package/dist/src/nile-column-drilldown-chart/index.d.ts +2 -0
  72. package/dist/src/nile-column-drilldown-chart/index.js +2 -0
  73. package/dist/src/nile-column-drilldown-chart/nile-column-drilldown-chart.css.d.ts +1 -0
  74. package/dist/src/nile-column-drilldown-chart/nile-column-drilldown-chart.css.js +28 -0
  75. package/dist/src/nile-column-drilldown-chart/nile-column-drilldown-chart.d.ts +49 -0
  76. package/dist/src/nile-column-drilldown-chart/nile-column-drilldown-chart.js +186 -0
  77. package/dist/src/nile-column-pyramid-chart/index.d.ts +2 -0
  78. package/dist/src/nile-column-pyramid-chart/index.js +2 -0
  79. package/dist/src/nile-column-pyramid-chart/nile-column-pyramid-chart.css.d.ts +1 -0
  80. package/dist/src/nile-column-pyramid-chart/nile-column-pyramid-chart.css.js +28 -0
  81. package/dist/src/nile-column-pyramid-chart/nile-column-pyramid-chart.d.ts +39 -0
  82. package/dist/src/nile-column-pyramid-chart/nile-column-pyramid-chart.js +155 -0
  83. package/dist/src/nile-column-range-chart/index.d.ts +2 -0
  84. package/dist/src/nile-column-range-chart/index.js +2 -0
  85. package/dist/src/nile-column-range-chart/nile-column-range-chart.css.d.ts +1 -0
  86. package/dist/src/nile-column-range-chart/nile-column-range-chart.css.js +28 -0
  87. package/dist/src/nile-column-range-chart/nile-column-range-chart.d.ts +40 -0
  88. package/dist/src/nile-column-range-chart/nile-column-range-chart.js +169 -0
  89. package/dist/src/nile-donut-chart/nile-donut-chart.d.ts +2 -0
  90. package/dist/src/nile-donut-chart/nile-donut-chart.js +16 -1
  91. package/dist/src/nile-dumbbell-lower-chart/index.d.ts +1 -0
  92. package/dist/src/nile-dumbbell-lower-chart/index.js +2 -0
  93. package/dist/src/nile-dumbbell-lower-chart/nile-dumbbell-lower-chart.css.d.ts +1 -0
  94. package/dist/src/nile-dumbbell-lower-chart/nile-dumbbell-lower-chart.css.js +28 -0
  95. package/dist/src/nile-dumbbell-lower-chart/nile-dumbbell-lower-chart.d.ts +40 -0
  96. package/dist/src/nile-dumbbell-lower-chart/nile-dumbbell-lower-chart.js +214 -0
  97. package/dist/src/nile-dumbbell-upper-chart/index.d.ts +1 -0
  98. package/dist/src/nile-dumbbell-upper-chart/index.js +2 -0
  99. package/dist/src/nile-dumbbell-upper-chart/nile-dumbbell-upper-chart.css.d.ts +1 -0
  100. package/dist/src/nile-dumbbell-upper-chart/nile-dumbbell-upper-chart.css.js +28 -0
  101. package/dist/src/nile-dumbbell-upper-chart/nile-dumbbell-upper-chart.d.ts +40 -0
  102. package/dist/src/nile-dumbbell-upper-chart/nile-dumbbell-upper-chart.js +214 -0
  103. package/dist/src/nile-euler-chart/index.d.ts +2 -0
  104. package/dist/src/nile-euler-chart/index.js +2 -0
  105. package/dist/src/nile-euler-chart/nile-euler-chart.css.d.ts +1 -0
  106. package/dist/src/nile-euler-chart/nile-euler-chart.css.js +28 -0
  107. package/dist/src/nile-euler-chart/nile-euler-chart.d.ts +38 -0
  108. package/dist/src/nile-euler-chart/nile-euler-chart.js +149 -0
  109. package/dist/src/nile-heatmap-chart/index.d.ts +2 -0
  110. package/dist/src/nile-heatmap-chart/index.js +2 -0
  111. package/dist/src/nile-heatmap-chart/nile-heatmap-chart.css.d.ts +1 -0
  112. package/dist/src/nile-heatmap-chart/nile-heatmap-chart.css.js +28 -0
  113. package/dist/src/nile-heatmap-chart/nile-heatmap-chart.d.ts +49 -0
  114. package/dist/src/nile-heatmap-chart/nile-heatmap-chart.js +259 -0
  115. package/dist/src/nile-histogram-chart/nile-histogram-chart.js +3 -1
  116. package/dist/src/nile-inverted-area-chart/index.d.ts +2 -0
  117. package/dist/src/nile-inverted-area-chart/index.js +2 -0
  118. package/dist/src/nile-inverted-area-chart/nile-inverted-area-chart.css.d.ts +1 -0
  119. package/dist/src/nile-inverted-area-chart/nile-inverted-area-chart.css.js +28 -0
  120. package/dist/src/nile-inverted-area-chart/nile-inverted-area-chart.d.ts +40 -0
  121. package/dist/src/nile-inverted-area-chart/nile-inverted-area-chart.js +173 -0
  122. package/dist/src/nile-line-column-chart/index.d.ts +2 -0
  123. package/dist/src/nile-line-column-chart/index.js +2 -0
  124. package/dist/src/nile-line-column-chart/nile-line-column-chart.css.d.ts +1 -0
  125. package/dist/src/nile-line-column-chart/nile-line-column-chart.css.js +28 -0
  126. package/dist/src/nile-line-column-chart/nile-line-column-chart.d.ts +42 -0
  127. package/dist/src/nile-line-column-chart/nile-line-column-chart.js +205 -0
  128. package/dist/src/nile-lollipop-chart/index.d.ts +2 -0
  129. package/dist/src/nile-lollipop-chart/index.js +2 -0
  130. package/dist/src/nile-lollipop-chart/nile-lollipop-chart.css.d.ts +1 -0
  131. package/dist/src/nile-lollipop-chart/nile-lollipop-chart.css.js +28 -0
  132. package/dist/src/nile-lollipop-chart/nile-lollipop-chart.d.ts +39 -0
  133. package/dist/src/nile-lollipop-chart/nile-lollipop-chart.js +174 -0
  134. package/dist/src/nile-organization-chart/index.d.ts +2 -0
  135. package/dist/src/nile-organization-chart/index.js +2 -0
  136. package/dist/src/nile-organization-chart/nile-organization-chart.css.d.ts +1 -0
  137. package/dist/src/nile-organization-chart/nile-organization-chart.css.js +28 -0
  138. package/dist/src/nile-organization-chart/nile-organization-chart.d.ts +57 -0
  139. package/dist/src/nile-organization-chart/nile-organization-chart.js +206 -0
  140. package/dist/src/nile-polygon-chart/index.d.ts +2 -0
  141. package/dist/src/nile-polygon-chart/index.js +2 -0
  142. package/dist/src/nile-polygon-chart/nile-polygon-chart.css.d.ts +1 -0
  143. package/dist/src/nile-polygon-chart/nile-polygon-chart.css.js +28 -0
  144. package/dist/src/nile-polygon-chart/nile-polygon-chart.d.ts +41 -0
  145. package/dist/src/nile-polygon-chart/nile-polygon-chart.js +167 -0
  146. package/dist/src/nile-radial-bar-chart/index.d.ts +2 -0
  147. package/dist/src/nile-radial-bar-chart/index.js +2 -0
  148. package/dist/src/nile-radial-bar-chart/nile-radial-bar-chart.css.d.ts +1 -0
  149. package/dist/src/nile-radial-bar-chart/nile-radial-bar-chart.css.js +28 -0
  150. package/dist/src/nile-radial-bar-chart/nile-radial-bar-chart.d.ts +42 -0
  151. package/dist/src/nile-radial-bar-chart/nile-radial-bar-chart.js +191 -0
  152. package/dist/src/nile-variable-pie-chart/index.d.ts +2 -0
  153. package/dist/src/nile-variable-pie-chart/index.js +2 -0
  154. package/dist/src/nile-variable-pie-chart/nile-variable-pie-chart.css.d.ts +1 -0
  155. package/dist/src/nile-variable-pie-chart/nile-variable-pie-chart.css.js +28 -0
  156. package/dist/src/nile-variable-pie-chart/nile-variable-pie-chart.d.ts +42 -0
  157. package/dist/src/nile-variable-pie-chart/nile-variable-pie-chart.js +180 -0
  158. package/dist/src/nile-vector-chart/index.d.ts +2 -0
  159. package/dist/src/nile-vector-chart/index.js +2 -0
  160. package/dist/src/nile-vector-chart/nile-vector-chart.css.d.ts +1 -0
  161. package/dist/src/nile-vector-chart/nile-vector-chart.css.js +28 -0
  162. package/dist/src/nile-vector-chart/nile-vector-chart.d.ts +44 -0
  163. package/dist/src/nile-vector-chart/nile-vector-chart.js +181 -0
  164. package/dist/src/nile-xrange-chart/index.d.ts +2 -0
  165. package/dist/src/nile-xrange-chart/index.js +2 -0
  166. package/dist/src/nile-xrange-chart/nile-xrange-chart.css.d.ts +1 -0
  167. package/dist/src/nile-xrange-chart/nile-xrange-chart.css.js +28 -0
  168. package/dist/src/nile-xrange-chart/nile-xrange-chart.d.ts +44 -0
  169. package/dist/src/nile-xrange-chart/nile-xrange-chart.js +193 -0
  170. package/package.json +4 -1
@@ -0,0 +1,174 @@
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 { applySeparatedChartConfig } from '../internal/separated-chart-config.js';
6
+ import { getHighcharts } from '../internal/highcharts-provider.js';
7
+ import { deepMerge } from '../internal/utils.js';
8
+ import { styles } from './nile-lollipop-chart.css.js';
9
+ let NileLollipopChart = class NileLollipopChart extends NileElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this._hc = null;
13
+ this.chart = null;
14
+ this.resizeObserver = null;
15
+ this.config = null;
16
+ this.chartTitle = '';
17
+ this.chartSubtitle = '';
18
+ this.data = [];
19
+ this.categories = [];
20
+ this.options = {};
21
+ this.loading = false;
22
+ this.height = '400px';
23
+ }
24
+ applyConfig(cfg) {
25
+ applySeparatedChartConfig(this, cfg);
26
+ }
27
+ connectedCallback() {
28
+ super.connectedCallback();
29
+ if (this.config)
30
+ this.applyConfig(this.config);
31
+ }
32
+ disconnectedCallback() {
33
+ super.disconnectedCallback();
34
+ this.destroyChart();
35
+ this.resizeObserver?.disconnect();
36
+ this.resizeObserver = null;
37
+ }
38
+ firstUpdated() {
39
+ this.initChart();
40
+ this.setupResizeObserver();
41
+ }
42
+ updated(changedProperties) {
43
+ if (changedProperties.has('config') && this.config) {
44
+ this.applyConfig(this.config);
45
+ return;
46
+ }
47
+ const props = ['data', 'categories', 'chartTitle', 'chartSubtitle', 'options', 'height', 'loading'];
48
+ if (!props.some(p => changedProperties.has(p)))
49
+ return;
50
+ if (this.loading) {
51
+ this.destroyChart();
52
+ return;
53
+ }
54
+ if (this.chart) {
55
+ this.chart.update(this.buildOptions(), true, true);
56
+ }
57
+ else {
58
+ this.initChart();
59
+ }
60
+ }
61
+ setupResizeObserver() {
62
+ if (!this.chartContainer)
63
+ return;
64
+ this.resizeObserver = new ResizeObserver(() => this.chart?.reflow());
65
+ this.resizeObserver.observe(this.chartContainer);
66
+ }
67
+ buildOptions() {
68
+ const self = this;
69
+ const series = [];
70
+ for (const s of this.data) {
71
+ series.push({
72
+ type: 'column',
73
+ name: s.name,
74
+ data: s.data,
75
+ color: s.color,
76
+ pointWidth: 3,
77
+ borderWidth: 0,
78
+ enableMouseTracking: true,
79
+ });
80
+ series.push({
81
+ type: 'scatter',
82
+ name: s.name,
83
+ data: s.data.map((y, i) => [i, y]),
84
+ color: s.color,
85
+ marker: { radius: 7, lineWidth: 2, lineColor: '#ffffff', symbol: 'circle' },
86
+ showInLegend: false,
87
+ enableMouseTracking: true,
88
+ });
89
+ }
90
+ return deepMerge({
91
+ chart: { height: this.height },
92
+ title: { text: this.chartTitle || undefined },
93
+ subtitle: { text: this.chartSubtitle || undefined },
94
+ xAxis: { categories: this.categories },
95
+ yAxis: { title: { text: undefined }, min: 0 },
96
+ legend: { enabled: this.data.length > 1 },
97
+ tooltip: { shared: true },
98
+ plotOptions: {
99
+ column: { grouping: false, pointPadding: 0.12 },
100
+ scatter: { clip: false },
101
+ series: {
102
+ cursor: 'pointer',
103
+ point: {
104
+ events: {
105
+ click() {
106
+ self.emit('nile-chart-click', {
107
+ point: this,
108
+ category: this.category,
109
+ value: this.y,
110
+ seriesName: this.series.name,
111
+ });
112
+ },
113
+ },
114
+ },
115
+ },
116
+ },
117
+ series,
118
+ credits: { enabled: false },
119
+ }, this.options);
120
+ }
121
+ async initChart() {
122
+ if (this.loading || !this.chartContainer)
123
+ return;
124
+ if (!this._hc)
125
+ this._hc = await getHighcharts();
126
+ this.chart = this._hc.chart(this.chartContainer, this.buildOptions());
127
+ this.emit('nile-chart-ready', { chart: this.chart });
128
+ }
129
+ destroyChart() {
130
+ if (this.chart) {
131
+ this.chart.destroy();
132
+ this.chart = null;
133
+ }
134
+ }
135
+ render() {
136
+ if (this.loading) {
137
+ return html `<div class="chart-loading" style="height:${this.height}">Loading...</div>`;
138
+ }
139
+ return html `<div class="chart-container"></div>`;
140
+ }
141
+ };
142
+ NileLollipopChart.styles = styles;
143
+ __decorate([
144
+ query('.chart-container')
145
+ ], NileLollipopChart.prototype, "chartContainer", void 0);
146
+ __decorate([
147
+ property({ type: Object })
148
+ ], NileLollipopChart.prototype, "config", void 0);
149
+ __decorate([
150
+ property({ type: String, attribute: 'chart-title' })
151
+ ], NileLollipopChart.prototype, "chartTitle", void 0);
152
+ __decorate([
153
+ property({ type: String, attribute: 'chart-subtitle' })
154
+ ], NileLollipopChart.prototype, "chartSubtitle", void 0);
155
+ __decorate([
156
+ property({ type: Array })
157
+ ], NileLollipopChart.prototype, "data", void 0);
158
+ __decorate([
159
+ property({ type: Array })
160
+ ], NileLollipopChart.prototype, "categories", void 0);
161
+ __decorate([
162
+ property({ type: Object })
163
+ ], NileLollipopChart.prototype, "options", void 0);
164
+ __decorate([
165
+ property({ type: Boolean, reflect: true })
166
+ ], NileLollipopChart.prototype, "loading", void 0);
167
+ __decorate([
168
+ property({ type: String })
169
+ ], NileLollipopChart.prototype, "height", void 0);
170
+ NileLollipopChart = __decorate([
171
+ customElement('nile-lollipop-chart')
172
+ ], NileLollipopChart);
173
+ export { NileLollipopChart };
174
+ //# sourceMappingURL=nile-lollipop-chart.js.map
@@ -0,0 +1,2 @@
1
+ export { NileOrganizationChart } from './nile-organization-chart.js';
2
+ export type { OrgChartLink, OrgChartNode } from './nile-organization-chart.js';
@@ -0,0 +1,2 @@
1
+ export { NileOrganizationChart } from './nile-organization-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-organization-chart.css.js.map
@@ -0,0 +1,57 @@
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
+ /** Directed edge: reporting line from `from` to `to` (node ids). */
6
+ export interface OrgChartLink {
7
+ from: string;
8
+ to: string;
9
+ }
10
+ /** Node card in the org chart (`id` must match link endpoints). */
11
+ export interface OrgChartNode {
12
+ id: string;
13
+ title?: string;
14
+ name?: string;
15
+ description?: string;
16
+ image?: string;
17
+ color?: string;
18
+ /** When set, children hang under this node (Highcharts layout). */
19
+ layout?: 'hanging';
20
+ }
21
+ export declare class NileOrganizationChart extends NileElement {
22
+ static styles: CSSResultGroup;
23
+ private _hc;
24
+ private chart;
25
+ private resizeObserver;
26
+ private chartContainer;
27
+ /** Full chart configuration. Accepts separated `{ chart, aq }` input. */
28
+ config: SeparatedChartConfigInputType | null;
29
+ chartTitle: string;
30
+ chartSubtitle: string;
31
+ nodes: OrgChartNode[];
32
+ links: OrgChartLink[];
33
+ options: Highcharts.Options;
34
+ loading: boolean;
35
+ height: string;
36
+ seriesName: string;
37
+ /**
38
+ * When true (default), the chart flows top-down — typical for org charts in Highcharts.
39
+ * Set false for a horizontal layout.
40
+ */
41
+ inverted: boolean;
42
+ private applyConfig;
43
+ connectedCallback(): void;
44
+ disconnectedCallback(): void;
45
+ protected firstUpdated(): void;
46
+ protected updated(changedProperties: PropertyValues): void;
47
+ private setupResizeObserver;
48
+ private buildOptions;
49
+ private initChart;
50
+ private destroyChart;
51
+ render(): TemplateResult;
52
+ }
53
+ declare global {
54
+ interface HTMLElementTagNameMap {
55
+ 'nile-organization-chart': NileOrganizationChart;
56
+ }
57
+ }
@@ -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
@@ -0,0 +1,2 @@
1
+ export { NilePolygonChart } from './nile-polygon-chart.js';
2
+ export type { PolygonSeriesConfig } from './nile-polygon-chart.js';
@@ -0,0 +1,2 @@
1
+ export { NilePolygonChart } from './nile-polygon-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-polygon-chart.css.js.map
@@ -0,0 +1,41 @@
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 PolygonSeriesConfig {
6
+ name: string;
7
+ data: [number, number][];
8
+ color?: string;
9
+ lineWidth?: number;
10
+ }
11
+ export declare class NilePolygonChart extends NileElement {
12
+ static styles: CSSResultGroup;
13
+ private _hc;
14
+ private chart;
15
+ private resizeObserver;
16
+ private chartContainer;
17
+ config: SeparatedChartConfigInputType | null;
18
+ chartTitle: string;
19
+ chartSubtitle: string;
20
+ series: PolygonSeriesConfig[];
21
+ xAxisTitle: string;
22
+ yAxisTitle: string;
23
+ options: Highcharts.Options;
24
+ loading: boolean;
25
+ height: string;
26
+ private applyConfig;
27
+ connectedCallback(): void;
28
+ disconnectedCallback(): void;
29
+ protected firstUpdated(): void;
30
+ protected updated(changedProperties: PropertyValues): void;
31
+ private setupResizeObserver;
32
+ private buildOptions;
33
+ private initChart;
34
+ private destroyChart;
35
+ render(): TemplateResult;
36
+ }
37
+ declare global {
38
+ interface HTMLElementTagNameMap {
39
+ 'nile-polygon-chart': NilePolygonChart;
40
+ }
41
+ }