Jump to content
Software FX Community

Axis labels repeating out of sequence


Jbassking
 Share

Recommended Posts

I need to display labels on the X-Axis instead of numbers. For example wk1, wk2, wk3, etc...

The problem we're getting is that the labels don't match the values as they were added and in some cases the labels just aren't correct.

In a vertical bar chart the X-Axis display wk2, wk4, wk6, wk8 and so on. The first two bars however are for wk22 and wk1. The data for wk22 was the first data point added but the data for wk1 was added about 20 points later.

The second set of bars is wk23 and wk2.

Does the data have to be in a certain order when added?

We've also seen labels repeated. For example we used labels such as 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008. (Yes this can be done using the Data points instead of the labels). The labels ended up displaying as:

2001, 2004, 2005, 2007, 2008, 2007, 2007, 2008

This is a scatter chart.

Link to comment
Share on other sites

The data you see is the data in the chart.

So whatever problem you are having is when passing the data to the chart not when the data is displayed.

This will require a sample program that reproduces the problem. With the binary file, all I can say is that the chart is behaving the way is supposed to. The data it has is the data that is showing.

Link to comment
Share on other sites

Here is the problem:

With Load Scatter, you are assigning:

chart1.AxisX.Labels[p] = XValue.ToString();

Inside a a nested loop of s and p. So, for a given p you are doing this s times. However, some of the X-Values are null and therefore skipped in your code. What you end up with is a mix of the labels of all passes.

You need to figure out which labels you want to display, the labels for which series? Do you want to synchronize all series so that all labels match. You will have to write some code to do this. This is not what you are currently doing. You are simply passing the data as it comes.

With Load Bar:

When passing DateTime X-Values, the dates must be SORTED from lowest to highest. Yours are not.

Link to comment
Share on other sites

If you test the code there are no skipped labels. I do have to make a slight change so if there is no XValue then no Y will be set. This still doesn't make sense as to why the Axis labels show the way they do. Why would it repeat 2007 after 2008. 

The Load Bar doesn't use DateTime values so I don't know why you say they need to be sorted.

 

Link to comment
Share on other sites

> If you test the code there are no skipped labels. I do have to make a slight change so if there is no XValue then no Y will be set. This still doesn't make

> sense as to why the Axis labels show the way they do. Why would it repeat 2007 after 2008. 

Please run your code in the debugger and you will see that:

chart1.AxisX.Labels[p]

Is being assigned multiple times for the same p (s = 0..9). The last round (s = 9) only assigns (0...4) the rest (5..9) remains there from previous rounds.

> The Load Bar doesn't use DateTime values so I don't know why you say they need to be sorted.

My mistake. I tought this code was going throug this line:

chart1.Data.X[s, p] =

Convert.ToDateTime(XValue).ToOADate();Indeed this is the same problem as before. You are overriding labels in succesive passes. When you debugg you will see that the last time

chart1.AxisX.Labels[0] gets assigned (s = 1), it is assigned to "wk1" overriding the previous value of "wk22". This is what your code is doing.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...