how can I change forecolor of a chart label?

烈酒焚心 提交于 2021-02-20 18:44:02

问题


how can i change the fore color of the chart labels? here's a screenshot of the chart enter image description here

i tried using the chart1.series[0].FontForeColor = color.white; but the entire chart turns white.


回答1:


Try this:

        this.chart1.BackColor = Color.AliceBlue;

        this.chart1.ChartAreas[0].AxisX.LineColor = Color.Red;
        this.chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.Red;
        this.chart1.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.Red;

        this.chart1.ChartAreas[0].AxisY.LineColor = Color.Red;
        this.chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.Red;
        this.chart1.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.Red;

Here LabelStyle.ForeColor changes the label color, as you requested.

The properties LineColor and MajorGrid.LineColor allow modification of the grid lines (black on your screenshot), in case you need that as well. The colors Red and AliceBlue, of course, are just for example.



来源:https://stackoverflow.com/questions/21822762/how-can-i-change-forecolor-of-a-chart-label

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!