mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-03 02:52:08 +08:00
85 lines
1.8 KiB
TypeScript
85 lines
1.8 KiB
TypeScript
import { EChartsOption } from 'echarts';
|
|
|
|
export interface ILineData {
|
|
value: number;
|
|
timeStamp: number;
|
|
}
|
|
export interface ICurve {
|
|
title?: string;
|
|
path: string;
|
|
colors: string[];
|
|
parser?: (option: ICurve, data: ILineData) => EChartsOption;
|
|
message?: string;
|
|
unit?: string;
|
|
api?: any;
|
|
}
|
|
|
|
export const LEGEND_HEIGHT = 18;
|
|
export const defaultLegendPadding = 10;
|
|
export const GRID_HEIGHT = 192;
|
|
export const EXPAND_GRID_HEIGHT = 250;
|
|
export const TITLE_HEIGHT = 40;
|
|
export const UNIT_HEIGHT = 20;
|
|
export const LEGEND_PADDING = 10;
|
|
export const OPERATOR_TITLE_HEIGHT = 92;
|
|
|
|
export const baseLineLegend = {
|
|
itemWidth: 12,
|
|
itemHeight: 2,
|
|
icon: 'rect',
|
|
textStyle: {
|
|
lineHeight: LEGEND_HEIGHT,
|
|
},
|
|
};
|
|
|
|
export const baseLineGrid = {
|
|
left: '0',
|
|
right: '2%',
|
|
top: TITLE_HEIGHT + UNIT_HEIGHT,
|
|
height: GRID_HEIGHT,
|
|
containLabel: true,
|
|
};
|
|
|
|
export const baseAxisStyle = {
|
|
nameTextStyle: {
|
|
color: '#A0A4AA',
|
|
},
|
|
axisLine: {
|
|
lineStyle: {
|
|
color: '#A0A4AA',
|
|
},
|
|
},
|
|
splitline: {
|
|
lineStyle: {
|
|
color: '#A0A4AA',
|
|
},
|
|
},
|
|
};
|
|
|
|
export const noAxis = {
|
|
axisLine: {
|
|
lineStyle: {
|
|
color: '#A0A4AA',
|
|
},
|
|
show: false,
|
|
},
|
|
axisTick: {
|
|
show: false,
|
|
},
|
|
};
|
|
|
|
export const getHight = (options: any) => {
|
|
let grid = options ? options.grid : null;
|
|
if (!options || !grid) grid = baseLineGrid;
|
|
return Number(grid.height) + getLegendHight(options) + Number(grid.top) + LEGEND_PADDING + UNIT_HEIGHT;
|
|
};
|
|
|
|
export const getLegendHight = (options: any) => {
|
|
if (!options) return 0;
|
|
if (options.legend.show === false) return 0;
|
|
const legendHight = options.legend.textStyle.lineHeight + defaultLegendPadding;
|
|
if (options.legend.orient !== 'vertical') return legendHight;
|
|
const legendLength = options.series.length;
|
|
return legendHight * legendLength;
|
|
};
|