We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

NumericalAxis LabelFormat with degree symbol

I have the following property declaration in my xaml

<syncfusion:SfChart.SecondaryAxis>

                    <syncfusion:NumericalAxis Header="Crucible Angle(In Degrees)"

                                              PlotOffset="20" ShowGridLines="True"

                                              ShowTrackBallInfo="True"

                                              Interval="5"

                                              Minimum="0"

                                              Maximum="95"

                                              LabelFormat="0°"

                                              LabelExtent="25"/>

 </syncfusion:SfChart.SecondaryAxis>

and in the designer everything is good, the LabelFormat is displaying the degree symbol in the designer.

Chart1.png

However it won't build, I get this error

 MC3000: 'Invalid character in the given encoding. Line 53, position 61.' XML is not valid.

Line 53, position 61 is the ° symbol in the LabelFormat="0°" from the xaml above.

How can I do this and avoid the error?


1 Reply

MD Moneeshram Dhanabal Syncfusion Team February 8, 2023 09:25 AM UTC

Hi Jack,


We have validated your query to add a degree symbol as a suffix in the secondary axis label. This can be achieved by using the LabelCreated Event in the Secondary axis. In the event handler method, we will get the label content value and append it with the degree symbol, as shown in the code snippet below.

<chart:SfChart x:Name="Chart" Margin="10" >

              . . .

            <chart:SfChart.SecondaryAxis>

                <chart:NumericalAxis  PlotOffset="20" ShowGridLines="True"

                                     ShowTrackBallInfo="True" Interval="5" Minimum="0" Maximum="95"

                                     LabelExtent="25" LabelCreated="NumericalAxis_LabelCreated"/>

            </chart:SfChart.SecondaryAxis>

              . . .

</chart:SfChart>


private void NumericalAxis_LabelCreated(object sender, LabelCreatedEventArgs e)

{

            e.AxisLabel.LabelContent = e.AxisLabel.LabelContent + "°" ;

}


Please check this case and let us know if you need any further assistance.


Regards,

Moneeshram


Loader.
Live Chat Icon For mobile
Up arrow icon