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
LegendScrollBar problem with Inverted Legend
Re: LegendScrollBar problem with Inverted Legend
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:
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: LegendScrollBar problem with Inverted Legend
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?
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?
Re: LegendScrollBar problem with Inverted Legend
Hi Amol,
Here the following seems to work as expected:
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.
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: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?
It doesn't happen with the latest version of TeeChart for .NET so I recommend you to try it: http://www.steema.com/evaluation/netAmol 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.
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);
}
So probably the best way to do this would be creating your own custom legend manually.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: LegendScrollBar problem with Inverted Legend
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.
Inverted legend also has inverted scrolling Is it possible to get inverted legend without scrolling affected?
Thank you.
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: LegendScrollBar problem with Inverted Legend
You could try something like this:wrote: ↑Tue Jun 16, 2020 6:53 amInverted legend also has inverted scrolling Is it possible to get inverted legend without scrolling affected.
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 |