diff --git a/timeserieschart/src/TimeSeriesChartPanel.tsx b/timeserieschart/src/TimeSeriesChartPanel.tsx index e613084b..d39af4da 100644 --- a/timeserieschart/src/TimeSeriesChartPanel.tsx +++ b/timeserieschart/src/TimeSeriesChartPanel.tsx @@ -54,7 +54,6 @@ import { DEFAULT_VISUAL, THRESHOLD_PLOT_INTERVAL, QuerySettingsOptions, - LOG_BASE, } from './time-series-chart-model'; import { getTimeSeries, @@ -122,13 +121,10 @@ export function TimeSeriesChartPanel(props: TimeSeriesChartProps): ReactElement return merge({}, DEFAULT_VISUAL, props.spec.visual); }, [props.spec.visual]); - // Use the logBase from yAxis options, defaulting to 'none' if not set - const useLogarithmicBase: LOG_BASE = yAxis?.logBase; - // convert Perses dashboard format to be ECharts compatible const echartsYAxis = useMemo(() => { - return convertPanelYAxis(yAxis, useLogarithmicBase); - }, [yAxis, useLogarithmicBase]); + return convertPanelYAxis(yAxis); + }, [yAxis]); const [selectedLegendItems, setSelectedLegendItems] = useState('ALL'); const [legendSorting, setLegendSorting] = useState['sorting']>(); diff --git a/timeserieschart/src/utils/data-transform.test.ts b/timeserieschart/src/utils/data-transform.test.ts index 75eacea2..9efd0aef 100644 --- a/timeserieschart/src/utils/data-transform.test.ts +++ b/timeserieschart/src/utils/data-transform.test.ts @@ -54,7 +54,7 @@ describe('convertPanelYAxis', () => { min: 0.1, max: 1, }; - const echartsAxis = convertPanelYAxis(persesAxis, undefined); + const echartsAxis = convertPanelYAxis(persesAxis); // Axis label is handled outside of echarts since it is built with a custom React component. expect(echartsAxis).toEqual({ show: true, @@ -75,8 +75,9 @@ describe('convertPanelYAxis', () => { }, min: 0.1, max: 1, + logBase: 2, }; - const actualAxisLog2 = convertPanelYAxis(persesAxis, 2); + const actualAxisLog2 = convertPanelYAxis(persesAxis); // Axis label is handled outside of echarts since it is built with a custom React component. expect(actualAxisLog2).toEqual({ show: true, @@ -88,7 +89,8 @@ describe('convertPanelYAxis', () => { show: true, }, }); - const actualAxisLog10 = convertPanelYAxis(persesAxis, 10); + persesAxis.logBase = 10; + const actualAxisLog10 = convertPanelYAxis(persesAxis); // Axis label is handled outside of echarts since it is built with a custom React component. expect(actualAxisLog10).toEqual({ show: true, diff --git a/timeserieschart/src/utils/data-transform.ts b/timeserieschart/src/utils/data-transform.ts index b6dde148..0577e523 100644 --- a/timeserieschart/src/utils/data-transform.ts +++ b/timeserieschart/src/utils/data-transform.ts @@ -40,7 +40,6 @@ import { TimeSeriesChartVisualOptions, TimeSeriesChartYAxisOptions, LineStyleType, - LOG_BASE, } from '../time-series-chart-model'; export type RunningQueriesState = ReturnType; @@ -232,13 +231,10 @@ function findMax(data: LegacyTimeSeries[] | TimeSeries[]): number { * Converts Perses panel yAxis from dashboard spec to ECharts supported yAxis options. * Handles both linear and logarithmic scales with appropriate min/max calculations. */ -export function convertPanelYAxis( - inputAxis: TimeSeriesChartYAxisOptions = {}, - useLogarithmicBase: LOG_BASE | undefined -): YAXisComponentOption { +export function convertPanelYAxis(inputAxis: TimeSeriesChartYAxisOptions = {}): YAXisComponentOption { // Determine the appropriate min value based on scale type and user input let minValue: YAXisComponentOption['min']; - if (useLogarithmicBase !== undefined) { + if (inputAxis.logBase !== undefined) { // For logarithmic scales without explicit min: // Let ECharts auto-calculate the range based on data to avoid issues with // function-based calculations which can result in improper ranges (e.g., 1-10) @@ -277,11 +273,11 @@ export function convertPanelYAxis( }; // Apply logarithmic scale settings if requested - if (useLogarithmicBase !== undefined) { + if (inputAxis.logBase !== undefined) { return { ...yAxis, type: 'log', - logBase: useLogarithmicBase, + logBase: inputAxis.logBase, }; }