Drawing ToolTips in C1Chart for WPF

To increase the performance in C1Chart for WPF, Line and Symbol Charts, containing large amount of data one can set the DataSeries.RenderMode property to RenderMode.Bitmap. However, on setting the RenderMode to Bitmap the Data point labels, tooltips and PlotElementLoaded event are not available. This blog explains an approach to show ToolTips in a Scatter Chart with RenderMode set to 'Bitmap' : ToolTipInChart The ToolTips here are implemented using the ChartPanelObject and adding the ChartPanel as a Layer in the chart.


Let's have a look at the steps being taken to accomplish the same :

  1. Create a ChartPanel and ChartPanelObject
  2. Add the information, which is to be displayed in the ToolTip, in the ChartPanelObject
  3. Set the corresponding Action and Attach properties of the ChartPanelObject
  4. Add the ChartPanelObject to the ChartPanel.Children collection and the corresponding ChartPanel object to the View.Layers collection of the chart

Here is the complete code for the above implementation :

var pnl = new ChartPanel();  

var obj = new ChartPanelObject()  
 HorizontalAlignment = HorizontalAlignment.Right,  
 VerticalAlignment = VerticalAlignment.Bottom  

var bdr = new Border()  
 Background = new SolidColorBrush(Colors.Blue) { Opacity = 0.6 },  
 BorderBrush = new SolidColorBrush(Colors.Blue),  
 BorderThickness = new Thickness(1, 1, 3, 3),  
 CornerRadius = new CornerRadius(6, 6, 0, 6),  
 Padding = new Thickness(3)  

var sp = new StackPanel();  

var tb1 = new TextBlock();  
var bind1 = new Binding();  
bind1.Source = obj;  
bind1.StringFormat = "x={0:#.##}";  
bind1.Path = new PropertyPath("DataPoint.X");  
tb1.SetBinding(TextBlock.TextProperty, bind1);  

var tb2 = new TextBlock();  
var bind2 = new Binding();  
bind2.Source = obj;  
bind2.StringFormat = "y={0:#.##}";  
bind2.Path = new PropertyPath("DataPoint.Y");  
tb2.SetBinding(TextBlock.TextProperty, bind2);  


bdr.Child = sp;  

obj.Content = bdr;  
obj.DataPoint = new Point();  
obj.Action = ChartPanelAction.MouseMove;  
obj.Attach = ChartPanelAttach.DataXY;  



Download Sample CS Download Sample VB


GrapeCity Developer Tools
comments powered by Disqus