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

Message ListMessage List     Post MessagePost Message

  Y axis scaling
Posted by Guus Mathijssen on Jan-18-2012 21:29
Attachments:
Hi,

we would like to depend on the automatic autoscaling, but found a case where it did not
work properly

<%@ language="vbscript" %>
<%
Set cd = CreateObject("ChartDirector.API")

' The data for the line chart
data = Array(7,7,7,7,8,8,8,8)

' The labels for the line chart
labels = Array("0", "1", "2", "3", "4", "5", "6", "7")

' Create a XYChart object of size 250 x 250 pixels
Set c = cd.XYChart(250, 250)

' Set the plotarea at (30, 20) and of size 200 x 200 pixels
Call c.setPlotArea(30, 20, 200, 200)

' Add a line chart layer using the given data
Call c.addLineLayer(data)

' Set the labels on the x axis.
Call c.xAxis().setLabels(labels)

' Display 1 out of 3 labels on the x-axis.
Call c.xAxis().setLabelStep(3)

Call c.yAxis().setLinearScale3("{value|" & 0 & "}")

' Output the chart
Response.ContentType = "image/png"
Response.BinaryWrite c.makeChart2(cd.PNG)
Response.End
%>

The 7 and 8 are repeated several times on the Y axis.
We need the scale without decimals.
Do you have a solution for this?

Regards,
Guus
Yammer.png

  Re: Y axis scaling
Posted by Peter Kwan on Jan-19-2012 02:31
Hi Guus,

The actual labels on the y-axis are probably 6.8, 7.0, 7.2, 7.4, 7.6, 7.8, 8.0, 8.2. Because your code formats the labels to no decimal place, so they become 7, 7, 7, 7, 8, 8, 8, 8.

If you would like ChartDirector to auto-scale the y-axis so that the labels are integers, you may use:

'At least 1 unit between two labels
Call c.yAxis().setMinTickInc(1)

Hope this can help.

Regards
Peter Kwan

  Re: Y axis scaling
Posted by Guus Mathijssen on Jan-19-2012 04:01
Thanks Peter!
Exactly what I needed