Page 1 of 1

pie chart -> other slice -> legend

Posted: Mon Oct 06, 2008 5:22 pm
by 14045174
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.

Posted: Tue Oct 07, 2008 8:26 am
by narcis
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;
		}

Posted: Tue Oct 07, 2008 2:59 pm
by 14045174
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.

Posted: Tue Oct 07, 2008 3:33 pm
by narcis
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.