mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 05:01:50 +02:00
TAChart: Allow html tags in display text of distance measurement tool.
git-svn-id: trunk@55451 -
This commit is contained in:
parent
cde5b90623
commit
1ff61505bf
@ -10,23 +10,23 @@ object MainForm: TMainForm
|
|||||||
LCLVersion = '1.9.0.0'
|
LCLVersion = '1.9.0.0'
|
||||||
object BottomPanel: TPanel
|
object BottomPanel: TPanel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 91
|
Height = 105
|
||||||
Top = 353
|
Top = 339
|
||||||
Width = 647
|
Width = 639
|
||||||
Align = alBottom
|
Align = alBottom
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.Left = 8
|
BorderSpacing.Left = 8
|
||||||
BorderSpacing.Top = 8
|
BorderSpacing.Right = 8
|
||||||
BorderSpacing.Bottom = 8
|
BorderSpacing.Bottom = 8
|
||||||
BevelOuter = bvNone
|
BevelOuter = bvNone
|
||||||
ClientHeight = 91
|
ClientHeight = 105
|
||||||
ClientWidth = 647
|
ClientWidth = 639
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
object CgHTML: TCheckGroup
|
object CgHTML: TCheckGroup
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 78
|
Height = 78
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 327
|
Width = 333
|
||||||
AutoFill = True
|
AutoFill = True
|
||||||
AutoSize = True
|
AutoSize = True
|
||||||
BorderSpacing.InnerBorder = 4
|
BorderSpacing.InnerBorder = 4
|
||||||
@ -40,7 +40,7 @@ object MainForm: TMainForm
|
|||||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||||
ChildSizing.ControlsPerLine = 4
|
ChildSizing.ControlsPerLine = 4
|
||||||
ClientHeight = 58
|
ClientHeight = 58
|
||||||
ClientWidth = 323
|
ClientWidth = 329
|
||||||
Columns = 4
|
Columns = 4
|
||||||
Items.Strings = (
|
Items.Strings = (
|
||||||
'title'
|
'title'
|
||||||
@ -50,18 +50,19 @@ object MainForm: TMainForm
|
|||||||
'x axis labels'
|
'x axis labels'
|
||||||
'x axis title'
|
'x axis title'
|
||||||
'y axis title'
|
'y axis title'
|
||||||
|
'distance tool'
|
||||||
)
|
)
|
||||||
OnItemClick = CgHTMLItemClick
|
OnItemClick = CgHTMLItemClick
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
Data = {
|
Data = {
|
||||||
0700000002020202020202
|
080000000202020202020202
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
object BtnCopyToClipboard: TButton
|
object BtnCopyToClipboard: TButton
|
||||||
AnchorSideTop.Control = BottomPanel
|
AnchorSideTop.Control = BottomPanel
|
||||||
AnchorSideRight.Control = BottomPanel
|
AnchorSideRight.Control = BottomPanel
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 518
|
Left = 510
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 121
|
Width = 121
|
||||||
@ -79,7 +80,7 @@ object MainForm: TMainForm
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = BtnCopyToClipboard
|
AnchorSideRight.Control = BtnCopyToClipboard
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 518
|
Left = 510
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 37
|
Top = 37
|
||||||
Width = 121
|
Width = 121
|
||||||
@ -96,7 +97,7 @@ object MainForm: TMainForm
|
|||||||
AnchorSideTop.Side = asrBottom
|
AnchorSideTop.Side = asrBottom
|
||||||
AnchorSideRight.Control = BtnCopyToClipboard
|
AnchorSideRight.Control = BtnCopyToClipboard
|
||||||
AnchorSideRight.Side = asrBottom
|
AnchorSideRight.Side = asrBottom
|
||||||
Left = 518
|
Left = 510
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 66
|
Top = 66
|
||||||
Width = 121
|
Width = 121
|
||||||
@ -110,22 +111,46 @@ object MainForm: TMainForm
|
|||||||
object CbRTL: TCheckBox
|
object CbRTL: TCheckBox
|
||||||
AnchorSideLeft.Control = CgHTML
|
AnchorSideLeft.Control = CgHTML
|
||||||
AnchorSideLeft.Side = asrBottom
|
AnchorSideLeft.Side = asrBottom
|
||||||
AnchorSideTop.Control = BtnCopyToClipboard
|
AnchorSideTop.Control = CbRotateXLabels
|
||||||
AnchorSideTop.Side = asrCenter
|
AnchorSideTop.Side = asrBottom
|
||||||
Left = 343
|
Left = 349
|
||||||
Height = 19
|
Height = 19
|
||||||
Top = 11
|
Top = 38
|
||||||
Width = 86
|
Width = 86
|
||||||
BorderSpacing.Left = 16
|
BorderSpacing.Left = 16
|
||||||
|
BorderSpacing.Top = 8
|
||||||
Caption = 'Right-to-left'
|
Caption = 'Right-to-left'
|
||||||
OnChange = CbRTLChange
|
OnChange = CbRTLChange
|
||||||
TabOrder = 4
|
TabOrder = 4
|
||||||
Visible = False
|
Visible = False
|
||||||
end
|
end
|
||||||
|
object CbRotateXLabels: TCheckBox
|
||||||
|
AnchorSideTop.Control = BtnCopyToClipboard
|
||||||
|
AnchorSideTop.Side = asrCenter
|
||||||
|
Left = 349
|
||||||
|
Height = 19
|
||||||
|
Top = 11
|
||||||
|
Width = 131
|
||||||
|
Caption = 'Rotate x labels by 45°'
|
||||||
|
OnChange = CbRotateXLabelsChange
|
||||||
|
TabOrder = 5
|
||||||
|
end
|
||||||
|
object Label1: TLabel
|
||||||
|
AnchorSideLeft.Control = BottomPanel
|
||||||
|
AnchorSideTop.Control = CgHTML
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 0
|
||||||
|
Height = 15
|
||||||
|
Top = 90
|
||||||
|
Width = 305
|
||||||
|
BorderSpacing.Top = 4
|
||||||
|
Caption = 'Measure distance: drag with left mouse button held down'
|
||||||
|
ParentColor = False
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object Chart: TChart
|
object Chart: TChart
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 337
|
Height = 323
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 639
|
Width = 639
|
||||||
AxisList = <
|
AxisList = <
|
||||||
@ -163,6 +188,8 @@ object MainForm: TMainForm
|
|||||||
)
|
)
|
||||||
Foot.TextFormat = tfHTML
|
Foot.TextFormat = tfHTML
|
||||||
Foot.Visible = True
|
Foot.Visible = True
|
||||||
|
Legend.Alignment = laTopCenter
|
||||||
|
Legend.ColumnCount = 2
|
||||||
Legend.TextFormat = tfHTML
|
Legend.TextFormat = tfHTML
|
||||||
Legend.Visible = True
|
Legend.Visible = True
|
||||||
Title.Brush.Color = clBtnFace
|
Title.Brush.Color = clBtnFace
|
||||||
@ -175,6 +202,7 @@ object MainForm: TMainForm
|
|||||||
)
|
)
|
||||||
Title.TextFormat = tfHTML
|
Title.TextFormat = tfHTML
|
||||||
Title.Visible = True
|
Title.Visible = True
|
||||||
|
Toolset = ChartTools
|
||||||
Align = alClient
|
Align = alClient
|
||||||
BorderSpacing.Around = 8
|
BorderSpacing.Around = 8
|
||||||
Color = clWhite
|
Color = clWhite
|
||||||
@ -184,7 +212,7 @@ object MainForm: TMainForm
|
|||||||
Marks.LinkPen.Color = clGray
|
Marks.LinkPen.Color = clGray
|
||||||
Marks.Style = smsLabel
|
Marks.Style = smsLabel
|
||||||
Marks.TextFormat = tfHTML
|
Marks.TextFormat = tfHTML
|
||||||
Title = '<font color="red">Measured</font>'
|
Title = '<font color="red">Measured data points</font>'
|
||||||
LinePen.Color = clRed
|
LinePen.Color = clRed
|
||||||
LineType = ltNone
|
LineType = ltNone
|
||||||
Pointer.Brush.Color = clRed
|
Pointer.Brush.Color = clRed
|
||||||
@ -209,4 +237,23 @@ object MainForm: TMainForm
|
|||||||
left = 224
|
left = 224
|
||||||
top = 153
|
top = 153
|
||||||
end
|
end
|
||||||
|
object ChartTools: TChartToolset
|
||||||
|
left = 368
|
||||||
|
top = 88
|
||||||
|
object DistanceTool: TDataPointDistanceTool
|
||||||
|
Shift = [ssLeft]
|
||||||
|
DistanceMode = cdmOnlyX
|
||||||
|
DrawingMode = tdmNormal
|
||||||
|
Marks.Distance = 15
|
||||||
|
Marks.Format = '%0:.9g'
|
||||||
|
Marks.Frame.Color = clTeal
|
||||||
|
Marks.LabelBrush.Color = clMoneyGreen
|
||||||
|
Marks.LinkPen.Color = clSilver
|
||||||
|
Marks.LinkPen.Visible = False
|
||||||
|
Marks.TextFormat = tfHTML
|
||||||
|
MeasureMode = cdmOnlyX
|
||||||
|
Options = [dpdoLabelAbove]
|
||||||
|
OnGetDistanceText = DistanceToolGetDistanceText
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -6,7 +6,8 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, TAGraph, TASeries, TASources, Forms, Controls,
|
Classes, SysUtils, FileUtil, TAGraph, TASeries, TASources, Forms, Controls,
|
||||||
Graphics, Dialogs, ExtCtrls, StdCtrls, TAChartAxisUtils, TAFuncSeries;
|
Graphics, Dialogs, ExtCtrls, StdCtrls, TAChartAxisUtils, TAFuncSeries,
|
||||||
|
TATools, TADataTools;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -19,7 +20,11 @@ type
|
|||||||
Chart: TChart;
|
Chart: TChart;
|
||||||
CgHTML: TCheckGroup;
|
CgHTML: TCheckGroup;
|
||||||
CbRTL: TCheckBox;
|
CbRTL: TCheckBox;
|
||||||
|
ChartTools: TChartToolset;
|
||||||
|
CbRotateXLabels: TCheckBox;
|
||||||
|
DistanceTool: TDataPointDistanceTool;
|
||||||
FitSeries: TFitSeries;
|
FitSeries: TFitSeries;
|
||||||
|
Label1: TLabel;
|
||||||
ListChartSource: TListChartSource;
|
ListChartSource: TListChartSource;
|
||||||
DataSeries: TLineSeries;
|
DataSeries: TLineSeries;
|
||||||
BottomPanel: TPanel;
|
BottomPanel: TPanel;
|
||||||
@ -27,9 +32,12 @@ type
|
|||||||
procedure BtnCopyToClipboardClick(Sender: TObject);
|
procedure BtnCopyToClipboardClick(Sender: TObject);
|
||||||
procedure BtnSaveWMFClick(Sender: TObject);
|
procedure BtnSaveWMFClick(Sender: TObject);
|
||||||
procedure BtnSaveSVGClick(Sender: TObject);
|
procedure BtnSaveSVGClick(Sender: TObject);
|
||||||
|
procedure CbRotateXLabelsChange(Sender: TObject);
|
||||||
procedure CgHTMLItemClick(Sender: TObject; Index: integer);
|
procedure CgHTMLItemClick(Sender: TObject; Index: integer);
|
||||||
procedure ChartAxisList1MarkToText(var AText: String; AMark: Double);
|
procedure ChartAxisList1MarkToText(var AText: String; AMark: Double);
|
||||||
procedure CbRTLChange(Sender: TObject);
|
procedure CbRTLChange(Sender: TObject);
|
||||||
|
procedure DistanceToolGetDistanceText(ASender: TDataPointDistanceTool;
|
||||||
|
var AText: String);
|
||||||
procedure FitSeriesFitComplete(Sender: TObject);
|
procedure FitSeriesFitComplete(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
|
|
||||||
@ -66,6 +74,14 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.CbRotateXLabelsChange(Sender: TObject);
|
||||||
|
begin
|
||||||
|
if CbRotateXLabels.Checked then
|
||||||
|
Chart.BottomAxis.Marks.LabelFont.Orientation := 450
|
||||||
|
else
|
||||||
|
Chart.BottomAxis.Marks.LabelFont.Orientation := 0;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainForm.BtnSaveSVGClick(Sender: TObject);
|
procedure TMainForm.BtnSaveSVGClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
Chart.SaveToSVGFile('test.svg');
|
Chart.SaveToSVGFile('test.svg');
|
||||||
@ -85,6 +101,7 @@ begin
|
|||||||
4: Chart.BottomAxis.Marks.TextFormat := tf;
|
4: Chart.BottomAxis.Marks.TextFormat := tf;
|
||||||
5: Chart.BottomAxis.Title.TextFormat := tf;
|
5: Chart.BottomAxis.Title.TextFormat := tf;
|
||||||
6: Chart.LeftAxis.Title.TextFormat := tf;
|
6: Chart.LeftAxis.Title.TextFormat := tf;
|
||||||
|
7: DistanceTool.Marks.TextFormat := tf;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -129,6 +146,12 @@ begin
|
|||||||
FitSeries.Source := ListChartSource_Fit;
|
FitSeries.Source := ListChartSource_Fit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMainForm.DistanceToolGetDistanceText(
|
||||||
|
ASender: TDataPointDistanceTool; var AText: String);
|
||||||
|
begin
|
||||||
|
AText := 'Δα = ' + FormatFloat('0.00', ASender.Distance) + '°';
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMainForm.FitSeriesFitComplete(Sender: TObject);
|
procedure TMainForm.FitSeriesFitComplete(Sender: TObject);
|
||||||
var
|
var
|
||||||
p: Array of Double;
|
p: Array of Double;
|
||||||
@ -160,6 +183,7 @@ begin
|
|||||||
CgHTML.Checked[4] := Chart.BottomAxis.Marks.TextFormat = tfNormal;
|
CgHTML.Checked[4] := Chart.BottomAxis.Marks.TextFormat = tfNormal;
|
||||||
CgHTML.Checked[5] := Chart.BottomAxis.Title.TextFormat = tfNormal;
|
CgHTML.Checked[5] := Chart.BottomAxis.Title.TextFormat = tfNormal;
|
||||||
CgHTML.Checked[6] := Chart.LeftAxis.Title.TextFormat = tfNormal;
|
CgHTML.Checked[6] := Chart.LeftAxis.Title.TextFormat = tfNormal;
|
||||||
|
CgHTML.Checked[7] := DistanceTool.Marks.TextFormat = tfNormal;
|
||||||
|
|
||||||
{$IFDEF WINDOWS}
|
{$IFDEF WINDOWS}
|
||||||
Chart.Foot.Text[1] := '<font name="Times New Roman" color="gray">' + Chart.Foot.Text[1] + '</font>';
|
Chart.Foot.Text[1] := '<font name="Times New Roman" color="gray">' + Chart.Foot.Text[1] + '</font>';
|
||||||
|
@ -41,6 +41,7 @@ type
|
|||||||
property Frame;
|
property Frame;
|
||||||
property LabelBrush;
|
property LabelBrush;
|
||||||
property LinkPen;
|
property LinkPen;
|
||||||
|
property TextFormat;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TDataPointDistanceTool = class(TDataPointDrawTool)
|
TDataPointDistanceTool = class(TDataPointDrawTool)
|
||||||
|
@ -66,7 +66,7 @@ type
|
|||||||
TScaleItems = set of TScaleItem;
|
TScaleItems = set of TScaleItem;
|
||||||
|
|
||||||
IChartDrawer = interface
|
IChartDrawer = interface
|
||||||
['{6D8E5591-6788-4D2D-9FE6-596D5157C3C3}']
|
['{6D8E5591-6788-4D2D-9FE6-596D5157C3C3}']
|
||||||
procedure AddToFontOrientation(ADelta: Integer);
|
procedure AddToFontOrientation(ADelta: Integer);
|
||||||
procedure ClippingStart(const AClipRect: TRect);
|
procedure ClippingStart(const AClipRect: TRect);
|
||||||
procedure ClippingStart;
|
procedure ClippingStart;
|
||||||
|
@ -24,7 +24,7 @@ type
|
|||||||
FDrawer: IChartDrawer;
|
FDrawer: IChartDrawer;
|
||||||
FSize: TPoint;
|
FSize: TPoint;
|
||||||
FPos: TPoint;
|
FPos: TPoint;
|
||||||
FStartPos: TPoint;
|
FRotPos: TPoint;
|
||||||
FCurrentFont: TFPCustomFont;
|
FCurrentFont: TFPCustomFont;
|
||||||
FSavedFont: TFPCustomFont;
|
FSavedFont: TFPCustomFont;
|
||||||
FFontAngle: Double;
|
FFontAngle: Double;
|
||||||
@ -682,15 +682,15 @@ begin
|
|||||||
offs := (h * SUB_OFFSET_MULTIPLIER) div SUBSUP_DIVISOR
|
offs := (h * SUB_OFFSET_MULTIPLIER) div SUBSUP_DIVISOR
|
||||||
else
|
else
|
||||||
offs := (h * SUP_OFFSET_MULTIPLIER) div SUBSUP_DIVISOR; // this is negative
|
offs := (h * SUP_OFFSET_MULTIPLIER) div SUBSUP_DIVISOR; // this is negative
|
||||||
P := Point(FPos.X, FPos.Y+offs) - FStartPos;
|
P := Point(FPos.X, FPos.Y+offs) - FRotPos;
|
||||||
p := RotatePoint(P, -FFontAngle) + FStartPos;
|
p := RotatePoint(P, -FFontAngle) + FRotPos;
|
||||||
FDrawer.TextOut.TextFormat(tfNormal).Pos(P).Text(s).Done;
|
FDrawer.TextOut.TextFormat(tfNormal).Pos(P).Text(s).Done;
|
||||||
FCurrentFont.Size := oldFontSize;
|
FCurrentFont.Size := oldFontSize;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
FDrawer.SetFont(FCurrentFont);
|
FDrawer.SetFont(FCurrentFont);
|
||||||
w := FDrawer.TextExtent(s, tfNormal).X; // tfNormal is correct
|
w := FDrawer.TextExtent(s, tfNormal).X; // tfNormal is correct
|
||||||
p := RotatePoint(FPos - FStartPos, -FFontAngle) + FStartPos;
|
p := RotatePoint(FPos - FRotPos, -FFontAngle) + FRotPos;
|
||||||
FDrawer.TextOut.TextFormat(tfNormal).Pos(P).Text(s).Done;
|
FDrawer.TextOut.TextFormat(tfNormal).Pos(P).Text(s).Done;
|
||||||
end;
|
end;
|
||||||
inc(FPos.X, w);
|
inc(FPos.X, w);
|
||||||
@ -789,8 +789,8 @@ var
|
|||||||
parser: THTMLParser;
|
parser: THTMLParser;
|
||||||
begin
|
begin
|
||||||
Init;
|
Init;
|
||||||
|
FRotPos := Point(AX, AY);
|
||||||
FPos := Point(AX, AY);
|
FPos := Point(AX, AY);
|
||||||
FStartPos := FPos;
|
|
||||||
parser := THTMLParser.Create('<p>' + AText + '</p>');
|
parser := THTMLParser.Create('<p>' + AText + '</p>');
|
||||||
try
|
try
|
||||||
parser.OnFoundTag := @HTMLTagFound;
|
parser.OnFoundTag := @HTMLTagFound;
|
||||||
|
Loading…
Reference in New Issue
Block a user