public class CSfChartRenderer : Syncfusion.SfChart.XForms.Droid.SfChartRenderer
{
private SfChart _nativeChart;
private Syncfusion.SfChart.XForms.SfChart _formsChart;
protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Syncfusion.SfChart.XForms.SfChart> e)
{
base.OnElementChanged(e);
_nativeChart = Control;
_formsChart = e.NewElement;
_nativeChart.TooltipCreated += sfChart_TooltipCreated;
_nativeChart.LabelsGenerated += sfChart_LabelsGenerated;
}
void sfChart_LabelsGenerated(object sender, Com.Syncfusion.Charts.SfChart.LabelsGeneratedEventArgs e)
{
IList<ChartPointInfo> infos = e.P1 as IList<ChartPointInfo>;
for (int i = 0; i < infos.Count; i++)
{
ChartPointInfo pointInfo = infos[i];
pointInfo.Label = SetTooltip(pointInfo.ChartDataPoint);
}
}
private void sfChart_TooltipCreated(object sender, SfChart.TooltipCreatedEventArgs e)
{
e.P1.Label = SetTooltip(e.P1.ChartDataPoint);
}
private string SetTooltip(ChartDataPoint chartDataPoint)
{
int index = -1;
System.Collections.IList data = null;
int count = _nativeChart.Series.Size();
for (int i = 0; i < count; i++)
{
index = ((ArrayList)((ChartSeries)_nativeChart.Series.Get(i)).DataSource).IndexOf(chartDataPoint);
if (index > -1)
{
data = _formsChart.Series[i].ItemsSource as System.Collections.IList;
break;
}
}
if (index > -1 && data != null)
return (data[index] as ChartPointValue).ToolTip.ToString();
return string.Empty;
}
}
IList data = Chart.Series [0].ItemsSource as IList;
Is it more clear?
Thanks fo your help
Hi Alexandre,
We are able to achieve your requirement by using the following
code snippet.
nint seriesIndex = chart.IndexOfSeries (tooltipView.Series); |
Please let us know, if you have any queires.
Thanks,
Karthikeyan V.