Jump to content
Software FX Community

PointLabels not within boundary of bar chart


eridgway

Recommended Posts

Posted

Hi,

Having a few problems with the point labels on my bar chart. The point labels are not staying within the boundaries of the bar chart, causing them to overwrite the x-axis label for lowest negative value, and writing over the chart border on the higher positive values.

I can solve the "higher positive values" problem by switching the AxesStyle to Math (removing the top border), but I have not come up with a way to keep the "lowest negative value" from overwriting the Axis label.

Suggestions?

Posted

It does not look like the problem described in this article is what you are experiencing.

Labels may go in the X-Axis area if there is nowhere else for them to go, Chart FX will not try to align them differently if they are close to the X-Axis.

A possible solution is to decrease the Min value so that there is room for the labels within the plot area.

Posted

Hmm, ok. As another option, is there a way to force the labels to stay at the top of the bar, regardless if the value is negative? So on neg values, it would sit just on top of the 0-line.

Posted

The point label's vertical alignment will always be inverted for negative values.

What you can do is to create a conditional attribute that inverts the alignment of negative values:

ConditionalAttributes ca = new ConditionalAttributes();

ca.PointLabels.LineAlignment =

StringAlignment.Near;ca.Condition.From = double.NegativeInfinity;

ca.Condition.To = 0;

chart.ConditionalAttributes.Add(ca);

 

  • 3 weeks later...
Posted

Hmm, couldn't get that solution to work (pointlabels is a boolean property), but here's the general fix I came up with in case anyone else runs into this issue.

 double dSpace = 0.125; //percentage of your chart that the point labels should take up, in this case I'm going with 1/8 of the chart

 double dBarMin = chtBar.AxisY.Min;  double dBarMax = chtBar.AxisY.Max;  double dBarTotal = dBarMax + (-1* dBarMin);  //total Y size double dBottomPad = (dBarTotal * dSpace); //how much extra y-value to tag onto the lower end   chtBar.AxisY.Min = chtBar.AxisY.Min - dBottomPad;

Hit Test Problems.zip

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...