mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 20:10:27 +02:00
Merged revision(s) 65470-65471 #15a417978a-#15a417978a from trunk:
TAChart/TChartLiveView: Simplification ........ TAChart/LiveView demo: fix typo. ........ git-svn-id: branches/fixes_2_2@65484 -
This commit is contained in:
parent
272b12351f
commit
cfa1013f51
@ -15,7 +15,6 @@
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
@ -43,7 +42,7 @@
|
||||
<Unit1>
|
||||
<Filename Value="main.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="MainFrom"/>
|
||||
<ComponentName Value="MainForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit1>
|
||||
|
@ -19,7 +19,7 @@ begin
|
||||
RequireDerivedFormResource:=True;
|
||||
Application.Scaled:=True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TMainFrom, MainFrom);
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
end.
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
object MainFrom: TMainFrom
|
||||
object MainForm: TMainForm
|
||||
Left = 299
|
||||
Height = 446
|
||||
Top = 130
|
||||
@ -7,7 +7,7 @@ object MainFrom: TMainFrom
|
||||
ClientHeight = 446
|
||||
ClientWidth = 723
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '2.1.0.0'
|
||||
LCLVersion = '2.3.0.0'
|
||||
object Chart1: TChart
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
@ -106,7 +106,6 @@ object MainFrom: TMainFrom
|
||||
Width = 69
|
||||
BorderSpacing.Left = 24
|
||||
Caption = 'Viewport size'
|
||||
ParentColor = False
|
||||
Visible = False
|
||||
end
|
||||
object seViewportSize: TFloatSpinEdit
|
||||
@ -120,7 +119,6 @@ object MainFrom: TMainFrom
|
||||
Width = 73
|
||||
Alignment = taRightJustify
|
||||
BorderSpacing.Left = 8
|
||||
MaxValue = 0
|
||||
OnChange = seViewportSizeChange
|
||||
TabOrder = 2
|
||||
Value = 5
|
||||
@ -170,7 +168,6 @@ object MainFrom: TMainFrom
|
||||
Width = 40
|
||||
BorderSpacing.Left = 24
|
||||
Caption = 'ExtentY'
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
object ChartNavScrollBar1: TChartNavScrollBar
|
||||
|
@ -10,9 +10,9 @@ uses
|
||||
|
||||
type
|
||||
|
||||
{ TMainFrom }
|
||||
{ TMainForm }
|
||||
|
||||
TMainFrom = class(TForm)
|
||||
TMainForm = class(TForm)
|
||||
btnAddDataPoint: TButton;
|
||||
Chart1: TChart;
|
||||
Chart1LineSeries1: TLineSeries;
|
||||
@ -38,7 +38,7 @@ type
|
||||
end;
|
||||
|
||||
var
|
||||
MainFrom: TMainFrom;
|
||||
MainForm: TMainForm;
|
||||
|
||||
implementation
|
||||
|
||||
@ -47,9 +47,9 @@ implementation
|
||||
uses
|
||||
Math, TAChartUtils;
|
||||
|
||||
{ TMainFrom }
|
||||
{ TMainForm }
|
||||
|
||||
procedure TMainFrom.btnAddDataPointClick(Sender: TObject);
|
||||
procedure TMainForm.btnAddDataPointClick(Sender: TObject);
|
||||
const
|
||||
TWO_PI = 2.0 * pi;
|
||||
var
|
||||
@ -60,7 +60,7 @@ begin
|
||||
Chart1Lineseries1.AddXY(x, y);
|
||||
end;
|
||||
|
||||
procedure TMainFrom.cbFixedExtentChange(Sender: TObject);
|
||||
procedure TMainForm.cbFixedExtentChange(Sender: TObject);
|
||||
begin
|
||||
Chart1.Extent.YMin := -1.5;
|
||||
Chart1.Extent.YMax := 1.5;
|
||||
@ -68,7 +68,7 @@ begin
|
||||
Chart1.Extent.UseYMax := cbFixedExtent.Checked;
|
||||
end;
|
||||
|
||||
procedure TMainFrom.cbLiveModeChange(Sender: TObject);
|
||||
procedure TMainForm.cbLiveModeChange(Sender: TObject);
|
||||
begin
|
||||
ChartLiveView1.Active := cbLiveMode.Checked;
|
||||
seViewportSize.Visible := cbLiveMode.Checked;
|
||||
@ -77,12 +77,12 @@ begin
|
||||
lblExtentY.Visible := cbLiveMode.Checked;
|
||||
end;
|
||||
|
||||
procedure TMainFrom.cbExtentYChange(Sender: TObject);
|
||||
procedure TMainForm.cbExtentYChange(Sender: TObject);
|
||||
begin
|
||||
ChartLiveView1.ExtentY := TChartLiveViewExtentY(cbExtentY.ItemIndex);
|
||||
end;
|
||||
|
||||
procedure TMainFrom.FormCreate(Sender: TObject);
|
||||
procedure TMainForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
// Add three data points to start with
|
||||
btnAddDataPointClick(nil);
|
||||
@ -95,7 +95,7 @@ begin
|
||||
cbExtentY.ItemIndex := ord(ChartLiveView1.ExtentY);
|
||||
end;
|
||||
|
||||
procedure TMainFrom.seViewportSizeChange(Sender: TObject);
|
||||
procedure TMainForm.seViewportSizeChange(Sender: TObject);
|
||||
begin
|
||||
ChartLiveView1.ViewportSize := seViewportSize.Value;
|
||||
end;
|
||||
|
@ -198,7 +198,7 @@ var
|
||||
fext, lext: TDoubleRect; // "full extent", "logical extent" variables
|
||||
w: double;
|
||||
i, j: Integer;
|
||||
yminAx, ymaxAx, yminSer, ymaxSer: Double;
|
||||
ymin, ymax: Double;
|
||||
dy: Double;
|
||||
ser: TChartSeries;
|
||||
axis: TChartAxis;
|
||||
@ -238,8 +238,8 @@ begin
|
||||
// Ignore x-axes
|
||||
if (axis.Alignment in [calTop, calBottom]) then
|
||||
Continue;
|
||||
ymaxAx := -Infinity;
|
||||
yminAx := Infinity;
|
||||
ymax := -Infinity;
|
||||
ymin := Infinity;
|
||||
// Step through all active non-rotated series attached to this axis
|
||||
for j := 0 to FChart.SeriesCount-1 do
|
||||
begin
|
||||
@ -248,50 +248,46 @@ begin
|
||||
ser := TChartSeries(FChart.Series[j]);
|
||||
if (not ser.Active) or (ser.GetAxisY <> axis) or ser.IsRotated then
|
||||
continue;
|
||||
yminSer := Infinity;
|
||||
ymaxSer := -Infinity;
|
||||
ser.FindYRange(lext.a.x, lext.b.x, yminSer, ymaxSer);
|
||||
yminAx := Min(yminAx, yminSer);
|
||||
ymaxAx := Max(ymaxAx, ymaxSer);
|
||||
ser.FindYRange(lext.a.x, lext.b.x, ymin, ymax);
|
||||
end;
|
||||
end;
|
||||
// Only if an axis has no active non-rotated series, we have -infinity
|
||||
if ymaxAx > -Infinity then
|
||||
if ymax > -Infinity then
|
||||
begin
|
||||
if ymaxAx = yminAx then
|
||||
if ymax = ymin then
|
||||
begin
|
||||
if yminAx = 0 then
|
||||
if ymin = 0 then
|
||||
begin
|
||||
yminAx := -1;
|
||||
ymaxAx := +1;
|
||||
ymin := -1;
|
||||
ymax := +1;
|
||||
end
|
||||
else
|
||||
// Set the range to 10% around the value, take care of the sign!
|
||||
begin
|
||||
dy := abs(yminAx) * 0.1;
|
||||
yminAx := yminAx - dy;
|
||||
ymaxAx := ymaxAx + dy;
|
||||
dy := abs(ymin) * 0.1;
|
||||
ymin := ymin - dy;
|
||||
ymax := ymax + dy;
|
||||
end;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
yminAx := -1;
|
||||
ymaxAx := +1;
|
||||
ymin := -1;
|
||||
ymax := +1;
|
||||
end;
|
||||
// Only if the user did not set its own range we set the axis range
|
||||
// determined above.
|
||||
if (not FAxisRanges[i].UseMin) then
|
||||
begin
|
||||
axis.Range.Min := yminAx;
|
||||
axis.Range.Min := ymin;
|
||||
axis.Range.UseMin := true; // we had stored the original UseMin in FAxisRanges
|
||||
lext.a.y := axis.GetTransform.AxisToGraph(yminAx);
|
||||
lext.a.y := Min(lext.a.y, axis.GetTransform.AxisToGraph(ymin));
|
||||
end;
|
||||
if (not FAxisRanges[i].UseMax) then
|
||||
begin
|
||||
axis.Range.Max := ymaxAx;
|
||||
axis.Range.Max := ymax;
|
||||
axis.Range.UseMax := true; // we had stored the original UseMax in FAxisRanges
|
||||
lext.b.y := axis.GetTransform.AxisToGraph(ymaxAx);
|
||||
lext.b.y := Max(lext.b.y, axis.GetTransform.AxisToGraph(ymax));
|
||||
end;
|
||||
end; // series loop
|
||||
end; // axes loop
|
||||
|
Loading…
Reference in New Issue
Block a user