Donut Chart Annotation

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
rpt
Newbie
Newbie
Posts: 24
Joined: Wed Aug 09, 2006 12:00 am

Donut Chart Annotation

Post by rpt » Tue Aug 23, 2016 8:34 pm


Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Donut Chart Annotation

Post by Christopher » Wed Aug 24, 2016 8:07 am

Hello,

Many thanks for the links to your code, however, it is not clear to me what your issue is here, or what you would like to achieve. Would you please be so kind as to explain what you would like to see on the Chart?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

rpt
Newbie
Newbie
Posts: 24
Joined: Wed Aug 09, 2006 12:00 am

Re: Donut Chart Annotation

Post by rpt » Wed Aug 24, 2016 12:30 pm

I am sorry , I am not able to position "sample" in center of doughnut

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Donut Chart Annotation

Post by Christopher » Wed Aug 24, 2016 1:58 pm

Hello,

No problem, thank you - you can get this to work with:

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;
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

rpt
Newbie
Newbie
Posts: 24
Joined: Wed Aug 09, 2006 12:00 am

Re: Donut Chart Annotation

Post by rpt » Wed Aug 24, 2016 2:42 pm

Thanks this worked. Just want to let you know we are in process of buying .net version of software.

Thanks for your kind support.

rpt
Newbie
Newbie
Posts: 24
Joined: Wed Aug 09, 2006 12:00 am

Re: Donut Chart Annotation

Post by rpt » Wed Dec 07, 2016 2:57 pm

Is this possible to have Marks in different color based on some condition
Attachments
untitled.png
untitled.png (16.52 KiB) Viewed 20825 times

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Donut Chart Annotation

Post by Marc » Wed Dec 07, 2016 3:48 pm

Hello,

This would be a way to achieve it:

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;

    }
series.ValueColor(e.ValueIndex) would give you the Point colour if you were to wish to check by that.


Regards,
Marc
Steema Support

rpt
Newbie
Newbie
Posts: 24
Joined: Wed Aug 09, 2006 12:00 am

Re: Donut Chart Annotation

Post by rpt » Thu Jan 05, 2017 3:49 pm

Can you please help me to put marks in center in donut chart.
Untitled.png
Untitled.png (13.43 KiB) Viewed 20758 times

Source :https://github.com/dekajp/TeeChart-for- ... ms-samples

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Donut Chart Annotation

Post by Christopher » Mon Jan 09, 2017 11:38 am

rpt wrote:Can you please help me to put marks in center in donut chart.
I think you should be able to use the technique for custom positioning of marks which you can see here.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Donut Chart Annotation

Post by Marc » Tue Jan 10, 2017 3:18 pm

Hello,

As an alternative approach, you can turn off Marks and plot them yourself to take more control. This code centres them.

Eg.

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));
      }
    }
You could add more sophistication. If the slice is small you could reduce the Font size (eg. if ((dnt.Angles.StartAngle - dnt.Angles.EndAngle) < somevalue) .. make font smaller…)

Or change the colour of the mark if the slice is a dark colour or light, etc.

I hope that may be of help.

Regards,
Marc
Steema Support

rpt
Newbie
Newbie
Posts: 24
Joined: Wed Aug 09, 2006 12:00 am

Re: Donut Chart Annotation

Post by rpt » Wed Jan 11, 2017 1:21 pm

Perfect and Working. Thank you Marc.

Post Reply