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

Creating an event handler for chartitemdatabound

5 Answers 219 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 04 May 2009, 06:18 PM
I need a chartitemdatabound event handler to change how my labels are displayed for a pie chart.  The following code I saw in another forum is throwing an error.

this.chart1.ItemDataBound += new EventHandler<ChartItemDataBoundEventArgs>(chart1_ItemDataBound);

Cannot implicitly convert type 'System.EventHandler<Telerik.Reporting.Charting.ChartItemDataBoundEventArgs>' to 'System.EventHandler' 

Am I missing a using directive or something obvious?

Rich




5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 05 May 2009, 09:13 AM
Hi Richard,

Here is the proper way to attach an event handler:

this.chart1.ItemDataBound += new EventHandler(chart1_ItemDataBound); 
 
private void chart1_ItemDataBound(object sender, EventArgs e) 
 

However you do not have to do this manually, but can wire it up from the events tab in the properties grid (see attached screenshot).

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Richard
Top achievements
Rank 1
answered on 05 May 2009, 12:47 PM
Thanks for the response, however, what I am trying to do will not work with the normal system.eventargs.

The following link is a post on the telerik forums that describes what I am trying to do, however, it is related to the radchart for winforms.

I would like to implement this for the chart in a telerik report.

http://www.telerik.com/community/forums/winforms/chart/xaxis-label-inside-the-bar.aspx

Thanks,

Rich





0
Accepted
Steve
Telerik team
answered on 05 May 2009, 01:16 PM
Hi Richard,

You have two options:
  1. Do this through the report designer by using the chart's ChartSeriesItem Editor (see attached screenshots)
  2. Through code - however you would need to use the NeedDataSource event when you want to alter the chart definition item and not the ItemDataBound event. The code is almost identical:

     private void chart2_NeedDataSource(object sender, EventArgs e) 
            { 
                Telerik.Reporting.Processing.Chart procChart = (Telerik.Reporting.Processing.Chart)sender; 
                Telerik.Reporting.Chart defChart = (Telerik.Reporting.Chart)procChart.ItemDefinition; 
                defChart.Series[0].Items[0].Label.TextBlock.Text = "New Label"
                defChart.Series[0].Items[0].Label.Appearance.LabelLocation = Telerik.Reporting.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Inside; 
            } 

    Note that we set those properties to the definition chart item and not to its processing counterpart. More info on definition vs. processing is available in this help article.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Richard
Top achievements
Rank 1
answered on 05 May 2009, 03:07 PM
Thanks.

The screen shots did not post, however.

Rich
0
Steve
Telerik team
answered on 05 May 2009, 03:38 PM
Hello Richard,

They have been omitted from my previous post for some reason - here they are again.

Regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Richard
Top achievements
Rank 1
Answers by
Steve
Telerik team
Richard
Top achievements
Rank 1
Share this question
or