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

Message ListMessage List     Post MessagePost Message

  Help - Color coding on the graph
Posted by dilip on Mar-06-2013 18:31
Hi

I'm using java ChartDirector, I want to color code some sections on the graph to
highlight.

For example, if the graph has the data range of 0 to 100

Then to apply color for specific range, say, for the value ranges...

0 to 10 = green

20 to 30 = yellow

50 to 70 = red

How can I do this? please help

Here are the steps of the code to give you an idea of what type of graph I'm using...

********
XYChart xyChart = new XYChart(600, 310, 0xf0f0ff, 0x000000);

xyChart.setPlotArea(55, 60, 520, 192, 0xffffff, -1, -1, 0xcccccc,
0xcccccc);

LineLayer lineLayer = xyChart.addLineLayer2();
lineLayer.setLineWidth(1);

lineLayer.setXData(graphData.getXRawData());

lineLayer.addDataSet(graphData.getYRawData(), Integer.valueOf("ff6600", 16));

********

Thanks

Dilip

  Re: Help - Color coding on the graph
Posted by Peter Kwan on Mar-06-2013 23:05
Hi dilip,

I am not exactly clear what you would like to color code. It could be the plot area background, or it could be the line itself (in the latter case, line is would be multi-colored).

Assuming you are referring to the plot area background, you may use Axis.addZone. You may refer to the "Marks and Zones" sample code for an example.

http://www.advsofteng.com/doc/cdjava.htm#markzone.htm

Hope this can help.

Regards
Peter Kwan

  Re: Help - Color coding on the graph
Posted by dilip on Mar-06-2013 23:36
Attachments:
Hi Peter,

Thanks for the quick response


To the line itself (multi-colored).

Please check the attached image.

My requirement is that the orange line (on the attached chart) should be multicolored.

Thanks

Dilip
example_chart.png

  Re: Help - Color coding on the graph
Posted by dilip on Mar-07-2013 04:43
Hi Peter,

Could you please tell me how to make the multi colored line?

Thanks

  Re: Help - Color coding on the graph
Posted by Peter Kwan on Mar-07-2013 23:33
Hi dilip,

You may use a y-zone color as the line color. You may refer to the sample code "Y Zone Coloring". This sample code uses a y-zone color to color an area chart, so that different area has different colors. You may modify it to apply the y-zone color to a line as well.

In brief, it is like:

int myLineColor = c.yZoneColor(10, 0x00ff00, c.yZoneColor(30, 0xffff00, 0xff0000));

LineLayer layer = c.addLineLayer(myData, myLineColor, ....);

Hope this can help.

Regards
Peter Kwan

  Re: Help - Color coding on the graph
Posted by dilip on Mar-08-2013 01:06
Excellent, it worked, thanks for help.