2D Chart for WinForms | ComponentOne
Chart for WinForms Task-Based Help / Add ToolTips to Chart Elements / Add ToolTips to Chart's Points in the Data Series
In This Topic
    Add ToolTips to Chart's Points in the Data Series
    In This Topic

    To add ToolTips to the Chart's DataSeries, complete the following steps:

    1. Add C1Chart to the Form.
    2. Add the following directive to declare the C1.Win.C1Chart namepace:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Imports C1.Win.C1Chart
      

      To write code in C#

      C#
      Copy Code
      using C1.Win.C1Chart;
      
    3. Add the following code in the Form_load procedure to declare the dataseries and add the tooltips to the dataseries:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      C1Chart1.ToolTip.Enabled = True
      Dim sc As ChartDataSeriesCollection = C1Chart1.ChartGroups(0).ChartData.SeriesList 
      For Each ds As ChartDataSeries In sc
          ds.TooltipText = "Series: {#TEXT}" + ControlChars.Cr + ControlChars.Lf + "x = {#XVAL}" + ControlChars.Cr + ControlChars.Lf + "y = {#YVAL}"
      Next ds
      

      To write code in C#

      C#
      Copy Code
      ChartDataSeriesCollection sc =
      c1Chart1.ChartGroups[0].ChartData.SeriesList; 
        foreach (ChartDataSeries ds in sc)
           ds.TooltipText = "Series: {#TEXT}" + '\r' + '\n' + "x = {#XVAL}" + '\r' + '\n' + "y = {#YVAL}";
      // Enable tooltip
      c1Chart1.ToolTip.Enabled = true;
      

      This topic illustrates the following:

      When you hover over the points in the data series on the chart area at run time, the tooltips appear for each point, like the following:


    See Also