請參見下面的圖表。我以編程方式構建圖表,因此請勿使用asp.net控件語法。如何更改Microsoft Chart Controls中的軸分隔線顏色(柱形圖)
如何改變這種水平和垂直交叉身陷囹圄網格線的顏色?正如你所看到的,我已經研究出如何改變實際的軸顏色,但網格顏色仍然是黑色的。
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();
}
}