From cd3c8733682f68ee0232fed09a2853e8bb12052d Mon Sep 17 00:00:00 2001 From: goodmice Date: Thu, 30 Jun 2022 11:32:19 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=BD=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/d3/plugins/D3ContextMenu.tsx | 13 ++++--- .../Telemetry/Operations/OperationsChart.jsx | 38 +++++++------------ 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/src/components/d3/plugins/D3ContextMenu.tsx b/src/components/d3/plugins/D3ContextMenu.tsx index d344420..293b0fd 100644 --- a/src/components/d3/plugins/D3ContextMenu.tsx +++ b/src/components/d3/plugins/D3ContextMenu.tsx @@ -32,12 +32,15 @@ export const D3ContextMenu = memo(({ const overlay = useFunctionalValue(_overlay) const menuItems = useMemo(() => { - const menuItems: ItemType[] = [ - { key: 'refresh', label: 'Обновить', onClick: onUpdate }, - { key: 'download', label: svg && ( + const menuItems: ItemType[] = [] + + if (onUpdate) + menuItems.push({ key: 'refresh', label: 'Обновить', onClick: onUpdate }) + + if (svg) + menuItems.push({ key: 'download', label: ( Сохранить - )}, - ] + )}) if (additionalMenuItems) menuItems.push(...additionalMenuItems) diff --git a/src/pages/Telemetry/Operations/OperationsChart.jsx b/src/pages/Telemetry/Operations/OperationsChart.jsx index 6d6b655..ed11537 100644 --- a/src/pages/Telemetry/Operations/OperationsChart.jsx +++ b/src/pages/Telemetry/Operations/OperationsChart.jsx @@ -1,4 +1,4 @@ -import { memo, useCallback, useMemo, useState } from 'react' +import { memo, useMemo } from 'react' import { D3Chart } from '@components/d3' import { formatDate } from '@utils' @@ -71,42 +71,30 @@ const ticks = { y: { visible: true }, } -export const OperationsChart = memo(({ data, yDomain, height }) => { - const [isChartLoading, setIsChartLoading] = useState(false) +const plugins = { + tooltip: { + enabled: true, + type: 'nearest', + height: 150, + limit: 4, + }, + cursor: { + enabled: true, + } +} +export const OperationsChart = memo(({ data, yDomain, height, onDomainChanged }) => { const domain = useMemo(() => ({ y: { min: 0, max: yDomain }, // x: { min: new Date('2021-11-04 03:57'), max: new Date('2022-06-17 13:16') } }), [yDomain]) - const onChartUpdate = useCallback(() => { - setIsChartLoading(true) - setTimeout(() => setIsChartLoading(false), 2000) - }, []) - - const plugins = useMemo(() => ({ - tooltip: { - enabled: true, - type: 'nearest', - height: 150, - limit: 4, - }, - cursor: { - enabled: true, - }, - menu: { - enabled: false, - onUpdate: onChartUpdate, - } - }), [onChartUpdate]) - return (