Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 3D Pie Chart
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
do_pete




PostPosted: Tue Dec 06, 2005 10:12 am   Post subject: 3D Pie Chart

This is a module I created that will draw a 2D pie chart, 2D pie chart with title, 3D pie chart, 3D pie chart with title and legend. The syntax of the command is like this:

Chart.DrawPieChart (x, y, radius : int, Items, Colours : array 1 .. * of int)

Chart.Draw3DPieChart (x, y, radius, height : int,
Items, Colours : array 1 .. * of int)

DrawPieChartWTitle (x, y, radius : int, Items, Colours : array 1 .. * of int,
title : string, font : int)

Draw3DPieChartWTitle (x, y, radius, height : int, Items,
Colours : array 1 .. * of int, title : string, font : int)

DrawLegend (x, y, font, font2 : int, text : array 1 .. * of string,
Colours : array 1 .. * of int)


x, y, and radius are pretty self-explanitory. The Items are the values that you want the pie chart to display. The colours are the colours.

When making a legend you have to have the names in an array. if you want the legend to be displayed on more than one line you use "\n". You have to more or equal amount of colours as names

Here is an example:
code:
import "Chart.tu"
var colours : array 1 .. 5 of int := init (1, 2, 3, 4, 5)
var values : array 1 .. 5 of int := init (1, 2, 3, 4, 5)
var legend : array 1 .. 7 of string := init ("Test #1", "Test #2", "\n", "Test #3", "Test #4", "\n", "Test #5")
var font1 : int := Font.New ("times new roman:12")
var font2 : int := Font.New ("times new roman:12:bold,underline")
var font3 : int := Font.New ("times new roman:14:bold,underline")
Chart.Draw3DPieChartWTitle (325, 250, 50, 15, values, colours, "3D Pie Chart", font3)
Chart.DrawLegend (260, 175, font1, font2, legend, colours)



Chart.tu
 Description:

Download
 Filename:  Chart.tu
 Filesize:  10.26 KB
 Downloaded:  162 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue Dec 06, 2005 10:40 am   Post subject: (No subject)

I like
Turing:

import "Chart.tu"
View.Set ("offscreenonly")
var colours : array 1 .. 2 of int := init (red, blue)
var values : array 1 .. 2 of int := init (1, 0)
var font3 : int := Font.New ("times new roman:14:bold,underline")
for i : 1 .. 100
    values (1) := 100 - i
    values (2) := i
    Chart.Draw3DPieChartWTitle (325, 250, 50, 15, values, colours, "Loading...", font3)
    View.Update
    delay (20)
end for
cls
colours (2) := green
Chart.Draw3DPieChartWTitle (325, 250, 50, 15, values, colours, "Done!", font3)

Laughing

Excellently done +Bits
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
do_pete




PostPosted: Tue Dec 06, 2005 11:04 am   Post subject: (No subject)

does anybody know how to make it look more like this:
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Tony




PostPosted: Tue Dec 06, 2005 11:37 am   Post subject: (No subject)

in your draw procedure, wrap the
code:

for i : 1 .. upper (Items)
...
   Draw.FillArc (x, y + height_loop, radius, radius div 2, StartAngle, EndAngle, Colours (i))

part around in another for loop, for height_loop : 0 .. desired_height

Actually it shouldn't be Filled, just the Draw.Arc for the edges.

And you'd just have to figure out a darker shade to replace Colours(i) with.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
do_pete




PostPosted: Tue Dec 06, 2005 11:54 am   Post subject: (No subject)

thanks tony! Very Happy It all makes sense now
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: