zedGraph控件怎样用c++实现画图功能
想在vs2005的c++环境,利用zedGraph控件,在窗体Form1中实现曲线显示,程序如下。调试时语法没错,但就是不能显示图形,不知是怎么回事,还请高手指点迷津。谢谢了先!private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
GraphPane myPane = zedGraphControl1->GraphPane;
myPane.CurveList->Clear();
// 设置初始数据
double x, y1, y2;
PointPairList^ list1 = gcnew PointPairList();
PointPairList^ list2 = gcnew PointPairList();
for ( int i=0; i<60; i++ )
{
x = (double) i + 5;
y1 = 1.5 + Math::Sin( (double) i * 0.2 );
y2 = 3.0 * ( 1.5 + Math::Sin( (double) i * 0.2 ) );
list1->Add( x, y1 );
list2->Add( x, y2 );
}
// 创建红色的菱形曲线
// 标记, 图中的 "Porsche"
LineItem myCurve1 = myPane.AddCurve("Porsche",list1, Color::Red, SymbolType::Diamond );
// 创建蓝色的圆形曲线
// 标记, 图中的 "Piper"
LineItem myCurve2 = myPane.AddCurve("Piper",list2, Color::Blue, SymbolType::Circle );
// 在数据变化时绘制图形
myPane.AxisChange(this->CreateGraphics());
}
private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
GraphPane myPane = zedGraphControl1->GraphPane;
myPane.Draw( e->Graphics );
}