@aquera/nile-visualization 0.1.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 (121) hide show
  1. package/dist/src/index.d.ts +35 -0
  2. package/dist/src/index.js +20 -0
  3. package/dist/src/internal/chart-adapters.d.ts +11 -0
  4. package/dist/src/internal/chart-adapters.js +159 -0
  5. package/dist/src/internal/highcharts-provider.d.ts +14 -0
  6. package/dist/src/internal/highcharts-provider.js +56 -0
  7. package/dist/src/internal/nile-element.d.ts +8 -0
  8. package/dist/src/internal/nile-element.js +21 -0
  9. package/dist/src/internal/utils.d.ts +1 -0
  10. package/dist/src/internal/utils.js +23 -0
  11. package/dist/src/nile-ai-panel/index.d.ts +1 -0
  12. package/dist/src/nile-ai-panel/index.js +2 -0
  13. package/dist/src/nile-ai-panel/nile-ai-panel.css.d.ts +1 -0
  14. package/dist/src/nile-ai-panel/nile-ai-panel.css.js +73 -0
  15. package/dist/src/nile-ai-panel/nile-ai-panel.d.ts +29 -0
  16. package/dist/src/nile-ai-panel/nile-ai-panel.js +98 -0
  17. package/dist/src/nile-ai-sender/index.d.ts +1 -0
  18. package/dist/src/nile-ai-sender/index.js +2 -0
  19. package/dist/src/nile-ai-sender/nile-ai-sender.css.d.ts +1 -0
  20. package/dist/src/nile-ai-sender/nile-ai-sender.css.js +71 -0
  21. package/dist/src/nile-ai-sender/nile-ai-sender.d.ts +20 -0
  22. package/dist/src/nile-ai-sender/nile-ai-sender.js +77 -0
  23. package/dist/src/nile-anomaly-chart/index.d.ts +2 -0
  24. package/dist/src/nile-anomaly-chart/index.js +2 -0
  25. package/dist/src/nile-anomaly-chart/nile-anomaly-chart.css.d.ts +1 -0
  26. package/dist/src/nile-anomaly-chart/nile-anomaly-chart.css.js +28 -0
  27. package/dist/src/nile-anomaly-chart/nile-anomaly-chart.d.ts +59 -0
  28. package/dist/src/nile-anomaly-chart/nile-anomaly-chart.js +268 -0
  29. package/dist/src/nile-area-chart/index.d.ts +2 -0
  30. package/dist/src/nile-area-chart/index.js +2 -0
  31. package/dist/src/nile-area-chart/nile-area-chart.css.d.ts +1 -0
  32. package/dist/src/nile-area-chart/nile-area-chart.css.js +28 -0
  33. package/dist/src/nile-area-chart/nile-area-chart.d.ts +37 -0
  34. package/dist/src/nile-area-chart/nile-area-chart.js +122 -0
  35. package/dist/src/nile-bar-chart/index.d.ts +2 -0
  36. package/dist/src/nile-bar-chart/index.js +2 -0
  37. package/dist/src/nile-bar-chart/nile-bar-chart.css.d.ts +1 -0
  38. package/dist/src/nile-bar-chart/nile-bar-chart.css.js +28 -0
  39. package/dist/src/nile-bar-chart/nile-bar-chart.d.ts +44 -0
  40. package/dist/src/nile-bar-chart/nile-bar-chart.js +185 -0
  41. package/dist/src/nile-bubble-chart/index.d.ts +2 -0
  42. package/dist/src/nile-bubble-chart/index.js +2 -0
  43. package/dist/src/nile-bubble-chart/nile-bubble-chart.css.d.ts +1 -0
  44. package/dist/src/nile-bubble-chart/nile-bubble-chart.css.js +28 -0
  45. package/dist/src/nile-bubble-chart/nile-bubble-chart.d.ts +36 -0
  46. package/dist/src/nile-bubble-chart/nile-bubble-chart.js +123 -0
  47. package/dist/src/nile-chart/index.d.ts +3 -0
  48. package/dist/src/nile-chart/index.js +3 -0
  49. package/dist/src/nile-chart/nile-chart-config.d.ts +58 -0
  50. package/dist/src/nile-chart/nile-chart-config.js +2 -0
  51. package/dist/src/nile-chart/nile-chart.css.d.ts +1 -0
  52. package/dist/src/nile-chart/nile-chart.css.js +298 -0
  53. package/dist/src/nile-chart/nile-chart.d.ts +51 -0
  54. package/dist/src/nile-chart/nile-chart.js +303 -0
  55. package/dist/src/nile-column-chart/index.d.ts +2 -0
  56. package/dist/src/nile-column-chart/index.js +2 -0
  57. package/dist/src/nile-column-chart/nile-column-chart.css.d.ts +1 -0
  58. package/dist/src/nile-column-chart/nile-column-chart.css.js +28 -0
  59. package/dist/src/nile-column-chart/nile-column-chart.d.ts +36 -0
  60. package/dist/src/nile-column-chart/nile-column-chart.js +118 -0
  61. package/dist/src/nile-donut-chart/index.d.ts +2 -0
  62. package/dist/src/nile-donut-chart/index.js +2 -0
  63. package/dist/src/nile-donut-chart/nile-donut-chart.css.d.ts +1 -0
  64. package/dist/src/nile-donut-chart/nile-donut-chart.css.js +28 -0
  65. package/dist/src/nile-donut-chart/nile-donut-chart.d.ts +40 -0
  66. package/dist/src/nile-donut-chart/nile-donut-chart.js +131 -0
  67. package/dist/src/nile-gauge-chart/index.d.ts +2 -0
  68. package/dist/src/nile-gauge-chart/index.js +2 -0
  69. package/dist/src/nile-gauge-chart/nile-gauge-chart.css.d.ts +1 -0
  70. package/dist/src/nile-gauge-chart/nile-gauge-chart.css.js +28 -0
  71. package/dist/src/nile-gauge-chart/nile-gauge-chart.d.ts +38 -0
  72. package/dist/src/nile-gauge-chart/nile-gauge-chart.js +149 -0
  73. package/dist/src/nile-kpi-chart/index.d.ts +2 -0
  74. package/dist/src/nile-kpi-chart/index.js +2 -0
  75. package/dist/src/nile-kpi-chart/nile-kpi-chart.css.d.ts +1 -0
  76. package/dist/src/nile-kpi-chart/nile-kpi-chart.css.js +165 -0
  77. package/dist/src/nile-kpi-chart/nile-kpi-chart.d.ts +80 -0
  78. package/dist/src/nile-kpi-chart/nile-kpi-chart.js +335 -0
  79. package/dist/src/nile-line-chart/index.d.ts +2 -0
  80. package/dist/src/nile-line-chart/index.js +2 -0
  81. package/dist/src/nile-line-chart/nile-line-chart.css.d.ts +1 -0
  82. package/dist/src/nile-line-chart/nile-line-chart.css.js +28 -0
  83. package/dist/src/nile-line-chart/nile-line-chart.d.ts +36 -0
  84. package/dist/src/nile-line-chart/nile-line-chart.js +115 -0
  85. package/dist/src/nile-pie-chart/index.d.ts +2 -0
  86. package/dist/src/nile-pie-chart/index.js +2 -0
  87. package/dist/src/nile-pie-chart/nile-pie-chart.css.d.ts +1 -0
  88. package/dist/src/nile-pie-chart/nile-pie-chart.css.js +28 -0
  89. package/dist/src/nile-pie-chart/nile-pie-chart.d.ts +48 -0
  90. package/dist/src/nile-pie-chart/nile-pie-chart.js +197 -0
  91. package/dist/src/nile-radar-chart/index.d.ts +2 -0
  92. package/dist/src/nile-radar-chart/index.js +2 -0
  93. package/dist/src/nile-radar-chart/nile-radar-chart.css.d.ts +1 -0
  94. package/dist/src/nile-radar-chart/nile-radar-chart.css.js +28 -0
  95. package/dist/src/nile-radar-chart/nile-radar-chart.d.ts +36 -0
  96. package/dist/src/nile-radar-chart/nile-radar-chart.js +137 -0
  97. package/dist/src/nile-scatter-chart/index.d.ts +2 -0
  98. package/dist/src/nile-scatter-chart/index.js +2 -0
  99. package/dist/src/nile-scatter-chart/nile-scatter-chart.css.d.ts +1 -0
  100. package/dist/src/nile-scatter-chart/nile-scatter-chart.css.js +28 -0
  101. package/dist/src/nile-scatter-chart/nile-scatter-chart.d.ts +36 -0
  102. package/dist/src/nile-scatter-chart/nile-scatter-chart.js +124 -0
  103. package/dist/src/nile-spline-chart/index.d.ts +2 -0
  104. package/dist/src/nile-spline-chart/index.js +2 -0
  105. package/dist/src/nile-spline-chart/nile-spline-chart.css.d.ts +1 -0
  106. package/dist/src/nile-spline-chart/nile-spline-chart.css.js +28 -0
  107. package/dist/src/nile-spline-chart/nile-spline-chart.d.ts +36 -0
  108. package/dist/src/nile-spline-chart/nile-spline-chart.js +118 -0
  109. package/dist/src/nile-trendline-chart/index.d.ts +2 -0
  110. package/dist/src/nile-trendline-chart/index.js +2 -0
  111. package/dist/src/nile-trendline-chart/nile-trendline-chart.css.d.ts +1 -0
  112. package/dist/src/nile-trendline-chart/nile-trendline-chart.css.js +28 -0
  113. package/dist/src/nile-trendline-chart/nile-trendline-chart.d.ts +59 -0
  114. package/dist/src/nile-trendline-chart/nile-trendline-chart.js +246 -0
  115. package/dist/src/nile-waterfall-chart/index.d.ts +2 -0
  116. package/dist/src/nile-waterfall-chart/index.js +2 -0
  117. package/dist/src/nile-waterfall-chart/nile-waterfall-chart.css.d.ts +1 -0
  118. package/dist/src/nile-waterfall-chart/nile-waterfall-chart.css.js +28 -0
  119. package/dist/src/nile-waterfall-chart/nile-waterfall-chart.d.ts +37 -0
  120. package/dist/src/nile-waterfall-chart/nile-waterfall-chart.js +137 -0
  121. package/package.json +62 -0
@@ -0,0 +1,20 @@
1
+ import type { CSSResultGroup, TemplateResult } from 'lit';
2
+ import NileElement from '../internal/nile-element.js';
3
+ export declare class NileAiSender extends NileElement {
4
+ static styles: CSSResultGroup;
5
+ /** Placeholder text for the input. */
6
+ placeholder: string;
7
+ /** Whether the input is disabled. */
8
+ disabled: boolean;
9
+ private value;
10
+ private inputEl;
11
+ private handleInput;
12
+ private handleKeyDown;
13
+ private send;
14
+ render(): TemplateResult;
15
+ }
16
+ declare global {
17
+ interface HTMLElementTagNameMap {
18
+ 'nile-ai-sender': NileAiSender;
19
+ }
20
+ }
@@ -0,0 +1,77 @@
1
+ import { __decorate } from "tslib";
2
+ import { customElement, property, query, state } from 'lit/decorators.js';
3
+ import { html } from 'lit';
4
+ import NileElement from '../internal/nile-element.js';
5
+ import { styles } from './nile-ai-sender.css.js';
6
+ let NileAiSender = class NileAiSender extends NileElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ /** Placeholder text for the input. */
10
+ this.placeholder = 'Ask about this chart...';
11
+ /** Whether the input is disabled. */
12
+ this.disabled = false;
13
+ this.value = '';
14
+ }
15
+ handleInput(e) {
16
+ this.value = e.target.value;
17
+ }
18
+ handleKeyDown(e) {
19
+ if (e.key === 'Enter' && !e.shiftKey) {
20
+ e.preventDefault();
21
+ this.send();
22
+ }
23
+ }
24
+ send() {
25
+ const message = this.value.trim();
26
+ if (!message || this.disabled)
27
+ return;
28
+ this.emit('nile-ai-send', { message });
29
+ this.value = '';
30
+ if (this.inputEl)
31
+ this.inputEl.value = '';
32
+ }
33
+ render() {
34
+ return html `
35
+ <div class="sender">
36
+ <input
37
+ class="sender-input"
38
+ type="text"
39
+ .value=${this.value}
40
+ placeholder=${this.placeholder}
41
+ ?disabled=${this.disabled}
42
+ @input=${this.handleInput}
43
+ @keydown=${this.handleKeyDown}
44
+ />
45
+ <button
46
+ class="sender-btn"
47
+ ?disabled=${!this.value.trim() || this.disabled}
48
+ @click=${this.send}
49
+ aria-label="Send message"
50
+ >
51
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
52
+ <line x1="8" y1="12" x2="8" y2="4"/>
53
+ <polyline points="4,7 8,3 12,7"/>
54
+ </svg>
55
+ </button>
56
+ </div>
57
+ `;
58
+ }
59
+ };
60
+ NileAiSender.styles = styles;
61
+ __decorate([
62
+ property({ type: String })
63
+ ], NileAiSender.prototype, "placeholder", void 0);
64
+ __decorate([
65
+ property({ type: Boolean, reflect: true })
66
+ ], NileAiSender.prototype, "disabled", void 0);
67
+ __decorate([
68
+ state()
69
+ ], NileAiSender.prototype, "value", void 0);
70
+ __decorate([
71
+ query('.sender-input')
72
+ ], NileAiSender.prototype, "inputEl", void 0);
73
+ NileAiSender = __decorate([
74
+ customElement('nile-ai-sender')
75
+ ], NileAiSender);
76
+ export { NileAiSender };
77
+ //# sourceMappingURL=nile-ai-sender.js.map
@@ -0,0 +1,2 @@
1
+ export { NileAnomalyChart } from './nile-anomaly-chart.js';
2
+ export type { AnomalySeriesData, AnomalyConfig } from './nile-anomaly-chart.js';
@@ -0,0 +1,2 @@
1
+ export { NileAnomalyChart } from './nile-anomaly-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-anomaly-chart.css.js.map
@@ -0,0 +1,59 @@
1
+ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
2
+ import type Highcharts from 'highcharts';
3
+ import NileElement from '../internal/nile-element.js';
4
+ export interface AnomalySeriesData {
5
+ name: string;
6
+ data: number[];
7
+ color?: string;
8
+ }
9
+ export interface AnomalyConfig {
10
+ /** Standard deviation multiplier for the threshold band. Default: 2. */
11
+ threshold?: number;
12
+ /** Color for anomaly markers. Default: '#ef4444' (red). */
13
+ anomalyColor?: string;
14
+ /** Color for the normal range band. Default: 'rgba(59,130,246,0.1)'. */
15
+ bandColor?: string;
16
+ }
17
+ export declare class NileAnomalyChart extends NileElement {
18
+ static styles: CSSResultGroup;
19
+ private _hc;
20
+ private chart;
21
+ private resizeObserver;
22
+ private chartContainer;
23
+ /** The chart title displayed above the chart. */
24
+ chartTitle: string;
25
+ /** The subtitle displayed below the title. */
26
+ chartSubtitle: string;
27
+ /** Array of series data. Anomalies are detected per series. */
28
+ data: AnomalySeriesData[];
29
+ /** X-axis category labels. */
30
+ categories: string[];
31
+ /** Anomaly detection configuration. */
32
+ anomaly: AnomalyConfig;
33
+ /** Deep-merge override object for full Highcharts options. */
34
+ options: Highcharts.Options;
35
+ /** Whether to show a loading indicator instead of the chart. */
36
+ loading: boolean;
37
+ /** CSS height for the chart container. */
38
+ height: string;
39
+ /** Y-axis title text. */
40
+ yAxisTitle: string;
41
+ disconnectedCallback(): void;
42
+ protected firstUpdated(): void;
43
+ protected updated(changedProperties: PropertyValues): void;
44
+ private setupResizeObserver;
45
+ /**
46
+ * Detect anomalies using mean ± (threshold × stddev).
47
+ * Returns { upper, lower, mean, anomalyIndices } for a data array.
48
+ */
49
+ private detectAnomalies;
50
+ private buildOptions;
51
+ private initChart;
52
+ private destroyChart;
53
+ render(): TemplateResult;
54
+ }
55
+ declare global {
56
+ interface HTMLElementTagNameMap {
57
+ 'nile-anomaly-chart': NileAnomalyChart;
58
+ }
59
+ }
@@ -0,0 +1,268 @@
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 { deepMerge } from '../internal/utils.js';
7
+ import { styles } from './nile-anomaly-chart.css.js';
8
+ let NileAnomalyChart = class NileAnomalyChart extends NileElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this._hc = null;
12
+ this.chart = null;
13
+ this.resizeObserver = null;
14
+ /** The chart title displayed above the chart. */
15
+ this.chartTitle = '';
16
+ /** The subtitle displayed below the title. */
17
+ this.chartSubtitle = '';
18
+ /** Array of series data. Anomalies are detected per series. */
19
+ this.data = [];
20
+ /** X-axis category labels. */
21
+ this.categories = [];
22
+ /** Anomaly detection configuration. */
23
+ this.anomaly = {};
24
+ /** Deep-merge override object for full Highcharts options. */
25
+ this.options = {};
26
+ /** Whether to show a loading indicator instead of the chart. */
27
+ this.loading = false;
28
+ /** CSS height for the chart container. */
29
+ this.height = '400px';
30
+ /** Y-axis title text. */
31
+ this.yAxisTitle = '';
32
+ }
33
+ disconnectedCallback() {
34
+ super.disconnectedCallback();
35
+ this.destroyChart();
36
+ this.resizeObserver?.disconnect();
37
+ this.resizeObserver = null;
38
+ }
39
+ firstUpdated() {
40
+ this.initChart();
41
+ this.setupResizeObserver();
42
+ }
43
+ updated(changedProperties) {
44
+ const chartProps = [
45
+ 'data',
46
+ 'categories',
47
+ 'chartTitle',
48
+ 'chartSubtitle',
49
+ 'options',
50
+ 'height',
51
+ 'yAxisTitle',
52
+ 'anomaly',
53
+ 'loading',
54
+ ];
55
+ const needsUpdate = chartProps.some(p => changedProperties.has(p));
56
+ if (!needsUpdate)
57
+ return;
58
+ if (this.loading) {
59
+ this.destroyChart();
60
+ return;
61
+ }
62
+ if (this.chart) {
63
+ this.chart.update(this.buildOptions(), true, true);
64
+ }
65
+ else {
66
+ this.initChart();
67
+ }
68
+ }
69
+ setupResizeObserver() {
70
+ if (!this.chartContainer)
71
+ return;
72
+ this.resizeObserver = new ResizeObserver(() => {
73
+ this.chart?.reflow();
74
+ });
75
+ this.resizeObserver.observe(this.chartContainer);
76
+ }
77
+ /**
78
+ * Detect anomalies using mean ± (threshold × stddev).
79
+ * Returns { upper, lower, mean, anomalyIndices } for a data array.
80
+ */
81
+ detectAnomalies(values) {
82
+ const n = values.length;
83
+ if (n === 0)
84
+ return { upper: 0, lower: 0, mean: 0, anomalyIndices: [] };
85
+ const mean = values.reduce((a, b) => a + b, 0) / n;
86
+ const variance = values.reduce((sum, v) => sum + (v - mean) ** 2, 0) / n;
87
+ const stddev = Math.sqrt(variance);
88
+ const multiplier = this.anomaly?.threshold ?? 2;
89
+ const upper = mean + multiplier * stddev;
90
+ const lower = mean - multiplier * stddev;
91
+ const anomalyIndices = [];
92
+ for (let i = 0; i < n; i++) {
93
+ if (values[i] > upper || values[i] < lower) {
94
+ anomalyIndices.push(i);
95
+ }
96
+ }
97
+ return { upper, lower, mean, anomalyIndices };
98
+ }
99
+ buildOptions() {
100
+ const self = this;
101
+ const anomalyColor = this.anomaly?.anomalyColor ?? '#ef4444';
102
+ const bandColor = this.anomaly?.bandColor ?? 'rgba(59, 130, 246, 0.1)';
103
+ const series = [];
104
+ const plotBands = [];
105
+ for (const s of this.data) {
106
+ const { upper, lower, mean, anomalyIndices } = this.detectAnomalies(s.data);
107
+ // Main data line
108
+ series.push({
109
+ type: 'line',
110
+ name: s.name,
111
+ data: s.data.map((val, i) => ({
112
+ y: val,
113
+ marker: anomalyIndices.includes(i)
114
+ ? {
115
+ enabled: true,
116
+ radius: 7,
117
+ fillColor: anomalyColor,
118
+ lineColor: anomalyColor,
119
+ lineWidth: 2,
120
+ symbol: 'diamond',
121
+ }
122
+ : undefined,
123
+ })),
124
+ color: s.color,
125
+ marker: { enabled: true, radius: 3 },
126
+ });
127
+ // Anomaly scatter points (for legend + tooltip clarity)
128
+ if (anomalyIndices.length > 0) {
129
+ series.push({
130
+ type: 'scatter',
131
+ name: `${s.name} (Anomalies)`,
132
+ data: anomalyIndices.map(i => ({
133
+ x: i,
134
+ y: s.data[i],
135
+ })),
136
+ color: anomalyColor,
137
+ marker: { radius: 8, symbol: 'diamond', lineWidth: 2, lineColor: '#fff' },
138
+ tooltip: {
139
+ pointFormat: '<b>Anomaly:</b> {point.y}<br/>Threshold: ±{point.threshold}',
140
+ },
141
+ linkedTo: ':previous',
142
+ });
143
+ }
144
+ // Mean line
145
+ series.push({
146
+ type: 'line',
147
+ name: `${s.name} (Mean)`,
148
+ data: s.data.map(() => Math.round(mean * 100) / 100),
149
+ color: '#94a3b8',
150
+ dashStyle: 'ShortDot',
151
+ marker: { enabled: false },
152
+ enableMouseTracking: false,
153
+ linkedTo: ':previous',
154
+ });
155
+ // Normal range band (via plotBands on yAxis)
156
+ plotBands.push({
157
+ from: Math.round(lower * 100) / 100,
158
+ to: Math.round(upper * 100) / 100,
159
+ color: bandColor,
160
+ label: {
161
+ text: 'Normal Range',
162
+ style: { color: '#6b7280', fontSize: '11px' },
163
+ },
164
+ });
165
+ }
166
+ const defaults = {
167
+ chart: {
168
+ type: 'line',
169
+ height: this.height,
170
+ },
171
+ title: {
172
+ text: this.chartTitle || undefined,
173
+ },
174
+ subtitle: {
175
+ text: this.chartSubtitle || undefined,
176
+ },
177
+ xAxis: {
178
+ categories: this.categories,
179
+ title: { text: undefined },
180
+ },
181
+ yAxis: {
182
+ title: { text: this.yAxisTitle || undefined },
183
+ plotBands,
184
+ },
185
+ tooltip: {
186
+ shared: true,
187
+ },
188
+ plotOptions: {
189
+ series: {
190
+ cursor: 'pointer',
191
+ point: {
192
+ events: {
193
+ click() {
194
+ self.emit('nile-chart-click', {
195
+ point: this,
196
+ category: this.category,
197
+ value: this.y,
198
+ seriesName: this.series.name,
199
+ });
200
+ },
201
+ },
202
+ },
203
+ },
204
+ },
205
+ series,
206
+ credits: {
207
+ enabled: false,
208
+ },
209
+ };
210
+ return deepMerge(defaults, this.options);
211
+ }
212
+ async initChart() {
213
+ if (this.loading || !this.chartContainer)
214
+ return;
215
+ if (!this._hc)
216
+ this._hc = await getHighcharts();
217
+ this.chart = this._hc.chart(this.chartContainer, this.buildOptions());
218
+ this.emit('nile-chart-ready', { chart: this.chart });
219
+ }
220
+ destroyChart() {
221
+ if (this.chart) {
222
+ this.chart.destroy();
223
+ this.chart = null;
224
+ }
225
+ }
226
+ render() {
227
+ if (this.loading) {
228
+ return html `<div class="chart-loading" style="height:${this.height}">Loading...</div>`;
229
+ }
230
+ return html `<div class="chart-container"></div>`;
231
+ }
232
+ };
233
+ NileAnomalyChart.styles = styles;
234
+ __decorate([
235
+ query('.chart-container')
236
+ ], NileAnomalyChart.prototype, "chartContainer", void 0);
237
+ __decorate([
238
+ property({ type: String, attribute: 'chart-title' })
239
+ ], NileAnomalyChart.prototype, "chartTitle", void 0);
240
+ __decorate([
241
+ property({ type: String, attribute: 'chart-subtitle' })
242
+ ], NileAnomalyChart.prototype, "chartSubtitle", void 0);
243
+ __decorate([
244
+ property({ type: Array })
245
+ ], NileAnomalyChart.prototype, "data", void 0);
246
+ __decorate([
247
+ property({ type: Array })
248
+ ], NileAnomalyChart.prototype, "categories", void 0);
249
+ __decorate([
250
+ property({ type: Object })
251
+ ], NileAnomalyChart.prototype, "anomaly", void 0);
252
+ __decorate([
253
+ property({ type: Object })
254
+ ], NileAnomalyChart.prototype, "options", void 0);
255
+ __decorate([
256
+ property({ type: Boolean, reflect: true })
257
+ ], NileAnomalyChart.prototype, "loading", void 0);
258
+ __decorate([
259
+ property({ type: String })
260
+ ], NileAnomalyChart.prototype, "height", void 0);
261
+ __decorate([
262
+ property({ type: String, attribute: 'y-axis-title' })
263
+ ], NileAnomalyChart.prototype, "yAxisTitle", void 0);
264
+ NileAnomalyChart = __decorate([
265
+ customElement('nile-anomaly-chart')
266
+ ], NileAnomalyChart);
267
+ export { NileAnomalyChart };
268
+ //# sourceMappingURL=nile-anomaly-chart.js.map
@@ -0,0 +1,2 @@
1
+ export { NileAreaChart } from './nile-area-chart.js';
2
+ export type { AreaChartSeriesData } from './nile-area-chart.js';
@@ -0,0 +1,2 @@
1
+ export { NileAreaChart } from './nile-area-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-area-chart.css.js.map
@@ -0,0 +1,37 @@
1
+ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
2
+ import type Highcharts from 'highcharts';
3
+ import NileElement from '../internal/nile-element.js';
4
+ export interface AreaChartSeriesData {
5
+ name: string;
6
+ data: number[];
7
+ color?: string;
8
+ }
9
+ export declare class NileAreaChart extends NileElement {
10
+ static styles: CSSResultGroup;
11
+ private _hc;
12
+ private chart;
13
+ private resizeObserver;
14
+ private chartContainer;
15
+ chartTitle: string;
16
+ chartSubtitle: string;
17
+ data: AreaChartSeriesData[];
18
+ categories: string[];
19
+ options: Highcharts.Options;
20
+ loading: boolean;
21
+ height: string;
22
+ yAxisTitle: string;
23
+ stacked: boolean;
24
+ disconnectedCallback(): void;
25
+ protected firstUpdated(): void;
26
+ protected updated(changedProperties: PropertyValues): void;
27
+ private setupResizeObserver;
28
+ private buildOptions;
29
+ private initChart;
30
+ private destroyChart;
31
+ render(): TemplateResult;
32
+ }
33
+ declare global {
34
+ interface HTMLElementTagNameMap {
35
+ 'nile-area-chart': NileAreaChart;
36
+ }
37
+ }
@@ -0,0 +1,122 @@
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 { deepMerge } from '../internal/utils.js';
7
+ import { styles } from './nile-area-chart.css.js';
8
+ let NileAreaChart = class NileAreaChart extends NileElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this._hc = null;
12
+ this.chart = null;
13
+ this.resizeObserver = null;
14
+ this.chartTitle = '';
15
+ this.chartSubtitle = '';
16
+ this.data = [];
17
+ this.categories = [];
18
+ this.options = {};
19
+ this.loading = false;
20
+ this.height = '400px';
21
+ this.yAxisTitle = '';
22
+ this.stacked = false;
23
+ }
24
+ disconnectedCallback() {
25
+ super.disconnectedCallback();
26
+ this.destroyChart();
27
+ this.resizeObserver?.disconnect();
28
+ this.resizeObserver = null;
29
+ }
30
+ firstUpdated() { this.initChart(); this.setupResizeObserver(); }
31
+ updated(changedProperties) {
32
+ const props = ['data', 'categories', 'chartTitle', 'chartSubtitle', 'options', 'height', 'yAxisTitle', 'stacked', 'loading'];
33
+ if (!props.some(p => changedProperties.has(p)))
34
+ return;
35
+ if (this.loading) {
36
+ this.destroyChart();
37
+ return;
38
+ }
39
+ if (this.chart) {
40
+ this.chart.update(this.buildOptions(), true, true);
41
+ }
42
+ else {
43
+ this.initChart();
44
+ }
45
+ }
46
+ setupResizeObserver() {
47
+ if (!this.chartContainer)
48
+ return;
49
+ this.resizeObserver = new ResizeObserver(() => { this.chart?.reflow(); });
50
+ this.resizeObserver.observe(this.chartContainer);
51
+ }
52
+ buildOptions() {
53
+ const self = this;
54
+ return deepMerge({
55
+ chart: { type: 'area', height: this.height },
56
+ title: { text: this.chartTitle || undefined },
57
+ subtitle: { text: this.chartSubtitle || undefined },
58
+ xAxis: { categories: this.categories },
59
+ yAxis: { title: { text: this.yAxisTitle || undefined } },
60
+ tooltip: { shared: true },
61
+ plotOptions: {
62
+ area: { stacking: this.stacked ? 'normal' : undefined, fillOpacity: 0.25 },
63
+ series: { cursor: 'pointer', point: { events: { click() { self.emit('nile-chart-click', { point: this, category: this.category, value: this.y, seriesName: this.series.name }); } } } },
64
+ },
65
+ series: this.data.map(s => ({ type: 'area', name: s.name, data: s.data, color: s.color })),
66
+ credits: { enabled: false },
67
+ }, this.options);
68
+ }
69
+ async initChart() {
70
+ if (this.loading || !this.chartContainer)
71
+ return;
72
+ if (!this._hc)
73
+ this._hc = await getHighcharts();
74
+ this.chart = this._hc.chart(this.chartContainer, this.buildOptions());
75
+ this.emit('nile-chart-ready', { chart: this.chart });
76
+ }
77
+ destroyChart() { if (this.chart) {
78
+ this.chart.destroy();
79
+ this.chart = null;
80
+ } }
81
+ render() {
82
+ if (this.loading)
83
+ return html `<div class="chart-loading" style="height:${this.height}">Loading...</div>`;
84
+ return html `<div class="chart-container"></div>`;
85
+ }
86
+ };
87
+ NileAreaChart.styles = styles;
88
+ __decorate([
89
+ query('.chart-container')
90
+ ], NileAreaChart.prototype, "chartContainer", void 0);
91
+ __decorate([
92
+ property({ type: String, attribute: 'chart-title' })
93
+ ], NileAreaChart.prototype, "chartTitle", void 0);
94
+ __decorate([
95
+ property({ type: String, attribute: 'chart-subtitle' })
96
+ ], NileAreaChart.prototype, "chartSubtitle", void 0);
97
+ __decorate([
98
+ property({ type: Array })
99
+ ], NileAreaChart.prototype, "data", void 0);
100
+ __decorate([
101
+ property({ type: Array })
102
+ ], NileAreaChart.prototype, "categories", void 0);
103
+ __decorate([
104
+ property({ type: Object })
105
+ ], NileAreaChart.prototype, "options", void 0);
106
+ __decorate([
107
+ property({ type: Boolean, reflect: true })
108
+ ], NileAreaChart.prototype, "loading", void 0);
109
+ __decorate([
110
+ property({ type: String })
111
+ ], NileAreaChart.prototype, "height", void 0);
112
+ __decorate([
113
+ property({ type: String, attribute: 'y-axis-title' })
114
+ ], NileAreaChart.prototype, "yAxisTitle", void 0);
115
+ __decorate([
116
+ property({ type: Boolean })
117
+ ], NileAreaChart.prototype, "stacked", void 0);
118
+ NileAreaChart = __decorate([
119
+ customElement('nile-area-chart')
120
+ ], NileAreaChart);
121
+ export { NileAreaChart };
122
+ //# sourceMappingURL=nile-area-chart.js.map
@@ -0,0 +1,2 @@
1
+ export { NileBarChart } from './nile-bar-chart.js';
2
+ export type { BarChartSeriesData } from './nile-bar-chart.js';
@@ -0,0 +1,2 @@
1
+ export { NileBarChart } from './nile-bar-chart.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;