0

StackedColumnSeries で xamDataChart を作成しようとしています。私の使用例では、可変数の StackedColumnSeries と StackedFragmentSeries を作成できるようにする必要があるため、すべてをコード ビハインドで作成しています。StackedColumnSeries ItemsSource は辞書のリストに設定されます。辞書に 10 進数値がある場合は、すべて正常に機能します。しかし、オブジェクトの値を持ち、そのオブジェクトから最終的な値をフェッチする必要があります。そして、私はそれを正しく理解できません。チャートは空を表示するだけなので、ValueMemberPath が正しく機能していないはずです。

問題を示すコード例を次に示します。

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();

上記の例で使用されている TestPoint クラス:

class TestPoint
{
    public decimal PointValue { get; set; }

    public TestPoint (decimal value)
    {
        PointValue = value;
    }
}

Infragistics バージョン 14.2 を使用しています (問題は Infragistics 13.1 では発生しませんでした)。

4

1 に答える 1

0

ValueMemberPath を からValueMemberPath = "[Serie1].PointValue"に変更することで機能しましたValueMemberPath = "[Serie1][PointValue]"

于 2015-03-23T08:09:36.367 に答える