Refreshing the chart will not showing the X-axis lables

2 posts, 0 answers
  1. chandra
    chandra avatar
    21 posts
    Member since:
    Apr 2008

    Posted 11 Jun 2008 Link to this post

    hi,

    I have drawn the Gantt chart with date on X-axis, time on Y-axis.
    I  have added the range of the X-Axis using the following Statement

    radChart1.PlotArea.XAxis.AddRange(GraphStartTime.ToOADate(), GraphStartTime.AddDays(7).ToOADate(), 1);

    I have set the Y-AxisLabel text to "XYZ".

    My requirement is to change the AxisLabel text to "ABC", when the user clicks on the button.

    I add the following code:
    private void btnChangeAxisLabel_Click(object sender, EventArgs e)
    {
                radChart1.PlotArea.YAxis.AxisLabel.TextBlock.Text = "XYZ";
                radChart1.Refresh();
                radChart1.UpdateGraphics();
                radChart1.Update();
    }


    It is changing the AxisLabel text to "ABC".
    But X-Axis ChartAxisItem's TextBlock.Text is not appearing(i.e The dates what i have added to X-axis is not appearing).

    Please share the sample code.




               
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 13 Jun 2008 Link to this post

    Hello chandra,

    Are the X-axis items' labels visible before you change the Y-AxisLabel or the X-Axis items' labels get hidden when you set the new Y-AxisLabel? We cannot reproduce the issue locally. Here is a sample code, that changes the Y-AxisLabel while the X-axis items' labels stay visible (do not change):
    1 public Form1() 
    2
    3     InitializeComponent(); 
    4
    5  
    6 protected override void OnLoad(EventArgs e) 
    7
    8     base.OnLoad(e); 
    9  
    10     Random r = new Random(42); 
    11  
    12     radChart1.PlotArea.XAxis.AutoScale = false
    13     radChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.LongDate; 
    14     radChart1.PlotArea.XAxis.Appearance.CustomFormat = "MMMM dd, yyyy"
    15     radChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = -60; 
    16     radChart1.PlotArea.XAxis.AddRange(DateTime.Today.ToOADate(), DateTime.Today.AddDays(7).ToOADate(), 1); 
    17     radChart1.PlotArea.YAxis.AxisLabel.Visible = true
    18     radChart1.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Initial text (ABC)"
    19  
    20     for (int i = 0; i < 10; i++) 
    21         this.radChart1.Series[0].AddItem(Math.Round(r.NextDouble() * 100)); 
    22
    23  
    24 private void radChart1_Click(object sender, ChartClickEventArgs args) 
    25
    26     radChart1.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Another text (XYZ)"
    27     radChart1.Refresh(); 
    28
    Note, that the range on X-axis is added before adding items to the Series.

    Let us know if this example helps.

    Regards,
    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
Back to Top