Friday, August 12, 2011

making animated charts in vb

for more information visit :www.gurukpo.com
A simple example: Creating a pie chart
1. Create a Visual Basic project.

2. Open the component window using CTRL + T or by selecting the ‘Component’ option from the ‘Project’ menu. Next, select FusionCharts for VB, and then click ‘Apply’ and finally the ‘OK’ button.
 

3. Notice, that a FusionCharts icon has now been added to the toolbox.
 
4. Double click the FusionCharts icon – a chart control will be added to the Form, with a 3D column chart displayed by default. FusionCharts for VB supports multiple data input methods - from XML string (called dataXML method), XML file (called dataURL method), using individual data input, arrays and from databases too.
Since I said this will be a simple example, we will be taking a look at only the dataXML and Individual Data input method. And we will use the other methods in other examples later on in the tutorial.
5. Add the following three buttons to the Form: 
Control
Name
Caption
Command1 cmdIndividualData &Individual data
Command2 cmdXMLString XML &String
Command3 cmdExit E&xit


6. Switch to the code view and enter the following code in the code window.

Private Sub cmdExit_Click()
    End
End Sub

Private Sub cmdIndividualData_Click()
    FusionCharts1.ChartType = pie3d
    FusionCharts1.Data.setChartParams "caption=Match Score; xAxisName=Player Name;yAxisName=Score"
    FusionCharts1.Data.addChartData "90", "label=David"
    FusionCharts1.Data.addChartData "70", "label=Josh"
    FusionCharts1.Data.addChartData "80", "label=Brain"
    FusionCharts1.RenderChart
End Sub

Private Sub cmdXMLString_Click()
    Dim XML As String
    XML = "<chart caption='Match Score' xAxisName='Player Name' yAxisName='Score'><set value='90' label='David' /><set value='70' label='Josh' /><set value='85' label='Brain' /></chart>"
    FusionCharts1.ChartType = pie3d
    FusionCharts1.setDataXML = XML
End Sub


7. Press F5 to run the project - the following screen will be displayed. The screen doesn’t display a chart as data is yet to be loaded.


8. Click on ‘Using Function’ or ‘XML String’ button – a 3D pie chart will be displayed.


 

Text Box: Explanation of the Code    •	cmdExit_Click(): This function terminates all processes and quits the application.  •	cmdXMLString_Click(): This function creates the XML string and passes it to the chart using the dataXML method.  •	cmdUsingFunction_Click(): This function automatically creates XML for the chart – using the AddChartData API.  •	setChartParams(): This function configures various parameters of the chart such as; caption, X axis name, Y axis name etc.   •	FusionCharts1.ChartType: This property is used for selecting the type of chart which is to be plotted. For the above example ‘FusionCharts1.ChartType’ was set to ‘pie 3d’.  •	RenderChart(): This function performs the task of rendering the chart.




No comments:

Post a Comment