diff --git a/.changeset/popular-zoos-applaud.md b/.changeset/popular-zoos-applaud.md new file mode 100644 index 000000000..1926b0f11 --- /dev/null +++ b/.changeset/popular-zoos-applaud.md @@ -0,0 +1,5 @@ +--- +"@hyperdx/app": minor +--- + +fix: improve the visibility of the search bar chart loading state diff --git a/packages/app/src/HDXMultiSeriesTimeChart.tsx b/packages/app/src/HDXMultiSeriesTimeChart.tsx index a6ff8b802..299994d18 100644 --- a/packages/app/src/HDXMultiSeriesTimeChart.tsx +++ b/packages/app/src/HDXMultiSeriesTimeChart.tsx @@ -31,6 +31,7 @@ import { } from 'recharts'; import { DisplayType } from '@hyperdx/common-utils/dist/types'; import { Popover } from '@mantine/core'; +import { Text } from '@mantine/core'; import { notifications } from '@mantine/notifications'; import type { NumberFormat } from '@/types'; @@ -371,173 +372,186 @@ export const MemoChart = memo(function MemoChart({ const [highlightEnd, setHighlightEnd] = useState(); return ( - { - sizeRef.current = [width ?? 1, height ?? 1]; - }} - className={isLoading ? 'effect-pulse' : ''} - > - setIsHovered(true)} - onMouseLeave={e => { - setIsHovered(false); - - setHighlightStart(undefined); - setHighlightEnd(undefined); +
+ { + sizeRef.current = [width ?? 1, height ?? 1]; }} - onMouseDown={e => e != null && setHighlightStart(e.activeLabel)} - onMouseMove={e => { - setIsHovered(true); + className={isLoading ? 'effect-pulse' : ''} + > + setIsHovered(true)} + onMouseLeave={e => { + setIsHovered(false); - if (highlightStart != null) { - setHighlightEnd(e.activeLabel); - setIsClickActive(undefined); // Clear out any click state as we're highlighting - } - }} - onMouseUp={e => { - if (e?.activeLabel != null && highlightStart === e.activeLabel) { - // If it's just a click, don't zoom setHighlightStart(undefined); setHighlightEnd(undefined); - } - if (highlightStart != null && highlightEnd != null) { - try { - onTimeRangeSelect?.( - new Date( - Number.parseInt( - highlightStart <= highlightEnd - ? highlightStart - : highlightEnd, - ) * 1000, - ), - new Date( - Number.parseInt( - highlightEnd >= highlightStart - ? highlightEnd - : highlightStart, - ) * 1000, - ), - ); - } catch (e) { - console.error('failed to highlight range', e); + }} + onMouseDown={e => e != null && setHighlightStart(e.activeLabel)} + onMouseMove={e => { + setIsHovered(true); + + if (highlightStart != null) { + setHighlightEnd(e.activeLabel); + setIsClickActive(undefined); // Clear out any click state as we're highlighting + } + }} + onMouseUp={e => { + if (e?.activeLabel != null && highlightStart === e.activeLabel) { + // If it's just a click, don't zoom + setHighlightStart(undefined); + setHighlightEnd(undefined); + } + if (highlightStart != null && highlightEnd != null) { + try { + onTimeRangeSelect?.( + new Date( + Number.parseInt( + highlightStart <= highlightEnd + ? highlightStart + : highlightEnd, + ) * 1000, + ), + new Date( + Number.parseInt( + highlightEnd >= highlightStart + ? highlightEnd + : highlightStart, + ) * 1000, + ), + ); + } catch (e) { + console.error('failed to highlight range', e); + } + setHighlightStart(undefined); + setHighlightEnd(undefined); + } + }} + onClick={(state, e) => { + if ( + state != null && + state.chartX != null && + state.chartY != null && + state.activeLabel != null && + // If we didn't drag and highlight yet + highlightStart == null + ) { + setIsClickActive({ + x: state.chartX, + y: state.chartY, + activeLabel: state.activeLabel, + xPerc: state.chartX / sizeRef.current[0], + yPerc: state.chartY / sizeRef.current[1], + }); + } else { + // We clicked on the chart but outside of a line + setIsClickActive(undefined); } - setHighlightStart(undefined); - setHighlightEnd(undefined); - } - }} - onClick={(state, e) => { - if ( - state != null && - state.chartX != null && - state.chartY != null && - state.activeLabel != null && - // If we didn't drag and highlight yet - highlightStart == null - ) { - setIsClickActive({ - x: state.chartX, - y: state.chartY, - activeLabel: state.activeLabel, - xPerc: state.chartX / sizeRef.current[0], - yPerc: state.chartY / sizeRef.current[1], - }); - } else { - // We clicked on the chart but outside of a line - setIsClickActive(undefined); - } - // TODO: Properly detect clicks outside of the fake tooltip - e.stopPropagation(); - }} - > - - {COLORS.map(c => { - return ( - - - - - ); - })} - - {isHovered && ( - - )} - - - {lines} - } - wrapperStyle={{ - zIndex: 1, + // TODO: Properly detect clicks outside of the fake tooltip + e.stopPropagation(); }} - allowEscapeViewBox={{ y: true }} - /> - {referenceLines} - {highlightStart && highlightEnd ? ( - + + {COLORS.map(c => { + return ( + + + + + ); + })} + + {isHovered && ( + + )} + - ) : null} - {showLegend && ( - } - offset={-100} + - )} - {/** Needs to be at the bottom to prevent re-rendering */} - {isClickActive != null ? ( - - ) : null} - {logReferenceTimestamp != null ? ( - } + wrapperStyle={{ + zIndex: 1, + }} + allowEscapeViewBox={{ y: true }} /> - ) : null} - - + {referenceLines} + {highlightStart && highlightEnd ? ( + + ) : null} + {showLegend && ( + } + offset={-100} + /> + )} + {/** Needs to be at the bottom to prevent re-rendering */} + {isClickActive != null ? ( + + ) : null} + {logReferenceTimestamp != null ? ( + + ) : null} + + + + {isLoading && ( + + Loading... + + )} +
); }); diff --git a/packages/app/styles/app.scss b/packages/app/styles/app.scss index 061ad7d55..8fb8bf910 100644 --- a/packages/app/styles/app.scss +++ b/packages/app/styles/app.scss @@ -661,18 +661,19 @@ body { } .effect-pulse { - animation: pulse 1s infinite; + animation: pulse 1.5s infinite ease-in-out; + filter: grayscale(0.8) opacity(0.5); } @keyframes pulse { 0% { - opacity: 0.7; + opacity: 0.4; } - 20% { - opacity: 1; + 50% { + opacity: 0.8; } 100% { - opacity: 0.7; + opacity: 0.4; } }