BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
<Grid.Resources>
<local:LableConverter x:Key="conv"/>
</Grid.Resources>
<chart:SfChart Margin="10">
<chart:SfChart.PrimaryAxis>
<chart:NumericalAxis/>
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis Minimum="-7" Maximum="-2"/>
</chart:SfChart.SecondaryAxis>
<chart:RangeColumnSeries Palette="Metro" ItemsSource="{Binding Collection}" XBindingPath="XValue" High="High" Low="Low">
<chart:RangeColumnSeries.AdornmentsInfo>
<chart:ChartAdornmentInfo ShowLabel="True" SegmentLabelContent="LabelContentPath" AdornmentsPosition="TopAndBottom" LabelPosition="Outer" >
<chart:ChartAdornmentInfo.LabelTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource conv}}" FontWeight="Bold"/>
</DataTemplate>
</chart:ChartAdornmentInfo.LabelTemplate>
</chart:ChartAdornmentInfo>
</chart:RangeColumnSeries.AdornmentsInfo>
</chart:RangeColumnSeries>
</chart:SfChart> |
public class LableConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var adornment = (value as ChartAdornment);
var diff = (adornment.Item as Model).High - adornment.YData;
if (diff <= 0.05 && diff != 0)
return "";
else
return adornment.YData;
}
} |
Wow, thank you so much! I didn't know about LabelConverter and IValueConverter. Also I appreciate for your clean code example.
In addition to that, how can i set different width and spacing of each column? For example, width={7, 1, 8.5, 3, 8, 10} with spacing of width/10 in your code.
Thank you in advance.
Add:
If i change the high and low values and re-assign Collection to the ItemSource, columns in graph update properly, but adornments don't. Why converter function iterates only once? and how to fix it?
<chart:RangeColumnSeries Palette="Metro" SegmentSpacing="0.9" ItemsSource="{Binding Collection}" XBindingPath="XValue" High="High" Low="Low"/> |
<chart:RangeColumnSeries Palette="Metro" chart:ChartSeriesBase.Spacing="0.7" ItemsSource="{Binding Collection}" XBindingPath="XValue" High="High" Low="Low"/> |
<chart:RangeColumnSeries Palette="Metro" ItemsSource="{Binding Collection}" XBindingPath="XValue" High="High" Low="Low">
<chart:RangeColumnSeries.CustomTemplate>
<DataTemplate>
<Canvas>
<Rectangle Height="{Binding Height}" Fill="{Binding Interior}" Width="{Binding Converter={StaticResource widthConv}}" Canvas.Left="{Binding Converter={StaticResource rectx}}" Canvas.Top="{Binding RectY}"/>
</Canvas>
</DataTemplate>
</chart:RangeColumnSeries.CustomTemplate>
</chart:RangeColumnSeries> |