降低Windows窗体图表中的网格可见性
本文关键字:网格 可见性 Windows 窗体 降低 | 更新日期: 2023-09-27 18:25:10
嗨,我在windows窗体应用程序中使用条形图。它显示了条形图后面的网格,我的客户想要两个改变1:将网格从线改为点视图,网格样式应该是深灰色。你能提出你的建议吗?
var chart = new Chart
{
Width = 500,
Height = 360,
AntiAliasing = AntiAliasingStyles.All,
TextAntiAliasingQuality = TextAntiAliasingQuality.High
};
chart.Series.Add("");
foreach (String description in keyValue.Keys)
{`enter code here`
decimal value;
keyValue.TryGetValue(description, out value);
chart.Series[0].Points.AddXY(description, value);
}
chart.Series[0].Font = new Font(Constant.FontFamily, 15f, FontStyle.Regular, GraphicsUnit.Point);
chart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bar;
chart.Series[0].Color = System.Drawing.Color.FromArgb(169, 14, 59);
chart.ChartAreas.Add("CharArea");
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font(Constant.FontFamily,15);
chart.Legends.Add(new Legend());
chart.Legends[0].Enabled = false;
chart.Series[0].CustomProperties = "DrawingStyle=Cylinder";
// chart.ChartAreas[0].AxisY.LabelStyle.Format = new Font(Constant.FontFamily, 9f, FontStyle.Regular, GraphicsUnit.Point);
using (var chartimage = new MemoryStream())
{
chart.SaveImage(chartimage, ChartImageFormat.Png);
return chartimage.GetBuffer();
}
添加到.FromArgb方法的末尾0,0
总的来说,它看起来像。FromArgb(r,g,b,0,0)
我在代码中做了以下更改,它对我有效。对于虚线和灰色
chart.ChartAreas[0].AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDotDot;
chart.ChartAreas[0].AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.DashDotDot;
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.DarkGray;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.DarkGray;