mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-09 23:58:57 +08:00
Merge pull request #828 from palash-signoz/timeline-fix
bug(FE): timeline interval is updated
This commit is contained in:
commit
fafdd4b87f
@ -1,36 +1,25 @@
|
||||
import React, { useState, useMemo } from 'react';
|
||||
import { isEqual } from 'lodash-es';
|
||||
import React, { useState, useMemo, useEffect } from 'react';
|
||||
import styles from './style.module.css';
|
||||
import { useMeasure } from 'react-use';
|
||||
import { toFixed } from 'utils/toFixed';
|
||||
import {
|
||||
INTERVAL_UNITS,
|
||||
resolveTimeFromInterval,
|
||||
} from 'container/TraceDetail/utils';
|
||||
import { INTERVAL_UNITS } from 'container/TraceDetail/utils';
|
||||
import useThemeMode from 'hooks/useThemeMode';
|
||||
import { Interval } from './types';
|
||||
import { getIntervalSpread, getIntervals } from './utils';
|
||||
interface TimelineProps {
|
||||
traceMetaData: object;
|
||||
globalTraceMetadata: object;
|
||||
intervalUnit: object;
|
||||
setIntervalUnit: Function;
|
||||
}
|
||||
|
||||
const Timeline_Height = 22;
|
||||
const Timeline_H_Spacing = 0;
|
||||
|
||||
const Timeline = ({
|
||||
traceMetaData,
|
||||
globalTraceMetadata,
|
||||
intervalUnit,
|
||||
setIntervalUnit,
|
||||
}: TimelineProps) => {
|
||||
const [ref, { width }] = useMeasure<HTMLDivElement>();
|
||||
const { isDarkMode } = useThemeMode();
|
||||
|
||||
const Timeline_Height = 22;
|
||||
const Timeline_H_Spacing = 0;
|
||||
|
||||
const [intervals, setIntervals] = useState<Interval[] | null>(null);
|
||||
|
||||
useMemo(() => {
|
||||
useEffect(() => {
|
||||
const {
|
||||
baseInterval,
|
||||
baseSpread,
|
||||
@ -44,7 +33,7 @@ const Timeline = ({
|
||||
for (const idx in INTERVAL_UNITS) {
|
||||
const standard_interval = INTERVAL_UNITS[idx];
|
||||
if (baseSpread * standard_interval.multiplier < 1) {
|
||||
intervalUnit = INTERVAL_UNITS[idx - 1];
|
||||
if (idx > 1) intervalUnit = INTERVAL_UNITS[idx - 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -58,7 +47,7 @@ const Timeline = ({
|
||||
intervalUnit,
|
||||
}),
|
||||
);
|
||||
}, [traceMetaData, globalTraceMetadata]);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div ref={ref} style={{ flex: 1, overflow: 'inherit' }}>
|
||||
@ -79,10 +68,9 @@ const Timeline = ({
|
||||
{intervals &&
|
||||
intervals.map((interval, index) => (
|
||||
<g
|
||||
transform={`translate(${
|
||||
Timeline_H_Spacing +
|
||||
transform={`translate(${Timeline_H_Spacing +
|
||||
(interval.percentage * (width - 2 * Timeline_H_Spacing)) / 100
|
||||
},0)`}
|
||||
},0)`}
|
||||
className={styles['timeline-tick']}
|
||||
key={interval.label + interval.percentage + index}
|
||||
>
|
||||
@ -102,4 +90,11 @@ const Timeline = ({
|
||||
);
|
||||
};
|
||||
|
||||
interface TimelineProps {
|
||||
traceMetaData: object;
|
||||
globalTraceMetadata: object;
|
||||
intervalUnit: object;
|
||||
setIntervalUnit: Function;
|
||||
}
|
||||
|
||||
export default Timeline;
|
||||
|
Loading…
x
Reference in New Issue
Block a user