UNPKG

@antv/narrative-text-schema

Version:

Json schema of narrative text visualization

57 lines (56 loc) 2.1 kB
import { CustomMetaData, CommonProps } from './common'; export declare type PhraseSpec = TextPhraseSpec | EntityPhraseSpec | CustomPhraseSpec<CustomMetaData>; export declare type TextPhraseSpec = CommonProps & { type: 'text'; value: string; bold?: boolean; italic?: boolean; underline?: boolean; url?: string; }; export declare type EntityPhraseSpec = CommonProps & { type: 'entity'; value?: string; metadata?: EntityMetaData; }; export declare type CustomPhraseSpec<P extends CustomMetaData = CustomMetaData> = CommonProps & { type: 'custom'; value?: string; metadata?: P; }; export declare type ValueAssessment = 'positive' | 'negative' | 'equal'; export declare const EntityType: readonly ["metric_name", "metric_value", "other_metric_value", "contribute_ratio", "delta_value", "ratio_value", "trend_desc", "dim_value", "time_desc", "proportion"]; export declare type EntityType = typeof EntityType[number]; export declare type EntityMetaData = { /** * entity type, 实体类型标记 * */ entityType: EntityType; /** * assessment up or down, used for derived value * 衍生指标评估参数,指定上涨或者下跌 * */ assessment?: ValueAssessment; /** * original data, 原始数据 * */ origin?: number; /** * detail data, 明细数据,用于弹框展示 */ detail?: unknown; /** source id of the variable, to access the variable info from variableSourceMap */ sourceId?: string; }; export declare type TypeOrMetaReturnType<T> = T | ((value: string, metadata: EntityMetaData) => T); /** entity phrase encoding channel */ export declare type EntityEncoding<NodeType> = Partial<{ color: TypeOrMetaReturnType<string>; bgColor: TypeOrMetaReturnType<string>; fontSize: TypeOrMetaReturnType<string | number>; fontWeight: TypeOrMetaReturnType<string | number>; underline: TypeOrMetaReturnType<boolean>; prefix: TypeOrMetaReturnType<NodeType>; suffix: TypeOrMetaReturnType<NodeType>; inlineChart: TypeOrMetaReturnType<NodeType>; }>;