Hello all,
I'm learning to use the RadChart control and I'd like to ask how to dynamically get the name of the series item that generated the RadChart.Click event to use it as part of the series name for the next chart generated (ex. if the chart shows the sales volumes per month in an given year and the user clicks on the July column, the next chart should show the details for July and the series name would be "Sales details for July").
Any help would be really appreciated!
I'm learning to use the RadChart control and I'd like to ask how to dynamically get the name of the series item that generated the RadChart.Click event to use it as part of the series name for the next chart generated (ex. if the chart shows the sales volumes per month in an given year and the user clicks on the July column, the next chart should show the details for July and the series name would be "Sales details for July").
Any help would be really appreciated!
5 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 27 Sep 2012, 09:07 AM
Hello,
You can get the name of the series item on RadChart Click event as follows.
C#:
Thanks,
Princy.
You can get the name of the series item on RadChart Click event as follows.
C#:
protected
void
RadChart2_Click(
object
sender, ChartClickEventArgs args)
{
Response.Write(args.SeriesItem.Name.ToString());
}
Thanks,
Princy.
0

dajegas
Top achievements
Rank 1
answered on 27 Sep 2012, 09:40 AM
Hi Princy,
thanks for your reply, but unfortunately it does not work...
When I use the statement you posted I get a generic "Item n" value which I believe is some kind of default value.
Here is how I bind the data to the chart:
thanks for your reply, but unfortunately it does not work...
When I use the statement you posted I get a generic "Item n" value which I believe is some kind of default value.
Here is how I bind the data to the chart:
string
dlColumn =
string
.Empty;
DataTable tblSeries = FillSeries(
ref
dlColumn);
radChart.DataSource = tblSeries;
radChart.PlotArea.XAxis.DataLabelsColumn = dlColumn;
radChart.DataBound +=
new
EventHandler(radChart_DataBound);
radChart.DataBind();
0
Hi Alessio,
I believe Princy's reply is correct, however it depends on the way the ChartSeries.Name is set. If you have auto-generated series RadChart will put as their name the name of the column used to provide values (RadChart1 in the attached example -- the name is Value). If you have created the ChartSeries and assigned its DataYColumn property, then you should set its name, so that you can retrieve it in Click event handler (RadChart2 in the attached example - the name is My Series).
Best regards,
Ves
the Telerik team
I believe Princy's reply is correct, however it depends on the way the ChartSeries.Name is set. If you have auto-generated series RadChart will put as their name the name of the column used to provide values (RadChart1 in the attached example -- the name is Value). If you have created the ChartSeries and assigned its DataYColumn property, then you should set its name, so that you can retrieve it in Click event handler (RadChart2 in the attached example - the name is My Series).
Best regards,
Ves
the Telerik team
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 their blog feed now.
0

dajegas
Top achievements
Rank 1
answered on 28 Sep 2012, 09:17 AM
Hi Ves,
thanks a lot for your example, but it's having the same behavior as in my code...
I can control the Series.Name but what I'm interested in is getting the SeriesItem.Name the user has clicked on.
I changed your example in
but if I click on one of the columns I'd like to have the "Namex" printed but instead I get the usual "Itemx".
thanks a lot for your example, but it's having the same behavior as in my code...
I can control the Series.Name but what I'm interested in is getting the SeriesItem.Name the user has clicked on.
I changed your example in
protected
void
RadChart1_Click(
object
sender, Telerik.Charting.ChartClickEventArgs args)
{
Response.Write(args.SeriesItem.Name);
}
but if I click on one of the columns I'd like to have the "Namex" printed but instead I get the usual "Itemx".
0
Hi,
In order to retrieve the SeriesItem.Name it should be set properly before that. You can do this in ItemDataBound event. Please, find attached an updated version of the example.
Best regards,
Ves
the Telerik team
In order to retrieve the SeriesItem.Name it should be set properly before that. You can do this in ItemDataBound event. Please, find attached an updated version of the example.
Best regards,
Ves
the Telerik team
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 their blog feed now.