Skip to main content
Version: 5.5

Layout

The layout component enables the padding configuration to add to a chart.

The layout configuration is nested in the configuration using

// get layout
Layout layout = chart.getOptions().getLayout();
// get padding
Padding padding = chart.getOptions().getLayout().getPadding();

// sets top and bottom options to padding of chart
chart.getOptions().getLayout().getPadding().setTop(10);
chart.getOptions().getLayout().getPadding().setBottom(10);
// to set same padding value to all sides of the chart
chart.getOptions().getLayout().getPadding().set(10);

int paddingTop = chart.getOptions().getLayout().getPadding().getTop();

The default values are set in global defaults options, see default global layout options.

The following layout options are available.

NameTypeDescription
autoPaddingbooleanIf true, apply automatic padding so visible elements are completely drawn.
paddingPaddingTo set specific padding for specific sides.

See padding documentation for more details.

Scriptable

Padding also accepts a callback which is called at runtime and that takes the context as single argument, see here the details, which is representing contextual information and chart instance.

The padding element can be set as a callback, providing a padding item instance, as following:

// get layout
Layout layout = chart.getOptions().getLayout();
// sets callback
layout.setPadding(new PaddingCallback<ChartContext>(){

@Override
public PaddingItem invoke(ChartContext context){
PaddingItem padding = new PaddingItem();
// your logic
return padding;
}
});

The following option can be set by a callback:

NameCallbackReturned types
paddingPaddingCallback<ChartContext>PaddingItem