@operato/chart 7.0.36 → 7.0.39
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/CHANGELOG.md +19 -0
- package/dist/src/editors/configurer.d.ts +4 -2
- package/dist/src/editors/configurer.js +24 -13
- package/dist/src/editors/configurer.js.map +1 -1
- package/dist/src/editors/input-chart-abstract.d.ts +0 -26
- package/dist/src/editors/input-chart-abstract.js +1 -607
- package/dist/src/editors/input-chart-abstract.js.map +1 -1
- package/dist/src/editors/input-chart-styles.js +27 -0
- package/dist/src/editors/input-chart-styles.js.map +1 -1
- package/dist/src/editors/ox-input-chart-hbar.d.ts +1 -1
- package/dist/src/editors/ox-input-chart-hbar.js +2 -69
- package/dist/src/editors/ox-input-chart-hbar.js.map +1 -1
- package/dist/src/editors/ox-input-chart-mixed.d.ts +1 -0
- package/dist/src/editors/ox-input-chart-mixed.js +2 -2
- package/dist/src/editors/ox-input-chart-mixed.js.map +1 -1
- package/dist/src/editors/ox-input-chart-pie.d.ts +1 -0
- package/dist/src/editors/ox-input-chart-pie.js +3 -1
- package/dist/src/editors/ox-input-chart-pie.js.map +1 -1
- package/dist/src/editors/ox-input-chart-radar.d.ts +1 -0
- package/dist/src/editors/ox-input-chart-radar.js +2 -2
- package/dist/src/editors/ox-input-chart-radar.js.map +1 -1
- package/dist/src/editors/ox-input-chart-timeseries.d.ts +2 -0
- package/dist/src/editors/ox-input-chart-timeseries.js +9 -3
- package/dist/src/editors/ox-input-chart-timeseries.js.map +1 -1
- package/dist/src/editors/ox-property-editor-chart.js.map +1 -1
- package/dist/src/editors/templates/annotations.d.ts +23 -0
- package/dist/src/editors/templates/annotations.js +270 -0
- package/dist/src/editors/templates/annotations.js.map +1 -0
- package/dist/src/editors/templates/display-value.d.ts +12 -0
- package/dist/src/editors/templates/display-value.js +105 -0
- package/dist/src/editors/templates/display-value.js.map +1 -0
- package/dist/src/editors/templates/series.d.ts +31 -0
- package/dist/src/editors/templates/series.js +277 -0
- package/dist/src/editors/templates/series.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/editors/configurer.ts +25 -14
- package/src/editors/input-chart-abstract.ts +1 -655
- package/src/editors/input-chart-styles.ts +27 -0
- package/src/editors/ox-input-chart-hbar.ts +3 -73
- package/src/editors/ox-input-chart-mixed.ts +2 -2
- package/src/editors/ox-input-chart-pie.ts +3 -2
- package/src/editors/ox-input-chart-radar.ts +3 -2
- package/src/editors/ox-input-chart-timeseries.ts +10 -3
- package/src/editors/ox-property-editor-chart.ts +1 -1
- package/src/editors/templates/annotations.ts +287 -0
- package/src/editors/templates/display-value.ts +110 -0
- package/src/editors/templates/series.ts +304 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@material/web/icon/icon.js';
|
|
3
|
+
import { LitElement, html } from 'lit';
|
|
4
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
5
|
+
import { keyed } from 'lit/directives/keyed.js';
|
|
6
|
+
import { random as randomColor, TinyColor } from '@ctrl/tinycolor';
|
|
7
|
+
import './display-value';
|
|
8
|
+
let MultipleSeriesTemplate = class MultipleSeriesTemplate extends LitElement {
|
|
9
|
+
createRenderRoot() {
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
updated(_changedProperties) {
|
|
13
|
+
if (_changedProperties.has('configurer') || _changedProperties.has('chartType')) {
|
|
14
|
+
this.requestUpdate();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
return keyed(this.configurer.currentSeriesIndex, html `
|
|
19
|
+
<div id="series-properties-container" fullwidth>
|
|
20
|
+
<div id="series-tab-header" @wheel=${this._onWheelScroll}>
|
|
21
|
+
<md-icon id="series-tab-nav-left-button" @click=${this._scrollLeft}>chevron_left</md-icon>
|
|
22
|
+
<div id="series-tabs" active-tab-index=${this.configurer.currentSeriesIndex} fit-container>
|
|
23
|
+
${this._renderTabs()}
|
|
24
|
+
</div>
|
|
25
|
+
<md-icon id="series-tab-nav-right-button" @click=${this._scrollRight}>chevron_right</md-icon>
|
|
26
|
+
</div>
|
|
27
|
+
<div id="add-series-button-container">
|
|
28
|
+
<md-icon id="add-series-button" @click=${this._addSeries}>add</md-icon>
|
|
29
|
+
</div>
|
|
30
|
+
${this._renderSeriesForm()}
|
|
31
|
+
</div>
|
|
32
|
+
`);
|
|
33
|
+
}
|
|
34
|
+
_renderTabs() {
|
|
35
|
+
return this.configurer.datasets.map((dataset, index) => html `
|
|
36
|
+
<div
|
|
37
|
+
data-series=${index + 1}
|
|
38
|
+
data-tab-index=${index}
|
|
39
|
+
tab
|
|
40
|
+
?selected=${index === this.configurer.currentSeriesIndex}
|
|
41
|
+
@click=${() => this._selectTab(index)}
|
|
42
|
+
>
|
|
43
|
+
${index + 1}
|
|
44
|
+
${this.configurer.datasets.length > 1 && this.configurer.currentSeriesIndex === index
|
|
45
|
+
? html `<md-icon @click=${() => this._removeSeries(index)}>close</md-icon>`
|
|
46
|
+
: html ``}
|
|
47
|
+
</div>
|
|
48
|
+
`);
|
|
49
|
+
}
|
|
50
|
+
_renderSeriesForm() {
|
|
51
|
+
const configurer = this.configurer;
|
|
52
|
+
const chartType = this.chartType;
|
|
53
|
+
return html `
|
|
54
|
+
<div class="tab-content">
|
|
55
|
+
<label for="data-key"> <ox-i18n msgid="label.data-key">Data Key</ox-i18n> </label>
|
|
56
|
+
<input id="data-key" type="text" value-key="dataKey" .value=${configurer.dataKey || ''} />
|
|
57
|
+
|
|
58
|
+
${chartType === 'line' || chartType === 'bar'
|
|
59
|
+
? html `
|
|
60
|
+
<label for="series-type"> <ox-i18n msgid="label.series-type">Type</ox-i18n> </label>
|
|
61
|
+
<select
|
|
62
|
+
id="series-type"
|
|
63
|
+
class="select-content"
|
|
64
|
+
value-key="series.type"
|
|
65
|
+
.value=${configurer.series.type || ''}
|
|
66
|
+
>
|
|
67
|
+
<option value="bar" selected>Bar</option>
|
|
68
|
+
<option value="line">Line</option>
|
|
69
|
+
</select>
|
|
70
|
+
`
|
|
71
|
+
: html ``}
|
|
72
|
+
|
|
73
|
+
<label for="series-label"> <ox-i18n msgid="label.label">Label</ox-i18n> </label>
|
|
74
|
+
<input id="series-label" type="text" value-key="series.label" .value=${configurer.series.label || ''} />
|
|
75
|
+
|
|
76
|
+
${configurer.series.type === 'line'
|
|
77
|
+
? html `
|
|
78
|
+
<label for="series-line-tension"> <ox-i18n msgid="label.line-tension">Line Tension</ox-i18n> </label>
|
|
79
|
+
<select
|
|
80
|
+
id="series-line-tension"
|
|
81
|
+
class="select-content"
|
|
82
|
+
value-key="series.lineTension"
|
|
83
|
+
.value=${String(configurer.series.lineTension || 0)}
|
|
84
|
+
>
|
|
85
|
+
<option value="0.4">Smooth</option>
|
|
86
|
+
<option value="0">Angled</option>
|
|
87
|
+
</select>
|
|
88
|
+
`
|
|
89
|
+
: html ``}
|
|
90
|
+
${configurer.series.type === 'line'
|
|
91
|
+
? html `
|
|
92
|
+
<label for="series-border-width"> <ox-i18n msgid="label.border-width">Border Width</ox-i18n> </label>
|
|
93
|
+
<input
|
|
94
|
+
id="series-border-width"
|
|
95
|
+
type="number"
|
|
96
|
+
value-key="series.borderWidth"
|
|
97
|
+
.value=${String(configurer.series.borderWidth || 0)}
|
|
98
|
+
/>
|
|
99
|
+
`
|
|
100
|
+
: html ``}
|
|
101
|
+
|
|
102
|
+
<label for="series-color"> <ox-i18n msgid="label.color">Color</ox-i18n> </label>
|
|
103
|
+
<ox-input-color id="series-color" value-key="color" .value=${configurer.color}></ox-input-color>
|
|
104
|
+
|
|
105
|
+
${configurer.series.type === 'line'
|
|
106
|
+
? html `
|
|
107
|
+
<label for="series-point-style"> <ox-i18n msgid="label.point-shape">Point Shape</ox-i18n> </label>
|
|
108
|
+
<select
|
|
109
|
+
id="series-point-style"
|
|
110
|
+
class="select-content"
|
|
111
|
+
value-key="series.pointStyle"
|
|
112
|
+
.value=${configurer.series.pointStyle || ''}
|
|
113
|
+
>
|
|
114
|
+
<option value=""> </option>
|
|
115
|
+
<option value="circle">⚬</option>
|
|
116
|
+
<option value="triangle">▵</option>
|
|
117
|
+
<option value="rect">□</option>
|
|
118
|
+
<option value="rectRot">◇</option>
|
|
119
|
+
<option value="cross">+</option>
|
|
120
|
+
<option value="crossRot">⨉</option>
|
|
121
|
+
<option value="star">✱</option>
|
|
122
|
+
<option value="line">―</option>
|
|
123
|
+
<option value="dash">┄</option>
|
|
124
|
+
</select>
|
|
125
|
+
|
|
126
|
+
<label for="series-point-radius"> <ox-i18n msgid="label.point-size">Point Size</ox-i18n> </label>
|
|
127
|
+
<input
|
|
128
|
+
id="series-point-radius"
|
|
129
|
+
type="number"
|
|
130
|
+
value-key="series.pointRadius"
|
|
131
|
+
.value=${String(configurer.series.pointRadius || 0)}
|
|
132
|
+
/>
|
|
133
|
+
`
|
|
134
|
+
: html ``}
|
|
135
|
+
|
|
136
|
+
<label for="series-stack"> <ox-i18n msgid="label.stack-group">Stack group</ox-i18n> </label>
|
|
137
|
+
<input id="series-stack" type="text" value-key="series.stack" .value=${configurer.series.stack || ''} />
|
|
138
|
+
|
|
139
|
+
${configurer.series.type === 'line'
|
|
140
|
+
? html `
|
|
141
|
+
<input id="series-fill" type="checkbox" value-key="series.fill" ?checked=${configurer.series.fill} />
|
|
142
|
+
<label for="series-fill"> <ox-i18n msgid="label.fill">Fill</ox-i18n> </label>
|
|
143
|
+
`
|
|
144
|
+
: html ``}
|
|
145
|
+
${configurer.multiAxis && configurer.series.type !== 'horizontalBar'
|
|
146
|
+
? html `
|
|
147
|
+
<label for="series-y-axis-id"> <ox-i18n msgid="label.target-axis">Target Axis</ox-i18n> </label>
|
|
148
|
+
<select
|
|
149
|
+
id="series-y-axis-id"
|
|
150
|
+
class="select-content"
|
|
151
|
+
value-key="series.yAxisID"
|
|
152
|
+
.value=${configurer.series.yAxisID || ''}
|
|
153
|
+
>
|
|
154
|
+
<option value="left">Left</option>
|
|
155
|
+
<option value="right">Right</option>
|
|
156
|
+
</select>
|
|
157
|
+
`
|
|
158
|
+
: html ``}
|
|
159
|
+
|
|
160
|
+
<label></label>
|
|
161
|
+
<ox-chart-display-value .configurer=${configurer} fullwidth></ox-chart-display-value>
|
|
162
|
+
</div>
|
|
163
|
+
`;
|
|
164
|
+
}
|
|
165
|
+
_getSeriesModel({ chartType, datasetsLength, lastSeriesColor }) {
|
|
166
|
+
const addSeriesOption = {
|
|
167
|
+
label: `series ${datasetsLength + 1}`,
|
|
168
|
+
data: [],
|
|
169
|
+
borderWidth: 1,
|
|
170
|
+
dataKey: '',
|
|
171
|
+
yAxisID: 'left',
|
|
172
|
+
color: randomColor({
|
|
173
|
+
hue: lastSeriesColor.toHsv().h
|
|
174
|
+
}).toRgbString(),
|
|
175
|
+
stack: ''
|
|
176
|
+
};
|
|
177
|
+
addSeriesOption.type = addSeriesOption.chartType = chartType;
|
|
178
|
+
return addSeriesOption;
|
|
179
|
+
}
|
|
180
|
+
_selectTab(index) {
|
|
181
|
+
this.configurer.setCurrentSeriesIndex(index);
|
|
182
|
+
this.requestUpdate();
|
|
183
|
+
}
|
|
184
|
+
_removeSeries(index) {
|
|
185
|
+
this.configurer.removeSeries(index);
|
|
186
|
+
this.requestUpdate();
|
|
187
|
+
}
|
|
188
|
+
_addSeries() {
|
|
189
|
+
const configurer = this.configurer;
|
|
190
|
+
if (!configurer.config.data.datasets) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const lastSeriesIndex = configurer.config.data.datasets.length;
|
|
194
|
+
const chartType = configurer.series.type || configurer.config.type;
|
|
195
|
+
const color = configurer.datasets[lastSeriesIndex - 1]?.backgroundColor;
|
|
196
|
+
const lastSeriesColor = new TinyColor(Array.isArray(color) ? color[0] : color);
|
|
197
|
+
const seriesModel = this._getSeriesModel({
|
|
198
|
+
chartType: chartType,
|
|
199
|
+
datasetsLength: lastSeriesIndex,
|
|
200
|
+
lastSeriesColor
|
|
201
|
+
});
|
|
202
|
+
this.configurer.addSeries(seriesModel);
|
|
203
|
+
this.requestUpdate();
|
|
204
|
+
}
|
|
205
|
+
_onWheelScroll(event) {
|
|
206
|
+
const tabContainer = this.seriesTabs;
|
|
207
|
+
if (tabContainer) {
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
tabContainer.scrollLeft += event.deltaY;
|
|
210
|
+
this._onTabScroll();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
_scrollLeft() {
|
|
214
|
+
this._scrollTabContainer(-1);
|
|
215
|
+
}
|
|
216
|
+
_scrollRight() {
|
|
217
|
+
this._scrollTabContainer(1);
|
|
218
|
+
}
|
|
219
|
+
_scrollTabContainer(direction) {
|
|
220
|
+
const tabContainer = this.renderRoot.querySelector('#series-tabs');
|
|
221
|
+
if (tabContainer) {
|
|
222
|
+
tabContainer.style.scrollBehavior = 'smooth';
|
|
223
|
+
tabContainer.scrollLeft += direction * tabContainer.clientWidth;
|
|
224
|
+
}
|
|
225
|
+
setTimeout(() => {
|
|
226
|
+
tabContainer.style.scrollBehavior = 'auto';
|
|
227
|
+
this._onTabScroll();
|
|
228
|
+
}, 300);
|
|
229
|
+
}
|
|
230
|
+
_onTabScroll() {
|
|
231
|
+
let tabContainer;
|
|
232
|
+
let tabNavLeftButton;
|
|
233
|
+
let tabNavRightButton;
|
|
234
|
+
tabContainer = this.seriesTabs;
|
|
235
|
+
tabNavLeftButton = this.seriesTabNavLeftButton;
|
|
236
|
+
tabNavRightButton = this.seriesTabNavRightButton;
|
|
237
|
+
if (!tabContainer) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (tabContainer.clientWidth == tabContainer.scrollWidth) {
|
|
241
|
+
tabNavLeftButton.setAttribute('disabled', '');
|
|
242
|
+
tabNavRightButton.setAttribute('disabled', '');
|
|
243
|
+
}
|
|
244
|
+
else if (tabContainer.scrollLeft <= 0) {
|
|
245
|
+
tabNavLeftButton.setAttribute('disabled', '');
|
|
246
|
+
tabNavRightButton.removeAttribute('disabled');
|
|
247
|
+
}
|
|
248
|
+
else if (tabContainer.scrollLeft + tabContainer.clientWidth >= tabContainer.scrollWidth) {
|
|
249
|
+
tabNavLeftButton.removeAttribute('disabled');
|
|
250
|
+
tabNavRightButton.setAttribute('disabled', '');
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
tabNavLeftButton.removeAttribute('disabled');
|
|
254
|
+
tabNavRightButton.removeAttribute('disabled');
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
__decorate([
|
|
259
|
+
property({ type: Object })
|
|
260
|
+
], MultipleSeriesTemplate.prototype, "configurer", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
property({ type: String })
|
|
263
|
+
], MultipleSeriesTemplate.prototype, "chartType", void 0);
|
|
264
|
+
__decorate([
|
|
265
|
+
query('#series-tabs')
|
|
266
|
+
], MultipleSeriesTemplate.prototype, "seriesTabs", void 0);
|
|
267
|
+
__decorate([
|
|
268
|
+
query('#series-tab-nav-left-button')
|
|
269
|
+
], MultipleSeriesTemplate.prototype, "seriesTabNavLeftButton", void 0);
|
|
270
|
+
__decorate([
|
|
271
|
+
query('#series-tab-nav-right-button')
|
|
272
|
+
], MultipleSeriesTemplate.prototype, "seriesTabNavRightButton", void 0);
|
|
273
|
+
MultipleSeriesTemplate = __decorate([
|
|
274
|
+
customElement('ox-chart-series')
|
|
275
|
+
], MultipleSeriesTemplate);
|
|
276
|
+
export { MultipleSeriesTemplate };
|
|
277
|
+
//# sourceMappingURL=series.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"series.js","sourceRoot":"","sources":["../../../../src/editors/templates/series.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE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AAiB,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;QAChD,CAAC;aAAM,CAAC;YACN,gBAAgB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAA;YAC5C,iBAAiB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAA;QAC/C,CAAC;IACH,CAAC;CACF,CAAA;AA9R6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAAwB;AACvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAA0F;AAE9F;IAAtB,KAAK,CAAC,cAAc,CAAC;0DAAyB;AACT;IAArC,KAAK,CAAC,6BAA6B,CAAC;sEAAgC;AAC9B;IAAtC,KAAK,CAAC,8BAA8B,CAAC;uEAAiC;AAV5D,sBAAsB;IADlC,aAAa,CAAC,iBAAiB,CAAC;GACpB,sBAAsB,CAmSlC","sourcesContent":["import '@material/web/icon/icon.js'\n\nimport { LitElement, html, PropertyValues } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\nimport { keyed } from 'lit/directives/keyed.js'\nimport { MdIcon } from '@material/web/icon/icon.js'\nimport { random as randomColor, TinyColor } from '@ctrl/tinycolor'\n\nimport { Configurer } from '../configurer'\nimport './display-value'\n\n@customElement('ox-chart-series')\nexport class MultipleSeriesTemplate extends LitElement {\n createRenderRoot() {\n return this\n }\n\n @property({ type: Object }) configurer!: Configurer\n @property({ type: String }) chartType?: 'bar' | 'horizontalBar' | 'line' | 'radar' | 'pie' | 'doughnut' | 'polarArea'\n\n @query('#series-tabs') seriesTabs!: HTMLElement\n @query('#series-tab-nav-left-button') seriesTabNavLeftButton!: MdIcon\n @query('#series-tab-nav-right-button') seriesTabNavRightButton!: MdIcon\n\n protected updated(_changedProperties: PropertyValues): void {\n if (_changedProperties.has('configurer') || _changedProperties.has('chartType')) {\n this.requestUpdate()\n }\n }\n\n render() {\n return keyed(\n this.configurer.currentSeriesIndex,\n html`\n <div id=\"series-properties-container\" fullwidth>\n <div id=\"series-tab-header\" @wheel=${this._onWheelScroll}>\n <md-icon id=\"series-tab-nav-left-button\" @click=${this._scrollLeft}>chevron_left</md-icon>\n <div id=\"series-tabs\" active-tab-index=${this.configurer.currentSeriesIndex} fit-container>\n ${this._renderTabs()}\n </div>\n <md-icon id=\"series-tab-nav-right-button\" @click=${this._scrollRight}>chevron_right</md-icon>\n </div>\n <div id=\"add-series-button-container\">\n <md-icon id=\"add-series-button\" @click=${this._addSeries}>add</md-icon>\n </div>\n ${this._renderSeriesForm()}\n </div>\n `\n )\n }\n\n private _renderTabs() {\n return this.configurer.datasets.map(\n (dataset: OperatoChart.Dataset, index: number) => html`\n <div\n data-series=${index + 1}\n data-tab-index=${index}\n tab\n ?selected=${index === this.configurer.currentSeriesIndex}\n @click=${() => this._selectTab(index)}\n >\n ${index + 1}\n ${this.configurer.datasets.length > 1 && this.configurer.currentSeriesIndex === index\n ? html`<md-icon @click=${() => this._removeSeries(index)}>close</md-icon>`\n : html``}\n </div>\n `\n )\n }\n\n private _renderSeriesForm() {\n const configurer = this.configurer\n const chartType = this.chartType\n\n return html`\n <div class=\"tab-content\">\n <label for=\"data-key\"> <ox-i18n msgid=\"label.data-key\">Data Key</ox-i18n> </label>\n <input id=\"data-key\" type=\"text\" value-key=\"dataKey\" .value=${configurer.dataKey || ''} />\n\n ${chartType === 'line' || chartType === 'bar'\n ? html`\n <label for=\"series-type\"> <ox-i18n msgid=\"label.series-type\">Type</ox-i18n> </label>\n <select\n id=\"series-type\"\n class=\"select-content\"\n value-key=\"series.type\"\n .value=${configurer.series.type || ''}\n >\n <option value=\"bar\" selected>Bar</option>\n <option value=\"line\">Line</option>\n </select>\n `\n : html``}\n\n <label for=\"series-label\"> <ox-i18n msgid=\"label.label\">Label</ox-i18n> </label>\n <input id=\"series-label\" type=\"text\" value-key=\"series.label\" .value=${configurer.series.label || ''} />\n\n ${configurer.series.type === 'line'\n ? html`\n <label for=\"series-line-tension\"> <ox-i18n msgid=\"label.line-tension\">Line Tension</ox-i18n> </label>\n <select\n id=\"series-line-tension\"\n class=\"select-content\"\n value-key=\"series.lineTension\"\n .value=${String(configurer.series.lineTension || 0)}\n >\n <option value=\"0.4\">Smooth</option>\n <option value=\"0\">Angled</option>\n </select>\n `\n : html``}\n ${configurer.series.type === 'line'\n ? html`\n <label for=\"series-border-width\"> <ox-i18n msgid=\"label.border-width\">Border Width</ox-i18n> </label>\n <input\n id=\"series-border-width\"\n type=\"number\"\n value-key=\"series.borderWidth\"\n .value=${String(configurer.series.borderWidth || 0)}\n />\n `\n : html``}\n\n <label for=\"series-color\"> <ox-i18n msgid=\"label.color\">Color</ox-i18n> </label>\n <ox-input-color id=\"series-color\" value-key=\"color\" .value=${configurer.color}></ox-input-color>\n\n ${configurer.series.type === 'line'\n ? html`\n <label for=\"series-point-style\"> <ox-i18n msgid=\"label.point-shape\">Point Shape</ox-i18n> </label>\n <select\n id=\"series-point-style\"\n class=\"select-content\"\n value-key=\"series.pointStyle\"\n .value=${configurer.series.pointStyle || ''}\n >\n <option value=\"\"> </option>\n <option value=\"circle\">⚬</option>\n <option value=\"triangle\">▵</option>\n <option value=\"rect\">□</option>\n <option value=\"rectRot\">◇</option>\n <option value=\"cross\">+</option>\n <option value=\"crossRot\">⨉</option>\n <option value=\"star\">✱</option>\n <option value=\"line\">―</option>\n <option value=\"dash\">┄</option>\n </select>\n\n <label for=\"series-point-radius\"> <ox-i18n msgid=\"label.point-size\">Point Size</ox-i18n> </label>\n <input\n id=\"series-point-radius\"\n type=\"number\"\n value-key=\"series.pointRadius\"\n .value=${String(configurer.series.pointRadius || 0)}\n />\n `\n : html``}\n\n <label for=\"series-stack\"> <ox-i18n msgid=\"label.stack-group\">Stack group</ox-i18n> </label>\n <input id=\"series-stack\" type=\"text\" value-key=\"series.stack\" .value=${configurer.series.stack || ''} />\n\n ${configurer.series.type === 'line'\n ? html`\n <input id=\"series-fill\" type=\"checkbox\" value-key=\"series.fill\" ?checked=${configurer.series.fill} />\n <label for=\"series-fill\"> <ox-i18n msgid=\"label.fill\">Fill</ox-i18n> </label>\n `\n : html``}\n ${configurer.multiAxis && configurer.series.type !== 'horizontalBar'\n ? html`\n <label for=\"series-y-axis-id\"> <ox-i18n msgid=\"label.target-axis\">Target Axis</ox-i18n> </label>\n <select\n id=\"series-y-axis-id\"\n class=\"select-content\"\n value-key=\"series.yAxisID\"\n .value=${configurer.series.yAxisID || ''}\n >\n <option value=\"left\">Left</option>\n <option value=\"right\">Right</option>\n </select>\n `\n : html``}\n\n <label></label>\n <ox-chart-display-value .configurer=${configurer} fullwidth></ox-chart-display-value>\n </div>\n `\n }\n\n _getSeriesModel({\n chartType,\n datasetsLength,\n lastSeriesColor\n }: {\n chartType: string\n datasetsLength: number\n lastSeriesColor: TinyColor\n }) {\n const addSeriesOption: any = {\n label: `series ${datasetsLength + 1}`,\n data: [],\n borderWidth: 1,\n dataKey: '',\n yAxisID: 'left',\n color: randomColor({\n hue: lastSeriesColor.toHsv().h\n }).toRgbString(),\n stack: ''\n }\n\n addSeriesOption.type = addSeriesOption.chartType = chartType\n return addSeriesOption\n }\n\n private _selectTab(index: number) {\n this.configurer.setCurrentSeriesIndex(index)\n this.requestUpdate()\n }\n\n private _removeSeries(index: number) {\n this.configurer.removeSeries(index)\n this.requestUpdate()\n }\n\n private _addSeries() {\n const configurer = this.configurer\n\n if (!configurer.config.data.datasets) {\n return\n }\n\n const lastSeriesIndex = configurer.config.data.datasets.length\n const chartType = configurer.series.type || configurer.config.type\n const color = configurer.datasets[lastSeriesIndex - 1]?.backgroundColor\n const lastSeriesColor = new TinyColor(Array.isArray(color) ? color[0] : color)\n\n const seriesModel = this._getSeriesModel({\n chartType: chartType!,\n datasetsLength: lastSeriesIndex,\n lastSeriesColor\n })\n\n this.configurer.addSeries(seriesModel)\n this.requestUpdate()\n }\n\n private _onWheelScroll(event: WheelEvent) {\n const tabContainer = this.seriesTabs\n if (tabContainer) {\n event.preventDefault()\n\n tabContainer.scrollLeft += event.deltaY\n\n this._onTabScroll()\n }\n }\n\n private _scrollLeft() {\n this._scrollTabContainer(-1)\n }\n\n private _scrollRight() {\n this._scrollTabContainer(1)\n }\n\n private _scrollTabContainer(direction: number) {\n const tabContainer = this.renderRoot!.querySelector<HTMLElement>('#series-tabs')\n if (tabContainer) {\n tabContainer.style.scrollBehavior = 'smooth'\n tabContainer.scrollLeft += direction * tabContainer.clientWidth\n }\n\n setTimeout(() => {\n tabContainer!.style.scrollBehavior = 'auto'\n this._onTabScroll()\n }, 300)\n }\n\n private _onTabScroll() {\n let tabContainer: HTMLElement | null | undefined\n let tabNavLeftButton: MdIcon\n let tabNavRightButton: MdIcon\n\n tabContainer = this.seriesTabs\n tabNavLeftButton = this.seriesTabNavLeftButton\n tabNavRightButton = this.seriesTabNavRightButton\n\n if (!tabContainer) {\n return\n }\n\n if (tabContainer.clientWidth == tabContainer.scrollWidth) {\n tabNavLeftButton.setAttribute('disabled', '')\n tabNavRightButton.setAttribute('disabled', '')\n } else if (tabContainer.scrollLeft <= 0) {\n tabNavLeftButton.setAttribute('disabled', '')\n tabNavRightButton.removeAttribute('disabled')\n } else if (tabContainer.scrollLeft + tabContainer.clientWidth >= tabContainer.scrollWidth) {\n tabNavLeftButton.removeAttribute('disabled')\n tabNavRightButton.setAttribute('disabled', '')\n } else {\n tabNavLeftButton.removeAttribute('disabled')\n tabNavRightButton.removeAttribute('disabled')\n }\n }\n}\n"]}
|