Recent

Author Topic: How to fix the size of the plot area?  (Read 33972 times)

CM630

  • Hero Member
  • *****
  • Posts: 1579
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How to fix the size of the plot area?
« Reply #30 on: September 12, 2012, 09:17:12 am »
Here is a problem when using multiple series on the same chart (like in TAChart axis demo)- when zooming, I usually need to zoom only horizontally- i.e. to see only a part of the duration of the process (i.e. between 3,450 secs to 3,65 secs). I think that this case will not be a problem.
Anyway, sometimes I have to zoom vertically only one of the series, and the rest to become unchanged. In fact, when I zoom (with the mouse) only the area is the mouse dragged area is show, which means, that only pieces of one of the series are shown. Do you think that what I want is doable, or I shall use separate charts for each series?
Still I wonder which of the two is the better solution...
I have attached an image, to explain things better.


BTW, I have the same problem for all the graphics demo- controls (usually TACHARTS) keep resizing with the form window. I could not find which property is responsible for that?
« Last Edit: September 12, 2012, 10:33:30 am by paskal »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: How to fix the size of the plot area?
« Reply #31 on: September 12, 2012, 10:16:30 am »
... controls (usually TACHARTS) keep resizing with the form window. I could not find which property is responsible for that?
Usually that is Align or Anchors property.

If you want graph to not scale when resizing, you can modify the max visible range be linearly relative to window size. You can do that in some onResize event, or there might be some other property in chart that already does that (i've never used it).

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: How to fix the size of the plot area?
« Reply #32 on: September 12, 2012, 10:58:51 am »
Quote
zoom only horizontally
Yes, that is easy. See e.g.
http://wiki.lazarus.freepascal.org/TAChart_documentation#Zoom_click_tool and
http://wiki.lazarus.freepascal.org/TAChart_documentation#Extent_limits

Quote
zoom vertically only one of the series, and the rest to become unchanged
This is also not too hard, but need more precise definition:
Should the zoomed-in series expand above and below its usual range and overlap neighbor series? If so, should the corresponding axis marks also expand?
Alternatively, maybe other series should shrink to make room for the zoomed one?

In any case, while there is no pre-defined tool for this, you can either use
user-defined tool
or your own descendant to capture key/mouse combinations,
and either direct manipulation of axis transformation coefficients or
auto-scaling transformation for the actual zoomig.

See "axistransf"  demo for various examples, especially "Independent scale" page.

A nave also noticed that marks on the left axis are quite cramped.
There are properties in Axis.Marks to control axis intervals -- the may be useful.
« Last Edit: September 12, 2012, 11:06:09 am by Ask »

CM630

  • Hero Member
  • *****
  • Posts: 1579
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How to fix the size of the plot area?
« Reply #33 on: September 12, 2012, 12:06:01 pm »
Quote
zoom only horizontally
Yes, that is easy. See e.g.
http://wiki.lazarus.freepascal.org/TAChart_documentation#Zoom_click_tool and
http://wiki.lazarus.freepascal.org/TAChart_documentation#Extent_limits
I rather used that as a part of the explanation, since I think that I've done it before. In case I have not- it will be useful to have a hint.

Quote
Should the zoomed-in series expand above and below its usual range and overlap neighbor series? If so, should the corresponding axis marks also expand?
No, I do not want the chart to overlap the other, I want what is visible to be displayed in the same rectangle as before zooming.

Quote
Alternatively, maybe other series should shrink to make room for the zoomed one?
I prefer to have all the graphics with the equal height, so I do not want any of them to change.

Quote
In any case, while there is no pre-defined tool for this, you can either use
user-defined tool
or your own descendant to capture key/mouse combinations,
and either direct manipulation of axis transformation coefficients or
auto-scaling transformation for the actual zoomig.

See "axistransf"  demo for various examples, especially "Independent scale" page.
Well I already tend to use separate charts.

Quote
A nave also noticed that marks on the left axis are quite cramped.
There are properties in Axis.Marks to control axis intervals -- the may be useful.
That is why because I changed a line in the example:
Code: [Select]
for j := 1 to 20 do ls.AddXY(j, random*8); became
Code: [Select]
for j := 1 to 20 do ls.AddXY(j, i*(4-random*8);IMHO, it looks much better- all series have different amplitudes, + they have negative and positive values.

Since, I have no idea how to get around this:
Quote
BTW, I have the same problem for all the graphics demo- controls (usually TACHARTS) keep resizing with the form window. I could not find which property is responsible for that?
« Last Edit: September 12, 2012, 12:11:17 pm by paskal »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: How to fix the size of the plot area?
« Reply #34 on: September 12, 2012, 04:29:53 pm »
Quote
, I do not want the chart to overlap the other, I want what is visible to be displayed in the same rectangle as before zooming
So you want to cut the selected series to some specific extent?
Indeed, there is no such feature currently, so try many charts.
You may find TChartExtentLink component useful in that case.

Quote
it looks much better- all series have different amplitudes
I was talking about the features of the axis itself, not the data:
http://wiki.lazarus.freepascal.org/TAChart_documentation#Axis_intervals

... controls (usually TACHARTS) keep resizing with the form window. I could not find which property is responsible for that?
Usually that is Align or Anchors property.

Did you try that?

CM630

  • Hero Member
  • *****
  • Posts: 1579
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How to fix the size of the plot area?
« Reply #35 on: September 13, 2012, 07:43:02 am »
Oops, that's it "align".
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

CM630

  • Hero Member
  • *****
  • Posts: 1579
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How to fix the size of the plot area?
« Reply #36 on: November 05, 2012, 01:35:19 pm »
Quote from: wp
axis title can only be single-lined in TAChart.
Not so, see http://wiki.lazarus.freepascal.org/TAChart_documentation#Multi-line_marks and "Multiline" page of the "labels" demo.
I did
Code: [Select]
Chart1.LeftAxis.Title.Visible:=True;
Chart1.LeftAxis.Title.Caption:=Line1 + #10#13 + Line2 + #10#13 + Line3;

I got Line1□□Line2□□Line3.
Since wiki says „Multi-line marks
If the mark text contains LineEnding character sequence, it is split into several lines. Lines of different length are aligned according to Alignment property.
“ and „const LineEnding = #10;
I tried
Code: [Select]
Chart1.LeftAxis.Title.Visible:=True;
Chart1.LeftAxis.Title.Caption:=Line1 + #10 + Line2 + #10 + Line3;
Then I got Line1□Line2□Line3.
Both wiki and labelsdemo are about mark text, not about axis title.
So either @wp is right or I cannot understand how to do things properly?
« Last Edit: November 05, 2012, 01:36:58 pm by paskal »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

wp

  • Hero Member
  • *****
  • Posts: 13334
Re: How to fix the size of the plot area?
« Reply #37 on: November 05, 2012, 04:17:29 pm »
Try #13#10

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: How to fix the size of the plot area?
« Reply #38 on: November 05, 2012, 05:56:17 pm »
Quote
const LineEnding = #10;
Where did you see that? What platform are you on?

CM630

  • Hero Member
  • *****
  • Posts: 1579
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How to fix the size of the plot area?
« Reply #39 on: November 06, 2012, 07:52:06 am »
Try #13#10
Silly me, of course #10#13 should not work, since it is LfCr, and the right combination is CrLf. I've been mislead, that both values are reverse, because in fact LfCr works in showmessage('something'+#10#13+'else') (whether it should is another question).

Quote
const LineEnding = #10;
Where did you see that? What platform are you on?
First you go there: http://wiki.lazarus.freepascal.org/TAChart_documentation#Multi-line_marks and when you click on LineEnding you get to http://www.freepascal.org/docs-html/rtl/system/lineending.html.
It says:
Quote
LineEnding
Constant describing the current line ending character.
Declaration
Source position: sysunixh.inc line 28
const LineEnding = #10;...
In the labels demo I changed AText += Format(#13#10'%.9g', [AMark * 2]);   to AText += Format(#10'%.9g', [AMark * 2]);   and the lines do not get broken.

I see two proper options:
1. Wiki shall be fixed if LineEnding = #10 (Lf) it shall point to something else.
2. TChart shall be changed to fit the Wiki. I do not know which line break is more consistent with Pascal, but I tried ShowMessage ('Line1'+#10+'Line2')' and the line got properly broken.
Otherwise, considering the origin of LineFeed and CarriageReturn, only CrLf (and LfCr, but it is not a standard combination anywhere) makes sense.
« Last Edit: November 06, 2012, 08:05:02 am by paskal »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: How to fix the size of the plot area?
« Reply #40 on: November 06, 2012, 08:34:58 am »
LineEnding is a cross-platform constant, which is #13#10 on Windows,
#10 on Linux and some other platforms.
This fact is unfortunately not reflected in the wiki docs.

CM630

  • Hero Member
  • *****
  • Posts: 1579
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How to fix the size of the plot area?
« Reply #41 on: November 06, 2012, 08:51:56 am »
Does it mean that AText += Format(#10'%.9g', [AMark * 2]); shall work in Linux?
I thought that #10 (Lf) and #13#10 (CrLf) are OS specific only for the (bundled) text editors.

Edit: In Linux it works both ways (#13#10 and #10). I wonder if #13#10 shall be recommended in wiki, in order to overcome system dependency, but who knows how will it behave on Mac.
« Last Edit: November 06, 2012, 09:50:10 am by paskal »
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

CM630

  • Hero Member
  • *****
  • Posts: 1579
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: How to fix the size of the plot area?
« Reply #42 on: April 20, 2013, 03:03:57 pm »
IMHO there is something wrong with the titles of the right border.
Here is the source:
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
const
  CrLf = #13 + #10;
begin
  chart1.LeftAxis.Title.Font.Name:= 'Courier New';
  chart1.LeftAxis.Title.Visible:=True;
  chart1.LeftAxis.Title.Caption:= '1'+crlf+'2'+crlf+'3';

  chart2.LeftAxis.Title.Font.Name:= 'Courier New';
  chart2.LeftAxis.Title.Visible:=True;
  chart2.LeftAxis.Title.Caption:= ' '+crlf+' '+crlf+'3'; //The is a space between the quotes in ' '

  chart3.LeftAxis.Title.Font.Name:= 'Courier New';
  chart3.LeftAxis.Title.Visible:=True;
  chart3.LeftAxis.Title.Caption:= crlf+crlf+'3';

  chart4.LeftAxis.Title.Font.Name:= 'Courier New';
  chart4.LeftAxis.Title.Visible:=True;
  chart4.LeftAxis.Title.Caption:= crlf+crlf+crlf+crlf+crlf+crlf+crlf+crlf+crlf+crlf+crlf+crlf+crlf+crlf+crlf+crlf+crlf+crlf+'3';
end;       
As you can see, CrLF has a different height in comparison with other characters, which is wrong.
On the other side, as it seen from Chart4, the height of CrLf is not 0, but something else.
Лазар 4,4 32 bit (sometimes 64 bit); FPC3,2,2

 

TinyPortal © 2005-2018