@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,165 @@
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
+ /* ── Card variant ── */
14
+
15
+ .kpi-card {
16
+ background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));
17
+ border: var(--nile-border-width-1, var(--ng-stroke-width-1)) solid var(--nile-colors-neutral-400, var(--ng-colors-border-secondary));
18
+ border-radius: var(--nile-radius-radius-3xl, var(--ng-radius-xl));
19
+ box-shadow: var(--nile-box-shadow-3, var(--ng-shadow-sm));
20
+ transition: box-shadow var(--nile-transition-duration-default, var(--ng-transition-duration-default)) ease;
21
+ }
22
+
23
+ .kpi-card:hover {
24
+ box-shadow: var(--nile-box-shadow-7, var(--ng-shadow-md));
25
+ }
26
+
27
+ /* ── Base layout ── */
28
+
29
+ .kpi {
30
+ display: flex;
31
+ flex-direction: column;
32
+ gap: var(--nile-spacing-md, var(--ng-spacing-md));
33
+ padding: var(--nile-spacing-2xl, var(--ng-spacing-2xl)) var(--nile-spacing-3xl, var(--ng-spacing-3xl));
34
+ }
35
+
36
+ .kpi-label {
37
+ margin: 0;
38
+ font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
39
+ font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
40
+ font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));
41
+ color: var(--nile-colors-neutral-700, var(--ng-colors-text-secondary-700));
42
+ line-height: 1.4;
43
+ }
44
+
45
+ .kpi-value-row {
46
+ display: flex;
47
+ align-items: baseline;
48
+ gap: var(--nile-spacing-md, var(--ng-spacing-md));
49
+ flex-wrap: wrap;
50
+ }
51
+
52
+ .kpi-value {
53
+ margin: 0;
54
+ font-family: var(--nile-font-family-serif-colfax-medium, var(--ng-font-family-display));
55
+ font-size: 36px;
56
+ font-weight: var(--nile-font-weight-semi-bold, var(--ng-font-weight-semibold));
57
+ color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));
58
+ line-height: 1.2;
59
+ }
60
+
61
+ .kpi-prefix,
62
+ .kpi-suffix {
63
+ font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
64
+ font-size: var(--nile-type-scale-6, var(--ng-font-size-text-xl));
65
+ font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));
66
+ color: var(--nile-colors-neutral-700, var(--ng-colors-text-secondary-700));
67
+ }
68
+
69
+ .kpi-trend {
70
+ display: inline-flex;
71
+ align-items: center;
72
+ gap: var(--nile-spacing-xs, var(--ng-spacing-xs));
73
+ padding: var(--nile-spacing-xs, var(--ng-spacing-xs)) var(--nile-spacing-md, var(--ng-spacing-md));
74
+ border-radius: var(--nile-radius-radius-3xl, var(--ng-radius-xl));
75
+ font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
76
+ font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));
77
+ font-weight: var(--nile-font-weight-medium, var(--ng-font-weight-medium));
78
+ line-height: 1;
79
+ }
80
+
81
+ .kpi-trend--up {
82
+ background: var(--nile-colors-success-100, #ECFDF3);
83
+ color: var(--nile-colors-success-700, #067647);
84
+ }
85
+
86
+ .kpi-trend--down {
87
+ background: var(--nile-colors-error-100, #FEF3F2);
88
+ color: var(--nile-colors-error-700, #B42318);
89
+ }
90
+
91
+ .kpi-trend--neutral {
92
+ background: var(--nile-colors-neutral-100, var(--ng-colors-bg-secondary));
93
+ color: var(--nile-colors-neutral-700, var(--ng-colors-text-secondary-700));
94
+ }
95
+
96
+ .kpi-trend-arrow {
97
+ display: inline-flex;
98
+ width: 12px;
99
+ height: 12px;
100
+ }
101
+
102
+ .kpi-trend-arrow svg {
103
+ width: 100%;
104
+ height: 100%;
105
+ fill: currentColor;
106
+ }
107
+
108
+ .kpi-description {
109
+ margin: 0;
110
+ font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
111
+ font-size: var(--nile-type-scale-2, var(--ng-font-size-text-xs));
112
+ color: var(--nile-colors-neutral-700, var(--ng-colors-text-secondary-700));
113
+ line-height: 1.5;
114
+ }
115
+
116
+ .kpi-sparkline {
117
+ width: 100%;
118
+ height: 48px;
119
+ margin-top: var(--nile-spacing-xs, var(--ng-spacing-xs));
120
+ }
121
+
122
+ /* ── Gauge variant ── */
123
+
124
+ .kpi--gauge {
125
+ align-items: center;
126
+ text-align: center;
127
+ }
128
+
129
+ .kpi-gauge-container {
130
+ width: 160px;
131
+ height: 160px;
132
+ margin: 0 auto;
133
+ }
134
+
135
+ .kpi--gauge .kpi-value-row {
136
+ justify-content: center;
137
+ display: none;
138
+ }
139
+
140
+ .kpi--gauge .kpi-label {
141
+ text-align: center;
142
+ font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
143
+ }
144
+
145
+ .kpi--gauge .kpi-trend {
146
+ margin: 0 auto;
147
+ }
148
+
149
+ .kpi--gauge .kpi-description {
150
+ text-align: center;
151
+ }
152
+
153
+ /* ── Loading state ── */
154
+
155
+ .chart-loading {
156
+ display: flex;
157
+ align-items: center;
158
+ justify-content: center;
159
+ min-height: var(--nile-height-200px, var(--ng-height-200px));
160
+ color: var(--nile-colors-neutral-700, var(--ng-colors-text-secondary-700));
161
+ font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
162
+ font-size: var(--nile-type-scale-3, var(--ng-font-size-text-sm));
163
+ }
164
+ `;
165
+ //# sourceMappingURL=nile-kpi-chart.css.js.map
@@ -0,0 +1,80 @@
1
+ import type { CSSResultGroup, PropertyValues, TemplateResult } from 'lit';
2
+ import type Highcharts from 'highcharts';
3
+ import NileElement from '../internal/nile-element.js';
4
+ export type TrendDirection = 'up' | 'down' | 'neutral';
5
+ export type KpiVariant = 'default' | 'card' | 'gauge';
6
+ export interface KpiConfig {
7
+ label: string;
8
+ value: number | string;
9
+ prefix?: string;
10
+ suffix?: string;
11
+ trend?: {
12
+ value: number;
13
+ direction: TrendDirection;
14
+ label?: string;
15
+ };
16
+ description?: string;
17
+ sparkline?: number[];
18
+ }
19
+ export declare class NileKpiChart extends NileElement {
20
+ static styles: CSSResultGroup;
21
+ private _hc;
22
+ private sparklineChart;
23
+ private gaugeChart;
24
+ private resizeObserver;
25
+ private sparklineContainer;
26
+ private gaugeContainer;
27
+ /** Display variant: default (flat), card (bordered container), gauge (Highcharts solid gauge). */
28
+ variant: KpiVariant;
29
+ /** Label displayed above the value. */
30
+ label: string;
31
+ /** The main KPI value. */
32
+ value: string | number;
33
+ /** Prefix shown before the value (e.g. "$"). */
34
+ prefix: string;
35
+ /** Suffix shown after the value (e.g. "%"). */
36
+ suffix: string;
37
+ /** Trend percentage (e.g. 12.5). */
38
+ trendValue: number | null;
39
+ /** Trend direction: up, down, or neutral. */
40
+ trendDirection: TrendDirection;
41
+ /** Trend context label (e.g. "vs last month"). */
42
+ trendLabel: string;
43
+ /** Description shown below the value. */
44
+ description: string;
45
+ /** Sparkline data points. When provided, a Highcharts mini area chart renders below the value. */
46
+ sparkline: number[];
47
+ /** Color for the sparkline. */
48
+ sparklineColor: string;
49
+ /** Gauge: the numeric value (0-100 by default). */
50
+ gaugeValue: number;
51
+ /** Gauge: minimum value. */
52
+ gaugeMin: number;
53
+ /** Gauge: maximum value. */
54
+ gaugeMax: number;
55
+ /** Gauge: ring color. Falls back to brand color. */
56
+ gaugeColor: string;
57
+ /** Whether the component is in a loading state. */
58
+ loading: boolean;
59
+ /** Highcharts options override for the sparkline or gauge. */
60
+ options: Highcharts.Options;
61
+ disconnectedCallback(): void;
62
+ protected firstUpdated(): void;
63
+ protected updated(changedProperties: PropertyValues): void;
64
+ private setupResizeObserver;
65
+ private buildSparklineOptions;
66
+ private buildGaugeOptions;
67
+ private initSparkline;
68
+ private initGauge;
69
+ private destroySparkline;
70
+ private destroyGauge;
71
+ private destroyCharts;
72
+ private renderTrend;
73
+ private renderContent;
74
+ render(): TemplateResult;
75
+ }
76
+ declare global {
77
+ interface HTMLElementTagNameMap {
78
+ 'nile-kpi-chart': NileKpiChart;
79
+ }
80
+ }
@@ -0,0 +1,335 @@
1
+ import { __decorate } from "tslib";
2
+ import { customElement, property, query } from 'lit/decorators.js';
3
+ import { html, nothing } from 'lit';
4
+ import NileElement from '../internal/nile-element.js';
5
+ import { getHighcharts } from '../internal/highcharts-provider.js';
6
+ import { styles } from './nile-kpi-chart.css.js';
7
+ let NileKpiChart = class NileKpiChart extends NileElement {
8
+ constructor() {
9
+ super(...arguments);
10
+ this._hc = null;
11
+ this.sparklineChart = null;
12
+ this.gaugeChart = null;
13
+ this.resizeObserver = null;
14
+ /** Display variant: default (flat), card (bordered container), gauge (Highcharts solid gauge). */
15
+ this.variant = 'default';
16
+ /** Label displayed above the value. */
17
+ this.label = '';
18
+ /** The main KPI value. */
19
+ this.value = '';
20
+ /** Prefix shown before the value (e.g. "$"). */
21
+ this.prefix = '';
22
+ /** Suffix shown after the value (e.g. "%"). */
23
+ this.suffix = '';
24
+ /** Trend percentage (e.g. 12.5). */
25
+ this.trendValue = null;
26
+ /** Trend direction: up, down, or neutral. */
27
+ this.trendDirection = 'neutral';
28
+ /** Trend context label (e.g. "vs last month"). */
29
+ this.trendLabel = '';
30
+ /** Description shown below the value. */
31
+ this.description = '';
32
+ /** Sparkline data points. When provided, a Highcharts mini area chart renders below the value. */
33
+ this.sparkline = [];
34
+ /** Color for the sparkline. */
35
+ this.sparklineColor = '';
36
+ /** Gauge: the numeric value (0-100 by default). */
37
+ this.gaugeValue = 0;
38
+ /** Gauge: minimum value. */
39
+ this.gaugeMin = 0;
40
+ /** Gauge: maximum value. */
41
+ this.gaugeMax = 100;
42
+ /** Gauge: ring color. Falls back to brand color. */
43
+ this.gaugeColor = '';
44
+ /** Whether the component is in a loading state. */
45
+ this.loading = false;
46
+ /** Highcharts options override for the sparkline or gauge. */
47
+ this.options = {};
48
+ }
49
+ disconnectedCallback() {
50
+ super.disconnectedCallback();
51
+ this.destroyCharts();
52
+ this.resizeObserver?.disconnect();
53
+ this.resizeObserver = null;
54
+ }
55
+ firstUpdated() {
56
+ this.initSparkline();
57
+ this.initGauge();
58
+ this.setupResizeObserver();
59
+ }
60
+ updated(changedProperties) {
61
+ const sparklineProps = ['sparkline', 'sparklineColor', 'options'];
62
+ if (sparklineProps.some(p => changedProperties.has(p))) {
63
+ if (this.sparklineChart) {
64
+ this.sparklineChart.update(this.buildSparklineOptions(), true, true);
65
+ }
66
+ else {
67
+ this.initSparkline();
68
+ }
69
+ }
70
+ const gaugeProps = ['gaugeValue', 'gaugeMin', 'gaugeMax', 'gaugeColor', 'options', 'variant'];
71
+ if (gaugeProps.some(p => changedProperties.has(p))) {
72
+ if (this.gaugeChart) {
73
+ this.gaugeChart.update(this.buildGaugeOptions(), true, true);
74
+ }
75
+ else {
76
+ this.initGauge();
77
+ }
78
+ }
79
+ }
80
+ setupResizeObserver() {
81
+ this.resizeObserver = new ResizeObserver(() => {
82
+ this.sparklineChart?.reflow();
83
+ this.gaugeChart?.reflow();
84
+ });
85
+ if (this.sparklineContainer)
86
+ this.resizeObserver.observe(this.sparklineContainer);
87
+ if (this.gaugeContainer)
88
+ this.resizeObserver.observe(this.gaugeContainer);
89
+ }
90
+ buildSparklineOptions() {
91
+ const brandColor = this.sparklineColor || '#005EA6';
92
+ const defaults = {
93
+ chart: { type: 'area', height: 48, margin: [2, 0, 2, 0], backgroundColor: 'transparent' },
94
+ title: { text: undefined },
95
+ subtitle: { text: undefined },
96
+ xAxis: { visible: false },
97
+ yAxis: { visible: false },
98
+ legend: { enabled: false },
99
+ tooltip: { enabled: false },
100
+ plotOptions: {
101
+ area: {
102
+ marker: { enabled: false },
103
+ lineWidth: 2,
104
+ lineColor: brandColor,
105
+ fillColor: {
106
+ linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
107
+ stops: [
108
+ [0, brandColor + '33'],
109
+ [1, brandColor + '00'],
110
+ ],
111
+ },
112
+ states: { hover: { lineWidth: 2 } },
113
+ },
114
+ },
115
+ series: [{ type: 'area', data: this.sparkline }],
116
+ credits: { enabled: false },
117
+ };
118
+ return { ...defaults, ...this.options };
119
+ }
120
+ buildGaugeOptions() {
121
+ const color = this.gaugeColor || '#005EA6';
122
+ const trackColor = '#E5E7EB';
123
+ const displayValue = typeof this.value !== 'undefined' && this.value !== ''
124
+ ? (typeof this.value === 'number' ? this.value : this.gaugeValue)
125
+ : this.gaugeValue;
126
+ return {
127
+ chart: {
128
+ type: 'solidgauge',
129
+ height: 160,
130
+ margin: [0, 0, 0, 0],
131
+ backgroundColor: 'transparent',
132
+ },
133
+ title: { text: undefined },
134
+ subtitle: { text: undefined },
135
+ pane: {
136
+ startAngle: 0,
137
+ endAngle: 360,
138
+ background: [{
139
+ backgroundColor: trackColor,
140
+ outerRadius: '100%',
141
+ innerRadius: '80%',
142
+ borderWidth: 0,
143
+ shape: 'arc',
144
+ }],
145
+ center: ['50%', '50%'],
146
+ size: '100%',
147
+ },
148
+ yAxis: {
149
+ min: this.gaugeMin,
150
+ max: this.gaugeMax,
151
+ lineWidth: 0,
152
+ tickWidth: 0,
153
+ minorTickLength: 0,
154
+ tickLength: 0,
155
+ labels: { enabled: false },
156
+ },
157
+ tooltip: { enabled: false },
158
+ plotOptions: {
159
+ solidgauge: {
160
+ dataLabels: {
161
+ enabled: true,
162
+ borderWidth: 0,
163
+ y: -25,
164
+ useHTML: true,
165
+ format: `<div style="text-align:center"><span style="font-size:28px;font-weight:600;color:#101828">${this.prefix}{y}${this.suffix}</span></div>`,
166
+ },
167
+ rounded: true,
168
+ linecap: 'round',
169
+ },
170
+ },
171
+ series: [{
172
+ type: 'solidgauge',
173
+ name: this.label || 'Value',
174
+ data: [{
175
+ y: displayValue,
176
+ color,
177
+ radius: '100%',
178
+ innerRadius: '80%',
179
+ }],
180
+ }],
181
+ credits: { enabled: false },
182
+ ...this.options,
183
+ };
184
+ }
185
+ async initSparkline() {
186
+ if (!this.sparkline.length || !this.sparklineContainer)
187
+ return;
188
+ if (!this._hc)
189
+ this._hc = await getHighcharts();
190
+ this.destroySparkline();
191
+ this.sparklineChart = this._hc.chart(this.sparklineContainer, this.buildSparklineOptions());
192
+ this.emit('nile-chart-ready', { chart: this.sparklineChart });
193
+ }
194
+ async initGauge() {
195
+ if (this.variant !== 'gauge' || !this.gaugeContainer)
196
+ return;
197
+ if (!this._hc)
198
+ this._hc = await getHighcharts();
199
+ this.destroyGauge();
200
+ this.gaugeChart = this._hc.chart(this.gaugeContainer, this.buildGaugeOptions());
201
+ this.emit('nile-chart-ready', { chart: this.gaugeChart });
202
+ }
203
+ destroySparkline() {
204
+ if (this.sparklineChart) {
205
+ this.sparklineChart.destroy();
206
+ this.sparklineChart = null;
207
+ }
208
+ }
209
+ destroyGauge() {
210
+ if (this.gaugeChart) {
211
+ this.gaugeChart.destroy();
212
+ this.gaugeChart = null;
213
+ }
214
+ }
215
+ destroyCharts() {
216
+ this.destroySparkline();
217
+ this.destroyGauge();
218
+ }
219
+ renderTrend() {
220
+ if (this.trendValue === null)
221
+ return nothing;
222
+ const dir = this.trendDirection;
223
+ const formatted = Math.abs(this.trendValue).toFixed(1) + '%';
224
+ return html `
225
+ <span class="kpi-trend kpi-trend--${dir}">
226
+ <span class="kpi-trend-arrow">
227
+ ${dir === 'up'
228
+ ? html `<svg viewBox="0 0 12 12"><path d="M6 2.5l4 5H2z"/></svg>`
229
+ : dir === 'down'
230
+ ? html `<svg viewBox="0 0 12 12"><path d="M6 9.5l4-5H2z"/></svg>`
231
+ : html `<svg viewBox="0 0 12 12"><path d="M2 6.5h8" stroke="currentColor" stroke-width="1.5" fill="none"/></svg>`}
232
+ </span>
233
+ ${formatted}${this.trendLabel ? html ` <span>${this.trendLabel}</span>` : nothing}
234
+ </span>
235
+ `;
236
+ }
237
+ renderContent() {
238
+ const isGauge = this.variant === 'gauge';
239
+ return html `
240
+ <div class="kpi ${isGauge ? 'kpi--gauge' : ''}">
241
+ ${this.label ? html `<p class="kpi-label">${this.label}</p>` : nothing}
242
+
243
+ ${isGauge ? html `<div class="kpi-gauge-container"></div>` : nothing}
244
+
245
+ <div class="kpi-value-row">
246
+ <h2 class="kpi-value">
247
+ ${this.prefix ? html `<span class="kpi-prefix">${this.prefix}</span>` : nothing}${this.value}${this.suffix ? html `<span class="kpi-suffix">${this.suffix}</span>` : nothing}
248
+ </h2>
249
+ ${!isGauge ? this.renderTrend() : nothing}
250
+ </div>
251
+
252
+ ${isGauge ? this.renderTrend() : nothing}
253
+
254
+ ${this.description ? html `<p class="kpi-description">${this.description}</p>` : nothing}
255
+
256
+ ${this.sparkline.length && !isGauge
257
+ ? html `<div class="kpi-sparkline"></div>`
258
+ : nothing}
259
+ </div>
260
+ `;
261
+ }
262
+ render() {
263
+ if (this.loading) {
264
+ return html `<div class="chart-loading">Loading...</div>`;
265
+ }
266
+ const useCard = this.variant === 'card' || this.variant === 'gauge';
267
+ if (useCard) {
268
+ return html `<div class="kpi-card">${this.renderContent()}</div>`;
269
+ }
270
+ return this.renderContent();
271
+ }
272
+ };
273
+ NileKpiChart.styles = styles;
274
+ __decorate([
275
+ query('.kpi-sparkline')
276
+ ], NileKpiChart.prototype, "sparklineContainer", void 0);
277
+ __decorate([
278
+ query('.kpi-gauge-container')
279
+ ], NileKpiChart.prototype, "gaugeContainer", void 0);
280
+ __decorate([
281
+ property({ type: String, reflect: true })
282
+ ], NileKpiChart.prototype, "variant", void 0);
283
+ __decorate([
284
+ property({ type: String })
285
+ ], NileKpiChart.prototype, "label", void 0);
286
+ __decorate([
287
+ property({ type: String })
288
+ ], NileKpiChart.prototype, "value", void 0);
289
+ __decorate([
290
+ property({ type: String })
291
+ ], NileKpiChart.prototype, "prefix", void 0);
292
+ __decorate([
293
+ property({ type: String })
294
+ ], NileKpiChart.prototype, "suffix", void 0);
295
+ __decorate([
296
+ property({ type: Number, attribute: 'trend-value' })
297
+ ], NileKpiChart.prototype, "trendValue", void 0);
298
+ __decorate([
299
+ property({ type: String, attribute: 'trend-direction' })
300
+ ], NileKpiChart.prototype, "trendDirection", void 0);
301
+ __decorate([
302
+ property({ type: String, attribute: 'trend-label' })
303
+ ], NileKpiChart.prototype, "trendLabel", void 0);
304
+ __decorate([
305
+ property({ type: String })
306
+ ], NileKpiChart.prototype, "description", void 0);
307
+ __decorate([
308
+ property({ type: Array })
309
+ ], NileKpiChart.prototype, "sparkline", void 0);
310
+ __decorate([
311
+ property({ type: String, attribute: 'sparkline-color' })
312
+ ], NileKpiChart.prototype, "sparklineColor", void 0);
313
+ __decorate([
314
+ property({ type: Number, attribute: 'gauge-value' })
315
+ ], NileKpiChart.prototype, "gaugeValue", void 0);
316
+ __decorate([
317
+ property({ type: Number, attribute: 'gauge-min' })
318
+ ], NileKpiChart.prototype, "gaugeMin", void 0);
319
+ __decorate([
320
+ property({ type: Number, attribute: 'gauge-max' })
321
+ ], NileKpiChart.prototype, "gaugeMax", void 0);
322
+ __decorate([
323
+ property({ type: String, attribute: 'gauge-color' })
324
+ ], NileKpiChart.prototype, "gaugeColor", void 0);
325
+ __decorate([
326
+ property({ type: Boolean, reflect: true })
327
+ ], NileKpiChart.prototype, "loading", void 0);
328
+ __decorate([
329
+ property({ type: Object })
330
+ ], NileKpiChart.prototype, "options", void 0);
331
+ NileKpiChart = __decorate([
332
+ customElement('nile-kpi-chart')
333
+ ], NileKpiChart);
334
+ export { NileKpiChart };
335
+ //# sourceMappingURL=nile-kpi-chart.js.map
@@ -0,0 +1,2 @@
1
+ export { NileLineChart } from './nile-line-chart.js';
2
+ export type { LineChartSeriesData } from './nile-line-chart.js';
@@ -0,0 +1,2 @@
1
+ export { NileLineChart } from './nile-line-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-line-chart.css.js.map
@@ -0,0 +1,36 @@
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 LineChartSeriesData {
5
+ name: string;
6
+ data: number[];
7
+ color?: string;
8
+ }
9
+ export declare class NileLineChart 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: LineChartSeriesData[];
18
+ categories: string[];
19
+ options: Highcharts.Options;
20
+ loading: boolean;
21
+ height: string;
22
+ yAxisTitle: string;
23
+ disconnectedCallback(): void;
24
+ protected firstUpdated(): void;
25
+ protected updated(changedProperties: PropertyValues): void;
26
+ private setupResizeObserver;
27
+ private buildOptions;
28
+ private initChart;
29
+ private destroyChart;
30
+ render(): TemplateResult;
31
+ }
32
+ declare global {
33
+ interface HTMLElementTagNameMap {
34
+ 'nile-line-chart': NileLineChart;
35
+ }
36
+ }