mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-10 13:39:14 +02:00
TAChart: Update barseriestools demo.
git-svn-id: trunk@54310 -
This commit is contained in:
parent
00d819c364
commit
c45e27567f
@ -224,9 +224,9 @@ object MainForm: TMainForm
|
||||
end
|
||||
object DataPointDragTool: TDataPointDragTool
|
||||
Shift = [ssRight]
|
||||
OnBeforeMouseDown = DataPointDragToolBeforeMouseDown
|
||||
Targets = [nptPoint, nptXList, nptYList]
|
||||
OnDrag = DataPointDragToolDrag
|
||||
OnDragStart = DataPointDragToolDragStart
|
||||
end
|
||||
end
|
||||
object ChartStyles: TChartStyles
|
||||
|
@ -39,18 +39,18 @@ type
|
||||
LogSplitter: TSplitter;
|
||||
procedure DataPointClickToolPointClick(ATool: TChartTool;
|
||||
APoint: TPoint);
|
||||
procedure DataPointDragToolBeforeMouseDown(ATool: TChartTool; APoint: TPoint
|
||||
);
|
||||
procedure DataPointDragToolDrag(ASender: TDataPointDragTool;
|
||||
var AGraphPoint: TDoublePoint);
|
||||
procedure DataPointDragToolDragStart(ASender: TDataPointDragTool;
|
||||
var AGraphPoint: TDoublePoint);
|
||||
procedure DataPointHintToolHint(ATool: TDataPointHintTool;
|
||||
const APoint: TPoint; var AHint: String);
|
||||
procedure CbHorizontalChange(Sender: TObject);
|
||||
procedure Cb100PercentChange(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure ToolTargetChanged(Sender: TObject);
|
||||
|
||||
private
|
||||
FDragStart: TDoublePoint;
|
||||
|
||||
public
|
||||
|
||||
@ -66,8 +66,10 @@ implementation
|
||||
uses
|
||||
LCLType;
|
||||
|
||||
|
||||
{ TMainForm }
|
||||
|
||||
{ Flip x and y axes of the chart }
|
||||
procedure TMainForm.CbHorizontalChange(Sender: TObject);
|
||||
begin
|
||||
if CbHorizontal.Checked then
|
||||
@ -97,15 +99,17 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Normalize the stacked bars to 100% }
|
||||
procedure TMainForm.Cb100PercentChange(Sender: TObject);
|
||||
begin
|
||||
if Cb100Percent.Checked then
|
||||
BarSeriesREDYELLOW.Source := CalculatedChartSource
|
||||
else
|
||||
BarSeriesREDYELLOW.Source := ListChartSourceREDYELLOW;
|
||||
// CalculatedChartSource.Percentage := Cb100Percent.Checked;
|
||||
end;
|
||||
|
||||
{ Every click detected by the DatapointClickTool creates an entry in the
|
||||
log memo }
|
||||
procedure TMainForm.DataPointClickToolPointClick(ATool: TChartTool;
|
||||
APoint: TPoint);
|
||||
var
|
||||
@ -133,6 +137,18 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Prevent an exception if the DragTool wants to change the non-editable
|
||||
calculated chart source }
|
||||
procedure TMainForm.DataPointDragToolBeforeMouseDown(ATool: TChartTool;
|
||||
APoint: TPoint);
|
||||
begin
|
||||
if Cb100Percent.Checked then begin
|
||||
ShowMessage('Please uncheck the 100% checkbox.');
|
||||
ATool.Handled;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Make sure to keep x value fixed (or y value, if series is rotated) }
|
||||
procedure TMainForm.DataPointDragToolDrag(ASender: TDataPointDragTool;
|
||||
var AGraphPoint: TDoublePoint);
|
||||
var
|
||||
@ -142,15 +158,10 @@ begin
|
||||
if ser.IsRotated then
|
||||
AGraphPoint.Y := ASender.Origin.Y
|
||||
else
|
||||
AGraphPoint.X := ASender.Origin.X; // Keep x value fixed
|
||||
end;
|
||||
|
||||
procedure TMainForm.DataPointDragToolDragStart(ASender: TDataPointDragTool;
|
||||
var AGraphPoint: TDoublePoint);
|
||||
begin
|
||||
FDragStart := AGraphPoint;
|
||||
AGraphPoint.X := ASender.Origin.X;
|
||||
end;
|
||||
|
||||
{ Prepare the text for the hint popup window of the DataPointHintTool }
|
||||
procedure TMainForm.DataPointHintToolHint(ATool: TDataPointHintTool;
|
||||
const APoint: TPoint; var AHint: String);
|
||||
var
|
||||
@ -166,9 +177,9 @@ begin
|
||||
end;
|
||||
|
||||
if ser <> nil then begin
|
||||
ttl := ser.Title;
|
||||
if yidx > 0 then
|
||||
ttl := TBarSeries(ser).Styles.Styles[yidx].Text;
|
||||
ttl := TBarSeries(ser).Styles.Styles[yidx].Text else
|
||||
ttl := ser.Title;
|
||||
AHint := Format(
|
||||
'Mouse over "%s": point #%d, x value %.1f (%s), y value %.1f',
|
||||
[ ttl, idx, ser.GetXValue(idx), ListChartSourceLABELS.Item[idx]^.Text,
|
||||
@ -192,6 +203,8 @@ begin
|
||||
CbHorizontalChange(nil);
|
||||
end;
|
||||
|
||||
{ Change the clicking behavior of the click and hint tools by modifying their
|
||||
Targets. }
|
||||
procedure TMainForm.ToolTargetChanged(Sender: TObject);
|
||||
begin
|
||||
if Sender = RbToolTargetDatapoint then begin
|
||||
|
Loading…
Reference in New Issue
Block a user