我知道要隱藏刻度標簽只需將一個空字串傳遞給 .tickFormat ("") 方法。這適用于 Javascript,但不適用于 Typescript,因為它回傳以下錯誤:
TS2769: No overload matches this call.
Overload 1 of 3, '(format: null): Axis<NumberValue>', gave the following error.
Argument of type '""' is not assignable to parameter of type 'null'.
Overload 2 of 3, '(format: (domainValue: NumberValue, index: number) => string): Axis<NumberValue>', gave the following error.
Argument of type 'string' is not assignable to parameter of type '(domainValue: NumberValue, index: number) => string'.
> 100 | const Xaxis = d3.axisTop(Xscale).tickFormat("");
tickFormat 方法想要:
tickFormat(format: (domainValue: Domain, index: number) => string): this;
/**
* Reset the tick format function. A null format indicates that the scale’s
* default formatter should be used, which is generated by calling scale.tickFormat.
* In this case, the arguments specified by axis.tickArguments
* are likewise passed to scale.tickFormat.
*
* @param format null
*/
tickFormat(format: null): this;
如何通過傳遞空字串并隱藏標簽來解決問題?
uj5u.com熱心網友回復:
該錯誤告訴您解決方案:
Overload 2 of 3, '(format: (domainValue: NumberValue, index: number) => string): Axis<NumberValue>', gave the following error.
Argument of type 'string' is not assignable to parameter of type '(domainValue: NumberValue, index: number) => string'.
您應該提供一個回傳字串的函式:
axis.tickFormat(() => '');
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/516095.html
上一篇:不乘以100的刻度百分比
