The charts widget provides a basic implementation of dynamic series. This allows you to vary the number of data series (for example lines on a line chart) in your chart at runtime, based on the data in your app.
This how-to will teach you how to do the following:
- Create a chart with dynamic series
Before starting this how-to, make sure you have completed the following prerequisites:
- Install the latest Mendix Desktop Modeler
- Download the latest Charts Widget from the Mendix App Store
3 Configuring the Charts Widget
3.1 Setting up the Domain Model
In order to create the Charts widget with dynamic series, a specific data structure is set up.
- Configure your domain model to contain an entity Value with attributes xValue and yValue.
- Add another entity, Series, with attributes name, color, and fillColor.
- Add an association Value_Series between the two entities.
3.2 Adding Chart Configuration
To configure a Charts widget with a dynamic series, follow these steps:
- Open the page containing the Charts widget.
- Right click, select Properties.
- In the tab Chart properties, add a new Series property.
- In the tab Data source, select Dynamic.
- Set the Data entity to Value. This is the entity from which the data values will be retrieved.
- Set the Data source as Database or Microflow.
- In the tab Dynamic series, set the Series entity to Series.
- Set the Series name attribute to Series/name and Line color attribute to Series/color.
- Add the charts page to user navigation.
3.3 Viewing the Chart
To view the chart, follow these steps:
- Run the project.
Open the page containing the dynamic series chart.