各位好!
    我现在遇到的问题大意为:在一幅折线图中,假如已有3条折线,我如何实现去掉其中特定的一条折线。
之前的方法是:先完全清除再绑定,这样有刷新抖动。
查了网上:
To remove just one PieItem object:Dim zgc As ZedGraph.ZedGraphControl = Me.ZedGraphControl1Dim zgPane As ZedGraph.GraphPane = zgc.GraphPaneDim zgPieItem As ZedGraph.PieItem = zgPane.CurveList("PieItemLabel")
zgPane.CurveList.Remove(zgPieItem)
但这没看懂如何使用!恳请,知道的人指教!谢谢

解决方案 »

  1.   

    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.Drawing;
    using ZedGraph;
    using ZedGraph.Web;namespace HINDI.Web.Report
    {
        public partial class LineChart : System.Web.UI.Page
        {
            private string zPath = System.Configuration.ConfigurationManager.AppSettings["ZedPath"];
            
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    this.ZedGraphDemo();
                }
            }        #region ZedGraph生成折线图
            private void ZedGraphDemo()
            {
                //设置图表保存文件夹
                this.zgwLine.RenderedImagePath = zPath;
            }        /// 
            /// ZedGraph折线图演示
            /// 
            /// 封装的一个GDI+绘图图面
            /// ZedGraph.MasterPane:绘图面板
            private void CreateImage(Graphics g, MasterPane pane)
            {            ZedGraph.GraphPane myPane = pane[0];            //主题
                myPane.Title.Text = "指标数据报表";
                //主题字体颜色
                myPane.Title.FontSpec.FontColor = Color.Red;
                //主题字体大小
                myPane.Title.FontSpec.Size = 20;
                //横纵坐标的标题
                string [] subject = new string[]{"月份","数据值"};
                //月份数组
                string [] months = new string[] { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二" };
                //月份对应值
                double[] datas = new double[] { 1.5,2.1,1.5,1.8,1.7,1.9,5.9,4.3,1.7,1.8,1.1,1.9};
                //数据点集合(包含横纵坐标点)
                PointPairList list = new PointPairList();
                for (int i = 0; i < months.Length; i++)
                {
                    //横坐标点
                    double x = Convert.ToDouble(i);
                    //纵坐标点
                    double y = datas[i];
                    //添加到集合中
                    list.Add(x,y);
                }
                //设置横坐标的标题
                myPane.XAxis.Title.Text = subject[0];
                //设置纵坐标的标题
                myPane.YAxis.Title.Text = subject[1];            //设置横坐标的类型为文本
                myPane.XAxis.Type = AxisType.Text;
                //设置横坐标的开始的最小值
                myPane.XAxis.Scale.Min = 0;
                //设置横坐标的结束的最大值
                myPane.XAxis.Scale.Max = 13;
                //设置横坐标要显示的文本
                myPane.XAxis.Scale.TextLabels = months;
                //设置横坐标的字体大小
                myPane.XAxis.Scale.FontSpec.Size = 8;
                //设置纵坐标的字体大小
                myPane.YAxis.Scale.FontSpec.Size = 10;
                //设置横坐标的文本为可见的(默认可见)
                //myPane.XAxis.Scale.IsVisible = true;
                //将横纵坐标点添加到面板中,并设置名称,值,颜色,点的形状
                LineItem curve = myPane.AddCurve("实际值", list, Color.Red, SymbolType.Circle);
                //设置各点的连线宽度
                curve.Line.Width = 1.0F;
                //设置点的填充颜色
                curve.Symbol.Fill = new Fill(Color.White);
                //设置点的大小
                curve.Symbol.Size = 5;
                //设置连接线的抗锯齿效果
                curve.Line.IsAntiAlias = true;
                //设置图形的填充颜色(渐变效果,及渐变的角度)
                myPane.Chart.Fill = new Fill(Color.White,Color.SteelBlue,45.0F);
                myPane.AxisChange(g);
                //绘制图片
                myPane.Draw(g);        }
            #endregion        protected void zgwLine_RenderGraph(Graphics g, MasterPane pane)
            {
                CreateImage(g, pane);
            }
        }
    }