// Graph.h: interface for the CGraph class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_GRAPH_H__3D6A0D2D_1343_4795_A479_5FD941D023F3__INCLUDED_) #define AFX_GRAPH_H__3D6A0D2D_1343_4795_A479_5FD941D023F3__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <windows.h>
#define GRAPH_CURVE_TYPE0//曲线类型
#define GRAPH_INSTANCE_NUM10//定义实例数
#define CIYANKA_BTN_TITLE65500//定义数轴标签窗体ID
typedef struct _AXIS_COORD
{
CPoint ptZero;//数轴0坐标点
int nXMax;//X轴最大坐标
int nYMax;//Y轴最大坐标
int nYMaxData;//Y轴标签最大数据
DOUBLE nXAge;//X平均坐标
DOUBLE nYAge;//Y平均坐标
int nYAgeData;//Y轴标签平均数据
int nXNum;//X坐标位段数
int nYNum;//Y坐标位段数
int nXLableL;//X轴标签坐标
int nXLableT;
int nYLableL;//Y轴标签坐标
int nYLableT;
int nXNL;//x轴说明文字位置
int nXNT;
int nYNL;//Y轴说明文字位置
int nYNT;
int nXNHeight;//x轴说明文字高度
int nYNWidth;//Y轴说明文字宽度
CString strXN;//X坐标字串
CString strYN;//Y坐标字串
BOOL bFlag;//是否有数据坐标辅助虚线
}AXISCOORD,*pAXISCOORD;
typedef struct _LEGEND_COORD
{
int nL;
int nT;
int nWidth;
int nHeight;
}LEGENDCOORD,*pELGENDCOORD;
struct AXISDATA
{
CPoint pt;//曲线数据位置
DOUBLE dData;//曲线数据
AXISDATA*pAD;//
};
struct AXISLABLEDATA
{
CString strData;//曲线数据标签
AXISLABLEDATA*pALD;//
};
typedef struct YEAR_MONTH_DAY_DATA
{
int nYear;
int nMonth;
int nDay;
}YMDDATE;
class CGraph
{
public:
CGraph();
virtual ~CGraph();
private:
CRect rectWindow;//保存窗口大小
CString strTitle;//保存标题
CPoint ptTitle;//标题坐标
LEGENDCOORD ptLegend;//图例坐标
DOUBLE xPix;//每 mm 宽度的像素
DOUBLE yPix;//每 mm 高度的像素
CSize size;//字符串大小
AXISCOORD AxisCoord;//坐标数据
COLORREF dataColor[GRAPH_INSTANCE_NUM];//数据颜
CString strLegTitle;//图例标题
int nInstanceNum;//曲线实例数
AXISDATA*pAD[GRAPH_INSTANCE_NUM];//曲线数据
AXISLABLEDATA *pgALD;//曲线数据标签
int nLableNum;//x轴标签数
int nXAxisLableHeigthOffset;//x轴标签坐标高度偏移
DOUBLE dMaxData;//最大数据输入数
CString strLegend[GRAPH_INSTANCE_NUM];//保存图例文字
int TypeGraph;//保存图表类型
CButton Btn;//保存数轴数据标签窗体
void SetFont(CFont &Font,CDC *pDC,int FontSize=14,int nWeight=0,CString strWordType="宋体",int nFlag=0,int nSpin=0);
void SetPen(CPen &Pen,int nStyle,int nWidth,COLORREF color);
void SetBrush(CBrush &Br,COLORREF crColor);
int GetDateNum(int year,int month);
void DrawTitle(CDC *pDC);//打印标题
void DrawLegend(CDC *pDC);//画图例
void DrawAxis(CDC *pDC);//画数轴
void DrawAxisData(CDC *pDC);//画数轴数据
int GetMaxLable(DOUBLE dNum);//返回输入数据的最大单位整数,如输入:73250返回80000
void SetYLableData(DOUBLE dNum,int nField=10);//设置Y轴标签
void ExitGraph();
DOUBLE GetAxisData(CPoint pt,DOUBLE &Data);
void SetTitle(CString strVal);
void SetAxisString(CString strXAxis="",CString strYAxis="");
cstring转为int
void SetXAxisLableHeightOffset(int dOffset=0);
void SetAxisSuppLine(BOOL bFlag=0);
DOUBLE RoundC(DOUBLE dNum,int nRoundNum=5,int nDigit=0);
public:
BOOL DrawGraph(CDC *pDC);
BOOL SetLegendText(int nIndex,CString strVal);
void SetXLableData(CString strVal);
BOOL SetAxisData(int nIndex,DOUBLE dNum);
void InitGraph(CString strTitle,int nXAxisLHO=0,int nType=GRAPH_CURVE_TYPE,BOOL
bFlag=FALSE,CString strXN="日期",CString strYN="销售量",CString strLegend="图例");
void DrawAxisTitleData(CPoint pt,CWnd *pWnd);
BOOL ClearAxisTitleData();
BOOL GetYMDNum(CString strDate,YMDDATE &date1,YMDDATE &date2,int nML=1);//nML为输入月份前几个月BOOL GetYMDNum(CString &strInOutDate,CString &strOutDate,int nML=1);
BOOL GetYMDNum(int Year,int Month,YMDDATE &date1,YMDDATE &date2,int nML=1);
BOOL GetYMDNum(int Year,int Month,CString &strDate1,CString &strDate2,int nML=1);
};
#endif // !defined(AFX_GRAPH_H__3D6A0D2D_1343_4795_A479_5FD941D023F3__INCLUDED_)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。