Skip to content

Commit 66a48ff

Browse files
nickofthymemarkov00
authored andcommitted
refactor: series identifications throughout library (#419)
BREAKING CHANGE: `GeometryId` is now `SeriesIdentifier`. `customSeriesColors` prop on `SeriesSpec` which used to take a `CustomSeriesColorsMap`, now expects a `CustomSeriesColors` type. `LegendItemListener` now passes the `SeriesIdentifier` type as the first callback argument.
1 parent 3013c41 commit 66a48ff

File tree

73 files changed

+2824
-1698
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2824
-1698
lines changed

.storybook/utils.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

integration/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ function requireAllStories() {
2323

2424
function encodeString(string: string) {
2525
return string
26+
.replace(/-/g, ' ')
27+
.replace(/\w-\w/g, ' ')
2628
.replace(/\//gi, ' ')
2729
.replace(/-/g, ' ')
2830
.replace(/[^a-z|A-Z|0-9|\s|\/]+/gi, '')
Loading
Loading
Loading
Loading
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
"ts-loader": "^6.1.2",
134134
"ts-prune": "^0.3.0",
135135
"typescript": "^3.6.3",
136-
"utility-types": "^3.8.0",
136+
"utility-types": "^3.9.0",
137137
"webpack": "^4.29.5",
138138
"webpack-cli": "^3.3.1",
139139
"webpack-dev-server": "^3.3.1"

src/chart_types/xy_chart/domains/y_domain.test.ts

Lines changed: 124 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ describe('Y Domain', () => {
1717
const dataSeries: RawDataSeries[] = [
1818
{
1919
specId: 'a',
20-
key: [''],
21-
seriesColorKey: '',
20+
yAccessor: 'y1',
21+
splitAccessors: new Map(),
22+
seriesKeys: [''],
23+
key: '',
2224
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
2325
},
2426
{
2527
specId: 'a',
26-
key: [''],
27-
seriesColorKey: '',
28+
yAccessor: 'y1',
29+
splitAccessors: new Map(),
30+
seriesKeys: [''],
31+
key: '',
2832
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
2933
},
3034
];
@@ -58,22 +62,28 @@ describe('Y Domain', () => {
5862
const dataSeries1: RawDataSeries[] = [
5963
{
6064
specId: 'a',
61-
key: [''],
62-
seriesColorKey: '',
65+
yAccessor: 'y1',
66+
splitAccessors: new Map(),
67+
seriesKeys: [''],
68+
key: '',
6369
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
6470
},
6571
{
6672
specId: 'a',
67-
key: [''],
68-
seriesColorKey: '',
73+
yAccessor: 'y1',
74+
splitAccessors: new Map(),
75+
seriesKeys: [''],
76+
key: '',
6977
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
7078
},
7179
];
7280
const dataSeries2: RawDataSeries[] = [
7381
{
7482
specId: 'a',
75-
key: [''],
76-
seriesColorKey: '',
83+
yAccessor: 'y1',
84+
splitAccessors: new Map(),
85+
seriesKeys: [''],
86+
key: '',
7787
data: [{ x: 1, y1: 10 }, { x: 2, y1: 10 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
7888
},
7989
];
@@ -123,22 +133,28 @@ describe('Y Domain', () => {
123133
const dataSeries1: RawDataSeries[] = [
124134
{
125135
specId: 'a',
126-
key: [''],
127-
seriesColorKey: '',
136+
yAccessor: 'y1',
137+
splitAccessors: new Map(),
138+
seriesKeys: [''],
139+
key: '',
128140
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
129141
},
130142
{
131143
specId: 'a',
132-
key: [''],
133-
seriesColorKey: '',
144+
yAccessor: 'y1',
145+
splitAccessors: new Map(),
146+
seriesKeys: [''],
147+
key: '',
134148
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
135149
},
136150
];
137151
const dataSeries2: RawDataSeries[] = [
138152
{
139153
specId: 'a',
140-
key: [''],
141-
seriesColorKey: '',
154+
yAccessor: 'y1',
155+
splitAccessors: new Map(),
156+
seriesKeys: [''],
157+
key: '',
142158
data: [{ x: 1, y1: 10 }, { x: 2, y1: 10 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
143159
},
144160
];
@@ -181,22 +197,28 @@ describe('Y Domain', () => {
181197
const dataSeries1: RawDataSeries[] = [
182198
{
183199
specId: 'a',
184-
key: [''],
185-
seriesColorKey: '',
200+
yAccessor: 'y1',
201+
splitAccessors: new Map(),
202+
seriesKeys: [''],
203+
key: '',
186204
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
187205
},
188206
{
189207
specId: 'a',
190-
key: [''],
191-
seriesColorKey: '',
208+
yAccessor: 'y1',
209+
splitAccessors: new Map(),
210+
seriesKeys: [''],
211+
key: '',
192212
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
193213
},
194214
];
195215
const dataSeries2: RawDataSeries[] = [
196216
{
197217
specId: 'a',
198-
key: [''],
199-
seriesColorKey: '',
218+
yAccessor: 'y1',
219+
splitAccessors: new Map(),
220+
seriesKeys: [''],
221+
key: '',
200222
data: [{ x: 1, y1: 10 }, { x: 2, y1: 10 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
201223
},
202224
];
@@ -239,22 +261,28 @@ describe('Y Domain', () => {
239261
const dataSeries1: RawDataSeries[] = [
240262
{
241263
specId: 'a',
242-
key: [''],
243-
seriesColorKey: '',
264+
yAccessor: 'y1',
265+
splitAccessors: new Map(),
266+
seriesKeys: [''],
267+
key: '',
244268
data: new Array(maxValues).fill(0).map((d, i) => ({ x: i, y1: i })),
245269
},
246270
{
247271
specId: 'a',
248-
key: [''],
249-
seriesColorKey: '',
272+
yAccessor: 'y1',
273+
splitAccessors: new Map(),
274+
seriesKeys: [''],
275+
key: '',
250276
data: new Array(maxValues).fill(0).map((d, i) => ({ x: i, y1: i })),
251277
},
252278
];
253279
const dataSeries2: RawDataSeries[] = [
254280
{
255281
specId: 'a',
256-
key: [''],
257-
seriesColorKey: '',
282+
yAccessor: 'y1',
283+
splitAccessors: new Map(),
284+
seriesKeys: [''],
285+
key: '',
258286
data: new Array(maxValues).fill(0).map((d, i) => ({ x: i, y1: i })),
259287
},
260288
];
@@ -460,14 +488,18 @@ describe('Y Domain', () => {
460488
const dataSeries: RawDataSeries[] = [
461489
{
462490
specId: 'a',
463-
key: [''],
464-
seriesColorKey: '',
491+
yAccessor: 'y1',
492+
splitAccessors: new Map(),
493+
seriesKeys: [''],
494+
key: '',
465495
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
466496
},
467497
{
468498
specId: 'a',
469-
key: [''],
470-
seriesColorKey: '',
499+
yAccessor: 'y1',
500+
splitAccessors: new Map(),
501+
seriesKeys: [''],
502+
key: '',
471503
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
472504
},
473505
];
@@ -494,14 +526,18 @@ describe('Y Domain', () => {
494526
const dataSeries: RawDataSeries[] = [
495527
{
496528
specId: 'a',
497-
key: [''],
498-
seriesColorKey: '',
529+
yAccessor: 'y1',
530+
splitAccessors: new Map(),
531+
seriesKeys: [''],
532+
key: '',
499533
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
500534
},
501535
{
502536
specId: 'a',
503-
key: [''],
504-
seriesColorKey: '',
537+
yAccessor: 'y1',
538+
splitAccessors: new Map(),
539+
seriesKeys: [''],
540+
key: '',
505541
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
506542
},
507543
];
@@ -540,14 +576,18 @@ describe('Y Domain', () => {
540576
const dataSeries: RawDataSeries[] = [
541577
{
542578
specId: 'a',
543-
key: [''],
544-
seriesColorKey: '',
579+
yAccessor: 'y1',
580+
splitAccessors: new Map(),
581+
seriesKeys: [''],
582+
key: '',
545583
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
546584
},
547585
{
548586
specId: 'a',
549-
key: [''],
550-
seriesColorKey: '',
587+
yAccessor: 'y1',
588+
splitAccessors: new Map(),
589+
seriesKeys: [''],
590+
key: '',
551591
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
552592
},
553593
];
@@ -586,14 +626,18 @@ describe('Y Domain', () => {
586626
const dataSeries: RawDataSeries[] = [
587627
{
588628
specId: 'a',
589-
key: [''],
590-
seriesColorKey: '',
629+
yAccessor: 'y1',
630+
splitAccessors: new Map(),
631+
seriesKeys: [''],
632+
key: '',
591633
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
592634
},
593635
{
594636
specId: 'a',
595-
key: [''],
596-
seriesColorKey: '',
637+
yAccessor: 'y1',
638+
splitAccessors: new Map(),
639+
seriesKeys: [''],
640+
key: '',
597641
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
598642
},
599643
];
@@ -628,14 +672,18 @@ describe('Y Domain', () => {
628672
const dataSeries: RawDataSeries[] = [
629673
{
630674
specId: 'a',
631-
key: [''],
632-
seriesColorKey: '',
675+
yAccessor: 'y1',
676+
splitAccessors: new Map(),
677+
seriesKeys: [''],
678+
key: '',
633679
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
634680
},
635681
{
636682
specId: 'a',
637-
key: [''],
638-
seriesColorKey: '',
683+
yAccessor: 'y1',
684+
splitAccessors: new Map(),
685+
seriesKeys: [''],
686+
key: '',
639687
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
640688
},
641689
];
@@ -674,14 +722,18 @@ describe('Y Domain', () => {
674722
const dataSeries: RawDataSeries[] = [
675723
{
676724
specId: 'a',
677-
key: [''],
678-
seriesColorKey: '',
725+
yAccessor: 'y1',
726+
splitAccessors: new Map(),
727+
seriesKeys: [''],
728+
key: '',
679729
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
680730
},
681731
{
682732
specId: 'a',
683-
key: [''],
684-
seriesColorKey: '',
733+
yAccessor: 'y1',
734+
splitAccessors: new Map(),
735+
seriesKeys: [''],
736+
key: '',
685737
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
686738
},
687739
];
@@ -714,22 +766,28 @@ describe('Y Domain', () => {
714766
const dataSeries1: RawDataSeries[] = [
715767
{
716768
specId: 'a',
717-
key: [''],
718-
seriesColorKey: '',
769+
yAccessor: 'y1',
770+
splitAccessors: new Map(),
771+
seriesKeys: [''],
772+
key: '',
719773
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
720774
},
721775
{
722776
specId: 'a',
723-
key: [''],
724-
seriesColorKey: '',
777+
yAccessor: 'y1',
778+
splitAccessors: new Map(),
779+
seriesKeys: [''],
780+
key: '',
725781
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
726782
},
727783
];
728784
const dataSeries2: RawDataSeries[] = [
729785
{
730786
specId: 'a',
731-
key: [''],
732-
seriesColorKey: '',
787+
yAccessor: 'y1',
788+
splitAccessors: new Map(),
789+
seriesKeys: [''],
790+
key: '',
733791
data: [{ x: 1, y1: 10 }, { x: 2, y1: 10 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
734792
},
735793
];
@@ -774,14 +832,18 @@ describe('Y Domain', () => {
774832
const dataSeries: RawDataSeries[] = [
775833
{
776834
specId: 'a',
777-
key: [''],
778-
seriesColorKey: '',
835+
yAccessor: 'y1',
836+
splitAccessors: new Map(),
837+
seriesKeys: [''],
838+
key: '',
779839
data: [{ x: 1, y1: 2 }, { x: 2, y1: 2 }, { x: 3, y1: 2 }, { x: 4, y1: 5 }],
780840
},
781841
{
782842
specId: 'a',
783-
key: [''],
784-
seriesColorKey: '',
843+
yAccessor: 'y1',
844+
splitAccessors: new Map(),
845+
seriesKeys: [''],
846+
key: '',
785847
data: [{ x: 1, y1: 2 }, { x: 4, y1: 7 }],
786848
},
787849
];

0 commit comments

Comments
 (0)