如何使用 C++ 绘制带有日期轴的图表和 ZedGraph?
我已成功使用 C++ 示例项目使用 ZedGraph 从我的 C++ 项目中绘制图表。但是,没有 C++ 的日期轴示例。
以下代码取自以下位置的 C# 示例: http://zedgraph.org/wiki/index.php?title=教程:Date_Axis_Chart_Demo 。请参阅我的评论以及文本 //JEM// 以了解我的问题出在哪里
PointPairList list = new PointPairList();
for ( int i=0; i<36; i++ )
{
double x = (double) new XDate( 1995, 5, i+11 );
> //JEM //This line above doesn't work in
> C++.
double y = Math.Sin( (double) i * Math.PI / 15.0 );
list.Add( x, y );
}
....missing code...
// Set the XAxis to date type
myPane.XAxis.Type = AxisType.Date;
//JEM //This one also doesn't work even if I change it to the
//syntax that C++ understands, that is,
myPane->XAxis->Type = AxisType->Date;
I have successfully used the C++ example project to draw graphs from my C++ project using ZedGraph. However there is no example with Date axis for C++.
The following code is taken from the C# example found at
http://zedgraph.org/wiki/index.php?title=Tutorial:Date_Axis_Chart_Demo. Please see my comments with the text //JEM// to see where my problem is
PointPairList list = new PointPairList();
for ( int i=0; i<36; i++ )
{
double x = (double) new XDate( 1995, 5, i+11 );
> //JEM //This line above doesn't work in
> C++.
double y = Math.Sin( (double) i * Math.PI / 15.0 );
list.Add( x, y );
}
....missing code...
// Set the XAxis to date type
myPane.XAxis.Type = AxisType.Date;
//JEM //This one also doesn't work even if I change it to the
//syntax that C++ understands, that is,
myPane->XAxis->Type = AxisType->Date;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许 C++ 对匿名变量有一些问题?
尝试先创建一个
XDate
对象,然后再将其转换为 double。Maybe C++ has some problems with the anonymous variables?
Try to create a
XDate
object first before converting it to double.谢谢加塞克。
就这样最后就这样下去了。你的回答是转折点!
这是来自 sourceforge dot net Documentation/html/M_ZedGraph_XDate__ctor_3.htm 的 C++ Xdate 类型的构造函数。
XDate (intyear,intmonth,intday,inthour,intmin,doublesecond)
我还在此链接上找到了详细的示例 http://www.c-plusplus.de/forum/viewtopic-var-t-is-186422-and -view-is-next.html
用下面的代码
Thanks Gacek.
This is how it finally went down. Your answer was the turning point!!!
here is the constructor for the Xdate type for c++ from sourceforge dot net documentation/html/M_ZedGraph_XDate__ctor_3.htm.
XDate (int year, int month, int day, int hour, int minute, double second)
I have also found a detailed example on this link http://www.c-plusplus.de/forum/viewtopic-var-t-is-186422-and-view-is-next.html
with the following code