diff --git a/src/pages/Telemetry/Operations/OperationsChart.jsx b/src/pages/Telemetry/Operations/OperationsChart.jsx
index a0e7e82..3a20be2 100644
--- a/src/pages/Telemetry/Operations/OperationsChart.jsx
+++ b/src/pages/Telemetry/Operations/OperationsChart.jsx
@@ -8,7 +8,7 @@ import '@styles/detected_operations.less'
const displayNumber = makeDisplayValue({ fixed: 2 })
-const makeTooltipRender = (category) => ([{ data: [data] }]) => (
+export const makeTooltipRender = (category) => ([{ data: [data] }]) => (
{data.operationCategory?.name}
{formatDate(data.dateStart, undefined, 'DD.MM.YYYY')}
@@ -21,12 +21,12 @@ const makeTooltipRender = (category) => ([{ data: [data] }]) => (
{displayNumber(data.depthEnd)} м
- {category?.name ?? 'Ключ'}:
+ {category?.keyValueName ?? 'Ключ'}:
{displayNumber(data.value)}
- {category?.unit ?? '----'}
+ {category?.keyValueUnits ?? '----'}
Цель:
{displayNumber(data.operationValue?.targetValue)}
- {category?.unit ?? '----'}
+ {category?.keyValueUnits ?? '----'}
)
diff --git a/src/pages/Telemetry/Operations/index.jsx b/src/pages/Telemetry/Operations/index.jsx
index 8306be8..b04f835 100644
--- a/src/pages/Telemetry/Operations/index.jsx
+++ b/src/pages/Telemetry/Operations/index.jsx
@@ -70,7 +70,11 @@ const Operations = memo(() => {
invokeWebApiWrapperAsync(
async () => {
const categories = arrayOrDefault(await DetectedOperationService.getCategories())
- setCategories(categories.map(({ id, name }) => ({ value: id, label: name })))
+ setCategories(categories.map((category) => ({
+ ...category,
+ value: category.id,
+ label: category.name,
+ })))
},
setIsLoading,
'Не удалось загрзуить категории операций'
diff --git a/src/pages/WellOperations/Tvd/TLChart.jsx b/src/pages/WellOperations/Tvd/TLChart.jsx
index 7050c87..84b431d 100644
--- a/src/pages/WellOperations/Tvd/TLChart.jsx
+++ b/src/pages/WellOperations/Tvd/TLChart.jsx
@@ -11,8 +11,13 @@ import { DetectedOperationService } from '@api'
import { unique } from '@utils/filters'
import { formatDate } from '@utils'
+import { makeTooltipRender } from '@pages/Telemetry/Operations/OperationsChart'
import { makeGetColor } from '.'
+import '@styles/d3.less'
+import '@styles/tvd.less'
+import '@styles/detected_operations.less'
+
const defaultOffset = { left: 40, right: 20, top: 20, bottom: 20 }
const zeroDate = moment('2000-01-01 00:00:00')
@@ -42,10 +47,13 @@ export const TLChart = memo(({
backgroundColor = '#0000',
barHeight = 15,
offset = defaultOffset,
+ tooltipSize = { width: 200, height: 220 },
}) => {
const [isLoading, setIsLoading] = useState(false)
const [svgRef, setSvgRef] = useState()
const [data, setData] = useState()
+ const [selected, setSelected] = useState()
+ const [tooltipPos, setTooltipPos] = useState({ x: 0, y: 0 })
const getColor = useMemo(() => makeGetColor(data?.map((row) => row.idCategory).filter(unique)), [data])
@@ -124,22 +132,54 @@ export const TLChart = memo(({
.attr('width', (d) => xAxis(d.endTime) - xAxis(d.startTime))
.attr('height', barHeight)
.attr('fill', (d) => getColor(d.idCategory))
+ .on('mouseover', (e, data) => {
+ d3.select(svgRef).select('.chart-area')
+ .selectAll('rect')
+ .filter((d) => d.idCategory === data.idCategory)
+ .attr('stroke-width', '2px')
+ const rect = e.target.getBoundingClientRect()
+ setTooltipPos({ x: rect.x, y: rect.y })
+ setSelected(data)
+ })
+ .on('mouseout', (e, data) => {
+ d3.select(svgRef).select('.chart-area')
+ .selectAll('rect')
+ .filter((d) => d.idCategory === data.idCategory)
+ .attr('stroke-width', '0')
+ setSelected(null)
+ })
}, [svgRef, xAxis, yAxis, data, getColor])
+ const tooltipStyle = useMemo(() => {
+ return {
+ ...tooltipSize,
+ left: tooltipPos.x - tooltipSize.width - 8,
+ top: tooltipPos.y - tooltipSize.height / 2 + barHeight / 2,
+ }
+ }, [tooltipPos, tooltipSize, barHeight])
+
return (
-
+
+ {selected && (
+
+
+ {makeTooltipRender(selected.operationCategory)([{ data: [selected] }])}
+
+
+ )}
{data ? (
-