AxisLabelItemBase.TextColor Property
Gets or sets an axis label item’s text color.
Namespace: DevExpress.XtraCharts
Assembly: DevExpress.XtraCharts.v24.2.dll
Declaration
[XtraChartsLocalizableCategory(XtraChartsCategory.Appearance)]
public Color TextColor { get; set; }
Property Value
Type | Description |
---|---|
Color | A Color structure which specifies the axis label item’s text color. |
Remarks
An axis label item is the specific instance of the AxisLabelItem class, obtained in the ChartControl.CustomDrawAxisLabel (or WebChartControl.CustomDrawAxisLabel) event handler.
For axis labels as a whole (represented by an instance of the AxisLabel class), the TitleBase.TextColor property, which is similar, is provided.
For more information, refer to Axis Labels.
Example
Apart from the capability to customize the overall appearance of axis labels, you can obtain individual axis labels at runtime. Then, it’s possible to apply all the options available for axis labels to them, individually. For example, based on some criteria (e.g. an axis value threshold), you can apply different formatting to axis labels.
For this, the special ChartControl.CustomDrawAxisLabel event is introduced. Handle it to obtain axis labels.
Note
For the WebChartControl you should handle its WebChartControl.CustomDrawSeries event to implement this task.
The following code demonstrates one possible implementation of this capability.
private void chartControl1_CustomDrawAxisLabel(object sender, CustomDrawAxisLabelEventArgs e) {
AxisBase axis = e.Item.Axis;
if (axis is AxisY || axis is AxisY3D || axis is RadarAxisY) {
double axisValue = (double)e.Item.AxisValue;
if (axisValue < 0) {
e.Item.TextColor = Color.Red;
}
else if (axisValue > 0) {
e.Item.Text = "+" + e.Item.Text;
e.Item.TextColor = Color.Green;
}
else if (axisValue == 0) {
e.Item.Text = "Zero";
}
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the TextColor property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.