mschart走势图 vc_VC++6.0中MsChart控件的用法
1.MSChart制图类
1.1添加MSChart控件
MSChart是VC++6.0中自带的一个特殊控件类,用于绘制坐标曲线图。如果要使用这个控件,则可以按下图的示意进行添加此控件。
1.2MSChart控件的使用方法
首先在要使用的类的实现文件中包含如下头文件:
#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:显示在柱状图内中间4:显示在柱状图//内下方
m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetDataPoints().GetItem(-1).GetDataPointLabel().SetLocationType(0);
}
void CDrawImp::DrawChart(int type)
{
int nRowCount =bs.FactDictoryList.GetCount();
VARIANT var;
m_Chart.SetRowCount(nRowCount);
m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetPen().GetVtColor().Set(0, 0, 255);
char buf[32];
/* double max = 0.0;
double min = 10.0;
double temp;
for (int i=0; i
{
switch(type)
{
case 0:
temp = bs.FactDictoryList.GetAt(bs.FactDictoryList.FindIndex(i)).FactCF;
break;
case 1:
temp = bs.FactDictoryList.GetAt(bs.FactDictoryList.FindIndex(i)).cfimportance;
break;
case 2:
temp =bs.FactDictoryList.GetAt(bs.FactDictoryList.FindIndex(i)).structimportance;
break;
case 3:
temp =bs.FactDictoryList.GetAt(bs.FactDictoryList.FindIndex(i)).edgeimportance;
break;
default:
break;
}
if (max < temp)
max = temp;
if (min > temp)
min = temp;
}*/
m_Chart.GetPlot().GetAxis(1,var).GetValueScale().SetMaximum(10); // Y轴最大刻度
m_Chart.GetPlot().GetAxis(1,var).GetValueScale().SetMinimum(0); // Y轴最小刻度
double c;
for(int row = 1; row <= nRowCount; ++row)
{
m_Chart.SetRow(row);
sprintf(buf, "%d", row);
m_Chart.SetRowLabel((LPCTSTR)buf);
switch(type)
{
case 0:
c =bs.FactDictoryList.GetAt(bs.FactDictoryList.FindIndex(row-1)).FactCF;
m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetPen().GetVtColor().Set(0, 0, 255);
// Y轴名称
m_Chart.GetPlot().GetAxis(1,var).GetAxisTitle().SetText("基本事件概率(-lg)");
break;
case 1:
c =bs.FactDictoryList.GetAt(bs.FactDictoryList.FindIndex(row-1)).cfimportance;
m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetPen().GetVtColor().Set(255, 0, 0); // Y轴名称
m_Chart.GetPlot().GetAxis(1,var).GetAxisTitle().SetText("概率重要度(-lg)");
break;
case 2:
c =bs.FactDictoryList.GetAt(bs.FactDictoryList.FindIndex(row-1)).structimportance;
m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetPen().GetVtColor().Set(0, 255, 0);
//Y轴名称
m_Chart.GetPlot().GetAxis(1,var).GetAxisTitle().SetText("结构重要度");
break;
case 3:
c =bs.FactDictoryList.GetAt(bs.FactDictoryList.FindIndex(row-1)).edgeimportance;
m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetPen().GetVtColor().Set(255, 0, 255);
// Y轴名称
m_Chart.GetPlot().GetAxis(1,var).GetAxisTitle().SetText("临界重要度(-lg)");
break;
default:
break;
}
m_Chart.GetDataGrid().SetData(row, 1, -log10(c), 0);
}
m_Chart.Refresh();
}
1.1.2.3添加ON_SIZE消息响应函数
void CDrawImp::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if( m_Chart.GetSafeHwnd() )
m_Chart.MoveWindow( 0, 0, cx, cy );
}
1.1.2.4CDrawImp的OnInitDialog函数种创建MSChart
BOOL CDrawImp::OnInitDialog()
{
CDialog::OnInitDialog();
m_radio = 0;
m_combo.SetCurSel(0);
UpdateData(FALSE);
CRect rc;
GetClientRect(&rc);
rc.top += 80;
rc.bottom -= 15;
rc.left += 15;
rc.right -= 15;
m_Chart.Create("mschart", WS_CHILD| WS_VISIBLE, rc, this, 10);
initmschart();
DrawChart(0);
CString s;
s.Format("顶事件发生概率为: %f",topcf);
GetDlgItem(IDC_TOPCFSTATIC)->SetWindowText(s);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
mschart走势图 vc_VC++6.0中MsChart控件的用法相关推荐
- Asp.net 2.0 中获取控件输出的Html代码 (转)
将Asp.net 控件的呈现html获取,在不少场合会用到,比如生成静态页时 以下代码选自 Asp.net 2.0 高级编程 转自:Asp.net 2.0 中获取控件输出的Html代码 public ...
- wxpython中grid控件一些用法总结
1. 官网主动查找控件的使用方法 wxpython中grid控件的用法可以通过搜索wxpython网址查看使用方法说明.网址:https://docs.wxpython.org/index.html ...
- 测试ASP.NET 2.0中Gridview控件高级技巧
ASP.NET 2.0中,新增加的gridview控件的确十分强大,弥补了在asp.net 1.1中,使用datagrid控件时的不足之处.因为在asp.net 1.1中,在使用datagrid时,很 ...
- .net中控件中嵌套控件的用法
最常见的在控件中嵌套控件是,在DataGrid中嵌套一个 CheckBox, 效果是可以知道哪些被选中 for (int i=0; i<DataGrid1.Items.Count;i++) ...
- mschart走势图 vc_VC++操作MSChart表格控件,效果不错。
[实例简介] 在VC++中使用MSChart表格控件,效果不错.MSChart,微软的一个很不错的画图控件,功能比较全面 [实例截图] [核心代码] TestMsChart └── TestMsCha ...
- vfp 8.0中image控件的属性:RotateFlip
该属性可使该IMAGE中的图发生旋转等效果.如果与TIME控件配合,可以做出多种自己想要的效果: 比如:在TIME的TIMER事件中: (I在FORM的INIT事件中定义成全局变量,且初值为0) I= ...
- Silverlight toolkit 中ListPicker控件的用法【转】
ListPicker控件,从外形上看有点像ComboBox,主要的功能也是可以在多个项目中来选择一个项目,如下图,在平常状态下,看到的是跟一般的文字框相同(如图1),而展开后就会出现项目列表(如图2) ...
- Windows MObile中ListView控件的用法详解
-前言:ListView在Windows Mobile中的应用非常广泛,也是Windows Mobile中很重要的一个控件,在此俺新手给他做个总结,方便其它新手参考哈! --------------- ...
- winform 窗体中 Time 控件的用法
作用: 用于背景进程中.通过引发Timer事件,Timer控件可以有规律的隔一段时间执行一次代码.也就是,你可以根据你自己的需要,给Timer控件设置时间,Timer每隔这段时间,就执行一次代码. 属 ...
- Android中ExpandableListView控件的用法详解
<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widge ...
最新文章
- 一次性搞定权限树遍历(通用解决方案)
- 封装(私有化成员变量,获取变量值)
- 云+X案例展 | 民生类:基于AWS PaaS构建基础集团企业级中台
- 【转】Visual Studio 2005 上 AJAX(AjaxControlToolkit) 的安装
- 【LeetCode】剑指 Offer 13. 机器人的运动范围
- CentOS中VMware tools的安装以及安装失败的解决办法,java架构师视频课程
- javascript之生成一个指定范围内的随机数
- 《永不放弃-马云给创业者的24堂课》— 综合素质提升书籍
- JPA Example查询
- java不能对什么类型进行转换_@Value - 无法将类型'java.lang.String'的值转换为所需类型'java.lang.Integer'...
- 利用爬虫大量抓取网页图片
- Java毕业设计——>SpringBoot+VUE实现的前后端分离小米手机商城系统
- kibana 7.5.1 + apm 7.5.1实现应用性能(apm)监控
- 快速识记会计中的借贷两方
- Python爬取京东商品数据
- 笔记10.9:硬盘、计算机启动过程、缓冲缓存
- 《卓有成效的管理者》——学习心得(一)
- 中国数学家黄金一代-北大数学专业2000级
- (48)STM32——图片显示实验
- 知识图谱与古希腊人物关系