@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 ColumnChartSeriesData {
|
|
5
|
+
name: string;
|
|
6
|
+
data: number[];
|
|
7
|
+
color?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class NileColumnChart 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: ColumnChartSeriesData[];
|
|
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-column-chart': NileColumnChart;
|
|
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-column-chart.css.js';
|
|
8
|
+
let NileColumnChart = class NileColumnChart 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: 'column', height: this.height },
|
|
55
|
+
title: { text: this.chartTitle || undefined },
|
|
56
|
+
subtitle: { text: this.chartSubtitle || undefined },
|
|
57
|
+
xAxis: { categories: this.categories },
|
|
58
|
+
yAxis: { min: 0, title: { text: this.yAxisTitle || undefined } },
|
|
59
|
+
tooltip: { valueSuffix: '' },
|
|
60
|
+
plotOptions: {
|
|
61
|
+
column: { dataLabels: { enabled: false } },
|
|
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: 'column', 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
|
+
NileColumnChart.styles = styles;
|
|
87
|
+
__decorate([
|
|
88
|
+
query('.chart-container')
|
|
89
|
+
], NileColumnChart.prototype, "chartContainer", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
property({ type: String, attribute: 'chart-title' })
|
|
92
|
+
], NileColumnChart.prototype, "chartTitle", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
property({ type: String, attribute: 'chart-subtitle' })
|
|
95
|
+
], NileColumnChart.prototype, "chartSubtitle", void 0);
|
|
96
|
+
__decorate([
|
|
97
|
+
property({ type: Array })
|
|
98
|
+
], NileColumnChart.prototype, "data", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
property({ type: Array })
|
|
101
|
+
], NileColumnChart.prototype, "categories", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
property({ type: Object })
|
|
104
|
+
], NileColumnChart.prototype, "options", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
property({ type: Boolean, reflect: true })
|
|
107
|
+
], NileColumnChart.prototype, "loading", void 0);
|
|
108
|
+
__decorate([
|
|
109
|
+
property({ type: String })
|
|
110
|
+
], NileColumnChart.prototype, "height", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
property({ type: String, attribute: 'y-axis-title' })
|
|
113
|
+
], NileColumnChart.prototype, "yAxisTitle", void 0);
|
|
114
|
+
NileColumnChart = __decorate([
|
|
115
|
+
customElement('nile-column-chart')
|
|
116
|
+
], NileColumnChart);
|
|
117
|
+
export { NileColumnChart };
|
|
118
|
+
//# sourceMappingURL=nile-column-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-donut-chart.css.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
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 DonutChartSeriesData {
|
|
5
|
+
name: string;
|
|
6
|
+
y: number;
|
|
7
|
+
color?: string;
|
|
8
|
+
sliced?: boolean;
|
|
9
|
+
selected?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class NileDonutChart extends NileElement {
|
|
12
|
+
static styles: CSSResultGroup;
|
|
13
|
+
private _hc;
|
|
14
|
+
private chart;
|
|
15
|
+
private resizeObserver;
|
|
16
|
+
private chartContainer;
|
|
17
|
+
chartTitle: string;
|
|
18
|
+
chartSubtitle: string;
|
|
19
|
+
data: DonutChartSeriesData[];
|
|
20
|
+
seriesName: string;
|
|
21
|
+
innerSize: string;
|
|
22
|
+
options: Highcharts.Options;
|
|
23
|
+
loading: boolean;
|
|
24
|
+
height: string;
|
|
25
|
+
showDataLabels: boolean;
|
|
26
|
+
showLegend: boolean;
|
|
27
|
+
disconnectedCallback(): void;
|
|
28
|
+
protected firstUpdated(): void;
|
|
29
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
30
|
+
private setupResizeObserver;
|
|
31
|
+
private buildOptions;
|
|
32
|
+
private initChart;
|
|
33
|
+
private destroyChart;
|
|
34
|
+
render(): TemplateResult;
|
|
35
|
+
}
|
|
36
|
+
declare global {
|
|
37
|
+
interface HTMLElementTagNameMap {
|
|
38
|
+
'nile-donut-chart': NileDonutChart;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
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-donut-chart.css.js';
|
|
8
|
+
let NileDonutChart = class NileDonutChart 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.seriesName = '';
|
|
18
|
+
this.innerSize = '50%';
|
|
19
|
+
this.options = {};
|
|
20
|
+
this.loading = false;
|
|
21
|
+
this.height = '400px';
|
|
22
|
+
this.showDataLabels = true;
|
|
23
|
+
this.showLegend = true;
|
|
24
|
+
}
|
|
25
|
+
disconnectedCallback() {
|
|
26
|
+
super.disconnectedCallback();
|
|
27
|
+
this.destroyChart();
|
|
28
|
+
this.resizeObserver?.disconnect();
|
|
29
|
+
this.resizeObserver = null;
|
|
30
|
+
}
|
|
31
|
+
firstUpdated() { this.initChart(); this.setupResizeObserver(); }
|
|
32
|
+
updated(changedProperties) {
|
|
33
|
+
const props = ['data', 'chartTitle', 'chartSubtitle', 'options', 'height', 'seriesName', 'innerSize', 'loading', 'showDataLabels', 'showLegend'];
|
|
34
|
+
if (!props.some(p => changedProperties.has(p)))
|
|
35
|
+
return;
|
|
36
|
+
if (this.loading) {
|
|
37
|
+
this.destroyChart();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (this.chart) {
|
|
41
|
+
this.chart.update(this.buildOptions(), true, true);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.initChart();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
setupResizeObserver() {
|
|
48
|
+
if (!this.chartContainer)
|
|
49
|
+
return;
|
|
50
|
+
this.resizeObserver = new ResizeObserver(() => { this.chart?.reflow(); });
|
|
51
|
+
this.resizeObserver.observe(this.chartContainer);
|
|
52
|
+
}
|
|
53
|
+
buildOptions() {
|
|
54
|
+
const self = this;
|
|
55
|
+
return deepMerge({
|
|
56
|
+
chart: { type: 'pie', height: this.height },
|
|
57
|
+
title: { text: this.chartTitle || undefined },
|
|
58
|
+
subtitle: { text: this.chartSubtitle || undefined },
|
|
59
|
+
tooltip: { pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' },
|
|
60
|
+
accessibility: { point: { valueSuffix: '%' } },
|
|
61
|
+
plotOptions: {
|
|
62
|
+
pie: {
|
|
63
|
+
innerSize: this.innerSize,
|
|
64
|
+
allowPointSelect: true,
|
|
65
|
+
cursor: 'pointer',
|
|
66
|
+
dataLabels: { enabled: this.showDataLabels, format: '<b>{point.name}</b>: {point.percentage:.1f} %' },
|
|
67
|
+
showInLegend: this.showLegend,
|
|
68
|
+
point: { events: { click() { self.emit('nile-chart-click', { point: this, name: this.name, value: this.y, percentage: this.percentage, seriesName: this.series.name }); } } },
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
series: [{ type: 'pie', name: this.seriesName, data: this.data.map(d => ({ name: d.name, y: d.y, color: d.color, sliced: d.sliced, selected: d.selected })) }],
|
|
72
|
+
credits: { enabled: false },
|
|
73
|
+
}, this.options);
|
|
74
|
+
}
|
|
75
|
+
async initChart() {
|
|
76
|
+
if (this.loading || !this.chartContainer)
|
|
77
|
+
return;
|
|
78
|
+
if (!this._hc)
|
|
79
|
+
this._hc = await getHighcharts();
|
|
80
|
+
this.chart = this._hc.chart(this.chartContainer, this.buildOptions());
|
|
81
|
+
this.emit('nile-chart-ready', { chart: this.chart });
|
|
82
|
+
}
|
|
83
|
+
destroyChart() { if (this.chart) {
|
|
84
|
+
this.chart.destroy();
|
|
85
|
+
this.chart = null;
|
|
86
|
+
} }
|
|
87
|
+
render() {
|
|
88
|
+
if (this.loading)
|
|
89
|
+
return html `<div class="chart-loading" style="height:${this.height}">Loading...</div>`;
|
|
90
|
+
return html `<div class="chart-container"></div>`;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
NileDonutChart.styles = styles;
|
|
94
|
+
__decorate([
|
|
95
|
+
query('.chart-container')
|
|
96
|
+
], NileDonutChart.prototype, "chartContainer", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
property({ type: String, attribute: 'chart-title' })
|
|
99
|
+
], NileDonutChart.prototype, "chartTitle", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
property({ type: String, attribute: 'chart-subtitle' })
|
|
102
|
+
], NileDonutChart.prototype, "chartSubtitle", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
property({ type: Array })
|
|
105
|
+
], NileDonutChart.prototype, "data", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
property({ type: String, attribute: 'series-name' })
|
|
108
|
+
], NileDonutChart.prototype, "seriesName", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
property({ type: String, attribute: 'inner-size' })
|
|
111
|
+
], NileDonutChart.prototype, "innerSize", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
property({ type: Object })
|
|
114
|
+
], NileDonutChart.prototype, "options", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: Boolean, reflect: true })
|
|
117
|
+
], NileDonutChart.prototype, "loading", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
property({ type: String })
|
|
120
|
+
], NileDonutChart.prototype, "height", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
property({ type: Boolean, attribute: 'show-data-labels' })
|
|
123
|
+
], NileDonutChart.prototype, "showDataLabels", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ type: Boolean, attribute: 'show-legend' })
|
|
126
|
+
], NileDonutChart.prototype, "showLegend", void 0);
|
|
127
|
+
NileDonutChart = __decorate([
|
|
128
|
+
customElement('nile-donut-chart')
|
|
129
|
+
], NileDonutChart);
|
|
130
|
+
export { NileDonutChart };
|
|
131
|
+
//# sourceMappingURL=nile-donut-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-gauge-chart.css.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
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 GaugeBand {
|
|
5
|
+
from: number;
|
|
6
|
+
to: number;
|
|
7
|
+
color: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class NileGaugeChart 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
|
+
value: number;
|
|
18
|
+
min: number;
|
|
19
|
+
max: number;
|
|
20
|
+
suffix: string;
|
|
21
|
+
bands: GaugeBand[];
|
|
22
|
+
options: Highcharts.Options;
|
|
23
|
+
loading: boolean;
|
|
24
|
+
height: string;
|
|
25
|
+
disconnectedCallback(): void;
|
|
26
|
+
protected firstUpdated(): void;
|
|
27
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
28
|
+
private setupResizeObserver;
|
|
29
|
+
private buildOptions;
|
|
30
|
+
private initChart;
|
|
31
|
+
private destroyChart;
|
|
32
|
+
render(): TemplateResult;
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface HTMLElementTagNameMap {
|
|
36
|
+
'nile-gauge-chart': NileGaugeChart;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
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 { getHighcharts } from '../internal/highcharts-provider.js';
|
|
6
|
+
import { deepMerge } from '../internal/utils.js';
|
|
7
|
+
import { styles } from './nile-gauge-chart.css.js';
|
|
8
|
+
let NileGaugeChart = class NileGaugeChart 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.value = 0;
|
|
17
|
+
this.min = 0;
|
|
18
|
+
this.max = 100;
|
|
19
|
+
this.suffix = '';
|
|
20
|
+
this.bands = [];
|
|
21
|
+
this.options = {};
|
|
22
|
+
this.loading = false;
|
|
23
|
+
this.height = '280px';
|
|
24
|
+
}
|
|
25
|
+
disconnectedCallback() {
|
|
26
|
+
super.disconnectedCallback();
|
|
27
|
+
this.destroyChart();
|
|
28
|
+
this.resizeObserver?.disconnect();
|
|
29
|
+
this.resizeObserver = null;
|
|
30
|
+
}
|
|
31
|
+
firstUpdated() { this.initChart(); this.setupResizeObserver(); }
|
|
32
|
+
updated(changedProperties) {
|
|
33
|
+
const props = ['value', 'min', 'max', 'suffix', 'bands', 'chartTitle', 'chartSubtitle', 'options', 'height', 'loading'];
|
|
34
|
+
if (!props.some(p => changedProperties.has(p)))
|
|
35
|
+
return;
|
|
36
|
+
if (this.loading) {
|
|
37
|
+
this.destroyChart();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (this.chart) {
|
|
41
|
+
this.chart.update(this.buildOptions(), true, true);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.initChart();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
setupResizeObserver() {
|
|
48
|
+
if (!this.chartContainer)
|
|
49
|
+
return;
|
|
50
|
+
this.resizeObserver = new ResizeObserver(() => { this.chart?.reflow(); });
|
|
51
|
+
this.resizeObserver.observe(this.chartContainer);
|
|
52
|
+
}
|
|
53
|
+
buildOptions() {
|
|
54
|
+
return deepMerge({
|
|
55
|
+
chart: { type: 'gauge', height: this.height },
|
|
56
|
+
title: { text: this.chartTitle || undefined },
|
|
57
|
+
subtitle: { text: this.chartSubtitle || undefined },
|
|
58
|
+
pane: {
|
|
59
|
+
startAngle: -150,
|
|
60
|
+
endAngle: 150,
|
|
61
|
+
background: [{
|
|
62
|
+
backgroundColor: '#EEE',
|
|
63
|
+
borderWidth: 0,
|
|
64
|
+
outerRadius: '109%',
|
|
65
|
+
innerRadius: '103%',
|
|
66
|
+
}],
|
|
67
|
+
},
|
|
68
|
+
yAxis: {
|
|
69
|
+
min: this.min,
|
|
70
|
+
max: this.max,
|
|
71
|
+
plotBands: this.bands.map(b => ({
|
|
72
|
+
from: b.from,
|
|
73
|
+
to: b.to,
|
|
74
|
+
color: b.color,
|
|
75
|
+
thickness: 20,
|
|
76
|
+
})),
|
|
77
|
+
labels: { distance: 25 },
|
|
78
|
+
},
|
|
79
|
+
tooltip: { enabled: false },
|
|
80
|
+
series: [{
|
|
81
|
+
type: 'gauge',
|
|
82
|
+
name: this.chartTitle || 'Value',
|
|
83
|
+
data: [this.value],
|
|
84
|
+
dataLabels: {
|
|
85
|
+
format: `{y}${this.suffix}`,
|
|
86
|
+
borderWidth: 0,
|
|
87
|
+
style: { fontSize: '20px' },
|
|
88
|
+
},
|
|
89
|
+
}],
|
|
90
|
+
credits: { enabled: false },
|
|
91
|
+
}, this.options);
|
|
92
|
+
}
|
|
93
|
+
async initChart() {
|
|
94
|
+
if (this.loading || !this.chartContainer)
|
|
95
|
+
return;
|
|
96
|
+
if (!this._hc)
|
|
97
|
+
this._hc = await getHighcharts();
|
|
98
|
+
this.chart = this._hc.chart(this.chartContainer, this.buildOptions());
|
|
99
|
+
this.emit('nile-chart-ready', { chart: this.chart });
|
|
100
|
+
}
|
|
101
|
+
destroyChart() { if (this.chart) {
|
|
102
|
+
this.chart.destroy();
|
|
103
|
+
this.chart = null;
|
|
104
|
+
} }
|
|
105
|
+
render() {
|
|
106
|
+
if (this.loading)
|
|
107
|
+
return html `<div class="chart-loading" style="height:${this.height}">Loading...</div>`;
|
|
108
|
+
return html `<div class="chart-container"></div>`;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
NileGaugeChart.styles = styles;
|
|
112
|
+
__decorate([
|
|
113
|
+
query('.chart-container')
|
|
114
|
+
], NileGaugeChart.prototype, "chartContainer", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: String, attribute: 'chart-title' })
|
|
117
|
+
], NileGaugeChart.prototype, "chartTitle", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
property({ type: String, attribute: 'chart-subtitle' })
|
|
120
|
+
], NileGaugeChart.prototype, "chartSubtitle", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
property({ type: Number })
|
|
123
|
+
], NileGaugeChart.prototype, "value", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
property({ type: Number })
|
|
126
|
+
], NileGaugeChart.prototype, "min", void 0);
|
|
127
|
+
__decorate([
|
|
128
|
+
property({ type: Number })
|
|
129
|
+
], NileGaugeChart.prototype, "max", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
property({ type: String })
|
|
132
|
+
], NileGaugeChart.prototype, "suffix", void 0);
|
|
133
|
+
__decorate([
|
|
134
|
+
property({ type: Array })
|
|
135
|
+
], NileGaugeChart.prototype, "bands", void 0);
|
|
136
|
+
__decorate([
|
|
137
|
+
property({ type: Object })
|
|
138
|
+
], NileGaugeChart.prototype, "options", void 0);
|
|
139
|
+
__decorate([
|
|
140
|
+
property({ type: Boolean, reflect: true })
|
|
141
|
+
], NileGaugeChart.prototype, "loading", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
property({ type: String })
|
|
144
|
+
], NileGaugeChart.prototype, "height", void 0);
|
|
145
|
+
NileGaugeChart = __decorate([
|
|
146
|
+
customElement('nile-gauge-chart')
|
|
147
|
+
], NileGaugeChart);
|
|
148
|
+
export { NileGaugeChart };
|
|
149
|
+
//# sourceMappingURL=nile-gauge-chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|