Page 1 of 1

Donut Chart Annotation

Posted: Tue Aug 23, 2016 8:34 pm
by 9642129

Re: Donut Chart Annotation

Posted: Wed Aug 24, 2016 8:07 am
by Christopher
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?

Re: Donut Chart Annotation

Posted: Wed Aug 24, 2016 12:30 pm
by 9642129
I am sorry , I am not able to position "sample" in center of doughnut

Re: Donut Chart Annotation

Posted: Wed Aug 24, 2016 1:58 pm
by Christopher
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;

Re: Donut Chart Annotation

Posted: Wed Aug 24, 2016 2:42 pm
by 9642129
Thanks this worked. Just want to let you know we are in process of buying .net version of software.

Thanks for your kind support.

Re: Donut Chart Annotation

Posted: Wed Dec 07, 2016 2:57 pm
by 9642129
Is this possible to have Marks in different color based on some condition

Re: Donut Chart Annotation

Posted: Wed Dec 07, 2016 3:48 pm
by Marc
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

Re: Donut Chart Annotation

Posted: Thu Jan 05, 2017 3:49 pm
by 9642129
Can you please help me to put marks in center in donut chart.
Untitled.png
Untitled.png (13.43 KiB) Viewed 20752 times

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

Re: Donut Chart Annotation

Posted: Mon Jan 09, 2017 11:38 am
by Christopher
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.

Re: Donut Chart Annotation

Posted: Tue Jan 10, 2017 3:18 pm
by Marc
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

Re: Donut Chart Annotation

Posted: Wed Jan 11, 2017 1:21 pm
by 9642129
Perfect and Working. Thank you Marc.