pie chart -> other slice -> legend

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
UserLS
Advanced
Posts: 247
Joined: Wed May 23, 2007 12:00 am

pie chart -> other slice -> legend

Post by UserLS » Mon Oct 06, 2008 5:22 pm

In general, I like the idea of having legend for the other slice, however, it appears at a very odd position. I'd like to have an option, where this "other" legend is part of the main legend, separated by a line or just indented from the main items or something along this line. Also, it would be nice to have an option to set it's title to the other slice's name.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Oct 07, 2008 8:26 am

Hi Profitstar,

Yes, this is possible doing something like this:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private void InitializeChart()
		{
			tChart1.Aspect.View3D = false;

			Steema.TeeChart.Styles.Pie pie1 = new Steema.TeeChart.Styles.Pie(tChart1.Chart);
			pie1.FillSampleValues();
						
			pie1.OtherSlice.Style = Steema.TeeChart.Styles.PieOtherStyles.BelowPercent;
			pie1.OtherSlice.Value = 10;
			pie1.OtherSlice.Legend.Visible = true;

			Bitmap bmp = tChart1.Bitmap;
			pie1.OtherSlice.Legend.CustomPosition = true;
			pie1.OtherSlice.Legend.Left = tChart1.Legend.Left;
			pie1.OtherSlice.Legend.Top = tChart1.Legend.Bottom;
		}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

UserLS
Advanced
Posts: 247
Joined: Wed May 23, 2007 12:00 am

Post by UserLS » Tue Oct 07, 2008 2:59 pm

That is great! But how my user will select this option, while setting up the graph? Remember, I am not the person, who is actually building the final graph. I just provide users with an easy interface to setup a TChart graph with characteristics, they select and data provided by our application based on their selections. So, somewhere on the screen they need to be able to select an option "put this other legend on the reasonable location". Currently, legend has a position property and it would be logical to have another option for it to "attach" it to the main legend.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Oct 07, 2008 3:33 pm

Hi Profitstar,

In that case you can implement AfterDraw event for your client's charts as shown here:

Code: Select all

    public Form1()
    {
      InitializeComponent();
      InitializeChart();
    }

    private void InitializeChart()
    {
      tChart1.Aspect.View3D = false;

      Steema.TeeChart.Styles.Pie pie1 = new Steema.TeeChart.Styles.Pie(tChart1.Chart);
      pie1.FillSampleValues();

      pie1.OtherSlice.Style = Steema.TeeChart.Styles.PieOtherStyles.BelowPercent;
      pie1.OtherSlice.Value = 10;
      pie1.OtherSlice.Legend.Visible = true;

      tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);

      Bitmap bmp = tChart1.Bitmap;
    }

    void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      foreach (Steema.TeeChart.Styles.Series  s in tChart1.Series)
      {
        if (s is Steema.TeeChart.Styles.Pie)
        {
          Steema.TeeChart.Styles.Pie p = s as Steema.TeeChart.Styles.Pie;

          if (p.OtherSlice.Style != Steema.TeeChart.Styles.PieOtherStyles.None)
          {
            p.OtherSlice.Legend.CustomPosition = true;
            p.OtherSlice.Legend.Left = tChart1.Legend.Left;
            p.OtherSlice.Legend.Top = tChart1.Legend.Bottom; 
          }
        }
      }
    }
Anyway, I'll add your request to the wish-list to be considered for inclusion in future releases.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply