I got this sample code from Infragistics support to display marker text values for Range Column
Series and as you can see the issue for last column where marker text is not being aligned properly
I am attaching the relevant Xaml and code-behind
<Window.Resources>
<local:BarAxisConverter x:Key="AxisConverter"> </local:BarAxisConverter>
<DataTemplate x:Key="TextMarkerTemplate">
<local:RangeBarMarker Context="{Binding}"
HighMemberPath="High"
LowMemberPath="Low"/>
</DataTemplate>
<Style TargetType="ig:NumericYAxis">
<Setter Property="MajorStrokeDashArray"
Value="10 2" />
<Setter Property="MajorStrokeThickness"
Value="0.5" />
</Style>
<Style TargetType="ig:CategoryXAxis">
<Style TargetType="{x:Type ig:XamDataChart}" >
<Setter Property="HorizontalZoombarVisibility"
Value="Collapsed" />
<Setter Property="VerticalZoomable"
Value="True" />
<Setter Property="HorizontalZoomable"
<Setter Property="PlotAreaBorderThickness"
Value="2" />
<Setter Property="PlotAreaBorderBrush"
Value="Black" />
<local:TestData x:Key="data" />
</Window.Resources>
<Grid x:Name="LayoutRoot" Width="5.3064in" Height="2.6713in" >
<Border BorderThickness="1" BorderBrush="Black" >
<ig:XamDataChart x:Name="theChart" >
<ig:XamDataChart.Axes>
<ig:NumericYAxis x:Name="yAxis" MinimumValue="-1" MaximumValue="10" MajorStrokeThickness="0.5">
<ig:NumericYAxis.LabelSettings >
<ig:AxisLabelSettings Extent="50" Location="OutsideTop"></ig:AxisLabelSettings>
</ig:NumericYAxis.LabelSettings>
</ig:NumericYAxis>
<ig:CategoryXAxis
x:Name="xAxis"
ItemsSource="{StaticResource data}"
Label="{}{Label}">
<ig:CategoryXAxis.LabelSettings >
<ig:AxisLabelSettings Extent="20" Location="OutsideRight"></ig:AxisLabelSettings>
</ig:CategoryXAxis.LabelSettings>
</ig:CategoryXAxis>
</ig:XamDataChart.Axes>
<ig:XamDataChart.Series>
<ig:RangeColumnSeries
x:Name="series1"
MarkerTemplate="{StaticResource TextMarkerTemplate}"
XAxis="{Binding ElementName=xAxis}"
YAxis="{Binding ElementName=yAxis}"
HighMemberPath="High" LowMemberPath="Low" Outline="Red" Thickness="2">
</ig:RangeColumnSeries>
</ig:XamDataChart.Series>
</ig:XamDataChart>
</Border>
</Grid>
</Window>
=======Code behind==========
public class TestData
: ObservableCollection<TestDataItem>
{
public TestData()
Add(new TestDataItem()
Label = "A",
High = 9,
Low = 1,
HighVal = 100
});
Label = "B",
High = 7,
Low = 2,
HighVal = 200
Label = "C",
High = 4,
Low = 3,
HighVal = 300
Label = "D",
Low = 3
Label = "E",
Low = 9
Label = "F",
High = null,
Low = null
}
Custom Class :
public class RangeBarMarker : ContentControl
public static readonly DependencyProperty ContextProperty =
DependencyProperty.Register("Context",
typeof(DataContext), typeof(RangeBarMarker),
new PropertyMetadata(null, (o, e) => (o as RangeBarMarker)
.OnContextChanged(e.OldValue, e.NewValue)));
public DataContext Context
get { return (DataContext)GetValue(DataContextProperty); }
set { SetValue(DataContextProperty, value); }
public static readonly DependencyProperty HighProperty =
DependencyProperty.Register("High",
typeof(double), typeof(RangeBarMarker),
new PropertyMetadata(0.0, (o, e) => (o as RangeBarMarker)
.OnHighChanged((double)e.OldValue, (double)e.NewValue)));
private void OnHighChanged(double oldValue, double newValue)
UpdateContent();
public double High
get { return (double)GetValue(HighProperty); }
set { SetValue(HighProperty, value); }
public static readonly DependencyProperty LowProperty =
DependencyProperty.Register("Low",
.OnLowChanged((double)e.OldValue, (double)e.NewValue)));
private void OnLowChanged(double oldValue, double newValue)
public double Low
get { return (double)GetValue(LowProperty); }
set { SetValue(LowProperty, value); }
public static readonly DependencyProperty LowMemberPathProperty =
DependencyProperty.Register("LowMemberPath",
typeof(string), typeof(RangeBarMarker),
.OnLowMemberPathChanged((string)e.OldValue, (string)e.NewValue)));
private void OnLowMemberPathChanged(string oldValue, string newValue)
public string LowMemberPath
get { return (string)GetValue(LowMemberPathProperty); }
set { SetValue(LowMemberPathProperty, value); }
public static readonly DependencyProperty HighMemberPathProperty =
DependencyProperty.Register("HighMemberPath",
.OnHighMemberPathChanged((string)e.OldValue, (string)e.NewValue)));
private void OnHighMemberPathChanged(string oldValue, string newValue)
public string HighMemberPath
get { return (string)GetValue(HighMemberPathProperty); }
set { SetValue(HighMemberPathProperty, value); }
public static readonly DependencyProperty ItemProperty =
DependencyProperty.Register("Item",
typeof(object), typeof(RangeBarMarker),
.OnItemChanged((object)e.OldValue, (object)e.NewValue)));
private void OnItemChanged(object oldValue, object newValue)
public object Item
get { return (object)GetValue(ItemProperty); }
set { SetValue(ItemProperty, value); }
private XamDataChart watchingChart = null;
private void UpdateContent()
if (!Valid())
return;
UpdateHandlers();
SetBinding(ItemProperty,
new Binding("Context.Item")
Source = this
SetBinding(HighProperty,
new Binding("Context.Item." + HighMemberPath)
SetBinding(LowProperty,
new Binding("Context.Item." + LowMemberPath)
if (!double.IsNaN(Low) &&
!double.IsNaN(High) &&
!double.IsInfinity(Low) &&
!double.IsInfinity(High))
var rangeSeries = Context.Series as RangeCategorySeries;
var viewport =
new Rect(
0, 0,
rangeSeries.ActualWidth,
rangeSeries.ActualHeight);
double scaledLow = rangeSeries.YAxis.GetScaledValue(Low, rangeSeries.Chart.WindowRect, viewport);
double scaledHigh = rangeSeries.YAxis.GetScaledValue(High, rangeSeries.Chart.WindowRect, viewport);
double mid = (scaledLow + scaledHigh) / 2.0;
scaledLow += 10;
scaledHigh -= 10;
Grid grid = new Grid();
TextBlock tbHigh = new TextBlock()
Text = High.ToString(),
RenderTransform =
new TranslateTransform()
Y = scaledHigh - mid
};
TextBlock tbLow = new TextBlock()
Text = Low.ToString(),
Y = scaledLow - mid
grid.Children.Add(tbHigh);
grid.Children.Add(tbLow);
Content = grid;
private void UpdateHandlers()
if (watchingChart != null)
watchingChart.WindowRectChanged -= watchingChart_WindowRectChanged;
watchingChart.SizeChanged -= watchingChart_SizeChanged;
watchingChart = null;
if (Context.Series.Chart != null)
watchingChart = Context.Series.Chart;
watchingChart.WindowRectChanged += watchingChart_WindowRectChanged;
watchingChart.SizeChanged += watchingChart_SizeChanged;
void watchingChart_SizeChanged(object sender, SizeChangedEventArgs e)
void watchingChart_WindowRectChanged(object sender, Infragistics.RectChangedEventArgs e)
private bool Valid()
if (HighMemberPath == null)
return false;
if (LowMemberPath == null)
if (Context == null)
if (Context.Series == null)
if (Context.Series as RangeCategorySeries == null)
if ((Context.Series as RangeCategorySeries).YAxis == null)
return true;
private void OnContextChanged(object oldValue, object newValue)
ClearContent();
private void ClearContent()
Content = null;
Sabhash,
If you are refering to the last column with values (9,7), I think the issue is that you defined the values as: High=7, Low=9 while it should have been High=9, Low=7.
Let me know if that's the issue I am observing.
Thank you,Sam
Sorry my bad..try using following sample data and it does show that text are cut off (for the first two columns) You can use sample code in my last conversation except set the Maximum and minimum value on NumericyAxis scale as 55 and 5 respect.
High = 41,
Low = 19
High = 51,
Low = 14
High = 25,
High = 27,
High = 30,
High = 34,
Low = 24
Subhash,
I have created a case for this post. You may already have received an email notification of it. I will respond through the case, and when the issue is resolved I will post the solution here to make it public.
The problem is correctable with a slight modification to the code:
private Series watchingSeries = null; private void UpdateHandlers() { if (watchingChart != null) { watchingChart.WindowRectChanged -= watchingChart_WindowRectChanged; watchingChart.SizeChanged -= watchingChart_SizeChanged; watchingChart = null; } if (watchingSeries != null) { watchingSeries.SizeChanged -= watchingSeries_SizeChanged; watchingSeries = null; } if (Context.Series.Chart != null) { watchingChart = Context.Series.Chart; watchingChart.WindowRectChanged += watchingChart_WindowRectChanged; watchingSeries = Context.Series; watchingChart.SizeChanged += watchingChart_SizeChanged; watchingSeries.SizeChanged += watchingSeries_SizeChanged; } } void watchingSeries_SizeChanged(object sender, SizeChangedEventArgs e) { UpdateContent(); } void watchingChart_SizeChanged(object sender, SizeChangedEventArgs e) { UpdateContent(); }
Hope this helps!
Graham