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

Message ListMessage List     Post MessagePost Message

  X axis labels for Non-Integral values
Posted by Viks30 on Jan-04-2011 08:07
Hello,

I am generating a Histogram where my Xaxis data points need to be separated in increments of a non-integer value.

For ex: My dataset may contain values like ( 0.234, 0.656, 0.543, 0.778, 1, 1.23)
I want these values to be seen on Xaxis under labels (buckets) of 0.2, 0.4, 0.6...so on.

From my observation, the SetLabelStep () function only accepts integral values. What are the work-arounds for the same in such a situation.

Regards..!!!

  Re: X axis labels for Non-Integral values
Posted by Peter Kwan on Jan-05-2011 00:20
Hi Viks30,

You may use a linear x-axis, which behaves exactly like the y-axis. (You can see the labels on the y-axis are always "nice" numbers, even your actual y-data values are arbitrary values.) There is an example called "Uneven Data Points" included in ChartDirector. The example uses date/time values for the x-coordinates, but it also works for a numeric x-axis.

In VB/VBScript, it is like:

Set layer = c.addBarLayer(myYData, ....)
Call layer.setXData(myXData)

'The following line should be present to configure the x-axis scale to be non-indented
Call c.xAxis().setIndent(False)

'The following line is optional. If omitted, ChartDirector will automatically label the
'x-axis, just like it will automatically label the y-axis.
Call c.xAxis().setLinearScale(0, 1.4, 0.2)

Note that for your case, there is no way to know for sure what should be the width of the bars. For instance, if your bars are at x = (0.234, 0.656, 0.543, 0.778, 1, 1.23), should the width of each bar occupies 0.2 x-unit, or 0.1 x-unit or any other number of unit? ChartDirector will just guess. If you have a specific width you want to use, you may use BarLayer.setBarWidth (or BarLayer.setBarGap) to configure the bar width. You may also want to use Axis.setMargin to add margins to the x-axis to reserve space for the bar width.

Hope this can help.

Regards
Peter Kwan