Page 1 of 1

Multiple Columns in Legend?

Posted: Tue Mar 09, 2010 4:13 pm
by 16054484
Here is my situation.
I create a chart that has a somewhat short height and I include the TeeChart legend on the right side.
The problem is, I have too many data series on the graph for this legend. Not all of the series are shown in the legend's single column of data.
There are series missing from the legend because the graph isn't tall enough and the legend will not wrap to a 2nd column of information.
Is there any way to display a 2nd column in the legend?

When I place the legend on the bottom or top, the information will appear on multiple rows with multiple columns so that all of the series are included in the legend. But when placed on the left or right, nothing is done to ensure that all of the data series are shown in the legend.

Is there an option I am missing on the legend or the chart that would allow it to display multiple columns when placed on the left or right side?

Thanks for any help.
-Aaron Peronto

Re: Multiple Columns in Legend?

Posted: Tue Mar 09, 2010 5:02 pm
by narcis
Hi Aaron,

The only solution I can think of is using a LegendScrollBar tool, for example:

Code: Select all

      Steema.TeeChart.Tools.LegendScrollBar legendScrollBar1 = new Steema.TeeChart.Tools.LegendScrollBar(tChart1.Chart);

Re: Multiple Columns in Legend?

Posted: Tue Mar 09, 2010 5:29 pm
by 14045174
I've run into the same problem before and the suggested solution will not work if I'd like to print the graph... Any other ideas?

Re: Multiple Columns in Legend?

Posted: Tue Mar 09, 2010 6:14 pm
by narcis
Hi UserLS,

In that case the only solution I can think of is setting Legend.Alignment to Bottom or Top.

Re: Multiple Columns in Legend?

Posted: Tue Mar 09, 2010 9:19 pm
by 16054484
I have the exact same problem in the fact that this graph is usually produced for the purpose of printing.

Thanks for the suggestion.
I don't think bottom or top alignment will work for us in this case. The height of the graph is already small enough that taking any more vertical real estate away from the graph in order to fit the legend above or below it will probably make it too difficult to read.

Re: Multiple Columns in Legend?

Posted: Wed Mar 10, 2010 11:31 am
by narcis
Hello everyone,

Ok, I added this as a feature request (TF02014726) to the wish-list to be considered for inclusion in future releases.

Re: Multiple Columns in Legend?

Posted: Wed Mar 10, 2010 6:02 pm
by 16054484
Thanks Narcis

Re: Multiple Columns in Legend?

Posted: Thu Dec 16, 2010 11:17 am
by narcis
Hello everyone,

After reviewing this issue we think this may be already achieved using existing TeeChart for .NET functionality, for example:

Code: Select all

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

      private void InitializeChart()
      {
        tChart1.Dock = DockStyle.Fill;
        tChart1.Series.Add(typeof(Steema.TeeChart.Styles.Line)).FillSampleValues();
        tChart1.Resize += new EventHandler(tChart1_Resize);
        DoExtraLegend();
      }

      Steema.TeeChart.Tools.ExtraLegend extraLegend;
      Steema.TeeChart.Styles.Line tmpSeries;

      void tChart1_Resize(object sender, EventArgs e)
      {
        DoExtraLegend();
      }

      private void DoExtraLegend()
      {
        tChart1.Draw();
        if (tChart1[0].Count > tChart1.Legend.Items.Count)
        {
          if (extraLegend == null)
          {
            extraLegend = new Steema.TeeChart.Tools.ExtraLegend(tChart1.Chart);
          }
          if (tmpSeries == null)
          {
            tmpSeries = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            tmpSeries.Visible = false;
            tmpSeries.Color = tChart1[0].Color;
            tmpSeries.LinePen.Color = ((Steema.TeeChart.Styles.Custom)tChart1[0]).LinePen.Color;
            extraLegend.Series = tmpSeries;
          }
          tChart1.Tools.Add(extraLegend);
          tChart1.Legend.LegendStyle = Steema.TeeChart.LegendStyles.Values;
          tmpSeries.Clear();

          for (int i = tChart1.Legend.Items.Count; i < tChart1[0].Count; i++)
          {
            tmpSeries.Add(tChart1[0].YValues[i]);
          }
          extraLegend.Legend.CustomPosition = false;
          extraLegend.Legend.Alignment = Steema.TeeChart.LegendAlignments.Right;
        }
        else
        {
          if (extraLegend != null)
          {
            tChart1.Tools.Remove(extraLegend);
          }
        }
      }
Does this fit your needs?

Thanks in advance.