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

Refreshing the chart will not showing the X-axis lables

1 Answer 43 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
chandra
Top achievements
Rank 1
chandra asked on 11 Jun 2008, 12:56 PM
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.




           

1 Answer, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 13 Jun 2008, 09:16 AM
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):
public Form1() 
    InitializeComponent(); 
 
protected override void OnLoad(EventArgs e) 
    base.OnLoad(e); 
 
    Random r = new Random(42); 
 
    radChart1.PlotArea.XAxis.AutoScale = false
    radChart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.LongDate; 
    radChart1.PlotArea.XAxis.Appearance.CustomFormat = "MMMM dd, yyyy"
    radChart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = -60; 
    radChart1.PlotArea.XAxis.AddRange(DateTime.Today.ToOADate(), DateTime.Today.AddDays(7).ToOADate(), 1); 
    radChart1.PlotArea.YAxis.AxisLabel.Visible = true
    radChart1.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Initial text (ABC)"
 
    for (int i = 0; i < 10; i++) 
        this.radChart1.Series[0].AddItem(Math.Round(r.NextDouble() * 100)); 
 
private void radChart1_Click(object sender, ChartClickEventArgs args) 
    radChart1.PlotArea.YAxis.AxisLabel.TextBlock.Text = "Another text (XYZ)"
    radChart1.Refresh(); 
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
Tags
Chart (obsolete as of Q1 2013)
Asked by
chandra
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Share this question
or