Add custom theme for charts

Hi there,

According to the amcharts documentation we can use any custom theme.

Unfortunately, I’ve got the following error when trying to use a custom theme* in the chart:
IllegalArgumentException: No enum constant com.haulmont.charts.gui.amcharts.model.ChartTheme.myTheme

*I’ve added the following line in my screen xml file: theme="myTheme"

Seems that available themes are predefined, so what is the way to add my own?


You’re right, the theme attribute supports only default themes. In case of custom theme, you can set the theme name using the setNativeJson method:

public class LineChartController extends AbstractFrame {
    private SerialChart lineChart;

    public void init(Map<String, Object> params) {
        lineChart.setNativeJson("{\"theme\": \"dark\"}");


1 Like

By the way, nativeJson element is also available in XML:

<chart:serialChart id="serialChart">
            "titles": [
                    "size": 15,
                    "text": "Chart Title"
        <chart:axis axisAlpha="0" position="LEFT" title="Incidents"/>
        <chart:graph id="g1" bullet="ROUND" type="COLUMN" valueField="value"/>
    <chart:categoryAxis position="TOP" title="Time" labelsEnabled="false"/>

See also Configuration using JSON - CUBA Platform. Displaying Charts And Maps

1 Like