Jump to content
Software FX Community

Bar Chart Bar Alignment


russ_uk

Recommended Posts

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?

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;

 

 

Link to comment
Share on other sites

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

post-7223-13922412965782_thumb.png

Link to comment
Share on other sites

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

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.

×
×
  • Create New...