hi
I create a Dynamic pie chart ,how i can draw percent or other string in parts of chart?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int i1;
int i2;
int i3;
int i4;
float total;
float deg1 ;
float deg2 ;
float deg3 ;
float deg4;
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
i1 = int.Parse(textBox1.Text);
i2 = int.Parse(textBox2.Text);
i3 = int.Parse(textBox3.Text);
i4 = int.Parse(textBox4.Text);
total = i1 + i2 + i3 + i4;
deg1 = (i1 / total) * 360;
deg2 = (i2 / total) * 360;
deg3 = (i3 / total) * 360;
deg4 = (i4 / total) * 360;
Pen p = new Pen(Color.Black, 2);
Graphics g = this.CreateGraphics();
Rectangle rec = new Rectangle(textBox1.Location.X + textBox1.Size.Width + 10, 12, 150, 150);
Brush b1 = new SolidBrush(Color.Red);
Brush b2 = new SolidBrush(Color.Blue);
Brush b3 = new SolidBrush(Color.Black);
Brush b4 = new SolidBrush(Color.BlueViolet);
SolidBrush BlackBrush = new SolidBrush(Color.Black);
g.Clear(Form1.DefaultBackColor);
g.DrawPie(p, rec, 0, deg1);
g.FillPie(b1, rec, 0, deg1);
g.DrawPie(p, rec, deg1, deg2);
g.FillPie(b2, rec, deg1, deg2);
g.DrawPie(p, rec, deg2 + deg1, deg3);
g.FillPie(b3, rec, deg2 + deg1, deg3);
g.DrawPie(p, rec, deg3 + deg2 + deg1, deg4);
g.FillPie(b4, rec, deg3 + deg2 + deg1, deg4);
}
}
}