SFCartesianChart not taking up all the space

Hi,

I have this cartesian chart and the line chart itself, does not fill up the given space of the chart, the line only reaches about half of the delegated space its given. 


As you can see the end point of the line does not reach the top of the border. I have tried changing the values, but the line always reaches the middle of the box as a maximum.

```

Container(
height: size.height * 0.175,
child: SfCartesianChart(
trackballBehavior: TrackballBehavior(
activationMode: ActivationMode.singleTap,
enable: true,
shouldAlwaysShow: true,
tooltipSettings: InteractiveTooltip(
enable: true,
color: Colour.kPrimaryColor,
decimalPlaces: 5,
),
),
plotAreaBorderWidth: 0,
primaryXAxis: CategoryAxis(
isVisible: false,
),
primaryYAxis: NumericAxis(
decimalPlaces: 5,
isVisible: false,
),
series: <LineSeries<PriceData, String>>[
LineSeries<PriceData, String>(
dataSource: <PriceData>[
PriceData('1', 0.0001),
PriceData('2', 0.0002),
PriceData('3', 0.0005),
PriceData('4', 0.0006),
PriceData('5', 0.001),
],
xValueMapper: (PriceData price, _) => price.day,
yValueMapper: (PriceData price, _) => price.value,
)
]
)
);

```

This is what I have so far,

Thanks for your help!!


3 Replies

SK Sriram Kiran Senthilkumar Syncfusion Team August 15, 2022 12:09 PM UTC

Hi Alvin,


Greetings from Syncfusion. We have checked the provided code snippet and we found that you have used `CategoryAxis` as the x-axis for the chart in which the `labelPlacement` property will be set to `betweenTicks` by default and thus the data points will render in between ticks and so there is extra space at the start and end of the chart. To avoid these spaces, please set the `labelPlacement` value to `onTicks`.

Also, regarding the space at the top side of the chart, it occurs due to auto range calculation in the y-axis based on the available data points in the series. To overcome this, you can either set the `maximum` value for the y-axis if the exact maximum value is known for the chart or you can use the `rangePadding` property and set its value as` ChartRangePadding.round` to avoid additional range calculation.

We have also created a simple sample with the provided code snippet and attached it below in which we have done modifications accordingly to achieve your requirement.

Chart, line chart

Description automatically generated


Regards,

Sriram Kiran


Attachment: f176800_6e55c198.zip


AL Alvin Lam August 15, 2022 02:46 PM UTC

Hey Sriram,

Thanks for your help as well as the explanation!!




SK Sriram Kiran Senthilkumar Syncfusion Team August 16, 2022 01:06 PM UTC

Hi Alvin,


Most welcome. Kindly get back to us if you have further queries. We are always happy to assist you.


Regards,

Sriram Kiran


Loader.
Up arrow icon