Skip to content

Commit 5990cba

Browse files
Add labels for BarChart
1 parent f983455 commit 5990cba

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

frontend/src/components/BarChart.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend,
1111
interface BarChartProps {
1212
graphData: ChartDataSet[];
1313
aspectRatio?: number;
14+
xLabel?: string;
15+
yLabel?: string;
1416
}
1517

16-
const BarChart: React.FC<BarChartProps> = ({ graphData, aspectRatio = 4 }) => {
18+
const BarChart: React.FC<BarChartProps> = ({ graphData, aspectRatio = 4, xLabel, yLabel }) => {
1719
const chartRef = useRef<any>(null);
1820

1921
const allX = Array.from(new Set(graphData.flatMap((ds) => ds.data.map((point) => point.x))));
@@ -72,9 +74,11 @@ const BarChart: React.FC<BarChartProps> = ({ graphData, aspectRatio = 4 }) => {
7274
scales: {
7375
x: {
7476
grid: { display: true },
77+
title: { display: !!xLabel, text: xLabel ?? "" },
7578
},
7679
y: {
7780
grid: { display: true },
81+
title: { display: !!yLabel, text: yLabel ?? "" },
7882
},
7983
},
8084
};

frontend/src/components/LabResultsPlot.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ const LabResultsPlot: React.FC<LabResultsPlotProps> = ({
5757
data: ds.data.filter((point) => plotComponents.length === 0 || plotComponents.includes(point.x)),
5858
}))}
5959
aspectRatio={4}
60+
yLabel="Concentration (ppm)"
61+
xLabel="Components"
6062
/>
6163
<div style={{ marginBottom: "20px" }}>
6264
Plot subset of components:{" "}

frontend/src/components/Simulation/Results.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ const Results: React.FC<ResultsProps> = ({ simulationResults }) => {
9494
concentrations: initialConcentrations,
9595
},
9696
})}
97+
xLabel="Components"
98+
yLabel="Concentration (ppm)"
9799
/>
98100

99101
<ResultConcTable

frontend/src/pages/Compare.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ const Compare: React.FC = () => {
198198
Output Concentrations
199199
</Typography>
200200

201-
<BarChart graphData={chartData} aspectRatio={3} />
201+
<BarChart graphData={chartData} aspectRatio={3} xLabel="Components" yLabel="Concentration (ppm)" />
202202

203203
<Typography variant="h5" style={{ marginBottom: "1rem" }}>
204204
Concentration Values (≥ 0.01)

0 commit comments

Comments
 (0)