Mouse hover tooltip in bar chart

Thread is closed for posting
5 posts, 0 answers
  1. Keith Stephens
    Keith Stephens avatar
    83 posts
    Member since:
    May 2010

    Posted 17 May 2011 Link to this post

    Hello,
    I followed the example here: http://demos.telerik.com/aspnet-ajax/controls/examples/integration/chartandtooltip/defaultcs.aspx?product=chart which uses a line chart.  works fine in my bar chart for one series, but my chart has 2 series (Sold, and Proposed)
    Is it possible to have the tooltip hover to show both series for the one employee.

    My chart is that I have employee names along the x axis and amounts on the y axix and each employee has 2 series (Sold and Proposed) I want to hover my mouse over the bars but show both series values.
    Thanks,
    Keith.
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 19 May 2011 Link to this post

    Hi Keith,

    The main part of the logic is handled in the following code:

    protected void RadChart1_ItemDataBound(object sender, Telerik.Charting.ChartItemDataBoundEventArgs e)
           {
               if (e.SeriesItem.YValue > 30)
               {
                   e.SeriesItem.ActiveRegion.Tooltip = "Attention! Temperature too high! " + '\n';
               }
               else if (e.SeriesItem.YValue < 10)
               {
                   e.SeriesItem.ActiveRegion.Tooltip = "Attention! Temperature too low! " + '\n';
               }
               e.SeriesItem.ActiveRegion.Tooltip += ((DataRowView)e.DataItem)["Measurement"].ToString() + ": Temperature: " + e.SeriesItem.YValue;
           }

    this can be done for more than one series as well. Give this approach a try and let me know how it goes and if any other questions arise.

    All the best,
    Yavor
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sampath
    Sampath avatar
    12 posts
    Member since:
    Mar 2013

    Posted 20 Jun 2013 Link to this post

    how do u  handle it for both series ?

    because i have the same question. i need to show details of two series for one data point.

    currently im using the following

    protected void RadChart1_ItemDataBound(object sender, ChartItemDataBoundEventArgs e)
        {
            if (RadChart1.PlotArea.XAxis.DataLabelsColumn == "bel")
            {
                string selectionTemp = Session["selection"].ToString();

                string selection = selectionTemp.Substring(1);

                string[] arry = selection.Split('/');

                string belContact = ((DataRowView)e.DataItem)["bel"].ToString();

                string querry = "SELECT [taskType],[buyerContact],Week " +
                                         "FROM [customerRelationshipIndexDB].[dbo].[V_Dashboard] " +
                                         "where Week between " + db.GetWeekNumber(RadDatePicker1.SelectedDate.Value) + " and " +                      db.GetWeekNumber(RadDatePicker2.SelectedDate.Value) + "  and CBU = '" + arry[0] + "' and brand = '" + arry[1] + "' and account='" + arry[2] + "' and [BEL Contact] = '" + belContact + "' " +
                                "order by Week,[taskType],[buyerContact]";

                e.SeriesItem.ActiveRegion.Tooltip += db.GetDrillDownDetail(querry);

            }
        }

    I need to run two querries for the two series. how can i differentiate between the two series? 
    Please help :)
  5. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 24 Jun 2013 Link to this post

    Hi Sampath,

    The ChartItemDataBoundEventArgs provides a reference to the currently created series item, the data item from which it was created, and the series to which it belongs. You can use the ChartSseries.Name property to differentiate between different series. Here's an example: 
    void RadChart1_ItemDataBound(object sender, ChartItemDataBoundEventArgs e)
    {
        DataRow dataItem = ((DataRowView)e.DataItem).Row;
     
        ChartSeriesItem seriesItem = e.SeriesItem;
     
        ChartSeries series = e.ChartSeries;
     
        var seriesName = series.Name;
     
        if (seriesName == "Series A")
            //...
    }

    I hope this helps.
     

    Regards,
    Petar Kirov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Sampath
    Sampath avatar
    12 posts
    Member since:
    Mar 2013

    Posted 02 Jul 2013 Link to this post

    sorry for the delay in replying. yes this helps. it solved my issue, thank you very much.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017