2 Commits

3 changed files with 39 additions and 2 deletions

View File

@@ -18,6 +18,10 @@ type HistoryChartProps = {
}; };
/** Контейнер истории: загружает выбранные теги и передает готовые серии в область ECharts. */ /** Контейнер истории: загружает выбранные теги и передает готовые серии в область ECharts. */
function isXAxisDataZoom(state: DataZoomState): boolean {
return state.dataZoomId?.startsWith('history-x-') || state.dataZoomIndex === 0 || state.dataZoomIndex === 1;
}
export function HistoryChart({ export function HistoryChart({
edge, edge,
from, from,
@@ -49,7 +53,12 @@ export function HistoryChart({
); );
const handleDataZoom = useCallback((event: DataZoomEventBatch) => { const handleDataZoom = useCallback((event: DataZoomEventBatch) => {
const state = event.batch?.[0] ?? event; const state = (event.batch ?? [event]).find(isXAxisDataZoom);
if (!state) {
return;
}
dataZoomRef.current = { dataZoomRef.current = {
start: state.start, start: state.start,
end: state.end, end: state.end,

View File

@@ -8,6 +8,8 @@ export type TooltipParam = {
}; };
export type DataZoomState = { export type DataZoomState = {
dataZoomId?: string;
dataZoomIndex?: number;
start?: number; start?: number;
end?: number; end?: number;
startValue?: number; startValue?: number;

View File

@@ -54,7 +54,7 @@ export function createHistoryChartOptions({
grid: { grid: {
top: 54, top: 54,
left: 48, left: 48,
right: 24, right: 56,
bottom: 72, bottom: 72,
}, },
xAxis: { xAxis: {
@@ -79,7 +79,9 @@ export function createHistoryChartOptions({
}, },
dataZoom: [ dataZoom: [
{ {
id: 'history-x-inside',
type: 'inside', type: 'inside',
xAxisIndex: 0,
throttle: 80, throttle: 80,
start: dataZoomState.start, start: dataZoomState.start,
end: dataZoomState.end, end: dataZoomState.end,
@@ -87,7 +89,9 @@ export function createHistoryChartOptions({
endValue: dataZoomState.endValue, endValue: dataZoomState.endValue,
}, },
{ {
id: 'history-x-slider',
type: 'slider', type: 'slider',
xAxisIndex: 0,
bottom: 18, bottom: 18,
height: 28, height: 28,
borderColor: 'rgba(148, 163, 184, 0.24)', borderColor: 'rgba(148, 163, 184, 0.24)',
@@ -102,6 +106,28 @@ export function createHistoryChartOptions({
startValue: dataZoomState.startValue, startValue: dataZoomState.startValue,
endValue: dataZoomState.endValue, endValue: dataZoomState.endValue,
}, },
{
id: 'history-y-inside',
type: 'inside',
yAxisIndex: 0,
filterMode: 'none',
throttle: 80,
},
{
id: 'history-y-slider',
type: 'slider',
yAxisIndex: 0,
filterMode: 'none',
right: 8,
width: 12,
borderColor: 'rgba(148, 163, 184, 0.24)',
fillerColor: 'rgba(91, 143, 249, 0.18)',
handleStyle: {
color: '#d4a574',
borderColor: '#e8c9a0',
},
textStyle: { color: '#94a3b8' },
},
], ],
series, series,
}; };