Page 1 of 1

Custom labels not invisibilising when scrolled off

Posted: Mon Feb 28, 2011 9:25 am
by 10550286
Hi,

I recently upgraded to the 2011 version of TChart, and am using CBuilder XE. I use custom labels on some of my charts, and I have been adding extra labels off the end of the axes in case the user panned in that direction. It seems now that these labels are visible and clustering up as garbage at the edge of the panel (see attached, left side).
To experiment, I panned a chart with custom labels, and when the label should scroll off and become invisible, it now stays where it is and seems to stop refreshing (see attached, right side - the 100 should have become invisible). If I scroll back again, the label starts refreshing again and resumes normal behaviour.
I haven't yet looked further into it - so would be interested in a quick fix I can do for this problem.

Sam.

Re: Custom labels not invisibilising when scrolled off

Posted: Tue Mar 01, 2011 12:28 pm
by yeray
Hi Sam,

I'm not sure to understand what should I exactly do to reproduce the problem. Could you please arrange a simple example project we can run as-is to reproduce the problem here (or write detailed step-by-step instructions to follow from zero in a new application).

Thanks in advance.

Re: Custom labels not invisibilising when scrolled off

Posted: Wed Mar 02, 2011 1:20 am
by 10550286
I thought I was pretty clear. Quite simply, you use custom labels, and then drag the chart around to move them off the chart.

But here is your step by step guide:
Create a new project (I'm using C++ Builder XE, TChart 2011).
Plonk a TChart onto the available form.

Add at the top of the cpp file:

Code: Select all

#include <Series.hpp>
Add to the constructor:

Code: Select all

TLineSeries *thisLineSeries = new TLineSeries(Chart1);
  thisLineSeries->AddXY(1,1,"",clBlack);
  thisLineSeries->AddXY(10,10,"",clBlack);
  thisLineSeries->AddXY(100,100,"",clBlack);
  Chart1->AddSeries(thisLineSeries);
  Chart1->LeftAxis->Items->Clear();
  Chart1->LeftAxis->Items->Add(1,"1");
  Chart1->LeftAxis->Items->Add(10,"10");
  Chart1->LeftAxis->Items->Add(100,"100");
Run the application. Using the right mouse button, drag the chart around. Note the behaviour of the labels.

Re: Custom labels not invisibilising when scrolled off

Posted: Wed Mar 02, 2011 2:28 am
by 10550286
Adding this to the Scroll event seems to work:

Code: Select all

TChartAxis* Axis;
  double dValue(0);
  double dMax(0);
  double dMin(0);
  for(int AxisIndex(0); AxisIndex < Chart1->Axes->Count; AxisIndex++)
  {
    Axis = Chart1->Axes->Items[AxisIndex];
    if(!Axis->Items->Automatic)
    {
      dMax = Axis->Maximum;
      dMin = Axis->Minimum;
      for(int LabelIndex(0); LabelIndex < Axis->Items->Count; LabelIndex++)
      {
        if(Axis->Items->Item[LabelIndex]->Value > dMax ||
           Axis->Items->Item[LabelIndex]->Value < dMin)
        {
          Axis->Items->Item[LabelIndex]->LabelPos = -10;
        }
      }
    }
  }

Re: Custom labels not invisibilising when scrolled off

Posted: Wed Mar 02, 2011 3:05 pm
by yeray
Hi Sam,

Thanks for the explanation and the code. I could reproduce it so I've added it to the defect list to be fixed in future releases (TV52015428). It seems to be broken since v2010.01.
I'm glad to hear you've found a workaround.

Re: Custom labels not invisibilising when scrolled off

Posted: Thu Jun 07, 2012 8:02 am
by Marc
Hello,

Status update: An internal fix for his has been added to TeeChart for the next maintenance release.

Regards,
Marc Meumann