Create a Basic Chart
Introduction
The Charts module provides widgets for different types of charts (for example, area, line, bar, column, and pie) in a Mendix application.
This how-to teaches you how to do the following:
- Create a chart with basic sample data
- Configure the chart display options
Prerequisites
Before starting this how-to, make sure you have completed the following prerequisites:
- Download the latest Charts module from the Mendix Marketplace
Implementing the Charts Widget in an Existing App
In this section, you will create a chart with basic sample data.
Setting up the Domain Model
To use the Charts widget, a specific data structure is set up. This is defined by entities and attributes in the domain model.
-
Create a new module called charts.
-
Configure your domain model to contain an entity Value with a string attribute xValue and a decimal attribute yValue:
Creating a Data Entry Page
To create a basic data entry page from which the Charts widget will fetch data, follow these steps:
-
Right-click the Value entity.
-
Select Generate overview pages:
-
Add the Value_Overview page to user navigation.
Adding the Charts Widget to a New Page
-
Create a page named ShowChart.
-
Add it to the user navigation.
-
On the ShowChart page, add the widget Area chart:
-
The final page should look like this:
Configuring the Charts Widget
To configure a Charts widget, follow these steps:
- Open the page with the Charts widget.
- Double-click the Area chart widget to open its properties.
- On the General tab, in the Data source section, click New in the Series list. The Edit Series Item dialog box opens.
- On the General tab of the dialog box, leave Data set set to Single series.
- Set Data source to Database and select the Value entity.
- Select xValue as the X axis attribute and yValue as the Y axis attribute.
Viewing the Chart
To view the chart, follow these steps:
-
Run the app.
-
In your browser, open the data entry page.
-
Enter data values for x value and y value:
-
Click the Save button.
-
Open the ShowChart page to view the chart you just created:
Read More
- Create a Multiple Series Chart
- Use a Chart with a REST Data Source
- Use Any Chart
- Use the Charts Theme