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:
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)
Now this code doesn't do anything, unless I add:
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
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!