Auto positioned adornment is missing sometimes

Hi,

I'm using your wpf SfChart control and sometimes adornment is missing when value of column is 1. I have converter to hide adornments with 0 value. Could you please check if you wil lsee some issues in my implementation? Thank you very much in advance.

<UserControl.Resources>
            <DataTemplate x:Key="ChartLabelTemplate">
                <Label Content="{Binding}"
                       FontSize="20"
                       Foreground="White"
                       HorizontalAlignment="Center"
                       HorizontalContentAlignment="Center"
                       Visibility="{Binding Converter={StaticResource MoreThanEqualToVisibilityConverter}, ConverterParameter=1}"/>
            </DataTemplate>
</UserControl.Resources>

        <syncfusion:SfChart Grid.Row="1" Foreground="White">
            <syncfusion:SfChart.PrimaryAxis>
                <syncfusion:CategoryAxis EnableScrollBar="False"
                                         EnableTouchMode="False"/>
            </syncfusion:SfChart.PrimaryAxis>
            <syncfusion:SfChart.SecondaryAxis>
                <syncfusion:NumericalAxis />
            </syncfusion:SfChart.SecondaryAxis>
            <syncfusion:ColumnSeries ItemsSource="{Binding ChartData}"
                                     XBindingPath="Datetime" YBindingPath="Quantity">
                <syncfusion:ColumnSeries.AdornmentsInfo>
                    <syncfusion:ChartAdornmentInfo LabelTemplate="{StaticResource ChartLabelTemplate}"
                                                   ShowLabel="True" LabelPosition="Auto"
                                                   FontSize="22"/>
                </syncfusion:ColumnSeries.AdornmentsInfo>
            </syncfusion:ColumnSeries>
        </syncfusion:SfChart>

public sealed class MoreThanEqualToVisibilityConverter : IValueConverter
    {
        #region Public Methods

        /// <summary>
        /// The convert.
        /// </summary>
        /// <param name="value"> The value. </param>
        /// <param name="targetType"> The target type. </param>
        /// <param name="parameter"> The parameter. </param>
        /// <param name="culture"> The culture. </param>
        /// <returns> The <see cref="object"/>. </returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            IComparable comparable1 = (IComparable)value;

            if (comparable1 == null)
            {
                return Visibility.Collapsed;
            }

            IComparable comparable2 = (IComparable)System.Convert.ChangeType(parameter, comparable1.GetType(), culture);

            if (comparable1.CompareTo(comparable2) >= 0)
            {
                return Visibility.Visible;
            }

            return Visibility.Collapsed;
        }

        /// <summary>
        /// The convert back.
        /// </summary>
        /// <param name="value"> The value. </param>
        /// <param name="targetType"> The target type. </param>
        /// <param name="parameter"> The parameter. </param>
        /// <param name="culture"> The culture. </param>
        /// <returns> The <see cref="object"/>. </returns>
        /// <exception cref="NotImplementedException">Any Exception </exception>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }

3 Replies

MK Muneesh Kumar G Syncfusion Team June 4, 2018 05:04 AM UTC

Hi Peter, 
 
Thanks for using Syncfusion products.  
 
We have analyzed the stated problem with your code and we could found that you are setting Label Foreground is White. We would like to inform you that adornment auto position placed outside of segment, so that it not visible due to label foreground and chart background are in same color. You can resolve this problem by setting label Background for Label or setting any other Foreground for label as per the below code snippet.  
 
Code snippet for setting Background: 
<DataTemplate x:Key="ChartLabelTemplate"> 
                <Label Content="{Binding}" 
                       FontSize="20" 
                       Foreground="White" Background="Red" 
                       HorizontalAlignment="Center" 
                       HorizontalContentAlignment="Center" 
                       Visibility="{Binding Converter={StaticResource MoreThanEqualToVisibilityConverter}, ConverterParameter=1}"/> 
            </DataTemplate> 
 
Code snippet for setting Foreground: 
  <DataTemplate x:Key="ChartLabelTemplate"> 
                <Label Content="{Binding}" 
                       FontSize="20" 
                       Foreground="Black"  
                       HorizontalAlignment="Center" 
                       HorizontalContentAlignment="Center" 
                       Visibility="{Binding Converter={StaticResource MoreThanEqualToVisibilityConverter}, ConverterParameter=1}"/> 
            </DataTemplate> 
 
Please let us know if you have any queries.  
 
Thanks,
Muneesh Kumar G
 



PV Peter Verbo June 4, 2018 06:24 AM UTC

Hi Muneesh Kumar G,

thank you for your answer but I don't think it is colors issue. You can check below image where left side should display 1 on top of new column but it is empty. On right side 2 is displayed correctly when quantity changed. And as I mentioned it fails only from time to time. So it is not 100% reproducible. So I don't know, maybe if there is a way to force redraw adornments or whole chart to be sure that all values are displayed correctly or something like that? I'm just guessing :)

Issue


Thanks,
Peter


DS Durgadevi Selvaraj Syncfusion Team June 5, 2018 11:21 AM UTC

Hi Peter, 

Thanks for your update. 

We have analyzed the reported problem and by default all the labels are showing properly, we assume that the converter in binding of Visibility property returns the Visibility.Collapsed for the label “1”. Could you please remove this from your code and let us know whether the label with text “1” is visible after that? 

Code Snippet[XAML] 
 
<DataTemplate x:Key="ChartLabelTemplate"> 
                <Label Content="{Binding}" 
                       FontSize="20" 
                       Foreground="White" 
                       HorizontalAlignment="Center" 
                       HorizontalContentAlignment="Center" 
                       Visibility="{Binding Converter={StaticResource MoreThanEqualToVisibilityConverter}, ConverterParameter=1}"/> 
</DataTemplate> 

Please let us know if you need any further assistance on this. 

Regards,  
Durgadevi.S 


Loader.
Up arrow icon