VC++60中MsChart的使用方法.docx
文本预览下载声明
?
HYPERLINK /andy8205/article/details/1900008 VC++6.0中MsChart的使用方法
1.???MSChart制图类
1.1?添加MSChart控件
MSChart是VC++6.0中自带的一个特殊控件类,用于绘制坐标曲线图。如果要使用这个控件,则可以按下图的示意进行添加此控件。
????????
1.2???MSChart控件的使用方法
首先在要使用的类的实现文件中包含如下头文件:
#include VcPlot.h
#include VcAxis.h
#include VcValueScale.h
#include VcSeriesCollection.h
#include VcSeries.h
#include VcPen.h
#include VcCategoryScale.h
#include VcColor.h
#include VcDataGrid.h
#include VcBackdrop.h
#include VcFill.h
#include VcBrush.h
#include VcDataPoints.h
#include VcDataPoint.h
#include VcDataPointLabel.h
#include VcAxisTitle.h
#include math.h
在要使用的类的头文件中包含:
#include mschart.h????
本系统中按照如下函数调用来实现MSChart类绘制故障树重要度曲线的功能(CDrawImp是调用MSChart的类)。
1.2.1?????????????类中变量定义
class CDrawImp : public CDialog
{
// Construction
public:
???????void DrawChart(int type);
???????void initmschart();
???????CMSChart m_Chart;
……
}
1.2.2?????????????类中MSChart的初始化函数
void CDrawImp::initmschart()
{
???????//?下面两句改变背景色
???????m_Chart.GetBackdrop().GetFill().SetStyle(1);
??????
???????//?显示图例
???????m_Chart.SetShowLegend(FALSE);
???????m_Chart.SetColumn(1);
???????m_Chart.SetChartType(3);
?
???????//?栈模式
???????m_Chart.SetStacking(FALSE);
?
???????// Y轴设置
???????VARIANT var;
//不自动标注Y轴刻度
???????m_Chart.GetPlot().GetAxis(1,var).GetValueScale().SetAuto(FALSE);????????????
//Y轴刻度10等分
???????m_Chart.GetPlot().GetAxis(1,var).GetValueScale().SetMajorDivision(10);
//每刻度一个刻度线
???????m_Chart.GetPlot().GetAxis(1,var).GetValueScale().SetMinorDivision(1);?
//不自动标注X轴刻度
???????m_Chart.GetPlot().GetAxis(0,var).GetCategoryScale().SetAuto(FALSE);
//每刻度一个标注???????????
???????m_Chart.GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerLabel(0);
//每刻度一个刻度线
???????m_Chart.GetPlot().GetAxis(0,var).GetCategoryScale().SetDivisionsPerTick(1);
???????m_Chart.GetPlot().GetAxis(0,var).GetAxisTitle().SetText(基本故障事件(对应表2中的序号));// X轴名称
?
???????// 1条曲线
???????m_Chart.SetColumnCount(1);
???????//?数据点类型显示数据值的模式(对柱柱状图和点线图有效)
???????// 0:?不显示?1:?显示在柱状图外
???????// 2:?显示在柱状图内上方?????3:?
显示全部