-1
A
回答
1
除了TLineSeries
爲線數據中,添加一個TFastLineSeries
與Stairs
屬性設置爲true
創建標記指定數據點的虛線。 (結果圖的圖像附在答案的末尾)。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, TeeProcs, TeEngine, Chart, Series;
type
TForm1 = class(TForm)
Chart1: TChart;
LineSeries: TLineSeries;
StairSeries: TFastLineSeries;
procedure FormCreate(Sender: TObject);
procedure StairSeriesGetMarkText(Sender: TChartSeries; ValueIndex: Integer; var MarkText: string);
private
BottomMinimum : double;
LeftMinimum : double;
DataPoint : double;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function Fx(x : double) : double;
begin
Result := ((x - 1.5) * 20) + 17;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
LineSeries.Clear;
StairSeries.Clear;
LeftMinimum := 12;
BottomMinimum := 1.25;
DataPoint := 1.68;
LineSeries.AddXY(1.5, Fx(1.5));
LineSeries.AddXY(1.6, Fx(1.6));
LineSeries.AddXY(1.7, Fx(1.7));
StairSeries.AddXY(BottomMinimum, Fx(DataPoint));
StairSeries.AddXY(DataPoint, Fx(DataPoint));
StairSeries.AddXY(DataPoint, LeftMinimum );
Chart1.LeftAxis.SetMinMax(LeftMinimum, LeftMinimum + 12 );
Chart1.BottomAxis.SetMinMax(BottomMinimum, BottomMinimum + 0.75);
end;
procedure TForm1.StairSeriesGetMarkText(Sender: TChartSeries; ValueIndex: Integer; var MarkText: string);
begin
if valueIndex = 0 then
MarkText := ' '+Format('%5.2n',[ Fx(DataPoint) ])
else if valueIndex = 1 then
MarkText := ''
else
MarkText := ' '+Format('%5.2n',[ DataPoint ])
end;
end.
的DFM:
object Form1: TForm1
Left = 234
Top = 127
Width = 602
Height = 533
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Chart1: TChart
Left = 56
Top = 24
Width = 465
Height = 409
BackWall.Brush.Color = clWhite
BackWall.Brush.Style = bsClear
Title.Text.Strings = (
'TChart')
Legend.Visible = False
View3D = False
TabOrder = 0
object LineSeries: TLineSeries
Marks.ArrowLength = 8
Marks.Visible = False
SeriesColor = clBlue
LinePen.Color = clBlue
LinePen.Width = 4
Pointer.InflateMargins = True
Pointer.Style = psCircle
Pointer.Visible = True
XValues.DateTime = False
XValues.Name = 'X'
XValues.Multiplier = 1.000000000000000000
XValues.Order = loAscending
YValues.DateTime = False
YValues.Name = 'Y'
YValues.Multiplier = 1.000000000000000000
YValues.Order = loNone
end
object StairSeries: TFastLineSeries
Marks.ArrowLength = 8
Marks.Transparent = True
Marks.Frame.Visible = False
Marks.Visible = True
SeriesColor = clRed
OnGetMarkText = StairSeriesGetMarkText
LinePen.Color = clRed
LinePen.Style = psDash
LinePen.Width = 2
XValues.DateTime = False
XValues.Name = 'X'
XValues.Multiplier = 1.000000000000000000
XValues.Order = loAscending
YValues.DateTime = False
YValues.Name = 'Y'
YValues.Multiplier = 1.000000000000000000
YValues.Order = loNone
end
end
end
注:這是我用Delphi 10.2始建與2007年德爾福測試它,我降級的代碼德爾福7
一個Delphi 7例要在2007年德爾福使用或更高更改設置軸MINMAX這個代碼:
Chart1.Axes.Left.SetMinMax(LeftMinimum, LeftMinimum+12);
Chart1.Axes.Bottom.SetMinMax(BottomMinimum, BottomMinimum+0.75);
生成的圖表應該是這樣的:
+0
謝謝!謝謝!謝謝! – fromstog
+0
我的榮幸,請將我的回答標記爲已接受。 –
相關問題
- 1. 如何在TeeChart中繪製垂直線?
- 2. 在CHtmlEditCtrl中繪製「紅色波浪線」
- 3. 如何在webform上繪製線條
- 4. Windowsforms:如何在DataGridView上繪製線條?
- 5. 如何在圖表上繪製線條?
- 6. 如何在iPad上繪製線條圖?
- 7. 在gtk.TextView上繪製線條
- 8. 如何繪製紅色的UIImageView框架
- 9. Teechart HTML5,線條顏色和厚度
- 10. RML - 用rml繪製一條紅線
- 11. 在Qt中繪製一條多色線
- 12. Google條形圖:向上移動零軸線,繪製負向傾斜的紅色
- 13. 在DrawingFrame上繪製線條與外線
- 14. 如何在Bokeh中繪製連續的彩色線條?
- 15. 如何在android中繪製混合或多色的線條?
- 16. 在TeeChart中繪製Graphics3D
- 17. 如何在圖像上繪製線條/繪畫?
- 18. 在ios上使用核心繪圖在一條線上繪製不同顏色
- 19. 在iPhone的UITextView上繪製直線條
- 20. 在OSx中的CALayer上繪製線條
- 21. 在Android上的TextView下繪製線條
- 22. 如何在按鈕上繪製一條簡單線條
- 23. 如何在pygame中繪製一條線並更改顏色?
- 24. 用漸變色繪製線條
- 25. 片段着色器 - 繪製線條?
- 26. 如何在彩色條上繪圖python
- 27. 如何在android中繪製一條線?
- 28. 如何在R中繪製線條?
- 29. 如何在Webforms中繪製線條?
- 30. 如何在VIM中繪製線條?
這是一個線系列3分。 –
使用「階梯」格式添加'TFastLineSeries'來創建紅色虛線。 –