Page 1 of 1
Percentage Circle chart
Posted: Wed Jul 11, 2007 10:08 am
by 8119968
Dear All,
I have the following data at 1AM = 80%, 2AM = 60%, 3AM = 75%, etc. I want to plot these data as a small pie chart in each hour with the percentage - like the the full circle is 100% so that I can draw a filled 80% of circle at 1AM, and 60% of circle at 2AM.
Is there anyway of doing this?
Regards,
Leng
Posted: Thu Jul 12, 2007 7:55 am
by Chris
Hello!
I have the following data at 1AM = 80%, 2AM = 60%, 3AM = 75%, etc. I want to plot these data as a small pie chart in each hour with the percentage - like the the full circle is 100% so that I can draw a filled 80% of circle at 1AM, and 60% of circle at 2AM.
Is there anyway of doing this?
Sure, you can use the Pie.AngleSize property, e.g.
Code: Select all
private Steema.TeeChart.Styles.Pie series1;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(series1 = new Pie());
//80% of 360
int angle = Steema.TeeChart.Utils.Round(360 * 0.8);
series1.RotationAngle = 90;
series1.AngleSize = angle;
series1.Add(80);
}
Posted: Thu Jul 12, 2007 8:14 am
by 8119968
Hi Christopher,
Many thanks for your reponse. By using pie chart we can have only a single series indeed and it's not within the X, Y Axis at all. What I would like to have is using X, Y axis and small circles inside like points style but with the percentage inside as in your example.
I would like to have basically many pies as the one in your example along X, Y axis.
Please advise.
LG
Posted: Thu Jul 12, 2007 10:47 am
by Chris
Hello!
What I would like to have is using X, Y axis and small circles inside like points style but with the percentage inside as in your example.
I see. Well, you could derive your own series type. Here's an example:
Code: Select all
public class PercentageCircle : Points
{
private int pieRadius;
public PercentageCircle() : this((Chart)null) { }
public PercentageCircle(Chart c) : base(c)
{
pieRadius = 50;
Marks.Visible = true;
Marks.Arrow.Visible = false;
Marks.ArrowLength = pieRadius + 5;
}
protected override void SetChart(Chart c)
{
base.SetChart(c);
if (c != null)
{
c.Legend.TextStyle = LegendTextStyles.Plain;
}
}
public int PieRadius
{
get { return pieRadius; }
set { pieRadius = value; }
}
protected override void DoBeforeDrawChart()
{
base.DoBeforeDrawChart();
GetVertAxis.MaximumOffset = PieRadius;
GetVertAxis.MinimumOffset = PieRadius;
GetHorizAxis.Labels.Style = AxisLabelStyle.Value;
GetHorizAxis.MaximumOffset = PieRadius;
GetHorizAxis.MinimumOffset = PieRadius;
}
public override void DrawValue(int valueIndex)
{
if (!IsNull(valueIndex) || (TreatNulls == TreatNullsStyle.Ignore))
{
Graphics3D g = Chart.Graphics3D;
int xPos = CalcXPos(valueIndex);
int yPos = CalcYPos(valueIndex);
double angle = 360 * (YValues[valueIndex] / 100.0);
System.Drawing.Color oldColor = g.Brush.Color;
bool oldGradientVisible = g.Brush.Gradient.Visible;
g.Pen = LinePen;
g.Brush.Color = ValueColor(valueIndex);
g.Brush.Gradient.Visible = false;
g.Pie(xPos - pieRadius, yPos - pieRadius, xPos + pieRadius, yPos + pieRadius, 0, angle);
g.Brush.Color = oldColor;
g.Brush.Gradient.Visible = oldGradientVisible;
}
}
}
And you could then use it thus:
Code: Select all
private PercentageCircle series1;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(series1 = new PercentageCircle());
series1.Add(80, "80%");
series1.Add(60, "60%");
series1.Add(75, "75%");
}
Posted: Fri Jul 13, 2007 5:12 am
by 8119968
Hi
Many thanks for your help. It works okay for me!
I am using the version 1.1.1544.23908 and I have minor problme with
as it does not exists. When drawing the first pie will never draw but it does draw the second pie. Any idea why?
Again, thanks alot for your useful advice!
Regards,
LG
Posted: Fri Jul 13, 2007 10:36 am
by Chris
Hello,
TreatNullsStyle is a teechart.net v3 feature. Maybe it's time you upgraded