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