📄 constantlinesandstripes.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "constantlinesandstripes.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "ChartfxLib_TLB"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ICfxConstDisp pConst;
// create 3 constant lines
ChartFX1->OpenDataEx(COD_CONSTANTS, 3, 0);
ChartFX1->ConstantLine->get_Item(0,&pConst);
pConst.Value = 70;
pConst.Axis = AXIS_Y; // horizontal
pConst.Label = L"Average 2";
// set the label of the constant line to be aligned to the right
pConst.Style |= CC_RIGHTALIGNED;
pConst.LineColor = RGB(255, 0, 0);
pConst.LineStyle = CHART_DASH;
pConst.LineWidth = 1;
pConst = NULL;
ChartFX1->ConstantLine->get_Item(1,&pConst);
pConst.Value = 30;
pConst.Axis = AXIS_Y; // horizontal
pConst.Label = L"Average 1";
// set the label of the constant line to be aligned to the right
pConst.Style |= CC_RIGHTALIGNED;
pConst.LineColor = RGB(0, 255, 0);
pConst.LineStyle = CHART_SOLID;
pConst.LineWidth = 2;
pConst = NULL;
ChartFX1->ConstantLine->get_Item(2,&pConst);
pConst.Value = 5;
pConst.Axis = AXIS_X; // vertical
pConst.Label = L"Check point";
pConst.LineColor = RGB(0, 0, 255);
pConst.LineStyle = CHART_DOT;
pConst.LineWidth = 1;
ChartFX1->CloseData(COD_CONSTANTS);
// assign font properties for the text labels of the constant lines
ChartFX1->Fonts[CHART_FIXEDFT] = (CfxFontAttr) (CF_BOLD | CF_ARIAL | 12);
// assign text color for the labels of the constant lines
ChartFX1->RGBFont[CHART_FIXEDFT] = RGB(0, 128, 128);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
ICfxStripeDisp pStripe;
// create 3 color stripes
ChartFX1->OpenDataEx(COD_STRIPES, 3, 0);
ChartFX1->Stripe->get_Item(0,&pStripe);
pStripe.Axis = AXIS_X; // vertical
pStripe.From = 4.5;
pStripe.To = 5.5;
pStripe.Color = CHART_PALETTECOLOR | 19;
pStripe = NULL;
ChartFX1->Stripe->get_Item(1,&pStripe);
pStripe.Axis = AXIS_Y; // Horizontal
pStripe.From = 10;
pStripe.To = 30;
pStripe.Color = CHART_PALETTECOLOR | 2;
pStripe = NULL;
ChartFX1->Stripe->get_Item(1,&pStripe);
pStripe.Axis = AXIS_Y; // Horizontal
pStripe.From = 60;
pStripe.To = 90;
pStripe.Color = CHART_PALETTECOLOR | 41;
ChartFX1->CloseData(COD_STRIPES);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -