@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.
- package/dist/src/index.d.ts +35 -0
- package/dist/src/index.js +20 -0
- package/dist/src/internal/chart-adapters.d.ts +11 -0
- package/dist/src/internal/chart-adapters.js +159 -0
- package/dist/src/internal/highcharts-provider.d.ts +14 -0
- package/dist/src/internal/highcharts-provider.js +56 -0
- package/dist/src/internal/nile-element.d.ts +8 -0
- package/dist/src/internal/nile-element.js +21 -0
- package/dist/src/internal/utils.d.ts +1 -0
- package/dist/src/internal/utils.js +23 -0
- package/dist/src/nile-ai-panel/index.d.ts +1 -0
- package/dist/src/nile-ai-panel/index.js +2 -0
- package/dist/src/nile-ai-panel/nile-ai-panel.css.d.ts +1 -0
- package/dist/src/nile-ai-panel/nile-ai-panel.css.js +73 -0
- package/dist/src/nile-ai-panel/nile-ai-panel.d.ts +29 -0
- package/dist/src/nile-ai-panel/nile-ai-panel.js +98 -0
- package/dist/src/nile-ai-sender/index.d.ts +1 -0
- package/dist/src/nile-ai-sender/index.js +2 -0
- package/dist/src/nile-ai-sender/nile-ai-sender.css.d.ts +1 -0
- package/dist/src/nile-ai-sender/nile-ai-sender.css.js +71 -0
- package/dist/src/nile-ai-sender/nile-ai-sender.d.ts +20 -0
- package/dist/src/nile-ai-sender/nile-ai-sender.js +77 -0
- package/dist/src/nile-anomaly-chart/index.d.ts +2 -0
- package/dist/src/nile-anomaly-chart/index.js +2 -0
- package/dist/src/nile-anomaly-chart/nile-anomaly-chart.css.d.ts +1 -0
- package/dist/src/nile-anomaly-chart/nile-anomaly-chart.css.js +28 -0
- package/dist/src/nile-anomaly-chart/nile-anomaly-chart.d.ts +59 -0
- package/dist/src/nile-anomaly-chart/nile-anomaly-chart.js +268 -0
- package/dist/src/nile-area-chart/index.d.ts +2 -0
- package/dist/src/nile-area-chart/index.js +2 -0
- package/dist/src/nile-area-chart/nile-area-chart.css.d.ts +1 -0
- package/dist/src/nile-area-chart/nile-area-chart.css.js +28 -0
- package/dist/src/nile-area-chart/nile-area-chart.d.ts +37 -0
- package/dist/src/nile-area-chart/nile-area-chart.js +122 -0
- package/dist/src/nile-bar-chart/index.d.ts +2 -0
- package/dist/src/nile-bar-chart/index.js +2 -0
- package/dist/src/nile-bar-chart/nile-bar-chart.css.d.ts +1 -0
- package/dist/src/nile-bar-chart/nile-bar-chart.css.js +28 -0
- package/dist/src/nile-bar-chart/nile-bar-chart.d.ts +44 -0
- package/dist/src/nile-bar-chart/nile-bar-chart.js +185 -0
- package/dist/src/nile-bubble-chart/index.d.ts +2 -0
- package/dist/src/nile-bubble-chart/index.js +2 -0
- package/dist/src/nile-bubble-chart/nile-bubble-chart.css.d.ts +1 -0
- package/dist/src/nile-bubble-chart/nile-bubble-chart.css.js +28 -0
- package/dist/src/nile-bubble-chart/nile-bubble-chart.d.ts +36 -0
- package/dist/src/nile-bubble-chart/nile-bubble-chart.js +123 -0
- package/dist/src/nile-chart/index.d.ts +3 -0
- package/dist/src/nile-chart/index.js +3 -0
- package/dist/src/nile-chart/nile-chart-config.d.ts +58 -0
- package/dist/src/nile-chart/nile-chart-config.js +2 -0
- package/dist/src/nile-chart/nile-chart.css.d.ts +1 -0
- package/dist/src/nile-chart/nile-chart.css.js +298 -0
- package/dist/src/nile-chart/nile-chart.d.ts +51 -0
- package/dist/src/nile-chart/nile-chart.js +303 -0
- package/dist/src/nile-column-chart/index.d.ts +2 -0
- package/dist/src/nile-column-chart/index.js +2 -0
- package/dist/src/nile-column-chart/nile-column-chart.css.d.ts +1 -0
- package/dist/src/nile-column-chart/nile-column-chart.css.js +28 -0
- package/dist/src/nile-column-chart/nile-column-chart.d.ts +36 -0
- package/dist/src/nile-column-chart/nile-column-chart.js +118 -0
- package/dist/src/nile-donut-chart/index.d.ts +2 -0
- package/dist/src/nile-donut-chart/index.js +2 -0
- package/dist/src/nile-donut-chart/nile-donut-chart.css.d.ts +1 -0
- package/dist/src/nile-donut-chart/nile-donut-chart.css.js +28 -0
- package/dist/src/nile-donut-chart/nile-donut-chart.d.ts +40 -0
- package/dist/src/nile-donut-chart/nile-donut-chart.js +131 -0
- package/dist/src/nile-gauge-chart/index.d.ts +2 -0
- package/dist/src/nile-gauge-chart/index.js +2 -0
- package/dist/src/nile-gauge-chart/nile-gauge-chart.css.d.ts +1 -0
- package/dist/src/nile-gauge-chart/nile-gauge-chart.css.js +28 -0
- package/dist/src/nile-gauge-chart/nile-gauge-chart.d.ts +38 -0
- package/dist/src/nile-gauge-chart/nile-gauge-chart.js +149 -0
- package/dist/src/nile-kpi-chart/index.d.ts +2 -0
- package/dist/src/nile-kpi-chart/index.js +2 -0
- package/dist/src/nile-kpi-chart/nile-kpi-chart.css.d.ts +1 -0
- package/dist/src/nile-kpi-chart/nile-kpi-chart.css.js +165 -0
- package/dist/src/nile-kpi-chart/nile-kpi-chart.d.ts +80 -0
- package/dist/src/nile-kpi-chart/nile-kpi-chart.js +335 -0
- package/dist/src/nile-line-chart/index.d.ts +2 -0
- package/dist/src/nile-line-chart/index.js +2 -0
- package/dist/src/nile-line-chart/nile-line-chart.css.d.ts +1 -0
- package/dist/src/nile-line-chart/nile-line-chart.css.js +28 -0
- package/dist/src/nile-line-chart/nile-line-chart.d.ts +36 -0
- package/dist/src/nile-line-chart/nile-line-chart.js +115 -0
- package/dist/src/nile-pie-chart/index.d.ts +2 -0
- package/dist/src/nile-pie-chart/index.js +2 -0
- package/dist/src/nile-pie-chart/nile-pie-chart.css.d.ts +1 -0
- package/dist/src/nile-pie-chart/nile-pie-chart.css.js +28 -0
- package/dist/src/nile-pie-chart/nile-pie-chart.d.ts +48 -0
- package/dist/src/nile-pie-chart/nile-pie-chart.js +197 -0
- package/dist/src/nile-radar-chart/index.d.ts +2 -0
- package/dist/src/nile-radar-chart/index.js +2 -0
- package/dist/src/nile-radar-chart/nile-radar-chart.css.d.ts +1 -0
- package/dist/src/nile-radar-chart/nile-radar-chart.css.js +28 -0
- package/dist/src/nile-radar-chart/nile-radar-chart.d.ts +36 -0
- package/dist/src/nile-radar-chart/nile-radar-chart.js +137 -0
- package/dist/src/nile-scatter-chart/index.d.ts +2 -0
- package/dist/src/nile-scatter-chart/index.js +2 -0
- package/dist/src/nile-scatter-chart/nile-scatter-chart.css.d.ts +1 -0
- package/dist/src/nile-scatter-chart/nile-scatter-chart.css.js +28 -0
- package/dist/src/nile-scatter-chart/nile-scatter-chart.d.ts +36 -0
- package/dist/src/nile-scatter-chart/nile-scatter-chart.js +124 -0
- package/dist/src/nile-spline-chart/index.d.ts +2 -0
- package/dist/src/nile-spline-chart/index.js +2 -0
- package/dist/src/nile-spline-chart/nile-spline-chart.css.d.ts +1 -0
- package/dist/src/nile-spline-chart/nile-spline-chart.css.js +28 -0
- package/dist/src/nile-spline-chart/nile-spline-chart.d.ts +36 -0
- package/dist/src/nile-spline-chart/nile-spline-chart.js +118 -0
- package/dist/src/nile-trendline-chart/index.d.ts +2 -0
- package/dist/src/nile-trendline-chart/index.js +2 -0
- package/dist/src/nile-trendline-chart/nile-trendline-chart.css.d.ts +1 -0
- package/dist/src/nile-trendline-chart/nile-trendline-chart.css.js +28 -0
- package/dist/src/nile-trendline-chart/nile-trendline-chart.d.ts +59 -0
- package/dist/src/nile-trendline-chart/nile-trendline-chart.js +246 -0
- package/dist/src/nile-waterfall-chart/index.d.ts +2 -0
- package/dist/src/nile-waterfall-chart/index.js +2 -0
- package/dist/src/nile-waterfall-chart/nile-waterfall-chart.css.d.ts +1 -0
- package/dist/src/nile-waterfall-chart/nile-waterfall-chart.css.js +28 -0
- package/dist/src/nile-waterfall-chart/nile-waterfall-chart.d.ts +37 -0
- package/dist/src/nile-waterfall-chart/nile-waterfall-chart.js +137 -0
- package/package.json +62 -0
|
@@ -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 ScatterChartSeriesData {
|
|
5
|
+
name: string;
|
|
6
|
+
data: [number, number][];
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class NileScatterChart 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: ScatterChartSeriesData[];
|
|
18
|
+
options: Highcharts.Options;
|
|
19
|
+
loading: boolean;
|
|
20
|
+
height: string;
|
|
21
|
+
xAxisTitle: 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-scatter-chart': NileScatterChart;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
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-scatter-chart.css.js';
|
|
8
|
+
let NileScatterChart = class NileScatterChart 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.options = {};
|
|
18
|
+
this.loading = false;
|
|
19
|
+
this.height = '400px';
|
|
20
|
+
this.xAxisTitle = '';
|
|
21
|
+
this.yAxisTitle = '';
|
|
22
|
+
}
|
|
23
|
+
disconnectedCallback() {
|
|
24
|
+
super.disconnectedCallback();
|
|
25
|
+
this.destroyChart();
|
|
26
|
+
this.resizeObserver?.disconnect();
|
|
27
|
+
this.resizeObserver = null;
|
|
28
|
+
}
|
|
29
|
+
firstUpdated() { this.initChart(); this.setupResizeObserver(); }
|
|
30
|
+
updated(changedProperties) {
|
|
31
|
+
const props = ['data', 'chartTitle', 'chartSubtitle', 'options', 'height', 'xAxisTitle', 'yAxisTitle', 'loading'];
|
|
32
|
+
if (!props.some(p => changedProperties.has(p)))
|
|
33
|
+
return;
|
|
34
|
+
if (this.loading) {
|
|
35
|
+
this.destroyChart();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (this.chart) {
|
|
39
|
+
this.chart.update(this.buildOptions(), true, true);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.initChart();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
setupResizeObserver() {
|
|
46
|
+
if (!this.chartContainer)
|
|
47
|
+
return;
|
|
48
|
+
this.resizeObserver = new ResizeObserver(() => { this.chart?.reflow(); });
|
|
49
|
+
this.resizeObserver.observe(this.chartContainer);
|
|
50
|
+
}
|
|
51
|
+
buildOptions() {
|
|
52
|
+
const self = this;
|
|
53
|
+
return deepMerge({
|
|
54
|
+
chart: { type: 'scatter', height: this.height, zoomType: 'xy' },
|
|
55
|
+
title: { text: this.chartTitle || undefined },
|
|
56
|
+
subtitle: { text: this.chartSubtitle || undefined },
|
|
57
|
+
xAxis: { title: { text: this.xAxisTitle || undefined } },
|
|
58
|
+
yAxis: { title: { text: this.yAxisTitle || undefined } },
|
|
59
|
+
tooltip: {
|
|
60
|
+
headerFormat: '<b>{series.name}</b><br>',
|
|
61
|
+
pointFormat: '{point.x}, {point.y}',
|
|
62
|
+
},
|
|
63
|
+
plotOptions: {
|
|
64
|
+
scatter: {
|
|
65
|
+
marker: { radius: 5, states: { hover: { enabled: true, lineColor: 'rgb(100,100,100)' } } },
|
|
66
|
+
states: { hover: { marker: { enabled: false } } },
|
|
67
|
+
},
|
|
68
|
+
series: { cursor: 'pointer', point: { events: { click() { self.emit('nile-chart-click', { point: this, x: this.x, y: this.y, seriesName: this.series.name }); } } } },
|
|
69
|
+
},
|
|
70
|
+
series: this.data.map(s => ({ type: 'scatter', name: s.name, data: s.data, color: s.color })),
|
|
71
|
+
credits: { enabled: false },
|
|
72
|
+
}, this.options);
|
|
73
|
+
}
|
|
74
|
+
async initChart() {
|
|
75
|
+
if (this.loading || !this.chartContainer)
|
|
76
|
+
return;
|
|
77
|
+
if (!this._hc)
|
|
78
|
+
this._hc = await getHighcharts();
|
|
79
|
+
this.chart = this._hc.chart(this.chartContainer, this.buildOptions());
|
|
80
|
+
this.emit('nile-chart-ready', { chart: this.chart });
|
|
81
|
+
}
|
|
82
|
+
destroyChart() { if (this.chart) {
|
|
83
|
+
this.chart.destroy();
|
|
84
|
+
this.chart = null;
|
|
85
|
+
} }
|
|
86
|
+
render() {
|
|
87
|
+
if (this.loading)
|
|
88
|
+
return html `<div class="chart-loading" style="height:${this.height}">Loading...</div>`;
|
|
89
|
+
return html `<div class="chart-container"></div>`;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
NileScatterChart.styles = styles;
|
|
93
|
+
__decorate([
|
|
94
|
+
query('.chart-container')
|
|
95
|
+
], NileScatterChart.prototype, "chartContainer", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
property({ type: String, attribute: 'chart-title' })
|
|
98
|
+
], NileScatterChart.prototype, "chartTitle", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
property({ type: String, attribute: 'chart-subtitle' })
|
|
101
|
+
], NileScatterChart.prototype, "chartSubtitle", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
property({ type: Array })
|
|
104
|
+
], NileScatterChart.prototype, "data", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
property({ type: Object })
|
|
107
|
+
], NileScatterChart.prototype, "options", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
property({ type: Boolean, reflect: true })
|
|
110
|
+
], NileScatterChart.prototype, "loading", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
property({ type: String })
|
|
113
|
+
], NileScatterChart.prototype, "height", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
property({ type: String, attribute: 'x-axis-title' })
|
|
116
|
+
], NileScatterChart.prototype, "xAxisTitle", void 0);
|
|
117
|
+
__decorate([
|
|
118
|
+
property({ type: String, attribute: 'y-axis-title' })
|
|
119
|
+
], NileScatterChart.prototype, "yAxisTitle", void 0);
|
|
120
|
+
NileScatterChart = __decorate([
|
|
121
|
+
customElement('nile-scatter-chart')
|
|
122
|
+
], NileScatterChart);
|
|
123
|
+
export { NileScatterChart };
|
|
124
|
+
//# sourceMappingURL=nile-scatter-chart.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-spline-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 SplineChartSeriesData {
|
|
5
|
+
name: string;
|
|
6
|
+
data: number[];
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class NileSplineChart 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: SplineChartSeriesData[];
|
|
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-spline-chart': NileSplineChart;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
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-spline-chart.css.js';
|
|
8
|
+
let NileSplineChart = class NileSplineChart 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
|
+
}
|
|
23
|
+
disconnectedCallback() {
|
|
24
|
+
super.disconnectedCallback();
|
|
25
|
+
this.destroyChart();
|
|
26
|
+
this.resizeObserver?.disconnect();
|
|
27
|
+
this.resizeObserver = null;
|
|
28
|
+
}
|
|
29
|
+
firstUpdated() { this.initChart(); this.setupResizeObserver(); }
|
|
30
|
+
updated(changedProperties) {
|
|
31
|
+
const props = ['data', 'categories', 'chartTitle', 'chartSubtitle', 'options', 'height', 'yAxisTitle', 'loading'];
|
|
32
|
+
if (!props.some(p => changedProperties.has(p)))
|
|
33
|
+
return;
|
|
34
|
+
if (this.loading) {
|
|
35
|
+
this.destroyChart();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (this.chart) {
|
|
39
|
+
this.chart.update(this.buildOptions(), true, true);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.initChart();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
setupResizeObserver() {
|
|
46
|
+
if (!this.chartContainer)
|
|
47
|
+
return;
|
|
48
|
+
this.resizeObserver = new ResizeObserver(() => { this.chart?.reflow(); });
|
|
49
|
+
this.resizeObserver.observe(this.chartContainer);
|
|
50
|
+
}
|
|
51
|
+
buildOptions() {
|
|
52
|
+
const self = this;
|
|
53
|
+
return deepMerge({
|
|
54
|
+
chart: { type: 'spline', height: this.height },
|
|
55
|
+
title: { text: this.chartTitle || undefined },
|
|
56
|
+
subtitle: { text: this.chartSubtitle || undefined },
|
|
57
|
+
xAxis: { categories: this.categories },
|
|
58
|
+
yAxis: { title: { text: this.yAxisTitle || undefined } },
|
|
59
|
+
tooltip: { shared: true },
|
|
60
|
+
plotOptions: {
|
|
61
|
+
spline: { marker: { enabled: true, radius: 4 } },
|
|
62
|
+
series: { cursor: 'pointer', point: { events: { click() { self.emit('nile-chart-click', { point: this, category: this.category, value: this.y, seriesName: this.series.name }); } } } },
|
|
63
|
+
},
|
|
64
|
+
series: this.data.map(s => ({ type: 'spline', name: s.name, data: s.data, color: s.color })),
|
|
65
|
+
credits: { enabled: false },
|
|
66
|
+
}, this.options);
|
|
67
|
+
}
|
|
68
|
+
async initChart() {
|
|
69
|
+
if (this.loading || !this.chartContainer)
|
|
70
|
+
return;
|
|
71
|
+
if (!this._hc)
|
|
72
|
+
this._hc = await getHighcharts();
|
|
73
|
+
this.chart = this._hc.chart(this.chartContainer, this.buildOptions());
|
|
74
|
+
this.emit('nile-chart-ready', { chart: this.chart });
|
|
75
|
+
}
|
|
76
|
+
destroyChart() { if (this.chart) {
|
|
77
|
+
this.chart.destroy();
|
|
78
|
+
this.chart = null;
|
|
79
|
+
} }
|
|
80
|
+
render() {
|
|
81
|
+
if (this.loading)
|
|
82
|
+
return html `<div class="chart-loading" style="height:${this.height}">Loading...</div>`;
|
|
83
|
+
return html `<div class="chart-container"></div>`;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
NileSplineChart.styles = styles;
|
|
87
|
+
__decorate([
|
|
88
|
+
query('.chart-container')
|
|
89
|
+
], NileSplineChart.prototype, "chartContainer", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
property({ type: String, attribute: 'chart-title' })
|
|
92
|
+
], NileSplineChart.prototype, "chartTitle", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
property({ type: String, attribute: 'chart-subtitle' })
|
|
95
|
+
], NileSplineChart.prototype, "chartSubtitle", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
property({ type: Array })
|
|
98
|
+
], NileSplineChart.prototype, "data", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
property({ type: Array })
|
|
101
|
+
], NileSplineChart.prototype, "categories", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
property({ type: Object })
|
|
104
|
+
], NileSplineChart.prototype, "options", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
property({ type: Boolean, reflect: true })
|
|
107
|
+
], NileSplineChart.prototype, "loading", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
property({ type: String })
|
|
110
|
+
], NileSplineChart.prototype, "height", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
property({ type: String, attribute: 'y-axis-title' })
|
|
113
|
+
], NileSplineChart.prototype, "yAxisTitle", void 0);
|
|
114
|
+
NileSplineChart = __decorate([
|
|
115
|
+
customElement('nile-spline-chart')
|
|
116
|
+
], NileSplineChart);
|
|
117
|
+
export { NileSplineChart };
|
|
118
|
+
//# sourceMappingURL=nile-spline-chart.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-trendline-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 TrendlineSeriesData {
|
|
5
|
+
name: string;
|
|
6
|
+
data: number[];
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ForecastConfig {
|
|
10
|
+
/** Number of periods to forecast beyond the actual data. */
|
|
11
|
+
periods: number;
|
|
12
|
+
/** Color for the forecast dashed line. */
|
|
13
|
+
color?: string;
|
|
14
|
+
/** Dash style for the forecast line. Default: 'Dash'. */
|
|
15
|
+
dashStyle?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class NileTrendlineChart 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. Each series is a line on the chart. */
|
|
28
|
+
data: TrendlineSeriesData[];
|
|
29
|
+
/** X-axis category labels (e.g., months, dates). */
|
|
30
|
+
categories: string[];
|
|
31
|
+
/** Forecast configuration. When set, extends each series with a forecast line. */
|
|
32
|
+
forecast: ForecastConfig | null;
|
|
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
|
+
* Simple linear regression forecast.
|
|
47
|
+
* Extends the data array by `periods` using least-squares fit.
|
|
48
|
+
*/
|
|
49
|
+
private computeForecast;
|
|
50
|
+
private buildOptions;
|
|
51
|
+
private initChart;
|
|
52
|
+
private destroyChart;
|
|
53
|
+
render(): TemplateResult;
|
|
54
|
+
}
|
|
55
|
+
declare global {
|
|
56
|
+
interface HTMLElementTagNameMap {
|
|
57
|
+
'nile-trendline-chart': NileTrendlineChart;
|
|
58
|
+
}
|
|
59
|
+
}
|