|
XYChart - NoValue - DoubleArray |
Posted by Fly on Sep-08-2015 14:55 |
|
Hi.
I try to use a cd.NoValue in a XYChart.
I get this message when I try to add a dataset :
ChartDirector erreur '800a8000'
Error converting argument 1 to type class DoubleArray
A piece of my code :
(in a loop)
If mat0(i,3) <> 0 Then
liste_valeurs3 = liste_valeurs3 & "; " &Round(mat0(i,3))
Else
liste_valeurs3 = liste_valeurs3 & "; cd.NoValue"
End If
(Next)
data2 = Split(liste_valeurs3, ";")
(Finally)
Call layer.addDataSet(data2, &H3333cc, lib_data2)
(This is where i get the error message).
Any idea ?
Thx. |
Re: XYChart - NoValue - DoubleArray |
Posted by Peter Kwan on Sep-08-2015 23:49 |
|
Hi Fly,
In ChartDirector, the data should be an array of numbers, not an array of text strings.
The NoValue constant is cd.NoValue (which is a number), not "cd.NoValue" (with quotes),
which is a text string.
Your code uses the numbers to create a long text string called liste_valeurs3. It then
"Split" the text string into an array of text strings. The cd.NoValue is never used. Only
"cd.NoValue" (a text string) is used. As ChartDirector needs an array of numbers, the VB
system tries to convert the array of text strings to an array of numbers, but it cannot
understand the "cd.NoValue" text string. and this results in the error.
Instead of using text strings, you may consider to use an array numbers. For example:
ReDim data2(pointCount - 1)
For i = 0 to pointCount - 1
If mat0(i,3) <> 0 Then
data2(i) = Round(mat0(i,3))
Else
data2(i) = cd.NoValue
End If
Next
Note that in the above code, text strings are not used. The data2 only contains numbers
(assuming mat0(i, 3) is a number). The cd.NoValue is used for zero values (as opposed to
the "cd.NoValue" text string).
Hope this can help.
Regards
Peter Kwan |
Re: XYChart - NoValue - DoubleArray |
Posted by Fly on Sep-09-2015 00:35 |
|
Thank you for your answer.
I changed the way I populate the array.
But... Still get 0 values where I should get NoValue on the graph.
See for the blue line for Octobre.
|
Re: XYChart - NoValue - DoubleArray |
Posted by Peter Kwan on Sep-09-2015 02:03 |
|
Hi Fly,
Your original code can display 0 value. For example, if mat0(i,3) is 0.1, then in your code,
the data value will not be cd.NoValue, because mat0(i,3) is not zero. Instead, the data
value will be 0, because your code use "Round" to round the value to 0.
If you do not want 0 in the final data value, please modify your code so that if the final
data value is 0, the data value will be replaced by cd.NoValue.
Regards
Peter Kwan |
Re: XYChart - NoValue - DoubleArray |
Posted by Fly on Sep-09-2015 14:45 |
|
Hi.
Sorry but I had already changed 0 by Cd.NoValue but it changed nothing.
Here a piece of my code :
for i=1 to interval2
prix=mat0(i,1)
nb_dates = nb_dates + 1
If nb_dates = 1 Then
data2(0) = Round(mat0(i,3))
Else
If CStr(Round(mat0(i,3),0)) <> "0" Then
data2(i-1) = Round(mat0(i,3))
Else
data2(i-1) = cd.NoValue
End If
Response.Write("<br>data2("&i&"-1)" & data2(i-1))
End If
next
And the debug give me that :
data2(2-1)2099
data2(3-1)661
data2(4-1)850
data2(5-1)1016
data2(6-1)1059
data2(7-1)712
data2(8-1)698
data2(9-1)343
data2(10-1)
data2(11-1)
data2(12-1)
And still get zeros... |
Re: XYChart - NoValue - DoubleArray |
Posted by Peter Kwan on Sep-10-2015 00:03 |
|
Hi Fly,
In your code,
Fly wrote:
Hi.
Sorry but I had already changed 0 by Cd.NoValue but it changed nothing.
Here a piece of my code :
for i=1 to interval2
prix=mat0(i,1)
nb_dates = nb_dates + 1
If nb_dates = 1 Then
data2(0) = Round(mat0(i,3))
Else
If CStr(Round(mat0(i,3),0)) <> "0" Then
data2(i-1) = Round(mat0(i,3))
Else
data2(i-1) = cd.NoValue
End If
Response.Write("<br>data2("&i&"-1)" & data2(i-1))
End If
next
And the debug give me that :
data2(2-1)2099
data2(3-1)661
data2(4-1)850
data2(5-1)1016
data2(6-1)1059
data2(7-1)712
data2(8-1)698
data2(9-1)343
data2(10-1)
data2(11-1)
data2(12-1)
And still get zeros...
|
Re: XYChart - NoValue - DoubleArray |
Posted by Peter Kwan on Sep-10-2015 00:20 |
|
Hi Fly,
According to your code, data2(10-1) looks empty, so it is not a number and it is not
NoValue (NoValue is different from empty). VB will try to change it to a number, and
according to VB syntax, Empty or a null string is equivalent to 0 in numeric context. So
the data2(10-1) is equivalent to 0, and therefore there are effectively 0 values in the
data2 array.
We need to determine why the data2 array can contain empty values. I can think of two
possibiilities:
(a) Your code may have modified cd.NoValue. For example, if you use cd.NoValue = ""
somewhere in your code, then the cd.NoValue will have been modified to an empty string
and it no longer contains the original NoValue constant, but the empty string. If you are
using IIS/ASP, the modification may remain until the IIS is reset (enter "iisreset" from the
command line), because the IIS may cache and reuse the "ChartDirector.API" object.
(b) There may be some unexpected behaviour in your code that cause the VB Empty
value or null string to be assigned to data2. For example, mat0(i,3) may contain a non-
number that causes some unexpected value to go into data2.
To diagnose the problem, please try the following:
Response.Write("NoValue = " & cd.NoValue)
for i=1 to interval2
prix=mat0(i,1)
nb_dates = nb_dates + 1
If nb_dates = 1 Then
data2(0) = Round(mat0(i,3))
Else
If CStr(Round(mat0(i,3),0)) <> "0" Then
data2(i-1) = Round(mat0(i,3))
Response.Write("Non-NoValue data2("&i&"-1)" & data2(i-1))
Else
data2(i-1) = cd.NoValue
Response.Write("NoValue data2("&i&"-1)" & data2(i-1) & " (" & cd.NoValue & ")")
End If
End If
next
The above will help to determine the cd.NoValue really contains the NoValue constant
(which should be 1.7E+308), also trace whether cd.NoValue is assigned to data2.
Regards
Peter Kwan |
Re: XYChart - NoValue - DoubleArray |
Posted by Fly on Sep-10-2015 00:55 |
|
Gotcha!
The cd was declared AFTER the loop....
Sorry for my mistake and thank you for your time!
Wonderfull product!
Bye.
Fly |
|