@triptease/tt-bar-chart 1.0.7 → 1.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 (38) hide show
  1. package/dist/cjs/package.json +3 -0
  2. package/dist/cjs/src/TtBarChart.js +239 -0
  3. package/dist/cjs/src/TtBarChart.js.map +1 -0
  4. package/dist/cjs/src/colors.js +5 -0
  5. package/dist/cjs/src/colors.js.map +1 -0
  6. package/dist/cjs/src/index.js +21 -0
  7. package/dist/cjs/src/index.js.map +1 -0
  8. package/dist/cjs/src/tt-bar-chart.js +11 -0
  9. package/dist/cjs/src/tt-bar-chart.js.map +1 -0
  10. package/dist/cjs/src/types.js +3 -0
  11. package/dist/cjs/src/types.js.map +1 -0
  12. package/dist/cjs/src/utils.js +70 -0
  13. package/dist/cjs/src/utils.js.map +1 -0
  14. package/dist/esm/src/TtBarChart.js.map +1 -0
  15. package/dist/esm/src/colors.js.map +1 -0
  16. package/dist/esm/src/index.js.map +1 -0
  17. package/dist/esm/src/tt-bar-chart.js.map +1 -0
  18. package/dist/esm/src/types.js.map +1 -0
  19. package/dist/esm/src/utils.js.map +1 -0
  20. package/package.json +16 -11
  21. package/dist/src/TtBarChart.js.map +0 -1
  22. package/dist/src/colors.js.map +0 -1
  23. package/dist/src/index.js.map +0 -1
  24. package/dist/src/tt-bar-chart.js.map +0 -1
  25. package/dist/src/types.js.map +0 -1
  26. package/dist/src/utils.js.map +0 -1
  27. /package/dist/{src → esm/src}/TtBarChart.d.ts +0 -0
  28. /package/dist/{src → esm/src}/TtBarChart.js +0 -0
  29. /package/dist/{src → esm/src}/colors.d.ts +0 -0
  30. /package/dist/{src → esm/src}/colors.js +0 -0
  31. /package/dist/{src → esm/src}/index.d.ts +0 -0
  32. /package/dist/{src → esm/src}/index.js +0 -0
  33. /package/dist/{src → esm/src}/tt-bar-chart.d.ts +0 -0
  34. /package/dist/{src → esm/src}/tt-bar-chart.js +0 -0
  35. /package/dist/{src → esm/src}/types.d.ts +0 -0
  36. /package/dist/{src → esm/src}/types.js +0 -0
  37. /package/dist/{src → esm/src}/utils.d.ts +0 -0
  38. /package/dist/{src → esm/src}/utils.js +0 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.TtBarChart = void 0;
43
+ const lit_1 = require("lit");
44
+ // @ts-expect-error Known error - https://github.com/apache/echarts/issues/21250
45
+ const echarts = __importStar(require("echarts"));
46
+ const decorators_js_1 = require("lit/decorators.js");
47
+ const utils_js_1 = require("./utils.js");
48
+ // @ts-expect-error Known error - https://github.com/apache/echarts/issues/21250
49
+ const components_1 = require("echarts/components");
50
+ const colors_js_1 = require("./colors.js");
51
+ const tt_dataset_1 = require("@triptease/tt-dataset");
52
+ const tt_data_point_1 = require("@triptease/tt-data-point");
53
+ const constructChartData = (ttDatasetElements) => {
54
+ if (!ttDatasetElements.every(tt_dataset_1.isTtDataset)) {
55
+ throw new Error("Children of element 'tt-bar-chart' must be 'tt-dataset' elements.");
56
+ }
57
+ const datasets = ttDatasetElements.map((ttDataset) => {
58
+ const datasetLabel = ttDataset.getAttribute('label');
59
+ if (!datasetLabel)
60
+ throw new Error("Attribute 'label' on element 'tt-dataset' is required");
61
+ const ttDataPoints = Array.from(ttDataset.querySelectorAll('tt-data-point'));
62
+ if (!ttDataPoints.every(tt_data_point_1.isTtDataPoint)) {
63
+ throw new Error("Children of element 'tt-dataset' must be 'tt-data-point' elements");
64
+ }
65
+ const data = ttDataPoints.map((ttDataPoint) => {
66
+ const dataPointLabel = ttDataPoint.getAttribute('label');
67
+ if (!dataPointLabel)
68
+ throw new Error("Attribute 'label' on element 'tt-data-point' is required");
69
+ const valueRaw = ttDataPoint.getAttribute('value');
70
+ const value = valueRaw ? Number(valueRaw) : undefined;
71
+ if (value !== undefined && Number.isNaN(value)) {
72
+ throw new Error("Attribute 'value' on element 'tt-data-point' is not a valid number");
73
+ }
74
+ return { label: dataPointLabel, value };
75
+ });
76
+ return { label: datasetLabel, data };
77
+ });
78
+ return datasets;
79
+ };
80
+ class TtBarChart extends lit_1.LitElement {
81
+ constructor() {
82
+ super(...arguments);
83
+ this.direction = 'horizontal';
84
+ this.stacked = false;
85
+ this.loading = false;
86
+ this.width = '100%';
87
+ this.height = '100%';
88
+ this.chart = null;
89
+ this.slotObserver = null;
90
+ }
91
+ render() {
92
+ return (0, lit_1.html) `
93
+ <div style="width: ${this.width}; height:${this.height};">
94
+ <div id=${this.id} style="width:${this.width}; height:${this.height};"></div>
95
+ <slot @slotchange=${this.handleSlotChange}></slot>
96
+ </div>
97
+ `;
98
+ }
99
+ handleSlotChange() {
100
+ this.slotObserver?.disconnect();
101
+ this.slotObserver = new MutationObserver(() => this.requestUpdate());
102
+ this.defaultSlot.assignedElements().forEach((el) => {
103
+ this.slotObserver.observe(el, { childList: true, attributes: true, subtree: true });
104
+ });
105
+ this.requestUpdate();
106
+ }
107
+ disconnectedCallback() {
108
+ super.disconnectedCallback();
109
+ this.slotObserver?.disconnect();
110
+ }
111
+ firstUpdated() {
112
+ if (this.chart === null) {
113
+ echarts.use([components_1.AriaComponent]);
114
+ const divElement = this.renderRoot.querySelector(`#${this.id}`);
115
+ if (!divElement) {
116
+ throw new Error('No div element');
117
+ }
118
+ this.chart = echarts.init(divElement);
119
+ }
120
+ }
121
+ updated() {
122
+ if (this.loadingPulseTimer) {
123
+ window.clearInterval(this.loadingPulseTimer);
124
+ }
125
+ if (this.loading && this.chart) {
126
+ this.setAttribute('aria-busy', 'true');
127
+ const pulseTimer = (0, utils_js_1.loadingAnimation)(this.chart, this.direction);
128
+ this.loadingPulseTimer = pulseTimer;
129
+ }
130
+ else {
131
+ this.removeAttribute('aria-busy');
132
+ const datasets = constructChartData(this.defaultSlot.assignedElements());
133
+ const labelsRaw = datasets.flatMap((dataset) => dataset.data.map((datapoint) => datapoint.label));
134
+ const labels = [...new Set(labelsRaw)];
135
+ const series = datasets.map((dataset, i) => ({
136
+ name: dataset.label,
137
+ type: 'bar',
138
+ data: labels.map((label) => {
139
+ const point = dataset.data.find((dp) => dp.label === label);
140
+ return point?.value ?? null;
141
+ }),
142
+ stack: this.stacked ? 'A' : undefined,
143
+ color: colors_js_1.defaultColorPalette[i],
144
+ cursor: 'default',
145
+ }));
146
+ const option = {
147
+ aria: {
148
+ show: true,
149
+ },
150
+ legend: {
151
+ show: datasets.length > 1,
152
+ textStyle: {
153
+ color: '#3b353b', //--text-400
154
+ },
155
+ },
156
+ xAxis: {
157
+ name: this.xAxisTitle,
158
+ nameTextStyle: {
159
+ lineHeight: 40,
160
+ color: '#575157', //--text-300
161
+ },
162
+ nameLocation: 'center',
163
+ type: this.direction === 'horizontal' ? 'value' : 'category',
164
+ data: this.direction === 'horizontal' ? undefined : labels,
165
+ axisLabel: {
166
+ formatter: (value) => (0, utils_js_1.valueFormatter)(value, this.direction === 'horizontal' ? this.valuePrefix : undefined, this.direction === 'horizontal' ? this.valueSuffix : undefined),
167
+ color: '#3b353b', //--text-400
168
+ },
169
+ splitLine: { show: this.direction === 'horizontal' },
170
+ },
171
+ yAxis: {
172
+ name: this.yAxisTitle,
173
+ nameTextStyle: {
174
+ lineHeight: 40,
175
+ color: '#575157', //--text-300
176
+ },
177
+ nameLocation: 'center',
178
+ type: this.direction === 'horizontal' ? 'category' : 'value',
179
+ data: this.direction === 'horizontal' ? labels : undefined,
180
+ axisLabel: {
181
+ formatter: (value) => (0, utils_js_1.valueFormatter)(value, this.direction === 'horizontal' ? undefined : this.valuePrefix, this.direction === 'horizontal' ? undefined : this.valueSuffix),
182
+ color: '#3b353b', //--text-400
183
+ },
184
+ splitLine: { show: this.direction === 'vertical' },
185
+ },
186
+ grid: {
187
+ left: 0,
188
+ right: 0,
189
+ top: 0,
190
+ ...(datasets.length > 1 ? {} : { bottom: 0 }),
191
+ },
192
+ tooltip: {
193
+ trigger: 'axis',
194
+ axisPointer: {
195
+ type: 'shadow',
196
+ },
197
+ valueFormatter: (value) => (0, utils_js_1.valueFormatter)(value, this.valuePrefix, this.valueSuffix),
198
+ },
199
+ series,
200
+ };
201
+ this.chart.setOption(option, { notMerge: true });
202
+ }
203
+ }
204
+ }
205
+ exports.TtBarChart = TtBarChart;
206
+ __decorate([
207
+ (0, decorators_js_1.property)({ type: String })
208
+ ], TtBarChart.prototype, "direction", void 0);
209
+ __decorate([
210
+ (0, decorators_js_1.property)({ type: String, attribute: 'x-axis-title' })
211
+ ], TtBarChart.prototype, "xAxisTitle", void 0);
212
+ __decorate([
213
+ (0, decorators_js_1.property)({ type: String, attribute: 'y-axis-title' })
214
+ ], TtBarChart.prototype, "yAxisTitle", void 0);
215
+ __decorate([
216
+ (0, decorators_js_1.property)({ type: Boolean, attribute: 'stacked' })
217
+ ], TtBarChart.prototype, "stacked", void 0);
218
+ __decorate([
219
+ (0, decorators_js_1.property)({ type: Boolean, attribute: 'loading' })
220
+ ], TtBarChart.prototype, "loading", void 0);
221
+ __decorate([
222
+ (0, decorators_js_1.property)({ type: String, attribute: 'width' })
223
+ ], TtBarChart.prototype, "width", void 0);
224
+ __decorate([
225
+ (0, decorators_js_1.property)({ type: String, attribute: 'height' })
226
+ ], TtBarChart.prototype, "height", void 0);
227
+ __decorate([
228
+ (0, decorators_js_1.property)({ type: String, attribute: 'value-prefix' })
229
+ ], TtBarChart.prototype, "valuePrefix", void 0);
230
+ __decorate([
231
+ (0, decorators_js_1.property)({ type: String, attribute: 'value-suffix' })
232
+ ], TtBarChart.prototype, "valueSuffix", void 0);
233
+ __decorate([
234
+ (0, decorators_js_1.state)()
235
+ ], TtBarChart.prototype, "chart", void 0);
236
+ __decorate([
237
+ (0, decorators_js_1.query)('slot')
238
+ ], TtBarChart.prototype, "defaultSlot", void 0);
239
+ //# sourceMappingURL=TtBarChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TtBarChart.js","sourceRoot":"","sources":["../../../src/TtBarChart.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAuC;AACvC,gFAAg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OAAO,EAAE,CAAC;yCACxB;AAGvB;IADC,IAAA,wBAAQ,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;0CACxB;AAGxB;IADC,IAAA,wBAAQ,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;+CACjC;AAGrB;IADC,IAAA,wBAAQ,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;+CACjC;AAGrB;IADC,IAAA,qBAAK,GAAE;yCAC6B;AAG7B;IADP,IAAA,qBAAK,EAAC,MAAM,CAAC;+CACwB","sourcesContent":["import { html, LitElement } from 'lit';\n// @ts-expect-error Known error - https://github.com/apache/echarts/issues/21250\nimport * as echarts from 'echarts';\nimport { property, query, state } from 'lit/decorators.js';\nimport { ChartDirection, Dataset } from './types.js';\nimport { loadingAnimation, valueFormatter } from './utils.js';\n// @ts-expect-error Known error - https://github.com/apache/echarts/issues/21250\nimport { AriaComponent } from 'echarts/components';\nimport { defaultColorPalette } from './colors.js';\nimport { isTtDataset } from '@triptease/tt-dataset';\nimport { isTtDataPoint } from '@triptease/tt-data-point';\n\nconst constructChartData = (ttDatasetElements: Element[]) => {\n if (!ttDatasetElements.every(isTtDataset)) {\n throw new Error(\"Children of element 'tt-bar-chart' must be 'tt-dataset' elements.\");\n }\n\n const datasets: Dataset[] = ttDatasetElements.map((ttDataset) => {\n const datasetLabel = ttDataset.getAttribute('label');\n if (!datasetLabel) throw new Error(\"Attribute 'label' on element 'tt-dataset' is required\");\n\n const ttDataPoints = Array.from(ttDataset.querySelectorAll('tt-data-point'));\n if (!ttDataPoints.every(isTtDataPoint)) {\n throw new Error(\"Children of element 'tt-dataset' must be 'tt-data-point' elements\");\n }\n\n const data = ttDataPoints.map((ttDataPoint) => {\n const dataPointLabel = ttDataPoint.getAttribute('label');\n if (!dataPointLabel) throw new Error(\"Attribute 'label' on element 'tt-data-point' is required\");\n\n const valueRaw = ttDataPoint.getAttribute('value');\n const value = valueRaw ? Number(valueRaw) : undefined;\n if (value !== undefined && Number.isNaN(value)) {\n throw new Error(\"Attribute 'value' on element 'tt-data-point' is not a valid number\");\n }\n\n return { label: dataPointLabel, value };\n });\n\n return { label: datasetLabel, data };\n });\n\n return datasets;\n};\n\nexport class TtBarChart extends LitElement {\n @property({ type: String })\n direction: ChartDirection = 'horizontal';\n\n @property({ type: String, attribute: 'x-axis-title' })\n xAxisTitle?: string;\n\n @property({ type: String, attribute: 'y-axis-title' })\n yAxisTitle?: string;\n\n @property({ type: Boolean, attribute: 'stacked' })\n stacked: boolean = false;\n\n @property({ type: Boolean, attribute: 'loading' })\n loading: boolean = false;\n\n @property({ type: String, attribute: 'width' })\n width: string = '100%';\n\n @property({ type: String, attribute: 'height' })\n height: string = '100%';\n\n @property({ type: String, attribute: 'value-prefix' })\n valuePrefix?: string;\n\n @property({ type: String, attribute: 'value-suffix' })\n valueSuffix?: string;\n\n @state()\n chart: echarts.ECharts | null = null;\n\n @query('slot')\n private defaultSlot!: HTMLSlotElement;\n\n private loadingPulseTimer: number | undefined;\n private slotObserver: MutationObserver | null = null;\n\n render() {\n return html`\n <div style=\"width: ${this.width}; height:${this.height};\">\n <div id=${this.id} style=\"width:${this.width}; height:${this.height};\"></div>\n <slot @slotchange=${this.handleSlotChange}></slot>\n </div>\n `;\n }\n\n protected handleSlotChange() {\n this.slotObserver?.disconnect();\n this.slotObserver = new MutationObserver(() => this.requestUpdate());\n this.defaultSlot.assignedElements().forEach((el) => {\n this.slotObserver!.observe(el, { childList: true, attributes: true, subtree: true });\n });\n this.requestUpdate();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.slotObserver?.disconnect();\n }\n\n protected firstUpdated() {\n if (this.chart === null) {\n echarts.use([AriaComponent]);\n const divElement = this.renderRoot.querySelector(`#${this.id}`) as HTMLDivElement;\n\n if (!divElement) {\n throw new Error('No div element');\n }\n\n this.chart = echarts.init(divElement);\n }\n }\n\n protected updated() {\n if (this.loadingPulseTimer) {\n window.clearInterval(this.loadingPulseTimer);\n }\n\n if (this.loading && this.chart) {\n this.setAttribute('aria-busy', 'true');\n const pulseTimer = loadingAnimation(this.chart, this.direction);\n this.loadingPulseTimer = pulseTimer;\n } else {\n this.removeAttribute('aria-busy');\n\n const datasets = constructChartData(this.defaultSlot.assignedElements());\n\n const labelsRaw = datasets.flatMap((dataset) => dataset.data.map((datapoint) => datapoint.label));\n const labels = [...new Set(labelsRaw)];\n\n const series: echarts.SeriesOption[] = datasets.map((dataset, i) => ({\n name: dataset.label,\n type: 'bar',\n data: labels.map((label) => {\n const point = dataset.data.find((dp) => dp.label === label);\n return point?.value ?? null;\n }),\n stack: this.stacked ? 'A' : undefined,\n color: defaultColorPalette[i],\n cursor: 'default',\n }));\n\n const option: echarts.EChartsOption = {\n aria: {\n show: true,\n },\n legend: {\n show: datasets.length > 1,\n textStyle: {\n color: '#3b353b', //--text-400\n },\n },\n xAxis: {\n name: this.xAxisTitle,\n nameTextStyle: {\n lineHeight: 40,\n color: '#575157', //--text-300\n },\n nameLocation: 'center',\n type: this.direction === 'horizontal' ? 'value' : 'category',\n data: this.direction === 'horizontal' ? undefined : labels,\n axisLabel: {\n formatter: (value: number | string) =>\n valueFormatter(\n value,\n this.direction === 'horizontal' ? this.valuePrefix : undefined,\n this.direction === 'horizontal' ? this.valueSuffix : undefined\n ),\n color: '#3b353b', //--text-400\n },\n splitLine: { show: this.direction === 'horizontal' },\n },\n yAxis: {\n name: this.yAxisTitle,\n nameTextStyle: {\n lineHeight: 40,\n color: '#575157', //--text-300\n },\n nameLocation: 'center',\n type: this.direction === 'horizontal' ? 'category' : 'value',\n data: this.direction === 'horizontal' ? labels : undefined,\n axisLabel: {\n formatter: (value: number | string) =>\n valueFormatter(\n value,\n this.direction === 'horizontal' ? undefined : this.valuePrefix,\n this.direction === 'horizontal' ? undefined : this.valueSuffix\n ),\n color: '#3b353b', //--text-400\n },\n splitLine: { show: this.direction === 'vertical' },\n },\n grid: {\n left: 0,\n right: 0,\n top: 0,\n ...(datasets.length > 1 ? {} : { bottom: 0 }),\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n type: 'shadow',\n },\n valueFormatter: (value: number | string) => valueFormatter(value, this.valuePrefix, this.valueSuffix),\n },\n series,\n };\n\n this.chart.setOption(option, { notMerge: true });\n }\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultColorPalette = void 0;
4
+ exports.defaultColorPalette = ['#ED6E2E', '#1967D3', '#119EAE', '#283492', '#596B7A', '#4d35a1'];
5
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.js","sourceRoot":"","sources":["../../../src/colors.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC","sourcesContent":["export const defaultColorPalette = ['#ED6E2E', '#1967D3', '#119EAE', '#283492', '#596B7A', '#4d35a1'];\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.TtBarChart = void 0;
18
+ var tt_bar_chart_js_1 = require("./tt-bar-chart.js");
19
+ Object.defineProperty(exports, "TtBarChart", { enumerable: true, get: function () { return tt_bar_chart_js_1.TtBarChart; } });
20
+ __exportStar(require("./types.js"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAA+C;AAAtC,6GAAA,UAAU,OAAA;AACnB,6CAA2B","sourcesContent":["export { TtBarChart } from './tt-bar-chart.js';\nexport * from './types.js';\n"]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TtBarChart = void 0;
4
+ const TtBarChart_js_1 = require("./TtBarChart.js");
5
+ Object.defineProperty(exports, "TtBarChart", { enumerable: true, get: function () { return TtBarChart_js_1.TtBarChart; } });
6
+ if (typeof window !== 'undefined') {
7
+ if (!window.customElements.get('tt-bar-chart')) {
8
+ window.customElements.define('tt-bar-chart', TtBarChart_js_1.TtBarChart);
9
+ }
10
+ }
11
+ //# sourceMappingURL=tt-bar-chart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tt-bar-chart.js","sourceRoot":"","sources":["../../../src/tt-bar-chart.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;AAQpC,2FARA,0BAAU,OAQA;AANnB,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QAC/C,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,0BAAU,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC","sourcesContent":["import { TtBarChart } from './TtBarChart.js';\n\nif (typeof window !== 'undefined') {\n if (!window.customElements.get('tt-bar-chart')) {\n window.customElements.define('tt-bar-chart', TtBarChart);\n }\n}\n\nexport { TtBarChart };\n"]}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { TtBarChart } from './TtBarChart.js';\n\nexport interface DataPoint {\n label: string;\n value: number | undefined;\n}\n\nexport interface Dataset {\n label: string;\n data: DataPoint[];\n}\n\nexport type ChartDirection = 'horizontal' | 'vertical';\n\ninterface TtBarChartExternalAttributes {\n id: string;\n width?: string;\n height?: string;\n direction?: ChartDirection;\n 'x-axis-title'?: string;\n 'y-axis-title'?: string;\n stacked?: boolean;\n loading?: boolean;\n 'value-prefix'?: string;\n 'value-suffix'?: string;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'tt-bar-chart': TtBarChart;\n }\n\n namespace JSX {\n interface IntrinsicElements {\n 'tt-bar-chart': TtBarChartExternalAttributes & { children?: Element | Element[]; style?: string };\n }\n }\n\n namespace React {\n namespace JSX {\n interface IntrinsicElements {\n 'tt-bar-chart': TtBarChartExternalAttributes & {\n ref?: React.Ref<unknown>;\n children?: React.ReactNode;\n style?: React.CSSProperties;\n };\n }\n }\n }\n}\n"]}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadingAnimation = exports.valueFormatter = void 0;
4
+ const numericalAxesFormatter = new Intl.NumberFormat(undefined, { notation: 'compact' });
5
+ const valueFormatter = (value, prefix, suffix) => {
6
+ let formattedValue = value;
7
+ if (typeof value === 'number') {
8
+ formattedValue = numericalAxesFormatter.format(value);
9
+ }
10
+ return `${prefix ?? ''}${formattedValue ?? value}${suffix ?? ''}`;
11
+ };
12
+ exports.valueFormatter = valueFormatter;
13
+ const SKELETON_ITEMS = 4;
14
+ const PULSE_INTERVAL = 1500;
15
+ const loadingAnimation = (chart, direction) => {
16
+ const isHorizontal = direction === 'horizontal';
17
+ const generateData = () => Array.from({ length: SKELETON_ITEMS }, () => Math.round(30 + Math.random() * 50));
18
+ const baseAxis = {
19
+ axisLabel: { show: false },
20
+ axisTick: { show: false },
21
+ axisLine: { show: false },
22
+ splitLine: { show: false },
23
+ };
24
+ chart.setOption({
25
+ animation: true,
26
+ animationDuration: 800,
27
+ animationEasing: 'cubicInOut',
28
+ grid: {
29
+ left: 0,
30
+ right: 0,
31
+ top: 0,
32
+ bottom: 0,
33
+ containLabel: false,
34
+ },
35
+ xAxis: isHorizontal
36
+ ? { ...baseAxis, type: 'value' }
37
+ : {
38
+ ...baseAxis,
39
+ type: 'category',
40
+ data: Array.from({ length: SKELETON_ITEMS }, () => ''),
41
+ },
42
+ yAxis: isHorizontal
43
+ ? {
44
+ ...baseAxis,
45
+ type: 'category',
46
+ data: Array.from({ length: SKELETON_ITEMS }, () => ''),
47
+ }
48
+ : { ...baseAxis, type: 'value' },
49
+ series: [
50
+ {
51
+ type: 'bar',
52
+ data: generateData(),
53
+ silent: true,
54
+ animationDurationUpdate: 800,
55
+ itemStyle: {
56
+ color: '#e5e7eb',
57
+ },
58
+ emphasis: { disabled: true },
59
+ },
60
+ ],
61
+ }, true);
62
+ const pulseTimer = window.setInterval(() => {
63
+ chart.setOption({
64
+ series: [{ data: generateData() }],
65
+ });
66
+ }, PULSE_INTERVAL);
67
+ return pulseTimer;
68
+ };
69
+ exports.loadingAnimation = loadingAnimation;
70
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":";;;AAIA,MAAM,sBAAsB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;AAElF,MAAM,cAAc,GAAG,CAAC,KAAsB,EAAE,MAA0B,EAAE,MAA0B,EAAE,EAAE;IAC/G,IAAI,cAAc,GAAG,KAAK,CAAC;IA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CAAC,CAAC;gBACE,GAAG,QAAQ;gBACX,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;aACvD;QAEL,KAAK,EAAE,YAAY;YACjB,CAAC,CAAC;gBACE,GAAG,QAAQ;gBACX,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;aACvD;YACH,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE;QAElC,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,YAAY,EAAE;gBACpB,MAAM,EAAE,IAAI;gBACZ,uBAAuB,EAAE,GAAG;gBAC5B,SAAS,EAAE;oBACT,KAAK,EAAE,SAAS;iBACjB;gBACD,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;aAC7B;SACF;KACF,EACD,IAAI,CACL,CAAC;IAEF,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE;QACzC,KAAK,CAAC,SAAS,CAAC;YACd,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC;SACnC,CAAC,CAAC;IACL,CAAC,EAAE,cAAc,CAAC,CAAC;IAEnB,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAjEW,QAAA,gBAAgB,oBAiE3B","sourcesContent":["// @ts-expect-error Known error - https://github.com/apache/echarts/issues/21250\nimport * as echarts from 'echarts';\nimport { ChartDirection } from './types.js';\n\nconst numericalAxesFormatter = new Intl.NumberFormat(undefined, { notation: 'compact' });\n\nexport const valueFormatter = (value: number | string, prefix: string | undefined, suffix: string | undefined) => {\n let formattedValue = value;\n\n if (typeof value === 'number') {\n formattedValue = numericalAxesFormatter.format(value);\n }\n\n return `${prefix ?? ''}${formattedValue ?? value}${suffix ?? ''}`;\n};\n\nconst SKELETON_ITEMS = 4;\nconst PULSE_INTERVAL = 1500;\n\nexport const loadingAnimation = (chart: echarts.ECharts, direction: ChartDirection) => {\n const isHorizontal = direction === 'horizontal';\n\n const generateData = () => Array.from({ length: SKELETON_ITEMS }, () => Math.round(30 + Math.random() * 50));\n\n const baseAxis = {\n axisLabel: { show: false },\n axisTick: { show: false },\n axisLine: { show: false },\n splitLine: { show: false },\n };\n\n chart.setOption(\n {\n animation: true,\n animationDuration: 800,\n animationEasing: 'cubicInOut',\n\n grid: {\n left: 0,\n right: 0,\n top: 0,\n bottom: 0,\n containLabel: false,\n },\n\n xAxis: isHorizontal\n ? { ...baseAxis, type: 'value' }\n : {\n ...baseAxis,\n type: 'category',\n data: Array.from({ length: SKELETON_ITEMS }, () => ''),\n },\n\n yAxis: isHorizontal\n ? {\n ...baseAxis,\n type: 'category',\n data: Array.from({ length: SKELETON_ITEMS }, () => ''),\n }\n : { ...baseAxis, type: 'value' },\n\n series: [\n {\n type: 'bar',\n data: generateData(),\n silent: true,\n animationDurationUpdate: 800,\n itemStyle: {\n color: '#e5e7eb',\n },\n emphasis: { disabled: true },\n },\n ],\n },\n true\n );\n\n const pulseTimer = window.setInterval(() => {\n chart.setOption({\n series: [{ data: generateData() }],\n });\n }, PULSE_INTERVAL);\n\n return pulseTimer;\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TtBarChart.js","sourceRoot":"","sources":["../../../src/TtBarChart.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,gFAAgF;AAChF,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM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,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;yCACxB;AAGvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;0CACxB;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;+CACjC;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;+CACjC;AAGrB;IADC,KAAK,EAAE;yCAC6B;AAG7B;IADP,KAAK,CAAC,MAAM,CAAC;+CACwB","sourcesContent":["import { html, LitElement } from 'lit';\n// @ts-expect-error Known error - https://github.com/apache/echarts/issues/21250\nimport * as echarts from 'echarts';\nimport { property, query, state } from 'lit/decorators.js';\nimport { ChartDirection, Dataset } from './types.js';\nimport { loadingAnimation, valueFormatter } from './utils.js';\n// @ts-expect-error Known error - https://github.com/apache/echarts/issues/21250\nimport { AriaComponent } from 'echarts/components';\nimport { defaultColorPalette } from './colors.js';\nimport { isTtDataset } from '@triptease/tt-dataset';\nimport { isTtDataPoint } from '@triptease/tt-data-point';\n\nconst constructChartData = (ttDatasetElements: Element[]) => {\n if (!ttDatasetElements.every(isTtDataset)) {\n throw new Error(\"Children of element 'tt-bar-chart' must be 'tt-dataset' elements.\");\n }\n\n const datasets: Dataset[] = ttDatasetElements.map((ttDataset) => {\n const datasetLabel = ttDataset.getAttribute('label');\n if (!datasetLabel) throw new Error(\"Attribute 'label' on element 'tt-dataset' is required\");\n\n const ttDataPoints = Array.from(ttDataset.querySelectorAll('tt-data-point'));\n if (!ttDataPoints.every(isTtDataPoint)) {\n throw new Error(\"Children of element 'tt-dataset' must be 'tt-data-point' elements\");\n }\n\n const data = ttDataPoints.map((ttDataPoint) => {\n const dataPointLabel = ttDataPoint.getAttribute('label');\n if (!dataPointLabel) throw new Error(\"Attribute 'label' on element 'tt-data-point' is required\");\n\n const valueRaw = ttDataPoint.getAttribute('value');\n const value = valueRaw ? Number(valueRaw) : undefined;\n if (value !== undefined && Number.isNaN(value)) {\n throw new Error(\"Attribute 'value' on element 'tt-data-point' is not a valid number\");\n }\n\n return { label: dataPointLabel, value };\n });\n\n return { label: datasetLabel, data };\n });\n\n return datasets;\n};\n\nexport class TtBarChart extends LitElement {\n @property({ type: String })\n direction: ChartDirection = 'horizontal';\n\n @property({ type: String, attribute: 'x-axis-title' })\n xAxisTitle?: string;\n\n @property({ type: String, attribute: 'y-axis-title' })\n yAxisTitle?: string;\n\n @property({ type: Boolean, attribute: 'stacked' })\n stacked: boolean = false;\n\n @property({ type: Boolean, attribute: 'loading' })\n loading: boolean = false;\n\n @property({ type: String, attribute: 'width' })\n width: string = '100%';\n\n @property({ type: String, attribute: 'height' })\n height: string = '100%';\n\n @property({ type: String, attribute: 'value-prefix' })\n valuePrefix?: string;\n\n @property({ type: String, attribute: 'value-suffix' })\n valueSuffix?: string;\n\n @state()\n chart: echarts.ECharts | null = null;\n\n @query('slot')\n private defaultSlot!: HTMLSlotElement;\n\n private loadingPulseTimer: number | undefined;\n private slotObserver: MutationObserver | null = null;\n\n render() {\n return html`\n <div style=\"width: ${this.width}; height:${this.height};\">\n <div id=${this.id} style=\"width:${this.width}; height:${this.height};\"></div>\n <slot @slotchange=${this.handleSlotChange}></slot>\n </div>\n `;\n }\n\n protected handleSlotChange() {\n this.slotObserver?.disconnect();\n this.slotObserver = new MutationObserver(() => this.requestUpdate());\n this.defaultSlot.assignedElements().forEach((el) => {\n this.slotObserver!.observe(el, { childList: true, attributes: true, subtree: true });\n });\n this.requestUpdate();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.slotObserver?.disconnect();\n }\n\n protected firstUpdated() {\n if (this.chart === null) {\n echarts.use([AriaComponent]);\n const divElement = this.renderRoot.querySelector(`#${this.id}`) as HTMLDivElement;\n\n if (!divElement) {\n throw new Error('No div element');\n }\n\n this.chart = echarts.init(divElement);\n }\n }\n\n protected updated() {\n if (this.loadingPulseTimer) {\n window.clearInterval(this.loadingPulseTimer);\n }\n\n if (this.loading && this.chart) {\n this.setAttribute('aria-busy', 'true');\n const pulseTimer = loadingAnimation(this.chart, this.direction);\n this.loadingPulseTimer = pulseTimer;\n } else {\n this.removeAttribute('aria-busy');\n\n const datasets = constructChartData(this.defaultSlot.assignedElements());\n\n const labelsRaw = datasets.flatMap((dataset) => dataset.data.map((datapoint) => datapoint.label));\n const labels = [...new Set(labelsRaw)];\n\n const series: echarts.SeriesOption[] = datasets.map((dataset, i) => ({\n name: dataset.label,\n type: 'bar',\n data: labels.map((label) => {\n const point = dataset.data.find((dp) => dp.label === label);\n return point?.value ?? null;\n }),\n stack: this.stacked ? 'A' : undefined,\n color: defaultColorPalette[i],\n cursor: 'default',\n }));\n\n const option: echarts.EChartsOption = {\n aria: {\n show: true,\n },\n legend: {\n show: datasets.length > 1,\n textStyle: {\n color: '#3b353b', //--text-400\n },\n },\n xAxis: {\n name: this.xAxisTitle,\n nameTextStyle: {\n lineHeight: 40,\n color: '#575157', //--text-300\n },\n nameLocation: 'center',\n type: this.direction === 'horizontal' ? 'value' : 'category',\n data: this.direction === 'horizontal' ? undefined : labels,\n axisLabel: {\n formatter: (value: number | string) =>\n valueFormatter(\n value,\n this.direction === 'horizontal' ? this.valuePrefix : undefined,\n this.direction === 'horizontal' ? this.valueSuffix : undefined\n ),\n color: '#3b353b', //--text-400\n },\n splitLine: { show: this.direction === 'horizontal' },\n },\n yAxis: {\n name: this.yAxisTitle,\n nameTextStyle: {\n lineHeight: 40,\n color: '#575157', //--text-300\n },\n nameLocation: 'center',\n type: this.direction === 'horizontal' ? 'category' : 'value',\n data: this.direction === 'horizontal' ? labels : undefined,\n axisLabel: {\n formatter: (value: number | string) =>\n valueFormatter(\n value,\n this.direction === 'horizontal' ? undefined : this.valuePrefix,\n this.direction === 'horizontal' ? undefined : this.valueSuffix\n ),\n color: '#3b353b', //--text-400\n },\n splitLine: { show: this.direction === 'vertical' },\n },\n grid: {\n left: 0,\n right: 0,\n top: 0,\n ...(datasets.length > 1 ? {} : { bottom: 0 }),\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n type: 'shadow',\n },\n valueFormatter: (value: number | string) => valueFormatter(value, this.valuePrefix, this.valueSuffix),\n },\n series,\n };\n\n this.chart.setOption(option, { notMerge: true });\n }\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.js","sourceRoot":"","sources":["../../../src/colors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC","sourcesContent":["export const defaultColorPalette = ['#ED6E2E', '#1967D3', '#119EAE', '#283492', '#596B7A', '#4d35a1'];\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,YAAY,CAAC","sourcesContent":["export { TtBarChart } from './tt-bar-chart.js';\nexport * from './types.js';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tt-bar-chart.js","sourceRoot":"","sources":["../../../src/tt-bar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QAC/C,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { TtBarChart } from './TtBarChart.js';\n\nif (typeof window !== 'undefined') {\n if (!window.customElements.get('tt-bar-chart')) {\n window.customElements.define('tt-bar-chart', TtBarChart);\n }\n}\n\nexport { TtBarChart };\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { TtBarChart } from './TtBarChart.js';\n\nexport interface DataPoint {\n label: string;\n value: number | undefined;\n}\n\nexport interface Dataset {\n label: string;\n data: DataPoint[];\n}\n\nexport type ChartDirection = 'horizontal' | 'vertical';\n\ninterface TtBarChartExternalAttributes {\n id: string;\n width?: string;\n height?: string;\n direction?: ChartDirection;\n 'x-axis-title'?: string;\n 'y-axis-title'?: string;\n stacked?: boolean;\n loading?: boolean;\n 'value-prefix'?: string;\n 'value-suffix'?: string;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'tt-bar-chart': TtBarChart;\n }\n\n namespace JSX {\n interface IntrinsicElements {\n 'tt-bar-chart': TtBarChartExternalAttributes & { children?: Element | Element[]; style?: string };\n }\n }\n\n namespace React {\n namespace JSX {\n interface IntrinsicElements {\n 'tt-bar-chart': TtBarChartExternalAttributes & {\n ref?: React.Ref<unknown>;\n children?: React.ReactNode;\n style?: React.CSSProperties;\n };\n }\n }\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAIA,MAAM,sBAAsB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;AAEzF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAsB,EAAE,MAA0B,EAAE,MAA0B,EAAE,EAAE;IAC/G,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,cAAc,GAAG,sBAAsB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,GAAG,MAAM,IAAI,EAAE,G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AEL,KAAK,EAAE,YAAY;YACjB,CAAC,CAAC;gBACE,GAAG,QAAQ;gBACX,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;aACvD;YACH,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE;QAElC,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,YAAY,EAAE;gBACpB,MAAM,EAAE,IAAI;gBACZ,uBAAuB,EAAE,GAAG;gBAC5B,SAAS,EAAE;oBACT,KAAK,EAAE,SAAS;iBACjB;gBACD,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;aAC7B;SACF;KACF,EACD,IAAI,CACL,CAAC;IAEF,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE;QACzC,KAAK,CAAC,SAAS,CAAC;YACd,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC;SACnC,CAAC,CAAC;IACL,CAAC,EAAE,cAAc,CAAC,CAAC;IAEnB,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC","sourcesContent":["// @ts-expect-error Known error - https://github.com/apache/echarts/issues/21250\nimport * as echarts from 'echarts';\nimport { ChartDirection } from './types.js';\n\nconst numericalAxesFormatter = new Intl.NumberFormat(undefined, { notation: 'compact' });\n\nexport const valueFormatter = (value: number | string, prefix: string | undefined, suffix: string | undefined) => {\n let formattedValue = value;\n\n if (typeof value === 'number') {\n formattedValue = numericalAxesFormatter.format(value);\n }\n\n return `${prefix ?? ''}${formattedValue ?? value}${suffix ?? ''}`;\n};\n\nconst SKELETON_ITEMS = 4;\nconst PULSE_INTERVAL = 1500;\n\nexport const loadingAnimation = (chart: echarts.ECharts, direction: ChartDirection) => {\n const isHorizontal = direction === 'horizontal';\n\n const generateData = () => Array.from({ length: SKELETON_ITEMS }, () => Math.round(30 + Math.random() * 50));\n\n const baseAxis = {\n axisLabel: { show: false },\n axisTick: { show: false },\n axisLine: { show: false },\n splitLine: { show: false },\n };\n\n chart.setOption(\n {\n animation: true,\n animationDuration: 800,\n animationEasing: 'cubicInOut',\n\n grid: {\n left: 0,\n right: 0,\n top: 0,\n bottom: 0,\n containLabel: false,\n },\n\n xAxis: isHorizontal\n ? { ...baseAxis, type: 'value' }\n : {\n ...baseAxis,\n type: 'category',\n data: Array.from({ length: SKELETON_ITEMS }, () => ''),\n },\n\n yAxis: isHorizontal\n ? {\n ...baseAxis,\n type: 'category',\n data: Array.from({ length: SKELETON_ITEMS }, () => ''),\n }\n : { ...baseAxis, type: 'value' },\n\n series: [\n {\n type: 'bar',\n data: generateData(),\n silent: true,\n animationDurationUpdate: 800,\n itemStyle: {\n color: '#e5e7eb',\n },\n emphasis: { disabled: true },\n },\n ],\n },\n true\n );\n\n const pulseTimer = window.setInterval(() => {\n chart.setOption({\n series: [{ data: generateData() }],\n });\n }, PULSE_INTERVAL);\n\n return pulseTimer;\n};\n"]}
package/package.json CHANGED
@@ -3,28 +3,33 @@
3
3
  "description": "Webcomponent tt-bar-chart following open-wc recommendations",
4
4
  "license": "MIT",
5
5
  "author": "tt-bar-chart",
6
- "version": "1.0.7",
6
+ "version": "1.1.0",
7
7
  "type": "module",
8
- "main": "dist/src/index.js",
9
- "module": "dist/src/index.js",
8
+ "main": "dist/esm/src/index.js",
9
+ "module": "dist/esm/src/index.js",
10
10
  "exports": {
11
11
  ".": {
12
- "import": "./dist/src/index.js",
13
- "types": "./dist/src/types.d.ts"
12
+ "types": "./dist/esm/src/index.d.ts",
13
+ "import": "./dist/esm/src/index.js",
14
+ "require": "./dist/cjs/src/index.js"
14
15
  },
15
16
  "./types": {
16
- "import": "./dist/src/types.js",
17
- "types": "./dist/src/types.d.ts"
17
+ "types": "./dist/esm/src/types.d.ts",
18
+ "import": "./dist/esm/src/types.js",
19
+ "require": "./dist/cjs/src/types.js"
18
20
  }
19
21
  },
20
22
  "files": [
21
- "dist/src"
23
+ "dist/esm",
24
+ "dist/cjs"
22
25
  ],
23
26
  "scripts": {
24
27
  "analyze": "cem analyze --litelement",
25
28
  "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"web-dev-server\"",
26
29
  "build": "yarn build:node && yarn build:web && npm run analyze -- --exclude dist",
27
- "build:node": "tsc",
30
+ "build:esm": "tsc",
31
+ "build:cjs": "tsc -p tsconfig.cjs.json && node ../../scripts/create-cjs-package.mjs",
32
+ "build:node": "yarn build:esm && yarn build:cjs",
28
33
  "build:node:watch": "tsc --watch",
29
34
  "build:web": "node ../../scripts/esbuild.mjs",
30
35
  "prepublish": "tsc && npm run analyze -- --exclude dist",
@@ -32,8 +37,8 @@
32
37
  "test:watch": "vitest --config=./vitest.browser.config.mjs"
33
38
  },
34
39
  "dependencies": {
35
- "@triptease/tt-data-point": "1.0.1",
36
- "@triptease/tt-dataset": "1.0.2",
40
+ "@triptease/tt-data-point": "1.1.0",
41
+ "@triptease/tt-dataset": "1.1.0",
37
42
  "echarts": "^6.0.0",
38
43
  "lit": "^3.1.4"
39
44
  },
@@ -1 +0,0 @@
1
- {"version":3,"file":"TtBarChart.js","sourceRoot":"","sources":["../../src/TtBarChart.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACvC,gFAAgF;AAChF,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC9D,gFAAgF;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE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AAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;+CACjC;AAGrB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC;+CACjC;AAGrB;IADC,KAAK,EAAE;yCAC6B;AAG7B;IADP,KAAK,CAAC,MAAM,CAAC;+CACwB","sourcesContent":["import { html, LitElement } from 'lit';\n// @ts-expect-error Known error - https://github.com/apache/echarts/issues/21250\nimport * as echarts from 'echarts';\nimport { property, query, state } from 'lit/decorators.js';\nimport { ChartDirection, Dataset } from './types.js';\nimport { loadingAnimation, valueFormatter } from './utils.js';\n// @ts-expect-error Known error - https://github.com/apache/echarts/issues/21250\nimport { AriaComponent } from 'echarts/components';\nimport { defaultColorPalette } from './colors.js';\nimport { isTtDataset } from '@triptease/tt-dataset';\nimport { isTtDataPoint } from '@triptease/tt-data-point';\n\nconst constructChartData = (ttDatasetElements: Element[]) => {\n if (!ttDatasetElements.every(isTtDataset)) {\n throw new Error(\"Children of element 'tt-bar-chart' must be 'tt-dataset' elements.\");\n }\n\n const datasets: Dataset[] = ttDatasetElements.map((ttDataset) => {\n const datasetLabel = ttDataset.getAttribute('label');\n if (!datasetLabel) throw new Error(\"Attribute 'label' on element 'tt-dataset' is required\");\n\n const ttDataPoints = Array.from(ttDataset.querySelectorAll('tt-data-point'));\n if (!ttDataPoints.every(isTtDataPoint)) {\n throw new Error(\"Children of element 'tt-dataset' must be 'tt-data-point' elements\");\n }\n\n const data = ttDataPoints.map((ttDataPoint) => {\n const dataPointLabel = ttDataPoint.getAttribute('label');\n if (!dataPointLabel) throw new Error(\"Attribute 'label' on element 'tt-data-point' is required\");\n\n const valueRaw = ttDataPoint.getAttribute('value');\n const value = valueRaw ? Number(valueRaw) : undefined;\n if (value !== undefined && Number.isNaN(value)) {\n throw new Error(\"Attribute 'value' on element 'tt-data-point' is not a valid number\");\n }\n\n return { label: dataPointLabel, value };\n });\n\n return { label: datasetLabel, data };\n });\n\n return datasets;\n};\n\nexport class TtBarChart extends LitElement {\n @property({ type: String })\n direction: ChartDirection = 'horizontal';\n\n @property({ type: String, attribute: 'x-axis-title' })\n xAxisTitle?: string;\n\n @property({ type: String, attribute: 'y-axis-title' })\n yAxisTitle?: string;\n\n @property({ type: Boolean, attribute: 'stacked' })\n stacked: boolean = false;\n\n @property({ type: Boolean, attribute: 'loading' })\n loading: boolean = false;\n\n @property({ type: String, attribute: 'width' })\n width: string = '100%';\n\n @property({ type: String, attribute: 'height' })\n height: string = '100%';\n\n @property({ type: String, attribute: 'value-prefix' })\n valuePrefix?: string;\n\n @property({ type: String, attribute: 'value-suffix' })\n valueSuffix?: string;\n\n @state()\n chart: echarts.ECharts | null = null;\n\n @query('slot')\n private defaultSlot!: HTMLSlotElement;\n\n private loadingPulseTimer: number | undefined;\n private slotObserver: MutationObserver | null = null;\n\n render() {\n return html`\n <div style=\"width: ${this.width}; height:${this.height};\">\n <div id=${this.id} style=\"width:${this.width}; height:${this.height};\"></div>\n <slot @slotchange=${this.handleSlotChange}></slot>\n </div>\n `;\n }\n\n protected handleSlotChange() {\n this.slotObserver?.disconnect();\n this.slotObserver = new MutationObserver(() => this.requestUpdate());\n this.defaultSlot.assignedElements().forEach((el) => {\n this.slotObserver!.observe(el, { childList: true, attributes: true, subtree: true });\n });\n this.requestUpdate();\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.slotObserver?.disconnect();\n }\n\n protected firstUpdated() {\n if (this.chart === null) {\n echarts.use([AriaComponent]);\n const divElement = this.renderRoot.querySelector(`#${this.id}`) as HTMLDivElement;\n\n if (!divElement) {\n throw new Error('No div element');\n }\n\n this.chart = echarts.init(divElement);\n }\n }\n\n protected updated() {\n if (this.loadingPulseTimer) {\n window.clearInterval(this.loadingPulseTimer);\n }\n\n if (this.loading && this.chart) {\n this.setAttribute('aria-busy', 'true');\n const pulseTimer = loadingAnimation(this.chart, this.direction);\n this.loadingPulseTimer = pulseTimer;\n } else {\n this.removeAttribute('aria-busy');\n\n const datasets = constructChartData(this.defaultSlot.assignedElements());\n\n const labelsRaw = datasets.flatMap((dataset) => dataset.data.map((datapoint) => datapoint.label));\n const labels = [...new Set(labelsRaw)];\n\n const series: echarts.SeriesOption[] = datasets.map((dataset, i) => ({\n name: dataset.label,\n type: 'bar',\n data: labels.map((label) => {\n const point = dataset.data.find((dp) => dp.label === label);\n return point?.value ?? null;\n }),\n stack: this.stacked ? 'A' : undefined,\n color: defaultColorPalette[i],\n cursor: 'default',\n }));\n\n const option: echarts.EChartsOption = {\n aria: {\n show: true,\n },\n legend: {\n show: datasets.length > 1,\n textStyle: {\n color: '#3b353b', //--text-400\n },\n },\n xAxis: {\n name: this.xAxisTitle,\n nameTextStyle: {\n lineHeight: 40,\n color: '#575157', //--text-300\n },\n nameLocation: 'center',\n type: this.direction === 'horizontal' ? 'value' : 'category',\n data: this.direction === 'horizontal' ? undefined : labels,\n axisLabel: {\n formatter: (value: number | string) =>\n valueFormatter(\n value,\n this.direction === 'horizontal' ? this.valuePrefix : undefined,\n this.direction === 'horizontal' ? this.valueSuffix : undefined\n ),\n color: '#3b353b', //--text-400\n },\n splitLine: { show: this.direction === 'horizontal' },\n },\n yAxis: {\n name: this.yAxisTitle,\n nameTextStyle: {\n lineHeight: 40,\n color: '#575157', //--text-300\n },\n nameLocation: 'center',\n type: this.direction === 'horizontal' ? 'category' : 'value',\n data: this.direction === 'horizontal' ? labels : undefined,\n axisLabel: {\n formatter: (value: number | string) =>\n valueFormatter(\n value,\n this.direction === 'horizontal' ? undefined : this.valuePrefix,\n this.direction === 'horizontal' ? undefined : this.valueSuffix\n ),\n color: '#3b353b', //--text-400\n },\n splitLine: { show: this.direction === 'vertical' },\n },\n grid: {\n left: 0,\n right: 0,\n top: 0,\n ...(datasets.length > 1 ? {} : { bottom: 0 }),\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n type: 'shadow',\n },\n valueFormatter: (value: number | string) => valueFormatter(value, this.valuePrefix, this.valueSuffix),\n },\n series,\n };\n\n this.chart.setOption(option, { notMerge: true });\n }\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/colors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC","sourcesContent":["export const defaultColorPalette = ['#ED6E2E', '#1967D3', '#119EAE', '#283492', '#596B7A', '#4d35a1'];\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,YAAY,CAAC","sourcesContent":["export { TtBarChart } from './tt-bar-chart.js';\nexport * from './types.js';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tt-bar-chart.js","sourceRoot":"","sources":["../../src/tt-bar-chart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IAClC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;QAC/C,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { TtBarChart } from './TtBarChart.js';\n\nif (typeof window !== 'undefined') {\n if (!window.customElements.get('tt-bar-chart')) {\n window.customElements.define('tt-bar-chart', TtBarChart);\n }\n}\n\nexport { TtBarChart };\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import { TtBarChart } from './TtBarChart.js';\n\nexport interface DataPoint {\n label: string;\n value: number | undefined;\n}\n\nexport interface Dataset {\n label: string;\n data: DataPoint[];\n}\n\nexport type ChartDirection = 'horizontal' | 'vertical';\n\ninterface TtBarChartExternalAttributes {\n id: string;\n width?: string;\n height?: string;\n direction?: ChartDirection;\n 'x-axis-title'?: string;\n 'y-axis-title'?: string;\n stacked?: boolean;\n loading?: boolean;\n 'value-prefix'?: string;\n 'value-suffix'?: string;\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'tt-bar-chart': TtBarChart;\n }\n\n namespace JSX {\n interface IntrinsicElements {\n 'tt-bar-chart': TtBarChartExternalAttributes & { children?: Element | Element[]; style?: string };\n }\n }\n\n namespace React {\n namespace JSX {\n interface IntrinsicElements {\n 'tt-bar-chart': TtBarChartExternalAttributes & {\n ref?: React.Ref<unknown>;\n children?: React.ReactNode;\n style?: React.CSSProperties;\n };\n }\n }\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAIA,MAAM,sBAAsB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;AAEzF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAsB,EAAE,MAA0B,EAAE,MAA0B,EAAE,EAAE;IAC/G,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,cAAc,GAAG,sBAAsB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,GAAG,MAAM,IAAI,EAAE,GAAG,cAAc,IAAI,KAAK,GAAG,MAAM,IAAI,EAAE,EAAE,CAAC;AACpE,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,MAAM,CAAC,MA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AAE,CAAC,EAAE,CAAC;aACvD;YACH,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE;QAElC,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,YAAY,EAAE;gBACpB,MAAM,EAAE,IAAI;gBACZ,uBAAuB,EAAE,GAAG;gBAC5B,SAAS,EAAE;oBACT,KAAK,EAAE,SAAS;iBACjB;gBACD,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;aAC7B;SACF;KACF,EACD,IAAI,CACL,CAAC;IAEF,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE;QACzC,KAAK,CAAC,SAAS,CAAC;YACd,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC;SACnC,CAAC,CAAC;IACL,CAAC,EAAE,cAAc,CAAC,CAAC;IAEnB,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC","sourcesContent":["// @ts-expect-error Known error - https://github.com/apache/echarts/issues/21250\nimport * as echarts from 'echarts';\nimport { ChartDirection } from './types.js';\n\nconst numericalAxesFormatter = new Intl.NumberFormat(undefined, { notation: 'compact' });\n\nexport const valueFormatter = (value: number | string, prefix: string | undefined, suffix: string | undefined) => {\n let formattedValue = value;\n\n if (typeof value === 'number') {\n formattedValue = numericalAxesFormatter.format(value);\n }\n\n return `${prefix ?? ''}${formattedValue ?? value}${suffix ?? ''}`;\n};\n\nconst SKELETON_ITEMS = 4;\nconst PULSE_INTERVAL = 1500;\n\nexport const loadingAnimation = (chart: echarts.ECharts, direction: ChartDirection) => {\n const isHorizontal = direction === 'horizontal';\n\n const generateData = () => Array.from({ length: SKELETON_ITEMS }, () => Math.round(30 + Math.random() * 50));\n\n const baseAxis = {\n axisLabel: { show: false },\n axisTick: { show: false },\n axisLine: { show: false },\n splitLine: { show: false },\n };\n\n chart.setOption(\n {\n animation: true,\n animationDuration: 800,\n animationEasing: 'cubicInOut',\n\n grid: {\n left: 0,\n right: 0,\n top: 0,\n bottom: 0,\n containLabel: false,\n },\n\n xAxis: isHorizontal\n ? { ...baseAxis, type: 'value' }\n : {\n ...baseAxis,\n type: 'category',\n data: Array.from({ length: SKELETON_ITEMS }, () => ''),\n },\n\n yAxis: isHorizontal\n ? {\n ...baseAxis,\n type: 'category',\n data: Array.from({ length: SKELETON_ITEMS }, () => ''),\n }\n : { ...baseAxis, type: 'value' },\n\n series: [\n {\n type: 'bar',\n data: generateData(),\n silent: true,\n animationDurationUpdate: 800,\n itemStyle: {\n color: '#e5e7eb',\n },\n emphasis: { disabled: true },\n },\n ],\n },\n true\n );\n\n const pulseTimer = window.setInterval(() => {\n chart.setOption({\n series: [{ data: generateData() }],\n });\n }, PULSE_INTERVAL);\n\n return pulseTimer;\n};\n"]}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes