|
|
|
@ -25,7 +25,7 @@ import { |
|
|
|
import { ComponentStyle, Font, simpleDateFormat, textStyle } from '@shared/models/widget-settings.models'; |
|
|
|
import { XAXisOption, YAXisOption } from 'echarts/types/dist/shared'; |
|
|
|
import { CustomSeriesOption, LineSeriesOption } from 'echarts/charts'; |
|
|
|
import { formatValue, isDefinedAndNotNull, isUndefinedOrNull, parseFunction } from '@core/utils'; |
|
|
|
import { formatValue, isDefinedAndNotNull, isUndefined, isUndefinedOrNull, parseFunction } from '@core/utils'; |
|
|
|
import { LinearGradientObject } from 'zrender/lib/graphic/LinearGradient'; |
|
|
|
import tinycolor from 'tinycolor2'; |
|
|
|
import Axis2D from 'echarts/types/src/coord/cartesian/Axis2D'; |
|
|
|
@ -293,6 +293,7 @@ export interface TimeSeriesChartYAxisSettings extends TimeSeriesChartAxisSetting |
|
|
|
min?: number | string; |
|
|
|
max?: number | string; |
|
|
|
intervalCalculator?: string; |
|
|
|
ticksFormatter?: string; |
|
|
|
} |
|
|
|
|
|
|
|
export interface TimeSeriesChartThreshold { |
|
|
|
@ -441,6 +442,7 @@ export const timeSeriesChartDefaultSettings: TimeSeriesChartSettings = { |
|
|
|
lineHeight: '1' |
|
|
|
}, |
|
|
|
tickLabelColor: timeSeriesChartColorScheme['axis.tickLabel'].light, |
|
|
|
ticksFormatter: null, |
|
|
|
showTicks: true, |
|
|
|
ticksColor: timeSeriesChartColorScheme['axis.ticks'].light, |
|
|
|
showLine: true, |
|
|
|
@ -647,6 +649,7 @@ export interface TimeSeriesChartYAxis { |
|
|
|
units: string; |
|
|
|
option: YAXisOption & ValueAxisBaseOption; |
|
|
|
intervalCalculator?: (axis: Axis2D) => number; |
|
|
|
ticksFormatter?: (value: any) => string; |
|
|
|
} |
|
|
|
|
|
|
|
export const createTimeSeriesYAxis = (axisId: string, units: string, |
|
|
|
@ -656,6 +659,10 @@ export const createTimeSeriesYAxis = (axisId: string, units: string, |
|
|
|
settings.tickLabelColor, darkMode, 'axis.tickLabel'); |
|
|
|
const yAxisNameStyle = createChartTextStyle(settings.labelFont, |
|
|
|
settings.labelColor, darkMode, 'axis.label'); |
|
|
|
let ticksFormatter: (value: any) => string; |
|
|
|
if (settings.ticksFormatter && settings.ticksFormatter.length) { |
|
|
|
ticksFormatter = parseFunction(settings.ticksFormatter, ['value']); |
|
|
|
} |
|
|
|
const yAxis: TimeSeriesChartYAxis = { |
|
|
|
id: axisId, |
|
|
|
units, |
|
|
|
@ -699,7 +706,18 @@ export const createTimeSeriesYAxis = (axisId: string, units: string, |
|
|
|
fontWeight: yAxisTickLabelStyle.fontWeight, |
|
|
|
fontFamily: yAxisTickLabelStyle.fontFamily, |
|
|
|
fontSize: yAxisTickLabelStyle.fontSize, |
|
|
|
formatter: (value: any) => formatValue(value, decimals, units, false) |
|
|
|
formatter: (value: any) => { |
|
|
|
let result: string; |
|
|
|
if (ticksFormatter) { |
|
|
|
try { |
|
|
|
result = ticksFormatter(value); |
|
|
|
} catch (_e) {} |
|
|
|
} |
|
|
|
if (isUndefined(result)) { |
|
|
|
result = formatValue(value, decimals, units, false); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
}, |
|
|
|
splitLine: { |
|
|
|
show: settings.showSplitLines, |
|
|
|
|