
Ultimate UI for WPF では、DataAnnotationBandLayer は、1 ~ 6 軸の注釈が付いた自由形式の平行四辺形です。これは多くの構成プロパティを提供し、XamDataChart コンポーネントの財務シリーズで一般的に使用されます。
Ultimate UI for WPF では、DataAnnotationBandLayer は、XamDataChart コンポーネントのプロット領域内の 2 つのポイント間に複数の傾斜した四角形を描画します。このデータ注釈レイヤーは、株価の上昇と下落の範囲を注釈するために使用できます。すべてのシリーズと同様に、DataAnnotationBandLayer も ItemsSource プロパティによるデータ バインディングをサポートしています。このプロパティには、線の開始ポイントと終了ポイントの x/y 座標を表す、少なくとも 4 つの数値データ列を持つデータ項目のコレクションを設定します。開始ポイントは StartValueXMemberPath および StartValueYMemberPath プロパティを使用してマップする必要があり、終了ポイントは EndValueXMemberPath および EndValueYMemberPath プロパティを使用してマップする必要があります。
たとえば、DataAnnotationBandLayer を使用して株価の成長範囲に注釈を付けることができます。
次のコード スニペットは、上の図に示すように、DataAnnotationBandLayer を描画する方法を示しています。また、この例では、プロット内にカスタム オーバーレイ テキストを描画する方法を示します。詳細については、チャート オーバーレイ テキスト トピックを参照してください。
XAML の場合:
<ig:DataAnnotationBandLayer/>
C# の場合:
var xAxisBottom = new CategoryXAxis
{
Label = "Index",
DataSource = data,
TickLength = 0,
LabelLocation = AxisLabelsLocation.OutsideBottom,
LabelFontSize = 12,
LabelMargin = new Padding(0, 15, 0, 5),
LabelExtent = 120,
LabelAngle = 90,
LabelTextColor = Color.Transparent,
};
chart.Axes.Add(xAxisBottom);
chart.Series.Add(CreateStockRapidGrowth(xAxisBottom));
public static Series CreateStockRapidGrowth(Axis targetAxis)
{
var annoLayer = new DataAnnotationBandLayer();
annoLayer.StartValueXMemberPath = "StartX";
annoLayer.StartValueYMemberPath = "StartY";
annoLayer.EndValueXMemberPath = "EndX";
annoLayer.EndValueYMemberPath = "EndY";
annoLayer.AnnotationBreadthMemberPath = "Value";
annoLayer.TargetAxis = targetAxis;
annoLayer.DataSource = new List<Annotation>
{
new Annotation() {
StartLabel = "Growth Start",
EndLabel = "Growth Stop",
StartX = 48, StartY = 110,
EndX = 105, EndY = 335,
Value = 170,
Label = "Rapid Growth" },
};
// setting optional annotation properties
annoLayer.Brush = Brushes.Purple;
annoLayer.Outline = Brushes.Purple;
annoLayer.StartLabelXMemberPath = "StartLabel";
annoLayer.StartLabelXDisplayMode = DataAnnotationDisplayMode.DataLabel;
annoLayer.EndLabelXMemberPath = "EndLabel";
annoLayer.EndLabelXDisplayMode = DataAnnotationDisplayMode.DataLabel;
annoLayer.CenterLabelXDisplayMode = DataAnnotationDisplayMode.Hidden;
// setting optional overlay text properties
annoLayer.OverlayTextColor = Brushes.Purple;
annoLayer.OverlayTextVerticalMargin = 20;
annoLayer.OverlayTextHorizontalMargin = -50;
annoLayer.OverlayTextLocation = OverlayTextLocation.InsideTopCenter;
annoLayer.OverlayTextMemberPath = "Label";
return annoLayer;
}
次のコード例は、軸注釈の背景、境界線の色、境界線の太さなどのスタイル プロパティをオーバーレイ テキストのスタイル プロパティとして設定して、DataAnnotationBandLayer をカスタマイズする方法を示しています。
C# の場合:
chart.Series.Add(StylingDataAnnotationBandLayer(xAxisBottom));
public Series StylingDataAnnotationBandLayer(Axis targetAxis)
{
var annoLayer = new DataAnnotationBandLayer();
// 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;
}
次の表は、DataAnnotationBandLayer の最も重要なプロパティとその説明を示しています。