This is a migrated thread and some comments may be shown as answers.

ItemToolTipOpening is not firing

1 Answer 54 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 06 Jan 2012, 12:35 AM
Hi,
I create my chart in code behind, I do not use seriesMapping, I add dataseries to my chart like this:
 /// <summary>
        /// Add dataseries to chart
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="chart"></param>
        /// <param name="seriesDef"></param>
        /// <param name="data"></param>
        public static void CreateDataSeries<T>(this RadChart chart, CustomSeriesDefinition<T> seriesDef, IEnumerable<T> data)
        {
            //if already there, do nothing
            if (chart.DefaultView.ChartArea.DataSeries.Any(s => s.LegendLabel == seriesDef.LegendLabel))
                return;

            var dataSeries = ChartGenerator.CreateDefaultDataSeries(seriesDef);
            if (seriesDef.IsVisableInLegend)
                dataSeries.LegendLabel = seriesDef.LegendLabel;
            foreach (var dataElement in data)
            {
                var point = seriesDef.Compute(dataElement);
                dataSeries.Add(point);

            }
            chart.DefaultView.ChartArea.DataSeries.Add(dataSeries);
        }
and the CustomSeriesDefinition is defined here
  public CustomSeriesDefinition(string legendLabel, SeriesDefinition chartType, Func<T, DataPoint> compute, bool isVisableInLegend, bool showItemToolTips = false)
        {
            
            ChartType = chartType;
            ChartType.ShowItemToolTips = showItemToolTips;
           
            Compute = compute;
            IsVisableInLegend = isVisableInLegend;
            LegendLabel = legendLabel;

        }
When I set the ShowItemToolTip = true, I never get the event firing for ItemToolTipOpening. Do I have to use SeriesMapping to use this event?

1 Answer, 1 is accepted

Sort by
0
Rahul
Top achievements
Rank 2
answered on 06 Jan 2012, 05:37 AM
Hi Joe,
        
Try registering event for tooltip in following way.

radChart.DefaultView.ChartArea.ItemToolTipOpening+=new ItemToolTipEventHandler(ChartArea_ItemToolTipOpening);
 
void ChartArea_ItemToolTipOpening(ItemToolTip2D tooltip, ItemToolTipEventArgs e)
{
tooltip.Content = "Disease Name : " + DiseaseName + "\n" +
                              "# of Pts     : " + TotalPatientCount + "\n"
                            + "% of Pts     : " + intPercentage;
 }


Regards,
Rahul
Tags
Chart
Asked by
Joe
Top achievements
Rank 1
Answers by
Rahul
Top achievements
Rank 2
Share this question
or