/** * This file is part of the NocoBase (R) project. * Copyright (c) 2020-2024 NocoBase Co., Ltd. * Authors: NocoBase Team. * * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. * For more information, please refer to: https://www.nocobase.com/agreement. */ import React from 'react'; import { AnySchema, Config, ConfigType } from './configs'; export type FieldOption = { value: string; label: string; key: string; alias?: string; name?: string; type?: string; interface?: string; uiSchema?: AnySchema; target?: string; targetFields?: FieldOption[]; }; export type MeasureProps = { field: string | string[]; aggregation?: string; alias?: string; }; export type DimensionProps = { field: string | string[]; alias?: string; format?: string; }; export type Transformer = (val: any, ...args: any[]) => string | number; export type FieldRenderProps = { label: string; interface?: string; transformer?: Transformer; }; export type RenderProps = { data: Record[]; general: any; advanced: any; fieldProps: { [field: string]: FieldRenderProps; }; }; export interface ChartType { name: string; title: string; enableAdvancedConfig?: boolean; Component: React.FC; schema: AnySchema; init?: (fields: FieldOption[], query: { measures?: MeasureProps[]; dimensions?: DimensionProps[]; }) => { general?: any; advanced?: any; }; getProps(props: RenderProps): any; getReference?: () => { title: string; link: string; }; } export type ChartProps = { name: string; title: string; enableAdvancedConfig?: boolean; Component: React.FC; config?: Config[]; }; export declare class Chart implements ChartType { name: string; title: string; enableAdvancedConfig: boolean; Component: React.FC; config: Config[]; configTypes: Map; constructor({ name, title, enableAdvancedConfig, Component, config }: ChartProps); get schema(): { type?: undefined; properties?: undefined; } | { type: string; properties: any; }; addConfigTypes(configs: { [key: string]: ConfigType; }): void; infer(fields: FieldOption[], { measures, dimensions, }: { measures?: MeasureProps[]; dimensions?: DimensionProps[]; }): { xField: FieldOption; yField: FieldOption; seriesField: FieldOption; colorField: FieldOption; yFields: FieldOption[]; }; getProps(props: RenderProps): any; }