JMix Charts 2.2-RC1 - Stacked Chart with dynamic categories

I already started using JMix 2.2-RC1, because I wanted to use the Charts which are not available in any other JMix 2.x version. Since it is a new project I also do not want to start with 1.5.

Right now I’m trying to build a chart and I would like to have exactly this: Examples - Apache ECharts

As far as I understand I need to add an entry here for each category:

        <charts:xAxes>
            <charts:xAxis name="cat1"/>
            <charts:xAxis name="cat2"/>
        </charts:xAxes>

And define the value fields:
charts:dataSet
<charts:source dataContainer=“charts1Dc”
categoryField=“datetime”
valueFields=“cat1,cat2”/>
</charts:dataSet>

This approach is very static and requires two value fields per record. It requires a getter and setter per value field. My data schema looks differently:

public class Charts1DTO {
@JmixGeneratedValue
@JmixId
private UUID id;
private String category;
@Temporal(TemporalType.DATE)
private Date datetime;
private Long memory;

I can have many categories in the field category and memory is the value field. Instead I can have multiple records for one y data point. In case of 4 categories, it could be 4 rows.

Any ideas how to solve this? Can somebody provide an example?
Thank you in advance.

Hi!

This is not entirely correct. In fact, for such a charts you only need one x-axis and only one y-axis. This is exactly the amount you can see in the original options of the example. You can use Jmix UI Samples application as a hint.
There is an example for a very similar case: Stacked Area Sample.

Also, release 2.2. already available. We recommend updating from 2.2-RC1 to it.

UPD:
Perhaps other DataItems are more suitable for data binding than the data container:
MapDataItem Sample.

Best regards,
Dmitriy

1 Like

@d.kremnev Thank you for the quick reply. Great to see that 2.2 has been released and that there are more Charts examples available.
The MapDataItem should address for what I’m looking for.