Frequently Asked Questions (FAQ)
Previous
Migration from v4 to v5
Loading...
When using AntV G2 to render charts, manually setting the padding
can cause the chart title to not render properly or disappear entirely.
Related issue: Title is not displayed after setting
G2 dynamically calculates the space required for all components by default, but once a fixed padding
value is specified, this automatic adjustment logic is skipped, which may lead to incomplete rendering of the components.
There are two ways to resolve this issue:
Allow G2 to automatically calculate the optimal spacing to ensure that all components are rendered correctly:
chart.interval().encode('x', 'category').encode('y', 'value').encode('color', 'type');
If you must manually set the padding
, make sure to reserve enough space for dynamically generated components:
chart.padding(50).interval().encode('x', 'category').encode('y', 'value').encode('color', 'type');
padding
, it is recommended to debug and find the appropriate values.