Hello Team,
I am using Sfchart and on TrackballCreated event i am creating ChartAnnotations like below example
SfSplineChart.ChartAnnotations.Add(annotation);
But after create ChartAnnotations Sfchart is not reloading only for android.
I have attached demo video below. please check
Hi Chetan,
I have reviewed the provided video. Could you let me know how the chart is modified based on the button toggle? Is the item source only modified, or is it a separate view used inside the tab view?
This information will help me reproduce the issue and assist you more effectively. If possible, please share the related code snippets.
Regards,
Saravanan.
Hello Saravanan Madheswaran,
I am rebinding the data again on chart source when i am clicking on Segment control.
Hi Chetan,
We have tried to replicate your scenario in our sample
and suspect that the binding is not set properly while changing the ItemsSource.
Could you please share the binding-related code? This will help us find the
solution more effectively.
In the meantime, we would like to inform you that Xamarin support is ending this year. We suggest transitioning this scenario to .NET MAUI. .NET MAUI offers enhanced support and ongoing updates, which should help address this issue more effectively.
Please visit our Syncfusion .Net Maui FT page
Best regards,
Nitheeshkumar
Hello Nitheesh kumar,
I am able to replicate this issue i am sharing below code also so may be will help you
This is method where we are sorting data on behalf of filter (1 month 6 month or 1 years).
private void LoadChartData(IEnumerable<EquityHistory> equityHistory)
{
if (equityHistory.Count() > 0)
{
var dataItems = equityHistory
.Select(item => new DataItem { Date = item.Date.DateTime, Value = item.Price })
.ToList();
if (!dataItems.SequenceEqual(ChartItems) && !HideOptionsByAgreements)
{
ChartItems = new ObservableCollection<DataItem>(dataItems);
}
}
}
and here is xaml code for binding. Without ChartAnnotations it is working fine but after annotation it is not.
<!--Chart-->
<controls:IndividualStockChartTemplate
Grid.Row="7"
IsTrackBallMove="{Binding IsTrackBallMove, Mode=TwoWay}"
Margin="23,32,23,10"
ChartItems="{Binding ChartItems, Mode=TwoWay}"
RollingTextValue="{Binding CurrentMarketValue, Mode=TwoWay}"
TimeFilterOptions="{Binding TimeFilterOptions}"
IsChartEmtpyStateActive="{Binding HideOptionsByAgreements}"
EmptyStateText="{x:Static resources:TextResources.EmptyStateAgreementsText}"
EmptyStateAutomationId="{x:Static resources:AutomationIdResources.EmptyStateTextAutomationId}"
EmptyStateButtonText="{x:Static resources:TextResources.ReviewAgreementsText}"
EmptyStateButtonAutomationId="{x:Static resources:AutomationIdResources.EmptyStateButtonTextAutomationId}"
EmptyStateButtonCommand="{Binding OnGoToExchangeAgreementsCommand}"
EmptyStateButtonDescription="{x:Static resources:ADAResources.EmptyStateButtonDescription}"/>
This is code for ChartAnnotations
private void SfSplineChart_TrackballCreated(System.Object sender, Syncfusion.SfChart.XForms.ChartTrackballCreatedEventArgs e)
{
try
{
IndividualStockChart.ChartAnnotations.Clear();
var chartTrackballExt = (sender as SfChart).ChartBehaviors[0] as Behaviors.ChartTrackballBehaviorExt;
var chart = sender as SfChart;
foreach (var trackballInfo in e.ChartPointsInfo)
{
if (count == 0)
{
lastAxosAccountsValue = RollingTextValue;
HapticFeedback.Perform(HapticFeedbackType.Click);
}
if (chartTrackballExt.IsMoving)
{
var textColor = Application.Current.UserAppTheme == OSAppTheme.Dark ? (Color)Application.Current.Resources["NeutralSlate500"] : (Color)Application.Current.Resources["NeutralSlate500"];
var annotation = new TextAnnotation()
{
Y1 = 10,
LabelStyle = new ChartAnnotationLabelStyle
{
FontSize = 12,
TextColor = textColor,
FontFamily = Application.Current.Resources["roboto-regular"].ToString(),
HorizontalTextAlignment = ChartAnnotationAlignment.Start,
},
CoordinateUnit = ChartCoordinateUnit.Pixels,
};
if (DeviceInfo.Platform == DevicePlatform.iOS)
{
annotation.X1 = trackballInfo.XPosition > chart.Bounds.Width * .9 ? trackballInfo.XPosition - 5 :
trackballInfo.XPosition < chart.Bounds.Width * .30 ? trackballInfo.XPosition + 78 :
trackballInfo.XPosition + 30;
}
else
{
var androidXPosition = trackballInfo.XPosition / DeviceDisplay.MainDisplayInfo.Density;
annotation.X1 = androidXPosition > chart.Bounds.Width * .9 ? trackballInfo.XPosition - 5 :
androidXPosition < chart.Bounds.Width * .30 ? trackballInfo.XPosition + (chart.Bounds.Width * .8) :
trackballInfo.XPosition + (chart.Bounds.Width * .26);
}
IndividualStockChart.ChartAnnotations.Add(annotation);
var currentData = trackballInfo.DataPoint as DataItem;
annotation.Text = currentData.Date.Value.ToString("MMM dd, yyyy");
if (currentData.Date != lastDataItem.Date && currentData.Value != lastDataItem.Value)
{
HapticFeedback.Perform(HapticFeedbackType.Click);
}
lastDataItem = currentData;
}
var trackballLabelText = trackballInfo.Label;
RollingTextValue = double.Parse(trackballLabelText);
count++;
}
}
catch (Exception ex)
{
}
}
Hi Chetan,
Thank you for the information. We will incorporate the provided code snippet into our sample to identify where the issue occurs. We need some time to validate this, and we will update you on the status within two working business days, by August 5, 2024.
Regards,
Nitheeshkumar.
Hi Chetan,
We apologize for the inconvenience. We are currently preparing the sample based on your input and are almost finished. We will share the investigation details and status by tomorrow, August 6, 2024. Thank you for your patience.
Regards,
Nitheeshkumar.
Hi Chetan,
We would like to inform you that we were able to
reproduce the issue where the ItemsSource does not get triggered when an annotation is
added to the chart using segmented control. We need time to validate this
scenario from various aspects on our end. We will update you with more details
by August 8, 2024.
Thank you for your patience and understanding. If you need further assistance, please let us know.
Regards,
Nitheeshkumar.
Hi Chetan,
We would like to inform you that we changed the ItemsSource with two scenarios: by clearing the ItemsSource and adding items, and by directly changing the ItemsSource. In both scenarios, we were able to reproduce your issue.
Is there any other scenario you would like us to add based on your requirement? If yes, could you please revert the changes by modifying the sample or provide details in text? This will help us provide a better and more precise solution.
Mean time we are working on the reported issue will update you the further details in two business days (Aug 9,2024), thanks for the understanding.
Regards,
Nitheeshkumar.
Hello Nitheesh kumar,
No i have not any another case. I am waiting for your response.
Hi Chetan,
We would like to inform you that we suspect a new
instance of the annotation is being created each time the trackball moves,
which may cause memory retention. To address this, we recommend clearing the
annotations before adding a new ItemsSource. We have modified the sample accordingly and
attached it for your reference.
In the meantime, we would like to inform you that Xamarin support is ending this year. We suggest transitioning this scenario to .NET MAUI. .NET MAUI offers enhanced support and ongoing updates, which should help address this issue more effectively.
Please visit our Syncfusion .Net Maui FT page
Please let us know if you need any further assistance or have any concerns.
Regards,
Nitheeshkumar.