q2-tecton-elements 1.13.1 → 1.14.1
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/cjs/click-elsewhere.cjs.entry.js +1 -1
- package/dist/cjs/{icons-08ffe5c9.js → icons-e2bc9ee9.js} +1 -1
- package/dist/cjs/{index-7febb200.js → index-0128397d.js} +41 -1
- package/dist/cjs/{index-dd823ee6.js → index-0fec9f3b.js} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/q2-avatar.cjs.entry.js +2 -2
- package/dist/cjs/q2-badge.cjs.entry.js +1 -1
- package/dist/cjs/q2-btn_2.cjs.entry.js +5 -5
- package/dist/cjs/q2-calendar.cjs.entry.js +3 -3
- package/dist/cjs/q2-card.cjs.entry.js +2 -2
- package/dist/cjs/q2-carousel-pane.cjs.entry.js +2 -2
- package/dist/cjs/q2-carousel.cjs.entry.js +2 -2
- package/dist/cjs/q2-chart-donut.cjs.entry.js +39976 -0
- package/dist/cjs/q2-checkbox-group.cjs.entry.js +2 -2
- package/dist/cjs/q2-checkbox.cjs.entry.js +10 -13
- package/dist/cjs/q2-dropdown-item.cjs.entry.js +2 -2
- package/dist/cjs/q2-dropdown.cjs.entry.js +4 -4
- package/dist/cjs/q2-editable-field.cjs.entry.js +2 -2
- package/dist/cjs/q2-icon.cjs.entry.js +3 -3
- package/dist/cjs/q2-input.cjs.entry.js +3 -3
- package/dist/cjs/q2-loading-element.cjs.entry.js +2 -2
- package/dist/cjs/q2-loc.cjs.entry.js +2 -2
- package/dist/cjs/q2-message.cjs.entry.js +2 -2
- package/dist/cjs/q2-optgroup.cjs.entry.js +2 -2
- package/dist/cjs/q2-option-list.cjs.entry.js +2 -2
- package/dist/cjs/q2-option.cjs.entry.js +1 -1
- package/dist/cjs/q2-pagination.cjs.entry.js +3 -3
- package/dist/cjs/q2-pill.cjs.entry.js +2 -2
- package/dist/cjs/q2-radio-group.cjs.entry.js +19 -11
- package/dist/cjs/q2-radio.cjs.entry.js +3 -3
- package/dist/cjs/q2-section.cjs.entry.js +2 -2
- package/dist/cjs/q2-select.cjs.entry.js +3 -3
- package/dist/cjs/q2-stepper-pane.cjs.entry.js +2 -2
- package/dist/cjs/q2-stepper-vertical.cjs.entry.js +2 -2
- package/dist/cjs/q2-stepper.cjs.entry.js +2 -2
- package/dist/cjs/q2-tab-container.cjs.entry.js +2 -2
- package/dist/cjs/q2-tab-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-tag.cjs.entry.js +2 -2
- package/dist/cjs/q2-tecton-elements.cjs.js +2 -2
- package/dist/cjs/q2-textarea.cjs.entry.js +2 -2
- package/dist/cjs/{shapes-305746b5.js → shapes-c1a60d46.js} +1 -1
- package/dist/cjs/tecton-tab-pane.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/q2-btn/index.js +18 -1
- package/dist/collection/components/q2-btn/styles.css +6 -0
- package/dist/collection/components/q2-calendar/styles.css +5 -0
- package/dist/collection/components/q2-chart-donut/index.js +628 -0
- package/dist/collection/components/q2-chart-donut/styles.css +140 -0
- package/dist/collection/components/q2-checkbox/index.js +31 -16
- package/dist/collection/components/q2-checkbox/styles.css +111 -139
- package/dist/collection/components/q2-dropdown/index.js +18 -1
- package/dist/collection/components/q2-dropdown/styles.css +5 -0
- package/dist/collection/components/q2-input/index.js +18 -1
- package/dist/collection/components/q2-pagination/index.js +1 -1
- package/dist/collection/components/q2-radio/styles.css +21 -18
- package/dist/collection/components/q2-radio-group/index.js +44 -15
- package/dist/collection/components/q2-radio-group/styles.css +36 -32
- package/dist/collection/components/q2-select/styles.css +5 -0
- package/dist/esm/click-elsewhere.entry.js +1 -1
- package/dist/esm/{icons-b1e11526.js → icons-ed54e307.js} +1 -1
- package/dist/esm/{index-0ff8de52.js → index-14e81efa.js} +1 -1
- package/dist/esm/{index-dbfb3ecc.js → index-6d5ed7cc.js} +41 -1
- package/dist/esm/loader.js +2 -2
- package/dist/esm/q2-avatar.entry.js +2 -2
- package/dist/esm/q2-badge.entry.js +1 -1
- package/dist/esm/q2-btn_2.entry.js +5 -5
- package/dist/esm/q2-calendar.entry.js +3 -3
- package/dist/esm/q2-card.entry.js +2 -2
- package/dist/esm/q2-carousel-pane.entry.js +2 -2
- package/dist/esm/q2-carousel.entry.js +2 -2
- package/dist/esm/q2-chart-donut.entry.js +39972 -0
- package/dist/esm/q2-checkbox-group.entry.js +2 -2
- package/dist/esm/q2-checkbox.entry.js +10 -13
- package/dist/esm/q2-dropdown-item.entry.js +2 -2
- package/dist/esm/q2-dropdown.entry.js +4 -4
- package/dist/esm/q2-editable-field.entry.js +2 -2
- package/dist/esm/q2-icon.entry.js +3 -3
- package/dist/esm/q2-input.entry.js +3 -3
- package/dist/esm/q2-loading-element.entry.js +2 -2
- package/dist/esm/q2-loc.entry.js +2 -2
- package/dist/esm/q2-message.entry.js +2 -2
- package/dist/esm/q2-optgroup.entry.js +2 -2
- package/dist/esm/q2-option-list.entry.js +2 -2
- package/dist/esm/q2-option.entry.js +1 -1
- package/dist/esm/q2-pagination.entry.js +3 -3
- package/dist/esm/q2-pill.entry.js +2 -2
- package/dist/esm/q2-radio-group.entry.js +19 -11
- package/dist/esm/q2-radio.entry.js +3 -3
- package/dist/esm/q2-section.entry.js +2 -2
- package/dist/esm/q2-select.entry.js +3 -3
- package/dist/esm/q2-stepper-pane.entry.js +2 -2
- package/dist/esm/q2-stepper-vertical.entry.js +2 -2
- package/dist/esm/q2-stepper.entry.js +2 -2
- package/dist/esm/q2-tab-container.entry.js +2 -2
- package/dist/esm/q2-tab-pane.entry.js +1 -1
- package/dist/esm/q2-tag.entry.js +2 -2
- package/dist/esm/q2-tecton-elements.js +2 -2
- package/dist/esm/q2-textarea.entry.js +2 -2
- package/dist/esm/{shapes-cff4e1f0.js → shapes-c32e3ba2.js} +1 -1
- package/dist/esm/tecton-tab-pane.entry.js +1 -1
- package/dist/q2-tecton-elements/p-0675f9c8.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-fdfbe75b.entry.js → p-09464226.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-10264ecb.entry.js → p-0e13d5ba.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-d5218cd6.entry.js → p-17cffd7d.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-2846ab94.entry.js → p-1eed57aa.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-2c15414c.entry.js → p-3796397e.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-a5562aaa.entry.js → p-37f1984c.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-3cfc0cb4.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-dd02cf8d.js → p-431bf43e.js} +1 -1
- package/dist/q2-tecton-elements/{p-ede12fc1.entry.js → p-58e42fc5.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-3fe98e3e.entry.js → p-627df469.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-327cca41.entry.js → p-65e2df25.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-ca7a3380.entry.js → p-663cb6e8.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-ffbded54.entry.js → p-6727f6d0.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-e0e7ae8b.entry.js → p-6ced7858.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-6fec9235.entry.js → p-706249e1.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-5bbf2bfe.entry.js → p-7249de38.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-824aebd9.js → p-73154834.js} +1 -1
- package/dist/q2-tecton-elements/{p-ae130f70.entry.js → p-7ddb159c.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-85cff6ec.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-49b2abc4.entry.js → p-87f448ab.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-3a420dbf.entry.js → p-882eaf0f.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-45eb7739.entry.js → p-8f815678.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-00e8f782.entry.js → p-92886dbe.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-255b2b4c.js → p-93c00587.js} +1 -1
- package/dist/q2-tecton-elements/{p-221abbf6.entry.js → p-9725d55f.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-430a979b.entry.js → p-9af46ffc.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-1305ec5f.entry.js → p-9d8a963b.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-148391d6.entry.js → p-b066cdd1.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-27736b6b.entry.js → p-bd6c6239.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-0900bec1.entry.js → p-c4eff511.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-c5691700.js +1 -0
- package/dist/q2-tecton-elements/p-cc57b8b1.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-1dfaee64.entry.js → p-cf9e8120.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-4ab30466.entry.js → p-d46efe36.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-d5d2b3c9.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-2bc1de01.entry.js → p-e435159b.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-c20cbb2d.entry.js → p-ea2a290e.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-eeb4a008.entry.js +39 -0
- package/dist/q2-tecton-elements/{p-d33e152c.entry.js → p-fbfb3615.entry.js} +1 -1
- package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
- package/dist/types/components/q2-btn/index.d.ts +1 -0
- package/dist/types/components/q2-chart-donut/index.d.ts +89 -0
- package/dist/types/components/q2-checkbox/index.d.ts +1 -1
- package/dist/types/components/q2-dropdown/index.d.ts +1 -0
- package/dist/types/components/q2-input/index.d.ts +1 -0
- package/dist/types/components/q2-radio-group/index.d.ts +4 -2
- package/dist/types/components.d.ts +48 -0
- package/dist/types/util.d.ts +1 -0
- package/dist/types/workspace/workspace/{tecton-production_release_1.13.x → tecton-production_release_1.14.x}/packages/q2-tecton-elements/.stencil/test/elements/q2-tag-test.d.ts +0 -0
- package/dist/types/workspace/workspace/{tecton-production_release_1.13.x → tecton-production_release_1.14.x}/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +0 -0
- package/package.json +3 -2
- package/dist/q2-tecton-elements/p-2caa89fd.js +0 -1
- package/dist/q2-tecton-elements/p-3a64e5ce.entry.js +0 -1
- package/dist/q2-tecton-elements/p-3abcb09d.entry.js +0 -1
- package/dist/q2-tecton-elements/p-a4ae89cc.entry.js +0 -1
- package/dist/q2-tecton-elements/p-b2302cd3.entry.js +0 -1
- package/dist/q2-tecton-elements/p-d52b435e.entry.js +0 -1
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
import { Component, State, Prop, h, Element, Event, Method, Watch, Listen, } from '@stencil/core';
|
|
2
|
+
import * as echarts from 'echarts/core';
|
|
3
|
+
import { TooltipComponent, LegendComponent, AriaComponent, } from 'echarts/components';
|
|
4
|
+
import { PieChart } from 'echarts/charts';
|
|
5
|
+
import { LabelLayout } from 'echarts/features';
|
|
6
|
+
import { CanvasRenderer } from 'echarts/renderers';
|
|
7
|
+
import { isEventFromElement, loc, overrideFocus } from 'src/utils';
|
|
8
|
+
echarts.use([TooltipComponent, LegendComponent, PieChart, CanvasRenderer, AriaComponent, LabelLayout]);
|
|
9
|
+
export class Q2ChartDonut {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.innerRadius = '70%';
|
|
12
|
+
this.outerRadius = '85%';
|
|
13
|
+
this.selectedOffset = 10;
|
|
14
|
+
this.hoverScaleSize = 5;
|
|
15
|
+
this.data = [];
|
|
16
|
+
this.defaultRecord = { id: null, value: null, name: null };
|
|
17
|
+
/// Event Handlers ///
|
|
18
|
+
this.onClickElsewhere = (event) => {
|
|
19
|
+
event.stopPropagation();
|
|
20
|
+
this.clearSelection();
|
|
21
|
+
};
|
|
22
|
+
this.onButtonKeyUp = (event) => {
|
|
23
|
+
const { selectedId, data } = this;
|
|
24
|
+
let selectedIndex = this.getIndexById(selectedId) || 0;
|
|
25
|
+
switch (event.key) {
|
|
26
|
+
case 'ArrowLeft':
|
|
27
|
+
case 'ArrowUp':
|
|
28
|
+
selectedIndex--;
|
|
29
|
+
if (selectedIndex < 0)
|
|
30
|
+
selectedIndex = data.length - 1;
|
|
31
|
+
this.chart.dispatchAction({
|
|
32
|
+
type: 'select',
|
|
33
|
+
seriesId: 'pie',
|
|
34
|
+
dataIndex: selectedIndex,
|
|
35
|
+
});
|
|
36
|
+
break;
|
|
37
|
+
case 'ArrowRight':
|
|
38
|
+
case 'ArrowDown':
|
|
39
|
+
selectedIndex++;
|
|
40
|
+
if (selectedIndex > data.length - 1)
|
|
41
|
+
selectedIndex = 0;
|
|
42
|
+
this.chart.dispatchAction({
|
|
43
|
+
type: 'select',
|
|
44
|
+
seriesId: 'pie',
|
|
45
|
+
dataIndex: selectedIndex,
|
|
46
|
+
});
|
|
47
|
+
break;
|
|
48
|
+
case 'Escape':
|
|
49
|
+
this.clearSelection();
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
this.onButtonClick = (event) => {
|
|
56
|
+
event.stopPropagation();
|
|
57
|
+
const { selectedId } = this;
|
|
58
|
+
const data = selectedId ? this.getDataById(selectedId) : Object.assign({}, this.defaultRecord);
|
|
59
|
+
this.click.emit(data);
|
|
60
|
+
};
|
|
61
|
+
this.onContainerClick = (event) => {
|
|
62
|
+
if (this.isInChangeEvent)
|
|
63
|
+
return;
|
|
64
|
+
if (!(event.target instanceof HTMLElement))
|
|
65
|
+
return;
|
|
66
|
+
this.clearSelection();
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/// LifeCycle Hooks ///
|
|
70
|
+
componentDidLoad() {
|
|
71
|
+
const chart = echarts.init(this.chartContainer);
|
|
72
|
+
this.cacheComputedStyles();
|
|
73
|
+
this.colors = this.getColors();
|
|
74
|
+
this.resizeObserver = new ResizeObserver(() => this.resizeChart());
|
|
75
|
+
this.resizeObserver.observe(this.hostElement);
|
|
76
|
+
this.updateChart(chart);
|
|
77
|
+
this.setupChartEvents(chart);
|
|
78
|
+
this.chart = chart;
|
|
79
|
+
overrideFocus(this.hostElement);
|
|
80
|
+
}
|
|
81
|
+
willDestroyElement() {
|
|
82
|
+
this.resizeObserver = null;
|
|
83
|
+
}
|
|
84
|
+
/// Getters ///
|
|
85
|
+
get centerData() {
|
|
86
|
+
const { selectedId, hoveredId, data } = this;
|
|
87
|
+
const idToDisplay = hoveredId || selectedId;
|
|
88
|
+
const index = this.getIndexById(idToDisplay);
|
|
89
|
+
return idToDisplay
|
|
90
|
+
? Object.assign(Object.assign({}, this.getDataById(idToDisplay)), { color: this.colors[index] }) : {
|
|
91
|
+
name: loc(this.summaryName || 'tecton.element.chartDonut.button.summaryName'),
|
|
92
|
+
icon: this.summaryIcon,
|
|
93
|
+
value: data.reduce((acc, cur) => acc + cur.value, 0),
|
|
94
|
+
color: null,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/// Helpers
|
|
98
|
+
cacheComputedStyles() {
|
|
99
|
+
this.chartContainerStyles = getComputedStyle(this.chartContainer);
|
|
100
|
+
this.hostElementStyles = getComputedStyle(this.hostElement);
|
|
101
|
+
}
|
|
102
|
+
displayValue(value) {
|
|
103
|
+
const valueAsFloat = parseFloat(value.toString());
|
|
104
|
+
if (isNaN(valueAsFloat))
|
|
105
|
+
return;
|
|
106
|
+
if (this.format === 'currency') {
|
|
107
|
+
return Intl.NumberFormat('en-US', {
|
|
108
|
+
style: 'currency',
|
|
109
|
+
currency: 'USD',
|
|
110
|
+
}).format(valueAsFloat);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
return Intl.NumberFormat('en-US').format(valueAsFloat);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
getCSSProperty(name) {
|
|
117
|
+
let fallback;
|
|
118
|
+
if (name.startsWith('var(') && name.endsWith(')')) {
|
|
119
|
+
const regExp = /var\((.*)\)/g;
|
|
120
|
+
const result = regExp.exec(name);
|
|
121
|
+
const split = result.length >= 2 ? result[1].split(',') : [];
|
|
122
|
+
name = split[0];
|
|
123
|
+
fallback = split[1];
|
|
124
|
+
}
|
|
125
|
+
let result = this.chartContainerStyles.getPropertyValue(name).trim();
|
|
126
|
+
if (!result)
|
|
127
|
+
result = this.hostElementStyles.getPropertyValue(name).trim();
|
|
128
|
+
return result || fallback;
|
|
129
|
+
}
|
|
130
|
+
getIndexById(id) {
|
|
131
|
+
return this.data.findIndex(item => item.id === id);
|
|
132
|
+
}
|
|
133
|
+
getDataByIndex(index) {
|
|
134
|
+
if (typeof index !== 'number')
|
|
135
|
+
return;
|
|
136
|
+
return this.data[index];
|
|
137
|
+
}
|
|
138
|
+
getDataById(id) {
|
|
139
|
+
if (!id)
|
|
140
|
+
return;
|
|
141
|
+
return this.data.find(item => item.id === id);
|
|
142
|
+
}
|
|
143
|
+
getColors() {
|
|
144
|
+
const defaultColors = [
|
|
145
|
+
'--comp-color-1',
|
|
146
|
+
'--comp-color-2',
|
|
147
|
+
'--comp-color-3',
|
|
148
|
+
'--comp-color-4',
|
|
149
|
+
'--comp-color-5',
|
|
150
|
+
'--comp-color-6',
|
|
151
|
+
'--comp-color-7',
|
|
152
|
+
'--comp-color-8',
|
|
153
|
+
'--comp-color-9',
|
|
154
|
+
'--comp-color-10',
|
|
155
|
+
'--comp-color-11',
|
|
156
|
+
'--comp-color-12',
|
|
157
|
+
];
|
|
158
|
+
return this.data.reduce((acc, cur) => {
|
|
159
|
+
let color = defaultColors.shift();
|
|
160
|
+
if (cur.color)
|
|
161
|
+
color = cur.color;
|
|
162
|
+
acc.push(this.getCSSProperty(color) || color);
|
|
163
|
+
return acc;
|
|
164
|
+
}, []);
|
|
165
|
+
}
|
|
166
|
+
setupChartEvents(chart) {
|
|
167
|
+
chart.on('mouseover', (params) => {
|
|
168
|
+
this.hoveredId = params.data.id;
|
|
169
|
+
});
|
|
170
|
+
chart.on('mouseout', () => {
|
|
171
|
+
this.hoveredId = null;
|
|
172
|
+
});
|
|
173
|
+
chart.on('selectchanged', (params) => {
|
|
174
|
+
var _a, _b, _c, _d;
|
|
175
|
+
const selectedIndex = (_d = (_c = (_b = (_a = params.selected) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.dataIndex) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : null;
|
|
176
|
+
const data = typeof selectedIndex === 'number' ? this.getDataByIndex(selectedIndex) : Object.assign({}, this.defaultRecord);
|
|
177
|
+
this.selectedId = data.id;
|
|
178
|
+
this.isInChangeEvent = true;
|
|
179
|
+
this.change.emit(data);
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
this.isInChangeEvent = false;
|
|
182
|
+
}, 0);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
updateChart(chart) {
|
|
186
|
+
return chart.setOption({
|
|
187
|
+
tooltip: {
|
|
188
|
+
show: false,
|
|
189
|
+
},
|
|
190
|
+
legend: {
|
|
191
|
+
show: false,
|
|
192
|
+
},
|
|
193
|
+
aria: {
|
|
194
|
+
enabled: true,
|
|
195
|
+
},
|
|
196
|
+
series: [
|
|
197
|
+
{
|
|
198
|
+
name: this.chartName,
|
|
199
|
+
animationType: 'scale',
|
|
200
|
+
color: this.colors,
|
|
201
|
+
id: 'pie',
|
|
202
|
+
type: 'pie',
|
|
203
|
+
selectedOffset: this.selectedOffset,
|
|
204
|
+
selectedMode: 'single',
|
|
205
|
+
radius: [this.innerRadius, this.outerRadius],
|
|
206
|
+
label: {
|
|
207
|
+
show: false,
|
|
208
|
+
},
|
|
209
|
+
labelLine: {
|
|
210
|
+
show: false,
|
|
211
|
+
},
|
|
212
|
+
itemStyle: {
|
|
213
|
+
borderWidth: 5,
|
|
214
|
+
borderColor: this.getCSSProperty('--comp-background-color'),
|
|
215
|
+
},
|
|
216
|
+
emphasis: {
|
|
217
|
+
scaleSize: this.hoverScaleSize,
|
|
218
|
+
itemStyle: {
|
|
219
|
+
color: 'inherit',
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
data: this.data,
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
resizeChart() {
|
|
228
|
+
this.chart.resize();
|
|
229
|
+
}
|
|
230
|
+
/// Watchers ///
|
|
231
|
+
propsUpdates() {
|
|
232
|
+
this.updateChart(this.chart);
|
|
233
|
+
}
|
|
234
|
+
dataUpdated() {
|
|
235
|
+
this.colors = this.getColors();
|
|
236
|
+
}
|
|
237
|
+
innerRadiusUpdated() {
|
|
238
|
+
const { innerRadius, outerRadius } = this;
|
|
239
|
+
const innerRadiusInt = parseFloat(innerRadius);
|
|
240
|
+
const outerRadiusInt = parseFloat(outerRadius);
|
|
241
|
+
if (innerRadiusInt >= outerRadiusInt) {
|
|
242
|
+
this.innerRadius = `${outerRadiusInt - 15}%`;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
outerRadiusUpdated() {
|
|
246
|
+
const { innerRadius, outerRadius } = this;
|
|
247
|
+
const innerRadiusInt = parseFloat(innerRadius);
|
|
248
|
+
const outerRadiusInt = parseFloat(outerRadius);
|
|
249
|
+
if (outerRadiusInt <= innerRadiusInt) {
|
|
250
|
+
this.outerRadius = `${innerRadiusInt + 15}%`;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/// Listeners ///
|
|
254
|
+
delegateFocus(event) {
|
|
255
|
+
var _a;
|
|
256
|
+
if (!isEventFromElement(event, this.hostElement))
|
|
257
|
+
return;
|
|
258
|
+
if (!this.isClickable)
|
|
259
|
+
return;
|
|
260
|
+
(_a = this.centerButtonElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
261
|
+
}
|
|
262
|
+
/// Methods ///
|
|
263
|
+
async selectById(id) {
|
|
264
|
+
const dataIndex = this.getIndexById(id);
|
|
265
|
+
if (dataIndex === -1)
|
|
266
|
+
return;
|
|
267
|
+
this.chart.dispatchAction({
|
|
268
|
+
type: 'select',
|
|
269
|
+
seriesId: 'pie',
|
|
270
|
+
dataIndex,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
async selectByIndex(index) {
|
|
274
|
+
const dataIndex = this.data[index] ? index : null;
|
|
275
|
+
if (!dataIndex)
|
|
276
|
+
return;
|
|
277
|
+
this.chart.dispatchAction({
|
|
278
|
+
type: 'select',
|
|
279
|
+
seriesId: 'pie',
|
|
280
|
+
dataIndex,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
async clearSelection() {
|
|
284
|
+
const { selectedId } = this;
|
|
285
|
+
if (!selectedId)
|
|
286
|
+
return;
|
|
287
|
+
this.chart.dispatchAction({
|
|
288
|
+
type: 'unselect',
|
|
289
|
+
seriesId: 'pie',
|
|
290
|
+
dataIndex: this.getIndexById(selectedId),
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
/// DOM ///
|
|
294
|
+
renderCenterBlock() {
|
|
295
|
+
const { icon, name, value, color } = this.centerData;
|
|
296
|
+
const { isClickable } = this;
|
|
297
|
+
const TagName = isClickable ? 'button' : 'div';
|
|
298
|
+
const displayValue = this.displayValue(value);
|
|
299
|
+
const props = isClickable
|
|
300
|
+
? {
|
|
301
|
+
onKeyUp: this.onButtonKeyUp,
|
|
302
|
+
onClick: this.onButtonClick,
|
|
303
|
+
ref: el => (this.centerButtonElement = el),
|
|
304
|
+
'aria-description': loc('tecton.element.chartDonut.button.description'),
|
|
305
|
+
'aria-roledescription': loc('tecton.element.chartDonut.button.roleDescription'),
|
|
306
|
+
}
|
|
307
|
+
: null;
|
|
308
|
+
return (h(TagName, Object.assign({ class: "center-card", "test-id": "centerCard" }, props),
|
|
309
|
+
icon && (h("q2-icon", { type: icon, style: color && { color } })),
|
|
310
|
+
name && h("div", { class: "name" }, name),
|
|
311
|
+
value && h("div", { class: "value" }, displayValue)));
|
|
312
|
+
}
|
|
313
|
+
render() {
|
|
314
|
+
return (h("click-elsewhere", { onChange: this.onClickElsewhere },
|
|
315
|
+
h("div", { ref: el => (this.chartContainer = el), class: "chart-container", "test-id": "chartContainer", onClick: this.onContainerClick }),
|
|
316
|
+
this.renderCenterBlock()));
|
|
317
|
+
}
|
|
318
|
+
static get is() { return "q2-chart-donut"; }
|
|
319
|
+
static get encapsulation() { return "shadow"; }
|
|
320
|
+
static get originalStyleUrls() { return {
|
|
321
|
+
"$": ["styles.scss"]
|
|
322
|
+
}; }
|
|
323
|
+
static get styleUrls() { return {
|
|
324
|
+
"$": ["styles.css"]
|
|
325
|
+
}; }
|
|
326
|
+
static get properties() { return {
|
|
327
|
+
"chartName": {
|
|
328
|
+
"type": "string",
|
|
329
|
+
"mutable": false,
|
|
330
|
+
"complexType": {
|
|
331
|
+
"original": "string",
|
|
332
|
+
"resolved": "string",
|
|
333
|
+
"references": {}
|
|
334
|
+
},
|
|
335
|
+
"required": false,
|
|
336
|
+
"optional": false,
|
|
337
|
+
"docs": {
|
|
338
|
+
"tags": [],
|
|
339
|
+
"text": ""
|
|
340
|
+
},
|
|
341
|
+
"attribute": "chart-name",
|
|
342
|
+
"reflect": true
|
|
343
|
+
},
|
|
344
|
+
"summaryIcon": {
|
|
345
|
+
"type": "string",
|
|
346
|
+
"mutable": false,
|
|
347
|
+
"complexType": {
|
|
348
|
+
"original": "string",
|
|
349
|
+
"resolved": "string",
|
|
350
|
+
"references": {}
|
|
351
|
+
},
|
|
352
|
+
"required": false,
|
|
353
|
+
"optional": false,
|
|
354
|
+
"docs": {
|
|
355
|
+
"tags": [],
|
|
356
|
+
"text": ""
|
|
357
|
+
},
|
|
358
|
+
"attribute": "summary-icon",
|
|
359
|
+
"reflect": true
|
|
360
|
+
},
|
|
361
|
+
"summaryName": {
|
|
362
|
+
"type": "string",
|
|
363
|
+
"mutable": false,
|
|
364
|
+
"complexType": {
|
|
365
|
+
"original": "string",
|
|
366
|
+
"resolved": "string",
|
|
367
|
+
"references": {}
|
|
368
|
+
},
|
|
369
|
+
"required": false,
|
|
370
|
+
"optional": false,
|
|
371
|
+
"docs": {
|
|
372
|
+
"tags": [],
|
|
373
|
+
"text": ""
|
|
374
|
+
},
|
|
375
|
+
"attribute": "summary-name",
|
|
376
|
+
"reflect": true
|
|
377
|
+
},
|
|
378
|
+
"innerRadius": {
|
|
379
|
+
"type": "string",
|
|
380
|
+
"mutable": true,
|
|
381
|
+
"complexType": {
|
|
382
|
+
"original": "string",
|
|
383
|
+
"resolved": "string",
|
|
384
|
+
"references": {}
|
|
385
|
+
},
|
|
386
|
+
"required": false,
|
|
387
|
+
"optional": false,
|
|
388
|
+
"docs": {
|
|
389
|
+
"tags": [],
|
|
390
|
+
"text": ""
|
|
391
|
+
},
|
|
392
|
+
"attribute": "inner-radius",
|
|
393
|
+
"reflect": false,
|
|
394
|
+
"defaultValue": "'70%'"
|
|
395
|
+
},
|
|
396
|
+
"outerRadius": {
|
|
397
|
+
"type": "string",
|
|
398
|
+
"mutable": true,
|
|
399
|
+
"complexType": {
|
|
400
|
+
"original": "string",
|
|
401
|
+
"resolved": "string",
|
|
402
|
+
"references": {}
|
|
403
|
+
},
|
|
404
|
+
"required": false,
|
|
405
|
+
"optional": false,
|
|
406
|
+
"docs": {
|
|
407
|
+
"tags": [],
|
|
408
|
+
"text": ""
|
|
409
|
+
},
|
|
410
|
+
"attribute": "outer-radius",
|
|
411
|
+
"reflect": false,
|
|
412
|
+
"defaultValue": "'85%'"
|
|
413
|
+
},
|
|
414
|
+
"selectedOffset": {
|
|
415
|
+
"type": "number",
|
|
416
|
+
"mutable": false,
|
|
417
|
+
"complexType": {
|
|
418
|
+
"original": "number",
|
|
419
|
+
"resolved": "number",
|
|
420
|
+
"references": {}
|
|
421
|
+
},
|
|
422
|
+
"required": false,
|
|
423
|
+
"optional": false,
|
|
424
|
+
"docs": {
|
|
425
|
+
"tags": [],
|
|
426
|
+
"text": ""
|
|
427
|
+
},
|
|
428
|
+
"attribute": "selected-offset",
|
|
429
|
+
"reflect": false,
|
|
430
|
+
"defaultValue": "10"
|
|
431
|
+
},
|
|
432
|
+
"hoverScaleSize": {
|
|
433
|
+
"type": "number",
|
|
434
|
+
"mutable": false,
|
|
435
|
+
"complexType": {
|
|
436
|
+
"original": "number",
|
|
437
|
+
"resolved": "number",
|
|
438
|
+
"references": {}
|
|
439
|
+
},
|
|
440
|
+
"required": false,
|
|
441
|
+
"optional": false,
|
|
442
|
+
"docs": {
|
|
443
|
+
"tags": [],
|
|
444
|
+
"text": ""
|
|
445
|
+
},
|
|
446
|
+
"attribute": "hover-scale-size",
|
|
447
|
+
"reflect": false,
|
|
448
|
+
"defaultValue": "5"
|
|
449
|
+
},
|
|
450
|
+
"format": {
|
|
451
|
+
"type": "string",
|
|
452
|
+
"mutable": false,
|
|
453
|
+
"complexType": {
|
|
454
|
+
"original": "'currency'",
|
|
455
|
+
"resolved": "\"currency\"",
|
|
456
|
+
"references": {}
|
|
457
|
+
},
|
|
458
|
+
"required": false,
|
|
459
|
+
"optional": false,
|
|
460
|
+
"docs": {
|
|
461
|
+
"tags": [],
|
|
462
|
+
"text": ""
|
|
463
|
+
},
|
|
464
|
+
"attribute": "format",
|
|
465
|
+
"reflect": true
|
|
466
|
+
},
|
|
467
|
+
"isClickable": {
|
|
468
|
+
"type": "boolean",
|
|
469
|
+
"mutable": false,
|
|
470
|
+
"complexType": {
|
|
471
|
+
"original": "boolean",
|
|
472
|
+
"resolved": "boolean",
|
|
473
|
+
"references": {}
|
|
474
|
+
},
|
|
475
|
+
"required": false,
|
|
476
|
+
"optional": false,
|
|
477
|
+
"docs": {
|
|
478
|
+
"tags": [],
|
|
479
|
+
"text": ""
|
|
480
|
+
},
|
|
481
|
+
"attribute": "is-clickable",
|
|
482
|
+
"reflect": true
|
|
483
|
+
},
|
|
484
|
+
"data": {
|
|
485
|
+
"type": "unknown",
|
|
486
|
+
"mutable": false,
|
|
487
|
+
"complexType": {
|
|
488
|
+
"original": "{ id: string; value: number; name: string; icon?: string; color?: string }[]",
|
|
489
|
+
"resolved": "{ id: string; value: number; name: string; icon?: string; color?: string; }[]",
|
|
490
|
+
"references": {}
|
|
491
|
+
},
|
|
492
|
+
"required": false,
|
|
493
|
+
"optional": false,
|
|
494
|
+
"docs": {
|
|
495
|
+
"tags": [],
|
|
496
|
+
"text": ""
|
|
497
|
+
},
|
|
498
|
+
"defaultValue": "[]"
|
|
499
|
+
}
|
|
500
|
+
}; }
|
|
501
|
+
static get states() { return {
|
|
502
|
+
"selectedId": {},
|
|
503
|
+
"hoveredId": {}
|
|
504
|
+
}; }
|
|
505
|
+
static get events() { return [{
|
|
506
|
+
"method": "change",
|
|
507
|
+
"name": "change",
|
|
508
|
+
"bubbles": true,
|
|
509
|
+
"cancelable": true,
|
|
510
|
+
"composed": true,
|
|
511
|
+
"docs": {
|
|
512
|
+
"tags": [],
|
|
513
|
+
"text": ""
|
|
514
|
+
},
|
|
515
|
+
"complexType": {
|
|
516
|
+
"original": "any",
|
|
517
|
+
"resolved": "any",
|
|
518
|
+
"references": {}
|
|
519
|
+
}
|
|
520
|
+
}, {
|
|
521
|
+
"method": "click",
|
|
522
|
+
"name": "click",
|
|
523
|
+
"bubbles": true,
|
|
524
|
+
"cancelable": true,
|
|
525
|
+
"composed": true,
|
|
526
|
+
"docs": {
|
|
527
|
+
"tags": [],
|
|
528
|
+
"text": ""
|
|
529
|
+
},
|
|
530
|
+
"complexType": {
|
|
531
|
+
"original": "any",
|
|
532
|
+
"resolved": "any",
|
|
533
|
+
"references": {}
|
|
534
|
+
}
|
|
535
|
+
}]; }
|
|
536
|
+
static get methods() { return {
|
|
537
|
+
"selectById": {
|
|
538
|
+
"complexType": {
|
|
539
|
+
"signature": "(id: string) => Promise<void>",
|
|
540
|
+
"parameters": [{
|
|
541
|
+
"tags": [],
|
|
542
|
+
"text": ""
|
|
543
|
+
}],
|
|
544
|
+
"references": {
|
|
545
|
+
"Promise": {
|
|
546
|
+
"location": "global"
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
"return": "Promise<void>"
|
|
550
|
+
},
|
|
551
|
+
"docs": {
|
|
552
|
+
"text": "",
|
|
553
|
+
"tags": []
|
|
554
|
+
}
|
|
555
|
+
},
|
|
556
|
+
"selectByIndex": {
|
|
557
|
+
"complexType": {
|
|
558
|
+
"signature": "(index: number) => Promise<void>",
|
|
559
|
+
"parameters": [{
|
|
560
|
+
"tags": [],
|
|
561
|
+
"text": ""
|
|
562
|
+
}],
|
|
563
|
+
"references": {
|
|
564
|
+
"Promise": {
|
|
565
|
+
"location": "global"
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
"return": "Promise<void>"
|
|
569
|
+
},
|
|
570
|
+
"docs": {
|
|
571
|
+
"text": "",
|
|
572
|
+
"tags": []
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
"clearSelection": {
|
|
576
|
+
"complexType": {
|
|
577
|
+
"signature": "() => Promise<void>",
|
|
578
|
+
"parameters": [],
|
|
579
|
+
"references": {
|
|
580
|
+
"Promise": {
|
|
581
|
+
"location": "global"
|
|
582
|
+
}
|
|
583
|
+
},
|
|
584
|
+
"return": "Promise<void>"
|
|
585
|
+
},
|
|
586
|
+
"docs": {
|
|
587
|
+
"text": "",
|
|
588
|
+
"tags": []
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}; }
|
|
592
|
+
static get elementRef() { return "hostElement"; }
|
|
593
|
+
static get watchers() { return [{
|
|
594
|
+
"propName": "chartName",
|
|
595
|
+
"methodName": "propsUpdates"
|
|
596
|
+
}, {
|
|
597
|
+
"propName": "innerRadius",
|
|
598
|
+
"methodName": "propsUpdates"
|
|
599
|
+
}, {
|
|
600
|
+
"propName": "outerRadius",
|
|
601
|
+
"methodName": "propsUpdates"
|
|
602
|
+
}, {
|
|
603
|
+
"propName": "hoverScaleSize",
|
|
604
|
+
"methodName": "propsUpdates"
|
|
605
|
+
}, {
|
|
606
|
+
"propName": "selectedOffset",
|
|
607
|
+
"methodName": "propsUpdates"
|
|
608
|
+
}, {
|
|
609
|
+
"propName": "data",
|
|
610
|
+
"methodName": "propsUpdates"
|
|
611
|
+
}, {
|
|
612
|
+
"propName": "data",
|
|
613
|
+
"methodName": "dataUpdated"
|
|
614
|
+
}, {
|
|
615
|
+
"propName": "innerRadius",
|
|
616
|
+
"methodName": "innerRadiusUpdated"
|
|
617
|
+
}, {
|
|
618
|
+
"propName": "outerRadius",
|
|
619
|
+
"methodName": "outerRadiusUpdated"
|
|
620
|
+
}]; }
|
|
621
|
+
static get listeners() { return [{
|
|
622
|
+
"name": "focus",
|
|
623
|
+
"method": "delegateFocus",
|
|
624
|
+
"target": undefined,
|
|
625
|
+
"capture": false,
|
|
626
|
+
"passive": false
|
|
627
|
+
}]; }
|
|
628
|
+
}
|