動作環境
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"nn:ss";
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::Button1Click(TObject *Sender)
{
Chart1->LeftAxis->TickLength = 10;
Chart1->LeftAxis->MinorTickLength = 20;
Chart1->LeftAxis->Increment = 0.2;
Chart1->LeftAxis->MinorTickCount = 3;
Chart1->LeftAxis->Ticks->Width = 8;
Chart1->LeftAxis->MinorTicks->Width = 4;
}
//---------------------------------------------------------------------------
動作例
- 主目盛の長さが10に
- 副目盛の長さが20に
- 主目盛の間隔が0.2に
- 副目盛の間隔は主目盛に対して(3+1)等分に
- 主目盛の太さを8に
- 副目盛の太さを4に