📄 zhishu.pas
字号:
unit zhishu;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TeEngine, Series, ExtCtrls, TeeProcs, Chart, Buttons,UClass;
type
TForm2 = class(TForm)
Chart1: TChart;
Series1: THorizLineSeries;
Chart2: TChart;
Series2: THorizLineSeries;
Chart3: TChart;
Series3: THorizLineSeries;
Chart4: TChart;
HorizLineSeries1: THorizLineSeries;
GroupBox8: TGroupBox;
Label28: TLabel;
Label30: TLabel;
GroupBox7: TGroupBox;
Label25: TLabel;
Label27: TLabel;
GroupBox6: TGroupBox;
Label22: TLabel;
Label24: TLabel;
GroupBox3: TGroupBox;
Label19: TLabel;
Label21: TLabel;
Chart5: TChart;
HorizLineSeries2: THorizLineSeries;
GroupBox1: TGroupBox;
Label1: TLabel;
Label3: TLabel;
BitBtn4: TBitBtn;
BitBtn3: TBitBtn;
BitBtn6: TBitBtn;
GroupBox2: TGroupBox;
Label2: TLabel;
Label4: TLabel;
Chart6: TChart;
HorizLineSeries3: THorizLineSeries;
ScrollBar1: TScrollBar;
Button5: TButton;
procedure BitBtn6Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure ScrollBar1Change(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
WellID,WellTop, WellBottom:string;
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.BitBtn6Click(Sender: TObject);
Var DiferAxis,DiferChart,NewMin, NewMax:Double;
var i :longint;
var TmpChart :TComponent;
begin
Chart1.LeftAxis.Automatic:=false;
ScrollBar1.Enabled:=true;
With Chart1 do
DiferChart:=MaxYValue(leftAxis)-MinYValue(leftAxis);
With Chart1.LeftAxis do
Begin
DiferAxis:=(Maximum-Minimum)/0.8;
NewMin:=Chart1.MinYValue(Chart1.LeftAxis)+ScrollBar1.Position*(DiferChart-DiferAxis)/100.0;
NewMax:=Minimum+DiferAxis;
end;
for i:=1 to 84 do
begin
TmpChart:= FindComponent('chart'+IntToStr(i));
if ( TmpChart <> nil ) then
begin
TChart(TmpChart).LeftAxis.SetMinMax(NewMin,NewMax);
end
end;
if DiferChart/DiferAxis <= 1.01 then
begin
BitBtn6.Enabled:=false;
ScrollBar1.Position:=0;
ScrollBar1.Enabled:=false;
end
end;
procedure TForm2.BitBtn3Click(Sender: TObject);
Var DiferAxis,DiferChart,NewMin,NewMax :Double;
var i :longint;
var TmpChart :TComponent;
begin
Chart1.LeftAxis.Automatic:=false;
With Chart1 do
DiferChart:=MaxYValue(leftAxis)-MinYValue(leftAxis);
With Chart1.LeftAxis do
Begin
DiferAxis:=(Maximum-Minimum)*0.8;
NewMin:=Chart1.MinYValue(Chart1.LeftAxis)+ScrollBar1.Position*DiferChart/100.0;
NewMax:=Minimum+DiferAxis;
end;
for i:=1 to 84 do
begin
TmpChart:= FindComponent('chart'+IntToStr(i));
if ( TmpChart <> nil ) then
begin
TChart(TmpChart).LeftAxis.SetMinMax(NewMin,NewMax);
end
end;
ScrollBar1.Enabled:=true;
BitBtn4.Enabled:=true;
BitBtn6.Enabled:=true;
if DiferChart/DiferAxis > 100 then
BitBtn3.Enabled:=false;
end;
procedure TForm2.BitBtn4Click(Sender: TObject);
var i :longint;
var TmpChart :TComponent;
begin
ScrollBar1.Position:=0;
ScrollBar1.Enabled:=false;
for i:=1 to 12 do
begin
TmpChart:= FindComponent('chart'+IntToStr(i));
if ( TmpChart <> nil ) then
begin
TChart(TmpChart).LeftAxis.Automatic:=true;
end
end;
BitBtn6.Enabled:=false;
BitBtn4.Enabled:=false;
BitBtn3.Enabled:=true;
end;
procedure TForm2.ScrollBar1Change(Sender: TObject);
procedure ScrollChart(MyChart:TChart);
Var DiferAxis, DiferChart, Offset :Double;
begin
With MyChart do
DiferChart:=MaxYValue(leftAxis)-MinYValue(leftAxis);
With MyChart.LeftAxis do
begin
Automatic:=false;
DiferAxis:=Maximum-Minimum;
Offset:=Chart1.MinYValue(Chart1.LeftAxis)+ScrollBar1.Position*(DiferChart)/100.0;
if Offset <= Maximum then
begin
Minimum:=Offset;
Maximum:=Offset+DiferAxis;
end else
begin
Maximum:=Offset+DiferAxis;
Minimum:=Offset;
end
end;
end;
var i :longint;
var TmpChart :TComponent;
begin
for i:=1 to 84 do
begin
TmpChart:= FindComponent('Chart'+IntToStr(i));
if ( TmpChart <> nil ) then
begin
ScrollChart( TChart(TmpChart) );
end
end;
end;
procedure TForm2.FormShow(Sender: TObject);
var
SqlString:string;
i:integer;
begin
try
//取得某一口井已经计算井段并显示
form1.ADOQuery1.Close;
form1.ADOQuery1.SQL.Clear;
SqlString:='select * from Tbccmgzs where WellID='+ WellID+ ' and Depth>='+WellTop+' and Depth<='+WellBottom+ ' order by Depth';
form1.ADOQuery1.SQL.Add(SqlString);
form1.ADOQuery1.ExecSQL;
form1.ADOQuery1.Open;
//清空表格
Chart1.Series[0].Clear ;
Chart2.Series[0].Clear ;
Chart3.Series[0].Clear ;
Chart4.Series[0].Clear ;
Chart5.Series[0].Clear ;
Chart6.Series[0].Clear ;
if form1.ADOQuery1.RecordCount<>0 then
begin
//画实验分析数据
form1.ADOQuery1.Recordset.MoveFirst;
for i:=0 to form1.ADOQuery1.RecordCount-1 do
begin
Chart1.Series[0].AddXY(form1.ADOQuery1.Recordset.Fields['JMZS'].Value,form1.ADOQuery1.Recordset.Fields['Depth'].Value);
Chart2.Series[0].AddXY(form1.ADOQuery1.Recordset.Fields['SMZS'].Value,form1.ADOQuery1.Recordset.Fields['Depth'].Value);
Chart3.Series[0].AddXY(form1.ADOQuery1.Recordset.Fields['VMZS'].Value,form1.ADOQuery1.Recordset.Fields['Depth'].Value);
Chart4.Series[0].AddXY(form1.ADOQuery1.Recordset.Fields['AMZS'].Value,form1.ADOQuery1.Recordset.Fields['Depth'].Value);
Chart5.Series[0].AddXY(form1.ADOQuery1.Recordset.Fields['YMZS'].Value,form1.ADOQuery1.Recordset.Fields['Depth'].Value);
Chart6.Series[0].AddXY(form1.ADOQuery1.Recordset.Fields['ZHZS'].Value,form1.ADOQuery1.Recordset.Fields['Depth'].Value);
form1.ADOQuery1.Recordset.MoveNext ;
end;
end;
except
Application.HandleException(Self);
end;
ScrollBar1.Enabled:=false;
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
form2.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -