gpt4 book ai didi

.net - 如何更改 Microsoft Chart Controls(柱状图)中的轴分隔线颜色

转载 作者:行者123 更新时间:2023-12-04 00:25:11 26 4
gpt4 key购买 nike

请参阅下面的图表。我正在以编程方式构建图表,所以请不要使用 asp.net 控制语法。

bar chart example

如何更改横条后面水平和垂直交叉的网格线颜色?如您所见,我已经找到了如何更改实际轴颜色的方法,但网格颜色仍为黑色。

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();
}
}

最佳答案

没关系,找到答案:

area.Axes[n].MajorGrid.LineColor = Color.Whatever;

关于.net - 如何更改 Microsoft Chart Controls(柱状图)中的轴分隔线颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2429181/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com