我可以使用TeeChart在Delphi语言中创建一个堆叠的条形图。这是使用在循环中添加的值和序列。我更喜欢使用查询作为数据源来创建此图表,而不必将每个条形图作为单独的系列添加到循环中。有没有更好的方法,或者我应该看另一种类型的图表?这些数据是来自油井岩心样本的岩石类型的横截面。对于深度和岩石类型的每次测量,数据集都包含一条记录。它显示为岩石类型的单个垂直柱,就像岩心样品一样。
+----+
| | record 1 - depth1, rock type 1
| |
+----+
| |
| |
| | record 2 - depth2, rock type 2
| |
+----+
| | record 3 - depth3, rock type 3
+----+
procedure TForm128.GenerateLithologyChart;
var
LSeries: TBarSeries;
i : integer;
LastBot : double;
procedure AddRockSeries(depth : double; col : TColor);
begin
LSeries := TBarSeries.Create(LithologyChart);
LithologyChart.AddSeries(LSeries);
LSeries.AddBar(0, '', clBlue);
if col=clNone then
LSeries.AddNullXY(0,depth,'')
else
LSeries.AddXY(0,depth,'',col);
LSeries.Marks.Visible := False;
LSeries.MultiBar := mbStacked;
LSeries.CustomBarWidth := 80;
end;
begin
LithologyChart.LeftAxis.Inverted := True;
LithologyChart.Title.Text.Text := 'Well Lithology - data-aware test';
LithologyChart.SeriesList.Clear;
AdoQuery1.First;
i := 0;
LastBot := 0;
while not AdoQuery1.Eof do begin
if abs(AdoQuery1.FieldByName('Strata Top').asFloat-LastBot) > 0.0005 then begin
// create blank cross section for the missing depth range
AddRockSeries(AdoQuery1.FieldByName('Strata Top').asFloat-LastBot, clNone);
end;
AddRockSeries(AdoQuery1.FieldByName('Strata Bottom').asFloat-AdoQuery1.FieldByName('Strata Top').asFloat, clRed);
LastBot := AdoQuery1.FieldByName('Strata Bottom').asFloat;
inc(i);
//if i = 3 then break;
AdoQuery1.Next;
end;
AdoQuery1.First;
end;发布于 2013-06-06 16:56:55
尝试对您的TBarSeries使用mbSelfStack MultiBar样式。下面是一个示例:
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=false;
with Chart1.AddSeries(TBarSeries) as TBarSeries do
begin
Marks.Visible:=false;
MultiBar:=mbSelfStack;
FillSampleValues;
end;
end;使用此样式时,单个TBarSeries中的值将一个一个堆叠在另一个之上
https://stackoverflow.com/questions/16940911
复制相似问题