Palash Gupta e7a5eb7b22
feat: new dashboard page is updated (#3385)
* feat: dashboard widget page is refactored

* chore: key is updated

* chore: delete widget is updated

* chore: naming of the file is updated

* feat: dashboard changes are updated and selected dashboard and dashboardId is added

* chore: dashboard widget page is updated

* feat: setlayout is updated

* chore: selected dashboard is updated

* chore: dashboard is updated

* fix: feedback is updated

* chore: comments are resolved

* chore: empty widget id is updated

* fix: variables is updated

* chore: dashboard variable and name,description is now updated in hooks

* chore: build is fixed

* chore: loading experience is updated

* chore: title is updated

* fix: dashboard variables and other changes are updated

* feat: dashboard reducer is removed

* feat: widget header is updated

* feat: widget header is updated

* chore: dashboard is updated

* chore: feedback is updated

* fix: issues are fixed

* chore: delete is updated

* chore: warning message is updated

* chore: warning message is updated

* chore: widget graph component

* feat: dashboard condition is updated

* chore: getChartData is updated

* chore: widget details page is updated

* feat: tab sync is updated

* chore: layout is updated

* chore: labels is updated

* chore: message is updated

* chore: warining message is updated

---------

Co-authored-by: Rajat Dabade <rajat@signoz.io>
Co-authored-by: Vishal Sharma <makeavish786@gmail.com>
2023-10-08 23:21:17 +05:30

62 lines
1.4 KiB
TypeScript

import Graph from 'components/Graph';
import Spinner from 'components/Spinner';
import { themeColors } from 'constants/theme';
import getChartData, { GetChartDataProps } from 'lib/getChartData';
import { colors } from 'lib/getRandomColor';
import { memo, useCallback, useMemo } from 'react';
import { LogsExplorerChartProps } from './LogsExplorerChart.interfaces';
import { CardStyled } from './LogsExplorerChart.styled';
function LogsExplorerChart({
data,
isLoading,
isLabelEnabled = true,
className,
}: LogsExplorerChartProps): JSX.Element {
const handleCreateDatasets: Required<GetChartDataProps>['createDataset'] = useCallback(
(element, index, allLabels) => ({
data: element,
backgroundColor: colors[index % colors.length] || themeColors.red,
borderColor: colors[index % colors.length] || themeColors.red,
...(isLabelEnabled
? {
label: allLabels[index],
}
: {}),
}),
[isLabelEnabled],
);
const graphData = useMemo(
() =>
getChartData({
queryData: [
{
queryData: data,
},
],
createDataset: handleCreateDatasets,
}),
[data, handleCreateDatasets],
);
return (
<CardStyled className={className}>
{isLoading ? (
<Spinner size="default" height="100%" />
) : (
<Graph
name="logsExplorerChart"
data={graphData.data}
type="bar"
containerHeight="100%"
animate
/>
)}
</CardStyled>
);
}
export default memo(LogsExplorerChart);