I have an issue using Delphi 2007 & TChart 7.0.10.0 or 7.0.11.0 or the latest evaluation 9.0.5.0 on the TChart scaling.
The problem arises as soon I enlarge the window after a certain width and KEEP the Form height!
This is the drawing using a smaller form size.
now if I enlarge to 1200 weight I get this ugly scaling:
If I export in the designer without the aspect ratio set and with 1200 weight you will se this:
How to get ride of this?
Hp
I see you've set top and bottom margins to Chart1 in your project (8 and 20 percent respectively). I guess this has the intention of giving more space (in height) for Chart2 when you resize the form making it bigger.
Chart1's Top and Height properties should be set according to fill this blank space in the Form's OnResize event.
Try this:
procedure TGSSkillgroupStatisticForm.FormResize(Sender: TObject);
begin
Chart1.Draw;
Chart2.Top:=Chart1.ChartRect.Bottom + 25;
Chart2.Height:=Chart1.Height-Chart1.ChartRect.Bottom-40;
end;
Steema Support Central
Keep in mind that I only scale in the x-axis. Your 3-D bar / construct will after a certain width, overlap the scaling numbers! Your given answer do not fix this issue at all. To see the real problem in a better way, I added on the form creation:
Chart2.BottomAxis.Maximum := 20;
Series2.AddBar(12, 'Hallo', clred);
Here the result:
Related
In a Delphi 10.4.2 VCL Application in Windows 10, how can I calculate the height of a TCategoryButtons object at run-time, i.e. the sum of all its button heights and its Category items, as this height could vary depending on its font size?
Measuring the pixel heights at run-time, I have noticed that all buttons have the same height and that the buttons have a different height as the Category items.
Also, note that the buttons do not have a published Height property in the Object Inspector.
But shouldn't it be possible to calculate the sum of all its button heights and its Category items with some low-level methods?
This is a control entirely implemented in Pascal, in Vcl.CategoryButtons.pas.
Therefore, you can see exactly how it is implemented. For instance, in TCategoryButtons.Paint you see its complete drawing code. Similarly, you can investigate the hit testing done in MouseMove (or MouseDown or MouseUp).
Consequently, if nothing else, you can create your own modified version of TCategoryButtons using this code. Your version can save the total height when it has been determined (for instance, certainly after painting).
However, after a quick look, it seems like TButtonCategory.Bounds might be interesting. If you are lucky, this returns the on-screen rect of a category. The Bottom of the last category's rect should be the (effectively used) height of the entire control.
It seems to work for me:
Here I draw a red bar of the same height as the control.
procedure TForm5.FormPaint(Sender: TObject);
begin
var y := CategoryButtons1.Categories[
CategoryButtons1.Categories.Count - 1
].Bounds.Bottom;
Canvas.Brush.Color := clRed;
Canvas.FillRect(Rect(0, 0, ClientWidth, y))
end;
How can I calculate the exact width of the border of a TSpeedButton?
Depending on the values of the Flat and Down properties it seems to have a different width and a text starts at a different pixel. (with Margin <> -1 and no glyph set)
Delphi 10.2.3
I'm trying to figure it out how to set a fixed size to the bars' width in TChart.
I've tried to search a lot for a similar "problem", but I may be using the wrong terms, because I found no related topics in the internet.
My chart has Horizontal Scrolling enabled, so I would like to have bars with the same width regardless how many bars are in the chart.
Here's a sample where I added 10 sample values and, for my purpose, this bar width is acceptable:
But when I add 40 sample values, for example, the bars became so thin, even when showing only 10 values and letting all the others visible only after scroll the bars to the left:
Here's the code I'm using to add the sample values (just for you to see there's nothing special):
procedure TForm5.Button1Click(Sender: TObject);
var
i: Integer;
begin
for i := 0 to ChartFatGrupoPerc.SeriesCount-1 do
ChartFatGrupoPerc.Series[i].FillSampleValues(StrToInt(eItems.Text));
ChartFatGrupoPerc.BottomAxis.Maximum := StrToInt(eMax.Text);
ChartFatGrupoPerc.BottomAxis.Minimum := StrToInt(eMin.Text);
end;
So, the question is: Is there an way I can define the bars' width regardless the amount of values?
Thanks in advance,
Kelver Merlotti [KM]
Is there an way I can define the bars' width regardless the amount of values?
Yes, setting these properties would do the trick:
AutoBarSize := false;
CustomBarWidth := aSuitableNumber;
I have put a tchart on a delphi form (XE4) and make the width 65535 pixels (the maximum). I have set the scale of the bottom axis to fixed values (minimum 0, maximum 65534) and then I add values using something like:
for i := 0 to 60000 do
chart1.series[0].addXY(i, 10 + (i mod 80));
The result is some strange behaviour with additional lines being plotted on locations where they shouldn't be, while any point beyond 32767 is missing. The same thing happens when setting the maximum of the bottom axis to for example 5000 and fill the whole thing with 'only' 100 samples between 0 and 5000. Remarkable is the fact that some combinations of adding values close to the maximum value of the bottom axis do seem to work (even beyond 32767 pixels from the left).
Does anyone has some insight into the reasons of this behaviour? Is there any way to solve this problem aside from not using tcharts with a width over 32767 pixels?
TFastLineSeries is not available in TeeChart Lite for FMX, but it is in TeeChart Standard for VCL.
See the feature matrix here.
I've been able to reproduce the problem in a VCL project using a TLineSeries, so I've added it to the public tracker. In the meanwhile, if you are in VCL you can change to a TFastLineSeries.
On my notebook with a screen resolution of 1280x800 I've developed an application. Now I want to use it on a desktop computer with a resolution of 1600x1200.
Of course, it's too small on the desktop computer. I've set the sizes so that I could see the whole form on my notebook. But on the desktop computer, everything should be resized.
But on the large screen, things shouldn't be viewed bigger which means that the same amount of information can be displayed. Things should get a higher height and width value so that more information can be displayed.
In complicated code I mean something like this which should run automatically once when the form is created (OnCreate):
devResolutionX := 1280;
devResolutionY := 800;
useResolutionX := 1600; // how to get / read out this property?
useResolutionY := 1200; // how to get / read out this property?
Form1.Height := Form1.Height+devResolutionY-useResolutionY;
Form1.Height := Form1.Width+devResolutionX-useResolutionX;
// do that with all components which makes this approach complicated
What must I work with to reach that goal?
ScaleBy
alignments
anchors
Thank you very much in advance!
It looks like you just need to set the BorderStyle property of your form to bsSizeable. This will allow the user to resize the form (or maximize it) as he sees fit.
You will also want to make use of anchors here. If you set the akLeft, akTop, akRight, and akBottom anchors for all the components on your form, they will resize with the form.
As soon as you do this, though, you will probably quickly realize that wasn't actually what you wanted to do after all. These growing components are probably going to overlap with each other. So, you are going to need to put some thought into which edges of which components get anchored and which don't.
Sometimes you will need to do some more complicated component moving and sizing than can be handled by anchors alone. In these cases, you will want to handle the Form's OnResize event. This event will get fired whenever the user resizes the form, and it will give you the chance to do some math to recalulate the sizes and positions of certain components.
Just set your anchors correctly and the additional info will show. I wouldn't recommend programmatically forcing an arbitrary height and width. The best thing to do is use the form's OnClose event to save the form's height and width and then set the height and width with OnCreate.