@operato/chart 8.0.0-beta.0 → 8.0.0-beta.2

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 (40) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/package.json +6 -6
  3. package/.editorconfig +0 -29
  4. package/.storybook/main.js +0 -3
  5. package/.storybook/preview.js +0 -52
  6. package/.storybook/server.mjs +0 -8
  7. package/demo/index.html +0 -33
  8. package/src/chartjs/config-converter.ts +0 -341
  9. package/src/chartjs/ox-chart-js.ts +0 -207
  10. package/src/editors/configurer.ts +0 -336
  11. package/src/editors/index.ts +0 -8
  12. package/src/editors/input-chart-abstract.ts +0 -202
  13. package/src/editors/input-chart-styles.ts +0 -206
  14. package/src/editors/ox-input-chart-hbar.ts +0 -157
  15. package/src/editors/ox-input-chart-mixed.ts +0 -241
  16. package/src/editors/ox-input-chart-pie.ts +0 -69
  17. package/src/editors/ox-input-chart-radar.ts +0 -56
  18. package/src/editors/ox-input-chart-timeseries.ts +0 -279
  19. package/src/editors/ox-property-editor-chart.ts +0 -72
  20. package/src/editors/templates/annotations.ts +0 -295
  21. package/src/editors/templates/display-value.ts +0 -111
  22. package/src/editors/templates/series.ts +0 -316
  23. package/src/global.d.ts +0 -1
  24. package/src/index.ts +0 -0
  25. package/src/progress/ox-progress-circle.ts +0 -133
  26. package/src/scichart/ox-scichart.ts +0 -151
  27. package/src/scichart/scichart-builder.ts +0 -508
  28. package/src/types.d.ts +0 -124
  29. package/stories/common.ts +0 -87
  30. package/stories/ox-input-chart-bar.stories.ts +0 -188
  31. package/stories/ox-input-chart-doughnut.stories.ts +0 -130
  32. package/stories/ox-input-chart-hbar.stories.ts +0 -188
  33. package/stories/ox-input-chart-line.stories.ts +0 -198
  34. package/stories/ox-input-chart-pie.stories.ts +0 -130
  35. package/stories/ox-input-chart-polar-area.stories.ts +0 -130
  36. package/stories/ox-input-chart-radar.stories.ts +0 -141
  37. package/stories/ox-input-chart-timeseries.stories.ts +0 -268
  38. package/tsconfig.json +0 -25
  39. package/web-dev-server.config.mjs +0 -27
  40. package/web-test-runner.config.mjs +0 -41
@@ -1,202 +0,0 @@
1
- import '@operato/i18n/ox-i18n.js'
2
-
3
- import { html, PropertyValues } from 'lit'
4
- import { property } from 'lit/decorators.js'
5
-
6
- import { random as randomColor, TinyColor } from '@ctrl/tinycolor'
7
-
8
- import { InputChartStyles } from './input-chart-styles'
9
- import { Configurer } from './configurer'
10
- import { OxFormField } from '@operato/input'
11
-
12
- export class InputChartAbstract extends OxFormField {
13
- static styles = [InputChartStyles]
14
-
15
- @property({ type: Object }) value: OperatoChart.ChartConfig | null = null
16
- @property({ type: String, attribute: 'chart-type' }) chartType?: OperatoChart.ChartType
17
-
18
- private _configurer?: Configurer
19
-
20
- get configurer(): Configurer {
21
- if (!this._configurer) {
22
- this._configurer = new Configurer(this.value, () => {
23
- return this.value || this.getDefaultChartConfig(this.chartType, this.getDefaultDatasets())
24
- })
25
- }
26
- return this._configurer
27
- }
28
-
29
- updated(changes: PropertyValues<this>) {
30
- if (changes.has('value')) {
31
- this.configurer.updateValue(this.value!)
32
- }
33
- }
34
-
35
- render() {
36
- const configurer = this.configurer
37
-
38
- return html`
39
- <legend><ox-i18n msgid="label.chart">Chart</ox-i18n></legend>
40
-
41
- <label for="theme"> <ox-i18n msgid="label.theme">Theme</ox-i18n> </label>
42
- <select id="theme" value-key="theme" class="select-content" .value=${configurer.theme || 'light'}>
43
- <option value="auto">auto</option>
44
- <option value="dark">dark</option>
45
- <option value="light" checked>light</option>
46
- </select>
47
-
48
- <input id="tooltip" type="checkbox" value-key="tooltip" ?checked=${configurer.tooltip} />
49
- <label for="tooltip"> <ox-i18n msgid="label.tooltip">Tooltip</ox-i18n> </label>
50
-
51
- <input id="animation" type="checkbox" value-key="animation" ?checked=${configurer.animation} />
52
- <label for="animation"> <ox-i18n msgid="label.animation">Animation</ox-i18n> </label>
53
-
54
- <input id="display" type="checkbox" value-key="display" ?checked=${configurer.display} />
55
- <label for="display"> <ox-i18n msgid="label.legend">Legend</ox-i18n> </label>
56
-
57
- <input id="stacked" type="checkbox" value-key="stacked" ?checked=${configurer.stacked} />
58
- <label for="stacked"> <ox-i18n msgid="label.stacked">Stacked</ox-i18n> </label>
59
-
60
- ${configurer.display
61
- ? html`
62
- <label for="position"> <ox-i18n msgid="label.position">Position</ox-i18n> </label>
63
- <select id="position" value-key="position" class="select-content" .value=${configurer.position || ''}>
64
- <option value="top">top</option>
65
- <option value="right">right</option>
66
- <option value="bottom">bottom</option>
67
- <option value="left">left</option>
68
- </select>
69
- `
70
- : html``}
71
- ${this.subTemplate()}
72
- `
73
- }
74
-
75
- connectedCallback() {
76
- super.connectedCallback()
77
-
78
- this.renderRoot.addEventListener('change', this.onValuesChanged.bind(this))
79
- }
80
-
81
- subTemplate() {
82
- return html``
83
- }
84
-
85
- getDefaultDatasets(): OperatoChart.Dataset[] {
86
- return [this.getDefaultDataset('bar')]
87
- }
88
-
89
- getDefaultDataset(seriesType: 'bar' | 'horizontalBar' | 'line' | 'radar' | 'pie'): OperatoChart.Dataset {
90
- return {
91
- label: 'Series 1',
92
- data: [],
93
- borderWidth: 1,
94
- dataKey: '',
95
- yAxisID: 'left',
96
- color: randomColor({
97
- hue: new TinyColor('#fff').clone().toString()
98
- }).toRgbString(),
99
- backgroundColor: '#FFFFFF',
100
- type: seriesType,
101
- stack: '',
102
- fill: false,
103
- lineTension: 0.4,
104
- pointStyle: 'circle',
105
- pointRadius: 3,
106
- valuePrefix: '',
107
- valueSuffix: '',
108
- displayValue: false
109
- }
110
- }
111
-
112
- getDefaultChartConfig(type?: OperatoChart.ChartType, datasets?: OperatoChart.Dataset[]): OperatoChart.ChartConfig {
113
- return {
114
- data: {
115
- datasets: datasets || [],
116
- labelDataKey: ''
117
- },
118
- options: {
119
- theme: 'light',
120
- tooltip: true,
121
- animation: true,
122
- legend: {
123
- display: true,
124
- position: 'top'
125
- },
126
- scales: {
127
- xAxes: [this.getDefaultAxisOptions()],
128
- yAxes: [this.getDefaultAxisOptions()]
129
- },
130
- stacked: false,
131
- xGridLine: true,
132
- yGridLine: true,
133
- y2ndGridLine: false,
134
- multiAxis: false
135
- },
136
- type
137
- }
138
- }
139
-
140
- getDefaultAxisOptions(): OperatoChart.AxisOptions {
141
- return {
142
- axisTitle: '',
143
- barSpacing: 0,
144
- categorySpacing: 0,
145
- barPercentage: 0.9,
146
- ticks: {
147
- display: true,
148
- autoMin: true,
149
- autoMax: true,
150
- min: undefined,
151
- max: undefined,
152
- stepSize: undefined
153
- }
154
- }
155
- }
156
-
157
- onValuesChanged(e: Event) {
158
- e.stopPropagation()
159
-
160
- const element = e.target as HTMLInputElement
161
- let key = element.getAttribute('value-key')
162
- let value = element.value
163
-
164
- if (!key) {
165
- return
166
- }
167
-
168
- value = this._getElementValue(element)
169
-
170
- const attrs = key.split('.')
171
- let attr = attrs.shift() || ''
172
- let variable: any = this.configurer
173
-
174
- while (attrs.length > 0) {
175
- variable = variable[attr]
176
- attr = attrs.shift() || ''
177
- }
178
-
179
- variable[attr] = value
180
-
181
- this.value = { ...this.configurer.value }
182
-
183
- this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
184
- this.requestUpdate()
185
- }
186
-
187
- _getElementValue(element: HTMLElement) {
188
- switch (element.tagName) {
189
- case 'INPUT':
190
- switch ((element as HTMLInputElement).type) {
191
- case 'checkbox':
192
- return (element as HTMLInputElement).checked
193
- case 'number':
194
- return Number((element as HTMLInputElement).value) || 0
195
- case 'text':
196
- return String((element as HTMLInputElement).value)
197
- }
198
- default:
199
- return (element as any).value
200
- }
201
- }
202
- }
@@ -1,206 +0,0 @@
1
- import { css } from 'lit'
2
-
3
- export const InputChartStyles = css`
4
- :host {
5
- display: grid;
6
- grid-template-columns: repeat(10, 1fr);
7
- grid-gap: 5px;
8
-
9
- background-color: var(--ox-input-background-color, var(--md-sys-color-surface));
10
- color: var(--ox-input-color, var(--md-sys-color-on-surface));
11
- }
12
-
13
- :host > * {
14
- box-sizing: border-box;
15
- grid-column: span 7;
16
- }
17
-
18
- :host > label {
19
- box-sizing: border-box;
20
- grid-column: span 3;
21
- }
22
-
23
- :host > legend {
24
- box-sizing: border-box;
25
- grid-column: 1 / -1;
26
- color: var(--md-sys-color-on-secondary-container, #e46c2e);
27
- font: var(--property-sidebar-fieldset-legend, bold 13px var(--theme-font));
28
- text-transform: capitalize;
29
- }
30
-
31
- #series-properties-container,
32
- #annotations-properties-container {
33
- display: grid;
34
- grid-template-columns: 1fr 25px;
35
- align-items: center;
36
- justify-content: center;
37
- }
38
-
39
- #series-properties-container > [tab-content],
40
- #annotations-properties-container > [tab-content] {
41
- grid-column: span 2;
42
- }
43
-
44
- #series-tab-header,
45
- #annotations-tab-header {
46
- display: grid;
47
- grid-template-columns: 25px 1fr 25px;
48
- grid-gap: 5px;
49
- overflow: hidden;
50
- border: 1px solid rgba(0, 0, 0, 0.2);
51
- border-bottom: 0;
52
- background-color: var(--md-sys-color-surface-variant);
53
- color: var(--md-sys-color-on-surface);
54
- box-sizing: border-box;
55
- padding-top: 3px;
56
- align-items: center;
57
- }
58
-
59
- #series-tab-header > div,
60
- #annotations-tab-header > div {
61
- height: 25px;
62
- }
63
-
64
- #series-tab-header md-icon[disabled],
65
- #annotations-tab-header md-icon[disabled] {
66
- opacity: 0.1;
67
- }
68
-
69
- #series-tabs,
70
- #annotations-tabs {
71
- display: flex;
72
- overflow: hidden;
73
- }
74
-
75
- #series-tab-header #series-tabs [tab] md-icon,
76
- #annotations-tab-header #annotations-tabs [tab] md-icon {
77
- margin-left: auto;
78
- padding: 2px;
79
- color: var(--md-sys-color-on-surface);
80
-
81
- --md-icon-size: 12px;
82
- }
83
-
84
- #add-series-button-container,
85
- #add-annotation-button-container {
86
- height: 100%;
87
- box-sizing: border-box;
88
- align-items: center;
89
- justify-content: center;
90
- padding-top: 3px;
91
- display: flex;
92
- border-bottom: rgba(0, 0, 0, 0.2) 1px solid;
93
- }
94
-
95
- #add-series-button,
96
- #add-annotation-button {
97
- width: 20px;
98
- height: 20px;
99
- padding: 0;
100
- color: var(--md-sys-color-on-secondary-container);
101
- }
102
-
103
- .tab-content {
104
- grid-column: 1 / -1;
105
-
106
- background-color: rgba(255, 255, 255, 0.5);
107
- border: 1px solid rgba(0, 0, 0, 0.2);
108
- border-width: 0 1px 1px 1px;
109
- padding: 5px;
110
- display: grid;
111
- grid-template-columns: repeat(10, 1fr);
112
- grid-gap: 5px;
113
- }
114
-
115
- .tab-content > * {
116
- box-sizing: border-box;
117
- grid-column: span 7;
118
- }
119
-
120
- label,
121
- .tab-content > label {
122
- grid-column: span 3;
123
- text-align: right;
124
- color: var(--md-sys-color-on-secondary-container);
125
- font-size: 0.8em;
126
- line-height: 2;
127
- text-transform: capitalize;
128
- }
129
-
130
- input,
131
- select {
132
- border: 1px solid rgba(0, 0, 0, 0.2);
133
- border-radius: var(--spacing-small);
134
- }
135
-
136
- input[type='checkbox'],
137
- .tab-content > input[type='checkbox'] {
138
- grid-column: span 4;
139
- justify-self: end;
140
- align-self: center;
141
- }
142
-
143
- input[type='checkbox'] + label,
144
- .tab-content > input[type='checkbox'] + label {
145
- grid-column: span 6;
146
-
147
- text-align: left;
148
- }
149
-
150
- [fullwidth] {
151
- grid-column: 1 / -1;
152
- margin: 0;
153
- border: 0;
154
- }
155
-
156
- div[tab] {
157
- display: flex;
158
- align-items: center;
159
- background-color: rgba(0, 0, 0, 0.2);
160
- border-width: 1px 1px 0 1px;
161
- padding: 0 5px;
162
- color: var(--md-sys-color-on-surface);
163
- box-sizing: border-box;
164
- min-width: 45px;
165
- }
166
-
167
- div[tab][disabled] {
168
- background-color: rgba(0, 0, 0, 0.1);
169
- }
170
-
171
- div[tab]:last-child {
172
- border-width: 0;
173
- }
174
-
175
- div[tab][selected] {
176
- background-color: var(--md-sys-color-surface);
177
- color: var(--md-sys-color-on-surface);
178
- }
179
-
180
- #display-value-container {
181
- display: grid;
182
- grid-template-columns: repeat(10, 1fr);
183
- grid-gap: 5px;
184
-
185
- background-color: var(--ox-input-background-color, var(--md-sys-color-surface));
186
- color: var(--ox-input-color, var(--md-sys-color-on-surface));
187
- }
188
-
189
- #display-value-container > * {
190
- box-sizing: border-box;
191
- grid-column: span 7;
192
- }
193
-
194
- #display-value-container > label {
195
- box-sizing: border-box;
196
- grid-column: span 3;
197
- }
198
-
199
- #display-value-container > legend {
200
- box-sizing: border-box;
201
- grid-column: 1 / -1;
202
- color: var(--md-sys-color-on-secondary-container, #e46c2e);
203
- font: var(--property-sidebar-fieldset-legend, bold 13px var(--theme-font));
204
- text-transform: capitalize;
205
- }
206
- `
@@ -1,157 +0,0 @@
1
- import '@material/web/icon/icon.js'
2
- import '@operato/input/ox-input-color.js'
3
- import '@operato/i18n/ox-i18n.js'
4
-
5
- import { html } from 'lit'
6
- import { customElement } from 'lit/decorators.js'
7
- import { ifDefined } from 'lit/directives/if-defined.js'
8
-
9
- import { InputChartAbstract } from './input-chart-abstract'
10
-
11
- import './templates/display-value'
12
-
13
- @customElement('ox-input-chart-hbar')
14
- export class OxInputChartHBar extends InputChartAbstract {
15
- static styles = InputChartAbstract.styles
16
-
17
- subTemplate() {
18
- const configurer = this.configurer
19
-
20
- return html`
21
- <legend><ox-i18n msgid="label.series">Series</ox-i18n></legend>
22
- <ox-chart-series
23
- .configurer=${configurer}
24
- .chartType=${this.chartType}
25
- value-key="datasets"
26
- fullwidth
27
- ></ox-chart-series>
28
-
29
- <legend><ox-i18n msgid="label.y-axes">Y Axes</ox-i18n></legend>
30
-
31
- <label for="label-data-key"> <ox-i18n msgid="label.data-key">Data Key</ox-i18n> </label>
32
- <input id="label-data-key" type="text" value-key="labelDataKey" value=${ifDefined(configurer.labelDataKey)} />
33
-
34
- <label for="y-axes0-axis-title"> <ox-i18n msgid="label.title">Title</ox-i18n> </label>
35
- <input
36
- id="y-axes0-axis-title"
37
- type="text"
38
- value-key="yAxes0.axisTitle"
39
- value=${ifDefined(configurer.yAxes0.axisTitle)}
40
- />
41
-
42
- <label for="y-axes0-bar-spacing"><ox-i18n msgid="label.bar-spacing">Bar Spacing</ox-i18n></label>
43
- <input
44
- id="y-axes0-bar-spacing"
45
- type="number"
46
- min="0"
47
- max="1"
48
- step="0.1"
49
- value-key="yAxes0.barSpacing"
50
- value=${ifDefined(configurer.yAxes0.barSpacing)}
51
- />
52
- <label for="y-axes0-category-spacing"><ox-i18n msgid="label.tick-spacing">Tick Spacing</ox-i18n></label>
53
- <input
54
- id="y-axes0-category-spacing"
55
- type="number"
56
- min="0"
57
- max="1"
58
- step="0.1"
59
- value-key="yAxes0.categorySpacing"
60
- value=${ifDefined(configurer.yAxes0.categorySpacing)}
61
- />
62
-
63
- <input
64
- id="x-grid-line"
65
- type="checkbox"
66
- value-key="value.options.xGridLine"
67
- ?checked=${configurer.config.options?.xGridLine}
68
- />
69
- <label for="x-grid-line"> <ox-i18n msgid="label.grid-line">Grid Line</ox-i18n> </label>
70
-
71
- <input
72
- id="x-axes0-ticks-display"
73
- type="checkbox"
74
- value-key="xAxes0.ticks.display"
75
- ?checked=${configurer.xAxes0.ticks?.display}
76
- />
77
- <label for="x-axes0-ticks-display"> <ox-i18n msgid="label.display-tick">Display Tick</ox-i18n> </label>
78
-
79
- <legend><ox-i18n msgid="label.x-axes">X Axes</ox-i18n></legend>
80
-
81
- <label for="x-axes0-axis-title"> <ox-i18n msgid="label.title">Title</ox-i18n> </label>
82
- <input
83
- id="x-axes0-axis-title"
84
- type="text"
85
- value-key="xAxes0.axisTitle"
86
- .value=${configurer.xAxes0.axisTitle || ''}
87
- />
88
-
89
- <input
90
- id="x-axes0-axis-min-auto"
91
- type="checkbox"
92
- value-key="xAxes0.ticks.autoMin"
93
- ?checked=${configurer.xAxes0.ticks?.autoMin}
94
- />
95
- <label for="x-axes0-axis-min-auto"> <ox-i18n msgid="label.axis-min-auto">Axis Min Auto</ox-i18n> </label>
96
-
97
- <input
98
- id="x-axes0-ticks-auto-max"
99
- type="checkbox"
100
- value-key="xAxes0.ticks.autoMax"
101
- ?checked=${configurer.xAxes0.ticks?.autoMax}
102
- />
103
- <label for="x-axes0-ticks-auto-max"> <ox-i18n msgid="label.axis-max-auto">Axis Max Auto</ox-i18n> </label>
104
-
105
- ${!configurer.xAxes0.ticks?.autoMin
106
- ? html`
107
- <label for="x-axes0-ticks-min"> <ox-i18n msgid="label.axis-min">Axis Min</ox-i18n> </label>
108
- <input
109
- id="x-axes0-ticks-min"
110
- type="number"
111
- value-key="xAxes0.ticks.min"
112
- value=${ifDefined(configurer.xAxes0.ticks?.min)}
113
- />
114
- `
115
- : html``}
116
- ${!configurer.xAxes0.ticks?.autoMax
117
- ? html`
118
- <label for="x-axes0-ticks-max"> <ox-i18n msgid="label.axis-max">Axis Max</ox-i18n> </label>
119
- <input
120
- id="x-axes0-ticks-max"
121
- type="number"
122
- value-key="xAxes0.ticks.max"
123
- value=${ifDefined(configurer.xAxes0.ticks?.max)}
124
- />
125
- `
126
- : html``}
127
-
128
- <label for="y-axes0-ticks-step-size"> <ox-i18n msgid="label.axis-step-size">Axis Step Size</ox-i18n> </label>
129
- <input
130
- id="y-axes0-ticks-step-size"
131
- type="number"
132
- value-key="yAxes0.ticks.stepSize"
133
- value=${ifDefined(configurer.yAxes0.ticks?.stepSize)}
134
- />
135
-
136
- <input
137
- id="y-grid-line"
138
- type="checkbox"
139
- value-key="value.options.yGridLine"
140
- ?checked=${configurer.config.options?.yGridLine}
141
- />
142
- <label for="y-grid-line"> <ox-i18n msgid="label.grid-line">Grid Line</ox-i18n> </label>
143
-
144
- <input
145
- id="y-axes0-ticks-display"
146
- type="checkbox"
147
- value-key="yAxes0.ticks.display"
148
- ?checked=${configurer.yAxes0.ticks?.display}
149
- />
150
- <label for="y-axes0-ticks-display"> <ox-i18n msgid="label.display-tick">Display Tick</ox-i18n> </label>
151
- `
152
- }
153
-
154
- getDefaultDatasets(): OperatoChart.Dataset[] {
155
- return [this.getDefaultDataset('horizontalBar')]
156
- }
157
- }