Skip to content

Commit

Permalink
fix(dual-axes): 修复双轴图缩略缺失start或end丢失右侧view问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liwenbo committed Dec 6, 2023
1 parent 66ea0f0 commit 1ab71a6
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
71 changes: 71 additions & 0 deletions __tests__/bugs/bug-dual-axes-silder-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { DualAxes } from '../../src';
import { createDiv } from '../utils/dom';

describe('dual-axes slider', () => {
const data = [
{ time: '2019-03', value: 350, count: 800 },
{ time: '2019-04', value: 900, count: 600 },
{ time: '2019-05', value: 300, count: 400 },
{ time: '2019-06', value: 450, count: 380 },
{ time: '2019-07', value: 470, count: 220 },
];

it('slider left view should have data', () => {
const dualAxes = new DualAxes(createDiv(), {
data: [data, data],
xField: 'time',
yField: ['value', 'count'],
slider: {
end: 1,
},
geometryOptions: [
{
geometry: 'column',
},
{
geometry: 'line',
lineStyle: {
lineWidth: 2,
},
},
],
});

dualAxes.render();
const filterData = dualAxes.chart.views[1].getData();
expect(filterData.length).toBeGreaterThan(0);
expect(filterData).toEqual(data);

dualAxes.destroy();
});

it('dual axes should have same data', () => {
const dualAxes = new DualAxes(createDiv(), {
data: [data, data],
xField: 'time',
yField: ['value', 'count'],
slider: {
end: 0.9,
},
geometryOptions: [
{
geometry: 'column',
},
{
geometry: 'line',
lineStyle: {
lineWidth: 2,
},
},
],
});

dualAxes.render();

const columnFilterData = dualAxes.chart.views[0].getData();
const lineFilterData = dualAxes.chart.views[1].getData();
expect(columnFilterData).toEqual(lineFilterData);

dualAxes.destroy();
});
});
4 changes: 2 additions & 2 deletions src/plots/dual-axes/adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ export function slider(params: Params<DualAxesOptions>): Params<DualAxesOptions>
chart.once('afterpaint', () => {
// 初始化数据,配置默认值时需要同步
if (!isBoolean(slider)) {
const { start, end } = slider;
if (start || end) {
const { start = 0, end = 1 } = slider;
if (start !== 0 || end !== 1) {
doSliderFilter(rightView, [start, end]);
}
}
Expand Down

0 comments on commit 1ab71a6

Please sign in to comment.