📄 cfxpassdata.cpp
字号:
// CfxPassData.cpp : implementation file
//
#include "stdafx.h"
#include "cfx98.h"
#include "CfxPassData.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCfxPassData dialog
CCfxPassData::CCfxPassData(CWnd* pParent /*=NULL*/)
: CDialog(CCfxPassData::IDD, pParent)
{
//{{AFX_DATA_INIT(CCfxPassData)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CCfxPassData::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCfxPassData)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
// ***CFX***
// Do not use class wizard to generate these. It will cause the generation of unecesary classes
DDX_Control(pDX, IDC_CHART1, m_ChartFX);
if (!pDX->m_bSaveAndValidate) // Link Chart FX pointer to control window
m_pChartFX = m_ChartFX.GetControlUnknown();
// ***CFX***
}
BEGIN_MESSAGE_MAP(CCfxPassData, CDialog)
//{{AFX_MSG_MAP(CCfxPassData)
ON_BN_CLICKED(IDC_3D, On3d)
ON_BN_CLICKED(IDC_CLUSTER, OnCluster)
ON_BN_CLICKED(IDC_GANTT, OnGantt)
ON_BN_CLICKED(IDC_PIE, OnPie)
ON_BN_CLICKED(IDC_BUBBLE, OnBubble)
ON_BN_CLICKED(IDC_OHLC, OnOhlc)
ON_BN_CLICKED(IDC_PYRAMID, OnPyramid)
ON_BN_CLICKED(IDC_STEP, OnStep)
ON_BN_CLICKED(IDC_DOUGHNUT, OnDoughnut)
ON_BN_CLICKED(IDC_SCATTER, OnScatter)
ON_BN_CLICKED(IDC_RADAR, OnRadar)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCfxPassData message handlers
BOOL CCfxPassData::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
m_pChartFX = NULL;
return CDialog::DestroyWindow();
}
void CCfxPassData::On3d()
{
if (IsDlgButtonChecked(IDC_3D)){
m_pChartFX->Chart3D = TRUE;
m_pChartFX->AxesStyle = CAS_3DFRAME;
} else {
m_pChartFX->Chart3D = FALSE;
m_pChartFX->AxesStyle = CAS_MATH;
}
}
void CCfxPassData::OnCluster()
{
if (IsDlgButtonChecked(IDC_CLUSTER))
m_pChartFX->Cluster = TRUE;
else
m_pChartFX->Cluster = FALSE;
}
void CCfxPassData::OnGantt()
{
int i;
//to remove the contant lines set in the bubble chart
m_pChartFX->ClearData(CD_CONSTANTLINES);
//in general to remove the strings set in the other charts
m_pChartFX->ClearData(CD_STRINGS);
//in general to remove different settings per series in the other charts
m_pChartFX->ClearData(CD_PERSERIESATTRIBUTES);
//in general to remove tools like dataeditor, legend boxes set in other charts
m_pChartFX->ClearData(CD_TOOLS);
//to remove the stripes set in the scatter chart
m_pChartFX->ClearData(CD_STRIPES);
//to remove the xvalues set in the scatter chart
m_pChartFX->ClearData(CD_XVALUES);
m_pChartFX->Palette = "Sunset";
m_pChartFX->PaletteBar = TRUE;
m_pChartFX->Gallery = GANTT;
//to remove pointlabels and cylinder settings from other charts
m_pChartFX->PointLabels = FALSE;
m_pChartFX->CylSides = 0;
//to reset scales changed in other charts
m_pChartFX->Axis->Item[AXIS_X]->ResetScale();
m_pChartFX->Axis->Item[AXIS_Y]->ResetScale();
//cod_remove to remove the data values assigned in other charts
m_pChartFX->OpenDataEx((CfxCod) (COD_VALUES|COD_REMOVE), 2, 10);
//cod_inivalues to assign the starting point of the gantt bars
m_pChartFX->OpenDataEx(COD_INIVALUES, 2, 10);
for(i=0;i<10;i++) {
m_pChartFX->Series->Item[0]->YFrom[i] = rand() % (10 * i + 1);
m_pChartFX->ValueEx[0][i] = 90 + rand() % (10 * i + 1);
m_pChartFX->Series->Item[1]->YFrom[i] = 80 + rand() % (10 * i + 1);
m_pChartFX->ValueEx[1][i] = 170 + rand() % (10 * i + 1);
}
m_pChartFX->CloseData(COD_VALUES);
m_pChartFX->CloseData(COD_INIVALUES);
//to assign colors to the series
m_pChartFX->OpenDataEx(COD_COLORS, 2, 0);
ICfxSeriesPtr pSerie;
pSerie = m_pChartFX->Series->Item[0];
pSerie->Color = CHART_PALETTECOLOR | 10;
pSerie->Border = TRUE;
pSerie->BorderColor = CHART_PALETTECOLOR | 20;
pSerie->Legend = "First Series";
pSerie->Volume = 50;
pSerie = m_pChartFX->Series->Item[1];
pSerie->Color = CHART_PALETTECOLOR | 20;
pSerie->Border = TRUE;
pSerie->BorderColor = CHART_PALETTECOLOR | 10;
pSerie->Legend = "Second series";
pSerie->Volume = 50;
m_pChartFX->CloseData(COD_COLORS);
//to create horizontal gridlines
ICfxAxisPtr pAxis;
pAxis = m_pChartFX->Axis->Item[AXIS_Y];
pAxis->Grid = TRUE;
pAxis->GridStyle = CHART_DOT;
//to display interlaced grid
pAxis->Style = (CfxAxisStyle) (pAxis->Style & ~AS_INTERLACED);
//to create the series legend box
m_pChartFX->SerLegBox = TRUE;
m_pChartFX->SerLegBoxObj->Docked = TGFP_FIXED;
//to hide the secondary Y axis created in the scatter chart
m_pChartFX->Axis->Item[AXIS_Y2]->Style = (CfxAxisStyle) (m_pChartFX->Axis->Item[AXIS_Y2]->Style | AS_HIDE);
}
void CCfxPassData::OnPie()
{
//in general to remove the strings set in the other charts
m_pChartFX->ClearData(CD_STRINGS);
//in general to remove different settings per series in the other charts
m_pChartFX->ClearData(CD_PERSERIESATTRIBUTES);
//in general to remove tools like dataeditor, legend boxes set in other charts
m_pChartFX->ClearData(CD_TOOLS);
//to remove the stripes set in the scatter chart
m_pChartFX->ClearData(CD_STRIPES);
m_pChartFX->Palette = "spring";
m_pChartFX->PaletteBar = TRUE;
m_pChartFX->Gallery = PIE;
//to show point labels
m_pChartFX->PointLabels = TRUE;
m_pChartFX->OpenDataEx((CfxCod) (COD_VALUES|COD_REMOVE), 2, 10);
char buffer[20], s[]="Slice ";
int j,i;
j=sprintf(buffer,"%s",s);
for(i=0;i<10;i++) {
m_pChartFX->ValueEx[0][i] = 20 + rand() % 100;
m_pChartFX->ValueEx[1][i] = 40 + rand() % 200;
itoa(i,buffer+j,10);
m_pChartFX->Legend[i] = buffer;
}
m_pChartFX->CloseData(COD_VALUES);
//to separate the same slice in both the pies
m_pChartFX->SeparateSlice[4] = 25;
m_pChartFX->SeparateSlice[14]= 25;
//to assign the series legend
m_pChartFX->Series->Item[0]->Legend = "first pie";
m_pChartFX->Series->Item[1]->Legend = "second pie";
//to assign colors to the slices
m_pChartFX->OpenDataEx(COD_COLORS, 10, 0);
for(i=0;i<10;i++)
m_pChartFX->Color[j] = CHART_PALETTECOLOR | (rand() % 40);
m_pChartFX->CloseData(COD_COLORS);
//to show the values legend box
m_pChartFX->LegendBox = TRUE;
m_pChartFX->LegendBoxObj->Docked = TGFP_BOTTOM;
}
void CCfxPassData::OnBubble()
{
int i;
//in general to remove the strings set in the other charts
m_pChartFX->ClearData(CD_STRINGS);
//in general to remove tools like dataeditor, legend boxes set in other charts
m_pChartFX->ClearData(CD_TOOLS);
//to remove the stripes set in the scatter chart
m_pChartFX->ClearData(CD_STRIPES);
//to remove the xvalues set in the scatter chart
m_pChartFX->ClearData(CD_XVALUES);
m_pChartFX->Palette = "Electric fire";
m_pChartFX->PaletteBar = TRUE;
m_pChartFX->Gallery = BUBBLE;
m_pChartFX->CylSides = 20;
//to remove the pointlabels and grids assigned in other charts
m_pChartFX->PointLabels = FALSE;
//to remove horizontal gridlines set in other charts
m_pChartFX->Axis->Item[AXIS_Y]->Grid = FALSE;
m_pChartFX->Axis->Item[AXIS_X]->ResetScale();
m_pChartFX->Axis->Item[AXIS_Y]->ResetScale();
m_pChartFX->OpenDataEx((CfxCod) (COD_VALUES|COD_REMOVE), 2, 12);
for(i=0;i<12;i++) {
m_pChartFX->ValueEx[0][i] = rand() % 100;
m_pChartFX->ValueEx[1][i] = 60 + rand() % 40;
}
m_pChartFX->CloseData(COD_VALUES);
m_pChartFX->RecalcScale();
m_pChartFX->OpenDataEx(COD_COLORS, 1, 0);
m_pChartFX->Series->Item[0]->Color = CHART_PALETTECOLOR | (rand() % 40);
m_pChartFX->CloseData(COD_COLORS);
/*
m_pChartFX->OpenDataEx(COD_CONSTANTS, 2, 0);
ICfxConstPtr pConst;
pConst = m_pChartFX->ConstantLine->Item[0];
pConst->Axis = AXIS_Y;
pConst->Label = "Constant line 1";
pConst->Value = 20;
pConst->LineColor = CHART_PALETTECOLOR | 25;
pConst->LineStyle = CHART_DASH;
pConst->Style = CC_RIGHTALIGNED;
pConst = m_pChartFX->ConstantLine->Item[1];
pConst->Axis = AXIS_Y;
pConst->Label = "Constant line 2";
pConst->Value = 80;
pConst->LineColor = CHART_PALETTECOLOR | 25;
pConst->LineStyle = CHART_DASH;
pConst->Style = CC_RIGHTALIGNED;
m_pChartFX->CloseData(COD_CONSTANTS);
*/
//to hide the secondary Y axis created in the scatter chart
m_pChartFX->Axis->Item[AXIS_Y2]->Style = (CfxAxisStyle) (m_pChartFX->Axis->Item[AXIS_Y2]->Style | AS_HIDE);
}
void CCfxPassData::OnOhlc()
{
int i,j;
//in general to remove the strings set in the other charts
m_pChartFX->ClearData(CD_STRINGS);
//in general to remove different settings per series in the other charts
m_pChartFX->ClearData(CD_PERSERIESATTRIBUTES);
//to remove the contant lines set in the bubble chart
m_pChartFX->ClearData(CD_CONSTANTLINES);
//in general to remove colors or patterns set in other charts
m_pChartFX->ClearData(CD_COLORSANDPATTERNS);
//in general to remove tools like dataeditor, legend boxes set in other charts
m_pChartFX->ClearData(CD_TOOLS);
//to remove the stripes set in the scatter chart
m_pChartFX->ClearData(CD_STRIPES);
//to remove the xvalues set in the scatter chart
m_pChartFX->ClearData(CD_XVALUES);
m_pChartFX->Palette = "Aquamarine";
m_pChartFX->PaletteBar = TRUE;
m_pChartFX->Gallery = OPENHILOWCLOSE;
m_pChartFX->PointLabels = FALSE;
m_pChartFX->CylSides = 0;
m_pChartFX->Axis->Item[AXIS_Y]->Grid = FALSE;
m_pChartFX->Axis->Item[AXIS_X]->ResetScale();
m_pChartFX->Axis->Item[AXIS_Y]->ResetScale();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -