We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ChartToolTipBehavior LabelFormat

Thread ID:

Created:

Updated:

Platform:

Replies:

132954 Sep 30,2017 06:27 AM Oct 2,2017 12:46 AM Xamarin.Android 1
loading
Tags: SfChart
Albert K
Asked On September 30, 2017 06:27 AM

Hi,

I have a DateTimeAxis as the PrimaryAxis  and a NumbericAxis as the SecondaryAxis.  How do I display the DateTime and Values in the tooltip ?  
Ii have the code below but it is not displaying the Date and Time.   Thank you.

chartTop.Behaviors.Add(new ChartTooltipBehavior() { LabelFormat = "dd/MM/yy hh:mm" });


Parthiban Sundaram [Syncfusion]
Replied On October 2, 2017 12:46 AM

Hi Albert, 
  
Thanks for using Syncfusion products. 
  
You can achieve this requirement by overriding the GetView method in ChartTooltipBehavior class. Please refer the following code snippet for more details. 
  
Code Snippet: 
 
   protected override View GetView(TooltipView tooltipView) 
        { 
            LinearLayout rootLayout = new LinearLayout(Chart.Context); 
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, 
                    LinearLayout.LayoutParams.MatchParent); 
            rootLayout.Orientation = Orientation.Vertical; 
            rootLayout.LayoutParameters = layoutParams; 
            TextView xLabel = new TextView(Chart.Context); 
            string date = (tooltipView.ChartDataPoint as DataModel).XValue.ToString(); 
            var doubleToDate = DateTime.FromOADate(Convert.ToDouble(date)); 
            var formattedDate = doubleToDate.ToString("dd/MM/yy hh:mm"); 
            xLabel.Text = "Date:" + formattedDate.ToString(); 
            xLabel.TextSize = 15; 
            xLabel.SetTextColor(Color.White); 
            TextView yLabel = new TextView(Chart.Context); 
            yLabel.Text = "YValue: " + (tooltipView.ChartDataPoint as DataModel).YValue.ToString(); 
            yLabel.TextSize = 15; 
            yLabel.SetTextColor(Color.White); 
            rootLayout.AddView(xLabel); 
            rootLayout.AddView(yLabel); 
            tooltipView.AddView(rootLayout); 
            return tooltipView; 
        } 
  
We have prepared the sample based on your requirement. Please download the sample from following location. 
  
  
Please let us know, if you need further assistance on this. 
  
Regards,
Parthiban S
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;