Skip to main content

Past Blast

Featured Products

Windows Mobile Developer Controls
Windows Mobile Developer Controls
Stay in touch using the DEVBUSS RSS feeds.
 

News

Windows Mobile Developer Controls
Windows Mobile Developer Controls

Pie Chart in eVB

Written by RajaSekhar Kosuri  [author's bio]  [read 31985 times]
Edited by Derek

Download the code

Page 1  Page 2  Page 3 

Introduction

Pictures speak better than words. This article helps you to display your data as a pie chart in eVB. We all know that programming in eVb is easier than other languages but drawing graphical charts like pie is not that easy as we don't have any predefined functions in eMbedded VB to draw pie charts. The application has a form consisting of three controls PictureBox, textBox and a command Button. When you click on the command button, the pie chart and a legend is displayed in the Picture Box. When you click on one of the legendry boxes, details of that particular sector are displayed in the textbox.

What You Need

Microsoft eMbedded Visual Basic version 3.0

Preface

Before answering your question "How can I use this Pie Chart in my application?", let me first tell you about the API calls and functions that have been used in this application. To your surprise, drawline and drawcircle are the only functions used in drawing the pie chart. Calculating the sectors and painting them is complicated and tricky. For those who aren't interested in the intricacies can directly add the form to their application and with minor changes done can represent their data as a pie chart.

In Command1_Click(), Initialize the variable max_values and the array input_values with the total number of values and actual values used in drawing the pie chart.

Private Sub Command1_Click()
Command1.Enabled = False
Dim input_values() As Integer
Dim max_values As Integer

    ' initialize this variable with maximum
    ' number of values used to draw the chart
    max_values = 4
    
    ' initialize this array with the actual
    ' values used to draw the chart
    ReDim input_values(max_values)

    input_values(0) = 10
    input_values(1) = 30
    input_values(2) = 75
    input_values(3) = 60
    
    ' this function draws the pie chart.
    Draw_Pie (input_values)
End Sub

Next Page