见下图.我正在以编程方式构建图表,所以请不要使用asp.net控件语法.

如何更改条形后面水平和垂直交叉的网格线颜色?如您所见,我已经找到了如何更改实际的轴颜色,但网格颜色保持黑色.
public ActionResult RenderChart()
{
var chart = new Chart();
double[] yValues = { 65.62, 75.54, 60.45, 55.73, 70.42 };
string[] xValues = { "Michelle", "Sarah", "Aliece", "Belinda", "Amanda" };
var series = new Series
{
Name = "Default",
ChartType = SeriesChartType.Column,
CustomProperties = "DrawingStyle=Cylinder"
};
series.Points.DataBindXY(xValues, yValues);
chart.BorderlineColor = Color.Silver;
var area = new ChartArea("Test");
area.AxisX.LineColor = Color.DarkGray;
area.AxisY.LineColor = Color.DarkGray;
chart.ChartAreas.Add(area);
chart.Series.Add(series);
series.IsValueShownAsLabel = true;
series.Font = new Font(series.Font, FontStyle.Bold);
chart.Width = 400;
chart.Height = 300;
using(var ms = new MemoryStream())
{
chart.SaveImage(ms, ChartImageFormat.Png);
Response.ContentType = "image/png";
Response.BinaryWrite(ms.ToArray());
return new EmptyResult();
}
}
Run Code Online (Sandbox Code Playgroud)
Nat*_*ley 17
没关系,找到了答案:
area.Axes[n].MajorGrid.LineColor = Color.Whatever;
Run Code Online (Sandbox Code Playgroud)