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

Message ListMessage List     Post MessagePost Message

  Is it possible to contol mark's line appearance
Posted by Dennis on Jan-12-2011 02:39
Hi, Peter

I have an Y-Axis is on the right. I use yAxis.addMark(...) to draw a horizontal line that points to a value on my Y-Axis. The issue is following: I need to add a gap between the left point of the line and the left border of my graph (in order to put some text information in this gap). Is it possible to left such a gap?

I'll try to illustrate my issue using the following schema:

...                                              ^
|                                                |
| text -----------------------------|- 200.54                    <-schematically
|   ^-text label                             |   ^- mark's value
|                                                |
|______________________________|
^---- left border                           ^----- Y-Axis

I tried to display a part of my graph, where 200.54 is the value of the mark, and dash line and "text" label represent how I need to display an additional info about the mark.


I hope you can understand my issue and propose a solution. I use ASP/JavaScript

Regards,
Dennis

  Re: Is it possible to contol mark's line appearance
Posted by Peter Kwan on Jan-12-2011 18:40
Hi Dennis,

There are several methods to achieve what you need. The easiest way is for the "text label" to have a white background. This will block the part of the line near the left border, but it will also block your chart in case there are chart objects (lines, bars, symbols) under the text label position. The code in this case is like (in ASP/Javascript):

//add the mark at y=-200.54, and put the label "-200.54" on the y-axis
c.yAxis().addMark(-200.54, c.dashLineColor(0x0000ff), "-200.54");

//add the "text" label for the mark
m = c.yAxis().addMark(-200.54, cd.Transparent, "    text ");
m.setAlignment(cd.Left);
m.setFontColor(0x000000);
m.setBackground(0xffffff);

You can also set the mark line color to be transparent for the part of the line that is is less than a certain x-data value. For example, if you have the part x < 3 to be transparent, you may use:

c.yAxis().addMark(-200.54, c.xZoneColor(3, cd.Transparent, c.dashLineColor(0x0000ff)), "-200.54");

Note that the 3 above is in x-data value coordinate. If you are using a label based x-axis, it is the position of the 4th label.

Hope this can help.

Regards
Peter Kwan

  Re: Is it possible to contol mark's line appearance
Posted by Dennis on Jan-12-2011 20:27
Hi Peter,

Thanks for your response. Setting the background color of the label is inappropriate for me, because I use opacity to left the area under the label visible.

The second variant seems not very suitable for me, too. The width of the label is dynamically calculated, and I can't synchronize the coordinate of the right point of the label with values on X-Axis.

Probably, there are some other solutions?

Regards,
Dennis

  Re: Is it possible to contol mark's line appearance
Posted by Peter Kwan on Jan-13-2011 02:45
Hi Dennis,

You may use BaseChart.addLine and BaseChart.addText to add lines and text at anywhere you want. You may use these methods to achieve what you need. For example:

.... add data to the chart as usual ....

//Put the label "-200.54" on the y-axis
c.yAxis().addMark(-200.54, cd.Transparent, "-200.54").setFontColor(0x000000);

//auto-scale the axis
c.layout();

yCoor = c.getYCoor(-200.54);
t = c.addText(c.getPlotArea().getLeftX(), yCoor, "My Label", "arialbd.ttf", 8, 0x000000, cd.Right);

c.addLine(c.getPlotArea().getLeftX() + t.getWidth(), yCoor, c.getPlotArea().getLeftX() + c.getPlotArea().getWidth(), yCoor, c.dashLineColor(0x0000ff), 1);

Hope this can help.

Regards
Peter Kwan

  Re: Is it possible to contol mark's line appearance
Posted by Dennis on Jan-14-2011 02:32
Hi Peter,

Thank you for the solution! chart.getYCoor(...) was exactly that I needed! ChartDirector works great!

Regards,
Dennis