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

Message ListMessage List     Post MessagePost Message

  Add Mark not correct position when decimal
Posted by Johnny Butler on May-21-2015 21:20
Attachments:
Hi,

I have an area chart, what I want to do is mark a specific point on the graph.  When I select
a round number like 5.0, it works correctly

mark = c.xAxis().addMark(5.0, 0xDD8888, "Data not submitted", "", 9)

If I try a decimal point like below, then its out of place, see attached, so 4.7 is showing past
4.8 on the chart.

mark = c.xAxis().addMark(4.7, 0xDD8888, "Data not submitted", "", 9)

Ive tried different options with the linear scale, ticket count etc but it doesn't seem to work.

Im using ruby.

thanks
Screen Shot 2015-05-21 at 14.13.05.png

  Re: Add Mark not correct position when decimal
Posted by Peter Kwan on May-22-2015 00:42
Hi Johnny,

I suspect the labels on your x-axis are configured with Axis.setLabels or Axis.setLabels2.
In this case, they are just "names" and is purely for human reading and have no meaning
to ChartDirector. (You can use random numbers or replace some of the labels with names
of fruits, and the chart would still be exactly the same except the labels, which shows
the labels has no effect on the chart other than for human reading.) If the x-axis are
using labels, the x-coordinate in addMark refers to the label index (because the label text
are just names, so they cannot be used as coordinates). The x-coordinates of 5 means
the 6th label (the 1st label has index 0), which is 5.0 in your chart. The x coordinate of
4.7 means somewhere between the 5th label (4.8) and the 6th labels (5.0), which is
consistent with what you observed.

For your case, there are two methods:

(a) Use real x-coordinates for the x-axis. Instead of using Axis.setLabels, you can use:

c.xAxis().setLinearScale(4.0, 7.4, 0.2)

Note that if you use x-coordinates (instead of x-axis labels), you would also need to
provide x-coordinates for your layers. For example:

myLayer = c.addAreaLayer(myData, ....)
myLaber.setXCoor(myXCoor)

The myXCoor is an array of numbers representing the x-coordinates of your data points.
The myData is an array of numbers representing the y-coordinates.

(b) If you prefer to treat the x-axis as labels (using Axis.setLabels), you would need to
convert the label position into x-coordinate for addMark. For example, the mark at the
midpoint between the "4.6" and "4.8" labels is 3.5. For your particular case, I think the
formula is:

#mark at 4.7, converted to label index
mark = c.xAxis().addMark((4.7 - 4.0) / 0.2, 0xDD8888, "Data not submitted", "", 9)

Hope this can help.

Regards
Peter Kwan

  Re: Add Mark not correct position when decimal
Posted by Johnny Butler on May-26-2015 22:37
Thanks Peter, I chose option 1.