バージョン 25.1 (最新)

チャート データ注釈矩形レイヤー (ベータ版)

Ultimate UI for WPF では、DataAnnotationRectLayer は、XamDataChart コンポーネントのプロット領域内の開始ポイントと終了ポイントによって定義された複数の四角形をを描画します。このデータ注釈レイヤーは、株価の弱気パターンなどのプロットエリアの領域に注釈を付けることに使用できます。すべてのシリーズと同様に、DataAnnotationRectLayer も ItemsSource プロパティによるデータ バインディングをサポートしています。このプロパティは、矩形の開始ポイントと終了ポイントの x/y 座標を表す、少なくとも 4 つの数値データ列を持つデータ項目のコレクションを設定する必要があります。開始ポイントは StartValueXMemberPath および StartValueYMemberPath プロパティを使用してマップする必要があり、終了ポイントは EndValueXMemberPath および EndValueYMemberPath プロパティを使用してマップする必要があります。

たとえば、DataAnnotationRectLayer を使用して、株価の弱気パターンとギャップを Y 軸に注釈付けできます。

DataAnnotationRectLayer.png

矩形注釈の描画

次のコード スニペットは、図に示すように、この注釈と、DataAnnotationRectLayer の上に提供されるプロパティを示しています。

XAML の場合:

<ig:DataAnnotationRectLayer
StartValueXMemberPath="StartX"
StartValueYMemberPath="StartY"
EndValueXMemberPath="EndX"
EndValueYMemberPath="EndY"
ItemsSource="{Binding}" />

C# の場合:

var xAxis = new CategoryXAxis
{
    Label = "Date",
    DataSource = data,
    LabelMargin = new Padding(0, 10, 0, 10),
};
chart.Axes.Add(xAxis);

chart.Series.Add(CreateStockBearishPatterns(xAxis));

public static Series CreateStockBearishPatterns(Axis targetAxis)
{
    var annoLayer = new DataAnnotationRectLayer();
    annoLayer.StartValueXMemberPath = "StartX";
    annoLayer.StartValueYMemberPath = "StartY";
    annoLayer.EndValueXMemberPath = "EndX";
    annoLayer.EndValueYMemberPath = "EndY";
    annoLayer.TargetAxis = targetAxis;
    annoLayer.DataSource = new List<Annotation>
    {
        new Annotation() {
            StartX = 85, StartY = 190,
            EndX = 140, EndY = 415,
            Label = "Head & Shoulders Pattern \n  (Bearish Downtrend)" },

        new Annotation() {
            StartX = 53, StartY = 75,
            EndX = 230, EndY = 80,
            Label = "Price Gap (Bearish Target)" },
    };

    // setting optional annotation properties
    annoLayer.Brush = Brushes.Purple;
    annoLayer.Outline = Brushes.Purple;
    annoLayer.AreaFillOpacity = 0.1;
    annoLayer.StartLabelXDisplayMode = DataAnnotationDisplayMode.Hidden;
    annoLayer.StartLabelYDisplayMode = DataAnnotationDisplayMode.Hidden;
    annoLayer.EndLabelXDisplayMode = DataAnnotationDisplayMode.Hidden;
    annoLayer.EndLabelYDisplayMode = DataAnnotationDisplayMode.Hidden;
    annoLayer.CenterLabelXDisplayMode = DataAnnotationDisplayMode.Hidden;

    // setting optional overlay text properties
    annoLayer.OverlayTextLocation = OverlayTextLocation.OutsideBottomCenter;
    annoLayer.OverlayTextColor = Brushes.Purple;
    annoLayer.OverlayTextMemberPath = "Label";

    return annoLayer;
}

データ矩形注釈のスタイル設定

次のコード例は、軸注釈の背景、境界線の色、境界線の太さなどのスタイル プロパティをオーバーレイ テキストのスタイル プロパティとして設定して、DataAnnotationRectLayer をカスタマイズする方法を示しています。

C# の場合:

chart.Series.Add(StylingDataAnnotationRectLayer(xAxisBottom));

public Series StylingDataAnnotationRectLayer(Axis targetAxis)
{
    var annoLayer = new DataAnnotationRectLayer();
    // NOTE see setup properties in the first examples

    // styling the starting point of annotation
    annoLayer.StartLabelDisplayMode = DataAnnotationDisplayMode.AxisValue;
    annoLayer.StartLabelTextColor = Brushes.White;
    annoLayer.StartLabelBackground = Brushes.Orange;
    annoLayer.StartLabelBorderColor = Brushes.Black;
    annoLayer.StartLabelBorderThickness = 1;
    annoLayer.StartLabelBorderRadius = 4;
    annoLayer.StartLabelPadding = new Thickness(4);

    // styling the ending point of annotation
    annoLayer.EndLabelDisplayMode = DataAnnotationDisplayMode.AxisValue;
    annoLayer.EndLabelTextColor = Brushes.White;
    annoLayer.EndLabelBackground = Brushes.Red;
    annoLayer.EndLabelBorderColor = Brushes.Black;
    annoLayer.EndLabelBorderThickness = 1;
    annoLayer.EndLabelBorderRadius = 4;
    annoLayer.EndLabelPadding = new Thickness(4);

    // styling optional label at center of annotations
    annoLayer.CenterLabelDisplayMode = DataAnnotationDisplayMode.AxisValue;
    annoLayer.CenterTextColor = Brushes.White;
    annoLayer.CenterBackground = Brushes.Green;
    annoLayer.CenterBorderColor = Brushes.Black;
    annoLayer.CenterBorderThickness = 1;
    annoLayer.CenterBorderRadius = 4;
    annoLayer.CenterPadding = new Thickness(4);

    // styling optional overlay text
    annoLayer.OverlayTextColor = Brushes.White;
    annoLayer.OverlayTextBackground = Brushes.Green;
    annoLayer.OverlayTextBorderColor = Brushes.Black;
    annoLayer.OverlayTextBorderThickness = 1;
    annoLayer.OverlayTextBorderRadius = 4;
    annoLayer.OverlayTextHorizontalMargin = 5;
    annoLayer.OverlayTextHorizontalPadding = 2;
    annoLayer.OverlayTextVerticalMargin = 5;
    annoLayer.OverlayTextVerticalPadding = 2;
    return annoLayer;
}

API リファレンス

次の表は、DataAnnotationRectLayer の最も重要なプロパティとその説明を示しています。

プロパティ名 プロパティ タイプ 説明

Axis

このプロパティは、オーバーレイ テキストの配置位置を管理します。

IEnumerable

このプロパティは、データを注釈レイヤーにバインドして正確な形状を提供します。

string

このプロパティは、注釈の開始位置となる x 座標を含むデータ列の列名にマッピングします。

string

このプロパティは、注釈の開始位置となる y 座標を含むデータ列の列名にマッピングします。

string

このプロパティは、注釈の終了位置となる x 座標を含むデータ列にマッピングします。

string

このプロパティは、注釈の終了位置となる y 座標を含むデータ列にマッピングします。

string

このプロパティは、軸に沿った xAxis の開始位置のオーバーレイ ラベルを表すデータ列へのマッピングです。

string

このプロパティは、軸に沿った yAxis の開始位置のオーバーレイ ラベルを表すデータ列へのマッピングです。

string

このプロパティは、軸に沿った xAxis の終了位置のオーバーレイ ラベルを表すデータ列へのマッピングです。

string

このプロパティは、軸に沿った yAxis の終了位置のオーバーレイ ラベルを表すデータ列へのマッピングです。

DataAnnotationDisplayMode

設定可能で、xAxis または yAxis に沿って表示される開始、終了、または中央のラベルのテキストを管理します。例: 'DataLabel' の場合、ラベルは LabelMemberPath を介してマッピングされた値を表示し、'AxisValue' の場合、データ値はシリーズに沿った特定のポイントから表示されます。

string

このプロパティは、注釈の横にオーバーレイ テキストとして表示されるデータ列の名前へのマッピングです。

string

このプロパティは、オーバーレイ テキストの配置位置を管理します。