|
Issue with c.makePicture |
Posted by hanson on Aug-06-2012 23:22 |
|
Hi,
I got problem with c.makePicture.
when i tried to run the code below, i was reminded that failed to change from type
"System.__ComObject" to "System.Drawing.Image".
The code was successful until "AxChartViewer1.Picture = c.makePicture".
hope you can tell me how can I continue my code.
thanks a lot in advance!
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
Dim cd As New ChartDirector.API
'The data for the bar chart
Dim data() As Integer = New Integer() {85, 156, 179.5, 211, 123}
'The labels for the bar chart
Dim labels() As String = New string() {"Mon", "Tue", "Wed", "Thu", "Fri"}
'Create a XYChart object of size 250 x 250 pixels
Dim c As ChartDirector.XYChart
c = cd.XYChart(250, 250)
'Set the plotarea at (30, 20) and of size 200 x 200 pixels
c.setPlotArea(30, 20, 200, 200)
'Add a bar chart layer using the given data
c.addBarLayer(data)
'Set the x axis labels using the given labels
c.xAxis().setLabels(labels)
'output the chart
AxChartViewer1.Picture = c.makePicture
'include tool tip for the chart
AxChartViewer1.ImageMap = c.getHTMLImageMap("clickable", "", _
"title='{xLabel}: US${value}K'")
End Sub |
Re: Issue with c.makePicture |
Posted by hanson on Aug-06-2012 23:28 |
|
BTW, I am using visual basic in VS 2008. |
Re: Issue with c.makePicture |
Posted by Peter Kwan on Aug-07-2012 01:37 |
|
Hi hanson,
For your case, you are using "ChartDirector for ASP/COM/VB" in VB 2008. Instead of using "ChartDirector for ASP/COM/VB", I suggest you to use "ChartDirector for .NET" for VB 2008.
The "ChartDirector for ASP/COM/VB" is designed for COM based systems, such as classical VB6, VBScript and VBA systems. To use it in .NET based systems (such as VB.NET, VB 2003, 2005, 2008, 2010), "COM Interop" has to be used, which automatically translates COM data types to .NET data types. This works for simple data types, such as numbers, text strings and arrays. However, for some complex objects (such as OLE Picture), there may be issues.
On the other hand, "ChartDirector for .NET" is a native .NET assembly, and can work with all CLR compliant languages directly, such as VB 2008. For the ActiveX ChartViewer Control, in "ChartDirector for .NET", it is replaced with the .NET Windows Forms WinChartViewer control.
Regards
Peter Kwan |
Re: Issue with c.makePicture |
Posted by hanson on Aug-07-2012 15:51 |
|
Hi Peter,
Thanks a lot for your help! |
|