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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Tooltip with custom text for SfChart series

Thread ID:

Created:

Updated:

Platform:

Replies:

129399 Mar 15,2017 11:45 PM UTC Mar 17,2017 03:28 AM UTC WPF 3
loading
Tags: SfChart
llllllllll
Asked On March 15, 2017 11:45 PM UTC

I want each point in my series to show a tooltip with some custom text when my mouse hovers over it. The tooltip should be something like "IdNumber, Xvalue, Yvalue". I have no problem getting the X and Y values to show but I don't know how to bind some identification number IdNumber for each point. Please help.


This is what I have now
=============================================

// New up the series and add to chart

var series = new FastScatterBitmapSeries();

chart.Series.Add(series);

// Series Data Binding

series.ItemsSource = plotPoints;

series.XBindingPath = "X";

series.YBindingPath = "Y";

series.ScatterHeight = 4;

series.ScatterWidth = 4;

// Series Tooltips

series.ShowTooltip = true;

var template = new DataTemplate();

var txtblock = new FrameworkElementFactory(typeof(TextBlock));

txtblock.SetValue(TextBlock.WidthProperty, 85.0);

txtblock.SetValue(TextBlock.HeightProperty, 25.0);

txtblock.SetValue(TextBlock.VerticalAlignmentProperty, VerticalAlignment.Center);

txtblock.SetValue(TextBlock.HorizontalAlignmentProperty, HorizontalAlignment.Center);

txtblock.SetValue(TextBlock.FontSizeProperty, 15.0);

var binding = new Binding();

binding.Path = new PropertyPath("ToolTip"); // This works for YData but how do I bind it to a custom ToolTip text

txtblock.SetValue(TextBlock.TextProperty, binding);

FrameworkElementFactory grid = new FrameworkElementFactory(typeof(StackPanel));

grid.AppendChild(txtblock);

template.VisualTree = grid;

series.TooltipTemplate = template;

=============================================



This is my PlotPoint class that has a custom tooltip text for each X,Y point


=============================================

private class PlotPoint




{



public PlotPoint(double x, double y, string toolTip=null)




{



X = x;


Y = y;


ToolTip = toolTip;




}



public double X { get; set; }


public double Y { get; set; }


public string ToolTip { get; set; }




}

=============================================







Devi Aruna Maharasi Murugan [Syncfusion]
Replied On March 16, 2017 12:03 PM UTC

Hi Keenan, 
  
Thanks for contacting Syncfusion Support. 
  
Since we can get the corresponding data model value from the tooltip’s datacontext as Item, we are able to bind any of the model property in tooltip as shown in the below code snippet, 
 
Model.CS 
 
public class Model 
    { 
        public double XValue { get; set; } 
        public double YValue { get; set; } 
        public string IDNum { get; set; } 
    } 
 
 
Tooltip text Binding 
 
  var binding = new Binding(); 
 
  binding.Path = new PropertyPath("Item.IDNum"); //corresponding model of the fast     
                                                   scatter as Item 
 
  txtblock.SetValue(TextBlock.TextProperty, binding); 
  
We have prepared the demo sample based on the provided code snippet and it can be downloaded from below link, 
Sample: CustomTooltip 
  
Please find the output screenshot, 
 
Regards, 
Devi 





llllllllll
Replied On March 16, 2017 03:31 PM UTC

Thank you that worked!

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On March 17, 2017 03:28 AM UTC

Hi Keenan, 
  
Thanks for your update. 
  
Please let us know, if you need any further assistance on this. 
  
Regards, 
Devi 


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

;