Skip to content

Commit

Permalink
fix(Chord): 修复弦图label 样式不能修改的问题 (#3270)
Browse files Browse the repository at this point in the history
Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com>
  • Loading branch information
ai-qing-hai and ai-qing-hai committed Jul 8, 2022
1 parent c15b9c2 commit bc5b2cf
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
44 changes: 44 additions & 0 deletions __tests__/bugs/issue-3200-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Chord } from '../../src';
import { createDiv } from '../utils/dom';
import { delay } from '../utils/delay';

describe('#3200', () => {
const DATA = [
{ source: '北京', target: '天津', value: 30 },
{ source: '北京', target: '上海', value: 80 },
{ source: '北京', target: '河北', value: 46 },
{ source: '北京', target: '辽宁', value: 49 },
{ source: '北京', target: '黑龙江', value: 69 },
{ source: '北京', target: '吉林', value: 19 },
{ source: '天津', target: '河北', value: 62 },
{ source: '天津', target: '辽宁', value: 82 },
{ source: '天津', target: '上海', value: 16 },
{ source: '上海', target: '黑龙江', value: 16 },
{ source: '河北', target: '黑龙江', value: 76 },
{ source: '河北', target: '内蒙古', value: 24 },
{ source: '内蒙古', target: '北京', value: 32 },
];

const chord = new Chord(createDiv(), {
data: DATA,
sourceField: 'source',
targetField: 'target',
weightField: 'value',
label: {
style: {
fill: 'red',
},
},
});

chord.render();

it('Chord label ', async () => {
await delay(200);
const fill = chord.chart.canvas.findAllByName('label')[0]?.cfg?.children[0].attr('fill');

expect(fill).toEqual('red');

chord.destroy();
});
});
8 changes: 4 additions & 4 deletions src/plots/chord/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ export const DEFAULT_OPTIONS = {
const centerX = (x[0] + x[1]) / 2;
const offsetX = centerX > 0.5 ? -4 : 4;
return {
labelEmit: true,
style: {
fill: '#8c8c8c',
},
offsetX,
content: name,
};
},
labelEmit: true,
style: {
fill: '#8c8c8c',
},
},
tooltip: {
showTitle: false,
Expand Down

0 comments on commit bc5b2cf

Please sign in to comment.