Chart Component

The Chart component is available in the Add Component palette of the Studio View Designer as soon as you install the add-on in your project. Creating a chart boils down to configuring the properties of this component either in XML using nested elements and attributes or through its Java API.

In the example below, a chart is created and first configured declaratively using XML:

<charts:chart id="chart">
        <charts:source dataContainer="vehiclesDc"
                       valueFields="cars motorcycles bicycles"/>
        <charts:bar name="Cars"/>
        <charts:bar name="Motorcycles" stack="stack"/>
        <charts:bar name="Bicycles" stack="stack"/>
            <charts:axisLabel formatter="{value}"/>

After that, additional properties are set programmatically in Java:

private Chart chart;

public void onInit(final InitEvent event) {
    chart.setLegend(new Legend().withTop("0"));
    chart.setTitle(new Title().withText("Vehicles").withSubtext("By Year"));

The resulting chart looks as follows:

chart component 1

If you don’t use the view designer, declare the charts namespace in your view’s XML descriptor manually:

<view xmlns=""

When configuring a chart, you can refer to the official Apache ECharts documentation to find the properties you need, and then use corresponding Jmix Chart properties. Most of the time, you will find exact matches between JavaScript and Jmix APIs.


The dataSet property defines the data source for the chart’s series and enables data reuse across multiple series within one charts tag.

In the following example, a data set is configured in XML and connects a chart to the vehiclesDc data container:

    <charts:source dataContainer="vehiclesDc"
                   valueFields="cars motorcycles bicycles"/>

The chart will use the year attribute of the entity to get a category name and cars, motorcycles and bicycles attributes to get values.

The same data set can be configured in Java as follows:

        new DataSet().withSource(
                new DataSet.Source<EntityDataItem>()
                        .withDataProvider(new ContainerChartItems<>(vehiclesDc))
                        .withValueFields("cars", "motorcycles", "bicycles")
The chart element can include only one dataSet configuration.


The series element defines the type of chart to display (e.g., line, bar, scatter). Each chart type can be configured differently within the series element.

The basic chart types supported by Jmix include:

In the following example, the series element defines a pie chart:

        <charts:source dataContainer="vehiclesIn2012Dc"
            <charts:label formatter="{b}: {d}%"/>

The label element configures text labels of pie segments. Its formatter attribute defines a pattern which can include the data item name and value. See more about label and formatter in the ECharts documentation.

The resulting pie chart looks as follows:

chart component series 1
The chart element can include multiple series configurations, in which case the data will be shared across all chart types.


The title property displays the chart’s main title and subtitle, customizable in text content, positioning, alignment, and style.

For example:

    <charts:title text="Vehicles" subtext="Ratio in 2012"
                  top="0" right="0" textAlign="CENTER">
        <charts:textStyle fontStyle="ITALIC"/>

This configuration specifies both the main title and a subtitle for the chart, positioned in the top right corner with centered text alignment and italic text style:

chart component title 1


The legend property shows the symbol, color, and name of different series. Legends can be clicked to toggle the display of the chart series. The legend is automatically generated based on the provided data.

    <charts:legend align="RIGHT"/>

This example displays a legend with symbols on the right:

chart component legend 1


The dataZoom property provides two primary features:

  • Inside data zoom enables users to zoom or roam within coordinate systems through mouse dragging, mouse wheel movements, or finger touch gestures on touch screens.

  • Slider type data zoom offers features like data thumbnails for a quick overview, zooming in/out, selection brushing, drag to move, and click to locate within the chart’s data range.

For example:

        <charts:sliderDataZoom orientation="HORIZONTAL"/>
        <charts:sliderDataZoom orientation="VERTICAL" right="5%"/>

Notice the horizontal and vertical sliders displayed on the chart:

chart component data zoom 1


The nativeJson property allows you to configure the chart using a direct JSON string as an alternative when the component’s Java API or XML attributes do not meet specific customization requirements. This feature provides access to the full range of ECharts' configuration options.

For example:

            "title": {
                "text": "Vehicles",
                "subtext": "Ratio in 2012",
                "top": "0",
                "right": "0",
                "textAlign": "CENTER",
                "textStyle": {
                  "fontStyle": "italic"

Here the nativeJson element configures the chart title in the same way as in the XML configuration above.

nativeJson configuration is merged with existing properties and overrides corresponding properties defined in XML.


The toolbox property provides a group of utility tools, which includes export, data view, dynamic type switching, data area zooming, and reset configurations.

For example, the following configuration adds ability to export the chart as a PNG image:

            <charts:saveAsImage title="Export to PNG" type="PNG"/>

Notice the download icon in the top right corner of the chart:

chart component export 1