動作環境
C++ Builder XE4
状況
- 横軸のラベル右側が表示しきれない
対応としては、グラフの表示枠を狭くしてラベル右側のスペースを増やす
実装
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"hh:nn:ss";
Chart1->Legend->Visible = false;
TDateTime dt;
dt = Now();
double yval;
for (int idx=0; idx < 10; idx++) {
yval = (1+ idx) % 2;
Series1->AddXY(dt, yval, "", clRed);
dt = IncSecond(dt, 1);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B_defaultClick(TObject *Sender)
{
Chart1->MarginRight = 3;
}
void __fastcall TForm1::B_narrowerClick(TObject *Sender)
{
Chart1->MarginRight = 10; // (初期値は 3 )
}
//---------------------------------------------------------------------------