Donut Chart Annotation
Posted: Tue Aug 23, 2016 8:34 pm
Steema Software - Customer Support Forums
http://teechart.com/support/
Code: Select all
Steema.TeeChart.Tools.Annotation tAnnot = new Annotation(chart);
tChart1.Tools.Add(tAnnot);
tAnnot.Text = "Sample";
tAnnot.Shape.Transparent = true;
tAnnot.Shape.Font.Size = 25;
tAnnot.Shape.CustomPosition = true;
tChart1.Draw();
tAnnot.Shape.Left = donut1.CircleXCenter - tAnnot.Bounds.Width / 2;
tAnnot.Shape.Top = donut1.CircleYCenter - tAnnot.Bounds.Height / 2;
return param;
Code: Select all
//add event
donut1.GetSeriesMark += new Steema.TeeChart.Styles.Series.GetSeriesMarkEventHandler(donut1_GetSeriesMark);
private void donut1_GetSeriesMark(Series series, GetSeriesMarkEventArgs e)
{
if (e.ValueIndex == 3) //add your criteria, here 4th point
series.Marks.Font.Color = Color.White;
else
series.Marks.Font.Color = Color.Black;
}
I think you should be able to use the technique for custom positioning of marks which you can see here.rpt wrote:Can you please help me to put marks in center in donut chart.
Code: Select all
donut.Marks.Visible = false;
//use Chart’s AfterDraw event
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
Steema.TeeChart.Styles.Donut dnt = (Steema.TeeChart.Styles.Donut)tChart1[0];
donut.Marks.Visible = false;
for (int i=0; i < dnt.Count; i++)
{
//use these integers for plot coords
int startxx;
int startyy;
int endxx;
int endyy;
//outside permiter halfway on each point
dnt.AngleToPos(dnt.Angles[i].MidAngle, dnt.XRadius, dnt.YRadius, out startxx, out startyy);
//get halfway as fraction, from donut hole to exterior
double halfwayloc = 1.0-(1.0 - (dnt.DonutPercent / 100.0)) / 2.0;
//get centre location for each Mark
dnt.AngleToPos(dnt.Angles[i].MidAngle, dnt.XRadius * halfwayloc, dnt.YRadius * halfwayloc, out endxx, out endyy);
//setup Font
g.Font.Size = 14;
g.Font.Name = "Microsoft Sans Serif";
//Get Mark text
string myText = dnt.ValueMarkText(i);
//output Text
g.TextOut(endxx - (int)(g.TextWidth(myText)/2), endyy - (g.FontHeight/2), dnt.ValueMarkText(i));
}
}