fix: fix the error type define

This commit is contained in:
kkxxkk2019 2023-09-12 22:28:10 +08:00
parent 61ed334766
commit 62dd5fe819
5 changed files with 21 additions and 14 deletions

View File

@ -24,13 +24,13 @@ export interface ICartesianChartSpec extends IChartSpec {
/**
* 线
*/
markLine?: IMarkLineSpec;
markLine?: IMarkLineSpec | IMarkLineSpec[];
/**
*
*/
markArea?: IMarkAreaSpec;
markArea?: IMarkAreaSpec | IMarkLineSpec[];
/**
*
*/
markPoint?: IMarkPointSpec;
markPoint?: IMarkPointSpec | IMarkPointSpec[];
}

View File

@ -1,8 +1,8 @@
import type { IPadding, IPointLike } from '@visactor/vutils';
import type { SymbolType } from '@visactor/vrender';
import type { IModelSpec } from '../../model/interface';
import type { IRectMarkSpec, ISymbolMarkSpec, ITextMarkSpec, StringOrNumber } from '../../typings';
import type { IComponentSpec } from '../base/interface';
import type { Datum } from '@visactor/vrender-components';
export type IAggrType = 'sum' | 'average' | 'min' | 'max' | 'variance' | 'standardDeviation' | 'median';
export type IDataPos = string | number | IAggrType;
@ -46,7 +46,7 @@ export type IMarkerLabelSpec = {
/**
*
*/
padding?: IPadding;
padding?: IPadding | number[] | number;
/**
*
*/
@ -58,10 +58,11 @@ export type IMarkerLabelSpec = {
text?: string | string[] | number | number[];
/**
* label文本 -
* @param datum marker组件聚合或回归计算后的数据值
* @param markData
* @param seriesData
* @returns
*/
formatMethod?: (datum: IDataPos) => string | string[] | number | number[];
formatMethod?: (markData: Datum[], seriesData: Datum[]) => string | string[] | number | number[];
/**
* label文本 -
*/
@ -148,7 +149,7 @@ export interface IMarkerSpec extends IComponentSpec {
export interface IMarkerSymbol extends IMarkerRef {
/** 是否展示 symbol */
visible: boolean;
visible?: boolean;
/**
* symbol
*/

View File

@ -85,6 +85,9 @@ export class MarkArea extends BaseMarker<IMarkAreaSpec & IMarkAreaTheme> impleme
}
protected _markerLayout() {
if (!this._markerComponent) {
return;
}
const spec = this._spec as any;
const data = this._markerData;
const startRelativeSeries = this._startRelativeSeries;
@ -124,12 +127,12 @@ export class MarkArea extends BaseMarker<IMarkAreaSpec & IMarkAreaTheme> impleme
width: maxX - minX,
height: maxY - minY
};
this._markerComponent?.setAttributes({
this._markerComponent.setAttributes({
points: points,
label: {
...this._markerComponent.attribute?.label,
text: this._spec.label.formatMethod
? this._spec.label.formatMethod(dataPoints)
? this._spec.label.formatMethod(dataPoints, this._relativeSeries.getViewData().latestData)
: this._markerComponent.attribute?.label?.text
},
limitRect

View File

@ -14,7 +14,7 @@ export interface IMarkLineTheme {
position?: IMarkLineLabelPosition;
} & IMarkerLabelSpec;
startSymbol: IMarkerSymbol;
startSymbol?: IMarkerSymbol;
endSymbol: IMarkerSymbol;
endSymbol?: IMarkerSymbol;
}

View File

@ -85,6 +85,9 @@ export class MarkPoint extends BaseMarker<IMarkPointSpec & IMarkPointTheme> impl
}
protected _markerLayout() {
if (!this._markerComponent) {
return;
}
const spec = this._spec;
const data = this._markerData;
const relativeSeries = this._relativeSeries;
@ -109,14 +112,14 @@ export class MarkPoint extends BaseMarker<IMarkPointSpec & IMarkPointTheme> impl
height: maxY - minY
};
this._markerComponent?.setAttributes({
this._markerComponent.setAttributes({
position: point,
itemContent: {
...this._markerComponent.attribute?.itemContent,
textStyle: {
...this._markerComponent.attribute?.itemContent?.textStyle,
text: this._spec.itemContent.text?.formatMethod
? this._spec.itemContent.text.formatMethod(dataPoints)
? this._spec.itemContent.text.formatMethod(dataPoints, this._relativeSeries.getViewData().latestData)
: this._markerComponent.attribute?.itemContent?.textStyle?.text
}
},