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

Message ListMessage List     Post MessagePost Message

  How to add symbols outsite plot area?
Posted by Eva on Jan-16-2016 05:44
Attachments:
Hello Peter,

I need to add a symbol to my Gantt Chart to the end of a bar that indicates
that the bar was truncated. I came up with an indicator shown in a green
circle in the "Desired Output" file. It would consist of a vertical dash
line, horizontal line, and a right triangle symbol.

Let's say I have one bar that needs to be truncated at position x[] = {0}, and the chart end date is 1/1/2046.

To accomplish that I'm doing the following (I use Java):

//draw arrow 10 pixels to the right of the chartEndDate
c.addScatterLayer(,,, Chart.RightTriangleShape,.);

//draw vertical the dash line 2 pixels inside the bar's right border
chart.addLine( ..)

//draw horizontal line 8 pixels to the right
chart.addLine(.);

The problem I have is when I use the addScatterLayer() method, the chart's
time is extended to accommodate the arrow (see Actual output image)
1. How can I prevent so the the end date of the plot area is not extended?
2. I'm forced to call addScatterLayer() method before the chart.layout(),
and addLine() after the chart.layout(). Is that correct?
3. Do you have a simpler way of creating the desired image?
4. What is the best way to calculate the x and y offsets to get the desired
length of lines?

Thank you,
Eva
Desired output.png
Desired output.png

15.34 Kb
Actual output.png
Actual output.png

7.59 Kb

  Re: How to add symbols outsite plot area?
Posted by Peter Kwan on Jan-19-2016 00:34
Hi Eva,

Are you adding the symbol with at a date after 1/1/2046 (eg. such as adding the symbol
at 1/1/2047)? If the y-axis is auto-scaled, by default it will scale the axis so that it
includes all the dates in your data, including the date in the scatter layer, so the axis
will be extended if your scatter points are outside the original date range.

To achieve what you want, there are several methods.

(a) If you are using ChartDirector 6.x, you can add the scatter point at 1/1/2046 and
using the built-in ArrowSymbol. See the followings for the built-in symbols in
ChartDirector 6.x.

http://www.advsofteng.com/doc/cdnet.htm#builtinsymbols.htm

By default, this means the center of the arrow will be at 1/1/2046. You can then shift
the arrow to the right using DataSet.setSymbolOffset by half the symbol size, so that
the arrow end point will be at 1/1/2046. It is like:

ScatterLayer layer = c.addScatterLayer(........);
layer.getDataSet(0).setSymbolOffsert(symbolSize / 2, 0);


(b) In earlier versions of ChartDirector, there is also vector layer that can be used to
add an arrow pointing from 1/1/2016. See:

http://www.advsofteng.com/doc/cdnet.htm#vector.htm


(c) If you know the desired ending date on the axis, you can use Axis.setDateScale to
set the end date. In this way, ChartDirector will use your end date instead of
automatically computing one. It is like:

//start date automatically determined, end date set to the specified date
c.yAxis().setDateScale(Chart.NoValue, Chart.CTime(myDate));


(d) I think for recent versions of ChartDirector (I do not remember which version this
feature is available), you can add the gantt chart layer, then call XYChart.layoutAxes to
fix the axis, then add the scatter layer.


For the vertical dash line ending the bar, you may consider to add a box-whisker layer
with just one whisker, like:

http://www.advsofteng.com/doc/cdnet.htm#markbar.htm

The above is for a vertical bar chart, but it can be applied to a horizontal box-whisker
layer as well. For bars that does not require the symbol, set the value of the whisker to
Chat.NoValue.


If you do want to compute the end points of the lines, the XYChart.getXCoor and
XYChart.getYCoor can be used after calling BaseChart.layout. For the length of the
vertical dash line in x-axis unit, it is equal to 1 minus the data gap, which is
configurable with BaseBoxLayer.setDataGap. The default gap is 0.75.

Hope this can help.

Regards
Peter Kwan