How to use the DataFlex Chart Library
Lesson 3 - Setting up a multiseries chart
Introduction to Multi-Series Charts
- A multi-series chart displays multiple sets of data in a single chart.
- Useful for comparing values, showing relationships, or combining metrics like totals and averages.
- You can mix chart types—for example, a bar series with a line series on the same chart.
How Multi-Series Charts Work
- The TChartData[] array holds multiple series.
- Each index in the array represents one series inside the chart.
- For example:
- chartData[0] → first series
- chartData[1] → second series
- chartData[2] → third series
- Each series has its own label and its own set of Y-axis data points.
Extending the Existing Setup
- We return to the OnLoad procedure from the previous lesson.
- Generate a second set of random numbers
Integer[] secondList
Get RandomIntegerArray 10 to secondList
- Create a second series in chartData
Move "Second Series" to chartData[1].sLabel
- Fill the second series with data
- For each index:
- Take the number from secondList[index]
- Move it into the second series:
Move secondList[i] to chartData[1].aDataPoints[i].yValue
Reuse the existing X-axis labels
- Labels from the first series are sufficient for the demo.
Compile and Test
- Compile the project
- Refresh the browser
- You now see two line series in one chart
- Each series responds independently to:
- Hover tooltips
- Click events
- Legend interactions (users can hide/show series)
Mixing Chart Types
- To combine a line chart with a bar chart:
Move "bar" to chartData[1].sType
- Compile
- Refresh
- The first series is still a line chart
- The second series becomes a bar chart
- Both series appear in the same chart, each with its own style