|
Draw line data on top of axis |
Posted by SteveT on Dec-11-2012 23:13 |
|
Hi,
The data source for a line chart we use can either include:
1. all data points for each X position
2. some missing data (Chart::NoData) at X positions.
In some instances the y axis data range and axis is set from 0->Max value.
In the case where all values are included (case 1 above) I would like to plot the line data on top of the X axis - therefore keeping the z order of the x axis line to the back of the render process.
This would help to determine if there is data available at 0 (a line eill be plotted) or indeed if there is no data for this sample.
I have tried ordering my line data with little success. It may be a simple fix but I'd appreciate some pointers in the right direction.
Thanks for your help in advance,
Kind regards,
Steven |
Re: Draw line data on top of axis |
Posted by Peter Kwan on Dec-12-2012 00:57 |
|
Hi SteveT,
Currently, in ChartDirector, the x-axis is always above the layers. If you would like to plot a layer so that horizontal line segments at y = 0 is visible and not blocked by the x-axis, the followings are some common methods:
(a) Make the line wider than the x-axis. For example, make the line 2 pixels wide.
(b) Assuming your x-axis is at the border of the plot area (instead of in the middle as in a 4-quadrant chart), you may move the x-axis a little bit from the y = 0 line by adding an axis margin on the y-axis. For example:
// 3-pixel margin at the bottom
c->yAxis()->setMargin(0, 3);
(c) Make the x-axis stem transparent, and also the plot area border transparent. You can still see the border of the plot area, because there are still grid lines (which are under the layers). See "Uneven Data Points" for an example. (The sixth chart in the following chart gallery page "http://www.advsofteng.com/gallery_line.html".) If you want the x-axis to be visible, you can make it transparent anyway, then add a line using BaseChart.addLine at the border of the plot area, and use setZOrder on the line to put it at the back of the plot area. If you are sure the x-axis is at y = 0, you may also use Axis.addMark to add a mark line at y = 0, and use Mark.setDrawOnTop(false) to put it at the back of the layers.
Hope this can help.
Regards
Peter Kwan |
Re: Draw line data on top of axis |
Posted by SteveT on Dec-14-2012 01:34 |
|
Thanks Peter - most helpful
If anyone is interested I chose option 3 and the code used (c++):
pChart->addLine(xAxisLeftX, xAxisYPos, xAxisRightX, xAxisYPos)->setZOrder(Chart::GridLinesZ);
to give the desired effect.
Steve |
|