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