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

Message ListMessage List     Post MessagePost Message

  Axis Formatting
Posted by Jason Adams on Nov-17-2011 02:10
Attachments:
My x axis is meant to indicate meters, but in order to do this I have to use formatting to
adjust my values to truly indicate a meter, as such:

{={value * multiplier}|@}

Now this works well, but I run into the issue that my scaling slowly drifts. If you notice in
the shot I include, it starts with increments of 20, but (I assume due to rounding) drifts off
by 1. It's really cosmetic, but the scaling looks bad.

I'm really not familiar with the formatting language of CD, and would be very interesting in
finding documentation for it. (I have the comchartdir.chm, and it helped, but it spends more
time on other things than presenting functions.) Is there a floor function I can use to keep
the rounding down? Such as:

{={Floor(value * multiplier)}|@}

Thank you!
Graph.jpg

  Re: Axis Formatting
Posted by Peter Kwan on Nov-17-2011 03:48
Hi Jason,

I suspect what you see is not caused by "rounding error", because the rounding error should not be that large. I can see some values miss by 2 units (like 302), so rounding will not soft the problem.

I suspect it is due to inaccuracies in either "value" or "multiplier".

Please kindly inform me how the "value" are determined. Are they automatically determined by ChartDirector using auto-scaling, or are they determined by your own code (by explicitly providing the tick values with setLabels2 or setLinearScale)? If the values are automatically determined by ChartDirector, it should be very accurate. (The error should be in the order of 10E-16 of the value, and is unlikely to have any effect after rounding.)

For the multiplier, it must come from your code. Are you sure it is accurate? Is it a hard coded number, like {={value}*100|@}, or is it a variable? May be you can change the format to the followings so we can see the actual value:

//replace 100 below with your actual multiplier
{={value}*100|@}<*br*>{value}*100

Regards
Peter Kwan

  Re: Axis Formatting
Posted by Jason Adams on Nov-17-2011 04:31
Attachments:
Hello Peter,

The values are auto scaled by CD, I provide the start and end values for a linear scale, and
leave the rest up to its own algorithms. As far as the multiplier goes, I'm using CD within
Real Studio (think Visual Basic), and my multiplier is a double that I'm converting to a string
to be placed within the formatting:

Chart.xAxis.setLinearScale (0, ChartData.Ubound)
Chart.xAxis.setLabelFormat "{={value}*" + MeterScale.Str + "|@}"

I thought rounding error was I wasn't sure if CD calculated an increment, started from the
beginning and added per tick; i.e., 0 to 300, 10 ticks, increment by 30: 0, 30, 60, etc... In
which case if it was incremented by a value with a small decimal value (say 30.2), then it
would periodically add up to 1: 0, 30, 60, 90, 120, 151, etc... Admittedly I don't know the
inner working of CD, so this was purely speculation.

I added the line per your request. Thanks so much for the help, it's greatly appreciated!
Graph.jpg

  Re: Axis Formatting
Posted by Jason Adams on Nov-17-2011 04:36
Having looked at it, I suppose really it's just accurate; that is, the tick value really is what
it is. So it's really not anything "wrong", but my multiplier causing me grief. I can't just
change the max of the linear scale, because that determines how many elements of the
data array to use, but this method messes with the scaling cleanliness.

Ideas?

  Re: Axis Formatting
Posted by Jason Adams on Nov-17-2011 22:44
Is it possible to calculate only the final value, and leave CD to auto-scale as such?
Obviously, as I said, I can't use Linear Scale for this, as it also affects the number of
elements used from the data array.

  Re: Axis Formatting
Posted by Peter Kwan on Nov-18-2011 02:09
Hi Jason,

I suggest you use something like:

Dim myLayer As AreaLayer = c.addAreaLayer(ChartData, ....)

'The following is how your data points should be positioned on the x-axis
myLayer.setXData(0, ChartData.Ubound * MeterScale)

(Note: if your chart has a trend layer, please use setXData on the trend layer too.)

You do not need to configure the x-axis at all. As long as your code provides the correct x-coordinates for the data points, ChartDirector should auto-scale the axis correctly.

Hope this can help.

Regards
Peter Kwan