Skip to content

Commit

Permalink
feat: add domain fitting (#510)
Browse files Browse the repository at this point in the history
* Upgrade prettier eslint dependencies 
* Fix linting errors
* Add option to fit y domain to data
  • Loading branch information
nickofthyme committed Jan 8, 2020
1 parent cc866d6 commit fefe728
Show file tree
Hide file tree
Showing 58 changed files with 1,747 additions and 484 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -98,10 +98,10 @@
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.10.0",
"eslint": "^6.7.1",
"eslint-config-prettier": "^6.7.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-jest": "^23.0.4",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.13.0",
"husky": "^3.1.0",
"jest": "^24.9.0",
Expand All @@ -117,7 +117,7 @@
"moment-timezone": "^0.5.27",
"node-sass": "^4.11.0",
"postcss-cli": "^6.1.3",
"prettier": "1.16.4",
"prettier": "^1.19.1",
"pretty-quick": "^2.0.0",
"puppeteer": "^1.20.0",
"react": "16.10.x",
Expand Down
Expand Up @@ -19,7 +19,11 @@ describe('Crosshair utils linear scale', () => {
id: barSeries1SpecId,
groupId: getGroupId('group1'),
seriesType: SeriesTypes.Bar,
data: [[0, 0], [1, 0], [2, 0]],
data: [
[0, 0],
[1, 0],
[2, 0],
],
xAccessor: 0,
yAccessors: [1],
xScaleType: ScaleType.Linear,
Expand All @@ -32,7 +36,11 @@ describe('Crosshair utils linear scale', () => {
id: barSeries2SpecId,
groupId: getGroupId('group1'),
seriesType: SeriesTypes.Bar,
data: [[0, 2], [1, 2], [2, 2]],
data: [
[0, 2],
[1, 2],
[2, 2],
],
xAccessor: 0,
yAccessors: [1],
xScaleType: ScaleType.Linear,
Expand All @@ -45,7 +53,11 @@ describe('Crosshair utils linear scale', () => {
id: lineSeries1SpecId,
groupId: getGroupId('group1'),
seriesType: SeriesTypes.Line,
data: [[0, 0], [1, 0], [2, 0]],
data: [
[0, 0],
[1, 0],
[2, 0],
],
xAccessor: 0,
yAccessors: [1],
xScaleType: ScaleType.Linear,
Expand All @@ -58,7 +70,11 @@ describe('Crosshair utils linear scale', () => {
id: lineSeries2SpecId,
groupId: getGroupId('group1'),
seriesType: SeriesTypes.Line,
data: [[0, 2], [1, 2], [2, 2]],
data: [
[0, 2],
[1, 2],
[2, 2],
],
xAccessor: 0,
yAccessors: [1],
xScaleType: ScaleType.Linear,
Expand Down
Expand Up @@ -18,7 +18,11 @@ describe('Crosshair utils ordinal scales', () => {
id: barSeries1SpecId,
groupId: getGroupId('group1'),
seriesType: SeriesTypes.Bar,
data: [['a', 0], ['b', 0], ['c', 0]],
data: [
['a', 0],
['b', 0],
['c', 0],
],
xAccessor: 0,
yAccessors: [1],
xScaleType: ScaleType.Ordinal,
Expand All @@ -31,7 +35,11 @@ describe('Crosshair utils ordinal scales', () => {
id: barSeries2SpecId,
groupId: getGroupId('group1'),
seriesType: SeriesTypes.Bar,
data: [['a', 2], ['b', 2], ['c', 2]],
data: [
['a', 2],
['b', 2],
['c', 2],
],
xAccessor: 0,
yAccessors: [1],
xScaleType: ScaleType.Ordinal,
Expand All @@ -44,7 +52,11 @@ describe('Crosshair utils ordinal scales', () => {
id: lineSeries1SpecId,
groupId: getGroupId('group1'),
seriesType: SeriesTypes.Line,
data: [['a', 0], ['b', 0], ['c', 0]],
data: [
['a', 0],
['b', 0],
['c', 0],
],
xAccessor: 0,
yAccessors: [1],
xScaleType: ScaleType.Ordinal,
Expand All @@ -57,7 +69,11 @@ describe('Crosshair utils ordinal scales', () => {
id: lineSeries2SpecId,
groupId: getGroupId('group1'),
seriesType: SeriesTypes.Line,
data: [['a', 2], ['b', 2], ['c', 2]],
data: [
['a', 2],
['b', 2],
['c', 2],
],
xAccessor: 0,
yAccessors: [1],
xScaleType: ScaleType.Ordinal,
Expand Down
96 changes: 80 additions & 16 deletions src/chart_types/xy_chart/domains/x_domain.test.ts
Expand Up @@ -179,7 +179,12 @@ describe('X Domain', () => {
xScaleType: ScaleType.Linear,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 1, y: 0 },
{ x: 2, y: 0 },
{ x: 5, y: 0 },
],
};
const ds2: BasicSeriesSpec = {
chartType: ChartTypes.XYAxis,
Expand All @@ -192,7 +197,10 @@ describe('X Domain', () => {
xScaleType: ScaleType.Linear,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 7, y: 0 },
],
};
const specDataSeries: BasicSeriesSpec[] = [ds1, ds2];
const { xValues } = getSplittedSeries(specDataSeries);
Expand All @@ -219,7 +227,12 @@ describe('X Domain', () => {
xScaleType: ScaleType.Linear,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 1, y: 0 },
{ x: 2, y: 0 },
{ x: 5, y: 0 },
],
};
const ds2: BasicSeriesSpec = {
chartType: ChartTypes.XYAxis,
Expand All @@ -232,7 +245,10 @@ describe('X Domain', () => {
xScaleType: ScaleType.Linear,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 7, y: 0 },
],
};
const specDataSeries = [ds1, ds2];

Expand Down Expand Up @@ -260,7 +276,12 @@ describe('X Domain', () => {
xScaleType: ScaleType.Linear,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 1, y: 0 },
{ x: 2, y: 0 },
{ x: 5, y: 0 },
],
};
const ds2: BasicSeriesSpec = {
chartType: ChartTypes.XYAxis,
Expand All @@ -273,7 +294,10 @@ describe('X Domain', () => {
xScaleType: ScaleType.Linear,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 7, y: 0 },
],
};
const specDataSeries = [ds1, ds2];

Expand Down Expand Up @@ -305,7 +329,12 @@ describe('X Domain', () => {
xScaleType: ScaleType.Linear,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 1, y: 0 },
{ x: 2, y: 0 },
{ x: 5, y: 0 },
],
};
const ds2: BasicSeriesSpec = {
chartType: ChartTypes.XYAxis,
Expand All @@ -318,7 +347,10 @@ describe('X Domain', () => {
xScaleType: ScaleType.Linear,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 7, y: 0 },
],
};
const specDataSeries = [ds1, ds2];

Expand Down Expand Up @@ -350,7 +382,12 @@ describe('X Domain', () => {
xScaleType: ScaleType.Linear,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 1, y: 0 },
{ x: 2, y: 0 },
{ x: 5, y: 0 },
],
};
const ds2: BasicSeriesSpec = {
chartType: ChartTypes.XYAxis,
Expand All @@ -363,7 +400,10 @@ describe('X Domain', () => {
xScaleType: ScaleType.Ordinal,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 7, y: 0 },
],
};
const specDataSeries = [ds1, ds2];

Expand Down Expand Up @@ -395,7 +435,12 @@ describe('X Domain', () => {
xScaleType: ScaleType.Linear,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 1, y: 0 },
{ x: 2, y: 0 },
{ x: 5, y: 0 },
],
};
const ds2: BasicSeriesSpec = {
chartType: ChartTypes.XYAxis,
Expand All @@ -408,7 +453,10 @@ describe('X Domain', () => {
xScaleType: ScaleType.Ordinal,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 7, y: 0 },
],
};
const specDataSeries = [ds1, ds2];

Expand Down Expand Up @@ -440,7 +488,12 @@ describe('X Domain', () => {
xScaleType: ScaleType.Ordinal,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 1, y: 0 },
{ x: 2, y: 0 },
{ x: 5, y: 0 },
],
};
const ds2: BasicSeriesSpec = {
chartType: ChartTypes.XYAxis,
Expand All @@ -453,7 +506,10 @@ describe('X Domain', () => {
xScaleType: ScaleType.Time,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 7, y: 0 },
],
};
const specDataSeries = [ds1, ds2];

Expand Down Expand Up @@ -485,7 +541,12 @@ describe('X Domain', () => {
xScaleType: ScaleType.Ordinal,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 2, y: 0 }, { x: 5, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 1, y: 0 },
{ x: 2, y: 0 },
{ x: 5, y: 0 },
],
};
const ds2: BasicSeriesSpec = {
chartType: ChartTypes.XYAxis,
Expand All @@ -498,7 +559,10 @@ describe('X Domain', () => {
xScaleType: ScaleType.Linear,
yScaleType: ScaleType.Linear,
yScaleToDataExtent: false,
data: [{ x: 0, y: 0 }, { x: 7, y: 0 }],
data: [
{ x: 0, y: 0 },
{ x: 7, y: 0 },
],
};
const specDataSeries = [ds1, ds2];

Expand Down

0 comments on commit fefe728

Please sign in to comment.