这是我的Chart control Graph
:
我想从左侧移除轴黑线,并在按钮处添加蓝线作为所有图形的框架。 我搜索了所有属性并尝试更改颜色,但默认颜色仍然是
答案 0 :(得分:1)
如果您想自定义图表,可以动态绘制自己的图表:
VB.net中的示例:
Const GraphHeight As Integer = 100
Const GraphWidth As Integer = 200
Dim cIMG As New Bitmap(GraphWidth, GraphHeight)
Dim G As Graphics = Graphics.FromImage(cIMG)
Dim red As Integer = 0
Dim pnts(4) As Point
pnts(0) = New Point(0, GraphHeight - 0)
pnts(1) = New Point(50, GraphHeight - 80)
pnts(2) = New Point(100, GraphHeight - 50)
pnts(3) = New Point(150, GraphHeight - 40)
pnts(4) = New Point(200, GraphHeight - 20)
G.DrawLines(Pens.Blue, pnts)
PictureBox1.Image = cIMG
C#中的示例:
const int GraphHeight = 100;
const int GraphWidth = 200;
Bitmap cIMG = new Bitmap(GraphWidth, GraphHeight);
Graphics G = Graphics.FromImage(cIMG);
int red = 0;
Point[] pnts = new Point[5];
pnts(0) = new Point(0, GraphHeight - 0);
pnts(1) = new Point(50, GraphHeight - 80);
pnts(2) = new Point(100, GraphHeight - 50);
pnts(3) = new Point(150, GraphHeight - 40);
pnts(4) = new Point(200, GraphHeight - 20);
G.DrawLines(Pens.Blue, pnts);
PictureBox1.Image = cIMG;
您可以使用循环绘制网格
答案 1 :(得分:1)
我知道这个老帖子,但是要回答OP问题。
更改线条颜色和线条样式
Chart1.ChartAreas(0).AxisY.LineColor = Color.Blue
Chart1.ChartAreas(0).AxisY.LineDashStyle =ChartDashStyle.Dot
如果要删除刻度线,请使用此代码
Chart1.ChartAreas(0).AxisY.MajorTickMark.Enabled = False
Chart1.ChartAreas(0).AxisY.MinorTickMark.Enabled = False