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

DrillDown YValue2

2 Answers 55 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Chris Wilson
Top achievements
Rank 1
Chris Wilson asked on 28 Aug 2008, 07:39 PM
Hi,

I have implemented drilldown on my chart and all is working fine in that I can get my Yvalue from the args.SeriesItem.

However, I am unable to get the YValue2 that I set using the series.DataYColumn2.

Before I spend anymore time trying to find out where I've gone wrong could someone let me know if it is indeed possible to get hold of the YValue2 in a chartclick postback?

Thanks
Chris

2 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 29 Aug 2008, 11:48 AM
Hello Chris Wilson,

We assume you have implemented a drill-down on a bar series type -- as the bar depends only a single YValue, when databinding the DataYColumn2 value is ignored and the YValue2 value is not bound at all.

Still, if you would like to supply such value you can handle the ItemDataBound event and set the YValue2 manually like this:

ASPX:
<telerik:RadChart ID="RadChart1" runat="Server" OnClick="RadChart1_Click"  
    OnItemDataBound="RadChart1_ItemDataBound"
</telerik:RadChart> 

Code-behind:
protected void Page_Load(object sender, EventArgs e) 
    if (!IsPostBack) 
    { 
        DataTable dt = new DataTable(); 
        dt.Columns.Add("YColumn", typeof(double)); 
        dt.Columns.Add("YColumn2", typeof(double)); 
 
        DataRow dr = dt.NewRow(); 
        dr[0] = 10; 
        dr[1] = 33; 
        dt.Rows.Add(dr); 
 
        DataRow dr2 = dt.NewRow(); 
        dr2[0] = 20; 
        dr2[1] = 44; 
        dt.Rows.Add(dr2); 
 
        ChartSeries series = new ChartSeries(); 
        series.DataYColumn = "YColumn"
 
        RadChart1.Series.Add(series); 
 
        RadChart1.DataSource = dt
        RadChart1.DataBind(); 
    } 
 
protected void RadChart1_ItemDataBound(object sender, ChartItemDataBoundEventArgs e) 
    e.SeriesItem.YValue2 = (double)((DataRowView)e.DataItem)["YColumn2"]; 
 
protected void RadChart1_Click(object sender, ChartClickEventArgs args) 
    if (args.SeriesItem != null) 
    { 
        Response.Write(args.SeriesItem.YValue2); 
    } 


Hope this helps.


Greetings,
Manuel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Chris Wilson
Top achievements
Rank 1
answered on 29 Aug 2008, 12:24 PM
Great, that is what I needed.

Thanks for your quick response.

Chris
Tags
Chart (Obsolete)
Asked by
Chris Wilson
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Chris Wilson
Top achievements
Rank 1
Share this question
or