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

Message ListMessage List     Post MessagePost Message

  yAxis label color of FinanceChart
Posted by Shenggang Zhang on Dec-17-2020 13:14
The problem is when drawing yAxis of financechart, I have to show red color of upper value, else green color.
How to do that? Could you give me some code snippet?
The attachment png file is a sample.

  Re: yAxis label color of FinanceChart
Posted by Peter Kwan on Dec-17-2020 16:53
Hi Shenggang,

As I do not know which programming language you are using, I will use C#/Java in the followings. If you need me to translate the code to another programming language, please let me know.

For the FinanceChart, there are many y-axes (one of the main price chart, and one for each indicator charts). The y=axis labels normally are automatically determined by ChartDirector, although you can also use Axis.setLinearScale to specify the scale and labels.

One method to achieve the coloring is as follows;

FinanceChart c = new FinanceChart(....);
.... some code to configure the financial chart ....

// Add the main price chart
XYChart m = c.addMainChart(......);

// Assume you want to configure the y-axis in the main price chart
Axis yAxis = m.yAxis();

int labelColor = m.yZoneColor(336.2, 0x00cc00, 0xee0000);
yAxis.setLabelStyle("normal", 8, labelColor);

// Use a special text color (0xffffff) and grid line color (0xcc0000) for the label 336.2
yAxis.addMark(336.2, -1, "336.2").setMarkColor(0xcc0000, 0xffffff, 0xcc0000);

Hope this can help.

Peter Kwan