-
Notifications
You must be signed in to change notification settings - Fork 357
Understanding padding
Jae Sung Park edited this page Oct 29, 2023
·
21 revisions
⚠️ The below criteria accurately applied starting from v3.10.0
There're remained inconsistency and will try to make adjustments in the future release.
Inconsistency of padding on previous versions (click to expand)
- The inconsistency of padding application stayed from the legacy(from the start of the fork).
- Adjusting it is extremely risky and hard, because it will affect entire chart rendering position. Also can break backward compatibility.
padding: {
top: 0,
bottom: 0,
left: 0,
right: 0
},
axis: {
x: {show: true},
y: {show: true},
y2: {show: true},
}
a) with legend
Non rotated axis | Rotated Axis | |
---|---|---|
Demo | https://jsfiddle.net/netil/0kbq419d/14/ | https://jsfiddle.net/netil/0kbq419d/22/ |
Screenshot | ![]() |
![]() |
Observation | - y axis vertical line remain shown - y2 axis vertical line remain shown - x axis remain shown completely with the legend |
- y axis vertical line remain shown - y2 axis vertical line remain shown - x axis remain shown completely with the legend |
b) without legend (legend.show=false
)
Non rotated axis | Rotated Axis | |
---|---|---|
Demo | https://jsfiddle.net/netil/0kbq419d/36/ | https://jsfiddle.net/netil/0kbq419d/37/ |
Screenshot | ![]() |
![]() |
Observation | - padding.bottom=0 , but x axis remain shown- removed the space where legend occupied |
render same as with legend case, but legend is hidden |
a) with legend
Non rotated axis | Rotated Axis | |
---|---|---|
Demo | https://jsfiddle.net/netil/0kbq419d/20/ | https://jsfiddle.net/netil/0kbq419d/24/ |
Screenshot | ![]() |
![]() |
Observation | - y axis is hidden completely - y2 axis vertical line remain shown - x axis remain shown completely with the legend |
- y/y2 axes are fully shown - x axis is hidden |
b) without legend (legend.show=false
)
Non rotated axis | Rotated Axis | |
---|---|---|
Demo | https://jsfiddle.net/netil/0kbq419d/39/ | https://jsfiddle.net/netil/0kbq419d/41 |
Screenshot | ![]() |
![]() |
Observation | - padding.bottom=0 , but x axis remain shown- removed the space where legend occupied |
render same as with legend case, but legend is hidden |
a) with legend
Non rotated axis | Rotated Axis | |
---|---|---|
Demo | https://jsfiddle.net/netil/0kbq419d/18/ | https://jsfiddle.net/netil/0kbq419d/26/ |
Screenshot | ![]() |
![]() |
Observation | - y axis is hidden completely - y2 axis vertical line remain shown - x axis remain shown completely with the legend |
- y/y2 axes are fully shown - x axis is hidden |
b) without legend (legend.show=false
)
Non rotated axis | Rotated Axis | |
---|---|---|
Demo | https://jsfiddle.net/netil/0kbq419d/43/ | https://jsfiddle.net/netil/0kbq419d/44/ |
Screenshot | ![]() |
![]() |
Observation | - padding.bottom=0 , but x axis remain shown- removed the space where legend occupied |
render same as with legend case, but legend is hidden |
- when padding set to 0, it should starting from shape area
- in this case, in the condition where axes are shown, they should be hidden
- in the previous version, legend visibility remained visible even padding set to 0, because of legend height.
- to keep this behavior, legend will be excluded from the padding calculation.
- if need control legend visibility, it can be easily manipulated by option:
legend.show=false
.
- Axis based chart will have default padding values(which vary based on options) as follows.
- Options which can make influential are:
- axis displays (
axis.[x|y|y2].show
) - axis position (
axis.[y|y2].inner
)
- axis displays (
![image](https://private-user-images.githubusercontent.com/2178435/269864520-085abe4b-93ec-49ee-935f-b3855f1d963f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzOTEwODcsIm5iZiI6MTczOTM5MDc4NywicGF0aCI6Ii8yMTc4NDM1LzI2OTg2NDUyMC0wODVhYmU0Yi05M2VjLTQ5ZWUtOTM1Zi1iMzg1NWYxZDk2M2YucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMjAwNjI3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTViNGZlNjMzZWI2YTAxMWM0MzdlMDYzMTlmZDc3MDRiZjcxNGY5ZjAyOThmYzNiZGMwNGRmY2E0NTA0ZTIxYyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.ms78MQWNzTLoqtHGoQ6wuA8oiAgoPz70Hn-5seH1zxs)
- Padding value will start from the chart shape's area.
- Specifying all direction's value as 0(zero), will make axes to be hidden.
- If want remove axes letting only chart shape visible, use
padding=false
instead.
- If want remove axes letting only chart shape visible, use
padding: {
top: 0,
bottom: 0,
left: 0,
right: 0
}
![image](https://private-user-images.githubusercontent.com/2178435/269867194-36ac9e1d-cd56-4906-8ac7-7bac5eab85c0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzOTEwODcsIm5iZiI6MTczOTM5MDc4NywicGF0aCI6Ii8yMTc4NDM1LzI2OTg2NzE5NC0zNmFjOWUxZC1jZDU2LTQ5MDYtOGFjNy03YmFjNWVhYjg1YzAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMjAwNjI3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTQ0MWYyNzRmMDU4ZGUyMjM3MjU2MDYwMzlkNDIzYWQ4MmE4NDIzMzZhOGYyNWRiZTFlMDg4Mzg5ZTZjN2YyMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.nnwf2KXj3p72lJx9i2If8_qlnNnKn6T2j7_PzWGuWyY)
⚠️ NOTE: legend element is "excluded" from the padding calculation.
- On
padding
dimension, legend element isn't included.- Hence, when legend element is visible, specifying
padding.bottom=0
will not behave hiding bottom area.
- If want legend element to be hidden, set
legend.show=false
.![]()
If just wants remove all other elements, rather than adjusting with padding values, use padding=false
instead.
padding: false
![image](https://private-user-images.githubusercontent.com/2178435/269878716-d6c2e9c2-b6a8-44ff-8b6b-133b1bf61d77.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzOTEwODcsIm5iZiI6MTczOTM5MDc4NywicGF0aCI6Ii8yMTc4NDM1LzI2OTg3ODcxNi1kNmMyZTljMi1iNmE4LTQ0ZmYtOGI2Yi0xMzNiMWJmNjFkNzcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMjAwNjI3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MjE4YTJhODY3ZTgwZDNjZDFjMDEzMDM4NDkxNzIwZDJhODNlMTkyOTllMDU2OTljYmMzMWFlMjcwOGU1MGU4NyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.nsaaelDc0ecgVXb0_x2R8VilVHbuxpK006EnYOTxNmE)
- When
padding.mode='fit'
is set, will remove padding values as possible.- Padding will vary based on variety of different option combination.
- "possible" means, will remove padding, but letting visible elements to not hide and occupying container element.
padding: {
mode: "fit"
}
![image](https://private-user-images.githubusercontent.com/2178435/269869639-e6b8c01a-cb5c-497b-b171-4512dff6c36c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzOTEwODcsIm5iZiI6MTczOTM5MDc4NywicGF0aCI6Ii8yMTc4NDM1LzI2OTg2OTYzOS1lNmI4YzAxYS1jYjVjLTQ5N2ItYjE3MS00NTEyZGZmNmMzNmMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMjAwNjI3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjNkMDRlYWU5YjdlMTQxNDJmYjc5ODYxNDA5OWIxMGNkNzlhNjdjMWJiNjk4NWU0MGQzZDVjMzM2MTg3YzQzOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.5baOOTdziurvOW_0BjtIBq-9fuWMx97cadXHJE7mV7Y)
- Padding value will start from the 'fit' mode state, relatively.
- Specifying all direction's value as 0(zero), will stay same as the 'fit' mode initial state.
- All padding values will be increased starting from the 'fit' mode initial state.
- The below example shows, all padding directions are given
20px
, and paddings are set starting from visible element's position.
- The below example shows, all padding directions are given
padding: {
mode: "fit",
top: 20,
bottom: 20,
left: 20,
right: 20
}
![image](https://private-user-images.githubusercontent.com/2178435/269871947-fef88d35-c079-400c-9249-cf3e8658fd14.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzOTEwODcsIm5iZiI6MTczOTM5MDc4NywicGF0aCI6Ii8yMTc4NDM1LzI2OTg3MTk0Ny1mZWY4OGQzNS1jMDc5LTQwMGMtOTI0OS1jZjNlODY1OGZkMTQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMjAwNjI3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MWE0Y2IyMmY1OTliYWI3ZjdmMzMwZGNkZmYwOGU5ZWMzMDQyNmY4YjczZjZiZjZiZmEyOWRiYmYzOWZiMDA1ZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.BTWw4JYCHwxYSO_ZMWQTHc-1hltVSPG5LKWAHZwWyl0)
- Why we decided to start billboard.js?
- Comparison table
- How to migrate from C3.js?
- Who's using billboard.js
- Third party applications
- Themes
- Roadmap
- Architecture & Event
- Plugin Interface
- Release workflow
- How behaves for dynamic loading?
- How tooltip behaves on grouped option?
- How to load as ESM directly from the browser?
- How to implement realtime chart?
- How to bundle for legacy browsers?
- How to generate chart image in Node.js environment?
- Understanding padding