Recent

Author Topic: TCalculatedChartSource produces wrong axis ranges  (Read 5820 times)

Magpie5212

  • New Member
  • *
  • Posts: 16
TCalculatedChartSource produces wrong axis ranges
« on: January 13, 2014, 10:16:51 am »
I have built a chart program to monitor a source via a XinoRF.  I added a calculated source to produce a smoothed line (camAverage).

When I turn on the calculated line the Y range suddenly jumps way out of scale.  For example when I am smoothing a temperature that ranges from 15 to 18 degrees the range maximum suddenly jumps to over 350.  However, the smooth line shown on the chart appears to track the input source.

Anyone else using TCalculatedLineSource seen this? 

How do I examine the data being transferred from the calculated line to the corresponding TLineSeries?

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: TCalculatedChartSource produces wrong axis ranges
« Reply #1 on: January 13, 2014, 12:37:59 pm »
Please post some code, if possible, as a simplified compilable project showing the issue

Magpie5212

  • New Member
  • *
  • Posts: 16
Re: TCalculatedChartSource produces wrong axis ranges
« Reply #2 on: January 13, 2014, 02:57:40 pm »
I am working on it, but my first attempts don't reveal the problem.  Obviously too much simplification.

Magpie5212

  • New Member
  • *
  • Posts: 16
Re: TCalculatedChartSource produces wrong axis ranges
« Reply #3 on: January 13, 2014, 06:04:09 pm »
First it appears that this fails on Linux (Raspberry Pi) with v0.9.30.4-6 but not on Windows with v1.0.14. 

It appears that the range goes astray when adding points dynamically on the Origin range.

Code: [Select]
unit Main;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, TAGraph, TASources, TASeries, Forms, Controls,
  Graphics, Dialogs, ExtCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    CalculatedChartSource1: TCalculatedChartSource;
    Chart1: TChart;
    Chart1LineSeries1: TLineSeries;
    Chart1LineSeries2: TLineSeries;
    ListChartSource1: TListChartSource;
    Timer1: TTimer;
    procedure FormActivate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  i: integer;
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormActivate(Sender: TObject);

begin
  for i:= 1 to 40 do
    ListChartSource1.Add(Double(i),Double(Random(100)/20+10),'Dummy', clBlack);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  i+=1;
  ListChartSource1.Add(Double(i),Double(Random(100)/20+10),'Dummy', clBlack);
  if i>60 then
    Timer1.Enabled:=False;
end;

end.

The form is:
Code: [Select]
object Form1: TForm1
  Left = 270
  Height = 446
  Top = 133
  Width = 534
  Caption = 'Form1'
  ClientHeight = 446
  ClientWidth = 534
  OnActivate = FormActivate
  LCLVersion = '0.9.30.4'
  object Chart1: TChart
    Left = 0
    Height = 446
    Top = 0
    Width = 534
    AxisList = <   
      item
        Title.LabelFont.Orientation = 900
      end   
      item
        Alignment = calBottom
      end>
    Foot.Brush.Color = clBtnFace
    Foot.Font.Color = clBlue
    Title.Brush.Color = clBtnFace
    Title.Font.Color = clBlue
    Title.Text.Strings = (
      'TAChart'
    )
    Align = alClient
    ParentColor = False
    object Chart1LineSeries1: TLineSeries
      LinePen.Width = 2
      Source = ListChartSource1
    end
    object Chart1LineSeries2: TLineSeries
      LinePen.Color = clYellow
      LinePen.Width = 4
      Source = CalculatedChartSource1
    end
  end
  object ListChartSource1: TListChartSource
    left = 80
    top = 53
  end
  object CalculatedChartSource1: TCalculatedChartSource
    AccumulationMethod = camAverage
    AccumulationRange = 10
    Origin = ListChartSource1
    left = 197
    top = 85
  end
  object Timer1: TTimer
    OnTimer = Timer1Timer
    left = 195
    top = 177
  end
end

wp

  • Hero Member
  • *****
  • Posts: 11854
Re: TCalculatedChartSource produces wrong axis ranges
« Reply #4 on: January 13, 2014, 10:36:11 pm »
I tested your program on Ubuntu with Laz trunk / fpc 2.62, and it runs fine. I guess the problems that you are seeing are due to the fairly old version that you use on Raspberry. There has been considerable progress from v0.9.30 to 1.0 and to the upcoming 1.2, and I'd recommend that you update your Lazarus on the Pi to at least 1.0.14 or 1.2RC1.

Magpie5212

  • New Member
  • *
  • Posts: 16
Re: TCalculatedChartSource produces wrong axis ranges
« Reply #5 on: January 14, 2014, 09:13:24 am »
Thanks - I was guessing that would be the best thing.  Just need to find out how to get past the standard install for the Raspberry Pi (apt-get install lazarus).

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: TCalculatedChartSource produces wrong axis ranges
« Reply #6 on: January 14, 2014, 08:36:51 pm »
Recently I had opportunity to check out Laz on a RaspBerry Pi with the latest Raspbian Wheezy.

Didnt upgrade from 0.9, but these are the recommendations I found how to do it:

Install subversion on the Raspberry to get a trunk version of Laz.

Dont run startx, build Laz from the prompt. If you go into the windowed environment Laz might not compile because of lack of memory. Maybe thats the reason for the make errors you mentioned in another thread.

If its necessary, you can get more memory by running raspi-config from the prompt and set the shared graphics memory to 64mb or maybe lower.

Laz 0.9 seemed to run just fine and charts were surprisingly snappy. Now the borrowed Raspberry is back to its owner.
« Last Edit: January 14, 2014, 08:53:47 pm by kapibara »
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

 

TinyPortal © 2005-2018