palash-signoz be8ec756c6
Feat (UI) :Trace Filter page is updated (#684)
* dayjs and less loader is added

* webpack config is added

* moment is removed

* useDebounceFunction hook is made

* old components and reducer is removed

* search is updated

* changes are upadted for the trace page as skeleton is ready

* chore: method is change from dayjs

* convertObject into params is updated

* initial filters are updated

* initial and final filter issue is fixed

* selection of the filter is updated

* filters are now able to selected

* checkbox disable when loading is in progress

* chore: getFilter filename is updated

* feat: clear all and exapanded filter is updated

* chore: clearAll and expand panel is updated

* feat: useClickOutSide hook is added

* chore: get filter url becomes encoded

* chore: get tag filters is added

* feat: search tags is wip

* bug: global max,min on change bug is resolved

* chore: getInitial filter is updated

* chore: expand panel is updated

* chore: get filter is updated

* chore: code smells is updated

* feat: loader is added in the panel header to show the loading

* chore: search tags in wip

* chore: button style is updated

* chore: search in wip

* chore: search ui is updated from the global state

* chore: search in wip

* chore: search is updated

* chore: getSpansAggregate section is updated

* useOutside click is updated

* useclickoutside hook is updated

* useclickoutside hook is updated

* parsing is updated

* initial filter is updated

* feat: trace table is updated

* chore: trace table is updated

* chore: useClickout side is updated for the search panel

* feat: unneccesary re-render and code is removed

* chore: trace table is updated

* custom component is removed and used antd search component

* error state is updated over search component

* chore: search bar is updated

* chore: left panel search and table component connection is updated

* chore: trace filter config is updated

* chore: for graph reducer is updated

* chore: graph is updated

* chore: table is updated

* chore: spans is updated

* chore: reducer is updated

* chore: graph component is updated

* chore: number of graph condition is updated

* chore: input and range slider is now sync

* chore: duration is updated

* chore: clearAllFilter is updated

* chore: duration slider is updated

* chore: duration is updated and panel body loading is updated

* chore: slider container is added to add padding from left to right

* chore: Select filter is updated

* chore: duration filter is updated

* chore: Divider is added

* chore: none option is added in both the dropdown

* chore: icon are updated

* chore: added padding in the pages component

* chore: none is updated

* chore: antd notification is added in the redux action

* chore: some of the changes are updated

* chore: display value is updated for the filter panel heading

* chore: calulation is memorised

* chore: utils function are updated in trace reducer

* chore: getFilters are updated

* tracetable is updated

* chore: actions is updated

* chore: metrics application is updated

* chore: search on clear action is updated

* chore: serviceName panel position is updated

* chore: added the label in the duration

* bug: edge case is fixed

* chore: some more changes are updated

* chore: some more changes are updated

* chore: clear all is fixed

* chore: panel heading caret is updated

* chore: checkbox is updated

* chore: isError handler is updated over initial render

* chore: traces is updated

* fix: tag search is updated

* chore: loading is added in the trace table and soring is introduced in the trace table

* bug: multiple render for the key is fixed

* Bug(UI): new suggestion is updated

* feat: isTraceFilterEnum function is made

* bug: new changes are updated

* chore: get Filter is updated

* chore: application metrics params is updated

* chore: error is added in the application metrics

* chore: filters is updated

* chore: expand panel edge case is updated

* chore: expand panel is updated and utls: updateUrl function is updated

* chore: reset trace state when unmounted

* chore: getFilter action is updated

* chore: api duration is updated

* chore: useEffect dependency is updated

* chore: filter is updated with the new arch

* bug: trace table issue is resolved

* chore: application rps url is updated for trace

* chore: duration filter is updated

* chore: search key is updated

* chore: filter is added in the search url

* bug: filter is fixed

* bug: filter is fixed

* bug: filter is fixed

* chore: reset trace data when unmounted

* chore: TopEnd point is added

* chore: getInitialSpanAggregate action is updated

* chore: application url is updated

* chore: no tags placeholder is updated

* chore: flow from customer is now fixed

* chore: search is updated

* chore: select all button is removed

* chore: prev filter is removed to show the result

* chore: config is updated

* chore: checkbox component is updated

* chore: span filter is updated

* chore: graph issue is resolved

* chore: selected is updated

* chore: all filter are selected

* feat: new trace page is updated

* chore: utils is updated

* feat: trace filter page is updated

* chore: duration is now fixed

* chore: duration clear filter is added

* chore: onClickCheck is updated

* chore: trace filter page is updated

* bug: some of bugs are resolved

* chore: duration body is updated

* chore: topEndPoint and application query is updated

* chore: user selection is updated in the duration filter

* chore: panel duration is updated

* chore: panel duration is updated

* chore: duration bug is solved

* chore: function display value is updated
2022-02-09 11:31:13 +05:30

179 lines
3.4 KiB
TypeScript

import {
ActiveElement,
BarController,
BarElement,
CategoryScale,
Chart,
ChartData,
ChartEvent,
ChartOptions,
ChartType,
Decimation,
Filler,
Legend,
LinearScale,
LineController,
LineElement,
PointElement,
SubTitle,
TimeScale,
TimeSeriesScale,
Title,
Tooltip,
} from 'chart.js';
import * as chartjsAdapter from 'chartjs-adapter-date-fns';
import React, { useCallback, useEffect, useRef } from 'react';
import { useSelector } from 'react-redux';
import { AppState } from 'store/reducers';
import AppReducer from 'types/reducer/app';
Chart.register(
LineElement,
PointElement,
LineController,
CategoryScale,
LinearScale,
TimeScale,
TimeSeriesScale,
Decimation,
Filler,
Legend,
Title,
Tooltip,
SubTitle,
BarController,
BarElement,
);
import { legend } from './Plugin';
import { LegendsContainer } from './styles';
const Graph = ({
data,
type,
title,
isStacked,
onClickHandler,
name,
}: GraphProps): JSX.Element => {
const { isDarkMode } = useSelector<AppState, AppReducer>((state) => state.app);
const chartRef = useRef<HTMLCanvasElement>(null);
const currentTheme = isDarkMode ? 'dark' : 'light';
// const [tooltipVisible, setTooltipVisible] = useState<boolean>(false);
const lineChartRef = useRef<Chart>();
const getGridColor = useCallback(() => {
if (currentTheme === undefined) {
return 'rgba(231,233,237,0.1)';
}
if (currentTheme === 'dark') {
return 'rgba(231,233,237,0.1)';
}
return 'rgba(231,233,237,0.8)';
}, [currentTheme]);
const buildChart = useCallback(() => {
if (lineChartRef.current !== undefined) {
lineChartRef.current.destroy();
}
if (chartRef.current !== null) {
const options: ChartOptions = {
responsive: true,
maintainAspectRatio: false,
interaction: {
mode: 'index',
intersect: false,
},
plugins: {
title: {
display: title === undefined ? false : true,
text: title,
},
legend: {
display: false,
},
},
layout: {
padding: 0,
},
scales: {
x: {
grid: {
display: true,
color: getGridColor(),
},
adapters: {
date: chartjsAdapter,
},
time: {
unit: 'minute',
},
type: 'time',
},
y: {
display: true,
grid: {
display: true,
color: getGridColor(),
},
},
stacked: {
display: isStacked === undefined ? false : 'auto',
},
},
elements: {
line: {
tension: 0,
cubicInterpolationMode: 'monotone',
},
},
onClick: (event, element, chart) => {
if (onClickHandler) {
onClickHandler(event, element, chart, data);
}
},
};
lineChartRef.current = new Chart(chartRef.current, {
type: type,
data: data,
options,
plugins: [legend(name, data.datasets.length > 3)],
});
}
}, [chartRef, data, type, title, isStacked, getGridColor, onClickHandler]);
useEffect(() => {
buildChart();
}, []);
return (
<div style={{ height: '85%' }}>
<canvas ref={chartRef} />
<LegendsContainer id={name} />
</div>
);
};
interface GraphProps {
type: ChartType;
data: Chart['data'];
title?: string;
isStacked?: boolean;
label?: string[];
onClickHandler?: graphOnClickHandler;
name: string;
}
export type graphOnClickHandler = (
event: ChartEvent,
elements: ActiveElement[],
chart: Chart,
data: ChartData,
) => void;
export default Graph;