How to set Y Axis Minimum at Start or When Zooming
When using SFCartesianChart & CandleSeries with AutoScrollingDelta= 50 at start. How to set the Y Axis minimum based on minimum of visible data ? I can only do using setting minimum =700 manully .Is it possible to set automatically or using a binding property ?
Also Candle Chart does not set the Y Axis minimum when zooming . I am thinking of using zoomend event but don't know how get Chart visible data minimum and set that to Y Axis
Screen shot at Start of the Application with this in XMAL AutoScrollingDelta= 50
Screen at start with AutoScrollingDelta = 50
Screenshot after zooming out many Bars cannot see the Left side Candles.
thanks
Hi Praveen,
We have acknowleged your query. We are currently the possibilities to set the Minimum value of y Axis dynamically based on zooming. If you don't want to change the Y Axis range while zoomin, we suggest you to use ZoomMode in ChartZoomPanBehavior and set mode as 'X'. It will make sure to zoom the chart in X Axis. We will check and provide further details about the dynamically change the Minimum value of Y Axis based on the visible data points within two business days (07/15/2024).
Regards,
Nitheeshkumar.
Hi Praveen,
We have acknowleged your query. We are currently the possibilities to set the Minimum value of y Axis dynamically based on zooming. If you don't want to change the Y Axis range while zoomin, we suggest you to use ZoomMode in ChartZoomPanBehavior and set mode as 'X'. It will make sure to zoom the chart in X Axis. We will check and provide further details about the dynamically change the Minimum value of Y Axis based on the visible data points within two business days (17th July 2024).
Regards,
Nitheeshkumar.
Hi Praveen,
Yes,
you can dynamically adjust the Y Axis Minimum and Maximum values. This can be
achieved by capturing the range of the X Axis during zooming or panning using
the ActualRangeChanged
event in the Axis. By doing so, you can obtain the data model based on the
zoomed axis range and then determine the maximum and minimum Y values from this
data.
Here is a code snippet for your reference to illustrate this:
|
<chart:SfCartesianChart.XAxes> <chart:NumericalAxis ActualRangeChanged="NumericalAxis_ActualRangeChanged"> </chart:NumericalAxis> </chart:SfCartesianChart.XAxes> |
|
private void NumericalAxis_ActualRangeChanged(object sender, ActualRangeChangedEventArgs e) { if(sender is NumericalAxis axis) { var visibleMin = axis.VisibleMinimum; var visibleMax = axis.VisibleMaximum;
ChartDataModel? minimum, maximum;
if (axis.Parent is SfCartesianChart chart && chart.BindingContext is ViewModel viewModel) { if(viewModel != null && viewModel.Data != null) { List<ChartDataModel> filteredData = viewModel.Data.Where(dp => dp.XValue2 >= visibleMin && dp.XValue2 <= visibleMax).ToList(); minimum = viewModel.Data.LastOrDefault(x => x.XValue2 < visibleMin); maximum = viewModel.Data.FirstOrDefault(x => x.XValue2 > visibleMax);
if(minimum != null) filteredData.Add(minimum); if(maximum != null) filteredData.Add(maximum);
yAxis.Minimum = Math.Round(filteredData.Min(y => y.YValue),MidpointRounding.ToNegativeInfinity); yAxis.Maximum = Math.Round(filteredData.Max(y => y.YValue),MidpointRounding.ToPositiveInfinity); } } } }
|
This approach will ensure that your Y Axis adjusts dynamically based on the visible data points during zooming or panning.
If you need any additional assistance or have further concerns, feel free to ask.
Thank you for your understanding.
Regards,
Dhanaraj Rajendran.
Attachment: YAxisRangeUpdating__Output_d0ced124.zip
The solution works.
Performance on zooming is slow even before using this code. I will create a separate thread for it .
Great communication and right on time for solution. Thanks SyncFunsion Team - Dhanaraj
and
Nitheeshkumar
Hi Praveen,
You're welcome. Glad that the issue is resolved. We will mark this thread as solved. Please let us know if you have any further assistance on this. We are happy to help.
Regards,
Preethi R
- 5 Replies
- 4 Participants
-
PD Praveen D
- Jul 12, 2024 11:49 PM UTC
- Jul 18, 2024 06:43 AM UTC