Skip to content

Commit

Permalink
fix: tickStyle传入基础类型报错 (#1292)
Browse files Browse the repository at this point in the history
  • Loading branch information
ACERY1 committed Nov 29, 2021
1 parent c1d477f commit fddc32b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/f2/src/components/axis/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ export interface Style<Type = void> {
label?: StyleText<Type>;
}

export interface StyleProps<Type = void> extends Omit<Style, 'label' | 'grid'> {
export interface StyleProps<Type = void> extends Omit<Style, 'label' | 'grid' | 'labelOffset'> {
label?: StyleText<Type> | LabelCallback<Type>;
grid?: LineAttrs | GridCallBack;
labelOffset?: number | string;
}

interface Point {
Expand Down
13 changes: 9 additions & 4 deletions packages/f2/src/components/axis/withAxis.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deepMix, isFunction, mix, each, clone } from '@antv/util';
import { deepMix, isFunction, mix, each, clone, isString, isNumber } from '@antv/util';
import { jsx } from '../../jsx';
import equal from '../../base/equal';
import Component from '../../base/component';
Expand Down Expand Up @@ -132,10 +132,15 @@ export default (View) => {
if (style[key] === null) {
return;
}
const styleValue = isFunction(style[key]) ? undefined : style[key]

this.style[key] = px2hd(
deepMix(clone(value), isFunction(style[key]) ? undefined : style[key])
);
if (isString(value) || isNumber(value)) {
this.style[key] = px2hd(styleValue) || value;
} else {
this.style[key] = px2hd(
deepMix(clone(value), styleValue)
);
}
});

return ticks.map((tick: Tick, index) => {
Expand Down
1 change: 1 addition & 0 deletions packages/f2/test/components/axis/axis.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ describe('Axis 轴', () => {
stroke: '#e8e8e8',
lineWidth: 1,
},
labelOffset: '50px',
}}
/>
<Axis
Expand Down

0 comments on commit fddc32b

Please sign in to comment.