@oliasoft-open-source/charts-library 2.1.0 → 2.1.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 (29) hide show
  1. package/.storybook/main.js +18 -22
  2. package/.storybook/preview.js +37 -0
  3. package/.storybook/storybook.less +8 -0
  4. package/package.json +2 -1
  5. package/src/components/bar-chart/bar-chart-prop-types.js +7 -0
  6. package/src/components/bar-chart/bar-chart.jsx +7 -2
  7. package/src/components/bar-chart/{basic.stories.jsx → bar-chart.stories.jsx} +108 -371
  8. package/src/components/line-chart/Controls/Controls.jsx +2 -0
  9. package/src/components/line-chart/Controls/Layer.jsx +52 -49
  10. package/src/components/line-chart/line-chart-prop-types.js +10 -0
  11. package/src/components/line-chart/line-chart.jsx +91 -10
  12. package/src/components/line-chart/line-chart.module.less +6 -0
  13. package/src/components/line-chart/line-chart.stories.jsx +393 -0
  14. package/src/components/line-chart/state/line-chart-reducer.js +26 -15
  15. package/src/components/pie-chart/pie-chart.stories.jsx +234 -0
  16. package/src/components/scatter-chart/{scatter.stories.jsx → scatter-chart.stories.jsx} +25 -79
  17. package/src/helpers/chart-consts.js +2 -0
  18. package/src/helpers/chart-interface.ts +9 -0
  19. package/src/helpers/chart-utils.js +24 -4
  20. package/src/helpers/get-custom-legend-plugin-example.js +81 -0
  21. package/src/components/bar-chart/charts.stories.jsx +0 -119
  22. package/src/components/line-chart/basic.stories.jsx +0 -735
  23. package/src/components/line-chart/charts.stories.jsx +0 -264
  24. package/src/components/line-chart/stories/shapes/cubes.stories.jsx +0 -326
  25. package/src/components/line-chart/stories/shapes/pyramid.stories.jsx +0 -189
  26. package/src/components/line-chart/stories/shapes/round.stories.jsx +0 -339
  27. package/src/components/line-chart/stories/shapes/triangle.stories.jsx +0 -166
  28. package/src/components/pie-chart/basic.stories.jsx +0 -390
  29. package/src/components/pie-chart/charts.stories.jsx +0 -66
@@ -1,189 +0,0 @@
1
- import React from 'react';
2
- import { LineChart } from '../../line-chart';
3
- import { Container } from '../../../../helpers/container';
4
-
5
- const style = {
6
- height: '1000px',
7
- width: '1000px',
8
- };
9
-
10
- const tetrahedronPoints = [
11
- {
12
- x: -0.930313,
13
- y: -0.308393,
14
- },
15
- {
16
- x: 0.651745,
17
- y: -0.547048,
18
- },
19
- {
20
- x: 0.093034,
21
- y: 0.963013,
22
- },
23
- {
24
- x: 0.185534,
25
- y: -0.107573,
26
- },
27
- ];
28
-
29
- const tetrahedronLines = {
30
- label: 'Tetrahedron',
31
- borderColor: 'purple',
32
- borderWidth: 4,
33
- pointRadius: '0',
34
- pointHitRadius: '0',
35
- pointBackgroundColor: 'purple',
36
- data: [
37
- tetrahedronPoints[0],
38
- tetrahedronPoints[1],
39
- tetrahedronPoints[2],
40
- tetrahedronPoints[0],
41
- ],
42
- };
43
-
44
- const tetrahedronDashedLines = {
45
- borderColor: 'purple',
46
- borderWidth: 2,
47
- borderDash: [10, 5],
48
- pointRadius: '0',
49
- pointHitRadius: '0',
50
- hideLegend: true,
51
- data: [
52
- tetrahedronPoints[0],
53
- tetrahedronPoints[3],
54
- tetrahedronPoints[2],
55
- tetrahedronPoints[3],
56
- tetrahedronPoints[1],
57
- ],
58
- };
59
-
60
- const tetrahedronData = {
61
- datasets: [tetrahedronLines, tetrahedronDashedLines],
62
- };
63
-
64
- const pyramidPoints = [
65
- {
66
- x: 0.419253,
67
- y: -0.507608,
68
- },
69
- {
70
- x: 0.928705,
71
- y: -0.247533,
72
- },
73
- {
74
- x: -0.383145,
75
- y: -0.29446,
76
- },
77
- {
78
- x: -0.892597,
79
- y: -0.554536,
80
- },
81
- {
82
- x: -0.119469,
83
- y: 0.966812,
84
- },
85
- ];
86
-
87
- const pyramidLines = {
88
- label: 'Pyramid',
89
- borderColor: 'orange',
90
- borderWidth: 2,
91
- pointRadius: '0',
92
- pointHitRadius: '0',
93
- pointBackgroundColor: 'orange',
94
- data: [
95
- pyramidPoints[0],
96
- pyramidPoints[1],
97
- pyramidPoints[4],
98
- pyramidPoints[3],
99
- pyramidPoints[0],
100
- pyramidPoints[4],
101
- ],
102
- };
103
-
104
- const pyramidDashedLines = {
105
- borderColor: 'orange',
106
- borderDash: [10, 5],
107
- pointRadius: '0',
108
- pointHitRadius: '0',
109
- hideLegend: true,
110
- data: [
111
- pyramidPoints[2],
112
- pyramidPoints[4],
113
- pyramidPoints[2],
114
- pyramidPoints[1],
115
- pyramidPoints[2],
116
- pyramidPoints[3],
117
- ],
118
- };
119
-
120
- const pyramidData = {
121
- datasets: [pyramidLines, pyramidDashedLines],
122
- };
123
-
124
- const combinedData = {
125
- datasets: [
126
- tetrahedronLines,
127
- tetrahedronDashedLines,
128
- pyramidLines,
129
- pyramidDashedLines,
130
- ],
131
- };
132
-
133
- export const PyramidsLineChartExample = () => (
134
- <Container style={style}>
135
- <LineChart
136
- chart={{
137
- data: pyramidData,
138
- options: {
139
- title: 'Pyramid',
140
- chartStyling: {
141
- width: 600,
142
- height: 600,
143
- performanceMode: false, // enables animation
144
- },
145
- legend: {
146
- display: false,
147
- },
148
- },
149
- }}
150
- />
151
- <LineChart
152
- chart={{
153
- data: tetrahedronData,
154
- options: {
155
- title: 'Tetrahedron',
156
- chartStyling: {
157
- width: 600,
158
- height: 600,
159
- performanceMode: false, // enables animation
160
- },
161
- legend: {
162
- display: false,
163
- },
164
- },
165
- }}
166
- />
167
- <LineChart
168
- chart={{
169
- data: combinedData,
170
- options: {
171
- title: 'Both, with legend',
172
- chartStyling: {
173
- width: 600,
174
- height: 600,
175
- performanceMode: false, // enables animation
176
- },
177
- legend: {
178
- position: 'top',
179
- },
180
- },
181
- }}
182
- />
183
- </Container>
184
- );
185
-
186
- export default {
187
- title: 'Line Chart - Pyramid Shape',
188
- component: PyramidsLineChartExample,
189
- };
@@ -1,339 +0,0 @@
1
- import React from 'react';
2
- import { LineChart } from '../../line-chart';
3
- import { Container } from '../../../../helpers/container';
4
-
5
- const style = {
6
- height: '1000px',
7
- width: '1000px',
8
- };
9
-
10
- const circlePoints24 = [
11
- {
12
- x: 1,
13
- y: 0,
14
- },
15
- {
16
- x: 0.9659258262890683,
17
- y: 0.25881904510252074,
18
- },
19
- {
20
- x: 0.8660254037844387,
21
- y: 0.49999999999999994,
22
- },
23
- {
24
- x: 0.7071067811865476,
25
- y: 0.7071067811865475,
26
- },
27
- {
28
- x: 0.5000000000000001,
29
- y: 0.8660254037844386,
30
- },
31
- {
32
- x: 0.25881904510252074,
33
- y: 0.9659258262890683,
34
- },
35
- {
36
- x: 6.123233995736766e-17,
37
- y: 1,
38
- },
39
- {
40
- x: -0.25881904510252063,
41
- y: 0.9659258262890683,
42
- },
43
- {
44
- x: -0.4999999999999998,
45
- y: 0.8660254037844387,
46
- },
47
- {
48
- x: -0.7071067811865475,
49
- y: 0.7071067811865476,
50
- },
51
- {
52
- x: -0.8660254037844387,
53
- y: 0.49999999999999994,
54
- },
55
- {
56
- x: -0.9659258262890682,
57
- y: 0.258819045102521,
58
- },
59
- {
60
- x: -1,
61
- y: 1.2246467991473532e-16,
62
- },
63
- {
64
- x: -0.9659258262890683,
65
- y: -0.2588190451025208,
66
- },
67
- {
68
- x: -0.8660254037844388,
69
- y: -0.4999999999999997,
70
- },
71
- {
72
- x: -0.7071067811865479,
73
- y: -0.7071067811865471,
74
- },
75
- {
76
- x: -0.5000000000000004,
77
- y: -0.8660254037844385,
78
- },
79
- {
80
- x: -0.25881904510252063,
81
- y: -0.9659258262890683,
82
- },
83
- {
84
- x: -1.8369701987210297e-16,
85
- y: -1,
86
- },
87
- {
88
- x: 0.2588190451025203,
89
- y: -0.9659258262890684,
90
- },
91
- {
92
- x: 0.5000000000000001,
93
- y: -0.8660254037844386,
94
- },
95
- {
96
- x: 0.7071067811865474,
97
- y: -0.7071067811865477,
98
- },
99
- {
100
- x: 0.8660254037844384,
101
- y: -0.5000000000000004,
102
- },
103
- {
104
- x: 0.9659258262890681,
105
- y: -0.25881904510252157,
106
- },
107
- {
108
- x: 1,
109
- y: 0,
110
- },
111
- ];
112
-
113
- const circlePoints32 = [
114
- {
115
- x: 1,
116
- y: 0,
117
- },
118
- {
119
- x: 0.9807852804032304,
120
- y: 0.19509032201612825,
121
- },
122
- {
123
- x: 0.9238795325112867,
124
- y: 0.3826834323650898,
125
- },
126
- {
127
- x: 0.8314696123025452,
128
- y: 0.5555702330196022,
129
- },
130
- {
131
- x: 0.7071067811865476,
132
- y: 0.7071067811865475,
133
- },
134
- {
135
- x: 0.5555702330196023,
136
- y: 0.8314696123025452,
137
- },
138
- {
139
- x: 0.38268343236508984,
140
- y: 0.9238795325112867,
141
- },
142
- {
143
- x: 0.19509032201612833,
144
- y: 0.9807852804032304,
145
- },
146
- {
147
- x: 6.123233995736766e-17,
148
- y: 1,
149
- },
150
- {
151
- x: -0.1950903220161282,
152
- y: 0.9807852804032304,
153
- },
154
- {
155
- x: -0.3826834323650897,
156
- y: 0.9238795325112867,
157
- },
158
- {
159
- x: -0.555570233019602,
160
- y: 0.8314696123025453,
161
- },
162
- {
163
- x: -0.7071067811865475,
164
- y: 0.7071067811865476,
165
- },
166
- {
167
- x: -0.8314696123025453,
168
- y: 0.5555702330196022,
169
- },
170
- {
171
- x: -0.9238795325112867,
172
- y: 0.3826834323650899,
173
- },
174
- {
175
- x: -0.9807852804032304,
176
- y: 0.1950903220161286,
177
- },
178
- {
179
- x: -1,
180
- y: 1.2246467991473532e-16,
181
- },
182
- {
183
- x: -0.9807852804032304,
184
- y: -0.19509032201612836,
185
- },
186
- {
187
- x: -0.9238795325112868,
188
- y: -0.38268343236508967,
189
- },
190
- {
191
- x: -0.8314696123025455,
192
- y: -0.555570233019602,
193
- },
194
- {
195
- x: -0.7071067811865477,
196
- y: -0.7071067811865475,
197
- },
198
- {
199
- x: -0.5555702330196022,
200
- y: -0.8314696123025452,
201
- },
202
- {
203
- x: -0.38268343236509034,
204
- y: -0.9238795325112865,
205
- },
206
- {
207
- x: -0.19509032201612866,
208
- y: -0.9807852804032303,
209
- },
210
- {
211
- x: -1.8369701987210297e-16,
212
- y: -1,
213
- },
214
- {
215
- x: 0.1950903220161283,
216
- y: -0.9807852804032304,
217
- },
218
- {
219
- x: 0.38268343236509,
220
- y: -0.9238795325112866,
221
- },
222
- {
223
- x: 0.5555702330196018,
224
- y: -0.8314696123025455,
225
- },
226
- {
227
- x: 0.7071067811865474,
228
- y: -0.7071067811865477,
229
- },
230
- {
231
- x: 0.8314696123025452,
232
- y: -0.5555702330196022,
233
- },
234
- {
235
- x: 0.9238795325112865,
236
- y: -0.3826834323650904,
237
- },
238
- {
239
- x: 0.9807852804032303,
240
- y: -0.19509032201612872,
241
- },
242
- {
243
- x: 1,
244
- y: 0,
245
- },
246
- ];
247
-
248
- export const RoundLineChartExample = () => (
249
- <Container style={style}>
250
- <LineChart
251
- chart={{
252
- data: {
253
- datasets: [
254
- {
255
- label: 'circular data',
256
- data: circlePoints24,
257
- },
258
- ],
259
- },
260
- options: {
261
- title: 'Round data',
262
- },
263
- }}
264
- />
265
- <LineChart
266
- chart={{
267
- data: {
268
- datasets: [
269
- {
270
- label: 'circular data',
271
- data: circlePoints24,
272
- },
273
- ],
274
- },
275
- options: {
276
- title: 'With line tension',
277
- graph: { lineTension: 0.3 },
278
- },
279
- }}
280
- />
281
- <LineChart
282
- chart={{
283
- data: {
284
- datasets: [
285
- {
286
- label: 'circular data',
287
- pointRadius: '0',
288
- pointHoverRadius: '0',
289
- pointHitRadius: '0',
290
- backgroundColor: '#987654',
291
- data: circlePoints32,
292
- },
293
- ],
294
- },
295
- options: {
296
- title: 'Points with no radius',
297
- graph: { lineTension: 0.3 },
298
- },
299
- }}
300
- />
301
- <LineChart
302
- chart={{
303
- data: {
304
- datasets: [
305
- {
306
- label: 'circular data',
307
- backgroundColor: '#987654',
308
- data: circlePoints24,
309
- },
310
- ],
311
- },
312
- options: {
313
- title: 'With fixed chart size and range',
314
- additionalAxesOptions: {
315
- range: {
316
- x: {
317
- min: -1.5,
318
- max: 1.5,
319
- },
320
- y: {
321
- min: -1.5,
322
- max: 1.5,
323
- },
324
- },
325
- },
326
- chartStyling: {
327
- width: 500,
328
- height: 500,
329
- },
330
- },
331
- }}
332
- />
333
- </Container>
334
- );
335
-
336
- export default {
337
- title: 'Line Chart - Round Shape',
338
- component: RoundLineChartExample,
339
- };
@@ -1,166 +0,0 @@
1
- import React from 'react';
2
- import { LineChart } from '../../line-chart';
3
- import { Container } from '../../../../helpers/container';
4
-
5
- const style = {
6
- height: '1000px',
7
- width: '1000px',
8
- };
9
-
10
- const triangleLinesEquilateral = {
11
- label: 'Equilateral Triangle',
12
- data: [
13
- {
14
- x: 200,
15
- y: 200,
16
- },
17
- {
18
- x: 500,
19
- y: 719.615242271,
20
- },
21
- {
22
- x: 800,
23
- y: 200,
24
- },
25
- {
26
- x: 200,
27
- y: 200,
28
- },
29
- ],
30
- };
31
-
32
- const triangleLines = {
33
- label: 'Triangle',
34
- borderDash: [10, 5],
35
- data: [
36
- {
37
- x: 345,
38
- y: 123,
39
- },
40
- {
41
- x: 270,
42
- y: 876,
43
- },
44
- {
45
- x: 768,
46
- y: 421,
47
- },
48
- {
49
- x: 345,
50
- y: 123,
51
- },
52
- ],
53
- };
54
-
55
- const triangleLinesIsosceles = {
56
- label: 'Isosceles triangle',
57
- borderWidth: 3,
58
- data: [
59
- {
60
- x: 420,
61
- y: 70,
62
- },
63
- {
64
- x: 570,
65
- y: 720,
66
- },
67
- {
68
- x: 720,
69
- y: 70,
70
- },
71
- {
72
- x: 420,
73
- y: 70,
74
- },
75
- ],
76
- };
77
-
78
- const triangleLinesRightAngled = {
79
- label: 'Right-angled triangle',
80
- pointRadius: 5,
81
- data: [
82
- {
83
- x: 60,
84
- y: 360,
85
- },
86
- {
87
- x: 60,
88
- y: 654,
89
- },
90
- {
91
- x: 813,
92
- y: 360,
93
- },
94
- {
95
- x: 60,
96
- y: 360,
97
- },
98
- ],
99
- };
100
-
101
- const triangleData = {
102
- datasets: [triangleLinesEquilateral],
103
- };
104
-
105
- const multipleTriangleData = {
106
- datasets: [
107
- triangleLinesEquilateral,
108
- triangleLinesIsosceles,
109
- triangleLinesRightAngled,
110
- triangleLines,
111
- ],
112
- };
113
-
114
- export const TriangleLineChartExample = () => (
115
- <Container style={style}>
116
- <LineChart
117
- chart={{
118
- data: triangleData,
119
- options: {
120
- title: 'Triangle',
121
- chartStyling: {
122
- height: 500,
123
- width: 500,
124
- },
125
- },
126
- }}
127
- />
128
- <LineChart
129
- chart={{
130
- data: triangleData,
131
- options: {
132
- title: 'Centered Triangle',
133
- additionalAxesOptions: {
134
- suggestedMin: 0,
135
- suggestedMax: 1000,
136
- },
137
- chartStyling: {
138
- height: 500,
139
- width: 500,
140
- },
141
- },
142
- }}
143
- />
144
- <LineChart
145
- chart={{
146
- data: multipleTriangleData,
147
- options: {
148
- title: 'Multiple triangles with different styling',
149
- additionalAxesOptions: {
150
- suggestedMin: 0,
151
- suggestedMax: 900,
152
- },
153
- chartStyling: {
154
- height: 500,
155
- width: 500,
156
- },
157
- },
158
- }}
159
- />
160
- </Container>
161
- );
162
-
163
- export default {
164
- title: 'Line Chart - Triangle Shape',
165
- component: TriangleLineChartExample,
166
- };