See the chart below. I'm building the chart programatically, so no asp.net control syntax please.
How do I change the grid line colours that cross horizontally and vertically behind the bars? As you can see I've worked out how to change the actual axis colours, but the grid colours remain black.
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();
}
}
Select the worksheets for which you want to change the gridline color. Click File > Excel > Options. In the Advanced category, under Display options for this worksheet, make sure that the Show gridlines check box is selected. In the Gridline color box, click the color you want.
Select the bar chart or column chart, then click Kutools > Charts > Color Chart by Value. Then in the popped-out dialog, set the value range and the relative color as you need.
Use the Chart Styles button to quickly change the color or style of the chart. Click the chart you want to change. In the upper-right corner, next to the chart, click Chart Styles. Click Color and pick the color scheme you want, or click Style and pick the option you want.
In the Format Axis dialog box, click Scale, and under Value axis scale, modify any of the following options: To change the number at which the vertical (value) axis starts or ends, for the Minimum or Maximum option, type a different number in the Minimum box or the Maximum box.
Never mind, found the answer:
area.Axes[n].MajorGrid.LineColor = Color.Whatever;
You can also do it in the HTML like this
<asp:Chart ID="chartOutstandingOrders" runat="server" Width="500" Palette="Bright">
<Series>
<asp:Series ChartType="Line" Name="seriesBackorder">
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" BorderColor="#339966">
<AxisX LineColor="Gray">
<MajorGrid LineColor="LightGray" />
</AxisX>
<AxisY LineColor="Gray">
<MajorGrid LineColor="LightGray" />
</AxisY>
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With