How to add custom axis labels with specified color, font, and value type in WinForms Chart
To customize the position of TickLabels on a specified axis in a WinForms Charts, first set the drawing mode of the TickLabels to UserMode. This enables user-driven customization. Afterwards, clear the existing labels and add a new set of labels with the specified color, font, and ValueType to the labels collection of the chart axis.
this.chartControl1.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;
this.chartControl1.PrimaryXAxis.Labels.Clear();
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("a", Color.Purple, new Font("Symbol", 13), 0, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("b", Color.Red, new Font("Symbol", 13), 1, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("g", Color.Green, new Font("Symbol", 13), 2, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("d", Color.Crimson, new Font("Symbol", 13), 3, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("e", Color.Blue, new Font("Symbol", 13), 4, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("z", Color.Orange, new Font("Symbol", 13), 5, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("n", Color.Pink, new Font("Symbol", 13), 6, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("t", Color.RoyalBlue, new Font("Symbol", 13), 7, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("s", Color.Gold, new Font("Symbol", 13), 8, "", ChartValueType.Custom));
columnChart.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode
columnChart.PrimaryXAxis.Labels.Clear()
columnChart.PrimaryXAxis.Labels.Add(New ChartAxisLabel("a", Color.Purple, New Font("Symbol", 13), 0, "", ChartValueType.Custom))
columnChart.PrimaryXAxis.Labels.Add(New ChartAxisLabel("b", Color.Red, New Font("Symbol", 13), 1, "", ChartValueType.Custom))
columnChart.PrimaryXAxis.Labels.Add(New ChartAxisLabel("g", Color.Green, New Font("Symbol", 13), 2, "", ChartValueType.Custom))
columnChart.PrimaryXAxis.Labels.Add(New ChartAxisLabel("d", Color.Crimson, New Font("Symbol", 13), 3, "", ChartValueType.Custom))
columnChart.PrimaryXAxis.Labels.Add(New ChartAxisLabel("e", Color.Blue, New Font("Symbol", 13), 4, "", ChartValueType.Custom))
columnChart.PrimaryXAxis.Labels.Add(New ChartAxisLabel("z", Color.Orange, New Font("Symbol", 13), 5, "", ChartValueType.Custom))
columnChart.PrimaryXAxis.Labels.Add(New ChartAxisLabel("n", Color.Pink, New Font("Symbol", 13), 6, "", ChartValueType.Custom))
columnChart.PrimaryXAxis.Labels.Add(New ChartAxisLabel("t", Color.RoyalBlue, New Font("Symbol", 13), 7, "", ChartValueType.Custom))
columnChart.PrimaryXAxis.Labels.Add(New ChartAxisLabel("s", Color.Gold, New Font("Symbol", 13), 8, "", ChartValueType.Custom))Output:
Conclusion
I hope you enjoyed learning about how to add custom axis labels with specified color, font, and value type in WinForms Chart.
You can refer to our WinForms Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our WinForms Chart examples to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!