Я пытаюсь создать xamDataChart с помощью StackedColumnSeries. В моем случае использования я должен иметь возможность создавать переменное количество StackedColumnSeries и StackedFragmentSeries, поэтому я создаю все в коде. StackedColumnSeries ItemsSource устанавливается в список словарей. Все работает отлично, если словари имеют десятичные значения. Но мне нужно, чтобы они имели значения объектов и извлекали окончательное значение из этого объекта. И я не могу понять, диаграмма просто показывает пустой, поэтому ValueMemberPath не должен работать правильно.Использование свойства объекта элемента элемента элемента в Infragistics StackedFragmentSeries
Вот пример кода, демонстрирующий проблему:
var window = new Window() { Width = 600, Height = 400, WindowStartupLocation = WindowStartupLocation.CenterScreen };
var chart = new XamDataChart();
Axis xAxis = new CategoryXAxis() { ItemsSource = new List<string> { "First", "Second" } };
Axis yAxis = new NumericYAxis() { MinimumValue = 0, MaximumValue = 1000 };
chart.Axes.Add(xAxis);
chart.Axes.Add(yAxis);
// Trying to fetch chart fragment values from value member's property: Does not work.
var testItems = new List<Dictionary<string, TestPoint>>();
var stackedSeries = new StackedColumnSeries() { ItemsSource = testItems, XAxis = xAxis as CategoryXAxis, YAxis = yAxis as NumericYAxis };
stackedSeries.Series.Add(new StackedFragmentSeries() { ValueMemberPath = "[Serie1].PointValue" });
stackedSeries.Series.Add(new StackedFragmentSeries() { ValueMemberPath = "[Serie2].PointValue" });
testItems.Add(new Dictionary<string, TestPoint>() { { "Serie1", new TestPoint(100) }, { "Serie2", new TestPoint(200) } });
testItems.Add(new Dictionary<string, TestPoint>() { { "Serie1", new TestPoint(300) }, { "Serie2", new TestPoint(400) } });
// Value member is decimal and using it directly, works fine.
//var testItems = new List<Dictionary<string, decimal>>();
//var stackedSeries = new StackedColumnSeries() { ItemsSource = testItems, XAxis = xAxis as CategoryXAxis, YAxis = yAxis as NumericYAxis };
//stackedSeries.Series.Add(new StackedFragmentSeries() { ValueMemberPath = "[Serie1]" });
//stackedSeries.Series.Add(new StackedFragmentSeries() { ValueMemberPath = "[Serie2]" });
//testItems.Add(new Dictionary<string, decimal>() { { "Serie1", 100 }, { "Serie2", 200 } });
//testItems.Add(new Dictionary<string, decimal>() { { "Serie1", 300 }, { "Serie2", 400 } });
chart.Series.Add(stackedSeries);
window.Content = chart;
window.ShowDialog();
Класс ТестПоинт используется в приведенном выше примере:
class TestPoint
{
public decimal PointValue { get; set; }
public TestPoint (decimal value)
{
PointValue = value;
}
}
Я использую Infragistics версии 14.2 (проблема не возникает на Infragistics 13.1).
Я пробовал оба ValueMemberPath = "[Serie1] .PointValue" и ValueMemberPath = "[Serie1] [PointValue]" и отлично работает для меня с Infragistics 16.1 –