private void InitChart() { var ls = new List <Point>(); Random r = new Random(); for (int i = 0; i < 100; i++) { ls.Add(new Point(i, r.Next(0, 1000))); } flexChart1.ItemsSource = ls; flexChart1.ChartType = C1.Chart.ChartType.Scatter; flexChart1.ToolTip.Visibility = Visibility.Collapsed; flexChart1.Series.Clear(); flexChart1.Series.Add(new C1.Xaml.Chart.Series { Binding = "Y", BindingX = "X" }); #region Annotations Setup al = new EditableAnnotationLayer(flexChart1); al.Annotations.Add(new C1.Xaml.Chart.Annotation.Text { Attachment = AnnotationAttachment.Relative, Content = "Text Annotation", Location = new Point(0.55, 0.15), Style = new ChartStyle() { FontSize = 12, Stroke = new SolidColorBrush(Colors.Black) } }); al.Annotations.Add(new C1.Xaml.Chart.Annotation.Rectangle { Attachment = AnnotationAttachment.Absolute, Content = "Absolute", Location = new Point(100, 150), Width = 100, Height = 50, Style = new ChartStyle() { Fill = new SolidColorBrush(Colors.Red) } }); al.Annotations.Add(new C1.Xaml.Chart.Annotation.Ellipse { Attachment = AnnotationAttachment.Relative, Location = new Point(0.5f, 0.35f), Content = "Relative", Width = 100, Height = 50, Style = new ChartStyle() { Fill = new SolidColorBrush(Colors.Red) } }); al.Annotations.Add(new C1.Xaml.Chart.Annotation.Square { Attachment = AnnotationAttachment.DataCoordinate, Content = "DataCoordinate", Length = 120, Location = new Point(20, 200), Style = new ChartStyle() { Fill = new SolidColorBrush(Colors.Red) } }); al.Annotations.Add(new C1.Xaml.Chart.Annotation.Polygon("Polygon") { Attachment = AnnotationAttachment.Absolute, Points = { new Point(300, 25), new Point(250, 70), new Point(275, 115), new Point(325, 115), new Point(350, 70) }, Style = new ChartStyle() { Fill = new SolidColorBrush(Colors.Red) } }); al.Annotations.Add(new C1.Xaml.Chart.Annotation.Line { Attachment = AnnotationAttachment.Relative, Content = "Horizontal Line", Start = new Point(0, 0.5f), End = new Point(1.2f, 0.5f), Style = new ChartStyle() { Fill = new SolidColorBrush(Colors.Red) } }); al.Annotations.Add(new C1.Xaml.Chart.Annotation.Line { Attachment = AnnotationAttachment.Relative, Content = "Vertical Line", Start = new Point(0.7f, 0), End = new Point(0.7f, 1.2f), Style = new ChartStyle() { Fill = new SolidColorBrush(Colors.Red) } }); al.Annotations.Add(new C1.Xaml.Chart.Annotation.Line { Attachment = AnnotationAttachment.Absolute, Content = "Slanted Line", Start = new Point(100, 70), End = new Point(200, 170), Style = new ChartStyle() { Fill = new SolidColorBrush(Colors.Red) } }); al.PolygonAddFunc = (pt) => { return(new C1.Xaml.Chart.Annotation.Polygon(string.Empty) { Points = { pt, pt, pt } }); }; flexChart1.Layers.Add(al); al.PolygonReSizeFunc = (poly, rectangle) => { var top = new Point((float)(rectangle.Left + rectangle.Width / 2), rectangle.Y); var left = new Point(rectangle.Left, rectangle.Bottom); var right = new Point(rectangle.Right, rectangle.Bottom); poly.Points[0] = Helpers.CoordsToAnnoPoint(flexChart1, poly, top); poly.Points[1] = Helpers.CoordsToAnnoPoint(flexChart1, poly, left); poly.Points[2] = Helpers.CoordsToAnnoPoint(flexChart1, poly, right); }; al.ContentEditor = new AnnotationEditor(); #endregion flexChart1.Rendered += FlexChart1_Rendered; flexChart1.PointerPressed += FlexChart1_PointerPressed; Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown; }
private void SetupChart() { var ls = new List <Point>(); Random r = new Random(); for (int i = 0; i < 100; i++) { ls.Add(new Point(i, r.Next(0, 1000))); } flexChart1.DataSource = ls; flexChart1.ChartType = C1.Chart.ChartType.Scatter; flexChart1.ToolTip.Active = false; flexChart1.Series.Clear(); flexChart1.Series.Add(new C1.Win.Chart.Series { Binding = "Y", BindingX = "X" }); #region Annotations Setup al = new EditableAnnotationLayer(flexChart1); al.Annotations.Add(new C1Anno.Text { Attachment = AnnotationAttachment.Relative, Content = "Text Annotation", Location = new PointF(0.5f, 0.2f) }); al.Annotations.Add(new C1Anno.Rectangle { Attachment = AnnotationAttachment.Absolute, Content = "Absolute", Location = new PointF(100, 150), Width = 100, Height = 50 }); al.Annotations.Add(new C1Anno.Ellipse { Attachment = AnnotationAttachment.Relative, Location = new PointF(0.5f, 0.35f), Content = "Relative", Width = 100, Height = 50 }); al.Annotations.Add(new C1Anno.Square { Attachment = AnnotationAttachment.DataCoordinate, Content = "DataCoordinate", Length = 100, Location = new PointF(20, 200) }); al.Annotations.Add(new C1Anno.Polygon("Polygon") { Attachment = AnnotationAttachment.Absolute, Points = { new PointF(200, 25), new PointF(150, 70), new PointF(175, 115), new PointF(225, 115), new PointF(250, 70) }, }); al.Annotations.Add(new C1Anno.Line { Attachment = AnnotationAttachment.Relative, Content = "Horizontal Line", Start = new PointF(0, 0.5f), End = new PointF(1.2f, 0.5f), }); al.Annotations.Add(new C1Anno.Line { Attachment = AnnotationAttachment.Relative, Content = "Vertical Line", Start = new PointF(0.7f, 0), End = new PointF(0.7f, 1.2f), }); al.Annotations.Add(new C1Anno.Line { Attachment = AnnotationAttachment.Absolute, Content = "Slanted Line", Start = new PointF(100, 70), End = new PointF(200, 170), }); al.PolygonAddFunc = (pt) => { return(new C1Anno.Polygon(string.Empty) { Points = { pt, pt, pt } }); }; al.PolygonResizeFunc = (poly, rectangle) => { var top = new PointF((float)(rectangle.Left + rectangle.Width / 2), rectangle.Y); var left = new PointF(rectangle.Left, rectangle.Bottom); var right = new PointF(rectangle.Right, rectangle.Bottom); poly.Points[0] = Helpers.CoordsToAnnoPoint(flexChart1, poly, top); poly.Points[1] = Helpers.CoordsToAnnoPoint(flexChart1, poly, left); poly.Points[2] = Helpers.CoordsToAnnoPoint(flexChart1, poly, right); }; al.ContentEditor = new AnnotationEditor(); #endregion flexChart1.Rendered += OnChartRendered; flexChart1.MouseDown += OnMouseDown; flexChart1.KeyDown += OnKeyDown; }