@operato/chart 2.0.0-beta.27 → 2.0.0-beta.30

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 (67) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/src/chartjs/config-converter.d.ts +2 -1
  3. package/dist/src/chartjs/config-converter.js +1 -0
  4. package/dist/src/chartjs/config-converter.js.map +1 -1
  5. package/dist/src/chartjs/ox-chart-js.d.ts +3 -0
  6. package/dist/src/chartjs/ox-chart-js.js +28 -0
  7. package/dist/src/chartjs/ox-chart-js.js.map +1 -1
  8. package/dist/src/editors/input-chart-abstract.d.ts +4 -3
  9. package/dist/src/editors/input-chart-abstract.js +11 -6
  10. package/dist/src/editors/input-chart-abstract.js.map +1 -1
  11. package/dist/src/editors/input-chart-multi-series-abstract.js +1 -1
  12. package/dist/src/editors/input-chart-multi-series-abstract.js.map +1 -1
  13. package/dist/src/editors/ox-input-chart-hbar.d.ts +0 -1
  14. package/dist/src/editors/ox-input-chart-hbar.js +0 -3
  15. package/dist/src/editors/ox-input-chart-hbar.js.map +1 -1
  16. package/dist/src/editors/ox-input-chart-mixed.d.ts +0 -1
  17. package/dist/src/editors/ox-input-chart-mixed.js +0 -3
  18. package/dist/src/editors/ox-input-chart-mixed.js.map +1 -1
  19. package/dist/src/editors/ox-input-chart-pie.d.ts +2 -3
  20. package/dist/src/editors/ox-input-chart-pie.js +0 -3
  21. package/dist/src/editors/ox-input-chart-pie.js.map +1 -1
  22. package/dist/src/editors/ox-input-chart-radar.d.ts +0 -1
  23. package/dist/src/editors/ox-input-chart-radar.js +0 -3
  24. package/dist/src/editors/ox-input-chart-radar.js.map +1 -1
  25. package/dist/src/editors/ox-property-editor-chart.js +9 -7
  26. package/dist/src/editors/ox-property-editor-chart.js.map +1 -1
  27. package/dist/stories/common.d.ts +1 -1
  28. package/dist/stories/common.js.map +1 -1
  29. package/dist/stories/{ox-input-chart-mixed.stories.js → ox-input-chart-bar.stories.js} +6 -5
  30. package/dist/stories/ox-input-chart-bar.stories.js.map +1 -0
  31. package/dist/stories/ox-input-chart-doughnut.stories.d.ts +27 -0
  32. package/dist/stories/ox-input-chart-doughnut.stories.js +115 -0
  33. package/dist/stories/ox-input-chart-doughnut.stories.js.map +1 -0
  34. package/dist/stories/ox-input-chart-hbar.stories.js +1 -0
  35. package/dist/stories/ox-input-chart-hbar.stories.js.map +1 -1
  36. package/dist/stories/ox-input-chart-line.stories.d.ts +25 -0
  37. package/dist/stories/ox-input-chart-line.stories.js +184 -0
  38. package/dist/stories/ox-input-chart-line.stories.js.map +1 -0
  39. package/dist/stories/ox-input-chart-pie.stories.js +1 -0
  40. package/dist/stories/ox-input-chart-pie.stories.js.map +1 -1
  41. package/dist/stories/ox-input-chart-polar-area.stories.d.ts +27 -0
  42. package/dist/stories/ox-input-chart-polar-area.stories.js +115 -0
  43. package/dist/stories/ox-input-chart-polar-area.stories.js.map +1 -0
  44. package/dist/stories/ox-input-chart-radar.stories.js +1 -0
  45. package/dist/stories/ox-input-chart-radar.stories.js.map +1 -1
  46. package/dist/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +3 -3
  48. package/src/chartjs/config-converter.ts +1 -0
  49. package/src/chartjs/ox-chart-js.ts +28 -0
  50. package/src/editors/input-chart-abstract.ts +13 -12
  51. package/src/editors/input-chart-multi-series-abstract.ts +2 -2
  52. package/src/editors/ox-input-chart-hbar.ts +0 -4
  53. package/src/editors/ox-input-chart-mixed.ts +0 -4
  54. package/src/editors/ox-input-chart-pie.ts +2 -9
  55. package/src/editors/ox-input-chart-radar.ts +0 -4
  56. package/src/editors/ox-property-editor-chart.ts +9 -7
  57. package/src/types.d.ts +3 -2
  58. package/stories/common.ts +1 -1
  59. package/stories/{ox-input-chart-mixed.stories.ts → ox-input-chart-bar.stories.ts} +5 -4
  60. package/stories/ox-input-chart-doughnut.stories.ts +130 -0
  61. package/stories/ox-input-chart-hbar.stories.ts +1 -0
  62. package/stories/ox-input-chart-line.stories.ts +198 -0
  63. package/stories/ox-input-chart-pie.stories.ts +1 -0
  64. package/stories/ox-input-chart-polar-area.stories.ts +130 -0
  65. package/stories/ox-input-chart-radar.stories.ts +1 -0
  66. package/dist/stories/ox-input-chart-mixed.stories.js.map +0 -1
  67. /package/dist/stories/{ox-input-chart-mixed.stories.d.ts → ox-input-chart-bar.stories.d.ts} +0 -0
@@ -60,19 +60,21 @@ export class ChartEditor extends OxPropertyEditor {
60
60
  ${!value
61
61
  ? html``
62
62
  : value.type == 'line'
63
- ? html` <ox-input-chart-mixed .value=${value} fullwidth></ox-input-chart-mixed> `
63
+ ? html` <ox-input-chart-mixed .value=${value} chart-type="line" fullwidth></ox-input-chart-mixed> `
64
64
  : value.type == 'horizontalBar'
65
- ? html` <ox-input-chart-hbar .value=${value} fullwidth></ox-input-chart-hbar> `
65
+ ? html` <ox-input-chart-hbar .value=${value} chart-type="horizontalBar" fullwidth></ox-input-chart-hbar> `
66
66
  : value.type == 'bar'
67
- ? html` <ox-input-chart-mixed .value=${value} fullwidth></ox-input-chart-mixed> `
67
+ ? html` <ox-input-chart-mixed .value=${value} chart-type="bar" fullwidth></ox-input-chart-mixed> `
68
68
  : value.type == 'pie'
69
- ? html` <ox-input-chart-pie .value=${value} fullwidth></ox-input-chart-pie> `
69
+ ? html` <ox-input-chart-pie .value=${value} chart-type="pie" fullwidth></ox-input-chart-pie> `
70
70
  : value.type == 'doughnut'
71
- ? html` <ox-input-chart-pie .value=${value} fullwidth></ox-input-chart-pie> `
71
+ ? html` <ox-input-chart-pie .value=${value} chart-type="doughnut" fullwidth></ox-input-chart-pie> `
72
72
  : value.type == 'polarArea'
73
- ? html` <ox-input-chart-pie .value=${value} fullwidth></ox-input-chart-pie> `
73
+ ? html` <ox-input-chart-pie .value=${value} chart-type="polarArea" fullwidth></ox-input-chart-pie> `
74
74
  : value.type == 'radar'
75
- ? html` <ox-input-chart-radar .value=${value} fullwidth></ox-input-chart-radar> `
75
+ ? html`
76
+ <ox-input-chart-radar .value=${value} chart-type="radar" fullwidth></ox-input-chart-radar>
77
+ `
76
78
  : html``}
77
79
  `
78
80
  }
package/src/types.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  declare namespace OperatoChart {
2
+ export type ChartType = 'bar' | 'horizontalBar' | 'line' | 'radar' | 'pie' | 'doughnut' | 'polarArea' | undefined
2
3
  export interface ChartConfig {
3
4
  data: ChartData
4
5
  options?: ChartOptions
5
- type?: string
6
+ type?: ChartType
6
7
  }
7
8
 
8
9
  export interface ChartData {
@@ -18,7 +19,7 @@ declare namespace OperatoChart {
18
19
  dataKey?: string
19
20
  yAxisID?: string
20
21
  color?: string | string[]
21
- type?: 'bar' | 'horizontalBar' | 'line' | 'radar' | 'pie' | 'mixed'
22
+ type?: ChartType
22
23
  backgroundColor?: string | string[]
23
24
  stack?: string
24
25
  fill?: boolean
package/stories/common.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export function getDefaultChartConfig(
2
- type: 'bar' | 'line' | 'pie' | 'radar' | 'mixed',
2
+ type: OperatoChart.ChartType,
3
3
  datasets?: OperatoChart.Dataset[]
4
4
  ): OperatoChart.ChartConfig {
5
5
  return {
@@ -7,7 +7,7 @@ import '../src/scichart/ox-scichart.js'
7
7
  import { data, getDefaultChartConfig } from './common.js'
8
8
 
9
9
  export default {
10
- title: 'ox-input-chart-mixed',
10
+ title: 'ox-input-chart-mixed for bar',
11
11
  component: 'ox-input-chart-mixed',
12
12
  argTypes: {
13
13
  value: { control: 'object' }
@@ -84,6 +84,7 @@ const Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`
84
84
 
85
85
  <div class="container light">
86
86
  <ox-input-chart-mixed
87
+ chart-type="bar"
87
88
  id="editor"
88
89
  .value=${value}
89
90
  @change=${(e: CustomEvent) => {
@@ -124,7 +125,7 @@ Default.args = {}
124
125
  export const WithData = Template.bind({})
125
126
  WithData.args = {
126
127
  value: {
127
- ...getDefaultChartConfig('mixed'),
128
+ ...getDefaultChartConfig('bar'),
128
129
  data: {
129
130
  datasets: [
130
131
  {
@@ -162,9 +163,9 @@ WithData.args = {
162
163
  export const MultiAxis = Template.bind({})
163
164
  MultiAxis.args = {
164
165
  value: {
165
- ...getDefaultChartConfig('mixed'),
166
+ ...getDefaultChartConfig('bar'),
166
167
  options: {
167
- ...getDefaultChartConfig('mixed').options,
168
+ ...getDefaultChartConfig('bar').options,
168
169
  multiAxis: true
169
170
  },
170
171
  data: {
@@ -0,0 +1,130 @@
1
+ import { html, TemplateResult } from 'lit'
2
+
3
+ import '../src/editors/ox-input-chart-pie.js'
4
+ import '../src/chartjs/ox-chart-js.js'
5
+
6
+ import { data, getDefaultChartConfig } from './common.js'
7
+
8
+ export default {
9
+ title: 'ox-input-chart-pie for doughnut',
10
+ component: 'ox-input-chart-pie',
11
+ argTypes: {
12
+ value: { control: 'object' },
13
+ currentSeriesIndex: { control: 'number' }
14
+ }
15
+ }
16
+
17
+ interface Story<T> {
18
+ (args: T): TemplateResult
19
+ args?: Partial<T>
20
+ argTypes?: Record<string, unknown>
21
+ }
22
+
23
+ interface ArgTypes {
24
+ value: OperatoChart.ChartConfig
25
+ currentSeriesIndex: number
26
+ }
27
+
28
+ const Template: Story<ArgTypes> = ({ value, currentSeriesIndex }: ArgTypes) => html`
29
+ <link
30
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
31
+ rel="stylesheet"
32
+ />
33
+ <link
34
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
35
+ rel="stylesheet"
36
+ />
37
+ <link
38
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
39
+ rel="stylesheet"
40
+ />
41
+
42
+ <link href="/themes/light.css" rel="stylesheet" />
43
+ <link href="/themes/dark.css" rel="stylesheet" />
44
+ <link href="/themes/spacing.css" rel="stylesheet" />
45
+
46
+ <style>
47
+ .container {
48
+ width: 100%;
49
+ height: 100%;
50
+
51
+ display: flex;
52
+ flex-direction: row;
53
+ overflow-y: auto;
54
+ padding: var(--spacing-medium);
55
+ }
56
+
57
+ .container.dark {
58
+ background-color: black;
59
+ }
60
+
61
+ #editor {
62
+ width: 300px;
63
+ }
64
+
65
+ #chart {
66
+ flex: 1;
67
+ }
68
+ </style>
69
+
70
+ <div style="background-color: black; color: white;">
71
+ Type 'count' or 'average' for series dataKey, type 'year' for axis's dataKey
72
+ </div>
73
+
74
+ <div class="container light">
75
+ <ox-input-chart-pie
76
+ chart-type="doughnut"
77
+ id="editor"
78
+ .value=${value}
79
+ @change=${(e: CustomEvent) => {
80
+ const target = e.currentTarget as any
81
+ const config = target.value
82
+ const chartjs = document.querySelector('#chartjs') as HTMLElement
83
+ if (chartjs) {
84
+ ;(chartjs as any).config = { ...config }
85
+ }
86
+
87
+ const container = document.querySelector('.container') as HTMLElement
88
+ if (container) {
89
+ const theme = config.options.theme
90
+ if (theme == 'dark') {
91
+ container.classList.remove('light')
92
+ container.classList.add('dark')
93
+ } else {
94
+ container.classList.remove('dark')
95
+ container.classList.add('light')
96
+ }
97
+ }
98
+ }}
99
+ ></ox-input-chart-pie>
100
+ <ox-chart-js id="chartjs" .data=${data}></ox-chart-js>
101
+ </div>
102
+ `
103
+
104
+ export const Default = Template.bind({})
105
+ Default.args = {
106
+ currentSeriesIndex: 0
107
+ }
108
+
109
+ export const WithData = Template.bind({})
110
+ WithData.args = {
111
+ value: {
112
+ ...getDefaultChartConfig('doughnut'),
113
+ data: {
114
+ datasets: [
115
+ {
116
+ label: 'Doughnut Series',
117
+ data: [10, 20, 30],
118
+ backgroundColor: ['rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(75, 192, 192, 0.2)'],
119
+ borderColor: ['rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(75, 192, 192, 1)'],
120
+ borderWidth: 1
121
+ }
122
+ ],
123
+ labelDataKey: 'labels'
124
+ },
125
+ options: {
126
+ legend: { display: true }
127
+ }
128
+ },
129
+ currentSeriesIndex: 0
130
+ }
@@ -83,6 +83,7 @@ const Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`
83
83
  </div>
84
84
  <div class="container light">
85
85
  <ox-input-chart-hbar
86
+ chart-type="horizontalBar"
86
87
  id="editor"
87
88
  .value=${value}
88
89
  @change=${async (e: CustomEvent) => {
@@ -0,0 +1,198 @@
1
+ import { html, TemplateResult } from 'lit'
2
+
3
+ import '../src/editors/ox-input-chart-mixed.js'
4
+ import '../src/chartjs/ox-chart-js.js'
5
+ import '../src/scichart/ox-scichart.js'
6
+
7
+ import { data, getDefaultChartConfig } from './common.js'
8
+
9
+ export default {
10
+ title: 'ox-input-chart-mixed for line',
11
+ component: 'ox-input-chart-mixed',
12
+ argTypes: {
13
+ value: { control: 'object' }
14
+ }
15
+ }
16
+
17
+ interface Story<T> {
18
+ (args: T): TemplateResult
19
+ args?: Partial<T>
20
+ argTypes?: Record<string, unknown>
21
+ }
22
+
23
+ interface ArgTypes {
24
+ value: OperatoChart.ChartConfig
25
+ }
26
+
27
+ const Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`
28
+ <link
29
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
30
+ rel="stylesheet"
31
+ />
32
+ <link
33
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
34
+ rel="stylesheet"
35
+ />
36
+ <link
37
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
38
+ rel="stylesheet"
39
+ />
40
+
41
+ <link href="/themes/light.css" rel="stylesheet" />
42
+ <link href="/themes/dark.css" rel="stylesheet" />
43
+ <link href="/themes/spacing.css" rel="stylesheet" />
44
+
45
+ <style>
46
+ .container {
47
+ width: 100%;
48
+ height: 100%;
49
+
50
+ display: flex;
51
+ flex-direction: row;
52
+ overflow-y: auto;
53
+ padding: var(--spacing-medium);
54
+ }
55
+
56
+ .container.dark {
57
+ background-color: black;
58
+ }
59
+
60
+ #editor {
61
+ width: 300px;
62
+ }
63
+
64
+ #charts {
65
+ flex: 1;
66
+
67
+ display: flex;
68
+ flex-direction: column;
69
+ padding: 10px;
70
+ }
71
+
72
+ #chartjs {
73
+ flex: 1;
74
+ }
75
+
76
+ #scichart {
77
+ flex: 1;
78
+ }
79
+ </style>
80
+
81
+ <div style="background-color: black; color: white;">
82
+ Type 'count' or 'average' for series dataKey, type 'year' for axis's dataKey
83
+ </div>
84
+
85
+ <div class="container light">
86
+ <ox-input-chart-mixed
87
+ chart-type="line"
88
+ id="editor"
89
+ .value=${value}
90
+ @change=${(e: CustomEvent) => {
91
+ const target = e.currentTarget as any
92
+ const config = target.value
93
+ const chartjs = document.querySelector('#chartjs') as HTMLElement
94
+ if (chartjs) {
95
+ ;(chartjs as any).config = { ...config }
96
+ }
97
+ const scichart = document.querySelector('#scichart') as HTMLElement
98
+ if (scichart) {
99
+ ;(scichart as any).config = config
100
+ }
101
+
102
+ const container = document.querySelector('.container') as HTMLElement
103
+ if (container) {
104
+ const theme = config.options.theme
105
+ if (theme == 'dark') {
106
+ container.classList.remove('light')
107
+ container.classList.add('dark')
108
+ } else {
109
+ container.classList.remove('dark')
110
+ container.classList.add('light')
111
+ }
112
+ }
113
+ }}
114
+ ></ox-input-chart-mixed>
115
+ <div id="charts">
116
+ <ox-chart-js id="chartjs" .data=${data}></ox-chart-js>
117
+ <ox-scichart id="scichart"></ox-scichart>
118
+ </div>
119
+ </div>
120
+ `
121
+
122
+ export const Default = Template.bind({})
123
+ Default.args = {}
124
+
125
+ export const WithData = Template.bind({})
126
+ WithData.args = {
127
+ value: {
128
+ ...getDefaultChartConfig('line'),
129
+ data: {
130
+ datasets: [
131
+ {
132
+ label: 'Bar Series',
133
+ type: 'bar',
134
+ data: [10, 20, 30],
135
+ backgroundColor: 'rgba(255, 99, 132, 0.2)',
136
+ borderColor: 'rgba(255, 99, 132, 1)',
137
+ borderWidth: 1
138
+ },
139
+ {
140
+ label: 'Line Series',
141
+ type: 'line',
142
+ data: [15, 25, 35],
143
+ borderColor: 'rgba(54, 162, 235, 1)',
144
+ borderWidth: 1,
145
+ fill: false,
146
+ lineTension: 0.4,
147
+ pointStyle: 'circle',
148
+ pointRadius: 3
149
+ }
150
+ ],
151
+ labelDataKey: 'labels'
152
+ },
153
+ options: {
154
+ scales: {
155
+ xAxes: [{ ticks: { beginAtZero: true } }],
156
+ yAxes: [{ ticks: { beginAtZero: true } }]
157
+ },
158
+ legend: { display: true }
159
+ }
160
+ }
161
+ }
162
+
163
+ export const MultiAxis = Template.bind({})
164
+ MultiAxis.args = {
165
+ value: {
166
+ ...getDefaultChartConfig('line'),
167
+ options: {
168
+ ...getDefaultChartConfig('line').options,
169
+ multiAxis: true
170
+ },
171
+ data: {
172
+ datasets: [
173
+ {
174
+ label: 'Bar Series',
175
+ type: 'bar',
176
+ data: [10, 20, 30],
177
+ backgroundColor: 'rgba(255, 99, 132, 0.2)',
178
+ borderColor: 'rgba(255, 99, 132, 1)',
179
+ borderWidth: 1,
180
+ yAxisID: 'left'
181
+ },
182
+ {
183
+ label: 'Line Series',
184
+ type: 'line',
185
+ data: [15, 25, 35],
186
+ borderColor: 'rgba(54, 162, 235, 1)',
187
+ borderWidth: 1,
188
+ fill: false,
189
+ lineTension: 0.4,
190
+ pointStyle: 'circle',
191
+ pointRadius: 3,
192
+ yAxisID: 'right'
193
+ }
194
+ ],
195
+ labelDataKey: 'labels'
196
+ }
197
+ }
198
+ }
@@ -73,6 +73,7 @@ const Template: Story<ArgTypes> = ({ value, currentSeriesIndex }: ArgTypes) => h
73
73
 
74
74
  <div class="container light">
75
75
  <ox-input-chart-pie
76
+ chart-type="pie"
76
77
  id="editor"
77
78
  .value=${value}
78
79
  @change=${(e: CustomEvent) => {
@@ -0,0 +1,130 @@
1
+ import { html, TemplateResult } from 'lit'
2
+
3
+ import '../src/editors/ox-input-chart-pie.js'
4
+ import '../src/chartjs/ox-chart-js.js'
5
+
6
+ import { data, getDefaultChartConfig } from './common.js'
7
+
8
+ export default {
9
+ title: 'ox-input-chart-pie for polla-area',
10
+ component: 'ox-input-chart-pie',
11
+ argTypes: {
12
+ value: { control: 'object' },
13
+ currentSeriesIndex: { control: 'number' }
14
+ }
15
+ }
16
+
17
+ interface Story<T> {
18
+ (args: T): TemplateResult
19
+ args?: Partial<T>
20
+ argTypes?: Record<string, unknown>
21
+ }
22
+
23
+ interface ArgTypes {
24
+ value: OperatoChart.ChartConfig
25
+ currentSeriesIndex: number
26
+ }
27
+
28
+ const Template: Story<ArgTypes> = ({ value, currentSeriesIndex }: ArgTypes) => html`
29
+ <link
30
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
31
+ rel="stylesheet"
32
+ />
33
+ <link
34
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
35
+ rel="stylesheet"
36
+ />
37
+ <link
38
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
39
+ rel="stylesheet"
40
+ />
41
+
42
+ <link href="/themes/light.css" rel="stylesheet" />
43
+ <link href="/themes/dark.css" rel="stylesheet" />
44
+ <link href="/themes/spacing.css" rel="stylesheet" />
45
+
46
+ <style>
47
+ .container {
48
+ width: 100%;
49
+ height: 100%;
50
+
51
+ display: flex;
52
+ flex-direction: row;
53
+ overflow-y: auto;
54
+ padding: var(--spacing-medium);
55
+ }
56
+
57
+ .container.dark {
58
+ background-color: black;
59
+ }
60
+
61
+ #editor {
62
+ width: 300px;
63
+ }
64
+
65
+ #chart {
66
+ flex: 1;
67
+ }
68
+ </style>
69
+
70
+ <div style="background-color: black; color: white;">
71
+ Type 'count' or 'average' for series dataKey, type 'year' for axis's dataKey
72
+ </div>
73
+
74
+ <div class="container light">
75
+ <ox-input-chart-pie
76
+ chart-type="polarArea"
77
+ id="editor"
78
+ .value=${value}
79
+ @change=${(e: CustomEvent) => {
80
+ const target = e.currentTarget as any
81
+ const config = target.value
82
+ const chartjs = document.querySelector('#chartjs') as HTMLElement
83
+ if (chartjs) {
84
+ ;(chartjs as any).config = { ...config }
85
+ }
86
+
87
+ const container = document.querySelector('.container') as HTMLElement
88
+ if (container) {
89
+ const theme = config.options.theme
90
+ if (theme == 'dark') {
91
+ container.classList.remove('light')
92
+ container.classList.add('dark')
93
+ } else {
94
+ container.classList.remove('dark')
95
+ container.classList.add('light')
96
+ }
97
+ }
98
+ }}
99
+ ></ox-input-chart-pie>
100
+ <ox-chart-js id="chartjs" .data=${data}></ox-chart-js>
101
+ </div>
102
+ `
103
+
104
+ export const Default = Template.bind({})
105
+ Default.args = {
106
+ currentSeriesIndex: 0
107
+ }
108
+
109
+ export const WithData = Template.bind({})
110
+ WithData.args = {
111
+ value: {
112
+ ...getDefaultChartConfig('polarArea'),
113
+ data: {
114
+ datasets: [
115
+ {
116
+ label: 'PolarArea Series',
117
+ data: [10, 20, 30],
118
+ backgroundColor: ['rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(75, 192, 192, 0.2)'],
119
+ borderColor: ['rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(75, 192, 192, 1)'],
120
+ borderWidth: 1
121
+ }
122
+ ],
123
+ labelDataKey: 'labels'
124
+ },
125
+ options: {
126
+ legend: { display: true }
127
+ }
128
+ },
129
+ currentSeriesIndex: 0
130
+ }
@@ -73,6 +73,7 @@ const Template: Story<ArgTypes> = ({ value, currentSeriesIndex }: ArgTypes) => h
73
73
 
74
74
  <div class="container light">
75
75
  <ox-input-chart-radar
76
+ chart-type="radar"
76
77
  id="editor"
77
78
  .value=${value}
78
79
  @change=${(e: CustomEvent) => {
@@ -1 +0,0 @@
1
- {"version":3,"file":"ox-input-chart-mixed.stories.js","sourceRoot":"","s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C,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;gBACzC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;aAC1C;YACD,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;SAC1B;KACF;CACF,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAC1C,SAAS,CAAC,IAAI,GAAG;IACf,KAAK,EAAE;QACL,GAAG,qBAAqB,CAAC,OAAO,CAAC;QACjC,OAAO,EAAE;YACP,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAC,OAAO;YACzC,SAAS,EAAE,IAAI;SAChB;QACD,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR;oBACE,KAAK,EAAE,YAAY;oBACnB,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;oBAClB,eAAe,EAAE,yBAAyB;oBAC1C,WAAW,EAAE,uBAAuB;oBACpC,WAAW,EAAE,CAAC;oBACd,OAAO,EAAE,MAAM;iBAChB;gBACD;oBACE,KAAK,EAAE,aAAa;oBACpB,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;oBAClB,WAAW,EAAE,uBAAuB;oBACpC,WAAW,EAAE,CAAC;oBACd,IAAI,EAAE,KAAK;oBACX,WAAW,EAAE,GAAG;oBAChB,UAAU,EAAE,QAAQ;oBACpB,WAAW,EAAE,CAAC;oBACd,OAAO,EAAE,OAAO;iBACjB;aACF;YACD,YAAY,EAAE,QAAQ;SACvB;KACF;CACF,CAAA","sourcesContent":["import { html, TemplateResult } from 'lit'\n\nimport '../src/editors/ox-input-chart-mixed.js'\nimport '../src/chartjs/ox-chart-js.js'\nimport '../src/scichart/ox-scichart.js'\n\nimport { data, getDefaultChartConfig } from './common.js'\n\nexport default {\n title: 'ox-input-chart-mixed',\n component: 'ox-input-chart-mixed',\n argTypes: {\n value: { control: 'object' }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n value: OperatoChart.ChartConfig\n}\n\nconst Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n <link\n href=\"https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1\"\n rel=\"stylesheet\"\n />\n\n <link href=\"/themes/light.css\" rel=\"stylesheet\" />\n <link href=\"/themes/dark.css\" rel=\"stylesheet\" />\n <link href=\"/themes/spacing.css\" rel=\"stylesheet\" />\n\n <style>\n .container {\n width: 100%;\n height: 100%;\n\n display: flex;\n flex-direction: row;\n overflow-y: auto;\n padding: var(--spacing-medium);\n }\n\n .container.dark {\n background-color: black;\n }\n\n #editor {\n width: 300px;\n }\n\n #charts {\n flex: 1;\n\n display: flex;\n flex-direction: column;\n padding: 10px;\n }\n\n #chartjs {\n flex: 1;\n }\n\n #scichart {\n flex: 1;\n }\n </style>\n\n <div style=\"background-color: black; color: white;\">\n Type 'count' or 'average' for series dataKey, type 'year' for axis's dataKey\n </div>\n\n <div class=\"container light\">\n <ox-input-chart-mixed\n id=\"editor\"\n .value=${value}\n @change=${(e: CustomEvent) => {\n const target = e.currentTarget as any\n const config = target.value\n const chartjs = document.querySelector('#chartjs') as HTMLElement\n if (chartjs) {\n ;(chartjs as any).config = { ...config }\n }\n const scichart = document.querySelector('#scichart') as HTMLElement\n if (scichart) {\n ;(scichart as any).config = config\n }\n\n const container = document.querySelector('.container') as HTMLElement\n if (container) {\n const theme = config.options.theme\n if (theme == 'dark') {\n container.classList.remove('light')\n container.classList.add('dark')\n } else {\n container.classList.remove('dark')\n container.classList.add('light')\n }\n }\n }}\n ></ox-input-chart-mixed>\n <div id=\"charts\">\n <ox-chart-js id=\"chartjs\" .data=${data}></ox-chart-js>\n <ox-scichart id=\"scichart\"></ox-scichart>\n </div>\n </div>\n`\n\nexport const Default = Template.bind({})\nDefault.args = {}\n\nexport const WithData = Template.bind({})\nWithData.args = {\n value: {\n ...getDefaultChartConfig('mixed'),\n data: {\n datasets: [\n {\n label: 'Bar Series',\n type: 'bar',\n data: [10, 20, 30],\n backgroundColor: 'rgba(255, 99, 132, 0.2)',\n borderColor: 'rgba(255, 99, 132, 1)',\n borderWidth: 1\n },\n {\n label: 'Line Series',\n type: 'line',\n data: [15, 25, 35],\n borderColor: 'rgba(54, 162, 235, 1)',\n borderWidth: 1,\n fill: false,\n lineTension: 0.4,\n pointStyle: 'circle',\n pointRadius: 3\n }\n ],\n labelDataKey: 'labels'\n },\n options: {\n scales: {\n xAxes: [{ ticks: { beginAtZero: true } }],\n yAxes: [{ ticks: { beginAtZero: true } }]\n },\n legend: { display: true }\n }\n }\n}\n\nexport const MultiAxis = Template.bind({})\nMultiAxis.args = {\n value: {\n ...getDefaultChartConfig('mixed'),\n options: {\n ...getDefaultChartConfig('mixed').options,\n multiAxis: true\n },\n data: {\n datasets: [\n {\n label: 'Bar Series',\n type: 'bar',\n data: [10, 20, 30],\n backgroundColor: 'rgba(255, 99, 132, 0.2)',\n borderColor: 'rgba(255, 99, 132, 1)',\n borderWidth: 1,\n yAxisID: 'left'\n },\n {\n label: 'Line Series',\n type: 'line',\n data: [15, 25, 35],\n borderColor: 'rgba(54, 162, 235, 1)',\n borderWidth: 1,\n fill: false,\n lineTension: 0.4,\n pointStyle: 'circle',\n pointRadius: 3,\n yAxisID: 'right'\n }\n ],\n labelDataKey: 'labels'\n }\n }\n}\n"]}