forked from ddrilling/asb_cloud_front
Улучшена работа контекстного меню
This commit is contained in:
parent
4ccab4dec5
commit
cd3c873368
@ -32,12 +32,15 @@ export const D3ContextMenu = memo<D3ContextMenuProps>(({
|
||||
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: (
|
||||
<a href={svgToDataURL(svg)} download={`${downloadFilename}.svg`}>Сохранить</a>
|
||||
)},
|
||||
]
|
||||
)})
|
||||
|
||||
if (additionalMenuItems)
|
||||
menuItems.push(...additionalMenuItems)
|
||||
|
@ -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 (
|
||||
<D3Chart
|
||||
xAxis={xAxis}
|
||||
domain={domain}
|
||||
datasets={chartDatasets}
|
||||
data={data}
|
||||
loading={isChartLoading}
|
||||
height={height}
|
||||
plugins={plugins}
|
||||
ticks={ticks}
|
||||
|
Loading…
Reference in New Issue
Block a user