- Home
- Forum
- Xamarin.Forms
- Tooltip customization
Tooltip customization
Thanks for contacting Syncfusion support.
We have prepared a sample for getting data from model to customize the tooltip content and it can be downloaded from the following location.
Sample: http://www.syncfusion.com/downloads/support/forum/123456/ze/TooltipCustomize976660311
Regards,
Manivannan E.
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;
}
}
We are unable to comprehend your exact requirement. However, we have prepared a sample to customize the trackball label content, by getting data from model and it can be downloaded from the following location.
Sample: http://www.syncfusion.com/downloads/support/forum/123456/ze/Trackball1584514824
If the provided sample does not meet your requirement, could you please provide more details or screenshot regarding your requirement, which would be helpful for us to serve you better.
Regards,
Manivannan E.
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.
Thanks for the update. Please let us know if have any other queries.
Regards,
Manivannan E.
- 8 Replies
- 3 Participants
-
AL Alex
- Mar 18, 2016 02:48 PM UTC
- Apr 1, 2016 05:33 AM UTC