@alicloud/cloud-charts
Version:

199 lines (198 loc) • 7.24 kB
TypeScript
import { Colors, Types } from './types';
import LanguageMap from '../locales';
import isEqual from 'lodash/isEqual';
import isEqualWith from 'lodash/isEqualWith';
import merge from 'lodash/merge';
export { isEqual, isEqualWith, merge };
export declare const requestAnimationFrame: ((callback: FrameRequestCallback) => number) & typeof globalThis.requestAnimationFrame;
export declare const propertyMap: {
axis: string[];
};
/**
* 向目标对象拷贝指定的key的值
*
* @param {string[]} keys 判断的key
* @param {Object} target 目标对象
* @param {Object} source 源对象
*
* @return {Object} 目标对象
* */
export declare function propertyAssign(keys: string[], target: Types.LooseObject, source: Types.LooseObject | false): Types.LooseObject;
/**
* 找到对应元素的父元素的大小
*
* @param {element} element Html元素
* @param {number | string} width props中传递的width属性
* @param {number | string} height props中传递的height属性
*
* @return {number[]} 宽和高的数组
* */
export declare function getParentSize(element: HTMLElement, width: number | string, height: number | string): number[];
/**
* 将像素字符串转为数值
*
* @param {string} px 像素字符串
*
* @return {number} 数值
* */
export declare function pxToNumber(px: string): number;
/**
* 从Highcharts格式数据中找到对应index的颜色
*
* @param {array} colors 颜色数组
* @param {array} rawData Highcharts 格式的数据
* @param {number} dataIndex y轴对应的index
* */
export declare function getDataIndexColor(colors: Colors, rawData: any[], dataIndex: number): string | void;
/** 主题关键字 */
/** 颜色映射, 主要针对状态色 */
export declare function mapColors(colors: Colors): Colors;
/**
* 根据状态获得颜色值
*
* @param {string} status 状态字符串
*
* @return {string} 颜色值
* */
export declare function getStatusColor(status: string): any;
/**
* 根据状态获得颜色名称
*
* @param {string} status 状态字符串
*
* @return {string} 颜色名称
* */
export declare function getStatusColorName(status: string): string;
export declare function getAreaColors(areaColors: string[], isStack?: boolean): string[];
/**
* 判断是否是无效数字
*
* @param v 输入值
* 增加判断V中有大写字母,目的是为了区分region地址和科学记数法
*
* @return {boolean} 是否无效数字
* */
export declare function isInvalidNumber(v: any): boolean;
/**
* 数字格式化小数位
*
* @param {number} num 输入数字
* @param {number} decimal 小数位数,默认一位
*
* @return {string|number} 如果不是数字,返回横杠字符串。如果是数字,返回设定小数位的字符串。
* */
export declare function numberDecimal(num: any, decimal?: number): any;
/**
* 数字格式化千分位
*
* @param {number} num 输入数字
* @param {number} char 分隔符,默认为逗号
*
* @return {string|number} 如果不是数字,返回横杠字符串。如果是数字,返回千分位的字符串。
* */
export declare function beautifyNumber(num: any, char?: string): any;
/**
* 空函数
* */
export declare function noop(): void;
/**
* tooltip item 获取原始数据
*
* @param {object} config 图表配置项
* @param {array} rawData 挂载于 this.rawData 上的原始数据
* @param {number} item tooltip格式化函数的当前数据项
*
* @return {object} 寻找得到的原始数据,没有找到则返回空对象。
* */
export declare function getRawData(config: {
dataType?: string;
}, rawData: any[], item: any): any;
/**
* 过滤对象中的key,常用于过滤传递给div的props,防止react invalid attribute warning
*
* @param {object} obj 过滤的对象
* @param {array} keys 过滤的键列表
*
* @return {object} 过滤后的结果
* */
export declare function filterKey(obj: Types.LooseObject, keys: string[]): Types.LooseObject;
export declare const unitFamily: any;
export interface customFormatterConfig {
unit?: string;
decimal?: number;
grouping?: boolean | string;
needUnitTransform?: boolean;
unitTransformTo?: string;
valueType?: 'number' | 'disk_1000' | 'disk_1024' | 'bandwidth_1000' | 'bandwidth_1024' | 'money' | 'percent_1' | 'percent_100' | 'time' | 'count';
hideZeroUnit?: boolean;
customCarryUnits?: string | string[];
customCarryThreshold?: number;
addonTextAfter?: string;
}
/**
* 自定义格式化函数,支持 单位、小数位、千分位 处理
* 包含云体系下的单位处理
* valueType 表示进位方式
* unit 为当前单位, 默认为当前类型的最小单位
* needUnitTransform 为是否需要转换
* unitTransformTo 为目标单位
* 如:
* disk - b、kb、mb
* bandwidth - b/s、kb/s、mb/s
* money - ¥
* percent - %
* count - count、k、m、b
* time - ms、s
* */
export declare function customFormatter(config: customFormatterConfig): (v: any) => string;
export declare function findUnitArray(input: string, valueType?: string): Array<string>;
/**
* 统一进位单位格式化
* */
export declare function unitConversion(originValue: any, unit?: any, decimal?: number, unitTransformTo?: any, valueType?: string, customCarryUnits?: string | string[], customCarryThreshold?: number, addonTextAfter?: string): {
value: any;
unit: string;
};
/**
* 获取指定颜色的顺序色
* *
* @param {string} primaryColor 指定颜色
* @param {string} backgroundColor 当前背景色
* @param {number} linearCount 顺序色个数
* @param {string} type 是否为中心取色
* */
export declare function calcLinearColor(primaryColor: string, backgroundColor?: string, linearCount?: number, type?: string, needDistribution?: boolean): any[];
/**
* 递归遍历树节点
* */
export declare function traverseTree(node: any, itemFunction?: any): any;
/**
* deepAssign 功能类似 deepMix
* 不同点在于 deepAssign 会将 null undefined 等类型直接覆盖给 source
*/
export declare const deepAssign: (rst: any, ...args: any[]) => any;
export declare function containsChinese(str: string): boolean;
export declare function sampleDataWithNoise(chartData: number[], sampleRate?: number, options?: any): number[];
/**
* 判断一个地点是否在中国境内
* @param latitude number 维度
* @param longitude number 经度
*/
export declare function isInsideChina(latitude: number, longitude: number): boolean;
export declare function getAutoMask(def: Types.ScaleOption, data: any, language?: keyof typeof LanguageMap): string;
export declare function getHourlyTimestamp(timestamp: number): number;
export declare function generateTimestamps(start: number, end: number, interval: number, showLast?: boolean, showInteger?: boolean): number[];
export declare function getFormatConfig(config: any): any;
declare type DataPoint = [number, number | null];
declare type InputSeries = {
name: string;
data: [number, number][];
};
declare type OutputSeries = {
name: string;
data: DataPoint[];
};
/**
* fillMissingTimestamps 数据补齐功能
*/
export declare function fillMissingTimestamps(input: InputSeries[], fillValue?: null | 0, tickInterval?: number): OutputSeries[];