Fine-Tune a Chart with Chart Playground
Introduction
You can fine-tune individual chart widgets with the Chart playground widget. The playground lets you change the layout, configuration, and series settings of a chart in the running app and see the result right away.
This guide teaches you how to do the following:
- Change the font style (layout)
- Change the chart type of a series (series)
- Enable the toolbar (configuration)
Prerequisites
Before starting this guide, make sure you have completed the following prerequisites:
- Install the latest version of Mendix Studio Pro
- Download the latest Charts module from the Mendix Marketplace
- Set up a chart by following Create a Basic Chart
Opening the Playground
To open the playground on your chart, follow these steps:
-
Open the page with the chart in Studio Pro.
-
Open the chart properties and go to the General tab.
-
Set Show playground slot to Yes. The Playground slot drop zone appears on the chart.
-
Find the Chart playground widget in the Toolbox.
-
Drag the Chart playground widget into the Playground slot.
-
Run the app.
-
In your browser, open the page with the chart.
-
Click Toggle Editor:
Changing the Layout
This is what the original chart looks like:
To create a custom layout, follow these steps:
-
Open the playground as described in Opening the Playground.
-
In the drop-down list, select Layout.
-
In Custom settings, add the following JSON:
{ "font": { "family": "Open Sans", "size": 14, "color": "#555" } } -
Change the font settings until the chart shows the font you want, then copy the JSON.
Changes made in the playground do not persist. Store them in the chart properties or in the Charts theme.After making some changes, the chart looks like this:
-
In Studio Pro, on the General tab of the chart, set Enable advanced options to Yes. Then paste the JSON into the Custom layout property on the Advanced tab.
Changing the Chart Type of a Series
This is what the chart looks like before making any changes:
To change how one series is drawn, follow these steps:
-
Open the playground as described in Opening the Playground.
-
In the drop-down list, select the series you want to display differently. In this example, this is Alpha.
-
Change Custom settings to
{ "type": "line" }:
-
Copy the JSON.
-
In Studio Pro, open the chart properties and set Enable advanced options to Yes on the General tab. Then select Alpha in the Series list and click Edit.
-
On the Advanced tab of the Edit Series Item dialog box, paste the JSON into Custom series options:
After the changes, the chart looks like this:
Changing the Configuration
To create a custom configuration, follow these steps:
-
Open the playground as described in Opening the Playground.
-
In the drop-down list, select Configuration.
-
Change Custom settings to
{ "displayModeBar": true }. -
Add more settings as needed. For all configuration settings, see Configuration Options in the Plotly documentation.
-
Copy the JSON.
-
In Studio Pro, on the General tab of the chart, set Enable advanced options to Yes. Then paste the JSON into the Custom configurations property on the Advanced tab:
The chart now shows the toolbar:
Removing the Playground
When you are done, remove the playground from the chart:
- Delete the Chart playground widget from the Playground slot.
- Set Show playground slot to No.
Your changes in Custom layout, Custom configurations, and Custom series options stay in effect.
Read More
- Chart Playground
- Charts
- Layout options: Chart Advanced Cheat Sheet
- Configuration options: Chart Advanced Cheat Sheet
- Data series options: Chart Advanced Cheat Sheet
- Full reference: Plotly JavaScript Open Source Graphing Library