15 lines
512 B
TypeScript
15 lines
512 B
TypeScript
import { useMemo } from 'react';
|
|
import type { SeriesOption } from 'echarts';
|
|
import { createSeriesOptions } from './historyChartSeries';
|
|
import type { HistoryChartLineData } from './useHistoryChartQueries';
|
|
|
|
export function useHistoryChartSeries(lines: HistoryChartLineData[], granulate: string): SeriesOption[] {
|
|
return useMemo(
|
|
() =>
|
|
lines.flatMap((line) =>
|
|
line.rows.length ? createSeriesOptions(line.rows, line.index, line.label, granulate) : [],
|
|
),
|
|
[granulate, lines],
|
|
);
|
|
}
|