Recent

Author Topic: Grid resolution in TAChart  (Read 998 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Grid resolution in TAChart
« on: September 14, 2019, 09:35:37 pm »
I've hacked together a program to support a (very) cheap handheld oscilliscope that doesn't have anything existing.

Because a 'scope typically states its resolution as volts/division or msec (etc.) per division, is it possible to get TAChart to /either/ not change the total number of grid lines (i.e. you can potentially zoon in so far the grid vanishes) or to report the number of horizontal and vertical lines displayed (which is different from the zoom ratio since it doesn't change continuously)?

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: Grid resolution in TAChart
« Reply #1 on: September 15, 2019, 01:11:49 am »
Does the number of grid lines have "absolute" priority? I am asking because this conflicts with "nice" labels. Also zooming with fixed label count conflicts with nice labels.

I am attaching a demo which uses comboboxes with a variety of V/div and time/div settings. Whenever an item is selected in one of these comboboxes the axis range is calculated according to the selected V/div or time/div and a given number of divisions. A ListChartSource is assigned to the Marks of each axis which contains the labels to be used - this bypasses any automatic label calculation. Even when you zoom moderately these labels are kept, but of course they move further apart and finally will disappear. (All the settings which normally are done in the Object Inspector are done by code here so that it is easier for you to see the essential changes).

Alternatively you could set the Intervals.count of each axis to the predefined axis intervals, and activate this setting by choosing Intervals.Options := [aipUseCount]. You can bypass the ugly labels by selecting full scale values such that the divisions are nice numbers. For example when there are 6 intervals with 0.2 V/div then the axis maximum should be set to 3*0.2 = 0.6 and its minimum to -0.6 (assuming that 0 is in the center, like in a "real" oscilloscope, dividing the 6 divisions equally in positive and negative y direction). Of course, when you zoom here, there will still be 6 intervals but they will be labels with many digits... (Use the Marks.Format property to cut down the number of decimals, e.g. '%.3f' for 3 decimals only).

Of course, you can combine both methods.
« Last Edit: September 15, 2019, 11:36:26 am by wp »

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Grid resolution in TAChart
« Reply #2 on: September 15, 2019, 09:14:43 am »
Thanks, I'll take a look at that and report back later. I've tried using aipUseCount so far without success, but I must have been missing something.

I'm not actually using labels at all, purely putting up a scope-type graticule with the possibility of annotating a point using a right-click. But I want the volts/div shown on the screen to stay right, even if the divisions temporarily disappear. This whole thing obviously ties in with my question about splitters since I want to be able to force the "CRT" size to e.g. 5x4" so that cut-and-paste into notes works consistently.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: Grid resolution in TAChart
« Reply #3 on: September 17, 2019, 12:52:30 pm »
The difference appears to be that my code doesn't use explicit TListChartSource components. If I remove them from your form (and comment out the appropriate bits in the event handlers) the default grid associated with the (axis elements of the) main TAChart component appears, and that always adjusts the displayed grid to track zoom.
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018