Skip to content

Commit fefe728

Browse files
authored
feat: add domain fitting (#510)
* Upgrade prettier eslint dependencies * Fix linting errors * Add option to fit y domain to data
1 parent cc866d6 commit fefe728

58 files changed

Lines changed: 1747 additions & 484 deletions

Some content is hidden

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@
9898
"enzyme": "^3.9.0",
9999
"enzyme-adapter-react-16": "^1.10.0",
100100
"eslint": "^6.7.1",
101-
"eslint-config-prettier": "^6.7.0",
101+
"eslint-config-prettier": "^6.9.0",
102102
"eslint-plugin-import": "^2.17.3",
103103
"eslint-plugin-jest": "^23.0.4",
104-
"eslint-plugin-prettier": "^3.1.0",
104+
"eslint-plugin-prettier": "^3.1.2",
105105
"eslint-plugin-react": "^7.13.0",
106106
"husky": "^3.1.0",
107107
"jest": "^24.9.0",
@@ -117,7 +117,7 @@
117117
"moment-timezone": "^0.5.27",
118118
"node-sass": "^4.11.0",
119119
"postcss-cli": "^6.1.3",
120-
"prettier": "1.16.4",
120+
"prettier": "^1.19.1",
121121
"pretty-quick": "^2.0.0",
122122
"puppeteer": "^1.20.0",
123123
"react": "16.10.x",

src/chart_types/xy_chart/crosshair/crosshair_utils.linear_snap.test.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ describe('Crosshair utils linear scale', () => {
1919
id: barSeries1SpecId,
2020
groupId: getGroupId('group1'),
2121
seriesType: SeriesTypes.Bar,
22-
data: [[0, 0], [1, 0], [2, 0]],
22+
data: [
23+
[0, 0],
24+
[1, 0],
25+
[2, 0],
26+
],
2327
xAccessor: 0,
2428
yAccessors: [1],
2529
xScaleType: ScaleType.Linear,
@@ -32,7 +36,11 @@ describe('Crosshair utils linear scale', () => {
3236
id: barSeries2SpecId,
3337
groupId: getGroupId('group1'),
3438
seriesType: SeriesTypes.Bar,
35-
data: [[0, 2], [1, 2], [2, 2]],
39+
data: [
40+
[0, 2],
41+
[1, 2],
42+
[2, 2],
43+
],
3644
xAccessor: 0,
3745
yAccessors: [1],
3846
xScaleType: ScaleType.Linear,
@@ -45,7 +53,11 @@ describe('Crosshair utils linear scale', () => {
4553
id: lineSeries1SpecId,
4654
groupId: getGroupId('group1'),
4755
seriesType: SeriesTypes.Line,
48-
data: [[0, 0], [1, 0], [2, 0]],
56+
data: [
57+
[0, 0],
58+
[1, 0],
59+
[2, 0],
60+
],
4961
xAccessor: 0,
5062
yAccessors: [1],
5163
xScaleType: ScaleType.Linear,
@@ -58,7 +70,11 @@ describe('Crosshair utils linear scale', () => {
5870
id: lineSeries2SpecId,
5971
groupId: getGroupId('group1'),
6072
seriesType: SeriesTypes.Line,
61-
data: [[0, 2], [1, 2], [2, 2]],
73+
data: [
74+
[0, 2],
75+
[1, 2],
76+
[2, 2],
77+
],
6278
xAccessor: 0,
6379
yAccessors: [1],
6480
xScaleType: ScaleType.Linear,

src/chart_types/xy_chart/crosshair/crosshair_utils.ordinal_snap.test.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ describe('Crosshair utils ordinal scales', () => {
1818
id: barSeries1SpecId,
1919
groupId: getGroupId('group1'),
2020
seriesType: SeriesTypes.Bar,
21-
data: [['a', 0], ['b', 0], ['c', 0]],
21+
data: [
22+
['a', 0],
23+
['b', 0],
24+
['c', 0],
25+
],
2226
xAccessor: 0,
2327
yAccessors: [1],
2428
xScaleType: ScaleType.Ordinal,
@@ -31,7 +35,11 @@ describe('Crosshair utils ordinal scales', () => {
3135
id: barSeries2SpecId,
3236
groupId: getGroupId('group1'),
3337
seriesType: SeriesTypes.Bar,
34-
data: [['a', 2], ['b', 2], ['c', 2]],
38+
data: [
39+
['a', 2],
40+
['b', 2],
41+
['c', 2],
42+
],
3543
xAccessor: 0,
3644
yAccessors: [1],
3745
xScaleType: ScaleType.Ordinal,
@@ -44,7 +52,11 @@ describe('Crosshair utils ordinal scales', () => {
4452
id: lineSeries1SpecId,
4553
groupId: getGroupId('group1'),
4654
seriesType: SeriesTypes.Line,
47-
data: [['a', 0], ['b', 0], ['c', 0]],
55+
data: [
56+
['a', 0],
57+
['b', 0],
58+
['c', 0],
59+
],
4860
xAccessor: 0,
4961
yAccessors: [1],
5062
xScaleType: ScaleType.Ordinal,
@@ -57,7 +69,11 @@ describe('Crosshair utils ordinal scales', () => {
5769
id: lineSeries2SpecId,
5870
groupId: getGroupId('group1'),
5971
seriesType: SeriesTypes.Line,
60-
data: [['a', 2], ['b', 2], ['c', 2]],
72+
data: [
73+
['a', 2],
74+
['b', 2],
75+
['c', 2],
76+
],
6177
xAccessor: 0,
6278
yAccessors: [1],
6379
xScaleType: ScaleType.Ordinal,

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

Lines changed: 80 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,12 @@ describe('X Domain', () => {
179179
xScaleType: ScaleType.Linear,
180180
yScaleType: ScaleType.Linear,
181181
yScaleToDataExtent: false,
182-
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
182+
data: [
183+
{ x: 0, y: 0 },
184+
{ x: 1, y: 0 },
185+
{ x: 2, y: 0 },
186+
{ x: 5, y: 0 },
187+
],
183188
};
184189
const ds2: BasicSeriesSpec = {
185190
chartType: ChartTypes.XYAxis,
@@ -192,7 +197,10 @@ describe('X Domain', () => {
192197
xScaleType: ScaleType.Linear,
193198
yScaleType: ScaleType.Linear,
194199
yScaleToDataExtent: false,
195-
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
200+
data: [
201+
{ x: 0, y: 0 },
202+
{ x: 7, y: 0 },
203+
],
196204
};
197205
const specDataSeries: BasicSeriesSpec[] = [ds1, ds2];
198206
const { xValues } = getSplittedSeries(specDataSeries);
@@ -219,7 +227,12 @@ describe('X Domain', () => {
219227
xScaleType: ScaleType.Linear,
220228
yScaleType: ScaleType.Linear,
221229
yScaleToDataExtent: false,
222-
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
230+
data: [
231+
{ x: 0, y: 0 },
232+
{ x: 1, y: 0 },
233+
{ x: 2, y: 0 },
234+
{ x: 5, y: 0 },
235+
],
223236
};
224237
const ds2: BasicSeriesSpec = {
225238
chartType: ChartTypes.XYAxis,
@@ -232,7 +245,10 @@ describe('X Domain', () => {
232245
xScaleType: ScaleType.Linear,
233246
yScaleType: ScaleType.Linear,
234247
yScaleToDataExtent: false,
235-
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
248+
data: [
249+
{ x: 0, y: 0 },
250+
{ x: 7, y: 0 },
251+
],
236252
};
237253
const specDataSeries = [ds1, ds2];
238254

@@ -260,7 +276,12 @@ describe('X Domain', () => {
260276
xScaleType: ScaleType.Linear,
261277
yScaleType: ScaleType.Linear,
262278
yScaleToDataExtent: false,
263-
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
279+
data: [
280+
{ x: 0, y: 0 },
281+
{ x: 1, y: 0 },
282+
{ x: 2, y: 0 },
283+
{ x: 5, y: 0 },
284+
],
264285
};
265286
const ds2: BasicSeriesSpec = {
266287
chartType: ChartTypes.XYAxis,
@@ -273,7 +294,10 @@ describe('X Domain', () => {
273294
xScaleType: ScaleType.Linear,
274295
yScaleType: ScaleType.Linear,
275296
yScaleToDataExtent: false,
276-
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
297+
data: [
298+
{ x: 0, y: 0 },
299+
{ x: 7, y: 0 },
300+
],
277301
};
278302
const specDataSeries = [ds1, ds2];
279303

@@ -305,7 +329,12 @@ describe('X Domain', () => {
305329
xScaleType: ScaleType.Linear,
306330
yScaleType: ScaleType.Linear,
307331
yScaleToDataExtent: false,
308-
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
332+
data: [
333+
{ x: 0, y: 0 },
334+
{ x: 1, y: 0 },
335+
{ x: 2, y: 0 },
336+
{ x: 5, y: 0 },
337+
],
309338
};
310339
const ds2: BasicSeriesSpec = {
311340
chartType: ChartTypes.XYAxis,
@@ -318,7 +347,10 @@ describe('X Domain', () => {
318347
xScaleType: ScaleType.Linear,
319348
yScaleType: ScaleType.Linear,
320349
yScaleToDataExtent: false,
321-
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
350+
data: [
351+
{ x: 0, y: 0 },
352+
{ x: 7, y: 0 },
353+
],
322354
};
323355
const specDataSeries = [ds1, ds2];
324356

@@ -350,7 +382,12 @@ describe('X Domain', () => {
350382
xScaleType: ScaleType.Linear,
351383
yScaleType: ScaleType.Linear,
352384
yScaleToDataExtent: false,
353-
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
385+
data: [
386+
{ x: 0, y: 0 },
387+
{ x: 1, y: 0 },
388+
{ x: 2, y: 0 },
389+
{ x: 5, y: 0 },
390+
],
354391
};
355392
const ds2: BasicSeriesSpec = {
356393
chartType: ChartTypes.XYAxis,
@@ -363,7 +400,10 @@ describe('X Domain', () => {
363400
xScaleType: ScaleType.Ordinal,
364401
yScaleType: ScaleType.Linear,
365402
yScaleToDataExtent: false,
366-
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
403+
data: [
404+
{ x: 0, y: 0 },
405+
{ x: 7, y: 0 },
406+
],
367407
};
368408
const specDataSeries = [ds1, ds2];
369409

@@ -395,7 +435,12 @@ describe('X Domain', () => {
395435
xScaleType: ScaleType.Linear,
396436
yScaleType: ScaleType.Linear,
397437
yScaleToDataExtent: false,
398-
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
438+
data: [
439+
{ x: 0, y: 0 },
440+
{ x: 1, y: 0 },
441+
{ x: 2, y: 0 },
442+
{ x: 5, y: 0 },
443+
],
399444
};
400445
const ds2: BasicSeriesSpec = {
401446
chartType: ChartTypes.XYAxis,
@@ -408,7 +453,10 @@ describe('X Domain', () => {
408453
xScaleType: ScaleType.Ordinal,
409454
yScaleType: ScaleType.Linear,
410455
yScaleToDataExtent: false,
411-
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
456+
data: [
457+
{ x: 0, y: 0 },
458+
{ x: 7, y: 0 },
459+
],
412460
};
413461
const specDataSeries = [ds1, ds2];
414462

@@ -440,7 +488,12 @@ describe('X Domain', () => {
440488
xScaleType: ScaleType.Ordinal,
441489
yScaleType: ScaleType.Linear,
442490
yScaleToDataExtent: false,
443-
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
491+
data: [
492+
{ x: 0, y: 0 },
493+
{ x: 1, y: 0 },
494+
{ x: 2, y: 0 },
495+
{ x: 5, y: 0 },
496+
],
444497
};
445498
const ds2: BasicSeriesSpec = {
446499
chartType: ChartTypes.XYAxis,
@@ -453,7 +506,10 @@ describe('X Domain', () => {
453506
xScaleType: ScaleType.Time,
454507
yScaleType: ScaleType.Linear,
455508
yScaleToDataExtent: false,
456-
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
509+
data: [
510+
{ x: 0, y: 0 },
511+
{ x: 7, y: 0 },
512+
],
457513
};
458514
const specDataSeries = [ds1, ds2];
459515

@@ -485,7 +541,12 @@ describe('X Domain', () => {
485541
xScaleType: ScaleType.Ordinal,
486542
yScaleType: ScaleType.Linear,
487543
yScaleToDataExtent: false,
488-
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
544+
data: [
545+
{ x: 0, y: 0 },
546+
{ x: 1, y: 0 },
547+
{ x: 2, y: 0 },
548+
{ x: 5, y: 0 },
549+
],
489550
};
490551
const ds2: BasicSeriesSpec = {
491552
chartType: ChartTypes.XYAxis,
@@ -498,7 +559,10 @@ describe('X Domain', () => {
498559
xScaleType: ScaleType.Linear,
499560
yScaleType: ScaleType.Linear,
500561
yScaleToDataExtent: false,
501-
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
562+
data: [
563+
{ x: 0, y: 0 },
564+
{ x: 7, y: 0 },
565+
],
502566
};
503567
const specDataSeries = [ds1, ds2];
504568

0 commit comments

Comments
 (0)