LegendScrollBar problem with Inverted Legend

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

LegendScrollBar problem with Inverted Legend

Post by Amol » Mon Aug 09, 2010 10:43 am

I have a chart with Legend visible and a LegendScrollBar added. We needed to have the ordering for legend reversed so I added Legend.Inverted=True to my code. The legend inverted all right but the LegendScrollBar didn't and now the scroll bar is working opposite to expectation.

I couldn't find any API to invert the LegendScrollBar as well. I also tried inverting the legend both before and after the LegendScrollBar was added - no effect.

Any ideas?

We are currently using Teechart .Net 2 for VS2005

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: LegendScrollBar problem with Inverted Legend

Post by Yeray » Wed Aug 11, 2010 3:57 pm

Hi Amol

This is a known bug already in the defect list to be fixed in future releases (TV52012536).
The only workaround I can think on is not to set the Inverted property and use GetLegendText to invert the strings. For example:

Code: Select all

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

            Steema.TeeChart.Styles.FastLine fast1 = new Steema.TeeChart.Styles.FastLine(tChart1.Chart);

            for (int i = 0; i < 200; i++)
            {
                fast1.Add(i);
            }

            //tChart1.Legend.Inverted = true;
            Steema.TeeChart.Tools.LegendScrollBar legendscroll1 = new Steema.TeeChart.Tools.LegendScrollBar(tChart1.Chart);

            tChart1.GetLegendText += new Steema.TeeChart.GetLegendTextEventHandler(tChart1_GetLegendText);
        }

        void tChart1_GetLegendText(object sender, Steema.TeeChart.GetLegendTextEventArgs e)
        {
            e.Text = tChart1[0].YValues[tChart1[0].Count - e.Index - 1].ToString();
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Amol
Advanced
Posts: 176
Joined: Mon May 29, 2006 12:00 am

Re: LegendScrollBar problem with Inverted Legend

Post by Amol » Thu Aug 12, 2010 12:49 pm

Thats too bad.

The workaround works but only for the text. Since we are also using groups, series colours, and check boxes, simply correcting the text would not be sufficient.

Is a workaround possible by inverting the legend positions with GetLegendPos() ? Or does that event only controls the complete legend rectangle and not the individual series?


As an addition, the problem is coming because we are using both stacked area series and unstacked point and line series in the same chart. This works only when the stacked series are added first - otherwise the unstacked point and line series become stacked as well. However, in the legend it is a requirement to show the point and line series first.

With this scenario, is there a better workaround possible?

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: LegendScrollBar problem with Inverted Legend

Post by Yeray » Fri Aug 13, 2010 1:13 pm

Hi Amol,
Amol wrote:Is a workaround possible by inverting the legend positions with GetLegendPos() ? Or does that event only controls the complete legend rectangle and not the individual series?
This event gives you the coordinates where each item of the legend is going to be drawn. You could use it to draw your text manually over the legend but it won't change the checkboxes behaviour.
Amol wrote:As an addition, the problem is coming because we are using both stacked area series and unstacked point and line series in the same chart. This works only when the stacked series are added first - otherwise the unstacked point and line series become stacked as well. However, in the legend it is a requirement to show the point and line series first.
It doesn't happen with the latest version of TeeChart for .NET so I recommend you to try it: http://www.steema.com/evaluation/net

Here the following seems to work as expected:

Code: Select all

        Random rnd;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart1.Legend.CheckBoxes = true;

            Steema.TeeChart.Styles.Points points1 = new Steema.TeeChart.Styles.Points(tChart1.Chart);
            Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            Steema.TeeChart.Styles.Area area1 = new Steema.TeeChart.Styles.Area(tChart1.Chart);
            Steema.TeeChart.Styles.Area area2 = new Steema.TeeChart.Styles.Area(tChart1.Chart);

            rnd = new Random();
            for (int i = 0; i < tChart1.Series.Count; i++)
            {
                if (tChart1[i] is Steema.TeeChart.Styles.Area)
                    AddValues(i, 0);
                else
                    AddValues(i, 100);
            }

            points1.Stacked = Steema.TeeChart.Styles.CustomStack.None;
            line1.Stacked = Steema.TeeChart.Styles.CustomStack.None;
            area1.Stacked = Steema.TeeChart.Styles.CustomStack.Stack;
            area2.Stacked = Steema.TeeChart.Styles.CustomStack.Stack;

            Bitmap b = tChart1.Bitmap;
            tChart1.Axes.Left.Automatic = false;
        }

        private void AddValues(int SeriesIndex, int MinValue)
        {
            tChart1[SeriesIndex].Add(MinValue + rnd.NextDouble() * 100);
            for (int i = 1; i < 10; i++)
                tChart1[SeriesIndex].Add(tChart1[SeriesIndex].YValues[i - 1] + rnd.NextDouble() * 10 - 4.5);
        }
However, note that adding the area series after the other, make them to be drawn the lasts, so they can overlap the point or the line series if they have similar YValues.
So probably the best way to do this would be creating your own custom legend manually.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

15688831
Newbie
Newbie
Posts: 4
Joined: Wed Jun 03, 2020 12:00 am

Re: LegendScrollBar problem with Inverted Legend

Post by 15688831 » Tue Jun 16, 2020 6:53 am

It's been a while since last post here, but issue is still reproducible for me even on TeeChart 4.2020.5.12 version.

Inverted legend also has inverted scrolling Is it possible to get inverted legend without scrolling affected?

Thank you.

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

Re: LegendScrollBar problem with Inverted Legend

Post by Christopher » Wed Jun 17, 2020 4:06 pm

wrote:
Tue Jun 16, 2020 6:53 am
Inverted legend also has inverted scrolling Is it possible to get inverted legend without scrolling affected.
You could try something like this:

Code: Select all

        private void InitializeChart()
        {
            var line = new Line(_tChart.Chart);

            for (int i = 0; i < 100; i++)
            {
                line.Add(i);
            }

            _tChart.Legend.FirstValue = line.Count - 20;

            _tChart.Legend.Inverted = true;

            _tChart.Tools.Add(typeof(LegendScrollBar));
        }
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

Post Reply