Use a Chart with a REST Data Source

Last modified: August 19, 2026

Introduction

With the Charts widget, you can plot data that comes from a REST service.

The widget does not call a REST service itself. Its data source accepts a database query (a microflow, a nanoflow, or an association) so you retrieve the REST data in a microflow and point the chart at that microflow.

This how-to teaches you how to do the following:

  • Publish a REST API
  • Retrieve the data from a REST service in a microflow
  • Use that microflow as the data source for the Charts widget

Prerequisites

Before starting this how-to, make sure you have completed the following prerequisites:

  • Create an app
  • Import the latest Charts Widgets from the Mendix Marketplace

Setting up Data to be Exposed by a REST Endpoint

Mendix allows you to publish REST web services natively from Studio Pro. This how-to publishes a service first, so that there is an endpoint to consume in the next sections.

To create an Area Chart with data from a REST service, follow these steps:

  1. Create a new Module in your app.
  2. Rename the module to ChartsREST.
  3. Open the Domain model.
  4. Create Value and Series entities with the attributes and association shown in the picture below.
    Chart Rest Domain
  5. Right-click Value and select Generate overview pages....
    Chart Rest Enter Data
  6. Add the Value_NewEdit page generated to your navigation.
  7. Run the app.
  8. In your browser, open the NewEdit page.
  9. Add values and series by entering data in the appropriate fields.

Publishing the Service

To use data from a model in the REST service, you need to create a JSON structure.

Creating the Structure

  1. Create a JSON Structure
    Charts Rest MD

Configuring the REST Service

To configure the REST service, follow these steps:

  1. Add Published REST service.

    Charts Rest Publish

  2. Add REST Service Microflow.

    Charts Rest Microflow

  3. Add Export mapping.

    Charts Rest Export Mapping

Retrieving the REST Data in a Microflow

To make the published data available to the chart, consume the service and return its results from a microflow:

  1. Add a consumed REST service for the endpoint you published.
  2. Add an import mapping that maps the JSON response to the Value entity.
  3. Create a microflow named DS_ValuesFromREST.
  4. In the microflow, add a Call REST service activity that calls the endpoint and applies the import mapping.
  5. Set the list of Value objects produced by the mapping as the return value of the microflow.

Using the Microflow as a Chart Data Source

To plot the retrieved data, follow these steps:

  1. Create a page in your app containing an Area chart widget.

  2. Double-click the Area chart widget to open its properties.

  3. On the General tab, in the Data source section, add a new Series item.

  4. In the General section of the series, leave Data set set to Single series.

  5. Set Data source to Microflow and select DS_ValuesFromREST.

  6. Set Series name to the text that should appear in the legend.

  7. Select the X axis attribute and the Y axis attribute.

  8. Run your app and view the chart.

    Area chart plotting data retrieved from a REST service

Read More