各位同行好,
现在在用mschart画图,出了几个问题,一直解决不了,请求高人相助:
问题一:有关图的放大缩小问题,从一些帖子上看到需要设置CursorX属性如下,但是为啥在俺的项目里就愣是报错呢?
Chart1.ChartAreas["Default"].CursorX.IsUserEnabled = true;
Chart1.ChartAreas["Default"].CursorX.IsUserSelectionEnabled = true;
Chart1.ChartAreas["Default"].AxisX.ScaleView.Zoomable = true;
错误提示:
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。
编译器错误消息: CS1061: “System.Web.UI.DataVisualization.Charting.ChartArea”不包含“CursorX”的定义,并且找不到可接受类型为“System.Web.UI.DataVisualization.Charting.ChartArea”的第一个参数的扩展方法“CursorX”(是否缺少 using 指令或程序集引用?)
PS:我的using集:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Threading;
using System.Linq;
using System.ComponentModel;
using System.Drawing;
using System.Web.SessionState;
using System.Web.UI.DataVisualization;
using System.Web.UI.DataVisualization.Charting;
问题二:
我的绑定数据源的方法是这样的:
#region 创建曲线序列
String ChartType = DropDownList2.SelectedItem.Value.ToString();
System.Web.UI.DataVisualization.Charting.Series series;
for (int i = 1; i < MyDataSet.Tables[0].Columns.Count; i++)
{
series = Chart1.Series.Add(MyDataSet.Tables[0].Columns[i].ColumnName.ToString().Trim());
series.ChartArea = "Default";
series.ChartType = (System.Web.UI.DataVisualization.Charting.SeriesChartType)Enum.Parse(typeof(System.Web.UI.DataVisualization.Charting.SeriesChartType), ChartType);//曲线类型赋值
series.BorderWidth = 2;
series.BorderColor = System.Drawing.Color.Red;
series.MarkerStyle = System.Web.UI.DataVisualization.Charting.MarkerStyle.Circle;
series.ShadowColor = Color.FromArgb(64, 0, 0, 0);
series.ShadowOffset = 2;
series.XValueType = ChartValueType.DateTime;
//绑定数据源,databind(行,横轴,纵轴)
//series.Points.DataBind(MyDataSet.Tables[0].Rows, MyDataSet.Tables[0].Columns[0].ToString(), MyDataSet.Tables[0].Columns[i].ToString(), "ToolTip=时间");
series.Points.DataBind(MyDataSet.Tables[0].Rows, MyDataSet.Tables[0].Columns[0].ToString(), MyDataSet.Tables[0].Columns[i].ToString(),"");