[英]Chart control change axis color
這是我的Chart control Graph
:
我想從左側移除軸黑線,並在按鈕上添加藍線作為所有圖形的框架。 我搜索了所有屬性並嘗試更改顏色,但默認顏色仍然存在
如果你想自定義圖表,你可以動態地繪制自己的圖表:
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;
你可以使用一個循環來繪制網格
我知道這個老帖子,但回答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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.