Page 1 of 1

Single data events hidden on large line charts

Posted: Fri Sep 09, 2005 2:23 pm
by 9336419
I've a need to show the user that there is a point on my line series that is very different from the rest, for example 100,000 points may be value=50 but point 1234 may be value=80. When the chart draws, it can hide this single event. How best can I make it visible?
Thanks
Brian

Posted: Fri Sep 09, 2005 2:59 pm
by narcis
Hi Brian,

You could "play" with pointer styles, colours and with left axis scales as done in the example below. To run it put a TChart into a form and add a line series to it.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
  for i:=1 to 100000 do
    if i=1234 then Series1.Add(80)
    else Series1.Add(50);

  Series1.Pointer.Visible:=true;

  Chart1.Draw;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var
  Min, Max: double;
begin
  Min:=Series1.YValues.MinValue;
  Max:=Series1.YValues.MaxValue;

  Chart1.Axes.Left.SetMinMax(Min-20,Max+20);
end;

function TForm1.Series1GetPointerStyle(Sender: TChartSeries;
  ValueIndex: Integer): TSeriesPointerStyle;
begin
  if ValueIndex > 0 then
    if (Series1.YValue[ValueIndex]-Series1.YValue[ValueIndex-1]>10) then
      result:=FormatPointer(Sender,ValueIndex)
    else result:=psNothing
  else
    if (Series1.YValue[ValueIndex]-Series1.YValue[ValueIndex+1]>10) then
      result:=FormatPointer(Sender,ValueIndex)
    else result:=psNothing;
end;

function TForm1.FormatPointer(Sender: TChartSeries;
  ValueIndex: Integer): TSeriesPointerStyle;
begin
  (Sender as TLineSeries).Pointer.Color:=clBlue;

  result:=psRectangle;
end;

Posted: Fri Sep 09, 2005 3:38 pm
by 9336419
THanks Narcis. This works but it has also shown that I must be supressing the few high values becuase I notice that your example shows single pixel lines where the values exist, even if I plot 1,000,000 points. I will go and examine my code!
Thanks
Brian

Posted: Mon Sep 12, 2005 8:13 am
by narcis
Hi Brian,

It appears as a single pixel line because there are many points and just one with that value. However you could also change line pen width.

Posted: Mon Sep 12, 2005 8:35 am
by 9336419
Narcis, Thanks it was me. I had DrawAllPoints set false becuase this was a good speed increase at an earlier time. I think I will have to leave DrawAllPoints set true and live with the increased time. It would be great if DrawAllPoints true looked at the data and rendered the max (or min) of the data points represented by that pixel, that way anyone could still see the data extents and gain the speed advantage.
Brian

Posted: Mon Sep 12, 2005 8:36 am
by 9336419
Sorry, I meant "It would be great if DrawAllPoints FALSE looked at the data...."

Posted: Mon Sep 12, 2005 8:58 am
by narcis
Hi Brian,

Ok, I've added your request to our wish-list to be considered for future releases. However, I guess this feature can also be an inconvenient for other TeeChart users.

If you need to improve your chart's performance please read this article about optimizing TeeChart performance for real-time charting. Maybe you can apply some of those advises to your application.