|
0 displayed at origin |
Posted by GY on Sep-24-2011 03:42 |
|
Hi,
I am using ChartDirector 4.01 ( VB/ASP )
I am trying to display the data labels in the scatter chart. The values are getting displayed
properly, but i also see a "0" being displayed at origin.
I dont quite understand how it is coming through.
I use the following code to draw the chart and set the data label.
Set objLayer = oGraph.addScatterLayer(getArray(xData(i)), getArray(yData(i)), Labels(i),
oAPI.CircleSymbol, 9, WHITE, BLACK)
objLayer.setSymbolScale getArray(CircleSize), oAPI.XScale
objLayer.setDataLabelFormat ("{value|0}")
objLayer.setDataLabelStyle("arialbd.ttf", 9).setAlignment (oAPI.BottomCenter)
I do not want that '0' to be displayed at origin.
What am I missing?
GY |
Re: 0 displayed at origin |
Posted by Peter Kwan on Sep-26-2011 01:45 |
|
Hi GY,
In your code, labels should appear whereever you have a data point. If there is a data label "0" at the origin, the most likely resaon is that you have a data point at the origin.
The most common reason that there is an unexpected data point at the origin is because some array elements are not used. In many programming languages (including VB/VBScript), unused elements are coerced to 0 in numeric context.
For example, suppose you have 10 data points, and you use the following arrays to store the data:
ReDim xData(10)
ReDim yData(10)
The above will introduce unused array elements and will create an zero data point. It is because the above arrays actually have 11 elements (in VB/VBScript syntax, the above code means the array index is from 0 to 10, and therefore contain 11 elements). As only 10 elements are used, so there is an unused element, which will be equivalent to 0.
To help confirm if the above is the cause of the problem, you may add the following code:
tempX = getArray(xData(i))
tempY = getArray(yData(i))
For j = 0 To Ubound(tempX)
If tempX(j) = 0 And tempY(j) = 0 Then
Call oGraph.addTitle("Zero point at (i, j) = (" & i & "," & j & ")")
End If
Next
With the above code, if you really have a data point at the origin, the chart title should display the array indexes of that point.
If the above is really the cause of the problem, the solution is to remove the data point at the origin before passing the data to ChartDirector.
Hope this can help.
Regards
Peter Kwan |
|