@operato/scene-chartjs 2.0.0-alpha.9 → 2.0.0-beta.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/editors/property-editor-chartjs-abstract.d.ts +3 -3
  3. package/dist/editors/property-editor-chartjs-abstract.js +0 -8
  4. package/dist/editors/property-editor-chartjs-abstract.js.map +1 -1
  5. package/dist/editors/property-editor-chartjs-hbar.d.ts +5 -5
  6. package/dist/editors/property-editor-chartjs-hbar.js +42 -46
  7. package/dist/editors/property-editor-chartjs-hbar.js.map +1 -1
  8. package/dist/editors/property-editor-chartjs-mixed.d.ts +1 -1
  9. package/dist/editors/property-editor-chartjs-multi-series-abstract.d.ts +6 -8
  10. package/dist/editors/property-editor-chartjs-multi-series-abstract.js +92 -100
  11. package/dist/editors/property-editor-chartjs-multi-series-abstract.js.map +1 -1
  12. package/dist/editors/property-editor-chartjs-pie.d.ts +1 -1
  13. package/dist/editors/property-editor-chartjs-radar.d.ts +1 -1
  14. package/dist/editors/property-editor-chartjs-styles.js +35 -29
  15. package/dist/editors/property-editor-chartjs-styles.js.map +1 -1
  16. package/dist/editors/property-editor-chartjs.d.ts +1 -1
  17. package/dist/editors/property-editor-chartjs.js +3 -1
  18. package/dist/editors/property-editor-chartjs.js.map +1 -1
  19. package/dist/ox-chart.d.ts +1 -1
  20. package/dist/plugins/chart-series-highlight.d.ts +1 -0
  21. package/dist/plugins/chart-series-highlight.js +3 -1
  22. package/dist/plugins/chart-series-highlight.js.map +1 -1
  23. package/package.json +7 -8
  24. package/schema.graphql +61 -42
  25. package/src/editors/property-editor-chartjs-abstract.ts +0 -12
  26. package/src/editors/property-editor-chartjs-hbar.ts +42 -48
  27. package/src/editors/property-editor-chartjs-multi-series-abstract.ts +113 -123
  28. package/src/editors/property-editor-chartjs-styles.ts +35 -29
  29. package/src/editors/property-editor-chartjs.ts +3 -1
  30. package/src/plugins/chart-series-highlight.ts +3 -2
  31. package/tsconfig.json +1 -0
  32. package/tsconfig.tsbuildinfo +1 -1
@@ -1,14 +1,11 @@
1
- import '@material/mwc-icon-button'
2
- import '@polymer/iron-pages/iron-pages'
3
- import '@polymer/paper-tabs/paper-tabs'
4
-
1
+ import '@material/web/icon/icon.js'
5
2
  import '@operato/i18n/ox-i18n.js'
6
3
 
7
4
  import { css, html } from 'lit'
8
5
  import { query } from 'lit/decorators.js'
9
6
 
10
7
  import { Properties } from '@hatiolab/things-scene'
11
- import { IconButton } from '@material/mwc-icon-button'
8
+ import { MdIcon } from '@material/web/icon/icon.js'
12
9
 
13
10
  import PropertyEditorChartJSAbstract from './property-editor-chartjs-abstract'
14
11
 
@@ -16,7 +13,7 @@ export default class PropertyEditorChartJSMultiSeriesAbstract extends PropertyEd
16
13
  static styles = [
17
14
  ...PropertyEditorChartJSAbstract.styles,
18
15
  css`
19
- paper-tabs {
16
+ md-tabs {
20
17
  background-color: rgb(204, 204, 204);
21
18
  }
22
19
  input[type='text'],
@@ -52,8 +49,8 @@ export default class PropertyEditorChartJSMultiSeriesAbstract extends PropertyEd
52
49
  }
53
50
 
54
51
  @query('#tabs') tabs!: HTMLElement
55
- @query('#tab-nav-left-button') tabNavLeftButton!: IconButton
56
- @query('#tab-nav-right-button') tabNavRightButton!: IconButton
52
+ @query('#tab-nav-left-button') tabNavLeftButton!: MdIcon
53
+ @query('#tab-nav-right-button') tabNavRightButton!: MdIcon
57
54
 
58
55
  get color() {
59
56
  var oldVersionColor = this.series.backgroundColor
@@ -101,7 +98,7 @@ export default class PropertyEditorChartJSMultiSeriesAbstract extends PropertyEd
101
98
  }
102
99
 
103
100
  get tabContainer(): HTMLElement | null | undefined {
104
- return this.tabs.shadowRoot?.querySelector('#tabsContainer')
101
+ return this.tabs
105
102
  }
106
103
 
107
104
  firstUpdated() {
@@ -214,134 +211,127 @@ export default class PropertyEditorChartJSMultiSeriesAbstract extends PropertyEd
214
211
  return html`
215
212
  <div id="series-properties-container" fullwidth>
216
213
  <div id="tab-header">
217
- <mwc-icon-button
214
+ <md-icon
218
215
  id="tab-nav-left-button"
219
- icon="chevron_left"
220
- @click=${(e: Event) => {
216
+ @tap=${(e: Event) => {
221
217
  this._onTabScrollNavLeft(e)
222
218
  }}
223
219
  disabled
224
- ></mwc-icon-button>
225
- <paper-tabs
220
+ >chevron_left</md-icon
221
+ >
222
+ <div
226
223
  id="tabs"
227
- @iron-select=${(e: Event) => (this.currentSeriesIndex = (e.target as any).selected)}
228
- .selected=${this.currentSeriesIndex}
229
- no-bar
230
- noink
231
- scrollable
232
- hide-scroll-buttons
224
+ @change=${(e: Event) => {
225
+ this.currentSeriesIndex = (e.target as any).activeTabIndex
226
+ }}
227
+ active-tab-index=${this.currentSeriesIndex}
233
228
  fit-container
234
229
  >
235
230
  ${this.datasets.map(
236
231
  (dataset: any, index: number) => html`
237
- <paper-tab data-series="${index + 1}" noink
238
- >${index + 1}
232
+ <div
233
+ data-series=${index + 1}
234
+ data-tab-index=${index}
235
+ tab
236
+ ?selected=${index == this.currentSeriesIndex}
237
+ @click=${(e: Event) => {
238
+ const target = e.target as HTMLDivElement
239
+ this.currentSeriesIndex = Number(target.getAttribute('data-tab-index'))
240
+ }}
241
+ >
242
+ ${index + 1}
239
243
  ${!this.datasets || (this.datasets.length != 1 && this.currentSeriesIndex == index)
240
- ? html`
241
- <mwc-icon-button icon="close" @tap=${(e: Event) => this.onTapRemoveCurrentTab(e)}>
242
- </mwc-icon-button>
243
- `
244
+ ? html` <md-icon @tap="${(e: Event) => this.onTapRemoveCurrentTab(e)}"> close </md-icon> `
244
245
  : html``}
245
- </paper-tab>
246
+ </div>
246
247
  `
247
248
  )}
248
- </paper-tabs>
249
- <mwc-icon-button
249
+ </div>
250
+ <md-icon
250
251
  id="tab-nav-right-button"
251
- icon="chevron_right"
252
252
  @click=${(e: Event) => {
253
253
  this._onTabScrollNavRight(e)
254
254
  }}
255
255
  disabled
256
- ></mwc-icon-button>
256
+ >chevron_right</md-icon
257
+ >
257
258
  </div>
258
259
  <div id="add-series-button-container">
259
- <mwc-icon-button
260
- id="add-series-button"
261
- icon="add"
262
- @tap=${(e: Event) => this.onTapAddTab(e)}
263
- ></mwc-icon-button>
260
+ <md-icon id="add-series-button" @tap=${(e: Event) => this.onTapAddTab(e)}>add</md-icon>
264
261
  </div>
265
262
 
266
- <iron-pages .selected=${this.currentSeriesIndex} .attr-for-selected="series-index">
267
- ${this.datasets.map(
268
- (dataset: any, index: number) => html`
269
- <div class="tab-content" series-index="${index}">
270
- <label> <ox-i18n msgid="label.data-key">Data Key</ox-i18n> </label>
271
- <input type="text" value-key="dataKey" .value=${this.dataKey} />
272
-
273
- ${this.value.type == 'bar'
274
- ? html`
275
- <label> <ox-i18n msgid="label.type">type</ox-i18n> </label>
276
- <select class="select-content" value-key="series.type" .value=${this.series.type}>
277
- <option value="bar" selected>bar</option>
278
- <option value="line">line</option>
279
- </select>
280
- `
281
- : html``}
282
-
283
- <label> <ox-i18n msgid="label.label">label</ox-i18n> </label>
284
- <input type="text" value-key="series.label" .value=${this.series.label} />
285
-
286
- ${this.series.type == 'line'
287
- ? html`
288
- <label> <ox-i18n msgid="label.line-tension">line tension</ox-i18n> </label>
289
- <select class="select-content" value-key="series.lineTension" .value=${this.series.lineTension}>
290
- <option value="0.4">smooth</option>
291
- <option value="0">angled</option>
292
- </select>
293
- `
294
- : html``}
295
- ${this.series.type == 'line'
296
- ? html`
297
- <label> <ox-i18n msgid="label.border-width">border width</ox-i18n> </label>
298
- <input type="number" value-key="series.borderWidth" .value=${this.series.borderWidth} />
299
- `
300
- : html``}
301
-
302
- <label> <ox-i18n msgid="label.color">color</ox-i18n> </label>
303
- <ox-input-color value-key="color" .value=${this.color}></ox-input-color>
304
-
305
- ${this.series.type == 'line'
306
- ? html`
307
- <label> <ox-i18n msgid="label.point-shape">point shape</ox-i18n> </label>
308
- <select class="select-content" value-key="series.pointStyle" .value=${this.series.pointStyle}>
309
- <option value="circle">⚬</option>
310
- <option value="triangle">▵</option>
311
- <option value="rect">□</option>
312
- <option value="rectRot">◇</option>
313
- <option value="cross">+</option>
314
- <option value="crossRot">⨉</option>
315
- <option value="star">✱</option>
316
- <option value="line">―</option>
317
- <option value="dash">┄</option>
318
- </select>
319
-
320
- <label> <ox-i18n msgid="label.point-size">point size</ox-i18n> </label>
321
- <input type="number" value-key="series.pointRadius" .value=${this.series.pointRadius} />
322
- `
323
- : html``} <label> <ox-i18n msgid="label.stack-group">Stack group</ox-i18n> </label>
324
- <input type="text" value-key="series.stack" .value=${this.series.stack || ''} /> ${this.series.type ==
325
- 'line'
326
- ? html`
327
- <input type="checkbox" value-key="series.fill" .checked=${this.series.fill} />
328
- <label> <ox-i18n msgid="label.fill">fill</ox-i18n> </label>
329
- `
330
- : html``}
331
- ${this.multiAxis
332
- ? html`
333
- <label> <ox-i18n msgid="label.target-axis">target axis</ox-i18n> </label>
334
- <select class="select-content" value-key="series.yAxisID" .value=${this.series.yAxisID}>
335
- <option value="left">left</option>
336
- <option value="right">right</option>
337
- </select>
338
- `
339
- : html``}
340
- ${this.displayValueTemplate()}
341
- </div>
342
- `
343
- )}
344
- </iron-pages>
263
+ <div class="tab-content">
264
+ <label> <ox-i18n msgid="label.data-key">Data Key</ox-i18n> </label>
265
+ <input type="text" value-key="dataKey" .value=${this.dataKey} />
266
+
267
+ ${this.value.type == 'bar'
268
+ ? html`
269
+ <label> <ox-i18n msgid="label.type">type</ox-i18n> </label>
270
+ <select class="select-content" value-key="series.type" .value=${this.series.type}>
271
+ <option value="bar" selected>bar</option>
272
+ <option value="line">line</option>
273
+ </select>
274
+ `
275
+ : html``}
276
+
277
+ <label> <ox-i18n msgid="label.label">label</ox-i18n> </label>
278
+ <input type="text" value-key="series.label" .value=${this.series.label} />
279
+
280
+ ${this.series.type == 'line'
281
+ ? html`
282
+ <label> <ox-i18n msgid="label.line-tension">line tension</ox-i18n> </label>
283
+ <select class="select-content" value-key="series.lineTension" .value=${this.series.lineTension}>
284
+ <option value="0.4">smooth</option>
285
+ <option value="0">angled</option>
286
+ </select>
287
+ `
288
+ : html``}
289
+ ${this.series.type == 'line'
290
+ ? html`
291
+ <label> <ox-i18n msgid="label.border-width">border width</ox-i18n> </label>
292
+ <input type="number" value-key="series.borderWidth" .value=${this.series.borderWidth} />
293
+ `
294
+ : html``}
295
+
296
+ <label> <ox-i18n msgid="label.color">color</ox-i18n> </label>
297
+ <ox-input-color value-key="color" .value=${this.color}></ox-input-color>
298
+
299
+ ${this.series.type == 'line'
300
+ ? html`
301
+ <label> <ox-i18n msgid="label.point-shape">point shape</ox-i18n> </label>
302
+ <select class="select-content" value-key="series.pointStyle" .value=${this.series.pointStyle}>
303
+ <option value="circle">⚬</option>
304
+ <option value="triangle">▵</option>
305
+ <option value="rect">□</option>
306
+ <option value="rectRot">◇</option>
307
+ <option value="cross">+</option>
308
+ <option value="crossRot">⨉</option>
309
+ <option value="star">✱</option>
310
+ <option value="line">―</option>
311
+ <option value="dash">┄</option>
312
+ </select>
313
+
314
+ <label> <ox-i18n msgid="label.point-size">point size</ox-i18n> </label>
315
+ <input type="number" value-key="series.pointRadius" .value=${this.series.pointRadius} />
316
+ `
317
+ : html``} <label> <ox-i18n msgid="label.stack-group">Stack group</ox-i18n> </label>
318
+ <input type="text" value-key="series.stack" .value=${this.series.stack || ''} /> ${this.series.type == 'line'
319
+ ? html`
320
+ <input type="checkbox" value-key="series.fill" .checked=${this.series.fill} />
321
+ <label> <ox-i18n msgid="label.fill">fill</ox-i18n> </label>
322
+ `
323
+ : html``}
324
+ ${this.multiAxis
325
+ ? html`
326
+ <label> <ox-i18n msgid="label.target-axis">target axis</ox-i18n> </label>
327
+ <select class="select-content" value-key="series.yAxisID" .value=${this.series.yAxisID}>
328
+ <option value="left">left</option>
329
+ <option value="right">right</option>
330
+ </select>
331
+ `
332
+ : html``}
333
+ ${this.displayValueTemplate()}
334
+ </div>
345
335
  </div>
346
336
  `
347
337
  }
@@ -352,21 +342,21 @@ export default class PropertyEditorChartJSMultiSeriesAbstract extends PropertyEd
352
342
  }
353
343
 
354
344
  if (this.tabContainer.clientWidth == this.tabContainer.scrollWidth) {
355
- this.tabNavLeftButton.disabled = true
356
- this.tabNavRightButton.disabled = true
345
+ this.tabNavLeftButton.setAttribute('disabled', '')
346
+ this.tabNavRightButton.setAttribute('disabled', '')
357
347
  }
358
348
  // left-end
359
349
  else if (this.tabContainer.scrollLeft == 0) {
360
- this.tabNavLeftButton.disabled = true
361
- this.tabNavRightButton.disabled = false
350
+ this.tabNavLeftButton.setAttribute('disabled', '')
351
+ this.tabNavRightButton.removeAttribute('disabled')
362
352
  }
363
353
  // right-end
364
354
  else if (this.tabContainer.scrollLeft + this.tabContainer.clientWidth >= this.tabContainer.scrollWidth) {
365
- this.tabNavLeftButton.disabled = false
366
- this.tabNavRightButton.disabled = true
355
+ this.tabNavLeftButton.removeAttribute('disabled')
356
+ this.tabNavRightButton.setAttribute('disabled', '')
367
357
  } else {
368
- this.tabNavLeftButton.disabled = false
369
- this.tabNavRightButton.disabled = false
358
+ this.tabNavLeftButton.removeAttribute('disabled')
359
+ this.tabNavRightButton.removeAttribute('disabled')
370
360
  }
371
361
  }
372
362
 
@@ -5,9 +5,6 @@ export const PropertyEditorChartJSStyles = css`
5
5
  display: grid;
6
6
  grid-template-columns: repeat(10, 1fr);
7
7
  grid-gap: 5px;
8
-
9
- --mdc-icon-button-size: 24px;
10
- --mdc-icon-size: 24px;
11
8
  }
12
9
 
13
10
  :host > * {
@@ -23,7 +20,7 @@ export const PropertyEditorChartJSStyles = css`
23
20
  :host > legend {
24
21
  box-sizing: border-box;
25
22
  grid-column: 1 / -1;
26
- color: var(--secondary-text-color, #e46c2e);
23
+ color: var(--md-sys-color-on-secondary-container, #e46c2e);
27
24
  font: var(--property-sidebar-fieldset-legend, bold 13px var(--theme-font));
28
25
  text-transform: capitalize;
29
26
  }
@@ -35,7 +32,7 @@ export const PropertyEditorChartJSStyles = css`
35
32
  justify-content: center;
36
33
  }
37
34
 
38
- #series-properties-container > iron-pages {
35
+ #series-properties-container > [tab-content] {
39
36
  grid-column: span 2;
40
37
  }
41
38
 
@@ -46,23 +43,32 @@ export const PropertyEditorChartJSStyles = css`
46
43
  overflow: hidden;
47
44
  border: 1px solid rgba(0, 0, 0, 0.2);
48
45
  border-bottom: 0;
49
- background-color: #ccc;
46
+ background-color: var(--md-sys-color-surface-variant);
47
+ color: var(--md-sys-color-on-surface);
50
48
  box-sizing: border-box;
51
49
  padding-top: 3px;
52
50
  align-items: center;
53
51
  }
54
52
 
55
- #tab-header > paper-tabs {
53
+ #tab-header > div {
56
54
  height: 25px;
57
55
  }
58
56
 
59
- #tab-header paper-tabs mwc-icon-button {
57
+ #tab-header md-icon[disabled] {
58
+ opacity: 0.1;
59
+ }
60
+
61
+ #tabs {
60
62
  display: flex;
63
+ overflow: hidden;
64
+ }
65
+
66
+ #tab-header #tabs [tab] md-icon {
61
67
  margin-left: 5px;
62
68
  padding: 2px;
63
- color: #585858;
69
+ color: var(--md-sys-color-on-surface);
64
70
 
65
- --mdc-icon-size: 16px;
71
+ --md-icon-size: 12px;
66
72
  }
67
73
 
68
74
  #add-series-button-container {
@@ -79,10 +85,12 @@ export const PropertyEditorChartJSStyles = css`
79
85
  width: 20px;
80
86
  height: 20px;
81
87
  padding: 0;
82
- color: var(--primary-text-color);
88
+ color: var(--md-sys-color-on-secondary-container);
83
89
  }
84
90
 
85
91
  .tab-content {
92
+ grid-column: 1 / -1;
93
+
86
94
  background-color: rgba(255, 255, 255, 0.5);
87
95
  border: 1px solid rgba(0, 0, 0, 0.2);
88
96
  border-width: 0 1px 1px 1px;
@@ -101,12 +109,18 @@ export const PropertyEditorChartJSStyles = css`
101
109
  .tab-content > label {
102
110
  grid-column: span 3;
103
111
  text-align: right;
104
- color: var(--primary-text-color);
112
+ color: var(--md-sys-color-on-secondary-container);
105
113
  font-size: 0.8em;
106
114
  line-height: 2;
107
115
  text-transform: capitalize;
108
116
  }
109
117
 
118
+ input,
119
+ select {
120
+ border: 1px solid rgba(0, 0, 0, 0.2);
121
+ border-radius: var(--spacing-small);
122
+ }
123
+
110
124
  input[type='checkbox'],
111
125
  .tab-content > input[type='checkbox'] {
112
126
  grid-column: span 4;
@@ -127,35 +141,27 @@ export const PropertyEditorChartJSStyles = css`
127
141
  border: 0;
128
142
  }
129
143
 
130
- select {
131
- border: 1px solid rgba(0, 0, 0, 0.2);
132
- }
133
- input[type='text'] {
134
- border: 1px solid rgba(0, 0, 0, 0.2);
135
- }
136
-
137
- paper-tab {
144
+ div[tab] {
145
+ display: flex;
146
+ align-items: center;
138
147
  background-color: rgba(0, 0, 0, 0.2);
139
- background-color: #ccc;
140
148
  border-width: 1px 1px 0 1px;
141
149
  padding: 0 5px;
142
- color: #fff;
143
- font-size: 13px;
150
+ color: var(--md-sys-color-on-surface);
144
151
  box-sizing: border-box;
145
152
  min-width: 45px;
146
153
  }
147
154
 
148
- paper-tab[disabled] {
155
+ div[tab][disabled] {
149
156
  background-color: rgba(0, 0, 0, 0.1);
150
157
  }
151
158
 
152
- paper-tab:last-child {
159
+ div[tab]:last-child {
153
160
  border-width: 0;
154
161
  }
155
162
 
156
- paper-tabs paper-tab.iron-selected {
157
- background-color: #f6f8f9;
158
- border-radius: 5px 5px 0 0;
159
- color: #585858;
163
+ div[tab][selected] {
164
+ background-color: var(--md-sys-color-surface);
165
+ color: var(--md-sys-color-on-surface);
160
166
  }
161
167
  `
@@ -17,6 +17,8 @@ export default class ChartJSEditor extends OxPropertyEditor {
17
17
  :host {
18
18
  display: block;
19
19
  padding: 5px;
20
+
21
+ --md-elevated-button-container-height: 20px;
20
22
  }
21
23
 
22
24
  #chart-type {
@@ -31,7 +33,7 @@ export default class ChartJSEditor extends OxPropertyEditor {
31
33
 
32
34
  text-align: right;
33
35
 
34
- color: var(--primary-text-color);
36
+ color: var(--md-sys-color-on-secondary-container);
35
37
  font-size: 0.8em;
36
38
  line-height: 2;
37
39
  text-transform: capitalize;
@@ -1,4 +1,4 @@
1
- import Chart from 'chart.js'
1
+ import 'ses'
2
2
 
3
3
  function seriesHighlight(chartInstance: SceneChart, seriesData: SceneChart.DataSeries) {
4
4
  chartInstance.data.datasets?.forEach(dataset => {
@@ -9,10 +9,11 @@ function seriesHighlight(chartInstance: SceneChart, seriesData: SceneChart.DataS
9
9
 
10
10
  let highlightColor = highlight.color
11
11
  let highlightCondition = highlight.condition
12
+ const c = new Compartment()
12
13
 
13
14
  seriesData.forEach((sdata, sIndex) => {
14
15
  sdata.forEach((data: SceneChart.Data, i: number) => {
15
- if (!eval(highlightCondition)) {
16
+ if (!c.evaluate(highlightCondition)) {
16
17
  return
17
18
  }
18
19
 
package/tsconfig.json CHANGED
@@ -7,6 +7,7 @@
7
7
  "lib": ["es2019", "dom"],
8
8
  "strict": true,
9
9
  "esModuleInterop": false,
10
+ "allowJs": true,
10
11
  "allowSyntheticDefaultImports": true,
11
12
  "experimentalDecorators": true,
12
13
  "importHelpers": true,