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

Message ListMessage List     Post MessagePost Message

  Overlay outline image over contour and other XYcharts
Posted by Malcolm Exton on Feb-26-2013 00:44
Is it possible to overlay a partially transparent image (e.g. GIF or PNG) containing the border of a country over an XYChart, such as a contour layer?

I've tried getDrawArea and loadPNG with setTransparencyColor without success. The outline image remains firmly behind the contour and other chart objects.

The use case is to have various geographically aligned data sets stacked over a map with the country's outline visible.

Regards

  Re: Overlay outline image over contour and other XYcharts
Posted by Peter Kwan on Feb-26-2013 22:23
Hi Malcolm,

The BaseChart.getDrawArea obtains the Drawarea object before the chart layers are drawn. It is best to be used to draw things on the background. Only the other hand, BaseChart.makeChart3 method draws the chart and then return the DrawArea object, which you may use to draw over the chart.

In addition to use the DrawArea object, you may also use CDML to load an image. For example, in C#/Java:

ChartDirector.TextBox t = c.addText(40, 60, "<*img=/path/to/aaa.png*>");
t.setMargin(0);

By default, text added using BaseChart.addText will be drawn in front of the chart layers (but you can use Box.setZOrder to change the drawing order). There are also additional CDML attributes in the <*img*> tag to control the width and height of the image (ChartDirector will compress or stretch the image to the specified size).

If you would like to use the DrawArea method, it is like:

DrawArea myImage = new DrawArea();
myImage.loadPNG("/path/to/aaa.png");

c.makeChart3().merge(myImage, 40, 60, Chart.TopLeft, 0);

In all cases, ChartDirector will correctly handle the transparency in loaded GIF/PNG without using setTransparentColor.

(The setTransparentColor is used to control the transparency when you save the chart. Because some image format (such as JPG and BMP) does not support transparency, and some image format (such as GIF) and old browsers (such as IE 6) supports only single color transparency (as opposed to semi-transparency or alpha transparency), so we have a method to control how transparency information is output.)

Hope this can help.

Regards
Peter Kwan