diff --git a/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/chartDefs.js b/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/chartDefs.js index ef9dd7e9aa..18f65f43a9 100644 --- a/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/chartDefs.js +++ b/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/chartDefs.js @@ -17,6 +17,44 @@ import PropTypes from 'prop-types' import { CartesianGrid, PolarAngleAxis, Cell } from 'recharts' import { Component, Fragment } from 'react' +/** + * Truncate long labels with ellipsis. + * + * @param {string} label - The label to be truncated. + * @param {number} maxLength - The maximum length of the label. + * @returns {string} The truncated label. + */ +const truncateLabel = (label, maxLength) => { + if (label.length > maxLength) { + return `${label.substring(0, maxLength)}...` + } + + return label +} + +/** + * Custom tick component for the XAxis that displays the full label on hover. + * + * @param {object} props - Props. + * @param {number} props.x - The x position of the tick. + * @param {number} props.y - The y position of the tick. + * @param {object} props.payload - The payload of the tick. + * @returns {Component} The rendered tick. + */ +export const CustomXAxisTick = ({ x, y, payload }) => { + const fullLabel = payload?.value + const truncatedLabel = truncateLabel(fullLabel, 10) + + return ( + + {fullLabel} + + {truncatedLabel} + + + ) +} + /** * Generates a color based on the metric, datasetId, and theme type. * @@ -234,6 +272,12 @@ export const GetChartElementConfig = ( } } +CustomXAxisTick.propTypes = { + x: PropTypes.number, + y: PropTypes.number, + payload: PropTypes.object, +} + GetChartElementConfig.propTypes = { chartType: PropTypes.string.isRequired, metric: PropTypes.object.isRequired, diff --git a/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/index.js b/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/index.js index 9ff2029bfa..e7d549bbb0 100644 --- a/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/index.js +++ b/src/fireedge/src/client/components/Charts/MultiChart/helpers/scripts/index.js @@ -23,6 +23,7 @@ import { GetChartDefs, GetChartConfig, GetChartElementConfig, + CustomXAxisTick, } from 'client/components/Charts/MultiChart/helpers/scripts/chartDefs' import { exportDataToPDF } from 'client/components/Charts/MultiChart/helpers/scripts/exportPDF' import { exportDataToCSV } from 'client/components/Charts/MultiChart/helpers/scripts/exportCSV' @@ -35,6 +36,7 @@ export { GetChartDefs, GetChartConfig, GetChartElementConfig, + CustomXAxisTick, exportDataToPDF, exportDataToCSV, } diff --git a/src/fireedge/src/client/components/Charts/MultiChart/helpers/subComponents/ChartRenderer.js b/src/fireedge/src/client/components/Charts/MultiChart/helpers/subComponents/ChartRenderer.js index 7b9167c650..0616e3b5a6 100644 --- a/src/fireedge/src/client/components/Charts/MultiChart/helpers/subComponents/ChartRenderer.js +++ b/src/fireedge/src/client/components/Charts/MultiChart/helpers/subComponents/ChartRenderer.js @@ -42,6 +42,7 @@ import { generateColorByMetric, GetChartConfig, GetChartElementConfig, + CustomXAxisTick, } from 'client/components/Charts/MultiChart/helpers/scripts' import { FormatPolarDataset, @@ -174,7 +175,11 @@ export const ChartRenderer = ({ {coordinateType === 'CARTESIAN' && ( <> - + } + /> )} diff --git a/src/fireedge/src/client/components/Tabs/Showback/index.js b/src/fireedge/src/client/components/Tabs/Showback/index.js index 8114651bd0..41b8313aa1 100644 --- a/src/fireedge/src/client/components/Tabs/Showback/index.js +++ b/src/fireedge/src/client/components/Tabs/Showback/index.js @@ -69,7 +69,6 @@ const topMetricNames = { } const commonStyles = { - minHeight: '250px', width: '100%', position: 'relative', marginTop: 2, @@ -204,7 +203,15 @@ const generateShowbackInfoTab = ({ groups }) => { ) return ( - + { flexDirection="row" justifyContent="space-between" mb={2} + flex={5} > - + { /> - + { - + item.VM.GID === groupId ) + } else { + responseData.HISTORY_RECORDS.HISTORY = history } } @@ -179,16 +181,21 @@ const showback = ( const responseData = value // Filter if there is not userId and there is a groupId - if (!userId && groupId && responseData && responseData.SHOWBACK_RECORDS) { + if (responseData && responseData.SHOWBACK_RECORDS) { // Filter data by group id const showbackHistory = Array.isArray( responseData.SHOWBACK_RECORDS.SHOWBACK ) ? responseData.SHOWBACK_RECORDS.SHOWBACK : [responseData.SHOWBACK_RECORDS.SHOWBACK] - responseData.SHOWBACK_RECORDS.SHOWBACK = showbackHistory.filter( - (item) => item.GID === groupId - ) + + if (!userId && groupId) { + responseData.SHOWBACK_RECORDS.SHOWBACK = showbackHistory.filter( + (item) => item.GID === groupId + ) + } else { + responseData.SHOWBACK_RECORDS.SHOWBACK = showbackHistory + } } // Return response