From c43919243ce7cbe92a1b5b5b2af425315f4a38b0 Mon Sep 17 00:00:00 2001 From: RoB Murdock Date: Fri, 13 Dec 2024 20:27:16 -0500 Subject: [PATCH] connection tooltip configuration to responsive line --- .../client/CouplingResponsiveLine.jsx | 89 +++---------------- 1 file changed, 10 insertions(+), 79 deletions(-) diff --git a/client/src/jsMain/javascript/com/zegreatrob/coupling/client/CouplingResponsiveLine.jsx b/client/src/jsMain/javascript/com/zegreatrob/coupling/client/CouplingResponsiveLine.jsx index f38471dd2..74ac164e4 100644 --- a/client/src/jsMain/javascript/com/zegreatrob/coupling/client/CouplingResponsiveLine.jsx +++ b/client/src/jsMain/javascript/com/zegreatrob/coupling/client/CouplingResponsiveLine.jsx @@ -23,8 +23,6 @@ export const CouplingResponsiveLine = (props) => { .map(group => group[1].reduce((result, current) => Object.assign(result, current), {})); const lineIds = props.data.map(value => value.id); const xValues = allPoints.map(point => point.x); - const xMin = props.xMin ?? new Date(Math.min(...xValues)) - const xMax = props.xMax ?? new Date(Math.max(...xValues)) const xMinMillis = Math.min(...xValues) const xMaxMillis = Math.max(...xValues) @@ -37,18 +35,18 @@ export const CouplingResponsiveLine = (props) => { const hasMonths = (range / (1000 * 60 * 60 * 24 * 30)) > 1 if (hasMonths) - return {format: '%y-%m-%d', precision: "day"} + return {format: '%y-%m-%d'} if (hasDays) - return {format: '%m-%d', precision: "hour"} + return {format: '%m-%d'} else if (hasHours) - return {format: '%H:%M', precision: "minute"} + return {format: '%H:%M'} else if (hasMinutes) - return {format: '%H:%M:%S', precision: "second"} + return {format: '%H:%M:%S'} else - return {format: '%H:%M:%S.%L', precision: "millisecond"} + return {format: '%H:%M:%S.%L'} } - const {format, precision} = calculatePrecision() + const {format} = calculatePrecision() const myColor = scaleOrdinal().domain(lineIds).range(schemeCategory10); const timeScale = scaleTime().domain([xMinMillis, xMaxMillis]).nice(); @@ -84,7 +82,10 @@ export const CouplingResponsiveLine = (props) => { dataKey='y' type="number" /> - d3TimeFormat(format)(value)}/> + d3TimeFormat(format)(value)} + content={props.tooltip ? (args) => props.tooltip(args.point.data) : undefined} + /> handleLegendClick(props.dataKey)} /> @@ -101,74 +102,4 @@ export const CouplingResponsiveLine = (props) => { ) - - return ( props.tooltip(args.point.data) : undefined} - legends={[ - { - anchor: 'bottom-right', - direction: 'column', - justify: false, - translateX: 85, - translateY: 0, - itemsSpacing: 0, - itemDirection: 'left-to-right', - itemWidth: 80, - itemHeight: 20, - itemOpacity: 0.75, - symbolSize: 12, - symbolShape: 'circle', - symbolBorderColor: 'rgba(0, 0, 0, .5)', - effects: [ - { - on: 'hover', - style: { - itemBackground: 'rgba(0, 0, 0, .03)', - itemOpacity: 1 - } - } - ] - } - ]} - /> - ) }