Skip to content

Commit 50a868d

Browse files
authored
Merge pull request #15 from NGO-Algorithm-Audit/feature/fix-legend-heatmap-for-synthdata
Feature/fix legend heatmap for synthdata
2 parents b479327 + ef2b359 commit 50a868d

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

src/components/componentMapper.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,25 +259,19 @@ export default function ComponentMapper({
259259
className="grid lg:grid-cols-[50%_50%] grid-cols-[100%]"
260260
>
261261
<div className="col-[1]">
262-
<h2 className="pb-2">
263-
{t('heatmap.realdata')}
264-
</h2>
265262
<HeatMapChart
266263
columns={realColumns}
267264
key={index}
268265
data={convertedData}
269-
title={resultItem.title ?? ''}
266+
title={t('heatmap.realdata')}
270267
/>
271268
</div>
272269
<div className="col-[1] lg:col-[2]">
273-
<h2 className="pb-2">
274-
{t('heatmap.syntheticdata')}
275-
</h2>
276270
<HeatMapChart
277271
columns={synthticColumns}
278272
key={index}
279273
data={syntheticData}
280-
title={resultItem.title ?? ''}
274+
title={t('heatmap.syntheticdata')}
281275
/>
282276
</div>
283277
</div>

src/components/graphs/HeatMap.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ const HeatMapChart = ({ title, data, columns }: HeatMapChartProps) => {
152152
'transform',
153153
`translate(${legendWidth - 50 + barWidth * data.length},0)`
154154
);
155-
const legendBarWidth = Math.abs(
156-
legendBar.node()!.getBoundingClientRect().x
157-
);
158155
svg.append('g')
159-
.attr('transform', `translate(${legendBarWidth + 10})`)
156+
.attr(
157+
'transform',
158+
`translate(${legendWidth - 50 + barWidth * data.length + 20})`
159+
)
160160
.datum(expandedDomain)
161161
.call(axisLabel)
162162
.select('.domain')
@@ -184,12 +184,15 @@ const HeatMapChart = ({ title, data, columns }: HeatMapChartProps) => {
184184

185185
// Render the chart container and SVG element with horizontal scroll if needed
186186
return (
187-
<div
188-
ref={containerRef}
189-
style={{ width: '100%', display: 'flex', overflowX: 'auto' }}
190-
className={`min-h-[${height}px] flex-col`}
191-
>
192-
<svg ref={svgRef}></svg>
187+
<div className="flex flex-col gap-4">
188+
<h3 className="text-center font-semibold text-base">{title}</h3>
189+
<div
190+
ref={containerRef}
191+
style={{ width: '100%', display: 'flex', overflowX: 'auto' }}
192+
className={`min-h-[${height}px] flex-col`}
193+
>
194+
<svg ref={svgRef}></svg>
195+
</div>
193196
</div>
194197
);
195198
};

0 commit comments

Comments
 (0)