TAChart: Add TCustomChartSeries.AddXY overload with YList argument. Update demo.

git-svn-id: trunk@33025 -
This commit is contained in:
ask 2011-10-22 18:05:41 +00:00
parent 49f696df00
commit 188fb2d302
4 changed files with 37 additions and 13 deletions

View File

@ -29,14 +29,16 @@ object Form1: TForm1
Width = 521
AxisList = <
item
Minors = <>
Title.LabelFont.Orientation = 900
end
item
TickLength = 0
Alignment = calBottom
Marks.Attachment = maCenter
Marks.Distance = 0
Marks.LabelBrush.Style = bsSolid
TickLength = 0
Minors = <>
end>
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
@ -70,10 +72,12 @@ object Form1: TForm1
Width = 521
AxisList = <
item
Minors = <>
Title.LabelFont.Orientation = 900
end
item
Alignment = calBottom
Minors = <>
end>
Depth = 10
Foot.Brush.Color = clBtnFace
@ -87,10 +91,10 @@ object Form1: TForm1
ParentColor = False
object chStackedBarSeries1: TBarSeries
Active = False
Marks.YIndex = -1
Marks.Format = '%0:.2g'
Marks.LinkPen.Visible = False
Marks.Style = smsCustom
Marks.YIndex = -1
ZPosition = 5
BarBrush.Color = clRed
Depth = 10
@ -100,20 +104,20 @@ object Form1: TForm1
end
object chStackedLineSeries1: TLineSeries
Active = False
Marks.YIndex = -1
Marks.Format = '%0:.2g'
Marks.LinkPen.Visible = False
Marks.Style = smsCustom
Marks.YIndex = -1
Depth = 10
MarkPositions = lmpInside
Source = ccsStacked
Styles = ChartStyles1
end
object chStackedAreaSeries1: TAreaSeries
Marks.YIndex = -1
Marks.Format = '%0:.2g'
Marks.LinkPen.Visible = False
Marks.Style = smsCustom
Marks.YIndex = -1
ZPosition = 5
AreaContourPen.Color = clGreen
AreaContourPen.EndCap = pecSquare
@ -188,10 +192,12 @@ object Form1: TForm1
AxisList = <
item
Grid.Visible = False
Minors = <>
Title.LabelFont.Orientation = 900
end
item
Alignment = calBottom
Minors = <>
end>
Foot.Brush.Color = clBtnFace
Foot.Font.Color = clBlue
@ -223,11 +229,13 @@ object Form1: TForm1
item
Grid.Color = clGray
TickLength = 0
Minors = <>
Title.LabelFont.Orientation = 900
end
item
Alignment = calBottom
Grid.Visible = False
Alignment = calBottom
Minors = <>
end>
ExpandPercentage = 5
Foot.Brush.Color = clBtnFace

View File

@ -58,30 +58,29 @@ procedure TForm1.FormCreate(Sender: TObject);
var
ylist: array [1..4] of Double;
i, j: Integer;
y: Double;
y, y0: Double;
begin
chWhiskersBoxAndWhiskerSeries1.ListSource.YCount := 5;
for i := 1 to 6 do begin
y := Random(80) + 10;
chWhiskersBoxAndWhiskerSeries1.AddXY(i, y);
y0 := y;
for j := 1 to 4 do begin
y += Random(20) + 5;
ylist[j] := y;
end;
chWhiskersBoxAndWhiskerSeries1.ListSource.SetYList(i - 1, ylist);
chWhiskersBoxAndWhiskerSeries1.AddXY(i, y0, ylist);
end;
chOHLCOpenHighLowCloseSeries1.ListSource.YCount := 4;
y := 50;
for i := 1 to 50 do begin
y += Random(80) / 10 - 4;
chOHLCOpenHighLowCloseSeries1.AddXY(i, y);
ylist[1] := y;
for j := 1 to 3 do begin
ylist[j] += Random(20) / 10 + 1;
ylist[j + 1] := ylist[j];
end;
chOHLCOpenHighLowCloseSeries1.ListSource.SetYList(i - 1, ylist);
chOHLCOpenHighLowCloseSeries1.AddXY(i, y, ylist);
end;
end;

View File

@ -32,7 +32,7 @@
<RequiredPackages Count="3">
<Item1>
<PackageName Value="LCLBase"/>
<MinVersion Major="1" Release="1" Valid="True"/>
<MinVersion Major="1" Valid="True" Release="1"/>
</Item1>
<Item2>
<PackageName Value="TAChartLazarusPkg"/>
@ -71,6 +71,10 @@
<SmartLinkUnit Value="True"/>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="True"/>
<DebugInfoType Value="dsAuto"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>

View File

@ -172,9 +172,14 @@ type
procedure SetYValue(AIndex: Integer; AValue: Double); inline;
public
function Add(
AValue: Double; AXLabel: String = ''; AColor: TColor = clTAColor): Integer; inline;
AValue: Double;
AXLabel: String = ''; AColor: TColor = clTAColor): Integer; inline;
function AddXY(
AX, AY: Double; AXLabel: String = ''; AColor: TColor = clTAColor): Integer; overload;
AX, AY: Double;
AXLabel: String = ''; AColor: TColor = clTAColor): Integer; overload; inline;
function AddXY(
AX, AY: Double; const AYList: array of Double;
AXLabel: String = ''; AColor: TColor = clTAColor): Integer; overload;
procedure Clear; inline;
function Count: Integer; inline;
procedure Delete(AIndex: Integer); virtual;
@ -520,6 +525,14 @@ begin
Result := AddXY(GetXMaxVal + 1, AValue, AXLabel, AColor);
end;
function TChartSeries.AddXY(
AX, AY: Double; const AYList: array of Double;
AXLabel: String; AColor: TColor): Integer;
begin
Result := ListSource.Add(AX, AY, AXLabel, AColor);
ListSource.SetYList(Result, AYList);
end;
function TChartSeries.AddXY(
AX, AY: Double; AXLabel: String; AColor: TColor): Integer;
begin