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

Message ListMessage List     Post MessagePost Message

  get some problem with creating a normal distribution chart
Posted by Eva on Jul-04-2019 17:31
Attachments:
Hi
I try to create a normal distribution chart by using barLayer and SplineLayer.
But get some problem with xAxis position.
I want the barLayer's position will be at middle of each xlabels.
My expression may not be very clear so I put a picture.
Hope it will help understand what I want.
sample.png

  Re: get some problem with creating a normal distribution chart
Posted by Peter Kwan on Jul-05-2019 03:33
Hi Eva,

There is an example in ChartDirector for a normal distribution chart. You can shift the bars by simply modifying the x-coordinates of the bars (in the Layer.setXData method). This will not affect the spline layer.

https://www.advsofteng.com/doc/cdcom.htm#histogram.htm

For your existing chart, it seems you are using a "label based x-axis" (the x-axis is configured using Axis.setLabels, and no x-coordinates are provided for the BarLayer and SplineLayer). If you prefer to use a label based x-axis, you can use the following code to shift the bar by 0.5 label spacing to the left:

' Assume this is your bar layer
Set layer = c.addBarLayer(data, &H6699bb)

' Shift by 0.5 label distance to the left
Call layer.setXData(-0.5, Ubound(data) - 0.5)

' **** Do not use setLabels ****
'Call c.xAxis().setLabels(labels)

' Instead, use setLinearScale2 for the x-axis labels
Call c.xAxis().setLinearScale2(0, Ubound(labels), labels)

Hope this can help.

Regards
Peter Kwan

  Re: get some problem with creating a normal distribution chart
Posted by Eva on Jul-08-2019 09:55
Hi Peter

It works. Thanks a lot!