TAChart/TChartLiveView: Simplify operation of ExtentY modes.

git-svn-id: trunk@65456 -
This commit is contained in:
wp 2021-07-15 16:12:39 +00:00
parent f22bca8150
commit b303ecbdd8
2 changed files with 21 additions and 21 deletions

View File

@ -6,8 +6,8 @@
</descr>
</element><element name="TChartLiveView.Active"><short>Allows to turn the scrolling controlled by the component ON and OFF.</short>
</element><element name="TChartLiveView.ExtentY"><short>Mode determining how the vertical y axis is displayed in the scrolling viewport</short>
<descr><p><var>lveAuto</var>: adjusts the height to the visible data range automatically. This works also when the chart contains several y axes.
</p><p><var>lveFull</var>: freezes the height to the full extent of the chart.</p><p><var>lveLogical</var>: freezes the height to the logical extent of the chart.</p><p><var>lveMultiAxisRange</var> tries to use a predefined <var>Range</var> of the y axes in case of a multi-axis chart. Use the <var>Range.Min</var>, <var>Range.Max</var>, <var>Range.UseMin</var> and <var>Range.UseMax</var> properties to set up the axis range. Note that the range is extended automatically when a series attached to this axis contains out-of-range y values. When no range is specified (i.e., <var>axis.Range.UseMin=false</var> and <var>axis.Range.UseMax=false</var>) the behaviour is similar to <var>lveAuto</var>.</p>
<descr><p><var>lveAuto</var>: adjusts the height to the visible data range automatically. This works also when the chart contains several y axes. Ranges assigned to the axes (by setting <var>axis.Range.Min</var> and <var>axis.Range.UseMin</var>, and/or <var>axis.Range.Max</var> and <var>axis.Range.UseMax</var>) are respected (as long as data points are within this range).
</p><p><var>lveFull</var>: freezes the height to the full extent of the chart.</p><p><var>lveLogical</var>: freezes the height to the logical extent of the chart.</p>
</descr>
</element><element name="TChartLiveView.Create"><short>Constructor of the <var>TChartLiveView</var>
</short>

View File

@ -29,7 +29,7 @@ uses
Classes, SysUtils, TAGraph, TAChartUtils;
type
TChartLiveViewExtentY = (lveAuto, lveFull, lveLogical, lveMultiAxisRange);
TChartLiveViewExtentY = (lveAuto, lveFull, lveLogical);
{ TChartLiveView }
@ -151,8 +151,9 @@ end;
procedure TChartLiveview.SetExtentY(const AValue: TChartLiveViewExtentY);
begin
if FExtentY = AValue then exit;
if FExtentY = lveAuto then
RestoreAxisRanges;
FExtentY := AValue;
RestoreAxisRanges;
FullExtentChanged(nil);
end;
@ -188,7 +189,6 @@ var
w: double;
i, j: Integer;
ymin, ymax: Double;
ygmin, ygmax: Double;
ser: TChartSeries;
ax: TChartAxis;
begin
@ -211,18 +211,10 @@ begin
lext.b.x := lext.a.x + w;
end;
case FExtentY of
lveFull:
lveAuto:
begin
lext.a.y := fext.a.y;
lext.b.y := fext.b.y;
end;
lveLogical:
;
lveAuto,
lveMultiAxisRange:
begin
lext.a.y := Infinity;
lext.b.y := -Infinity;
for i := 0 to FChart.AxisList.Count-1 do
begin
ax := FChart.AxisList[i];
@ -256,19 +248,27 @@ begin
ymax := abs(ymax) * 1.1;
end;
end;
ax.Range.Min := ymin;
ax.Range.Max := ymax;
if (FExtentY = lveMultiAxisRange) then
begin
if FAxisRanges[i].UseMin then ax.Range.Min := FAxisRanges[i].Min;
if FAxisRanges[i].UseMax then ax.Range.Max := FAxisRanges[i].Max;
end;
if FAxisRanges[i].UseMin then
ax.Range.Min := FAxisRanges[i].Min
else
ax.Range.Min := ymin;
if FAxisRanges[i].UseMax then
ax.Range.Max := FAxisRanges[i].Max
else
ax.Range.Max := ymax;
ax.Range.UseMin := true;
ax.Range.UseMax := true;
lext.a.y := Min(lext.a.y, ax.GetTransform.AxisToGraph(ymin));
lext.b.y := Max(lext.b.y, ax.GetTransform.AxisToGraph(ymax));
end; // for i
end;
lveFull:
begin
lext.a.y := fext.a.y;
lext.b.y := fext.b.y;
end;
lveLogical:
;
end;
FChart.LogicalExtent := lext;
end;