Chart Structuring

Any [CARTESIAN_TYPE]Chart widget represents the data along the Cartesian Axes and plotted with the Cartesian Grid. We will learn about configuring the Chart Axes in the next chapter.

Every Cartesian Chart widget provides two key properties:

  1. chartStructureData

  2. chartStylingData

These properties control how your Grid and Axes layouts are configured as per provided data and stylised as required.

ChartStructureData

First, let's understand the chartStructureData property, as it plays a vital role in the Grid Layout Construction. For this example, we will be using a BarChart in the code sample.

Let's take a look at the below example:

...
BarChart(
  height: 400,
  chartStructureData: const CartesianChartStructureData(
    xUnitValue: 1,
    yUnitValue: 1,
    maxXValue: 10,
    maxYValue: 10,
  ),
  data: BarSeries( // Data is mandatory for any chart
    barData: [
      SimpleBar(
        xValue: 1,
        yValue: const BarData(yValue: 2.3),
      ),
    ],
  ),
),

In the above example, we specified that our maximum values along X & Y axis are 10. And we are to consider unit value as 1 for both. This creates a 10 x 10 Cartesian Grid in which we have plotted our bar value.

If we were to update the unit values to 2, then we would get. 5 X 5 Grid. This how you can can use the chartStructureData property to effectively control the structuring of your grid dimensions, hence the name.

Class Properties

NameBehaviourTypeRequiredDefault Value

xUnitValue

Constructs intervals along x-axis.

num

false

1

yUnitValue

Constructs intervals along y-axis.

num

false

10

maxXValue

The max value along +ve x-axis. Auto-calculated internally from series data if not specified.

num?

false

null

maxYValue

The max value along +ve y-axis. Auto-calculated internally from series data if not specified.

num?

false

null

Once the Chart Structure is defined, all that's left is styling for the Grid and Axes. We'll look at this in the next chapter.

Last updated