LoginSignup
1
2

More than 3 years have passed since last update.

2016-01-22 c++ builder XE4, 10.2 Tokyo > TeeChart > 折れ線グラフにてデータがないところの線を切る (+ データ欠損処理)

Last updated at Posted at 2016-01-22
動作環境
C++ builder XE4
    TeeChart Lite v2013.08.130414
RAD Studio 10.2 Tokyo Update 2 (追記 2018/01/10)
    TeeChart v2016.17.160129 32bit VCL

折れ線グラフでデータがない線分を切る方法はいくつかあるようだ。
http://stackoverflow.com/questions/24311851/line-pieces-in-tee-chart-lite-xe5

null pointsを使ってみた。手順は以下。

  1. 初期化でSeries1->TreatNulls = tnDontPaint; を実行する
  2. Series1->AddNullXY(dx, dy);を切りたい場所で実行する
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::FormCreate(TObject *Sender)
{
    Chart1->Series[0]->XValues->DateTime = true;
    Chart1->BottomAxis->DateTimeFormat = L"nn:ss";

    TDateTime dt;

    Series1->TreatNulls = tnDontPaint; /*1*/

    double dx, dy;
    dt = Now();
    for (int idx=0; idx < 20; idx++) {
        dy = random(1000);
        dx = (double)dt;
        Series1->AddXY(dx, dy, "", clRed);

        if ((idx % 5) == 0) {
            Series1->AddNullXY(dx, dy);  /*2*/
        }

        dt = IncSecond(dt, 1);
    }
}

qiita.png

データ欠損処理

(追記 2018/10/24)

「直前のデータの日時」と「追加するデータの日時」が離れている場合、欠損期間として線を引かない
というような実装が考えられる。

検索用キーワード

(2019-09-11追加)

- 切断

1
2
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
1
2