@alicloud/cloud-charts
Version:

83 lines (82 loc) • 3.53 kB
TypeScript
import { Chart, Types, G2Dependents } from './types';
import { customFormatterConfig } from './common';
declare type Position = 'top' | 'top-left' | 'top-right' | 'right' | 'right-top' | 'right-bottom' | 'left' | 'left-top' | 'left-bottom' | 'bottom' | 'bottom-left' | 'bottom-right';
export interface LegendConfig extends customFormatterConfig {
visible?: boolean;
/** 是否支持分页 */
autoCollapse?: boolean;
/** 分页尺寸 */
collapseRow?: number;
position?: Position;
align?: string;
padding?: [number, number, number, number];
nameFormatter?(text: string, item: G2Dependents.ListItem, index: number): string;
valueFormatter?(value: string | number, item: G2Dependents.ListItem, index: number): string;
showData?: boolean;
marker?: Types.MarkerCfg;
allowAllCanceled?: boolean;
hoverable?: boolean;
/** @deprecated config.legend.onHover 已废弃,请使用 chart.on('legend-item:mouseenter', onHover) */
onHover?: Types.EventCallback;
clickable?: boolean;
/** @deprecated config.legend.onClick 已废弃,请使用 chart.on('legend-item:click', onClick) */
onClick?: Types.EventCallback;
/** @deprecated config.legend.defaultClickBehavior 已废弃,请使用 chart.on('legend-item:click', onClick) 绑定自定义点击事件 */
defaultClickBehavior?: boolean;
customConfig?: Types.LegendCfg;
/**
* @title 最大宽度
* @description **分类图例适用**,图例项最大宽度设置。
*/
maxWidth?: number;
/**
* @title 最大高度
* @description **分类图例适用**,图例项最大高度设置。
*/
maxHeight?: number;
/**
* @title 最大宽度比例
* @description **分类图例适用**,图例项最大宽度比例(以 view 的 bbox 宽度为参照,默认 0.45)。
*/
maxWidthRatio?: number;
/**
* @title 最大高度比例
* @description **分类图例适用**,图例项最大高度比例(以 view 的 bbox 高度为参照,默认 0.45)。
*/
maxHeightRatio?: number;
/**
* @title 是否采用反选模式
* @description 默认true,false时采用单选模式
*/
useReverseChecked?: boolean;
/**
* 默认false,true表示采用表格型legend并显示所有统计值
* 目前仅支持线图
*/
table?: boolean | {
/** 显示哪些指标 */
statistics?: Array<'min' | 'max' | 'avg' | 'current'>;
/** 显示几位小数,默认3位,当有valueFormmater时失效 */
decimal?: number;
};
/** legend数量多时是否折叠,默认false,优先级高于分页 */
foldable?: boolean;
dodge?: boolean;
}
/**
* rectLegend 直角坐标系legend配置。
*
* @param {this} ctx 组件实例 this 指针
* @param {Chart} chart 图表实例
* @param {Object} config 配置项
* @param {Object} defaultConfig 组件的自定义配置
* @param {boolean} isOneDataGroup 数据是否为单组形式,类似饼图和漏斗图
* @param {string} field 数据映射字段
* @param {boolean} isPolar 是否极坐标系
* @param {function} itemFormatter 组件自定义的 item 格式函数
* */
export default function <T>(ctx: T, chart: Chart, config: {
legend?: LegendConfig | boolean;
showStackSum?: boolean;
}, defaultConfig: Types.LegendCfg, isOneDataGroup: boolean, field?: string, isPolar?: boolean, itemFormatter?: (item: G2Dependents.ListItem, i: number) => G2Dependents.ListItem): void;
export {};