public void Page_Draw_PieSlices() { var app = this.GetVisioApplication(); var doc = this.GetNewDoc(); var page = app.ActivePage; int n = 36; double start_angle = 0.0; double radius = 1.0; double cx = 0.0; double cy = 2.0; double angle_step = Math.PI * 2.0 / (n - 1); foreach (double end_angle in Enumerable.Range(0, n).Select(i => i * angle_step)) { var center = new VA.Drawing.Point(cx, cy); var ps = new VACHART.PieSlice(center, radius, start_angle, end_angle); ps.Render(page); cx += 2.5; } var bordersize = new VA.Drawing.Size(1, 1); page.ResizeToFitContents(bordersize); doc.Close(true); }
public static List <PieSlice> GetSlicesFromValues(Drawing.Point center, double inner_radius, double outer_radius, IList <double> values) { var slices = PieSlice.GetSlicesFromValues(center, outer_radius, values); foreach (var slice in slices) { slice.InnerRadius = inner_radius; } return(slices); }
public void Render(IVisio.Page page) { var values = this.DataPoints.Select(p => p.Value).ToList(); var shapes = new List <IVisio.Shape>(values.Count); if (this.InnerRadius <= 0) { var slices = PieSlice.GetSlicesFromValues(this.Center, this.Radius, values); foreach (var slice in slices) { var rendered_shape = slice.Render(page); shapes.Add(rendered_shape); } } else { var slices = PieSlice.GetSlicesFromValues(this.Center, this.InnerRadius, this.Radius, values); foreach (var slice in slices) { var rendered_shape = slice.Render(page); shapes.Add(rendered_shape); } } for (int i = 0; i < this.DataPoints.Count; i++) { var dp = this.DataPoints[i]; var shape = shapes[i]; dp.VisioShape = shape; if (dp.Label != null) { if (dp.LabelFormat != null) { string formatted_label = string.Format(dp.Label, dp.Label); dp.VisioShape.Text = formatted_label; } else { dp.VisioShape.Text = dp.Label; } } } var allshapes = this.DataPoints.Select(dp => dp.VisioShape).Where(s => s != null).ToList(); ChartUtil.GroupShapesIfNeeded(page, allshapes); }
public IVisio.Shape PieSlice(VA.Drawing.Point center, double radius, double start_angle, double end_angle) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var application = this.Client.VisioApplication; using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication, "Draw Pie Slice")) { var active_page = application.ActivePage; var slice = new VA.Models.Charting.PieSlice(center, radius, start_angle, end_angle); var shape = slice.Render(active_page); return(shape); } }
public static List <PieSlice> GetSlicesFromValues(Drawing.Point center, double radius, IList <double> values) { double sectors_sum = values.Sum(); var slices = new List <PieSlice>(values.Count); double start_angle = 0; foreach (int i in Enumerable.Range(0, values.Count)) { double cur_val = values[i]; double cur_val_norm = cur_val / sectors_sum; double cur_angle = cur_val_norm * System.Math.PI * 2.0; double end_angle = start_angle + cur_angle; var ps = new PieSlice(center, radius, start_angle, end_angle); slices.Add(ps); start_angle += cur_angle; } return(slices); }
public IVisio.Shape PieSlice(VA.Drawing.Point center, double radius, double start_angle, double end_angle) { this.AssertApplicationAvailable(); this.AssertDocumentAvailable(); var application = this.Client.VisioApplication; using (var undoscope = new VA.Application.UndoScope(this.Client.VisioApplication, "Draw Pie Slice")) { var active_page = application.ActivePage; var slice = new VA.Models.Charting.PieSlice(center, radius, start_angle, end_angle); var shape = slice.Render(active_page); return shape; } }
public static List<PieSlice> GetSlicesFromValues(Drawing.Point center, double radius, IList<double> values) { double sectors_sum = values.Sum(); var slices = new List<PieSlice>(values.Count); double start_angle = 0; foreach (int i in Enumerable.Range(0, values.Count)) { double cur_val = values[i]; double cur_val_norm = cur_val / sectors_sum; double cur_angle = cur_val_norm * System.Math.PI * 2.0; double end_angle = start_angle + cur_angle; var ps = new PieSlice(center,radius,start_angle, end_angle); slices.Add(ps); start_angle += cur_angle; } return slices; }