Skip to content

Commit 8dbdf09

Browse files
authored
Merge pull request #26 from NGO-Algorithm-Audit/feature/small-tweaks
Feature/small tweaks
2 parents 3a952b1 + fd07365 commit 8dbdf09

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

src/components/DistributionReport.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export const DistributionReport = (
227227
)}
228228
rangeMax={2}
229229
rangeMin={0}
230-
colors="RdGn"
230+
colors="LtRd"
231231
/>
232232
</div>
233233
</div>

src/components/graphs/CountBarChart.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ const CountBarChart = ({ column, realData }: CountBarChartProps) => {
1616
const [containerWidth, setContainerWidth] = useState(800);
1717
const { t } = useTranslation();
1818

19+
const formatTick = (value: number) => {
20+
if (value >= 1000000) {
21+
return `${(value / 1000000).toFixed(1)}M`;
22+
} else if (value >= 1000) {
23+
return `${(value / 1000).toFixed(1)}K`;
24+
}
25+
return value.toString();
26+
};
27+
1928
useEffect(() => {
2029
const plotWidth = containerWidth - margin.left - margin.right;
2130
const plotHeight = height - margin.top - margin.bottom;
@@ -86,7 +95,7 @@ const CountBarChart = ({ column, realData }: CountBarChartProps) => {
8695
.style('fill', 'steelblue')
8796
.style('opacity', 0.5);
8897

89-
// Add axes
98+
// Add axes with formatted ticks
9099
svg.append('g')
91100
.attr('transform', `translate(0,${plotHeight})`)
92101
.call(d3.axisBottom(xScale))
@@ -96,7 +105,12 @@ const CountBarChart = ({ column, realData }: CountBarChartProps) => {
96105
.attr('dx', '-.8em')
97106
.attr('dy', '.15em');
98107

99-
svg.append('g').call(d3.axisLeft(yScale));
108+
svg.append('g').call(
109+
d3
110+
.axisLeft(yScale)
111+
.ticks(5) // Reduce number of ticks
112+
.tickFormat(d => formatTick(d as number))
113+
);
100114

101115
// Add title
102116
svg.append('text')

src/components/graphs/DistributionBarChart.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ const DistributionBarChart = ({
2323
const [containerWidth, setContainerWidth] = useState(800);
2424
const { t } = useTranslation();
2525

26+
const formatTickAsPercentage = (value: number) => {
27+
return `${(value * 100).toFixed(1)}%`;
28+
};
29+
2630
useEffect(() => {
2731
const plotWidth = containerWidth - margin.left - margin.right;
2832
const plotHeight = height - margin.top - margin.bottom;
@@ -146,7 +150,12 @@ const DistributionBarChart = ({
146150
.attr('dx', '-.8em')
147151
.attr('dy', '.15em');
148152

149-
svg.append('g').call(d3.axisLeft(yScale));
153+
svg.append('g').call(
154+
d3
155+
.axisLeft(yScale)
156+
.ticks(5) // Reduce number of ticks
157+
.tickFormat(d => formatTickAsPercentage(d as number))
158+
);
150159

151160
// Add title
152161
svg.append('text')

src/components/graphs/HeatMap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface HeatMapChartProps {
77
columns: string[];
88
rangeMin: number;
99
rangeMax: number;
10-
colors: 'RdYlBu' | 'RdGn';
10+
colors: 'RdYlBu' | 'LtRd';
1111
}
1212

1313
// Define margins for the chart

0 commit comments

Comments
 (0)