Compare commits
6 Commits
bur-67
...
smooth_lin
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d0408c533 | |||
| 1127b14946 | |||
| 9a542ce33e | |||
| 5ffe9192c1 | |||
| 88d628b696 | |||
| 1632bfb3d8 |
@@ -1,5 +1,6 @@
|
||||
branch=
|
||||
DEV_API_URL=http://localhost:3101
|
||||
BRANCH=
|
||||
#DEV_API_URL=http://localhost:3101
|
||||
DEV_API_URL=https://beta.drill.greact.ru
|
||||
VITE_DIAGRAM_API_URL=http://localhost:3002
|
||||
VITE_TOIR_LIGHT_ORIGIN=https://toir-light.greact.ru
|
||||
VITE_KEYCLOAK_URL=https://sso.greact.ru
|
||||
|
||||
@@ -4,6 +4,8 @@ import { useRef } from 'react';
|
||||
import { CalendarDays, CalendarClock, Check, ChevronDown, Clock3, DatabaseZap, Search } from 'lucide-react';
|
||||
import type { CurrentItem } from '../../../entities/current/types';
|
||||
import { HistoryChart } from '../../../features/history-chart/HistoryChart';
|
||||
import { HistoryChartAvgLineModeControl } from '../../../features/history-chart/HistoryChartAvgLineModeControl';
|
||||
import type { AvgLineMode } from '../../../features/history-chart/chartTypes';
|
||||
import { RANGE_PRESETS, createRange, type DateRangeState } from '../../../features/history/dateRange';
|
||||
import { formatNumber, toIsoFromInput } from '../../../utils/format';
|
||||
import type { HistoryGranularity } from '../../../utils/historyGranularity';
|
||||
@@ -93,6 +95,8 @@ export function ArchiveView({
|
||||
onSelectVisibleTags,
|
||||
onToggleTag,
|
||||
}: ArchiveViewProps) {
|
||||
const [avgLineMode, setAvgLineMode] = useState<AvgLineMode>('auto');
|
||||
const [selectedRangePresetId, setSelectedRangePresetId] = useState<string>('24h');
|
||||
const [selectorOpen, setSelectorOpen] = useState(false);
|
||||
const selectedPreview = selectedTags.slice(0, 10);
|
||||
const hiddenSelectedCount = Math.max(0, selectedTags.length - selectedPreview.length);
|
||||
@@ -103,6 +107,7 @@ export function ArchiveView({
|
||||
const fromIso = toIsoFromInput(range.from) as string;
|
||||
const toIso = toIsoFromInput(range.to) as string;
|
||||
const updateRangePart = (rangePart: RangePart, inputPart: RangeInputPart, value: string) => {
|
||||
setSelectedRangePresetId('');
|
||||
onRangeChange({
|
||||
...range,
|
||||
[rangePart]: updateRangeInputPart(range[rangePart], inputPart, value),
|
||||
@@ -149,14 +154,14 @@ export function ArchiveView({
|
||||
<input value={search} onChange={(event) => onSearchChange(event.target.value)} placeholder="Поиск" />
|
||||
</label>
|
||||
<div className="tag-selector__tools">
|
||||
<button type="button" onClick={onSelectFirstTags}>
|
||||
{/* <button type="button" onClick={onSelectFirstTags}>
|
||||
Первый
|
||||
</button>
|
||||
</button> */}
|
||||
<button type="button" onClick={onSelectVisibleTags}>
|
||||
Выбрать найденный
|
||||
Выбрать все
|
||||
</button>
|
||||
<button type="button" onClick={onClearVisibleTags}>
|
||||
Снять найденные
|
||||
Снять все
|
||||
</button>
|
||||
<button type="button" onClick={onClearTags}>
|
||||
Сбросить все
|
||||
@@ -209,12 +214,22 @@ export function ArchiveView({
|
||||
onPointerEnter={() => setSelectorOpen(false)}
|
||||
>
|
||||
<div className="toolbar">
|
||||
<div className="segmented">
|
||||
{RANGE_PRESETS.map((preset) => (
|
||||
<button key={preset.id} type="button" onClick={() => onRangeChange(createRange(preset.hours))}>
|
||||
{preset.label}
|
||||
</button>
|
||||
))}
|
||||
<div className="archive-toolbar-segmented-control">
|
||||
<div className="segmented segmented--range-preset">
|
||||
{RANGE_PRESETS.map((preset) => (
|
||||
<button
|
||||
key={preset.id}
|
||||
type="button"
|
||||
className={preset.id === selectedRangePresetId ? 'segmented__button--active' : undefined}
|
||||
onClick={() => {
|
||||
setSelectedRangePresetId(preset.id);
|
||||
onRangeChange(createRange(preset.hours));
|
||||
}}
|
||||
>
|
||||
{preset.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="archive-date-range">
|
||||
<span>С</span>
|
||||
@@ -250,11 +265,13 @@ export function ArchiveView({
|
||||
onChange={(value) => updateRangePart('to', 'time', value)}
|
||||
/>
|
||||
</div>
|
||||
<HistoryChartAvgLineModeControl value={avgLineMode} onChange={setAvgLineMode} />
|
||||
</div>
|
||||
|
||||
{selectedTags.length ? (
|
||||
<HistoryChart
|
||||
key={`${range.from}:${range.to}:${historyAxis.granulate}`}
|
||||
key={`${range.from}:${range.to}:${historyAxis.granulate}:${historyAxis.tickIntervalMs ?? ''}`}
|
||||
avgLineMode={avgLineMode}
|
||||
edge={edgeId}
|
||||
from={fromIso}
|
||||
to={toIso}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { useHistoryChartQueries } from './useHistoryChartQueries';
|
||||
import { useHistoryChartSeries } from './useHistoryChartSeries';
|
||||
|
||||
type HistoryChartProps = {
|
||||
avgLineMode: AvgLineMode;
|
||||
edge: string;
|
||||
from: string;
|
||||
granulate: string;
|
||||
@@ -42,6 +43,7 @@ function shouldShowAvgLine(mode: AvgLineMode, range: HistoryZoomRange): boolean
|
||||
}
|
||||
|
||||
export function HistoryChart({
|
||||
avgLineMode,
|
||||
edge,
|
||||
from,
|
||||
granulate,
|
||||
@@ -62,7 +64,6 @@ export function HistoryChart({
|
||||
const zoomRangeRef = useRef(zoomRange);
|
||||
const zoomTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
const lastReadyOptionRef = useRef<EChartsOption | null>(null);
|
||||
const [avgLineMode, setAvgLineMode] = useState<AvgLineMode>('auto');
|
||||
const lines = useHistoryChartQueries({
|
||||
edge,
|
||||
from: zoomRange.from,
|
||||
@@ -72,7 +73,7 @@ export function HistoryChart({
|
||||
tagLabels,
|
||||
});
|
||||
const showAvgLine = shouldShowAvgLine(avgLineMode, zoomRange);
|
||||
const series = useHistoryChartSeries(lines, zoomRange.granulate, showAvgLine);
|
||||
const series = useHistoryChartSeries(lines, zoomRange.granulate, avgLineMode, showAvgLine);
|
||||
const legendData = useMemo(() => lines.map((line) => line.label), [lines]);
|
||||
const loading = lines.some((line) => line.loading);
|
||||
const hasData = series.length > 0;
|
||||
@@ -149,13 +150,12 @@ export function HistoryChart({
|
||||
|
||||
return (
|
||||
<HistoryChartArea
|
||||
avgLineMode={avgLineMode}
|
||||
hasData={displayHasData}
|
||||
hasSelection={tags.length > 0}
|
||||
loading={loading}
|
||||
avgLineMode={avgLineMode}
|
||||
option={displayOption}
|
||||
onDataZoom={handleDataZoom}
|
||||
onAvgLineModeChange={setAvgLineMode}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ import type { EChartsOption } from 'echarts';
|
||||
import ReactEChartsCore from 'echarts-for-react/esm/core.js';
|
||||
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
||||
import type { WheelEvent } from 'react';
|
||||
import type { AvgLineMode, DataZoomEventBatch } from './chartTypes';
|
||||
import type { DataZoomEventBatch } from './chartTypes';
|
||||
import { echarts } from './historyChartEcharts';
|
||||
import type { AvgLineMode } from './chartTypes';
|
||||
|
||||
type HistoryChartAreaProps = {
|
||||
avgLineMode: AvgLineMode;
|
||||
@@ -11,17 +12,9 @@ type HistoryChartAreaProps = {
|
||||
hasSelection: boolean;
|
||||
loading: boolean;
|
||||
option: EChartsOption;
|
||||
onAvgLineModeChange: (mode: AvgLineMode) => void;
|
||||
onDataZoom: (event: DataZoomEventBatch) => void;
|
||||
};
|
||||
|
||||
// Порядок режимов соответствует требованию: авто, принудительно рисовать, принудительно скрыть.
|
||||
const AVG_LINE_MODES: Array<{ value: AvgLineMode; label: string }> = [
|
||||
{ value: 'auto', label: 'Авто' },
|
||||
{ value: 'show', label: 'Рисовать' },
|
||||
{ value: 'hide', label: 'Не рисовать' },
|
||||
];
|
||||
|
||||
/** Включает или выключает нативный X-зум колесом, чтобы Shift + колесо работал только по Y. */
|
||||
function setXAxisWheelZoom(chart: ReturnType<ReactEChartsCore['getEchartsInstance']>, enabled: boolean): void {
|
||||
chart.setOption(
|
||||
@@ -44,7 +37,6 @@ export function HistoryChartArea({
|
||||
hasSelection,
|
||||
loading,
|
||||
option,
|
||||
onAvgLineModeChange,
|
||||
onDataZoom,
|
||||
}: HistoryChartAreaProps) {
|
||||
const chartRef = useRef<InstanceType<typeof ReactEChartsCore> | null>(null);
|
||||
@@ -111,23 +103,8 @@ export function HistoryChartArea({
|
||||
|
||||
return (
|
||||
<div className="history-chart-shell" onWheelCapture={handleWheelCapture}>
|
||||
<div className="history-chart-controls" aria-label="Режим соединительной линии avg">
|
||||
<span>Линия avg</span>
|
||||
<div className="segmented history-chart-line-mode">
|
||||
{AVG_LINE_MODES.map((mode) => (
|
||||
<button
|
||||
key={mode.value}
|
||||
type="button"
|
||||
className={mode.value === avgLineMode ? 'history-chart-line-mode__button--active' : undefined}
|
||||
onClick={() => onAvgLineModeChange(mode.value)}
|
||||
aria-pressed={mode.value === avgLineMode}
|
||||
>
|
||||
{mode.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<ReactEChartsCore
|
||||
key={avgLineMode}
|
||||
ref={chartRef}
|
||||
echarts={echarts}
|
||||
option={option}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { AvgLineMode } from './chartTypes';
|
||||
|
||||
type HistoryChartAvgLineModeControlProps = {
|
||||
value: AvgLineMode;
|
||||
onChange: (mode: AvgLineMode) => void;
|
||||
};
|
||||
|
||||
const AVG_LINE_MODES: Array<{ value: AvgLineMode; label: string }> = [
|
||||
{ value: 'auto', label: 'Авто' },
|
||||
{ value: 'show', label: 'Рисовать' },
|
||||
{ value: 'hide', label: 'Скрывать' },
|
||||
];
|
||||
|
||||
export function HistoryChartAvgLineModeControl({ value, onChange }: HistoryChartAvgLineModeControlProps) {
|
||||
return (
|
||||
<div className="archive-toolbar-segmented-control archive-avgline-mode-control" aria-label="Режим соединительной линии avg">
|
||||
<span>Соединительная линия</span>
|
||||
<div className="segmented history-chart-line-mode">
|
||||
{AVG_LINE_MODES.map((mode) => (
|
||||
<button
|
||||
key={mode.value}
|
||||
type="button"
|
||||
className={mode.value === value ? 'segmented__button--active' : undefined}
|
||||
onClick={() => onChange(mode.value)}
|
||||
aria-pressed={mode.value === value}
|
||||
>
|
||||
{mode.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -9,8 +9,6 @@ export type HistoryBucketValue = [
|
||||
max: number,
|
||||
count: number,
|
||||
slotMs: number,
|
||||
previousTime: number | null,
|
||||
previousAvg: number | null,
|
||||
];
|
||||
|
||||
export type AvgLineMode = 'auto' | 'show' | 'hide';
|
||||
|
||||
92
src/features/history-chart/historyChartAvgLineSeries.ts
Normal file
92
src/features/history-chart/historyChartAvgLineSeries.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import type { LineSeriesOption, SeriesOption } from 'echarts';
|
||||
import type { HistoryPoint } from '../../entities/history/types';
|
||||
import { parseGranulateMs } from '../../utils/historyGranularity';
|
||||
import { SERIES_COLORS } from './historyChartSeries';
|
||||
|
||||
type AvgLineSeriesValue = [time: number, avg: number, min: number, max: number, count: number, slotMs: number];
|
||||
type AvgLineSeriesPoint = AvgLineSeriesValue | null;
|
||||
|
||||
function isFinitePoint(point: HistoryPoint): boolean {
|
||||
return [point.avg_value, point.min_value, point.max_value].every(Number.isFinite);
|
||||
}
|
||||
|
||||
function createAvgLineData(points: HistoryPoint[], granulate: string, breakOnGaps: boolean): AvgLineSeriesPoint[] {
|
||||
const slotMs = parseGranulateMs(granulate);
|
||||
const finitePoints = points.filter(isFinitePoint);
|
||||
|
||||
if (!breakOnGaps) {
|
||||
return finitePoints.map((point) => [
|
||||
new Date(point.time).getTime(),
|
||||
point.avg_value,
|
||||
point.min_value,
|
||||
point.max_value,
|
||||
point.point_count,
|
||||
slotMs,
|
||||
]);
|
||||
}
|
||||
|
||||
return finitePoints.flatMap((point, index) => {
|
||||
const currentTime = new Date(point.time).getTime();
|
||||
const currentPoint: AvgLineSeriesValue = [
|
||||
currentTime,
|
||||
point.avg_value,
|
||||
point.min_value,
|
||||
point.max_value,
|
||||
point.point_count,
|
||||
slotMs,
|
||||
];
|
||||
|
||||
if (index === 0) {
|
||||
return [currentPoint];
|
||||
}
|
||||
|
||||
const previousTime = new Date(finitePoints[index - 1].time).getTime();
|
||||
const hasAcceptableGap = currentTime - previousTime <= slotMs * 24;
|
||||
|
||||
return hasAcceptableGap ? [currentPoint] : [null, currentPoint];
|
||||
});
|
||||
}
|
||||
|
||||
export function createAvgLineSeries(
|
||||
points: HistoryPoint[],
|
||||
index: number,
|
||||
label: string,
|
||||
granulate: string,
|
||||
showAvgLine: boolean,
|
||||
breakOnGaps: boolean,
|
||||
): SeriesOption[] {
|
||||
if (!showAvgLine) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const color = SERIES_COLORS[index % SERIES_COLORS.length];
|
||||
|
||||
return [
|
||||
{
|
||||
name: `${label} avg-line`,
|
||||
type: 'line',
|
||||
data: createAvgLineData(points, granulate, breakOnGaps),
|
||||
encode: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
},
|
||||
smooth: true,
|
||||
connectNulls: false,
|
||||
showSymbol: false,
|
||||
symbol: 'none',
|
||||
silent: true,
|
||||
tooltip: {
|
||||
show: false,
|
||||
},
|
||||
lineStyle: {
|
||||
color,
|
||||
width: 1.5,
|
||||
opacity: 0.78,
|
||||
},
|
||||
emphasis: {
|
||||
disabled: true,
|
||||
},
|
||||
z: 4,
|
||||
} as LineSeriesOption,
|
||||
];
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CustomChart } from 'echarts/charts';
|
||||
import { CustomChart, LineChart } from 'echarts/charts';
|
||||
import {
|
||||
DataZoomComponent,
|
||||
GridComponent,
|
||||
@@ -10,6 +10,7 @@ import { CanvasRenderer } from 'echarts/renderers';
|
||||
|
||||
echarts.use([
|
||||
CustomChart,
|
||||
LineChart,
|
||||
GridComponent,
|
||||
LegendComponent,
|
||||
TooltipComponent,
|
||||
|
||||
@@ -27,8 +27,6 @@ const BUCKET = {
|
||||
max: 3,
|
||||
count: 4,
|
||||
slotMs: 5,
|
||||
previousTime: 6,
|
||||
previousAvg: 7,
|
||||
} as const;
|
||||
|
||||
type CartesianCoordSys = {
|
||||
@@ -46,10 +44,6 @@ type BucketValues = {
|
||||
min: number;
|
||||
max: number;
|
||||
slotMs: number;
|
||||
previousTime: number;
|
||||
previousAvg: number;
|
||||
previousTimeValue: unknown;
|
||||
previousAvgValue: unknown;
|
||||
};
|
||||
|
||||
/** Ограничивает число заданными границами, чтобы фигуры не выходили за canvas графика. */
|
||||
@@ -75,56 +69,31 @@ function isFinitePoint(point: HistoryPoint): boolean {
|
||||
return [point.avg_value, point.min_value, point.max_value].every(Number.isFinite);
|
||||
}
|
||||
|
||||
/** Упаковывает bucket и предыдущую avg-точку в tuple для custom series ECharts. */
|
||||
/** Упаковывает bucket в tuple для custom series ECharts. */
|
||||
function createBucketData(points: HistoryPoint[], slotMs: number): HistoryBucketValue[] {
|
||||
const finitePoints = points.filter(isFinitePoint);
|
||||
|
||||
return finitePoints.map((point, index) => {
|
||||
const previousPoint = finitePoints[index - 1];
|
||||
|
||||
return [
|
||||
return finitePoints.map((point) => [
|
||||
new Date(point.time).getTime(),
|
||||
point.avg_value,
|
||||
point.min_value,
|
||||
point.max_value,
|
||||
point.point_count,
|
||||
slotMs,
|
||||
previousPoint ? new Date(previousPoint.time).getTime() : null,
|
||||
previousPoint?.avg_value ?? null,
|
||||
];
|
||||
});
|
||||
]);
|
||||
}
|
||||
|
||||
/** Читает tuple bucket-а из ECharts API и возвращает значения с понятными именами. */
|
||||
function readBucketValues(api: CustomSeriesRenderItemAPI): BucketValues {
|
||||
const previousTimeValue = api.value(BUCKET.previousTime);
|
||||
const previousAvgValue = api.value(BUCKET.previousAvg);
|
||||
|
||||
return {
|
||||
time: Number(api.value(BUCKET.time)),
|
||||
avg: Number(api.value(BUCKET.avg)),
|
||||
min: Number(api.value(BUCKET.min)),
|
||||
max: Number(api.value(BUCKET.max)),
|
||||
slotMs: Number(api.value(BUCKET.slotMs)),
|
||||
previousTime: Number(previousTimeValue),
|
||||
previousAvg: Number(previousAvgValue),
|
||||
previousTimeValue,
|
||||
previousAvgValue,
|
||||
};
|
||||
}
|
||||
|
||||
/** Проверяет, можно ли рисовать соединительный отрезок к предыдущей avg-точке. */
|
||||
function hasPreviousAvg(values: BucketValues): boolean {
|
||||
return (
|
||||
values.previousTimeValue !== null &&
|
||||
values.previousTimeValue !== undefined &&
|
||||
values.previousAvgValue !== null &&
|
||||
values.previousAvgValue !== undefined &&
|
||||
Number.isFinite(values.previousTime) &&
|
||||
Number.isFinite(values.previousAvg)
|
||||
);
|
||||
}
|
||||
|
||||
/** Считает пиксельные фигуры одного bucket-а и обрезает их по области графика. */
|
||||
function createBucketShapes(api: CustomSeriesRenderItemAPI, values: BucketValues, chartArea: ChartArea) {
|
||||
const avgPoint = api.coord([values.time, values.avg]);
|
||||
@@ -155,30 +124,8 @@ function createBucketShapes(api: CustomSeriesRenderItemAPI, values: BucketValues
|
||||
};
|
||||
}
|
||||
|
||||
/** Создает отрезок к предыдущей avg-точке, если режим соединительной линии включен. */
|
||||
function createAvgLineShape(
|
||||
api: CustomSeriesRenderItemAPI,
|
||||
values: BucketValues,
|
||||
avgPoint: number[],
|
||||
avgY: number,
|
||||
chartArea: ChartArea,
|
||||
) {
|
||||
if (!hasPreviousAvg(values)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const previousPoint = api.coord([values.previousTime, values.previousAvg]);
|
||||
|
||||
return {
|
||||
x1: clamp(previousPoint[0], chartArea.x, chartArea.x + chartArea.width),
|
||||
y1: clamp(previousPoint[1], chartArea.y, chartArea.y + chartArea.height),
|
||||
x2: clamp(avgPoint[0], chartArea.x, chartArea.x + chartArea.width),
|
||||
y2: clamp(avgY, chartArea.y, chartArea.y + chartArea.height),
|
||||
};
|
||||
}
|
||||
|
||||
/** Рисует один bucket: min..max слот, avg-маркер и опциональный отрезок к предыдущей avg-точке. */
|
||||
function renderBucket(color: string, showAvgLine: boolean) {
|
||||
/** Рисует один bucket: min..max слот и горизонтальный avg-маркер. */
|
||||
function renderBucket(color: string) {
|
||||
return (params: CustomSeriesRenderItemParams, api: CustomSeriesRenderItemAPI): CustomSeriesRenderItemReturn => {
|
||||
const values = readBucketValues(api);
|
||||
|
||||
@@ -190,10 +137,6 @@ function renderBucket(color: string, showAvgLine: boolean) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Avg-линия рисуется внутри той же custom-серии, чтобы не удваивать число ECharts-серий при зуме.
|
||||
const lineShape = showAvgLine
|
||||
? createAvgLineShape(api, values, bucketShapes.avgPoint, bucketShapes.avgY, chartArea)
|
||||
: null;
|
||||
const avgOffset = clamp(
|
||||
(bucketShapes.avgY - bucketShapes.rangeShape.y) / bucketShapes.rangeShape.height,
|
||||
0,
|
||||
@@ -210,17 +153,6 @@ function renderBucket(color: string, showAvgLine: boolean) {
|
||||
fill: new graphic.LinearGradient(0, 0, 0, 1, createAvgGradientStops(color, avgOffset)),
|
||||
},
|
||||
},
|
||||
...(lineShape
|
||||
? [{
|
||||
type: 'line' as const,
|
||||
shape: lineShape,
|
||||
style: {
|
||||
stroke: color,
|
||||
lineWidth: 1,
|
||||
opacity: 0.72,
|
||||
},
|
||||
}]
|
||||
: []),
|
||||
...(bucketShapes.avgShape
|
||||
? [{
|
||||
type: 'rect' as const,
|
||||
@@ -235,13 +167,12 @@ function renderBucket(color: string, showAvgLine: boolean) {
|
||||
};
|
||||
}
|
||||
|
||||
/** Создает одну custom-серию на тег: bucket-слоты и avg-линия живут в одном renderItem. */
|
||||
/** Создает bucket-серию на тег: min..max слот и горизонтальный avg-маркер. */
|
||||
export function createSeriesOptions(
|
||||
points: HistoryPoint[],
|
||||
index: number,
|
||||
label: string,
|
||||
granulate: string,
|
||||
showAvgLine: boolean,
|
||||
): SeriesOption[] {
|
||||
const color = SERIES_COLORS[index % SERIES_COLORS.length];
|
||||
|
||||
@@ -250,7 +181,7 @@ export function createSeriesOptions(
|
||||
name: label,
|
||||
type: 'custom',
|
||||
data: createBucketData(points, parseGranulateMs(granulate)),
|
||||
renderItem: renderBucket(color, showAvgLine),
|
||||
renderItem: renderBucket(color),
|
||||
encode: {
|
||||
x: BUCKET.time,
|
||||
y: [BUCKET.avg, BUCKET.min, BUCKET.max],
|
||||
|
||||
@@ -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],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,16 +28,36 @@
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.history-chart-line-mode button {
|
||||
min-height: 24px;
|
||||
padding: 0 8px;
|
||||
font-size: 12px;
|
||||
.archive-avgline-mode-control .history-chart-line-mode button {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.history-chart-line-mode__button--active {
|
||||
color: #f8fafc;
|
||||
background: rgba(212, 165, 116, 0.16);
|
||||
border-color: rgba(212, 165, 116, 0.38);
|
||||
.archive-avgline-mode-control .history-chart-line-mode button:first-child {
|
||||
border-top-left-radius: var(--radius);
|
||||
border-bottom-left-radius: var(--radius);
|
||||
}
|
||||
|
||||
.archive-avgline-mode-control .history-chart-line-mode button:last-child {
|
||||
border-top-right-radius: var(--radius);
|
||||
border-bottom-right-radius: var(--radius);
|
||||
}
|
||||
|
||||
.segmented--range-preset button {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.segmented--range-preset button:first-child {
|
||||
border-top-left-radius: var(--radius);
|
||||
border-bottom-left-radius: var(--radius);
|
||||
}
|
||||
|
||||
.segmented--range-preset button:last-child {
|
||||
border-top-right-radius: var(--radius);
|
||||
border-bottom-right-radius: var(--radius);
|
||||
}
|
||||
|
||||
.history-chart-line-mode button {
|
||||
font-size: inherit;
|
||||
}
|
||||
|
||||
.chart-section--archive .history-chart-shell,
|
||||
|
||||
@@ -73,6 +73,12 @@
|
||||
background: rgba(201, 122, 61, 0.18);
|
||||
}
|
||||
|
||||
.segmented__button--active {
|
||||
border-color: rgba(212, 165, 116, 0.34);
|
||||
background: rgba(201, 122, 61, 0.14);
|
||||
color: #f8fafc;
|
||||
}
|
||||
|
||||
.source-chip,
|
||||
.status-pill,
|
||||
.metric-card__state {
|
||||
|
||||
@@ -216,6 +216,14 @@
|
||||
font-size: 0.84rem;
|
||||
}
|
||||
|
||||
.archive-toolbar-segmented-control {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: var(--muted);
|
||||
font-size: 0.84rem;
|
||||
}
|
||||
|
||||
.archive-date-input {
|
||||
color-scheme: dark;
|
||||
min-height: 36px;
|
||||
|
||||
@@ -15,7 +15,6 @@ export default defineConfig(({ mode }) => {
|
||||
'/api': {
|
||||
target: DEV_API_URL,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user