Skip to content

Commit

Permalink
fix(heatmap): 修复色力图 coordinate部分配置不起效 和 配置了 refect coordinate 失效的问题 (#…
Browse files Browse the repository at this point in the history
…3294)

* fix(heatmap): 修复色力图 coordinate部分配置不起效 和 配置了 refect coordinate 失效的问题

* fix(heatmap): 修复色力图 coordinate部分配置不起效 和 配置了 refect coordinate 失效的问题

* fix(heatmap): 修复色力图 coordinate部分配置不起效 和 配置了 refect coordinate 失效的问题 -2

* fix(heatmap): 修复色力图 coordinate部分配置不起效 和 配置了 refect coordinate 失效的问题 -2

* fix(heatmap): 修复色力图 coordinate部分配置不起效 和 配置了 refect coordinate 失效的问题 -2

* fix(heatmap): 修复色力图 coordinate部分配置不起效 和 配置了 refect coordinate 失效的问题 -3

Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com>
  • Loading branch information
ai-qing-hai and ai-qing-hai committed Jul 28, 2022
1 parent dd090c2 commit 45d60d7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
36 changes: 36 additions & 0 deletions __tests__/unit/plots/heatmap/coordinate-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,40 @@ describe('heatmap', () => {

heatmap.destroy();
});

it('coordinate reflect', () => {
const coordinate = {
type: 'polar',
cfg: {
radius: 0.85,
innerRadius: 0.2,
},
actions: [['scale', 0.5, -1]],
} as any;

const heatmap = new Heatmap(createDiv('custom axis'), {
width: 400,
height: 300,
data: semanticBasicHeatmapData,
xField: 'name',
yField: 'day',
colorField: 'sales',
shape: 'circle',
coordinate,
reflect: 'x',
});

heatmap.render();

// @ts-ignore
expect(heatmap.chart.options.coordinate).toMatchObject({
...coordinate,
actions: [
['scale', 0.5, -1],
['reflect', 'x'],
],
});

heatmap.destroy();
});
});
11 changes: 4 additions & 7 deletions src/plots/heatmap/adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,14 @@ function coordinate(params: Params<HeatmapOptions>): Params<HeatmapOptions> {
const { chart, options } = params;
const { coordinate, reflect } = options;

if (coordinate) {
chart.coordinate({
type: coordinate.type || 'rect',
cfg: coordinate.cfg,
});
}
const coordinateOption = deepAssign({ actions: [] }, coordinate ?? { type: 'rect' });

if (reflect) {
chart.coordinate().reflect(reflect);
coordinateOption.actions?.push?.(['reflect', reflect]);
}

chart.coordinate(coordinateOption);

return params;
}

Expand Down

0 comments on commit 45d60d7

Please sign in to comment.