ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Label background color
Posted by John Doe on Jul-17-2012 05:52
Hello Peter,

Is there a way to change the background color of the text label (not the axis labels)
against each bar in the chart? The text color is white and so are the grid lines, so when a
grid line passes over the text against a bar in the chart, the text gets obscured. I'd like to
change the background of this text to say, black ? sort of like highlighting text with black
color.

Please do let me know!
Thanks!

  Re: Label background color
Posted by Peter Kwan on Jul-17-2012 23:48
Hi John,

Yes. You may change the background color of any text label in ChartDirector. There is a sample code called "Text Style and Colors (2)" that comes with ChartDirector. It demonstrates many label styles, one of which are for bar labels (labels on top of the bars) with a custom background color. May be this is what you need. (You may look up "Text Style and Colors (2)" from the ChartDirector documentation index.

Hope this can help.

Regards
Peter Kwan

  Re: Label background color
Posted by John Doe on Jul-19-2012 03:25
That worked! Thanks Peter! But, the background color does not seem to take priority over
the chart borders that are the same color as the grid lines. Any ideas how to deal with
this?

  Re: Label background color
Posted by John Doe on Jul-24-2012 05:21
Any ideas on this one?

  Re: Label background color
Posted by Peter Kwan on Jul-25-2012 03:00
Hi John,

By "chart borders", do you mean "plot area borders"?

In ChartDirector terminology, the chart border is the border of the chart image. By default, the chart border is transparent, but you can configure a non-transparent border. The border can be a normal or rounded rectangle.

If a label overlaps with the chart border, it means part of it is outside the chart image and would not be visible.

The plot area is the region that the layers are plotted. By default, the left and bottom sides of the plot area are occupied by the axis. The axis labels lie outside the plot area.

If you have a long text label inside the plot area, it may extend outside the plot area, and overlap with the plot area border or the axis or the axis labels. In ChartDirector, these three objects will stay on top of the labels in the layer (such as the data labels).

If you are sure the border the overlaps with your text label is the plot area border (and not the axis), you can set the plot area border to transparent, so that it cannot overlap with anything. If you need to have some rectangular border behind the layers, you can add it as a custom text box using BaseChart.addText. The custom text box can be configured to contain no text, with a size (set using Box.setSize) the same as that of the plot area, and with a border color (set using Box.setBackground) set to the border color you want, and with the zorder (set using Box.setZOrder) set to PlotAreaZ so that the box is behind the layers. (Note: the exact code depends on your programming language.)

Hope this can help.

Regards
Peter Kwan