mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-14 05:21:33 +08:00

* feat: add autocomplete to groupBy filters * chore: handle none groupby in frontend --------- Co-authored-by: Palash Gupta <palashgdev@gmail.com>
62 lines
1.4 KiB
TypeScript
62 lines
1.4 KiB
TypeScript
import { Typography } from 'antd';
|
|
import Graph from 'components/Graph';
|
|
import Spinner from 'components/Spinner';
|
|
import React, { useMemo } from 'react';
|
|
import { useSelector } from 'react-redux';
|
|
import { useMeasure } from 'react-use';
|
|
import { AppState } from 'store/reducers';
|
|
import { TraceReducer } from 'types/reducer/trace';
|
|
|
|
import { getChartData, getChartDataforGroupBy } from './config';
|
|
import { Container } from './styles';
|
|
|
|
function TraceGraph(): JSX.Element {
|
|
const [ref, { width }] = useMeasure();
|
|
|
|
const { spansGraph, selectedGroupBy, yAxisUnit } = useSelector<
|
|
AppState,
|
|
TraceReducer
|
|
>((state) => state.traces);
|
|
|
|
const { loading, error, errorMessage, payload } = spansGraph;
|
|
|
|
const ChartData = useMemo(
|
|
() =>
|
|
selectedGroupBy.length === 0 || selectedGroupBy === 'none'
|
|
? getChartData(payload)
|
|
: getChartDataforGroupBy(payload),
|
|
[payload, selectedGroupBy],
|
|
);
|
|
|
|
if (error) {
|
|
return (
|
|
<Container center>
|
|
<Typography>{errorMessage || 'Something went wrong'}</Typography>
|
|
</Container>
|
|
);
|
|
}
|
|
|
|
if (loading) {
|
|
return (
|
|
<Container>
|
|
<Spinner height="20vh" size="small" tip="Loading..." />
|
|
</Container>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Container ref={ref as never}>
|
|
<Graph
|
|
animate={false}
|
|
data={ChartData}
|
|
name="traceGraph"
|
|
type="line"
|
|
yAxisUnit={yAxisUnit}
|
|
forceReRender={width}
|
|
/>
|
|
</Container>
|
|
);
|
|
}
|
|
|
|
export default TraceGraph;
|