From 1240c15401ef7fd7ce226840b22cb519ee12ce81 Mon Sep 17 00:00:00 2001 From: ts_salikhov Date: Wed, 17 Aug 2022 15:28:07 +0400 Subject: [PATCH 01/96] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=B2=D1=8B=D1=81=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BA=D1=83=D1=80=D1=81=D0=BE=D1=80=D0=B0=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=BE=D0=B2=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=BD=D0=B8=D1=82=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=D0=B0=20?= =?UTF-8?q?=D0=B8=20=D0=B0=D1=80=D1=85=D0=B8=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/d3/monitoring/D3HorizontalCursor.tsx | 8 +++++--- src/components/d3/monitoring/D3MonitoringCharts.tsx | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/d3/monitoring/D3HorizontalCursor.tsx b/src/components/d3/monitoring/D3HorizontalCursor.tsx index a8a1d12..44d1ec1 100644 --- a/src/components/d3/monitoring/D3HorizontalCursor.tsx +++ b/src/components/d3/monitoring/D3HorizontalCursor.tsx @@ -139,7 +139,7 @@ const _D3HorizontalCursor = ({ if (!mouseState.visible || fixed) return let top = mouseState.y + offsetY - if (top + height >= sizes.chartsHeight) { + if (top + height / 2 >= sizes.chartsHeight) { setPosition('bottom') top = mouseState.y - offsetY - height } else { @@ -179,14 +179,16 @@ const _D3HorizontalCursor = ({ -
+
{tooltipBodies[i]}
diff --git a/src/components/d3/monitoring/D3MonitoringCharts.tsx b/src/components/d3/monitoring/D3MonitoringCharts.tsx index 5d7f582..18a3261 100644 --- a/src/components/d3/monitoring/D3MonitoringCharts.tsx +++ b/src/components/d3/monitoring/D3MonitoringCharts.tsx @@ -559,6 +559,7 @@ const _D3MonitoringCharts = >({ groups={groups} sizes={sizes} data={data} + height={height} /> From ccd2158f36e51468d75cba4aa775fdaa04ec93c1 Mon Sep 17 00:00:00 2001 From: ts_salikhov Date: Thu, 18 Aug 2022 13:14:51 +0400 Subject: [PATCH 02/96] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=B2=D1=8B=D1=80=D0=B0=D0=B2=D0=BD=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE=20=D0=BB=D0=B5?= =?UTF-8?q?=D0=B2=D0=BE=D0=BC=D1=83=20=D0=BA=D1=80=D0=B0=D1=8E=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BB=D0=B5=D0=B2=D0=BE=D0=B3=D0=BE=20=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D0=BB=D0=B1=D0=B8=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4?= =?UTF-8?q?=D1=81=D0=BA=D0=B0=D0=B7=D0=BA=D0=B8=20=D0=BA=D1=83=D1=80=D1=81?= =?UTF-8?q?=D0=BE=D1=80=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D1=84=D0=B8=D0=BA=D0=BE=D0=B2=20=D0=BC=D0=BE=D0=BD=D0=B8=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=D0=B0=20=D0=B8=20=D0=B0=D1=80?= =?UTF-8?q?=D1=85=D0=B8=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/d3/monitoring/D3HorizontalCursor.tsx | 3 ++- src/styles/d3.less | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/d3/monitoring/D3HorizontalCursor.tsx b/src/components/d3/monitoring/D3HorizontalCursor.tsx index 44d1ec1..335475d 100644 --- a/src/components/d3/monitoring/D3HorizontalCursor.tsx +++ b/src/components/d3/monitoring/D3HorizontalCursor.tsx @@ -1,4 +1,4 @@ -import { CSSProperties, ReactNode, SVGProps, useEffect, useMemo, useRef, useState } from 'react' +import { CSSProperties, ReactNode, SVGProps, useEffect, useMemo, useRef, useState, isValidElement, cloneElement } from 'react' import * as d3 from 'd3' import { wrapPlugin } from '@components/d3/plugins/base' @@ -166,6 +166,7 @@ const _D3HorizontalCursor = ({ }) const bodies = groups.map((group) => render(group, chartData)) + .map(body => isValidElement(body) ? cloneElement(body, {className: 'tooltip-body' }) : body) setTooltipBodies(bodies) }, [groups, data, yAxis, lineY, fixed, mouseState.visible]) diff --git a/src/styles/d3.less b/src/styles/d3.less index 6ec1bb0..daadea4 100644 --- a/src/styles/d3.less +++ b/src/styles/d3.less @@ -99,6 +99,13 @@ } } } + + & .tooltip-body { + + & > div:nth-child(n+3):nth-child(3n+1) { + text-align: end; + } + } } } From 0e432df77cbf236933d5a60556eafb6f65a0aaaf Mon Sep 17 00:00:00 2001 From: ts_salikhov Date: Fri, 19 Aug 2022 12:19:42 +0400 Subject: [PATCH 03/96] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=B2=D1=8B=D1=81=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BA=D1=83=D1=80=D1=81=D0=BE=D1=80=D0=B0=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=BE=D0=B2=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=BD=D0=B8=D1=82=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=D0=B0=20?= =?UTF-8?q?=D0=B8=20=D0=B0=D1=80=D1=85=D0=B8=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/d3/monitoring/D3HorizontalCursor.tsx | 5 ++--- src/pages/Telemetry/TelemetryView/cursorRender.jsx | 2 +- src/styles/d3.less | 7 ------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/components/d3/monitoring/D3HorizontalCursor.tsx b/src/components/d3/monitoring/D3HorizontalCursor.tsx index 335475d..4466254 100644 --- a/src/components/d3/monitoring/D3HorizontalCursor.tsx +++ b/src/components/d3/monitoring/D3HorizontalCursor.tsx @@ -1,4 +1,4 @@ -import { CSSProperties, ReactNode, SVGProps, useEffect, useMemo, useRef, useState, isValidElement, cloneElement } from 'react' +import { CSSProperties, ReactNode, SVGProps, useEffect, useMemo, useRef, useState } from 'react' import * as d3 from 'd3' import { wrapPlugin } from '@components/d3/plugins/base' @@ -166,7 +166,6 @@ const _D3HorizontalCursor = ({ }) const bodies = groups.map((group) => render(group, chartData)) - .map(body => isValidElement(body) ? cloneElement(body, {className: 'tooltip-body' }) : body) setTooltipBodies(bodies) }, [groups, data, yAxis, lineY, fixed, mouseState.visible]) @@ -180,7 +179,7 @@ const _D3HorizontalCursor = ({ { {getChartIcon(chart)} {chart.shortLabel || chart.label} - {xFormat(chart)} + {xFormat(chart)} ) })} diff --git a/src/styles/d3.less b/src/styles/d3.less index daadea4..6ec1bb0 100644 --- a/src/styles/d3.less +++ b/src/styles/d3.less @@ -99,13 +99,6 @@ } } } - - & .tooltip-body { - - & > div:nth-child(n+3):nth-child(3n+1) { - text-align: end; - } - } } } From 20f002111de705cacf3f21fbaead22a3b740b8a2 Mon Sep 17 00:00:00 2001 From: ts_salikhov Date: Fri, 19 Aug 2022 13:16:46 +0400 Subject: [PATCH 04/96] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=B2=D1=8B=D1=81=D0=BE=D1=82=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=BA=D1=83=D1=80=D1=81=D0=BE=D1=80=D0=B0=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=BE=D0=B2=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=BD=D0=B8=D1=82=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=D0=B0=20?= =?UTF-8?q?=D0=B8=20=D0=B0=D1=80=D1=85=D0=B8=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/d3/monitoring/D3HorizontalCursor.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/d3/monitoring/D3HorizontalCursor.tsx b/src/components/d3/monitoring/D3HorizontalCursor.tsx index 4466254..af75ff0 100644 --- a/src/components/d3/monitoring/D3HorizontalCursor.tsx +++ b/src/components/d3/monitoring/D3HorizontalCursor.tsx @@ -139,7 +139,7 @@ const _D3HorizontalCursor = ({ if (!mouseState.visible || fixed) return let top = mouseState.y + offsetY - if (top + height / 2 >= sizes.chartsHeight) { + if (mouseState.y >= sizes.chartsHeight / 2) { setPosition('bottom') top = mouseState.y - offsetY - height } else { From b44d796ad078be09dc2c4831b7897b7fd4aefcc2 Mon Sep 17 00:00:00 2001 From: goodmice Date: Mon, 22 Aug 2022 06:32:05 +0500 Subject: [PATCH 05/96] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B5=D0=BA=D1=83=D1=89=D0=B8?= =?UTF-8?q?=D1=85=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=B2=D1=8B=D0=B1=D1=80=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D1=8B=D1=85=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../d3/monitoring/D3MonitoringChartEditor.tsx | 20 +++++++++--- .../d3/monitoring/D3MonitoringCharts.tsx | 19 ++++++++--- .../monitoring/D3MonitoringCurrentValues.tsx | 32 +++++++++++++++++++ 3 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 src/components/d3/monitoring/D3MonitoringCurrentValues.tsx diff --git a/src/components/d3/monitoring/D3MonitoringChartEditor.tsx b/src/components/d3/monitoring/D3MonitoringChartEditor.tsx index 86ffdeb..05601a9 100644 --- a/src/components/d3/monitoring/D3MonitoringChartEditor.tsx +++ b/src/components/d3/monitoring/D3MonitoringChartEditor.tsx @@ -1,4 +1,4 @@ -import { Button, Form, FormItemProps, Input, InputNumber, Select, Tooltip } from 'antd' +import { Button, Checkbox, Form, FormItemProps, Input, InputNumber, Select, Tooltip } from 'antd' import { memo, useCallback, useEffect, useMemo } from 'react' import { MinMax } from '@components/d3/types' @@ -43,10 +43,12 @@ const _D3MonitoringChartEditor = ({ }, [value]) const onDomainChange = useCallback((mm: MinMax) => { - onSave({ xDomain: { - min: ('min' in mm) ? mm.min : value.xDomain?.min, - max: ('max' in mm) ? mm.max : value.xDomain?.max, - }}) + onSave({ + xDomain: { + min: ('min' in mm) ? mm.min : value.xDomain?.min, + max: ('max' in mm) ? mm.max : value.xDomain?.max, + } + }) }, [value]) const onColorChange = useCallback((color: Color) => { @@ -100,6 +102,14 @@ const _D3MonitoringChartEditor = ({ + + onSave({ showCurrentValue: e.target.checked })} + > + Показать текущее значение сверху + + ) } diff --git a/src/components/d3/monitoring/D3MonitoringCharts.tsx b/src/components/d3/monitoring/D3MonitoringCharts.tsx index 5d7f582..cc27838 100644 --- a/src/components/d3/monitoring/D3MonitoringCharts.tsx +++ b/src/components/d3/monitoring/D3MonitoringCharts.tsx @@ -25,6 +25,7 @@ import { getByAccessor, getChartClass, getGroupClass, getTicks } from '@componen import { renderArea, renderLine, renderNeedle, renderPoint, renderRectArea } from '@components/d3/renders' import D3MonitoringEditor from './D3MonitoringEditor' +import D3MonitoringCurrentValues from './D3MonitoringCurrentValues' import { D3HorizontalCursor, D3HorizontalCursorSettings } from './D3HorizontalCursor' import D3MonitoringLimitChart, { TelemetryRegulators } from './D3MonitoringLimitChart' @@ -55,6 +56,8 @@ export type ExtendedChartDataset = ChartDataset & { xDomain: MinMax /** Скрыть отображение шкалы графика */ hideLabel?: boolean + /** Показать последнее значение сверху графика */ + showCurrentValue?: boolean } export type ExtendedChartRegistry = ChartRegistry & ExtendedChartDataset @@ -291,9 +294,9 @@ const _D3MonitoringCharts = >({ resetDatasets() }, [resetDatasets, resetRegulators]) - useEffect(() => methods?.({ setSettingsVisible }), [methods]) + useEffect(() => methods?.({ setSettingsVisible }), [methods]) /// Возвращаем в делегат доступные методы - useEffect(() => { + useEffect(() => { /// Обновляем группы if (isDev()) { datasets.forEach((sets, i) => { sets.forEach((set, j) => { @@ -366,7 +369,7 @@ const _D3MonitoringCharts = >({ }) }, [yAxisConfig, chartArea, datasets, animDurationMs, createAxesGroup]) - useEffect(() => { + useEffect(() => { /// Обновляем группы и горизонтальные оси const axesGroups = axesArea() .selectAll('.charts-group') .data(groups) @@ -542,7 +545,7 @@ const _D3MonitoringCharts = >({ return })} - regulators={regulators} data={data} yAxis={yAxis} @@ -552,6 +555,12 @@ const _D3MonitoringCharts = >({ top={sizes.chartsTop} zoneWidth={sizes.inlineWidth} /> + + groups={groups} + data={data} + left={offset.left} + sizes={sizes} + /> >({ ) } -export const D3MonitoringCharts = memo(_D3MonitoringCharts) +export const D3MonitoringCharts = memo(_D3MonitoringCharts) as typeof _D3MonitoringCharts export default D3MonitoringCharts diff --git a/src/components/d3/monitoring/D3MonitoringCurrentValues.tsx b/src/components/d3/monitoring/D3MonitoringCurrentValues.tsx new file mode 100644 index 0000000..77b2d52 --- /dev/null +++ b/src/components/d3/monitoring/D3MonitoringCurrentValues.tsx @@ -0,0 +1,32 @@ +import { memo } from 'react' + +import { ChartGroup, ChartSizes } from '@components/d3/monitoring/D3MonitoringCharts' +import { makeDisplayValue } from '@utils' + +export type D3MonitoringCurrentValuesProps = { + groups: ChartGroup[] + data: DataType[] + left: number + sizes: ChartSizes +} + +const display = makeDisplayValue({ def: '---', fixed: 2 }) + +const _D3MonitoringCurrentValues = ({ groups, data, left, sizes }: D3MonitoringCurrentValuesProps) => ( + + {groups.map((group) => ( + + {group.charts.filter((chart) => chart.showCurrentValue).map((chart, i) => ( + + {chart.shortLabel ?? chart.label}: + {display(chart.x((data.at(-1) ?? {}) as any))} + + ))} + + ))} + +) + +export const D3MonitoringCurrentValues = memo(_D3MonitoringCurrentValues) as typeof _D3MonitoringCurrentValues + +export default D3MonitoringCurrentValues From 3f7fd3c0c0d02b0e5fe89fc97b453ce206eb236c Mon Sep 17 00:00:00 2001 From: ts_salikhov Date: Mon, 22 Aug 2022 10:34:19 +0400 Subject: [PATCH 06/96] =?UTF-8?q?=D0=A3=D0=B2=D0=B5=D0=BB=D0=B8=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=88=D0=B8=D1=80=D0=B8=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Telemetry/TelemetryView/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Telemetry/TelemetryView/index.jsx b/src/pages/Telemetry/TelemetryView/index.jsx index c0c0242..884b23c 100755 --- a/src/pages/Telemetry/TelemetryView/index.jsx +++ b/src/pages/Telemetry/TelemetryView/index.jsx @@ -295,7 +295,7 @@ const TelemetryView = memo(() => { plugins={{ menu: { enabled: false }, cursor: { - width: 200, + width: 220, render: cursorRender, }, }} From 1a86f1727a5067270f44f2e81a84dc6963a11415 Mon Sep 17 00:00:00 2001 From: ts_salikhov Date: Mon, 22 Aug 2022 10:36:54 +0400 Subject: [PATCH 07/96] =?UTF-8?q?=D0=A3=D0=B2=D0=B5=D0=BB=D0=B8=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=88=D0=B8=D1=80=D0=B8=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Telemetry/Archive/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Telemetry/Archive/index.jsx b/src/pages/Telemetry/Archive/index.jsx index fa0fbb3..4db24f0 100755 --- a/src/pages/Telemetry/Archive/index.jsx +++ b/src/pages/Telemetry/Archive/index.jsx @@ -255,7 +255,7 @@ const Archive = memo(() => { plugins={{ menu: { enabled: false }, cursor: { - width: 200, + width: 220, render: cursorRender, } }} From 1dd19399e599745791984c9d8f8c923cd8723626 Mon Sep 17 00:00:00 2001 From: goodmice Date: Mon, 22 Aug 2022 14:47:14 +0500 Subject: [PATCH 08/96] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=B0=D0=B2=D1=82=D0=BE=D0=BC=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=BE=D0=B5=20=D0=BC=D0=B0=D1=81?= =?UTF-8?q?=D1=88=D1=82=D0=B0=D0=B1=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=BB=D1=8F=20TVD=20=D0=B8=20=D0=9E=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Telemetry/Operations/index.jsx | 11 ++- src/pages/WellOperations/Tvd/index.jsx | 99 ++++++++++++++++-------- src/utils/functions/numbers.tsx | 9 +++ 3 files changed, 86 insertions(+), 33 deletions(-) diff --git a/src/pages/Telemetry/Operations/index.jsx b/src/pages/Telemetry/Operations/index.jsx index c518806..282c1db 100644 --- a/src/pages/Telemetry/Operations/index.jsx +++ b/src/pages/Telemetry/Operations/index.jsx @@ -6,7 +6,7 @@ import { useWell } from '@asb/context' import LoaderPortal from '@components/LoaderPortal' import { DateRangeWrapper } from '@components/Table' import { invokeWebApiWrapperAsync } from '@components/factory' -import { getPermissions, arrayOrDefault, range, wrapPrivateComponent } from '@utils' +import { getPermissions, arrayOrDefault, range, wrapPrivateComponent, pretify } from '@utils' import { DetectedOperationService, DrillerService, TelemetryDataSaubService } from '@api' import DrillerList from './DrillerList' @@ -16,6 +16,7 @@ import OperationsChart from './OperationsChart' import OperationsTable from './OperationsTable' import '@styles/detected_operations.less' +import { unique } from '@asb/utils/filters' const Operations = memo(() => { const [isLoading, setIsLoading] = useState(false) @@ -61,6 +62,14 @@ const Operations = memo(() => { { actionName: 'Получение списка определённых операций', well } ), [well, dates, selectedCategory]) + useEffect(() => { + if (!data?.operations) return + const maxTarget = Math.max(...data.operations?.map((op) => op.operationValue?.targetValue || 0)) + const uniqueOps = data.operations?.map((op) => op.value || 0).filter(unique) + const value = uniqueOps.reduce((out, op) => out + op, 0) / uniqueOps.length * 3 / 2 + setYDomain(pretify(Math.max(maxTarget, value))) + }, [data]) + useEffect(() => { if (permissions.driller.get) updateDrillers() diff --git a/src/pages/WellOperations/Tvd/index.jsx b/src/pages/WellOperations/Tvd/index.jsx index 8bfed7c..f295d49 100644 --- a/src/pages/WellOperations/Tvd/index.jsx +++ b/src/pages/WellOperations/Tvd/index.jsx @@ -8,7 +8,7 @@ import { useWell } from '@asb/context' import { D3Chart } from '@components/d3' import LoaderPortal from '@components/LoaderPortal' import { invokeWebApiWrapperAsync } from '@components/factory' -import { formatDate, fractionalSum, wrapPrivateComponent, getOperations } from '@utils' +import { formatDate, fractionalSum, wrapPrivateComponent, getOperations, pretify } from '@utils' import TLPie from './TLPie' import TLChart from './TLChart' @@ -21,10 +21,26 @@ import '@styles/index.css' import '@styles/tvd.less' const operationsColors = [ - '#1abc9c', '#16a085', '#2ecc71', '#27ae60', '#3498db', - '#2980b9', '#9b59b6', '#8e44ad', '#34495e', '#2c3e50', - '#f1c40f', '#f39c12', '#e67e22', '#d35400', '#e74c3c', - '#c0392b', '#ecf0f1', '#bdc3c7', '#95a5a6', '#7f8c8d', + '#1abc9c', + '#16a085', + '#2ecc71', + '#27ae60', + '#3498db', + '#2980b9', + '#9b59b6', + '#8e44ad', + '#34495e', + '#2c3e50', + '#f1c40f', + '#f39c12', + '#e67e22', + '#d35400', + '#e74c3c', + '#c0392b', + '#ecf0f1', + '#bdc3c7', + '#95a5a6', + '#7f8c8d', ] export const makeGetColor = (types) => (type) => { @@ -35,14 +51,17 @@ export const makeGetColor = (types) => (type) => { return i < 0 ? operationsColors[type] : operationsColors[i] } -const Item = ({ label, children, ...other }) => (
{label}: {children}
) +const Item = ({ label, children, ...other }) => ( +
+ {label}: + {children} +
+) -const numericRender = (d) => d && Number.isFinite(+d) ? (+d).toFixed(2) : '-' +const numericRender = (d) => (d && Number.isFinite(+d) ? (+d).toFixed(2) : '-') const tooltipRender = (data) => { - if (!data || data.length <= 0) return ( - Данных нет - ) + if (!data || data.length <= 0) return Данных нет return data.map(({ chart, data }) => { const xFormat = (d) => chart.xAxis.format?.(d) ?? `${numericRender(d)} ${chart.xAxis.unit ?? ''}` @@ -57,19 +76,23 @@ const tooltipRender = (data) => { {data.slice(0, 2).map((d, i) => { const text = `${xFormat(chart.x(d))} :: ${yFormat(chart.y(d))}` - const href = ['plan', 'fact'].includes(chart.key) && `/well/${d.idWell}/operations/${chart.key}/?selectedId=${d.id}` + const href = + ['plan', 'fact'].includes(chart.key) && + `/well/${d.idWell}/operations/${chart.key}/?selectedId=${d.id}` return (
{href ? ( - + {text} ) : ( - - {text} - + {text} )}
) @@ -89,7 +112,7 @@ const xAxis = { type: 'linear', accessor: 'day', unit: 'день', - } + }, } const ticks = { @@ -105,27 +128,17 @@ const ticks = { x: { visible: true, count: d3.timeDay.every(1), - format: (d, i) => i % 2 === 0 ? formatDate(d, undefined, 'YYYY-MM-DD') : '', + format: (d, i) => (i % 2 === 0 ? formatDate(d, undefined, 'YYYY-MM-DD') : ''), }, y: { visible: true }, - } -} - -const domain = { - date: { - y: { min: 4500, max: 0 }, }, - day: { - x: { min: 0 }, - y: { min: 4500, max: 0 }, - } } const plugins = { tooltip: { enabled: true, limit: 3, height: 200, render: tooltipRender }, menu: { enabled: false }, legend: { enabled: true, offset: { x: 400 }, type: 'horizontal' }, - cursor: { enabled: false } + cursor: { enabled: false }, } const makeDataset = (key, label, color, width, radius, dash) => ({ @@ -146,7 +159,7 @@ const makeDataset = (key, label, color, width, radius, dash) => ({ fillOpacity: 0.1, shape: 'vline', strokeWidth: 1.5, - radius + radius, }, }) @@ -174,7 +187,26 @@ const Tvd = memo(({ well: givenWell, title, ...other }) => { return { ...operations, withoutNpt } }, [operations]) - + + const domain = useMemo(() => { + const maxValue = Math.max( + ...Object.entries(chartData) + .map(([_, ops]) => Math.max(...ops.map((op) => op.depth).filter(Boolean))) + .filter(Boolean) + ) + const minValue = pretify(maxValue) + + return { + date: { + y: { min: minValue, max: 0 }, + }, + day: { + x: { min: 0 }, + y: { min: minValue, max: 0 }, + }, + } + }, [chartData]) + const datasets = useMemo(() => { const radius = pointsEnabled ? 6 : 1 @@ -202,7 +234,10 @@ const Tvd = memo(({ well: givenWell, title, ...other }) => {

{title || 'График Глубина-день'}

{ }) export default wrapPrivateComponent(Tvd, { - requirements: [ 'OperationStat.get', 'DetectedOperation.get' ], + requirements: ['OperationStat.get', 'DetectedOperation.get'], title: 'TVD', route: 'tvd', }) diff --git a/src/utils/functions/numbers.tsx b/src/utils/functions/numbers.tsx index 6e6ca26..4de2a13 100644 --- a/src/utils/functions/numbers.tsx +++ b/src/utils/functions/numbers.tsx @@ -25,6 +25,15 @@ export const limitValue = (min: T, max: T) => (value: T) => { */ export const range = (end: number, start: number = 0) => Array.from({ length: end - start }, (_, i) => start + i) +export const pretify = (n: number): number | null => { + if (!Number.isFinite(n)) return null + let i = 0 + for (; Math.abs(n) >= 100; i++) n /= 10 + const sign = Math.sign(n), nn = Math.floor(n / 10) + n = (Math.abs(n) % 10 < 5) ? nn * 10 + sign * 5 : (nn + sign) * 10 + return n * Math.pow(10, i) +} + export type DisplayValueOptions = { def?: ReactNode inf?: ReactNode | ((v: number) => ReactNode) From aceedd8dee352bbdbea3df9d12ef04fd3712af15 Mon Sep 17 00:00:00 2001 From: ts_salikhov Date: Tue, 23 Aug 2022 15:55:48 +0400 Subject: [PATCH 09/96] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D1=80=D0=BE=D0=BA?= =?UTF-8?q?=20=D0=B2=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D0=B0=D1=85=20?= =?UTF-8?q?=D0=B2=D0=BE=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BA=D0=B5=20?= =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D1=80=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Measure/MeasureTable.jsx | 4 ++-- src/pages/Measure/View.jsx | 31 ++++++++++++++++++++---------- src/pages/Measure/index.jsx | 15 +++++++++++++++ src/pages/Measure/nnbData.js | 2 +- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index 810c4bf..9ba5ac7 100755 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -134,7 +134,7 @@ export const MeasureTable = memo(({ group, updateMeasuresFunc, additionalButtons
-
+
{data.map((item, index) => (
- +
diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index f7213e8..cf3911e 100755 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -6,18 +6,29 @@ import { Grid, GridItem } from '@components/Grid' import '@styles/index.css' import '@styles/measure.css' -const colsCount = 3 - -export const View = memo(({ columns, item }) => !item || !columns?.length ? ( +export const View = memo(({ columns, item, rowsInColumn }) => { + let rowPosition = 0 + let columnPosition = 1 + return !item || !columns?.length ? ( ) : ( - {columns.map((column, i) => ( + {columns.map((column, i) => { + if (i === rowsInColumn.first) { + columnPosition = 3 + rowPosition = 0 + } else if (i === rowsInColumn.second) { + columnPosition = 5 + rowPosition = 0 + } + rowPosition++ + + return ( {column.title} @@ -25,8 +36,8 @@ export const View = memo(({ columns, item }) => !item || !columns?.length ? ( @@ -45,6 +56,6 @@ export const View = memo(({ columns, item }) => !item || !columns?.length ? ( )} - ))} + )})} -)) +)}) diff --git a/src/pages/Measure/index.jsx b/src/pages/Measure/index.jsx index e6b4590..6449b4d 100755 --- a/src/pages/Measure/index.jsx +++ b/src/pages/Measure/index.jsx @@ -20,16 +20,31 @@ const defaultData = [ title: 'Замер бурового раствора', columns: columnsDrillingFluid, defaultValue: drillingFluidDefaultData, + rowsInColumn: { + first: 10, + second: 19, + third: 28, + }, }, { idCategory: 2, title: 'Шламограмма', columns: columnsMudDiagram, defaultValue: mudDiagramDefaultData, + rowsInColumn: { + first: 6, + second: 15, + third: 22, + }, }, { idCategory: 3, title: 'ННБ', columns: columnsNnb, defaultValue: nnbDefaultData, + rowsInColumn: { + first: 6, + second: 12, + third: 17, + }, additionalButtons: (group, idx, onClick) => (isEditing) => isEditing ? null : (