動作環境
C++ Builder XE4
概要
- BottomAxisの開始と終了日時を取得する
実装時のコード入力補完にてプロパティMinimumとMaximumを見つけた。
実装
Unit1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <DateUtils.hpp>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
Chart1->Series[0]->XValues->DateTime = true;
Chart1->BottomAxis->DateTimeFormat = L"mm/dd hh:nn";
TDateTime dt;
dt = Now();
double yval;
for (int idx=0; idx < 1000; idx++) {
yval = (1+ idx) % 200;
Series1->AddXY(dt, yval, "", clRed);
dt = IncMinute(dt, 1);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Chart1Click(TObject *Sender)
{
TDateTime startdt = Chart1->BottomAxis->Minimum;
TDateTime enddt = Chart1->BottomAxis->Maximum;
String msg;
msg = startdt.FormatString(L"yyyy/mm/dd hh:nn");
Memo1->Lines->Add(msg);
msg = enddt.FormatString(L"yyyy/mm/dd hh:nn");
Memo1->Lines->Add(msg);
}
//---------------------------------------------------------------------------
動作例
グラフ内をクリック後
開始日時と終了日時を取得できた。