3

開いているグラフライブラリでWPFを検索しているときに、DynamicDataDisplayライブラリを見つけました。

ただし、値に基づいて画像が含まれている軸ラベルをフォーマットする方法が見つかりませんでした(おそらくドキュメントが不十分なため)。

なぜこれが必要なのですか?

私は現在、ゲームの市場価格を追跡するツール(GW2)を作成しています。

これらの価格は金、銀、銅で表示され、銅の値に基づいて価格を取得します。縦軸に価格を表示したいと思います。

したがって、誰かがD3の軸ラベルをテンプレート化する方法を知っていることを願っています。

4

2 に答える 2

3

Mikhail Brinchuk が私を正しい方向に向けてくれてありがとう。これが私が思いついた解決策です:

<Window x:Class="ChartTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
    xmlns:chart="clr-namespace:ChartTest.Chart"
    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
    <chart:MoneyLabelProvider x:Key="MoneyLabelProvider"></chart:MoneyLabelProvider>
</Window.Resources>
<Grid>
    <d3:ChartPlotter x:Name="Plotter">
        <d3:ChartPlotter.VerticalAxis>
            <d3:VerticalIntegerAxis x:Name="Axis" LabelProvider="{StaticResource MoneyLabelProvider}">
            </d3:VerticalIntegerAxis>
         </d3:ChartPlotter.VerticalAxis>

        <d3:ChartPlotter.HorizontalAxis>
            <d3:HorizontalDateTimeAxis x:Name="DateTimeAxis">
            </d3:HorizontalDateTimeAxis>
        </d3:ChartPlotter.HorizontalAxis>
    </d3:ChartPlotter>
</Grid>

public class MoneyLabelProvider : GenericLabelProvider<int>
{
    public override System.Windows.UIElement[] CreateLabels(Microsoft.Research.DynamicDataDisplay.Charts.ITicksInfo<int> ticksInfo)
    {
        var customElements = new UIElement[ticksInfo.Ticks.Length];

        for (int i = 0; i < customElements.Length; i++)
        {
            var mv = new MoneyView(); // View provides the money style format
            var money = new Money(0, 0, ticksInfo.Ticks[i]); // Data class provides the calculation
            mv.DataContext = money; // Bind the data to the view

            customElements[i] = mv;
        }

        return customElements;
    }
}
于 2012-12-19T15:39:15.707 に答える
1

Axis には LabelProvider プロパティが含まれています。カスタム ラベル プロバイダーを作成し、オーバーライドされたメソッド CreateLabels で必要なすべてのコントロールを作成できます。

于 2012-12-19T14:23:33.380 に答える