Skip to content

Commit

Permalink
fix: tickline 不生效 & theme 不生效 (#1677)
Browse files Browse the repository at this point in the history
* fix: tickline 不生效

* fix:theme 不生效

Co-authored-by: xuying.xu <xuying.xu@alibaba-inc.com>
  • Loading branch information
tangying1027 and xuying.xu authored Dec 12, 2022
1 parent fc5d635 commit 49e7f78
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/f2/src/chart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ class Chart<TRecord extends DataRecord = DataRecord> extends Component<
super(props);

const { theme, px2hd } = context;

// hack 处理,设置默认的主题样式
// 目前没想到其他更合适的方式,只能先这样处理
deepMix(theme, px2hd(Theme));
context.theme = deepMix(px2hd(Theme), theme);

const { data } = props;

Expand Down
3 changes: 3 additions & 0 deletions packages/f2/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const axis = {
fill: '#E8E8E8',
radius: '10px',
},
tickLine: {
stroke: '#E8E8E8',
},
label: {
fill: '#808080',
fontSize: '20px',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions packages/f2/test/components/axis/axis.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,36 @@ describe('Axis 轴', () => {
expect(context).toMatchImageSnapshot();
});

it('刻度线', async () => {
const context = createContext('tickLine');

const { type, props } = (
<Canvas context={context} pixelRatio={1}>
<Chart data={valuationData}>
<Axis field="index" />
<Axis
field="value"
formatter={(v) => {
return v.toFixed(2) + '%';
}}
style={{
tickLine: {
length: 3,
},
}}
/>
<Line x="index" y="value" color="#2FC25B" />
</Chart>
</Canvas>
);

const canvas = new Canvas(props);
await canvas.render();

await delay(1000);
expect(context).toMatchImageSnapshot();
});

it('label 回调参数', async () => {
const context = createContext('label 回调参数');
const labelMockCallback = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion packages/f2/test/components/guide/guide.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('Guide ', () => {
// 10个图例 和1条线
expect(container.children[0].children.length).toBe(11);

await delay(250);
await delay(500);
expect(context).toMatchImageSnapshot();
});

Expand Down

0 comments on commit 49e7f78

Please sign in to comment.