Since we are in process of evaluation and till now we have been pretty pleased with Infragistics.
One of the serious requirement we have is have a column range chart whereas each column is rendered over a range(just the two values, high and low)
Also can we have the same chart along with line chart on same chart area?
thanks
-S
Here, this should give you a start on how you might accomplish this:
<Window.Resources> <local:TestData x:Key="data" /> <DataTemplate x:Key="hiloMarker"> <local:HiLowMarker Context="{Binding}" HighMemberPath="High" LowMemberPath="Low"/> </DataTemplate> </Window.Resources> <Grid x:Name="LayoutRoot" Background="White"> <igChart:XamDataChart x:Name="theChart" VerticalZoomable="True" HorizontalZoomable="True"> <igChart:XamDataChart.Axes> <igChart:NumericYAxis x:Name="yAxis" MinimumValue="0" MaximumValue="8" /> <igChart:CategoryXAxis x:Name="xAxis" ItemsSource="{StaticResource data}" Label="{}{Label}"/> </igChart:XamDataChart.Axes> <igChart:XamDataChart.Series> <igChart:RangeColumnSeries x:Name="series" MarkerType="Circle" MarkerTemplate="{StaticResource hiloMarker}" ItemsSource="{StaticResource data}" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" LowMemberPath="Low" HighMemberPath="High" > <igChart:RangeColumnSeries.ToolTip> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <TextBlock Text="High:" /> <TextBlock Text="{Binding Item.High}" Grid.Column="1" /> <TextBlock Text="Low:" Grid.Row="1"/> <TextBlock Text="{Binding Item.Low}" Grid.Row="1" Grid.Column="1" /> </Grid> </igChart:RangeColumnSeries.ToolTip> </igChart:RangeColumnSeries> </igChart:XamDataChart.Series> </igChart:XamDataChart>
And code behind:
public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } } public class TestData : ObservableCollection<TestDataItem> { public TestData() { Add(new TestDataItem() { Label = "A", Low = 1, High = 3 }); Add(new TestDataItem() { Label = "B", Low = 2, High = 3 }); Add(new TestDataItem() { Label = "C", Low = 1, High = 3 }); Add(new TestDataItem() { Label = "D", Low = 2, High = 4 }); } } public class TestDataItem { public string Label { get; set; } public double Low { get; set; } public double High { get; set; } } public class HiLowMarker : ContentControl { public static readonly DependencyProperty ContextProperty = DependencyProperty.Register("Context", typeof(DataContext), typeof(HiLowMarker), new PropertyMetadata(null, (o, e) => (o as HiLowMarker) .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(HiLowMarker), new PropertyMetadata(0.0, (o, e) => (o as HiLowMarker) .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", typeof(double), typeof(HiLowMarker), new PropertyMetadata(0.0, (o, e) => (o as HiLowMarker) .OnLowChanged((double)e.OldValue, (double)e.NewValue))); private void OnLowChanged(double oldValue, double newValue) { UpdateContent(); } public double Low { get { return (double)GetValue(LowProperty); } set { SetValue(LowProperty, value); } } public static readonly DependencyProperty LowMemberPathProperty = DependencyProperty.Register("LowMemberPath", typeof(string), typeof(HiLowMarker), new PropertyMetadata(null, (o, e) => (o as HiLowMarker) .OnLowMemberPathChanged((string)e.OldValue, (string)e.NewValue))); private void OnLowMemberPathChanged(string oldValue, string newValue) { UpdateContent(); } public string LowMemberPath { get { return (string)GetValue(LowMemberPathProperty); } set { SetValue(LowMemberPathProperty, value); } } public static readonly DependencyProperty HighMemberPathProperty = DependencyProperty.Register("HighMemberPath", typeof(string), typeof(HiLowMarker), new PropertyMetadata(null, (o, e) => (o as HiLowMarker) .OnHighMemberPathChanged((string)e.OldValue, (string)e.NewValue))); private void OnHighMemberPathChanged(string oldValue, string newValue) { UpdateContent(); } public string HighMemberPath { get { return (string)GetValue(HighMemberPathProperty); } set { SetValue(HighMemberPathProperty, value); } } public static readonly DependencyProperty ItemProperty = DependencyProperty.Register("Item", typeof(object), typeof(HiLowMarker), new PropertyMetadata(null, (o, e) => (o as HiLowMarker) .OnItemChanged((object)e.OldValue, (object)e.NewValue))); private void OnItemChanged(object oldValue, object newValue) { UpdateContent(); } 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) { Source = this }); SetBinding(LowProperty, new Binding("Context.Item." + LowMemberPath) { Source = this }); 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(), RenderTransform = new TranslateTransform() { 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) { UpdateContent(); } void watchingChart_WindowRectChanged(object sender, Infragistics.RectChangedEventArgs e) { UpdateContent(); } private bool Valid() { if (HighMemberPath == null) { return false; } if (LowMemberPath == null) { return false; } if (Context == null) { return false; } if (Context.Series == null) { return false; } if (Context.Series as RangeCategorySeries == null) { return false; } if ((Context.Series as RangeCategorySeries).YAxis == null) { return false; } return true; } private void OnContextChanged(object oldValue, object newValue) { ClearContent(); UpdateContent(); } private void ClearContent() { Content = null; } }
Hope this helps!-Graham
I would also recommend making a feature request for the label display next to the columns, as any solution I provide will likely be more complicated than it would be if it were a native feature of the chart.
-Graham
I'll see if I can give you some sort of assistance in this regard.
It wouldn't be sufficient to display them in a tooltip? They should be persistent next to the columns?
I really can't find a way to display these text labels. This is very important for us from end user perspective. Any help would be highly appreciated
I got it working for most of the part, except displaying the text for highs and lows, you did mention tooltip, but I am not sure if I understood that, can you provide a sample..thanks