From 520a3f93c67137ea810c8b57e8b19b1fc81bfb5a Mon Sep 17 00:00:00 2001 From: SagarRajput-7 Date: Mon, 2 Jun 2025 13:21:46 +0530 Subject: [PATCH] feat: research on data limit for signoz dashboard perf --- .../CustomDataControls.styles.scss | 85 +++++++++ .../CustomDataControls/CustomDataControls.tsx | 75 ++++++++ .../GlobalCustomDataControls.tsx | 91 ++++++++++ .../GlobalCustomDataControlsHeader.tsx | 88 ++++++++++ .../Description.styles.scss | 4 + .../DashboardDescription/index.tsx | 4 + .../NewWidget/RightContainer/index.tsx | 37 ++++ frontend/src/container/NewWidget/index.tsx | 29 ++++ .../PanelWrapper/UplotPanelWrapper.tsx | 163 ++++++++++++++++-- .../src/lib/uPlotLib/getUplotChartOptions.ts | 5 +- .../src/providers/Dashboard/Dashboard.tsx | 35 +++- frontend/src/providers/Dashboard/types.ts | 52 +++--- frontend/src/types/api/dashboard/getAll.ts | 3 + 13 files changed, 626 insertions(+), 45 deletions(-) create mode 100644 frontend/src/components/CustomDataControls/CustomDataControls.styles.scss create mode 100644 frontend/src/components/CustomDataControls/CustomDataControls.tsx create mode 100644 frontend/src/components/CustomDataControls/GlobalCustomDataControls.tsx create mode 100644 frontend/src/components/CustomDataControls/GlobalCustomDataControlsHeader.tsx diff --git a/frontend/src/components/CustomDataControls/CustomDataControls.styles.scss b/frontend/src/components/CustomDataControls/CustomDataControls.styles.scss new file mode 100644 index 0000000000..585646c275 --- /dev/null +++ b/frontend/src/components/CustomDataControls/CustomDataControls.styles.scss @@ -0,0 +1,85 @@ +.custom-data-controls { + margin: 8px 0; + + .custom-data-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; + } + + .custom-data-inputs { + margin-top: 8px; + + .input-group { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; + + .input-label { + margin-right: 8px; + } + } + } +} + +.global-custom-data-controls { + background-color: #f0f2f5; + border-radius: 4px; + padding: 10px; + margin-bottom: 16px; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + + .ant-card-body { + padding: 12px; + } + + &.dark-mode { + background-color: #141414; + border: 1px solid #303030; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); + } + + &.inline-layout { + .custom-data-inline-container { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 16px; + + .title-switch-group { + display: flex; + align-items: center; + gap: 12px; + min-width: 180px; + + .ant-typography { + white-space: nowrap; + } + } + + .inputs-container { + display: flex; + align-items: center; + gap: 20px; + + .input-group { + display: flex; + align-items: center; + margin-bottom: 0; + + .input-label { + margin-right: 8px; + white-space: nowrap; + } + } + } + } + + // Reduce vertical padding for the card + .ant-card-body { + padding: 8px 12px; + } + } +} diff --git a/frontend/src/components/CustomDataControls/CustomDataControls.tsx b/frontend/src/components/CustomDataControls/CustomDataControls.tsx new file mode 100644 index 0000000000..d1da03e205 --- /dev/null +++ b/frontend/src/components/CustomDataControls/CustomDataControls.tsx @@ -0,0 +1,75 @@ +import './CustomDataControls.styles.scss'; + +import { Card, InputNumber, Switch, Typography } from 'antd'; +import { Widgets } from 'types/api/dashboard/getAll'; + +interface CustomDataControlsProps { + widget: Widgets; + onUpdate: (updatedWidget: Partial) => void; +} + +const { Text } = Typography; + +function CustomDataControls({ + widget, + onUpdate, +}: CustomDataControlsProps): JSX.Element { + const handleCustomDataModeChange = (checked: boolean): void => { + onUpdate({ + customDataMode: checked, + customXData: checked ? widget.customXData || 15 : undefined, + customYData: checked ? widget.customYData || 4 : undefined, + }); + }; + + const handleDataPointsChange = (value: number | null): void => { + if (value !== null && value > 0) { + onUpdate({ customXData: value }); + } + }; + + const handleSeriesCountChange = (value: number | null): void => { + if (value !== null && value > 0) { + onUpdate({ customYData: value }); + } + }; + + return ( + +
+ Custom Data Generator + +
+ + {widget.customDataMode && ( +
+
+ Data Points (X): + +
+ +
+ Series Count (Y): + +
+
+ )} +
+ ); +} + +export default CustomDataControls; diff --git a/frontend/src/components/CustomDataControls/GlobalCustomDataControls.tsx b/frontend/src/components/CustomDataControls/GlobalCustomDataControls.tsx new file mode 100644 index 0000000000..d84f62d3fb --- /dev/null +++ b/frontend/src/components/CustomDataControls/GlobalCustomDataControls.tsx @@ -0,0 +1,91 @@ +import './CustomDataControls.styles.scss'; + +import { Card, InputNumber, Switch, Typography } from 'antd'; + +interface GlobalCustomDataControlsProps { + customDataMode: boolean; + setCustomDataMode: (value: boolean) => void; + customXData: number; + setCustomXData: (value: number) => void; + customYData: number; + setCustomYData: (value: number) => void; +} + +const { Text } = Typography; + +function GlobalCustomDataControls({ + customDataMode, + setCustomDataMode, + customXData, + setCustomXData, + customYData, + setCustomYData, +}: GlobalCustomDataControlsProps): JSX.Element { + const handleCustomDataModeChange = (checked: boolean): void => { + setCustomDataMode(checked); + + // Set default values if not already set + if (checked) { + if (!customXData) setCustomXData(15); + if (!customYData) setCustomYData(4); + } + }; + + const handleDataPointsChange = (value: number | null): void => { + if (value !== null && value > 0) { + setCustomXData(value); + } + }; + + const handleSeriesCountChange = (value: number | null): void => { + if (value !== null && value > 0) { + setCustomYData(value); + } + }; + + return ( + +
+ Global Custom Data Generator + +
+ + {customDataMode && ( +
+
+ Data Points (X): + +
+ +
+ Series Count (Y): + +
+
+ )} +
+ ); +} + +export default GlobalCustomDataControls; diff --git a/frontend/src/components/CustomDataControls/GlobalCustomDataControlsHeader.tsx b/frontend/src/components/CustomDataControls/GlobalCustomDataControlsHeader.tsx new file mode 100644 index 0000000000..8395ed17ca --- /dev/null +++ b/frontend/src/components/CustomDataControls/GlobalCustomDataControlsHeader.tsx @@ -0,0 +1,88 @@ +import './CustomDataControls.styles.scss'; + +import { Card, InputNumber, Switch, Typography } from 'antd'; +import { useIsDarkMode } from 'hooks/useDarkMode'; +import { useDashboard } from 'providers/Dashboard/Dashboard'; + +const { Text } = Typography; + +function GlobalCustomDataControlsHeader(): JSX.Element { + const { + globalCustomDataMode, + setGlobalCustomDataMode, + globalCustomXData, + setGlobalCustomXData, + globalCustomYData, + setGlobalCustomYData, + } = useDashboard(); + + const isDarkMode = useIsDarkMode(); + + const handleCustomDataModeChange = (checked: boolean): void => { + setGlobalCustomDataMode(checked); + + // Set default values if not already set + if (checked) { + if (!globalCustomXData) setGlobalCustomXData(15); + if (!globalCustomYData) setGlobalCustomYData(4); + } + }; + + const handleDataPointsChange = (value: number | null): void => { + if (value !== null && value > 0) { + setGlobalCustomXData(value); + } + }; + + const handleSeriesCountChange = (value: number | null): void => { + if (value !== null && value > 0) { + setGlobalCustomYData(value); + } + }; + + return ( + +
+
+ Custom Data Generator + +
+ + {globalCustomDataMode && ( +
+
+ Points (X): + +
+ +
+ Series (Y): + +
+
+ )} +
+
+ ); +} + +export default GlobalCustomDataControlsHeader; diff --git a/frontend/src/container/NewDashboard/DashboardDescription/Description.styles.scss b/frontend/src/container/NewDashboard/DashboardDescription/Description.styles.scss index 0f4b2dcc95..88aff0ef03 100644 --- a/frontend/src/container/NewDashboard/DashboardDescription/Description.styles.scss +++ b/frontend/src/container/NewDashboard/DashboardDescription/Description.styles.scss @@ -121,6 +121,10 @@ } } + .global-custom-data-section { + margin-bottom: 16px; + } + .dashboard-details { display: flex; justify-content: space-between; diff --git a/frontend/src/container/NewDashboard/DashboardDescription/index.tsx b/frontend/src/container/NewDashboard/DashboardDescription/index.tsx index cf7263d04e..f9e51be686 100644 --- a/frontend/src/container/NewDashboard/DashboardDescription/index.tsx +++ b/frontend/src/container/NewDashboard/DashboardDescription/index.tsx @@ -12,6 +12,7 @@ import { Typography, } from 'antd'; import logEvent from 'api/common/logEvent'; +import GlobalCustomDataControlsHeader from 'components/CustomDataControls/GlobalCustomDataControlsHeader'; import { SOMETHING_WENT_WRONG } from 'constants/api'; import { QueryParams } from 'constants/query'; import { PANEL_GROUP_TYPES, PANEL_TYPES } from 'constants/queryBuilder'; @@ -478,6 +479,9 @@ function DashboardDescription(props: DashboardDescriptionProps): JSX.Element { )} +
+ +
{(tags?.length || 0) > 0 && (
{tags?.map((tag) => ( diff --git a/frontend/src/container/NewWidget/RightContainer/index.tsx b/frontend/src/container/NewWidget/RightContainer/index.tsx index f0e518ab06..477181c8aa 100644 --- a/frontend/src/container/NewWidget/RightContainer/index.tsx +++ b/frontend/src/container/NewWidget/RightContainer/index.tsx @@ -12,6 +12,7 @@ import { Switch, Typography, } from 'antd'; +import CustomDataControls from 'components/CustomDataControls/CustomDataControls'; import TimePreference from 'components/TimePreferenceDropDown'; import { PANEL_TYPES, PanelDisplay } from 'constants/queryBuilder'; import GraphTypes, { @@ -113,6 +114,12 @@ function RightContainer({ customLegendColors, setCustomLegendColors, queryResponse, + customDataMode, + setCustomDataMode, + customXData, + setCustomXData, + customYData, + setCustomYData, }: RightContainerProps): JSX.Element { const { selectedDashboard } = useDashboard(); const [inputValue, setInputValue] = useState(title); @@ -280,6 +287,30 @@ function RightContainer({ rootClassName="description-input" /> + + {/* Custom Data Controls */} + {selectedWidget && ( + ): void => { + if (updatedWidget.customDataMode !== undefined) { + setCustomDataMode(updatedWidget.customDataMode); + } + if (updatedWidget.customXData !== undefined) { + setCustomXData(updatedWidget.customXData); + } + if (updatedWidget.customYData !== undefined) { + setCustomYData(updatedWidget.customYData); + } + }} + /> + )} +
Panel Type