private void ProcessMouseEvent(object sender, EventArgs e, Color c) { NHitTestResult result = nChartControl1.HitTest(e as NCallbackMouseEventArgs); if (result.ChartElement == ChartElement.DataPoint) { switch (result.Chart.Tag.ToString()) { case "BarChart": NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron); Color highlightColor = palette.SeriesColors[5]; NBarSeries barSeries = result.Series as NBarSeries; foreach (NBarSeries series in nChartControl1.Charts[0].Series) { series.FillStyles.Clear(); series.BorderStyles.Clear(); } barSeries.FillStyles[result.DataPointIndex] = new NColorFillStyle(c); barSeries.BorderStyles[result.DataPointIndex] = new NStrokeStyle(1, c); int nCount = nChartControl1.Panels.Count; for (int i = 0; i < nCount; i++) { if (nChartControl1.Panels[i] is NRoundedRectangularCallout) { nChartControl1.Panels.RemoveAt(i); } } NRoundedRectangularCallout m_RoundedRectangularCallout = new NRoundedRectangularCallout(); m_RoundedRectangularCallout.ArrowLength = new NLength(10, NRelativeUnit.ParentPercentage); m_RoundedRectangularCallout.FillStyle = new NGradientFillStyle(Color.FromArgb(255, Color.White), Color.FromArgb(125, highlightColor)); m_RoundedRectangularCallout.UseAutomaticSize = true; m_RoundedRectangularCallout.Orientation = 45; m_RoundedRectangularCallout.Anchor = new NDataPointAnchor(barSeries, result.DataPointIndex, ContentAlignment.TopRight, StringAlignment.Center); m_RoundedRectangularCallout.Text = ((NDataPoint)result.Object)[DataPointValue.Y].ToString(); nChartControl1.Panels.Add(m_RoundedRectangularCallout); break; case "PieChart": NPieSeries pieSeries = result.Series as NPieSeries; pieSeries.Detachments.Clear(); for (int i = 0; i < pieSeries.Values.Count; i++) { if (i == result.DataPointIndex) { pieSeries.Detachments.Add(15); } else { pieSeries.Detachments.Add(0); } } break; } } }
private void ConfigureAnnotations() { m_RectangularCallout = new NRectangularCallout(); m_RectangularCallout.ArrowLength = new NLength(15, NRelativeUnit.ParentPercentage); m_RectangularCallout.FillStyle = new NGradientFillStyle(Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.CadetBlue)); m_RectangularCallout.UseAutomaticSize = true; m_RectangularCallout.Orientation = 225; m_RectangularCallout.Anchor = new NDataPointAnchor(m_Bar, 2, ContentAlignment.MiddleCenter, StringAlignment.Center); m_RectangularCallout.Text = GetTextForAnnotation(m_RectangularCallout); nChartControl1.Panels.Add(m_RectangularCallout); m_RoundedRectangularCallout = new NRoundedRectangularCallout(); m_RoundedRectangularCallout.ArrowLength = new NLength(15, NRelativeUnit.ParentPercentage); m_RoundedRectangularCallout.FillStyle = new NGradientFillStyle(Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightGreen)); m_RoundedRectangularCallout.UseAutomaticSize = true; m_RoundedRectangularCallout.Orientation = 135; m_RoundedRectangularCallout.Anchor = new NModelPointAnchor(m_Chart, new NVector3DF(0, 0, 0)); m_RoundedRectangularCallout.Text = GetTextForAnnotation(m_RoundedRectangularCallout); nChartControl1.Panels.Add(m_RoundedRectangularCallout); m_CutEdgeRectangularCallout = new NCutEdgeRectangularCallout(); m_CutEdgeRectangularCallout.FillStyle = new NGradientFillStyle(Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightBlue)); m_CutEdgeRectangularCallout.ArrowLength = new NLength(40, NRelativeUnit.ParentPercentage); m_CutEdgeRectangularCallout.UseAutomaticSize = true; m_CutEdgeRectangularCallout.Orientation = 190; m_CutEdgeRectangularCallout.Anchor = new NLegendDataItemAnchor(m_Legend, 1); m_CutEdgeRectangularCallout.Text = GetTextForAnnotation(m_CutEdgeRectangularCallout); nChartControl1.Panels.Add(m_CutEdgeRectangularCallout); m_OvalCallout = new NOvalCallout(); m_OvalCallout.FillStyle = new NColorFillStyle(Color.FromArgb(200, Color.AliceBlue)); m_OvalCallout.ArrowLength = new NLength(15, NRelativeUnit.ParentPercentage); m_OvalCallout.UseAutomaticSize = true; m_OvalCallout.Orientation = 315; m_OvalCallout.Anchor = new NScalePointAnchor(m_Chart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY, (int)StandardAxis.Depth, AxisValueAnchorMode.Clip, new NVector3DD(7, 100, 0)); m_OvalCallout.Text = GetTextForAnnotation(m_OvalCallout); nChartControl1.Panels.Add(m_OvalCallout); m_ArrowAnnotation = new NArrowAnnotation(); m_ArrowAnnotation.UseAutomaticSize = true; m_ArrowAnnotation.ArrowHeadWidthPercent = 30; m_ArrowAnnotation.TextStyle.FontStyle.EmSize = new NLength(11, NGraphicsUnit.Point); m_ArrowAnnotation.TextStyle.FontStyle.Style |= FontStyle.Bold; m_ArrowAnnotation.Orientation = 45; m_ArrowAnnotation.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.Orange)); m_ArrowAnnotation.Anchor = new NDataPointAnchor(m_Bar, 4, ContentAlignment.MiddleCenter, StringAlignment.Center); m_ArrowAnnotation.Text = GetTextForAnnotation(m_ArrowAnnotation); nChartControl1.Panels.Add(m_ArrowAnnotation); nChartControl1.Controller.Selection.Clear(); nChartControl1.Controller.Selection.Add(m_Chart); nChartControl1.Controller.Tools.Add(new NTrackballTool()); }
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(); }
private void ConfigureAnnotations() { if (rectPanelCheck.Checked) { nRectangularCallout = new NRectangularCallout(); nRectangularCallout.ArrowLength = new NLength(15, NRelativeUnit.ParentPercentage); nRectangularCallout.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.CadetBlue)); nRectangularCallout.UseAutomaticSize = true; nRectangularCallout.Orientation = 225; nRectangularCallout.Anchor = new NDataPointAnchor(nBar, 2, ContentAlignment.MiddleCenter, StringAlignment.Center); nRectangularCallout.Text = GetTextForAnnotation(nRectangularCallout); nRectangularCallout.TextStyle.FontStyle.EmSize = new NLength(8); nChartControl1.Panels.Add(nRectangularCallout); } if (roundRectCalloutCheck.Checked) { nRoundedRectangularCallout = new NRoundedRectangularCallout(); nRoundedRectangularCallout.ArrowLength = new NLength(15, NRelativeUnit.ParentPercentage); nRoundedRectangularCallout.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightGreen)); nRoundedRectangularCallout.UseAutomaticSize = true; nRoundedRectangularCallout.Orientation = 135; nRoundedRectangularCallout.Anchor = new NModelPointAnchor(nChart, new NVector3DF(0, 0, 0)); nRoundedRectangularCallout.Text = GetTextForAnnotation(nRoundedRectangularCallout); nRoundedRectangularCallout.TextStyle.FontStyle.EmSize = new NLength(8); nChartControl1.Panels.Add(nRoundedRectangularCallout); } if (cutedgeRectPanelCheck.Checked) { nCutEdgeRectangularCallout = new NCutEdgeRectangularCallout(); nCutEdgeRectangularCallout.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.LightBlue)); nCutEdgeRectangularCallout.ArrowLength = new NLength(40, NRelativeUnit.ParentPercentage); nCutEdgeRectangularCallout.UseAutomaticSize = true; nCutEdgeRectangularCallout.Orientation = 190; nCutEdgeRectangularCallout.Anchor = new NLegendDataItemAnchor(nLegend, 1); nCutEdgeRectangularCallout.Text = GetTextForAnnotation(nCutEdgeRectangularCallout); nCutEdgeRectangularCallout.TextStyle.FontStyle.EmSize = new NLength(8); nChartControl1.Panels.Add(nCutEdgeRectangularCallout); } if (ovalPanelCheck.Checked) { nOvalCallout = new NOvalCallout(); nOvalCallout.FillStyle = new NColorFillStyle(Color.FromArgb(200, Color.AliceBlue)); nOvalCallout.ArrowLength = new NLength(15, NRelativeUnit.ParentPercentage); nOvalCallout.UseAutomaticSize = true; nOvalCallout.Orientation = 315; nOvalCallout.Anchor = new NScalePointAnchor(nChart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY, (int)StandardAxis.Depth, AxisValueAnchorMode.Clip, new NVector3DD(7, 100, 0)); nOvalCallout.Text = GetTextForAnnotation(nOvalCallout); nOvalCallout.TextStyle.FontStyle.EmSize = new NLength(8); nChartControl1.Panels.Add(nOvalCallout); } if (arrowCheck.Checked) { nArrowAnnotation = new NArrowAnnotation(); nArrowAnnotation.UseAutomaticSize = true; nArrowAnnotation.ArrowHeadWidthPercent = 30; nArrowAnnotation.TextStyle.FontStyle.EmSize = new NLength(11, NGraphicsUnit.Point); nArrowAnnotation.TextStyle.FontStyle.Style |= FontStyle.Bold; nArrowAnnotation.Orientation = 45; nArrowAnnotation.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, Color.FromArgb(125, Color.White), Color.FromArgb(125, Color.Orange)); nArrowAnnotation.Anchor = new NDataPointAnchor(nBar, 4, ContentAlignment.MiddleCenter, StringAlignment.Center); nArrowAnnotation.Text = GetTextForAnnotation(nArrowAnnotation); nArrowAnnotation.TextStyle.FontStyle.EmSize = new NLength(8); nChartControl1.Panels.Add(nArrowAnnotation); } }