LoginSignup
0
0

More than 5 years have passed since last update.

C++ Builder XE4 > TeeChart > 軸 > BottomAxisの開始日時と終了日時を取得する > Chart1->BottomAxis->Minimum と Maximum

Posted at
動作環境
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);
}
//---------------------------------------------------------------------------

動作例

グラフ内をクリック後

2019-01-08_17h34_33.png

開始日時と終了日時を取得できた。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0