private static void AddIntersectionPoint(RadCartesianChart chart, DataTemplate intersectionPointTemplate, CategoricalDataPoint dataPoint) { CartesianCustomAnnotation annotation = new CartesianCustomAnnotation(); annotation.ContentTemplate = intersectionPointTemplate; annotation.HorizontalValue = dataPoint.Category; annotation.VerticalValue = dataPoint.Value; annotation.Tag = typeof(ChartUtilities); chart.Annotations.Add(annotation); }
private CartesianCustomAnnotation CreateTick(ChartAxisCategoryInfo item, double verticalOffset = 0) { var tick = new CartesianCustomAnnotation(); tick.Content = CreateTickVisual(item.Category, verticalOffset); tick.VerticalValue = item.Category; tick.HorizontalValue = GetAxisCenter(); tick.HorizontalAlignment = HorizontalAlignment.Left; tick.VerticalAlignment = VerticalAlignment.Center; tick.Tag = "CustomAxisElement"; return(tick); }
private void DrawTorinoImpactLevelOne() { var origin = chart.ConvertDataToPoint(Tuple.Create <object, object>(1E-08, 10000)); var vertexA = chart.ConvertDataToPoint(Tuple.Create <object, object>(0.002, 20)); vertexA.X -= origin.X; vertexA.Y -= origin.Y; var vertexB = chart.ConvertDataToPoint(Tuple.Create <object, object>(0.01, 20)); vertexB.X -= origin.X; vertexB.Y -= origin.Y; var vertexC = chart.ConvertDataToPoint(Tuple.Create <object, object>(0.01, 100)); vertexC.X -= origin.X; vertexC.Y -= origin.Y; var vertexD = chart.ConvertDataToPoint(Tuple.Create <object, object>(1E-06, 10000)); vertexD.X -= origin.X; vertexD.Y -= origin.Y; var xamlString = @"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""> <Viewbox Stretch=""Fill""> <TextBlock Text=""This is custom annotation with ContentTemplate"" TextWrapping=""Wrap"" TextAlignment=""Center"" VerticalAlignment=""Center"" HorizontalAlignment=""Center"" /> <Path Fill=""#6400FF00""> <Path.Data> <PathGeometry> <PathFigure StartPoint=""0,0"">" + @"<LineSegment Point=""" + vertexA + @""" />" + @"<LineSegment Point=""" + vertexB + @""" />" + @"<LineSegment Point=""" + vertexC + @""" />" + @"<LineSegment Point=""" + vertexD + @""" />" + @"</PathFigure> </PathGeometry> </Path.Data> </Path> </Viewbox> </DataTemplate>"; var dataTemplate = XamlReader.Load(xamlString) as DataTemplate; var annotation = new CartesianCustomAnnotation() { HorizontalValue = 1E-08, VerticalValue = 10000, ContentTemplate = dataTemplate }; chart.Annotations.Add(annotation); }
private CartesianCustomAnnotation CreateTick(double value) { var tick = new CartesianCustomAnnotation(); tick.ClipToPlotArea = false; tick.Content = CreateTickVisual(value); tick.VerticalValue = value; tick.HorizontalValue = CustomAxisPositionKey; tick.HorizontalAlignment = HorizontalAlignment.Left; tick.VerticalAlignment = VerticalAlignment.Center; tick.Tag = CustomAxisElementKey; return(tick); }
private static void AddAnnotations(RadCartesianChart chart, object xCategory) { chart.Annotations.Add(new CartesianGridLineAnnotation { Axis = chart.HorizontalAxis, Value = xCategory, Tag = typeof(ChartUtilities) }); StackPanel dataPointsInfoPanel = new StackPanel(); foreach (CartesianSeries series in chart.Series) { CategoricalSeries categoricalSeries = series as CategoricalSeries; if (categoricalSeries == null) { continue; } var dataPoint = GetDataPoint(categoricalSeries.DataPoints, xCategory); if (dataPoint == null) { continue; } AddIntersectionPoint(chart, GetIntersectionPointTemplate(series), dataPoint); ContentPresenter cp = new ContentPresenter(); cp.ContentTemplate = GetDataPointTemplate(series); cp.Content = dataPoint; dataPointsInfoPanel.Children.Add(cp); } foreach (IndicatorBase indicator in chart.Indicators) { foreach (var dataPoint in GetDataPoints(indicator, xCategory)) { AddIntersectionPoint(chart, GetIntersectionPointTemplate(indicator), dataPoint); } } LinearAxis vAxis = (LinearAxis)chart.VerticalAxis; CartesianCustomAnnotation infoAnnotation = new CartesianCustomAnnotation(); infoAnnotation.Tag = typeof(ChartUtilities); infoAnnotation.HorizontalValue = xCategory; infoAnnotation.VerticalValue = vAxis.ActualRange.Maximum; infoAnnotation.Content = PrepareInfoContent(dataPointsInfoPanel); chart.Annotations.Add(infoAnnotation); }
private void UpdateChartAnnotation() { CartesianGridLineAnnotation myLineAnnotation = new CartesianGridLineAnnotation { Axis = Chart.HorizontalAxis, Value = ChartEventItems[ChartEventItems.Count - 1].EventStart, Stroke = new SolidColorBrush(Windows.UI.Colors.Red) }; Chart.Annotations.Add(myLineAnnotation); var newLabel = new CartesianCustomAnnotation { HorizontalAxis = horizontalAxis, VerticalAxis = verticalAxis }; var border = new Border { //Background = new SolidColorBrush(Windows.UI.Colors.Gray), VerticalAlignment = VerticalAlignment.Top, Opacity = 0.9 }; var content = new TextBlock { Text = ChartEventItems[ChartEventItems.Count - 1].EventDescription }; border.Child = content; newLabel.Content = border; newLabel.HorizontalValue = ChartEventItems[ChartEventItems.Count - 1].EventStart; newLabel.HorizontalAlignment = HorizontalAlignment.Left; newLabel.VerticalAlignment = VerticalAlignment.Top; newLabel.VerticalValue = 80d; // Position on Y axis newLabel.Tag = "label"; newLabel.Visibility = Visibility.Visible; newLabel.ClipToPlotArea = false; Chart.Annotations.Add(newLabel); }
private void DrawTorinoImpactLevelSix() { var origin = chart.ConvertDataToPoint(Tuple.Create <object, object>(0.0001, 10000)); var vertexA = chart.ConvertDataToPoint(Tuple.Create <object, object>(0.01, 1000)); vertexA.X -= origin.X; vertexA.Y -= origin.Y; var vertexB = chart.ConvertDataToPoint(Tuple.Create <object, object>(0.01, 10000)); vertexB.X -= origin.X; vertexB.Y -= origin.Y; var xamlString = @"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""> <Viewbox Stretch=""Fill""> <Path Fill=""#64FFA500""> <Path.Data> <PathGeometry> <PathFigure StartPoint=""0,0"">" + @"<LineSegment Point=""" + vertexA + @""" />" + @"<LineSegment Point=""" + vertexB + @""" />" + @"</PathFigure> </PathGeometry> </Path.Data> </Path> </Viewbox> </DataTemplate>"; var dataTemplate = XamlReader.Load(xamlString) as DataTemplate; var annotation = new CartesianCustomAnnotation() { HorizontalValue = 0.0001, VerticalValue = 10000, ContentTemplate = dataTemplate }; chart.Annotations.Add(annotation); }
/// <summary> /// Initializes a new instance of the CartesianCustomAnnotationAutomationPeer class. /// </summary> public CartesianCustomAnnotationAutomationPeer(CartesianCustomAnnotation owner) : base(owner) { }