1

I want to be able to have a vertical line from the x-axis to the height of the y value, which is dynamic as it is being taken from a database.

example: for the data point 1 Jan, I want to have a plotband associatedAxisEnd of 45 , 2 Jan associatedAxisEnd of 65 etc...

I'm only able to create a constant associatedAxisEnd height currently, is there a way to be able to loop through the chart data and set the associatedAxisEnd height dynamically?

  primaryXAxis: CategoryAxis(
      axisLine: const AxisLine(width: 3),
      majorGridLines: const MajorGridLines(width: 0, 
      color: Colors.transparent),
      plotBands: 
      <PlotBand>[
                   PlotBand(
                     isVisible: true,
                     isRepeatable: true,
                     repeatEvery: 2,
                     size: 1,
                     borderWidth: 1,
                     repeatUntil: 6,
                     associatedAxisEnd: 50, // is it possible to have a loop on this line?
                     borderColor: Colors.grey,
                     dashArray : const <double>[5, 5]
                            ),
                       ]
      )

chart sample

LiuBeiBei
  • 23
  • 3

1 Answers1

1

You cannot have a loop when setting values for the PlotBand’s associatedAxisEnd property. However, you can achieve your requirement by adding individual plot band lines for the chart data points as per required.

We have created a simple sample in which we have added plot band lines for the chart data points by lopping through the chart data and attached the sample below for reference. Also appended the user guide documentation link for plot line rendering below for reference.

https://help.syncfusion.com/flutter/cartesian-charts/axis-customization#plot-line

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/i404038-1323531402

Dharman
  • 30,962
  • 25
  • 85
  • 135
srk_sync
  • 339
  • 1
  • 4