### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: tachart  (Read 862 times)

#### metallaro1980

• New Member
• Posts: 26
##### tachart
« on: September 05, 2019, 11:59:47 am »
there is a way to enlarge x scale?
i have a tachart where i plot the results of the transient analysis.
when the vin (pulse generator) has a high frequency the signal plotted on the tachart is very compacted. there is a way to increase x scale in order to have a plot more opened (for ex: 1us of interval -> will be a double length of original size on x axis )?
thank you very much

#### wp

• Hero Member
• Posts: 7551
##### Re: tachart
« Reply #1 on: September 05, 2019, 12:28:08 pm »
Zooming? Drag a rectangle with the left mouse button held down from the upper left to the lower right corner of the rectangle that you want to enlarge, and you will expand the scale accordingly. Clicking into the chart restores the original viewport.

You may want to have a look at the zooming chapter in the tutorial https://wiki.lazarus.freepascal.org/TAChart_Tutorial:_ColorMapSeries,_Zooming.

In code, you can zoom around a certain region of your chart using the LogicalExtent. This is a TDoubleRect record of two TDoublePoint recorda, a and b. a is the lower left corner, b the upper right corner of the range visible in the chart. Assigning new values expands the chart accordingly

Code: Pascal  [Select][+][-]
1. uses
2.   TAChartUtils;  // for TDoubleRect;
3.
4. procedure TForm1.ZoomChart(NewXMin, NewXMax: Double);
5. var
6.   ext: TDoubleRect;
7. begin
8.   ext := Chart1.LogicalExtent;
9.   ext.a.X := NewXMin;
10.   ext.b.X := NewXMax;
11.   Chart1.LogicalExtent := ext;
12. end;
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

#### metallaro1980

• New Member
• Posts: 26
##### Re: tachart
« Reply #2 on: September 05, 2019, 01:24:53 pm »
Zooming? Drag a rectangle with the left mouse button held down from the upper left to the lower right corner of the rectangle that you want to enlarge, and you will expand the scale accordingly. Clicking into the chart restores the original viewport.

You may want to have a look at the zooming chapter in the tutorial https://wiki.lazarus.freepascal.org/TAChart_Tutorial:_ColorMapSeries,_Zooming.

In code, you can zoom around a certain region of your chart using the LogicalExtent. This is a TDoubleRect record of two TDoublePoint recorda, a and b. a is the lower left corner, b the upper right corner of the range visible in the chart. Assigning new values expands the chart accordingly

Code: Pascal  [Select][+][-]
1. uses
2.   TAChartUtils;  // for TDoubleRect;
3.
4. procedure TForm1.ZoomChart(NewXMin, NewXMax: Double);
5. var
6.   ext: TDoubleRect;
7. begin
8.   ext := Chart1.LogicalExtent;
9.   ext.a.X := NewXMin;
10.   ext.b.X := NewXMax;
11.   Chart1.LogicalExtent := ext;
12. end;

not zooming
like an oscilloscope ... you can set the x/us of intervals time

#### wp

• Hero Member
• Posts: 7551
##### Re: tachart
« Reply #3 on: September 05, 2019, 01:53:55 pm »
What is the total time range between first and last data point? And how many data are to be displayed?
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

#### metallaro1980

• New Member
• Posts: 26
##### Re: tachart
« Reply #4 on: September 05, 2019, 06:04:43 pm »
What is the total time range between first and last data point? And how many data are to be displayed?
normally the transient start from 0 to 5ms
with 25us of time step
it uses the frequency of a pulse generator so 1khz for a sine wave or others parameters for a pulse wave
the ac analysis is used for example for bode diagram (you must use for example vout in frequency domain (x axis)..magnitude in db y axis)
« Last Edit: September 05, 2019, 06:17:35 pm by metallaro1980 »

#### wp

• Hero Member
• Posts: 7551
##### Re: tachart
« Reply #5 on: September 05, 2019, 07:08:03 pm »
I still don't understand why this is not zooming. Please post a screenshot of what TAChart is outputting and of what you expect to see. If you have a measurement file please post it too (provided that it is easily readable).
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

#### metallaro1980

• New Member
• Posts: 26
##### Re: tachart
« Reply #6 on: September 05, 2019, 08:42:34 pm »
I still don't understand why this is not zooming. Please post a screenshot of what TAChart is outputting and of what you expect to see. If you have a measurement file please post it too (provided that it is easily readable).

i must have an enlarged plot with maybe scrollbar (horiz)
where for example instead of one interval (the x space from  0us to maybe 25us) 2 intervals..so
from 0us to 12.5us one interval
from 12.5us to 25us another one interval.
all this until 5ms

« Last Edit: September 05, 2019, 08:52:53 pm by metallaro1980 »

#### wp

• Hero Member
• Posts: 7551
##### Re: tachart
« Reply #7 on: September 05, 2019, 10:59:31 pm »
OK - I think I got the point now. Please study the attached demo. It uses some demo data similar to your screenshot and adds a scrollbar which is adjusted such that only a 12.5 us wide window of the entire data set covering 5 ms is visible. Using the scrollbar the window can be advanced in steps of 12.5 us over the chart. Just for curiosity I added an option to activate other time windows, 25 us and 50 us.

I don't give a deeper explanation here - just see the demo sources, there are lots of comments to explain why I did this and that.

Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

#### metallaro1980

• New Member
• Posts: 26
##### Re: tachart
« Reply #8 on: September 06, 2019, 12:53:53 pm »
OK - I think I got the point now. Please study the attached demo. It uses some demo data similar to your screenshot and adds a scrollbar which is adjusted such that only a 12.5 us wide window of the entire data set covering 5 ms is visible. Using the scrollbar the window can be advanced in steps of 12.5 us over the chart. Just for curiosity I added an option to activate other time windows, 25 us and 50 us.

I don't give a deeper explanation here - just see the demo sources, there are lots of comments to explain why I did this and that.

ok thank you very much !
i've done it !