📄 colors.cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Colors.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)
{
// Change default series colors
ICfxSeriesDisp pSeries;
ChartFX1->OpenDataEx(COD_COLORS, 2 /*2 Series*/, 0);
ChartFX1->Series->get_Item(0,&pSeries);
pSeries.Color = RGB(255, 0, 0);
pSeries = NULL;
ChartFX1->Series->get_Item(1,&pSeries);
pSeries.Color = RGB(0, 255, 0);
ChartFX1->CloseData(COD_COLORS);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
ICfxAxisDisp pAxis;
TFont *f;
// Text fonts and colors
f = new TFont;
// Y-Axis
ChartFX1->Axis->get_Item(AXIS_Y,&pAxis);
pAxis.TextColor = RGB(100, 100, 0);
SetOleFont(f, pAxis.Font);
f->Name = "Bookman Old Style";
f->Size = 10;
pAxis.TitleColor = RGB(100, 100, 0);
SetOleFont(f, pAxis.TitleFont);
f->Name = "Times New Roman";
f->Size = 14;
pAxis = NULL;
// X-Axis
ChartFX1->Axis->get_Item(AXIS_X,&pAxis);
pAxis.TextColor = RGB(100, 100, 0);
SetOleFont(f, pAxis.Font);
f->Name = "Courier New";
f->Size = 10;
pAxis.TitleColor = RGB(100, 100, 0);
SetOleFont(f, pAxis.TitleFont);
f->Name = "Times New Roman";
f->Size = 14;
// Title
ChartFX1->RGBFont[CHART_TOPTIT] = RGB(100, 100, 0);
ChartFX1->Fonts[CHART_TOPTIT] = (CfxFontAttr) (CF_TIMESNEWR | CF_ITALIC | CF_BOLD | 18);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
// Background colors
ChartFX1->RGBBk = RGB(200, 255, 200);
ChartFX1->RGB3DBk = RGB(100, 200, 175);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
// Display point labels
ICfxSeriesDisp pSeries;
ChartFX1->Series->get_Item(0,&pSeries);
pSeries.PointLabels = TRUE;
pSeries.PointLabelAlign = LA_RIGHT | LA_BASELINE;
pSeries.PointLabelAngle = -45;
// Set point labels font
ChartFX1->Fonts[CHART_VALUESFT] = (CfxFontAttr) (CF_COURIERNEW | CF_BOLD | CF_ITALIC | 10);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
// Set independent color for each point
int j;
ChartFX1->MultipleColors = TRUE;
ChartFX1->OpenDataEx(COD_COLORS, 20 /* 2 series times 10 points */, 0);
for (j = 0; j < 10; j++) {
ChartFX1->Color[j * 2] = RGB(255, 0, 0); // First series
ChartFX1->Color[1 + j * 2] = RGB(0, 255 - j * 20, 255); // Second series
}
ChartFX1->CloseData(COD_COLORS);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -