Recent

Author Topic: Chart (TAGraph) zoom locking bottom axis?  (Read 191 times)

jojo86

  • Jr. Member
  • **
  • Posts: 52
Chart (TAGraph) zoom locking bottom axis?
« on: March 25, 2019, 02:38:43 pm »
Hi,
I'm trying to build a Chart (TAGraph) with lazarus.
I would want to use the Zoom function, but I can't lock bottom axis position.

When I select an area on my chart, and if my selection is under 0 (negative number), my chart zoom in, but the bottom axis position move as you can see on my screen shot.
(https://zupimages.net/up/19/13/qpey.jpg)

So, how can I lock this axis position ? I tried by checking UseMin under : Marks=>Range, but same issue...
I want that this axis stay allways at the bottom even if I zoom in/out.


Thanx helping me,
« Last Edit: March 25, 2019, 02:40:51 pm by jojo86 »

wp

  • Hero Member
  • *****
  • Posts: 5635
Re: Chart (TAGraph) zoom locking bottom axis?
« Reply #1 on: March 25, 2019, 06:52:03 pm »
First of all: Whenever possible post supporting files directly in the forum; files on external servers will disappear at some time, and the post will become difficult to understand. Use "Attachments and other options" to upload files, read the explanation on file types below "Attach". When posting source code do not upload compiler-generated files such as exe, ppu etc - they will make the attachment too big, only post .pas, .lfm, .lpi and .lpr files and maybe related data files. Pack all files into a common zip to overcome the file extension restriction of the forum software.

Your question: You did not write how you perform the zooming action. There are several ways to do this in TAChart, and the answer may depend on them.

In the attachment you can find a rather general solution. It hooks into the OnExtentChanging event of the chart, measures the maximum unzoomed extent ("GetFullExtent)" covered by the data as well as the new zoomed range ("LogicalExtent"). When the zoomed extent is leaving the unzoomed extent the zoomed extent is corrected such that it stays inside the unzoomed extent. This way zooming and panning operations stay always within the range covered by the data. Panning is possible only after zooming.
« Last Edit: March 25, 2019, 06:53:39 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10