ZedGraph的在显示曲线图的时候,有外边框一直在显示,会显得特别碍眼,如何去掉它呢?
这个是原始的现象
1 去掉外边框的做法如下:
//去掉外边框
this.zedGraph.GraphPane.Border.IsVisible = false;
2 设置一下背景颜色
//设置灰色
this.zedGraph.GraphPane.Fill = new ZedGraph.Fill(Color.FromArgb(120, 120, 120));
//设置曲线区域的矩形框的颜色 黄色
this.zedGraph.GraphPane.Chart.Fill = new ZedGraph.Fill(Color.Yellow);
//设置绘制曲线区域的矩形框的边框颜色 红色
this.zedGraph.GraphPane.Chart.Border.Color = Color.Red;
效果如下图:
GraphPane
是绘图中主要的类,它包含所有其他类作为属性。还可以设置pane title、pane frame、axis frame以及背景颜色等。GraphPane类是ZedGraph类的外部“包装器”,它提供访问图形属性(比如 YAxis、 XAxis 、CurveList)的接口。
通过GraphPane
接口可以访问到的类有
类 | 描述 | 描述 |
---|---|---|
CurveList | Gets or sets the list of CurveItem items for this GraphPane | 获取或设置此GraphPane的CurveItem项列表 |
XAxis | Accesses the XAxis for this graph | 访问此图形的XAxis |
X2Axis | Accesses the X2Axis for this graph | 访问此图形的X2Axis |
YAxis | Accesses the primary YAxis for this graph | 访问此图形的主轴YAxis |
Y2Axis | Accesses the primary Y2Axis for this graph | 访问此图形的主轴Y2Axis |
YAxisList | Gets the collection of Y axes that belong to this GraphPane | 获取属于此GraphPane的Y轴集合 |
YAxisList2 | Gets the collection of Y2 axes that belong to this GraphPane | 获取属于此GraphPane的Y2轴集合 |
Chart | Gets the Chart instance for this GraphPane | 获取此GraphPane的Chart实例 |
BarSettings | Gets the BarSettings instance for this GraphPane | 获取此GraphPane的BarSettings实例 |
比如我们修改X轴的标题,
//通过GraphPane接口访问XAxis,并修改X轴的标题
this.zedGraph.GraphPane.XAxis.Title.Text = "Hi ,I'm XAxis";
小结一下:
GraphPane类封装了graph pane,所有的图形相关的元素都与GraphPane相关联。通过GraphPane可以获取其它类(轴、曲线等)的接口。