|
Error Contour Chart in vb6 |
Posted by akim on Feb-02-2010 14:29 |
|
The code is..
BEGIN=============================================
Public Sub createChart(viewer As Object)
Dim cd As New ChartDirector.API
Dim xx As Single
Dim c As XYChart
Dim layer As ContourLayer
Set layer = Nothing
Set c = cd.XYChart(825, 510)
Call c.addTitle(JudulContour, "ariali.ttf", 10, &HFFFFFF)
Call c.setPlotArea(45, 40, 750, 380, -1, -1, -1, c.dashLineColor(&H80000000, cd.DefaultShading), -1)
Call c.yAxis().setLinearScale(-90, 90, 30)
Call c.XAxis().setLinearScale(-180, 180, Array("", 210, 240, 270, 300, 330, 0, 30, 60, 90, 120, 150, 180))
' SetLabelX
' Add a contour layer using the given data
Set layer = c.addContourLayer(dataX, dataY, dataZ)
Call layer.setColorAxis(400, 445, cd.TopCenter, 450, cd.Bottom).setLogScale2(10, 1000000, Array("10<*super*>1", "10<*super*>2", "10<*super*>3", "10<*super*>4", "10<*super*>5", "10<*super*>6"))
' xx = MaxVal
' Move the grid lines in front of the contour layer
Call c.getPlotArea().moveGridBefore(layer)
Call c.addText(c.getPlotArea().getLeftX() + c.getPlotArea().getWidth() / 2, c.getPlotArea().getTopY() + 7 + c.getPlotArea().getHeight() / 2, "<*img=world_map_ok.gif*>", "normal", 8, &H0, cd.Center)
Call c.setColors(cd.whiteOnBlackPalette) ' Output the chart
Call layer.setSmoothInterpolation(False)
Call layer.setContourColor(cd.Transparent)
Call layer.ColorAxis().setColorGradient(True)
Call layer.ColorAxis().setTitle("electron/cm2/sec/ster")
Set viewer.Chart = Nothing
Set viewer.Picture = c.makePicture()
End Sub
Private Sub cmdnext_Click()
Call getdataMax(period1 to period2 )
Call ChartViewer1.updateViewPort(True, True)
Call GetReport
End Sub
Private Sub ChartViewer1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 0 Then
' Mouse is over chart with mouse button released (not dragging)
' Update image map if necessary
Call updateImageMap(ChartViewer1)
End If
End Sub
'
' User clicks on a hot spot on the chart
'
Private Sub ChartViewer1_ClickHotSpot(hotSpot As Collection, Button As Integer, Shift As Integer, _
X As Single, Y As Single)
' We show the pop up dialog only when the mouse action is not zoom in or zoom out
If ChartViewer1.MouseUsage <> cvZoomIn And ChartViewer1.MouseUsage <> cvZoomOut Then
'In this demo, just list out the information provided by ChartDirector about hot spot
ParamViewer.Display hotSpot, "symbol", Me.typeenergi.Text
End If
End Sub
END==============================================================
when I Click button "Prev" or "Next" then show the error.
what should i do...
|
Re: Error Contour Chart in vb6 |
Posted by Peter Kwan on Feb-02-2010 19:52 |
|
Hi akim,
First, please find out which line causes the problem. You may set a breakpoint in createChart and single step the code. If you are sure the problem is generated in createChart, please use the following method to trouble-shoot the problem:
Please modify createChart to:
Public Sub createChart(viewer As Object)
Dim cd As New ChartDirector.API
Dim xx As Single
Dim c As XYChart
Dim layer As ContourLayer
Set c = cd.XYChart(825, 510)
Call c.setPlotArea(45, 40, 750, 380)
Set layer = c.addContourLayer(dataX, dataY, dataZ)
Call layer.setSmoothInterpolation(False)
Call layer.setContourColor(cd.Transparent)
Call layer.ColorAxis().setColorGradient(True)
Set viewer.Chart = Nothing
Set viewer.Picture = c.makePicture()
End Sub
Please check if the error still occurs. If it does not occur, then try to add the code back, one line by one line, until the error occurs. This may help to identify the cause of the problem.
If the error occurs when you add back the setLogScale line, it may be because the data contains invalid values (it is invalid to use negative or zero values in log scale).
When the error occurs, please insert code to dump the data, like:
Open "c:\\dataX" For Output As #1
Dim i As Integer
For i = 0 To UBound(dataX)
Print #1, dataX(i)
Next
Close #1
Open "c:\\dataY" For Output As #2
For i = 0 To UBound(dataY)
Print #2, dataY(i)
Next
Close #2
Open "c:\\dataZ" For Output As #3
For i = 0 To UBound(dataZ)
Print #3, dataZ(i)
Next
Close #3
Then please inform me of the code that can produce the error, and the data files dataX, dataY and dataZ
Regards
Peter Kwan |
Re: Error Contour Chart in vb6 |
Posted by akim on Feb-03-2010 00:53 |
|
hi, Peter
sorry my english
first thank for your suggestion. the code was modified in createchart like this..
1.Public Sub createChart(viewer As Object)
2. Dim cd As New ChartDirector.API
3. Dim xx As Single
4. Dim c As XYChart
5. Dim layer As ContourLayer
6. Set c = cd.XYChart(825, 510)
7. Call c.setPlotArea(45, 40, 750, 380)
8. Set layer = c.addContourLayer(dataX, dataY, dataZ)
9. Call layer.setSmoothInterpolation(False)
10. Call layer.setContourColor(cd.Transparent)
11. Call layer.ColorAxis().setColorGradient(True)
12. Set viewer.Chart = Nothing
13. Set viewer.Picture = c.makePicture()
14. End Sub
the error still occurs in line 13, when I click button "Next".
examples data for dataX,dataY,dataZ
dataX=(10,20,-30,45,50,11,7,210...)
dataY=(10,20,-30,-45,50,11,-7,-10...)
dataX=(1000,20000,0.50,450,5000,1200,70,210...)
please what should i do....
Regards
akim |
Re: Error Contour Chart in vb6 |
Posted by Peter Kwan on Feb-03-2010 19:37 |
|
Hi Akim,
I have tested using your code and your data. There is no error in my case.
I think the data in your last message is not the complete data. May be you can provide me with the complete data for testing. Just save your data to three files and zip them and attached the zip file. The code to store the data array to files are:
Public Sub createChart(viewer As Object)
Open "c:\\dataX" For Output As #1
Dim i As Integer
For i = 0 To UBound(dataX)
Print #1, dataX(i)
Next
Close #1
Open "c:\\dataY" For Output As #2
For i = 0 To UBound(dataY)
Print #2, dataY(i)
Next
Close #2
Open "c:\\dataZ" For Output As #3
For i = 0 To UBound(dataZ)
Print #3, dataZ(i)
Next
Close #3
Dim cd As New ChartDirector.API
Dim xx As Single
Dim c As XYChart
Dim layer As ContourLayer
Set c = cd.XYChart(825, 510)
Call c.setPlotArea(45, 40, 750, 380)
Set layer = c.addContourLayer(dataX, dataY, dataZ)
Call layer.setSmoothInterpolation(False)
Call layer.setContourColor(cd.Transparent)
Call layer.ColorAxis().setColorGradient(True)
Set viewer.Chart = Nothing
Set viewer.Picture = c.makePicture()
End Sub
I will wait for your data files for dataX, dataY and dataZ.
Regards
Peter Kwan
|
Re: Error Contour Chart in vb6 |
Posted by akim on Feb-04-2010 10:26 |
|
Hi Peter,
The error has been solved. error occurs when the dataX,dataY,dataZ is EMPTY(my query is wrong).
thank you peter
regard
akim |
|