A donut graph is going to be difficult. Impossible? I do not think so however this will be a lot of work and will probably draw slowly.
Here are the tools Canvas has:
Methods
Clear()
- Clears anything drawn on this Canvas but not any background color or image.
DrawCircle(number x, number y, number r)
- Draws a circle (filled in) at the given coordinates on the canvas, with the given radius.
DrawLine(number x1, number y1, number x2, number y2)
- Draws a line between the given coordinates on the canvas.
DrawPoint(number x, number y)
- Draws a point at the given coordinates on the canvas.
DrawText(text text, number x, number y)
- Draws the specified text relative to the specified coordinates using the values of the FontSize and TextAlignment properties.
DrawTextAtAngle(text text, number x, number y, number angle)
- Draws the specified text starting at the specified coordinates at the specified angle using the values of the FontSize and TextAlignment properties.
number GetBackgroundPixelColor(number x, number y)
- Gets the color of the specified point. This includes the background and any drawn points, lines, or circles but not sprites.
number GetPixelColor(number x, number y)
- Gets the color of the specified point.
text Save()
- Saves a picture of this Canvas to the device's external storage. If an error occurs, the Screen's ErrorOccurred event will be called.
text SaveAs(text fileName)
- Saves a picture of this Canvas to the device's external storage in the file named fileName. fileName must end with one of .jpg, .jpeg, or .png, which determines the file type.
SetBackgroundPixelColor(number x, number y, number color)
- Sets the color of the specified point. This differs from DrawPoint by having an argument for color.
You can draw a circle, but it is filled in. So, you have to draw two circles, one larger than the other.
DrawCircle(number x, number y, number r)
- Draws a circle (filled in) at the given coordinates on the canvas, with the given radius.
DrawCircle(250,250, 100)
DrawCircle(250,250, 50)
then you have to partition the circle(s) into four pieces.
Trig comes to the rescue.
You can use this to partition:
DrawLine(number x1, number y1, number x2, number y2)
- Draws a line between the given coordinates on the canvas.
The first line is easy DrawLine(250 - 50, 250, 250 - 100, 250) perhaps (because you will not draw the line from 250,250 but the circumffereance of the the smaller circle, so 250 + or perhaps 250- on the x axis.
then you have to calculate where to draw the next three lines. You will need to find a point on the circumference of both the smaller and larger circles that represents the first 'pie slice'. Here is where you will need a trig operation in you Math blocks. Your next line is like your second; draw it a position of an arc representing the first piece slice plus the arc of the second perhaps. Do it one more time.
Now you have to fill in all the pixels of each segment (actually truncated pie slices).
You have a single tool to fill in the slices:
SetBackgroundPixelColor(number x, number y, number color)
- Sets the color of the specified point. This differs from DrawPoint by having an argument for color.
or perhaps use the DrawPoint and change the DrawPoint.Color
Now, you may have to calculate the position of every pixel within each segment ... possibly using a technique similar to drawing the segments themselves.
I do not think you want to do this, but if you do, or find a better way, please post the solution and your experience.
Regards,
Steve