public override void Initialize() { base.Initialize(); // Create title label NLabel title = new NLabel("Pie Data Point Anchor"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // Create a pie chart NPieChart chart = new NPieChart(); chart.Enable3D = false; // Create a pie series with 6 data points NPieSeries pieSeries = new NPieSeries(); chart.Series.Add(pieSeries); pieSeries.DataLabelStyle.Visible = true; pieSeries.LabelMode = PieLabelMode.SpiderNoOverlap; GenerateData(pieSeries); // Create a rounded rect callout NRoundedRectangularCallout callout = new NRoundedRectangularCallout(); callout.ArrowLength = new NLength(20, NGraphicsUnit.Point); callout.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightGreen)); callout.UseAutomaticSize = true; callout.Orientation = 80; callout.ContentAlignment = ContentAlignment.TopLeft; callout.Text = "Annotation"; callout.TextStyle.FontStyle.EmSize = new NLength(8); // Anchor the callout to pie data point #0 NPieDataPointAnchor anchor = new NPieDataPointAnchor(pieSeries, 0, 0.8f, StringAlignment.Near); callout.Anchor = anchor; // add title and chart panels ConfigureStandardLayout(chart, title, null); // add the annotation panel nChartControl1.Panels.Add(callout); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); // init form controla DataPointIndexUpDown.Value = anchor.DataPointIndex; AnchorPositionUpDown.Value = (decimal)anchor.RadialPosition; }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // Create title label NLabel title = new NLabel("Pie Data Point Anchor"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; nChartControl1.Panels.Add(title); // Create a pie chart NPieChart chart = new NPieChart(); nChartControl1.Panels.Add(chart); chart.Enable3D = false; // Create a pie series with 6 data points NPieSeries pieSeries = new NPieSeries(); chart.Series.Add(pieSeries); pieSeries.DataLabelStyle.Visible = true; pieSeries.LabelMode = PieLabelMode.SpiderNoOverlap; pieSeries.Values.FillRandomRange(new Random(), 6, 1, 5); // Create a rounded rect callout NRoundedRectangularCallout callout = new NRoundedRectangularCallout(); callout.ArrowLength = new NLength(20, NGraphicsUnit.Point); callout.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightGreen)); callout.UseAutomaticSize = true; callout.Orientation = 80; callout.ContentAlignment = ContentAlignment.TopLeft; callout.Text = "Annotation"; callout.TextStyle.FontStyle.EmSize = new NLength(8); // Anchor the callout to pie data point #0 NPieDataPointAnchor anchor = new NPieDataPointAnchor(pieSeries, 0, 0.8f, StringAlignment.Near); callout.Anchor = anchor; // add the annotation panel nChartControl1.Panels.Add(callout); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.BrightMultiColor); styleSheet.Apply(nChartControl1.Document); }
private void AnchorPositionUpDown_ValueChanged(object sender, EventArgs e) { if (nChartControl1 == null) { return; } NRoundedRectangularCallout callout = nChartControl1.Panels[2] as NRoundedRectangularCallout; if (callout == null) { return; } NPieDataPointAnchor anchor = callout.Anchor as NPieDataPointAnchor; if (anchor == null) { return; } anchor.RadialPosition = (float)AnchorPositionUpDown.Value; nChartControl1.Refresh(); }
private void DataPointIndexUpDown_ValueChanged(object sender, EventArgs e) { if (nChartControl1 == null) { return; } NRoundedRectangularCallout callout = nChartControl1.Panels[2] as NRoundedRectangularCallout; if (callout == null) { return; } NPieDataPointAnchor anchor = callout.Anchor as NPieDataPointAnchor; if (anchor == null) { return; } anchor.DataPointIndex = (int)DataPointIndexUpDown.Value; nChartControl1.Refresh(); }