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

Chart Refresh Issue

1 Answer 88 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.
Razi
Top achievements
Rank 1
Razi asked on 28 May 2009, 04:54 PM
Hi.

I'm having a fairly frustrating problem with the chart control, that I can't get over.

I'm trying to use the same chart for different reports based on what the user chooses.

One report is using the chart by binding data to it. The other is manually populating it. The graph works in both scenarios. My problem is when I try to change the X-Axis label.

Let's take this scenario. First, I generate a databound graph. Let's say it comes back with 4 bars on the X-Axis. It looks fine and works fine.

Then I generate a report which uses the graph without databinding. Let's say it needs to display 8 bars. Now if I set:

rdChart.PlotArea.XAxis.AutoScale =

True

 


Then the graph works fine, but the x-axis item labels are marked 1,2,3,4..., which I need to change.

So I added a loop to change the X-Axis labels:

 

Dim labels() As String = lbls.Split(",")

 

 

For i = 0 To rdChart.PlotArea.XAxis.Items.Count - 1

 

rdChart.PlotArea.XAxis(i).TextBlock.Text = labels(i)

 

Next

 


Now this code doesn't do anything, unless I add: 

rdChart.PlotArea.XAxis.AutoScale =

False

 


before doing the loop.

Now that's where the problem is. If I set AutoScale to false, the Chart stops populating the X-Axis items correctly. So for example, if the the databound chart had returned 4 bars on X-Axis, then it stays at 4, even though if the new series is supposed to have 8 bars.

I have tried many different combinations of 

rdChart.Series.Clear()

rdChart.Series.ClearItems()

rdChart.PlotArea.XAxis.ClearDataBoundState()
rdChart.Update()

 

rdChart.UpdateGraphics()

rdChart.Refresh()

and then setting the AutoScale to true, and then setting it back to false, but nothing seems to clear up the X-Axis display correctly. The number of X-Axis items displayed is not refreshing if I trun AutoScale off, and I can't set the X-Axis item labels if it's on. HELP!

1 Answer, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 01 Jun 2009, 01:38 PM
Hi Razi,

I would suggest to keep the AutoScale to true and use the BeforeLayout event to change the labels' text. Let me know if that works for your case.

All the best,
Evtim
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Chart (obsolete as of Q1 2013)
Asked by
Razi
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Share this question
or