Change axis plot values after databind?

4 posts, 1 answers
  1. joseph_korn
    joseph_korn avatar
    21 posts
    Member since:
    Apr 2007

    Posted 21 May 2008 Link to this post

    For example, if I am binding my chart to a dataset I could write some code like this:

    Me.RadChart1.DataManager.DataSource = myDataSet 
    Me.RadChart1.DataManager.ValuesXColumn = "SomeValue" 

    Is it possible, after a databind, to get access to those plot values of "SomeValue" so that they can be updated later on? I realize that I could change the dataset value and rebind if needed, but I am wondering if it is possible to get access to the values in the chart once they are bound.
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 22 May 2008 Link to this post

    Hi Joseph,

    Thank you for writing.

    You can manipulate the data after the data binding by simply accessing the items in the required series:

    1 Me.RadChart1.DataManager.DataSource = myDataSet  
    2 Me.RadChart1.DataManager.ValuesXColumn = "SomeValue" 
    3 Me.RadChart1.DataManager.DataBind() 
    4 Me.radChart1.Series(0).Items(0).YValue = 15 

    Should you have further questions, do not hesitate to write us back.

    Sincerely yours,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. joseph_korn
    joseph_korn avatar
    21 posts
    Member since:
    Apr 2007

    Posted 27 May 2008 Link to this post

    Thanks for the reply, but now after reading my original post, I realize that I was not using the correct terms.. The data I am looking to change is not the plot values, but the plot labels..

    I wish to change the labels of the x or y axis after databind if it is possible.. Is there any way?
  5. Answer
    Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 29 May 2008 Link to this post

    Hi Joseph,

    It is possible to change the labels on both axes. What you should do is handle the BeforeLayout event. At this point the labels are already created, and you can change their values to the required ones. Here is an example:

    1 Public Sub New() 
    2     InitializeComponent() 
    3  
    4     AddHandler Me.radChart1.BeforeLayout, AddressOf radChart1_BeforeLayout 
    5 End Sub 
    6  
    7 Private Sub radChart1_BeforeLayout(ByVal sender As ObjectByVal e As EventArgs) 
    8     Dim i As Integer = 0 
    9     While i < Me.radChart1.PlotArea.YAxis.Items.Count 
    10         Me.radChart1.PlotArea.YAxis.Items(i).Appearance.RotationAngle = 20 
    11         Me.radChart1.PlotArea.YAxis.Items(i).TextBlock.Text = String.Format("new label {0}", i) 
    12         i = i + 1 
    13     End While 
    14 End Sub 

    I hope this example will help.
    If you have further questions, drop us a line. We will be glad to help.

    Regards,
    Evtim
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top