Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion GUI/src/components/MetricsCharts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ type Props = {
endDate: string;
unit?: string;
groupByPeriod: GroupByPeriod;
filterEmpty?: boolean;
};

const MetricsCharts = ({ title, data, startDate, endDate, unit, groupByPeriod }: Props) => {
type DataItem = {
dateTime: number;
[key: string]: number;
};

const MetricsCharts = ({ title, data, startDate, endDate, unit, groupByPeriod, filterEmpty }: Props) => {
const { t } = useTranslation();

const charts: ChartType[] = [
Expand All @@ -41,7 +47,19 @@ const MetricsCharts = ({ title, data, startDate, endDate, unit, groupByPeriod }:
];
const [selectedChart, setSelectedChart] = useState<string>('barChart');

const filterChartsData = () => {
return data.chartData.map((obj : DataItem) => {
return Object.fromEntries(
Object.entries(obj).filter(([key, value]) => key === "dateTime" || value !== 0)
);
});
}

const buildChart = () => {
if(filterEmpty) {
data.chartData = filterChartsData();
}

if (selectedChart === 'pieChart') {
return (
<PieGraph
Expand Down
1 change: 1 addition & 0 deletions GUI/src/pages/FeedbackPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ const FeedbackPage: React.FC = () => {
{currentConfigs?.metric != 'negative_feedback' && (
<MetricsCharts
title={currentMetric}
filterEmpty={true}
data={chartData}
startDate={currentConfigs?.start ?? formatDate(new Date(), 'yyyy-MM-dd')}
endDate={currentConfigs?.end ?? formatDate(new Date(), 'yyyy-MM-dd')}
Expand Down