Recent

Author Topic: TChart: Autosizing Left and Right Axis - What's the trick?  (Read 1570 times)

Zitt

  • New member
  • *
  • Posts: 5
TChart: Autosizing Left and Right Axis - What's the trick?
« on: February 28, 2019, 04:58:47 am »
All,
Appreciate the feedback received in my previous GUI advice thread. I went with some of the advice; using TA3nalogGauge as the basis for the start of my GUI. I tried modifying the behavior of TA3nalogGauge to include a min and max needle; but I couldn't get it to work right.

I've added a Lazarus TChart to the GUI so I can give a chart representation of the current being utilized during the various "phases" of the RGB sequence. There are 5 configurable LED "strings" on this product; each can be configured with their own color/flashing sequence.

The Chart currently needs to display two Axis... one on the Left which shows the individual currents and one on the right which displays the total current for the entire device. I've tried in vain using the following article:
http://wiki.freepascal.org/TAChart_Tutorial:_Dual_y_axis,_Legend

but I can't seem to get the autoscale to work properly. As you can see in the picture attached; the right axis will not auto-scale correctly. I pretty sure the values never exceed 1600mA... so there is no reason for the autoscale to factor up to 32000mA.

What I need/what is for the Left and Right Axis to scale independently so both "waveforms" display at full scale.

Thoughts?

Code: Pascal  [Select]
  1.   object CurrentChart: TChart
  2.     AnchorSideLeft.Control = CurrentGauge
  3.     AnchorSideLeft.Side = asrBottom
  4.     AnchorSideTop.Control = CurrentGauge
  5.     AnchorSideRight.Control = FlashGB
  6.     AnchorSideRight.Side = asrBottom
  7.     AnchorSideBottom.Control = Owner
  8.     AnchorSideBottom.Side = asrBottom
  9.     Left = 209
  10.     Height = 231
  11.     Top = 496
  12.     Width = 367
  13.     AxisList = <    
  14.       item
  15.         Grid.Color = clBtnShadow
  16.         TickColor = clBtnFace
  17.         Marks.LabelBrush.Style = bsClear
  18.         Minors = <>
  19.         Range.Max = 1
  20.         Range.UseMin = True
  21.         Title.LabelFont.Orientation = 900
  22.         Title.LabelBrush.Style = bsClear
  23.         Transformations = LeftAxisTransformations
  24.       end    
  25.       item
  26.         Grid.Color = clBtnShadow
  27.         TickColor = clBtnFace
  28.         Alignment = calBottom
  29.         Marks.LabelBrush.Style = bsClear
  30.         Minors = <>
  31.         Range.Max = 40
  32.         Range.UseMax = True
  33.         Range.UseMin = True
  34.         Title.LabelBrush.Style = bsClear
  35.       end    
  36.       item
  37.         Alignment = calRight
  38.         Group = 1
  39.         Marks.LabelBrush.Style = bsClear
  40.         Minors = <>
  41.         Range.Max = 1
  42.         Range.UseMin = True
  43.         Title.LabelBrush.Style = bsClear
  44.         Transformations = RightAxisTransformations
  45.       end>
  46.     BackColor = clBlack
  47.     Foot.Brush.Color = clBtnFace
  48.     Foot.Font.Color = clBlue
  49.     Frame.Color = clBtnFace
  50.     Legend.Alignment = laBottomCenter
  51.     Legend.ColumnCount = 5
  52.     Legend.Transparency = 50
  53.     Legend.Visible = True
  54.     Title.Brush.Color = clBtnFace
  55.     Title.Font.Color = clBlue
  56.     Title.Text.Strings = (
  57.       'TAChart'
  58.     )        
  59.   object LeftAxisTransformations: TChartAxisTransformations
  60.     left = 248
  61.     top = 512
  62.     object LeftAxisTransform: TAutoScaleAxisTransform
  63.     end
  64.   end
  65.   object RightAxisTransformations: TChartAxisTransformations
  66.     left = 512
  67.     top = 512
  68.     object RightAxisTransform: TAutoScaleAxisTransform
  69.     end
  70.   end      
  71.  

wp

  • Hero Member
  • *****
  • Posts: 6142
Re: TChart: Autosizing Left and Right Axis - What's the trick?
« Reply #1 on: February 28, 2019, 10:25:24 am »
You do not show the series in the lfm, but I speculate that you did not assign the series' AxisIndexY to the index of the left/right axis.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Zitt

  • New member
  • *
  • Posts: 5
Re: TChart: Autosizing Left and Right Axis - What's the trick?
« Reply #2 on: February 28, 2019, 11:51:24 pm »
I'm about 80% sure I did assign both axis.
I'll look again when I get home from the day job.

Actually; I just noticed there was a TAChart subforum under "graphics"...
http://forum.lazarus.freepascal.org/index.php/board,55.0.html
Can a Mod move this topic there?
« Last Edit: March 01, 2019, 12:03:10 am by Zitt »

wp

  • Hero Member
  • *****
  • Posts: 6142
Re: TChart: Autosizing Left and Right Axis - What's the trick?
« Reply #3 on: March 01, 2019, 12:08:36 am »
I'm about 80% sure I did assign both axis.
If you did you should extract the chart part of your project with some dummy data into a simple compilable demo which you can upload here via "Attachments and other options". Put .pas, .lfm, .lpr and .lpi files into a common zip, no compiler generated files (.exe, .ppu, .compiled etc) please.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Zitt

  • New member
  • *
  • Posts: 5
Re: TChart: Autosizing Left and Right Axis - What's the trick?
« Reply #4 on: March 03, 2019, 07:06:55 am »
Indeed; I am setting axis at runtime (as is all the data).

A demo project is a little more complicated give the fact that all of the data is read runtime.

Let me ponder this.


wp

  • Hero Member
  • *****
  • Posts: 6142
Re: TChart: Autosizing Left and Right Axis - What's the trick?
« Reply #5 on: March 03, 2019, 10:29:30 am »
Please search the forum. I am rather sure that I already posted a runtime dual-axis example.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10