-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto set limitInPlot based on yAxis config (#2009)
* feat: auto set limitInPlot based on yAxis config * fix: more unit test for limitInPlot
- Loading branch information
Showing
10 changed files
with
338 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Area } from '../../../../src'; | ||
import { createDiv } from '../../../utils/dom'; | ||
|
||
const DATA = [ | ||
{ | ||
type: 'A', | ||
value: 0, | ||
}, | ||
{ | ||
type: 'B', | ||
value: 10, | ||
}, | ||
{ | ||
type: 'C', | ||
value: 5, | ||
}, | ||
{ | ||
type: 'D', | ||
value: 20, | ||
}, | ||
]; | ||
|
||
describe('line limitInPlot', () => { | ||
const plot = new Area(createDiv(), { | ||
data: DATA, | ||
xField: 'type', | ||
yField: 'value', | ||
}); | ||
|
||
it('limitInPlot false', () => { | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
}); | ||
|
||
it('limitInPlot true', () => { | ||
plot.update({ | ||
yAxis: { | ||
minLimit: 6, | ||
}, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeTruthy(); | ||
}); | ||
|
||
it('limitInPlot false', () => { | ||
plot.update({ | ||
yAxis: { | ||
minLimit: undefined, | ||
}, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
}); | ||
|
||
it('user config', () => { | ||
plot.update({ | ||
yAxis: { | ||
minLimit: 6, | ||
}, | ||
limitInPlot: false, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
|
||
plot.update({ | ||
yAxis: false, | ||
limitInPlot: true, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Bar } from '../../../../src'; | ||
import { createDiv } from '../../../utils/dom'; | ||
|
||
const DATA = [ | ||
{ | ||
type: 'A', | ||
value: 0, | ||
}, | ||
{ | ||
type: 'B', | ||
value: 10, | ||
}, | ||
{ | ||
type: 'C', | ||
value: 5, | ||
}, | ||
{ | ||
type: 'D', | ||
value: 20, | ||
}, | ||
]; | ||
|
||
describe('line limitInPlot', () => { | ||
const plot = new Bar(createDiv(), { | ||
data: DATA, | ||
yField: 'type', | ||
xField: 'value', | ||
}); | ||
|
||
it('limitInPlot false', () => { | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
}); | ||
|
||
it('limitInPlot true', () => { | ||
plot.update({ | ||
xAxis: { | ||
minLimit: 6, | ||
}, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeTruthy(); | ||
}); | ||
|
||
it('limitInPlot false', () => { | ||
plot.update({ | ||
xAxis: { | ||
minLimit: undefined, | ||
}, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
}); | ||
|
||
it('user config', () => { | ||
plot.update({ | ||
yAxis: { | ||
minLimit: 6, | ||
}, | ||
limitInPlot: false, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
|
||
plot.update({ | ||
yAxis: false, | ||
limitInPlot: true, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { Column } from '../../../../src'; | ||
import { createDiv } from '../../../utils/dom'; | ||
|
||
const DATA = [ | ||
{ | ||
type: 'A', | ||
value: 0, | ||
}, | ||
{ | ||
type: 'B', | ||
value: 10, | ||
}, | ||
{ | ||
type: 'C', | ||
value: 5, | ||
}, | ||
{ | ||
type: 'D', | ||
value: 20, | ||
}, | ||
]; | ||
|
||
describe('line limitInPlot', () => { | ||
const plot = new Column(createDiv(), { | ||
data: DATA, | ||
xField: 'type', | ||
yField: 'value', | ||
}); | ||
|
||
it('limitInPlot false', () => { | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
}); | ||
|
||
it('limitInPlot true', () => { | ||
plot.update({ | ||
yAxis: { | ||
minLimit: 6, | ||
}, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeTruthy(); | ||
}); | ||
|
||
it('limitInPlot false', () => { | ||
plot.update({ | ||
yAxis: { | ||
minLimit: undefined, | ||
}, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
}); | ||
|
||
it('user config', () => { | ||
plot.update({ | ||
yAxis: { | ||
minLimit: 6, | ||
}, | ||
limitInPlot: false, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
|
||
plot.update({ | ||
yAxis: false, | ||
limitInPlot: true, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { Line } from '../../../../src'; | ||
import { createDiv } from '../../../utils/dom'; | ||
|
||
const DATA = [ | ||
{ | ||
type: 'A', | ||
value: 0, | ||
}, | ||
{ | ||
type: 'B', | ||
value: 10, | ||
}, | ||
{ | ||
type: 'C', | ||
value: 5, | ||
}, | ||
{ | ||
type: 'D', | ||
value: 20, | ||
}, | ||
]; | ||
|
||
describe('line limitInPlot', () => { | ||
const plot = new Line(createDiv(), { | ||
data: DATA, | ||
xField: 'type', | ||
yField: 'value', | ||
point: { | ||
size: 10, | ||
}, | ||
}); | ||
|
||
it('limitInPlot false', () => { | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
}); | ||
|
||
it('limitInPlot true', () => { | ||
plot.update({ | ||
yAxis: { | ||
minLimit: 6, | ||
}, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeTruthy(); | ||
}); | ||
|
||
it('limitInPlot false', () => { | ||
plot.update({ | ||
yAxis: { | ||
minLimit: undefined, | ||
}, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
}); | ||
|
||
it('user config', () => { | ||
plot.update({ | ||
yAxis: { | ||
minLimit: 6, | ||
}, | ||
limitInPlot: false, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeFalsy(); | ||
|
||
plot.update({ | ||
yAxis: false, | ||
limitInPlot: true, | ||
}); | ||
plot.render(); | ||
expect(plot.chart.limitInPlot).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.