Creating Charts with FME | ChartGenerator

Liz Sanderson
Liz Sanderson
  • Updated

Introduction

Charts are an excellent way to visually communicate data that would otherwise be presented in text. Colour, chart type, and labels can be customized to make data appear in an attractive way to your client or target audience.

The best type of chart to use depends on the nature of the data: Pie Charts are best for displaying data that is shared among a total, such as budget allowances and election results; Bar Charts are best for comparing data spread across categories, such as monthly sales for different departments; Histograms or Scatter Plots are best for showing the distribution of data over one or two variables and can help to identify correlations.

FME's ChartGenerator transformer allows you to create custom Line, Scatter, Pie, Bar, and Histogram charts from the data in your workspace. The parameters dialog allows you to customize the chart appearance and displays a preview of the chart using arbitrary sample data.

ChartGenerator Parameters.png

Data values for the chart are specified from attributes, where each attribute defines a data series, and each feature provides a value for that series. The sum of all input features produces either a single raster chart or one per group, depending on whether Group By is enabled. Data values can also be specified from list attributes, where each feature corresponds to a chart, and each list attribute on the feature corresponds to a data series in the chart.

The transformer outputs raster charts as raster geometries on the features. Rasters can then be written to an image format such as PNG or JPEG, or incorporated into a report using the corresponding FME writer, such as PDF or Excel.

Step-by-Step Instructions

This example creates a pie chart using municipal election data from a simple CSV (Comma-Separated Values) file that contains candidate names and the number of votes per candidate.

1. Generate a New Workspace

Open FME Workbench and generate a new workspace. The source election data is a CSV file, and the output chart will be a PNG image, so enter the following parameters:

  • Reader Format: CSV (Comma Separated Value)
  • Reader Dataset: <Tutorial Download>/ElectionResults.csv
  • Writer Format: PNG (Portable Network Graphics)
  • Writer Dataset: <Tutorial Download>/output

Screen Shot 2021-10-15 at 11.31.28 AM.png

Click OK to generate the workspace.

2. Add Transformers to Prepare the Data

When using the ChartGenerator, the source data often needs to be prepared or reformatted before creating a chart. In this example, we will use the Sorter transformer to sort the features by vote count. The candidate with the most votes will appear first, so we can then use the "Explode Slice" option in the ChartGenerator to visually highlight the winning candidate.

Click the canvas and type "Sorter". Add this transformer to the workspace and connect it between the reader and writer feature types.

Screen Shot 2021-10-15 at 11.35.33 AM.png

Double-click the Sorter to open the parameters. Under "Sort By", specify the Votes attribute, Numeric, and Descending. This will configure the transformer to sort the features by vote count, with the highest first.

Screen Shot 2021-10-15 at 11.33.50 AM.png

Click OK.

3. Add and Configure a ChartGenerator Transformer

Add a ChartGenerator transformer and connect it between the Sorter and the writer feature type. Double-click it to open its parameters. We will create a Pie Chart from the number of votes and use the candidate names as labels. Set the following parameters:

Chart Settings

  • Type: Pie
  • Title: Election Results
  • Legend: Checked
  • Placement: Outer Upper Right
  • Feel free to customize the fonts for your chart in this section as well!

Data Series

  • Data Attribute: Votes
  • Label Attribute: Candidate
  • Color Scheme: Rainbow
  • Show Percentages: Yes
  • Effects: Explode Slice

Screen Shot 2021-10-18 at 10.18.25 AM.png

Tip: Check the ChartGenerator documentation for full details on how to set all of the transformer parameters.

The workspace is now configured to write the chart to a PNG file. You could also write the chart to a different format, a PDF, an Excel file, or another format that supports rasters.

Double-click the writer feature type and rename it to whatever you want your output PNG file to be named. The final workspace will look like this:

Screen Shot 2021-10-15 at 11.42.08 AM.png

4. Run the Workspace

Run the workspace and view the output file in the destination folder you specified.

The output PNG should look like this:

ElectionResults 10.18.52 AM.png

Preparing data for the ChartGenerator

The above example uses a Sorter to prepare data for the ChartGenerator. Other transformers that might be helpful to add before a ChartGenerator include the StatisticsCalculator (to create a chart based on calculated statistics, e.g., percent distribution), AttributeManager, and other attribute transformers.

Open the attached workspace, ElectionResults_Advanced.fmwt, for an example of how to use a series of transformers to reformat more complex input data. In that example, the source CSV file contains more data, including voting districts as column headers. We use Attribute* transformers to rearrange the spreadsheet so the data is more accessible and efficient for use by the ChartGenerator. We also add a user parameter that lets the end user choose which voting district to display a pie chart for.

The data preparation part of that workspace looks like this:

Screen Shot 2021-10-15 at 11.44.55 AM.png

Additional Resources

Data Attribution

The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

We're sorry to hear that.

Please tell us why.

As of January 14th, 2026, comments on knowledge base articles have been closed. To make sure questions don’t get missed and to enable more community support, we’ve moved discussions to the FME Community. If you have a question or a comment about this article, please create a new post or create a support ticket.