russ_uk Posted January 13, 2010 Report Share Posted January 13, 2010 Hi, It seems there is an issue with the alignment of bars within a bar chart. We have found that if each x-axis category does not have the same number ofbars (or in effect one for each series) then bars are not aligned within thecentre of the category label. This makes the bar chart almost impossible to read. For the example attached we have 3 x-axis categories, the first category(BAR1) has 3 values the other two categories have one value each. As theattached file shows the chart is very hard to interpret. To resolve the problem we have tried plotting equal points per categoryusing Chart.Hidden but this has no affect. Is there anyway to resolve this? Quote Link to comment Share on other sites More sharing options...
CarlosAC Posted January 13, 2010 Report Share Posted January 13, 2010 Hi russ_uk This is the normal behavior of Chart FX. When you add different number of points for each series, the chart will Quote Link to comment Share on other sites More sharing options...
russ_uk Posted January 13, 2010 Author Report Share Posted January 13, 2010 Hi, Many thanks for taking the time to reply. We thought that was the issue so have tried creating a single series per point and still get alignment issues. As you can see below the bars for BAR1 and BAR3 do not align with the centre of the category label. Is there anyway to get bars to align to the category label when the number of bars per category are not equal? Thanks Russ Quote Link to comment Share on other sites More sharing options...
CarlosAC Posted January 13, 2010 Report Share Posted January 13, 2010 Hi russ_uk The chart contains 10 series and 3 points. Can you please provide me with the method where you are adding the data to the chart, or maybe the data source (as a table). Please try the following code at your end: Random ran = new Random(); Chart1.Data.Series = 1; Chart1.Data.Points = 100; for (int i = 0; i < Chart1.Data.Series; i++) { for (int j = 0; j < Chart1.Data.Points; j++) { Chart1.Data[i, j] = ran.NextDouble() * 100; } } -- Pipon Quote Link to comment Share on other sites More sharing options...
russ_uk Posted January 13, 2010 Author Report Share Posted January 13, 2010 Hi, If the number of series and points per category are equal then the problem does not occur. But if you have one point per series like this; _chartFX.Data[0, 0] =1; _chartFX.Data[1, 0] = 2; _chartFX.Data[2, 0] = 3; _chartFX.Data[3, 1] = 4; _chartFX.Data[4, 1] = 5; _chartFX.Data[5, 1] = 6; _chartFX.Data[4, 2] = 7; _chartFX.Data[5, 2] = 8; _chartFX.Data[6, 2] = 9; then the bars will not align. Or if you have unequal points per series _chartFX.Data[0, 0] = 1;_chartFX.Data[0, 1] = Chart.Hidden; _chartFX.Data[0, 2] = Chart.Hidden;_chartFX.Data[1, 0] = Chart.Hidden; _chartFX.Data[1, 1] = 2;_chartFX.Data[1, 2] = Chart.Hidden; _chartFX.Data[2, 0] = Chart.Hidden;_chartFX.Data[2, 1] = Chart.Hidden; _chartFX.Data[2, 2] = 3; Quote Link to comment Share on other sites More sharing options...
CarlosAC Posted January 13, 2010 Report Share Posted January 13, 2010 Hi russ_uk In the first method, you are adding point #0 to the series 0, 1 and 2; point #1 to series 3, 4 and 5; and finally, point #2 to series 4, 5 and 6. Now, in the second method, you are adding point # 0 to the series 0; point #1 to the series 1; and point # 2 to series 2. In both cases, you are not adding points to specific series, and those points are adding Quote Link to comment Share on other sites More sharing options...
russ_uk Posted January 14, 2010 Author Report Share Posted January 14, 2010 Hi, Thanks again for taking the time to reply. Unfortunately we do not have an equal number of bars per category as the number of bars per category depends on the data. This is what is causing our issue, if the number of bars per category are equal then the chart renders correctly however, when we have 1 bar on the first category and 3 bars on the second then the bars within the first category simply don't align and make the chart unreadable. Kind Regards Russ LegendBox.zip Quote Link to comment Share on other sites More sharing options...
CarlosAC Posted January 14, 2010 Report Share Posted January 14, 2010 Hi russ_uk As I mentioned before, this is a normal behavior of Chart FX. This is by design. -- Pipon 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.