BarSeries cannot make any changes to Axis Label fonts

Hi! I tried everything but I cannot make any change to the fonts (size, color etc.) on any of the X and Y axis labels. Here is an example code, which doesn't work!


 LabelStyle style = new LabelStyle()

            {

                FontFamily = new FontFamily("Algerian"),

                FontSize = 20,

                Foreground = new SolidColorBrush(Colors.Blue)

            };

 CategoryAxis primaryAxis = new CategoryAxis()

            {

                LabelStyle = style,  //Doesn't work

                //FontSize = 20, //Doesn't work

                //FontStyle = FontStyles.Italic,  //Doesn't work

                Foreground = new SolidColorBrush(Colors.Blue),  //Doesn't work

                ShowGridLines = false  //This works

                //LabelRotationAngle = 90 //THIS WORKS if I enable it!

            };

            chart.PrimaryAxis = primaryAxis;


            NumericalAxis secondaryAxis = new NumericalAxis()

            {

                LabelStyle = style,  //Doesn't work

                //Foreground = new SolidColorBrush(Colors.Blue),  //Doesn't work

                ShowGridLines = false //This works

            };

            chart.SecondaryAxis = secondaryAxis;


Please help because I have spent hours and hours trying to find a solution. I only want a code solution and not an XAML one because I don't create any charts in the UI. I just save the charts without showing them in the UI. 


2 Replies

DD Devakumar Dhanapoosanam Syncfusion Team June 27, 2022 10:04 AM UTC

Hi Aristeidis,


We have checked the reported problem and we would like to let you know that the axis LabelStyle customization were working proper at our end while saving the chart without adding in UI.


LabelStyle labelStyle = new LabelStyle()

{

    FontFamily = new FontFamily("Algerian"),

    Foreground = new SolidColorBrush(Colors.Blue),

    FontSize = 20,

};

CategoryAxis primaryAxis = new CategoryAxis()

{

    LabelStyle = labelStyle,

    ShowGridLines = false

};

 

chart.PrimaryAxis = primaryAxis;

 

NumericalAxis secondaryAxis = new NumericalAxis()

{

    LabelStyle = labelStyle,

    ShowGridLines = false

};

 

chart.SecondaryAxis = secondaryAxis;


Chart, bar chart

Description automatically generated

Please find the tested sample from the attachment below and let us know if you need any further assistance.


If you still face any problem, can you please revert us by modifying the sample based on your scenario along with replication steps. It will help us provide an appropriate solution at the earliest.


Regards,

Devakumar D



DD Devakumar Dhanapoosanam Syncfusion Team June 27, 2022 10:07 AM UTC

Please find the tested sample in the attachment below.


Attachment: SF_175864_4ef8c01d.zip

Loader.
Up arrow icon