avg line serie and mode

This commit is contained in:
2026-07-08 14:17:10 +05:00
parent 5ffe9192c1
commit 9a542ce33e
7 changed files with 113 additions and 82 deletions

View File

@@ -1,18 +1,26 @@
import { useMemo } from 'react';
import type { SeriesOption } from 'echarts';
import { createAvgLineSeries } from './historyChartAvgLineSeries';
import { createSeriesOptions } from './historyChartSeries';
import type { HistoryChartLineData } from './useHistoryChartQueries';
import type { AvgLineMode } from './chartTypes';
export function useHistoryChartSeries(
lines: HistoryChartLineData[],
granulate: string,
avgLineMode: AvgLineMode,
showAvgLine: boolean,
): SeriesOption[] {
return useMemo(
() =>
lines.flatMap((line) =>
line.rows.length ? createSeriesOptions(line.rows, line.index, line.label, granulate, showAvgLine) : [],
line.rows.length
? [
...createSeriesOptions(line.rows, line.index, line.label, granulate),
...createAvgLineSeries(line.rows, line.index, line.label, granulate, showAvgLine, avgLineMode === 'auto'),
]
: [],
),
[granulate, lines, showAvgLine],
[granulate, lines, showAvgLine, avgLineMode],
);
}