fix(usage): keep the grouped-trend legend off the x-axis labels
The legend renders at the chart bottom (bottom: 0); with the default grid (bottom: 8) it overlapped the date labels once a group-by split the trend into multiple series. Reserve grid bottom space (matching the Tokens trend) whenever a legend is shown.
This commit is contained in:
@@ -133,12 +133,14 @@ const MetricChartCard: React.FC<MetricChartCardProps> = ({
|
|||||||
xAxisData={xAxisData}
|
xAxisData={xAxisData}
|
||||||
height={280}
|
height={280}
|
||||||
labelFormatter={labelFormatter}
|
labelFormatter={labelFormatter}
|
||||||
// Auto-show a legend once the trend is split into multiple series.
|
// Auto-show a legend once the trend is split into multiple series, and
|
||||||
|
// reserve room below the x-axis so it doesn't overlap the date labels.
|
||||||
legendData={
|
legendData={
|
||||||
seriesData.length > 1
|
seriesData.length > 1
|
||||||
? seriesData.map((s) => ({ name: s.name }))
|
? seriesData.map((s) => ({ name: s.name }))
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
grid={seriesData.length > 1 ? { bottom: 28 } : undefined}
|
||||||
/>
|
/>
|
||||||
</CardWrapper>
|
</CardWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user