.NET Framework Bookmark and Share   
 index > Chart Controls for .NET Framework > Changing the AxisLabel color
 

Changing the AxisLabel color

Hello,

is it possible to change the color of the AxisLabel like the color of the Label with LabelForeColor ?

Thanks by advance.
seriousme

yes you canchange

Chart1.ChartAreas(

"ChartArea1").AxisX.LabelStyle.ForeColor = Color.Blue


Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
KishorePV
Thanks for your reply.

Sorry, but I have not specified that I would like to change the color for only one AxisLabel, in fact an important date.
seriousme
Axis label color is defined by CustomLabel.ForeColor property. It is easy to set if you define your own custom labels but if you depend on the automatically generated axis labels then you can use Chart.Customize event and Axis.CustomLabels collection. During the Customize event chart will generate automatic labels and expose them in CustomLabels property for customization. At that moment you can update label ForeColor property.

Alex.
http://blogs.msdn.com/alexgor
Alex Gorev
Thanks for the reply, but by using the Customize event how to retrieve the DataPoint related to a CustomLabel ?

Indeed a CustomLabel provides its graphical position but no information about the position of the DataPoint ,
but my test to determine the good color is based on the DataPoint date.

I've tried to retreive the DataPoint index in the Series points collection and use this index to retrieve the good CustomLabel but no way,
because the indexes don't match.

So is there a solution with automatic generation and the Customize event, or will I have to manage the CustomLabels myself ?
If so what is the best way to do it ?

Thanks again.
seriousme
Is there a reliable way of retrieving the original data from the position of the label ?

Like the HitTest of a DataGridView that computes the cell coordinates from the mouse coordinates.

Thanks.
seriousme
There is no one to one relationship between axis label and series data points. You can have a label with no associated data points or you can have many of them. Each label has From and To properties which can be used to calculate position of the label along the axis. You can then try searching for the data point(s) with same position. Something like this:

(From + To) / 2 == point.Xvalue

or if you do not specify X values:

(From + To) / 2 == series.Points.IndexOf(point)

Alex.
http://blogs.msdn.com/alexgor
Alex Gorev

You can use google to search for other answers

Custom Search

More Threads

• Next Version
• How to show StackedGroupName of dundas chart
• outlook warning
• ImageLocation - Networkshare
• new Chart() locking up sometimes
• DataManipulator.InsertEmptyPoints Does it work?
• Pie Chart Control
• How can I change the fonts of Legend on pie chart?
• Need to show you chart pictures to get the point across... Too Complex to describe in words
• how to set the chart control's Title Height or width?