@react-magma/charts 0.0.0-9de073 → 0.0.0-next.0

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 (39) hide show
  1. package/README.md +1 -40
  2. package/dist/charts.js +1 -1
  3. package/dist/charts.js.map +1 -1
  4. package/dist/charts.modern.js +63 -25
  5. package/dist/charts.modern.js.map +1 -1
  6. package/dist/charts.modern.module.js +1 -1
  7. package/dist/charts.modern.module.js.map +1 -1
  8. package/dist/charts.umd.js +1 -1
  9. package/dist/charts.umd.js.map +1 -1
  10. package/dist/components/LineChart/Chart.d.ts +11 -2
  11. package/dist/components/LineChart/ChartDataTable.d.ts +2 -1
  12. package/dist/components/LineChart/CustomAxisComponent.d.ts +3 -0
  13. package/dist/components/LineChart/CustomPointComponent.d.ts +17 -1
  14. package/dist/components/LineChart/DataTable.d.ts +1 -0
  15. package/dist/components/LineChart/GraphTooltip.d.ts +2 -1
  16. package/dist/components/LineChart/LegendButton.d.ts +1 -1
  17. package/dist/components/LineChart/LineChart.d.ts +29 -1
  18. package/dist/components/LineChart/LineChart.stories.d.ts +6 -7
  19. package/dist/components/LineChart/magma-charts.d.ts +1 -457
  20. package/dist/index.d.ts +0 -1
  21. package/package.json +8 -6
  22. package/src/components/LineChart/Chart.tsx +180 -20
  23. package/src/components/LineChart/ChartDataTable.test.js +1 -1
  24. package/src/components/LineChart/ChartDataTable.tsx +38 -32
  25. package/src/components/LineChart/CustomAxisComponent.tsx +29 -0
  26. package/src/components/LineChart/CustomPointComponent.tsx +81 -8
  27. package/src/components/LineChart/DataTable.tsx +3 -1
  28. package/src/components/LineChart/GraphTooltip.tsx +58 -26
  29. package/src/components/LineChart/LegendButton.tsx +32 -32
  30. package/src/components/LineChart/LineChart.stories.tsx +9 -9
  31. package/src/components/LineChart/LineChart.test.js +105 -11
  32. package/src/components/LineChart/LineChart.tsx +277 -113
  33. package/src/components/LineChart/magma-charts.ts +279 -0
  34. package/src/index.ts +0 -1
  35. package/dist/components/DataViz/DataVizTabs.d.ts +0 -8
  36. package/dist/components/DataViz/index.d.ts +0 -1
  37. package/src/components/DataViz/DataVizTabs.tsx +0 -48
  38. package/src/components/DataViz/index.ts +0 -1
  39. package/src/components/LineChart/magma-charts.js +0 -309
@@ -0,0 +1,279 @@
1
+ // *
2
+ // * Colors
3
+ // *
4
+ // const yellow200 = '#FFF59D';
5
+ // const deepOrange600 = '#F4511E';
6
+ // const lime300 = '#DCE775';
7
+ // const lightGreen500 = '#8BC34A';
8
+ // const teal700 = '#00796B';
9
+ // const cyan900 = '#006064';
10
+
11
+ // const colors = [
12
+ // '#0085CC',
13
+ // '#E0004D',
14
+ // '#FA6600',
15
+ // '#48A200',
16
+ // '#B12FAD',
17
+ // '#00A393',
18
+ // ];
19
+
20
+ const colors = [
21
+ '#00507A',
22
+ '#8F0033',
23
+ '#B84900',
24
+ '#255200',
25
+ '#711E6E',
26
+ '#005249',
27
+ ];
28
+
29
+ const blueGrey50 = '#DFDFDF';
30
+ const blueGrey300 = '#8F8F8F';
31
+ const blueGrey700 = '#3F3F3F';
32
+ const grey900 = 'pink';
33
+
34
+ // *
35
+ // * Typography
36
+ // *
37
+ const sansSerif = '"Open Sans",Helvetica,sans-serif';
38
+ const letterSpacing = 'normal';
39
+ const fontSize = 12;
40
+
41
+ // *
42
+ // * Layout
43
+ // *
44
+ const padding = 8;
45
+ const baseProps = {
46
+ width: 350,
47
+ height: 350,
48
+ padding: 50,
49
+ };
50
+
51
+ // *
52
+ // * Labels
53
+ // *
54
+ const baseLabelStyles = {
55
+ fontFamily: sansSerif,
56
+ fontSize,
57
+ letterSpacing,
58
+ padding,
59
+ fill: blueGrey700,
60
+ stroke: 'transparent',
61
+ strokeWidth: 0,
62
+ };
63
+
64
+ const centeredLabelStyles = { textAnchor: 'middle', ...baseLabelStyles };
65
+ // *
66
+ // * Strokes
67
+ // *
68
+ // const strokeDasharray = '10, 5';
69
+ const strokeLinecap = 'round';
70
+ const strokeLinejoin = 'round';
71
+
72
+ export const magmaTheme: any = {
73
+ area: {
74
+ style: {
75
+ data: {
76
+ fill: grey900,
77
+ },
78
+ labels: baseLabelStyles,
79
+ },
80
+ ...baseProps,
81
+ },
82
+ axis: {
83
+ style: {
84
+ axis: {
85
+ fill: 'transparent',
86
+ stroke: blueGrey300,
87
+ strokeWidth: 1,
88
+ strokeLinecap,
89
+ strokeLinejoin,
90
+ },
91
+ axisLabel: {
92
+ ...centeredLabelStyles,
93
+ padding,
94
+ stroke: 'transparent',
95
+ },
96
+ grid: {
97
+ fill: 'none',
98
+ stroke: '#dfdfdf',
99
+ //strokeDasharray,
100
+ strokeLinecap,
101
+ strokeLinejoin,
102
+ pointerEvents: 'painted',
103
+ },
104
+ ticks: {
105
+ fill: 'transparent',
106
+ size: 0,
107
+ stroke: blueGrey300,
108
+ strokeWidth: 0,
109
+ strokeLinecap,
110
+ strokeLinejoin,
111
+ },
112
+ tickLabels: {
113
+ ...baseLabelStyles,
114
+ fill: blueGrey700,
115
+ },
116
+ },
117
+ ...baseProps,
118
+ },
119
+ polarDependentAxis: {
120
+ style: {
121
+ ticks: {
122
+ fill: 'transparent',
123
+ size: 1,
124
+ stroke: 'transparent',
125
+ },
126
+ },
127
+ },
128
+ bar: {
129
+ style: {
130
+ data: {
131
+ fill: blueGrey700,
132
+ padding,
133
+ strokeWidth: 0,
134
+ },
135
+ labels: baseLabelStyles,
136
+ },
137
+ ...baseProps,
138
+ },
139
+ boxplot: {
140
+ style: {
141
+ max: { padding, stroke: blueGrey700, strokeWidth: 1 },
142
+ maxLabels: { ...baseLabelStyles, padding: 3 },
143
+ median: { padding, stroke: blueGrey700, strokeWidth: 1 },
144
+ medianLabels: { ...baseLabelStyles, padding: 3 },
145
+ min: { padding, stroke: blueGrey700, strokeWidth: 1 },
146
+ minLabels: { ...baseLabelStyles, padding: 3 },
147
+ q1: { padding, fill: blueGrey700 },
148
+ q1Labels: { ...baseLabelStyles, padding: 3 },
149
+ q3: { padding, fill: blueGrey700 },
150
+ q3Labels: { ...baseLabelStyles, padding: 3 },
151
+ },
152
+ boxWidth: 20,
153
+ ...baseProps,
154
+ },
155
+ candlestick: {
156
+ style: {
157
+ data: {
158
+ stroke: blueGrey700,
159
+ },
160
+ labels: { ...baseLabelStyles, padding: 5 },
161
+ },
162
+ candleColors: {
163
+ positive: '#ffffff',
164
+ negative: blueGrey700,
165
+ },
166
+ ...baseProps,
167
+ },
168
+ chart: baseProps,
169
+ errorbar: {
170
+ borderWidth: 8,
171
+ style: {
172
+ data: {
173
+ fill: 'transparent',
174
+ opacity: 1,
175
+ stroke: blueGrey700,
176
+ strokeWidth: 2,
177
+ },
178
+ labels: baseLabelStyles,
179
+ },
180
+ ...baseProps,
181
+ },
182
+ group: {
183
+ colorScale: colors,
184
+ ...baseProps,
185
+ },
186
+ histogram: {
187
+ style: {
188
+ data: {
189
+ fill: blueGrey700,
190
+ stroke: grey900,
191
+ strokeWidth: 2,
192
+ },
193
+ labels: baseLabelStyles,
194
+ },
195
+ ...baseProps,
196
+ },
197
+ legend: {
198
+ colorScale: colors,
199
+ gutter: 10,
200
+ orientation: 'vertical',
201
+ titleOrientation: 'top',
202
+ style: {
203
+ data: {
204
+ type: 'circle',
205
+ },
206
+ labels: baseLabelStyles,
207
+ title: { ...baseLabelStyles, padding: 5 },
208
+ },
209
+ },
210
+ line: {
211
+ style: {
212
+ data: {
213
+ fill: 'transparent',
214
+ opacity: 1,
215
+ stroke: blueGrey700,
216
+ strokeWidth: 2,
217
+ },
218
+ labels: baseLabelStyles,
219
+ },
220
+ ...baseProps,
221
+ },
222
+ pie: {
223
+ colorScale: colors,
224
+ style: {
225
+ data: {
226
+ padding,
227
+ stroke: blueGrey50,
228
+ strokeWidth: 1,
229
+ },
230
+ labels: { ...baseLabelStyles, padding: 20 },
231
+ },
232
+ ...baseProps,
233
+ },
234
+ scatter: {
235
+ style: {
236
+ data: {
237
+ fill: blueGrey700,
238
+ opacity: 1,
239
+ stroke: 'transparent',
240
+ strokeWidth: 0,
241
+ },
242
+ labels: baseLabelStyles,
243
+ },
244
+ ...baseProps,
245
+ },
246
+ stack: {
247
+ colorScale: colors,
248
+ ...baseProps,
249
+ },
250
+ tooltip: {
251
+ style: { ...baseLabelStyles, padding: 0, pointerEvents: 'none' },
252
+ flyoutStyle: {
253
+ stroke: grey900,
254
+ strokeWidth: 1,
255
+ fill: '#f0f0f0',
256
+ pointerEvents: 'none',
257
+ },
258
+ flyoutPadding: 5,
259
+ cornerRadius: 5,
260
+ pointerLength: 10,
261
+ },
262
+ voronoi: {
263
+ style: {
264
+ data: {
265
+ fill: 'transparent',
266
+ stroke: 'transparent',
267
+ strokeWidth: 0,
268
+ },
269
+ labels: { ...baseLabelStyles, padding: 5, pointerEvents: 'none' },
270
+ flyout: {
271
+ stroke: grey900,
272
+ strokeWidth: 1,
273
+ fill: '#f0f0f0',
274
+ pointerEvents: 'none',
275
+ },
276
+ },
277
+ ...baseProps,
278
+ },
279
+ };
package/src/index.ts CHANGED
@@ -1,2 +1 @@
1
1
  export * from './components/LineChart';
2
- export * from './components/DataViz';
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- export interface DataVizTabsProps extends React.HTMLAttributes<HTMLDivElement> {
3
- heading?: String;
4
- introContent?: React.Component;
5
- data?: any;
6
- testId?: string;
7
- }
8
- export declare const DataVizTabs: React.ForwardRefExoticComponent<DataVizTabsProps & React.RefAttributes<HTMLDivElement>>;
@@ -1 +0,0 @@
1
- export * from './DataVizTabs';
@@ -1,48 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import {
4
- Heading,
5
- Paragraph,
6
- TabsContainer,
7
- Tabs,
8
- Tab,
9
- TabPanelsContainer,
10
- TabPanel,
11
- } from 'react-magma-dom';
12
- export interface DataVizTabsProps extends React.HTMLAttributes<HTMLDivElement> {
13
- heading?: String;
14
- introContent?: React.Component;
15
- data?: any;
16
- testId?: string;
17
- }
18
-
19
- export const DataVizTabs = React.forwardRef<HTMLDivElement, DataVizTabsProps>(
20
- (props, ref) => {
21
- const { data, testId, ...other } = props;
22
-
23
- return (
24
- <div ref={ref} {...other}>
25
- <Heading level={3}>Simple Line</Heading>
26
- <Paragraph>
27
- Data table description - Lorem ipsum dolor sit amet, consectetur
28
- adipiscing elit. Donec ullamcorper quam dolor, at consequat mi pretium
29
- in. Duis iaculis ligula nibh, sit amet.
30
- </Paragraph>
31
- <TabsContainer>
32
- <Tabs aria-label="Line Chart Demo">
33
- <Tab>Chart</Tab>
34
- <Tab>Data</Tab>
35
- </Tabs>
36
- <TabPanelsContainer>
37
- <TabPanel>Chart goes here!</TabPanel>
38
- <TabPanel>
39
- <Heading level={4}>2019 Annual Sales Figures</Heading>
40
- <Paragraph>Conversion rate by month</Paragraph>
41
- Table goes here!
42
- </TabPanel>
43
- </TabPanelsContainer>
44
- </TabsContainer>
45
- </div>
46
- );
47
- }
48
- );
@@ -1 +0,0 @@
1
- export * from './DataVizTabs';
@@ -1,309 +0,0 @@
1
- import { assign } from 'lodash';
2
-
3
- // *
4
- // * Colors
5
- // *
6
- // const yellow200 = '#FFF59D';
7
- // const deepOrange600 = '#F4511E';
8
- // const lime300 = '#DCE775';
9
- // const lightGreen500 = '#8BC34A';
10
- // const teal700 = '#00796B';
11
- // const cyan900 = '#006064';
12
-
13
- // const colors = [
14
- // '#0085CC',
15
- // '#E0004D',
16
- // '#FA6600',
17
- // '#48A200',
18
- // '#B12FAD',
19
- // '#00A393',
20
- // ];
21
-
22
- const colors = [
23
- '#00507A',
24
- '#8F0033',
25
- '#B84900',
26
- '#255200',
27
- '#711E6E',
28
- '#005249',
29
- ];
30
-
31
- const blueGrey50 = '#DFDFDF';
32
- const blueGrey300 = '#8F8F8F';
33
- const blueGrey700 = '#3F3F3F';
34
- const grey900 = 'pink';
35
-
36
- // *
37
- // * Typography
38
- // *
39
- const sansSerif = '"Open Sans",Helvetica,sans-serif';
40
- const letterSpacing = 'normal';
41
- const fontSize = 12;
42
-
43
- // *
44
- // * Layout
45
- // *
46
- const padding = 8;
47
- const baseProps = {
48
- width: 350,
49
- height: 350,
50
- padding: 50,
51
- };
52
-
53
- // *
54
- // * Labels
55
- // *
56
- const baseLabelStyles = {
57
- fontFamily: sansSerif,
58
- fontSize,
59
- letterSpacing,
60
- padding,
61
- fill: blueGrey700,
62
- stroke: 'transparent',
63
- strokeWidth: 0,
64
- };
65
-
66
- const centeredLabelStyles = assign({ textAnchor: 'middle' }, baseLabelStyles);
67
- // *
68
- // * Strokes
69
- // *
70
- const strokeDasharray = '10, 5';
71
- const strokeLinecap = 'round';
72
- const strokeLinejoin = 'round';
73
-
74
- // eslint-disable-next-line import/no-anonymous-default-export
75
- export default {
76
- area: assign(
77
- {
78
- style: {
79
- data: {
80
- fill: grey900,
81
- },
82
- labels: baseLabelStyles,
83
- },
84
- },
85
- baseProps
86
- ),
87
- axis: assign(
88
- {
89
- style: {
90
- axis: {
91
- fill: 'transparent',
92
- stroke: blueGrey300,
93
- strokeWidth: 2,
94
- strokeLinecap,
95
- strokeLinejoin,
96
- },
97
- axisLabel: assign({}, centeredLabelStyles, {
98
- padding,
99
- stroke: 'transparent',
100
- }),
101
- grid: {
102
- fill: 'none',
103
- stroke: blueGrey50,
104
- //strokeDasharray,
105
- strokeLinecap,
106
- strokeLinejoin,
107
- pointerEvents: 'painted',
108
- },
109
- ticks: {
110
- fill: 'transparent',
111
- size: 5,
112
- stroke: blueGrey300,
113
- strokeWidth: 1,
114
- strokeLinecap,
115
- strokeLinejoin,
116
- },
117
- tickLabels: assign({}, baseLabelStyles, {
118
- fill: blueGrey700,
119
- }),
120
- },
121
- },
122
- baseProps
123
- ),
124
- polarDependentAxis: assign({
125
- style: {
126
- ticks: {
127
- fill: 'transparent',
128
- size: 1,
129
- stroke: 'transparent',
130
- },
131
- },
132
- }),
133
- bar: assign(
134
- {
135
- style: {
136
- data: {
137
- fill: blueGrey700,
138
- padding,
139
- strokeWidth: 0,
140
- },
141
- labels: baseLabelStyles,
142
- },
143
- },
144
- baseProps
145
- ),
146
- boxplot: assign(
147
- {
148
- style: {
149
- max: { padding, stroke: blueGrey700, strokeWidth: 1 },
150
- maxLabels: assign({}, baseLabelStyles, { padding: 3 }),
151
- median: { padding, stroke: blueGrey700, strokeWidth: 1 },
152
- medianLabels: assign({}, baseLabelStyles, { padding: 3 }),
153
- min: { padding, stroke: blueGrey700, strokeWidth: 1 },
154
- minLabels: assign({}, baseLabelStyles, { padding: 3 }),
155
- q1: { padding, fill: blueGrey700 },
156
- q1Labels: assign({}, baseLabelStyles, { padding: 3 }),
157
- q3: { padding, fill: blueGrey700 },
158
- q3Labels: assign({}, baseLabelStyles, { padding: 3 }),
159
- },
160
- boxWidth: 20,
161
- },
162
- baseProps
163
- ),
164
- candlestick: assign(
165
- {
166
- style: {
167
- data: {
168
- stroke: blueGrey700,
169
- },
170
- labels: assign({}, baseLabelStyles, { padding: 5 }),
171
- },
172
- candleColors: {
173
- positive: '#ffffff',
174
- negative: blueGrey700,
175
- },
176
- },
177
- baseProps
178
- ),
179
- chart: baseProps,
180
- errorbar: assign(
181
- {
182
- borderWidth: 8,
183
- style: {
184
- data: {
185
- fill: 'transparent',
186
- opacity: 1,
187
- stroke: blueGrey700,
188
- strokeWidth: 2,
189
- },
190
- labels: baseLabelStyles,
191
- },
192
- },
193
- baseProps
194
- ),
195
- group: assign(
196
- {
197
- colorScale: colors,
198
- },
199
- baseProps
200
- ),
201
- histogram: assign(
202
- {
203
- style: {
204
- data: {
205
- fill: blueGrey700,
206
- stroke: grey900,
207
- strokeWidth: 2,
208
- },
209
- labels: baseLabelStyles,
210
- },
211
- },
212
- baseProps
213
- ),
214
- legend: {
215
- colorScale: colors,
216
- gutter: 10,
217
- orientation: 'vertical',
218
- titleOrientation: 'top',
219
- style: {
220
- data: {
221
- type: 'circle',
222
- },
223
- labels: baseLabelStyles,
224
- title: assign({}, baseLabelStyles, { padding: 5 }),
225
- },
226
- },
227
- line: assign(
228
- {
229
- style: {
230
- data: {
231
- fill: 'transparent',
232
- opacity: 1,
233
- stroke: blueGrey700,
234
- strokeWidth: 2,
235
- },
236
- labels: baseLabelStyles,
237
- },
238
- },
239
- baseProps
240
- ),
241
- pie: assign(
242
- {
243
- colorScale: colors,
244
- style: {
245
- data: {
246
- padding,
247
- stroke: blueGrey50,
248
- strokeWidth: 1,
249
- },
250
- labels: assign({}, baseLabelStyles, { padding: 20 }),
251
- },
252
- },
253
- baseProps
254
- ),
255
- scatter: assign(
256
- {
257
- style: {
258
- data: {
259
- fill: blueGrey700,
260
- opacity: 1,
261
- stroke: 'transparent',
262
- strokeWidth: 0,
263
- },
264
- labels: baseLabelStyles,
265
- },
266
- },
267
- baseProps
268
- ),
269
- stack: assign(
270
- {
271
- colorScale: colors,
272
- },
273
- baseProps
274
- ),
275
- tooltip: {
276
- style: assign({}, baseLabelStyles, { padding: 0, pointerEvents: 'none' }),
277
- flyoutStyle: {
278
- stroke: grey900,
279
- strokeWidth: 1,
280
- fill: '#f0f0f0',
281
- pointerEvents: 'none',
282
- },
283
- flyoutPadding: 5,
284
- cornerRadius: 5,
285
- pointerLength: 10,
286
- },
287
- voronoi: assign(
288
- {
289
- style: {
290
- data: {
291
- fill: 'transparent',
292
- stroke: 'transparent',
293
- strokeWidth: 0,
294
- },
295
- labels: assign({}, baseLabelStyles, {
296
- padding: 5,
297
- pointerEvents: 'none',
298
- }),
299
- flyout: {
300
- stroke: grey900,
301
- strokeWidth: 1,
302
- fill: '#f0f0f0',
303
- pointerEvents: 'none',
304
- },
305
- },
306
- },
307
- baseProps
308
- ),
309
- };