Jbassking Posted June 18, 2008 Report Share Posted June 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
Frank Posted June 18, 2008 Report Share Posted June 18, 2008 Please provide a sample application that reproduces this problem. There are just too many variables involved here. Quote Link to comment Share on other sites More sharing options...
Jbassking Posted June 18, 2008 Author Report Share Posted June 18, 2008 Will an export of the charts work or do you need an actual application? Quote Link to comment Share on other sites More sharing options...
Frank Posted June 18, 2008 Report Share Posted June 18, 2008 An export may be enough. It depends. Attach the binary file generated by Export, I will take a look and I'll let you know if I need more. Quote Link to comment Share on other sites More sharing options...
Jbassking Posted June 18, 2008 Author Report Share Posted June 18, 2008 I attached a zip with 2 .bin files. The 1st one is the wk1 bar chart and the 2nd one is the 2001, 2002, etc... scatter chart. Quote Link to comment Share on other sites More sharing options...
Frank Posted June 18, 2008 Report Share Posted June 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
Jbassking Posted June 18, 2008 Author Report Share Posted June 18, 2008 I'll put together a sample application with the data from both examples. Quote Link to comment Share on other sites More sharing options...
Jbassking Posted June 18, 2008 Author Report Share Posted June 18, 2008 The attached project shows the problem with both charts. I'm using the GetTip event to display the corrent information for the tooltips for the data points. Quote Link to comment Share on other sites More sharing options...
Frank Posted June 19, 2008 Report Share Posted June 19, 2008 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. Quote Link to comment Share on other sites More sharing options...
Jbassking Posted June 19, 2008 Author Report Share Posted June 19, 2008 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. Quote Link to comment Share on other sites More sharing options...
Frank Posted June 19, 2008 Report Share Posted June 19, 2008 > 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. Quote Link to comment Share on other sites More sharing options...
Jbassking Posted June 20, 2008 Author Report Share Posted June 20, 2008 Now that you pointed this out it is very obvious. This sure makes me feel pretty stupid right about now. In any case in order for me to use text on the X-Axis I have to make sure each Y data point assigned falls in the line with the X-Axis label? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.