@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,264 +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 dataset1 = {
11
- label: 'Curve 1',
12
- lineTension: 0,
13
- borderColor: '#a30125',
14
- pointBackgroundColor: '#a30125',
15
- pointRadius: 2,
16
- pointHoverRadius: 5,
17
- pointHitRadius: 20,
18
- borderWidth: 2,
19
- fill: false,
20
- yAxisID: 'y1',
21
- data: [
22
- {
23
- x: 0,
24
- y: 0,
25
- },
26
- {
27
- x: 5,
28
- y: 25,
29
- },
30
- {
31
- x: 10,
32
- y: 60,
33
- },
34
- {
35
- x: 15,
36
- y: 90,
37
- },
38
- {
39
- x: 20,
40
- y: 120,
41
- },
42
- {
43
- x: 25,
44
- y: 150,
45
- },
46
- ],
47
- };
48
-
49
- const dataset2 = {
50
- label: 'Curve 2',
51
- lineTension: 0,
52
- borderColor: '#a30125',
53
- pointBackgroundColor: '#a30125',
54
- pointRadius: 2,
55
- pointHoverRadius: 5,
56
- pointHitRadius: 20,
57
- borderWidth: 2,
58
- fill: false,
59
- yAxisID: 'y1',
60
- data: [
61
- {
62
- x: 0,
63
- y: 0,
64
- },
65
- {
66
- x: 3,
67
- y: 15,
68
- },
69
- {
70
- x: 6,
71
- y: 30,
72
- },
73
- {
74
- x: 9,
75
- y: 60,
76
- },
77
- {
78
- x: 12,
79
- y: 120,
80
- },
81
- {
82
- x: 15,
83
- y: 240,
84
- },
85
- ],
86
- };
87
-
88
- const dataset3 = {
89
- label: 'Curve 3',
90
- lineTension: 0,
91
- borderColor: '#011fa3',
92
- pointBackgroundColor: '#011fa3',
93
- pointRadius: 2,
94
- pointHoverRadius: 5,
95
- pointHitRadius: 20,
96
- borderWidth: 2,
97
- fill: false,
98
- yAxisID: 'y2',
99
- data: [
100
- {
101
- x: 0,
102
- y: 0,
103
- },
104
- {
105
- x: 7,
106
- y: 25,
107
- },
108
- {
109
- x: 14,
110
- y: 12,
111
- },
112
- {
113
- x: 21,
114
- y: 50,
115
- },
116
- {
117
- x: 28,
118
- y: 25,
119
- },
120
- {
121
- x: 30,
122
- y: 100,
123
- },
124
- ],
125
- };
126
-
127
- const formation = {
128
- label: 'Formation',
129
- formation: true,
130
- lineTension: 0,
131
- borderColor: '#987654',
132
- pointBackgroundColor: '#987654',
133
- pointRadius: 2,
134
- pointHoverRadius: 5,
135
- pointHitRadius: 20,
136
- borderWidth: 2,
137
- borderDash: [10, 5],
138
- fill: false,
139
- yAxisID: 'y2',
140
- hideLegend: true,
141
- data: [
142
- {
143
- x: 0,
144
- y: 66,
145
- },
146
- {
147
- x: 35.0 / 2,
148
- y: 66,
149
- label: 'formation label',
150
- },
151
- {
152
- x: 35,
153
- y: 66,
154
- },
155
- ],
156
- };
157
-
158
- const testChartData = {
159
- datasets: [dataset1, dataset2, dataset3, formation],
160
- };
161
-
162
- const kitchenSinkLineChart = {
163
- data: testChartData,
164
- options: {
165
- title: 'Look at this graph!',
166
- axes: {
167
- x: [
168
- {
169
- label: 'The X',
170
- },
171
- ],
172
- y: [
173
- {
174
- label: 'The Y',
175
- position: 'right',
176
- color: '#a30125',
177
- },
178
- {
179
- label: 'The Y 2',
180
- position: 'left',
181
- color: '#011fa3',
182
- gridLines: {
183
- drawOnChartArea: false,
184
- },
185
- },
186
- ],
187
- },
188
- additionalAxesOptions: {
189
- chartScaleType: 'linear',
190
- reverse: false,
191
- beginAtZero: false,
192
- stepSize: 50,
193
- truncateAxisNumbersToDigitsCallback: 0,
194
- suggestedMin: 0,
195
- suggestedMax: 35,
196
- // range: {
197
- // x: {
198
- // min: 0,
199
- // max: 100,
200
- // },
201
- // y: {
202
- // min: 0,
203
- // max: 100,
204
- // },
205
- // },
206
- },
207
- chartStyling: {
208
- width: 800,
209
- height: 800,
210
- maintainAspectRatio: false,
211
- staticChartHeight: false,
212
- performanceMode: true,
213
- },
214
- tooltip: {
215
- tooltips: true,
216
- showLabelsInTooltips: false,
217
- hideSimulationName: false,
218
- },
219
- graph: {
220
- lineTension: 0,
221
- spanGaps: false,
222
- showDataLabels: true,
223
- showMinorGridlines: true,
224
- },
225
- annotations: {
226
- showAnnotations: true,
227
- controlAnnotation: true,
228
- annotationsData: [
229
- {
230
- annotationAxis: 'y',
231
- label: 'cool annotation',
232
- value: 40,
233
- color: 'rgba(128, 32, 196, 0.5)',
234
- },
235
- ],
236
- },
237
- legend: {
238
- display: true,
239
- position: 'bottom',
240
- align: 'center',
241
- },
242
- chartOptions: {
243
- showPoints: true,
244
- enableZoom: false,
245
- enablePan: false,
246
- },
247
- interactions: {
248
- onLegendClick: null,
249
- onPointHover: null,
250
- onPointUnhover: null,
251
- },
252
- },
253
- };
254
-
255
- export const LineChartKitchenSink = () => (
256
- <Container style={style}>
257
- <LineChart chart={kitchenSinkLineChart} />
258
- </Container>
259
- );
260
-
261
- export default {
262
- title: 'Line Chart Kitchen Sink',
263
- component: LineChartKitchenSink,
264
- };
@@ -1,326 +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 cubeLines = {
11
- borderColor: '#011fa3',
12
- pointBackgroundColor: '#011fa3',
13
- pointRadius: '0',
14
- pointHoverRadius: '0',
15
- pointHitRadius: '0',
16
- borderWidth: 4,
17
- data: [
18
- {
19
- x: 10,
20
- y: 30,
21
- },
22
- {
23
- x: 10,
24
- y: 10,
25
- },
26
- {
27
- x: 30,
28
- y: 10,
29
- },
30
- {
31
- x: 36,
32
- y: 17,
33
- },
34
- {
35
- x: 36,
36
- y: 33,
37
- },
38
- {
39
- x: 20,
40
- y: 33,
41
- },
42
- {
43
- x: 10,
44
- y: 30,
45
- },
46
- {
47
- x: 30,
48
- y: 30,
49
- },
50
- {
51
- x: 30,
52
- y: 10,
53
- },
54
- {
55
- x: 30,
56
- y: 30,
57
- },
58
- {
59
- x: 36,
60
- y: 33,
61
- },
62
- ],
63
- };
64
-
65
- const cubeDashedLines = {
66
- borderColor: '#011fa3',
67
- pointBackgroundColor: '#011fa3',
68
- pointRadius: '0',
69
- pointHoverRadius: '0',
70
- pointHitRadius: '0',
71
- borderDash: [10, 5],
72
- borderWidth: 2,
73
- data: [
74
- {
75
- x: 10,
76
- y: 10,
77
- },
78
- {
79
- x: 20,
80
- y: 17,
81
- },
82
- {
83
- x: 36,
84
- y: 17,
85
- },
86
- {
87
- x: 20,
88
- y: 17,
89
- },
90
- {
91
- x: 20,
92
- y: 33,
93
- },
94
- ],
95
- };
96
-
97
- const cubeData = {
98
- datasets: [cubeLines, cubeDashedLines],
99
- };
100
-
101
- export const CubesLineChartExample = () => (
102
- <Container style={style}>
103
- <LineChart
104
- chart={{
105
- data: cubeData,
106
- options: {
107
- title: 'Cube using datasets',
108
- axes: {
109
- x: [
110
- {
111
- gridLines: {
112
- drawOnChartArea: false,
113
- },
114
- },
115
- ],
116
- y: [
117
- {
118
- gridLines: {
119
- drawOnChartArea: false,
120
- },
121
- },
122
- ],
123
- },
124
- additionalAxesOptions: {
125
- range: {
126
- x: {
127
- min: 5,
128
- max: 40,
129
- },
130
- y: {
131
- min: 5,
132
- max: 40,
133
- },
134
- },
135
- },
136
- chartStyling: {
137
- width: 768,
138
- height: 768,
139
- },
140
- legend: {
141
- display: false,
142
- },
143
- },
144
- }}
145
- />
146
- <LineChart
147
- chart={{
148
- data: cubeData,
149
- options: {
150
- title: 'Cube with perspective lines using annotations',
151
- axes: {
152
- x: [
153
- {
154
- gridLines: {
155
- drawOnChartArea: false,
156
- },
157
- },
158
- ],
159
- y: [
160
- {
161
- gridLines: {
162
- drawOnChartArea: false,
163
- },
164
- },
165
- ],
166
- },
167
- additionalAxesOptions: {
168
- range: {
169
- x: {
170
- min: 5,
171
- max: 40,
172
- },
173
- y: {
174
- min: 5,
175
- max: 40,
176
- },
177
- },
178
- },
179
- chartStyling: {
180
- width: 768,
181
- height: 768,
182
- },
183
- annotations: {
184
- annotationsData: [
185
- {
186
- annotationAxis: 'x',
187
- value: 55.7,
188
- endValue: 25.8,
189
- color: 'rgba(128, 32, 196, 0.5)',
190
- },
191
- {
192
- annotationAxis: 'x',
193
- value: 52.5,
194
- endValue: 3,
195
- color: 'rgba(128, 32, 196, 0.5)',
196
- },
197
- {
198
- annotationAxis: 'x',
199
- value: 49.3,
200
- endValue: -19.8,
201
- color: 'rgba(128, 32, 196, 0.4)',
202
- },
203
- {
204
- annotationAxis: 'x',
205
- value: 46.1,
206
- endValue: -42.6,
207
- color: 'rgba(128, 32, 196, 0.3)',
208
- },
209
- {
210
- annotationAxis: 'x',
211
- value: 42.9,
212
- endValue: -65.4,
213
- color: 'rgba(128, 32, 196, 0.2)',
214
- },
215
- {
216
- annotationAxis: 'x',
217
- value: 39.7,
218
- endValue: -88.2,
219
- color: 'rgba(128, 32, 196, 0.1)',
220
- },
221
- {
222
- annotationAxis: 'x',
223
- value: 36.5,
224
- endValue: -111,
225
- color: 'rgba(128, 32, 196, 0.1)',
226
- },
227
- {
228
- annotationAxis: 'x',
229
- value: 33.3,
230
- endValue: -133.8,
231
- color: 'rgba(128, 32, 196, 0.1)',
232
- },
233
- {
234
- annotationAxis: 'x',
235
- value: 30.1,
236
- endValue: -156.6,
237
- color: 'rgba(128, 32, 196, 0.1)',
238
- },
239
- {
240
- annotationAxis: 'x',
241
- value: 26.9,
242
- endValue: -179.4,
243
- color: 'rgba(128, 32, 196, 0.1)',
244
- },
245
- {
246
- annotationAxis: 'y',
247
- value: 10,
248
- color: 'rgba(128, 32, 196, 0.5)',
249
- },
250
- {
251
- annotationAxis: 'y',
252
- value: 17,
253
- color: 'rgba(128, 32, 196, 0.5)',
254
- },
255
- {
256
- annotationAxis: 'y',
257
- value: 23,
258
- color: 'rgba(128, 32, 196, 0.5)',
259
- },
260
- {
261
- annotationAxis: 'y',
262
- value: 28,
263
- color: 'rgba(128, 32, 196, 0.5)',
264
- },
265
- {
266
- annotationAxis: 'y',
267
- value: 32,
268
- color: 'rgba(128, 32, 196, 0.4)',
269
- },
270
- {
271
- annotationAxis: 'y',
272
- value: 35,
273
- color: 'rgba(128, 32, 196, 0.3)',
274
- },
275
- {
276
- annotationAxis: 'y',
277
- value: 37,
278
- color: 'rgba(128, 32, 196, 0.2)',
279
- },
280
- {
281
- annotationAxis: 'y',
282
- value: 38,
283
- color: 'rgba(128, 32, 196, 0.1)',
284
- },
285
- ],
286
- },
287
- legend: {
288
- display: false,
289
- },
290
- },
291
- }}
292
- />
293
- <LineChart
294
- chart={{
295
- data: cubeData,
296
- options: {
297
- title: 'Cube with gridlines',
298
- additionalAxesOptions: {
299
- range: {
300
- x: {
301
- min: 5,
302
- max: 40,
303
- },
304
- y: {
305
- min: 5,
306
- max: 40,
307
- },
308
- },
309
- },
310
- chartStyling: {
311
- width: 768,
312
- height: 768,
313
- },
314
- legend: {
315
- display: false,
316
- },
317
- },
318
- }}
319
- />
320
- </Container>
321
- );
322
-
323
- export default {
324
- title: 'Line Chart - Cube Shape',
325
- component: CubesLineChartExample,
326
- };