protected void Page_Load(object sender, EventArgs e) { nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Nonoverlapping Pie Labels"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL( new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // no legend nChartControl1.Legends.Clear(); // setup chart NPieChart pieChart = new NPieChart(); nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(pieChart); pieChart.Enable3D = true; pieChart.BoundsMode = BoundsMode.Fit; pieChart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); pieChart.Size = new NSizeL( new NLength(90, NRelativeUnit.ParentPercentage), new NLength(87, NRelativeUnit.ParentPercentage)); pieChart.ClockwiseDirection = clockwiseCheckBox.Checked; pieChart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated); pieChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); // setup pie series m_Pie = (NPieSeries)pieChart.Series.Add(SeriesType.Pie); m_Pie.LabelMode = PieLabelMode.SpiderNoOverlap; m_Pie.DataLabelStyle.Format = "<label>\n<percent>"; m_Pie.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point); m_Pie.Values.ValueFormatter = new NNumericValueFormatter("0.##"); m_Pie.BorderStyle.Color = Color.White; m_Pie.PieStyle = PieStyle.SmoothEdgePie; double[] arrValues = { 4.17, 7.19, 5.62, 7.91, 15.28, 0.97, 1.3, 1.12, 8.54, 9.84 }; for (int i = 0; i < arrValues.Length; i++) { m_Pie.Values.Add(arrValues[i]); } SetTexts(); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.BrightMultiColor); styleSheet.Apply(nChartControl1.Document); }
private void InnerRadiusScroll_ValueChanged(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e) { NPieChart pie = (NPieChart)nChartControl1.Charts[0]; pie.InnerRadius = new NLength(InnerRadiusScroll.Value, NRelativeUnit.ParentPercentage); nChartControl1.Refresh(); }
private NPieChart CreatePieChart() { NPieChart pieChart = new NPieChart(); NDockLayout.SetDockArea(pieChart, ENDockArea.Center); pieChart.Margins = new NMargins(10, 0, 10, 10); NPieSeries pieSeries = new NPieSeries(); pieChart.Series.Add(pieSeries); pieChart.DockSpiderLabelsToSides = false; NDataLabelStyle dataLabelStyle = new NDataLabelStyle(); dataLabelStyle.ArrowLength = 15; dataLabelStyle.ArrowPointerLength = 0; pieSeries.DataLabelStyle = dataLabelStyle; pieSeries.LabelMode = ENPieLabelMode.Spider; pieSeries.LegendView.Mode = ENSeriesLegendMode.DataPoints; pieSeries.LegendView.Format = "<label> <percent>"; pieSeries.DataPoints.Add(new NPieDataPoint(24, "Cars")); pieSeries.DataPoints.Add(new NPieDataPoint(18, "Airplanes")); pieSeries.DataPoints.Add(new NPieDataPoint(32, "Trains")); pieSeries.DataPoints.Add(new NPieDataPoint(23, "Ships")); pieSeries.DataPoints.Add(new NPieDataPoint(19, "Buses")); return(pieChart); }
private void TotalAngleScroll_Scroll(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e) { NPieChart pie = (NPieChart)nChartControl1.Charts[0]; pie.TotalAngle = TotalAngleScroll.Value; nChartControl1.Refresh(); }
private void TotalAngleScrollBar_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs <double> e) { NPieChart pie = (NPieChart)nChartControl1.Charts[0]; pie.TotalAngle = (float)TotalAngleScrollBar.Value * 360.0f; nChartControl1.Refresh(); }
private void InnerRadiusScrollBar_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs <double> e) { NPieChart pie = (NPieChart)nChartControl1.Charts[0]; pie.InnerRadius = new NLength((float)InnerRadiusScrollBar.Value * 100.0f, NRelativeUnit.ParentPercentage); nChartControl1.Refresh(); }
protected void nChartControl1_AsyncCustomCommand(object sender, EventArgs e) { NCallbackCustomCommandArgs args = e as NCallbackCustomCommandArgs; NCallbackCommand command = args.Command; NPieSeries pieSeries; switch (command.Name) { case "changeColor": string idText = command.Arguments["id"] as string; if (idText == null) { break; } NElementAtomIdentifier id = new NElementAtomIdentifier(idText); NChartNode node = id.FindInDocument(nChartControl1.Document) as NChartNode; if (node == null) { break; } NHitTestResult hitTestResult = new NHitTestResult(node); if (hitTestResult.ChartElement != ChartElement.DataPoint) { break; } pieSeries = hitTestResult.Series as NPieSeries; if (pieSeries == null) { break; } Color c = Color.Red; if (command.Arguments["color"].ToString() == "blue") { c = Color.Blue; } NColorFillStyle fs = pieSeries.FillStyles[hitTestResult.DataPointIndex] as NColorFillStyle; if (fs == null) { break; } pieSeries.FillStyles[hitTestResult.DataPointIndex] = new NColorFillStyle(c); clientSideRedrawRequired = (fs.Color != c); break; case "rotate10Degrees": NRootPanel rootPanel = nChartControl1.Document.RootPanel; NPieChart pieChart = nChartControl1.Charts[0] as NPieChart; pieChart.BeginAngle += 10; if (pieChart.BeginAngle >= 360) { pieChart.BeginAngle = pieChart.BeginAngle - 360; } break; } }
protected void nChartControl1_AsyncQueryCommandResult(object sender, EventArgs e) { NCallbackQueryCommandResultArgs args = e as NCallbackQueryCommandResultArgs; NCallbackCommand command = args.Command; NAjaxXmlTransportBuilder resultBuilder = args.ResultBuilder; switch (command.Name) { case "queryCurrentAngle": // build a custom response data section NRootPanel rootPanel = nChartControl1.Document.RootPanel; NPieChart pieChart = nChartControl1.Charts[0] as NPieChart; NAjaxXmlDataSection dataSection = new NAjaxXmlDataSection("angle"); dataSection.Data = pieChart.BeginAngle.ToString(); resultBuilder.AddDataSection(dataSection); break; case "changeColor": // add a built-in data section that will enforce full image refresh at the client if (clientSideRedrawRequired && !resultBuilder.ContainsRedrawDataSection()) { resultBuilder.AddRedrawDataSection(nChartControl1); } break; case "rotate10Degrees": if (!resultBuilder.ContainsRedrawDataSection()) { resultBuilder.AddRedrawDataSection(nChartControl1); } break; } }
public void OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e) { NThinChartControl chartControl = (NThinChartControl)control; NPieChart pieChart = (NPieChart)chartControl.Charts[0]; NHitTestResult hitTestResult = chartControl.HitTest(e.X, e.Y); int dataPointIndex = hitTestResult.DataPointIndex; // collapse all pie slices NPieSeries pieSeries = (NPieSeries)pieChart.Series[0]; for (int i = 0; i < pieSeries.Values.Count; i++) { pieSeries.Detachments[i] = 0; } // expand the one that's hit if (dataPointIndex != -1) { pieSeries.Detachments[dataPointIndex] = 5.0f; } chartControl.UpdateView(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); m_Manager = ((NMainForm)base.m_MainForm).chartCommandBarsManager; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Command Bars"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // hide the legend ((NLegend)nChartControl1.Legends[0]).Mode = LegendMode.Disabled; // create chart 1 NChart chart1 = nChartControl1.Charts[0]; chart1.Enable3D = true; chart1.Name = "Bar Chart"; chart1.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(5, NRelativeUnit.ParentPercentage)); chart1.Size = new NSizeL(new NLength(40, NRelativeUnit.ParentPercentage), new NLength(95, NRelativeUnit.ParentPercentage)); chart1.BoundsMode = BoundsMode.Fit; chart1.Axis(StandardAxis.Depth).Visible = false; // create chart 2 NChart chart2 = new NPieChart(); chart2.Enable3D = true; nChartControl1.Charts.Add(chart2); chart2.Name = "Pie Chart"; chart2.Location = new NPointL(new NLength(55, NRelativeUnit.ParentPercentage), new NLength(5, NRelativeUnit.ParentPercentage)); chart2.Size = new NSizeL(new NLength(40, NRelativeUnit.ParentPercentage), new NLength(95, NRelativeUnit.ParentPercentage)); chart2.BoundsMode = BoundsMode.Fit; chart2.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); // add series to first chart NBarSeries bar = (NBarSeries)chart1.Series.Add(SeriesType.Bar); bar.Name = "Bar"; bar.Values.FillRandom(Random, 10); bar.DataLabelStyle.Visible = false; // add series to second chart NPieSeries pie = (NPieSeries)chart2.Series.Add(SeriesType.Pie); pie.Name = "Pie"; pie.Values.FillRandom(Random, 5); pie.PieStyle = PieStyle.SmoothEdgePie; pie.FillStyles[0] = new NColorFillStyle(Color.FromArgb(169, 121, 11)); pie.FillStyles[1] = new NColorFillStyle(Color.FromArgb(157, 157, 92)); pie.FillStyles[2] = new NColorFillStyle(Color.FromArgb(98, 152, 92)); pie.FillStyles[3] = new NColorFillStyle(Color.FromArgb(111, 134, 181)); pie.FillStyles[4] = new NColorFillStyle(Color.FromArgb(179, 63, 92)); }
private NChart CreateAnchorPanelChart() { NChart chart = null; NSeries series = null; switch (MiniChartTypeComboBox.SelectedIndex) { case 0: // Pie chart = new NPieChart(); series = (NSeries)chart.Series.Add(SeriesType.Pie); break; case 1: // Doughnut { chart = new NPieChart(); NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie); pie.PieStyle = PieStyle.Torus; series = pie; break; } case 2: // Bar chart = new NCartesianChart(); chart.Wall(ChartWallType.Back).Visible = false; chart.Axis(StandardAxis.PrimaryX).Visible = false; chart.Axis(StandardAxis.PrimaryY).Visible = false; chart.Axis(StandardAxis.Depth).Visible = false; series = (NSeries)chart.Series.Add(SeriesType.Bar); break; case 3: // Area chart = new NCartesianChart(); chart.Wall(ChartWallType.Back).Visible = false; chart.Axis(StandardAxis.PrimaryX).Visible = false; chart.Axis(StandardAxis.PrimaryY).Visible = false; chart.Axis(StandardAxis.Depth).Visible = false; series = (NSeries)chart.Series.Add(SeriesType.Area); break; } chart.BoundsMode = BoundsMode.Fit; chart.DockMode = PanelDockMode.Fill; series.DataLabelStyle.Visible = false; NDataPoint dp = new NDataPoint(); for (int i = 0; i < 5; i++) { dp[DataPointValue.Value] = 5 + Random.Next(10); dp[DataPointValue.FillStyle] = new NColorFillStyle(RandomColor()); series.AddDataPoint(dp); } return(chart); }
protected void nChartControl1_AsyncRefresh(object sender, EventArgs e) { NRootPanel rootPanel = nChartControl1.Document.RootPanel; NPieChart pieChart = rootPanel.Charts[0] as NPieChart; pieChart.BeginAngle += 1; if (pieChart.BeginAngle >= 360) { pieChart.BeginAngle = 0; } }
public override void OnAsyncRefresh(string webControlId, System.Web.HttpContext context, NStateObject state, EventArgs args) { NChartSessionStateObject chartState = state as NChartSessionStateObject; NRootPanel rootPanel = chartState.Document.RootPanel; NPieChart pieChart = rootPanel.Charts[0] as NPieChart; pieChart.BeginAngle += 1; if (pieChart.BeginAngle >= 360) { pieChart.BeginAngle = 0; } }
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); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); m_Manager = ((NMainForm)base.m_MainForm).chartCommandBarsManager; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Customizing the Command Bar"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); NPieChart chart = new NPieChart(); chart.Enable3D = true; nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(chart); chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights); chart.DisplayOnLegend = nChartControl1.Legends[0]; chart.Location = new NPointL(new NLength(15, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(70, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); NPieSeries pieSeries = (NPieSeries)chart.Series.Add(SeriesType.Pie); pieSeries.PieEdgePercent = 30; pieSeries.PieStyle = PieStyle.SmoothEdgePie; pieSeries.Legend.Mode = SeriesLegendMode.DataPoints; pieSeries.Legend.Format = "<label> <percent>"; pieSeries.AddDataPoint(new NDataPoint(12, "Ships")); pieSeries.AddDataPoint(new NDataPoint(42, "Trains")); pieSeries.AddDataPoint(new NDataPoint(56, "Cars")); pieSeries.AddDataPoint(new NDataPoint(23, "Buses")); pieSeries.AddDataPoint(new NDataPoint(18, "Airplanes")); for (int i = 0; i < pieSeries.Values.Count; i++) { pieSeries.Detachments.Add(0); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); ShowStandardToolbarCheckBox_CheckedChanged(null, null); }
protected void nChartControl1_AsyncRefresh(object sender, EventArgs e) { // this method is called when the web control operates in the standard Microsoft AJAX mode DoSimulateResponseDelay(); NRootPanel rootPanel = nChartControl1.Document.RootPanel; NPieChart pieChart = nChartControl1.Charts[0] as NPieChart; pieChart.BeginAngle += 1; if (pieChart.BeginAngle >= 360) { pieChart.BeginAngle = 0; } }
void INMouseEventCallback.OnMouseEvent(NAspNetThinWebControl control, NBrowserMouseEventArgs e) { NThinChartControl chartControl = (NThinChartControl)control; NPieChart pieChart = (NPieChart)chartControl.Charts[0]; NPieSeries pieSeries = (NPieSeries)pieChart.Series[0]; for (int i = 0; i < pieSeries.Values.Count; i++) { pieSeries.Detachments[i] = 5.0f; } chartControl.UpdateView(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Sorted Pie Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); NChart chart = new NPieChart(); nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(chart); // configure the chart chart.Enable3D = true; chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.VividCameraLight); chart.DisplayOnLegend = nChartControl1.Legends[0]; chart.Location = new NPointL(new NLength(20, NRelativeUnit.ParentPercentage), new NLength(20, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(60, NRelativeUnit.ParentPercentage), new NLength(60, NRelativeUnit.ParentPercentage)); // configure the legend NLegend legend = nChartControl1.Legends[0]; legend.FillStyle = new NColorFillStyle(Color.FromArgb(100, Color.White)); // configure the pie series m_Pie = (NPieSeries)chart.Series.Add(SeriesType.Pie); m_Pie.Legend.Mode = SeriesLegendMode.DataPoints; m_Pie.Legend.Format = "<label> <percent>"; // add data m_Pie.BorderStyle.Color = Color.LightGray; m_Pie.AddDataPoint(new NDataPoint(0, "Cars")); m_Pie.AddDataPoint(new NDataPoint(0, "Trains")); m_Pie.AddDataPoint(new NDataPoint(0, "Airplanes")); m_Pie.AddDataPoint(new NDataPoint(0, "Buses")); m_Pie.AddDataPoint(new NDataPoint(0, "Ships")); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); ChangeDataButton_Click(null, null); }
public override void OnAsyncRefresh(string webControlId, System.Web.HttpContext context, NStateObject state, EventArgs args) { // this method is called when the web control operates in the Nevron Instant Callback mode DoSimulateResponseDelay(); NChartSessionStateObject chartState = state as NChartSessionStateObject; NRootPanel rootPanel = chartState.Document.RootPanel; NPieChart pieChart = rootPanel.Charts[0] as NPieChart; pieChart.BeginAngle += 1; if (pieChart.BeginAngle >= 360) { pieChart.BeginAngle = 0; } }
protected void Page_Load(object sender, EventArgs e) { if (!NThinChartControl1.Initialized) { // get the default chart NThinChartControl1.Panels.Clear(); NThinChartControl1.BackgroundStyle.FrameStyle.Visible = false; NThinChartControl1.Settings.EnableJittering = true; // set a chart title NLabel title = NThinChartControl1.Labels.AddHeader("Panel Selector Tool"); title.TextStyle.TextFormat = GraphicsCore.TextFormat.XML; title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.DockMode = PanelDockMode.Top; NDockPanel contentPanel = new NDockPanel(); contentPanel.DockMode = PanelDockMode.Fill; // create the first pie chart NPieChart pieChart1 = CreatePieChart(); pieChart1.Location = new NPointL(0, 0); pieChart1.Size = new NSizeL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage)); contentPanel.ChildPanels.Add(pieChart1); // create the second pie chart NPieChart pieChart2 = CreatePieChart(); pieChart2.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(0)); pieChart2.Size = new NSizeL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage)); contentPanel.ChildPanels.Add(pieChart2); NThinChartControl1.Panels.Add(contentPanel); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.BrightMultiColor); styleSheet.Apply(NThinChartControl1.Document); // add panel selector and trackball tools NPanelSelectorTool panelSelector = new NPanelSelectorTool(); panelSelector.ActivatePanelCallback = new ActivatePanelCallback(); NThinChartControl1.Controller.Tools.Add(panelSelector); NThinChartControl1.Controller.Tools.Add(new NTrackballTool()); } }
private void Timer1_Tick(object sender, System.EventArgs e) { NChartCollection charts = nChartControl1.Charts; for (int i = 0; i < charts.Count; i++) { NPieChart pieChart = (NPieChart)charts[i]; float newBeginAngle = pieChart.BeginAngle + 5; if (newBeginAngle > 360) { newBeginAngle -= 360; } pieChart.BeginAngle = newBeginAngle; } nChartControl1.Refresh(); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Pie Slice Radius"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); NPieChart pieChart = new NPieChart(); pieChart.InnerRadius = new NLength(0); pieChart.Enable3D = true; nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(pieChart); pieChart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated); pieChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights); pieChart.DisplayOnLegend = nChartControl1.Legends[0]; pieChart.Location = new NPointL(new NLength(15, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); pieChart.Size = new NSizeL(new NLength(70, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); NPieSeries pieSeries = (NPieSeries)pieChart.Series.Add(SeriesType.Pie); pieSeries.PieEdgePercent = 30; pieSeries.PieStyle = PieStyle.SmoothEdgePie; pieSeries.Legend.Mode = SeriesLegendMode.DataPoints; pieSeries.Legend.Format = "<label> <percent>"; pieSeries.UseBeginEndWidthPercents = true; for (int i = 0; i < 9; i++) { pieSeries.Values.Add(10 + i * 10); pieSeries.BeginWidthPercents.Add(0); pieSeries.EndWidthPercents.Add(10 + i * 10); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); }
private void RenderQuestionPieChart(int total, int totalseen, int errors) { chart.Charts.Clear(); NChart piechart = new NPieChart(); NPieSeries pie = (NPieSeries)piechart.Series.Add(SeriesType.Pie); pie.AddDataPoint(new NDataPoint(totalseen - errors, "Positive", new NColorFillStyle(Color.LightGreen))); pie.AddDataPoint(new NDataPoint(errors, "Negative", new NColorFillStyle(Color.Red))); pie.Legend.Mode = SeriesLegendMode.DataPoints; pie.Legend.Format = "<label> <percent>"; pie.PieStyle = PieStyle.SmoothEdgePie; pie.LabelMode = PieLabelMode.Spider; chart.Charts.Add(piechart); chart.Refresh(); this.RenderHistoryChart(); }
private NPieChart CreatePieChart() { NPieChart pieChart = new NPieChart(); pieChart.Enable3D = true; pieChart.Margins = new NMarginsL(10, 10, 10, 10); pieChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); pieChart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated); NPieSeries pieSeries = new NPieSeries(); pieSeries.LabelMode = PieLabelMode.Center; pieSeries.PieStyle = PieStyle.SmoothEdgePie; pieChart.Series.Add(pieSeries); Random rand = new Random(); for (int i = 0; i < 6; i++) { pieSeries.Values.Add(rand.Next(100) + 10); } return pieChart; }
private NPanel ConfigurePieChart() { // configure the chart bounds, contentalign, docking, light model and projection. NChart chart = new NPieChart(); chart.Enable3D = true; chart.BoundsMode = BoundsMode.Fit; chart.ContentAlignment = ContentAlignment.MiddleCenter; chart.DockMode = PanelDockMode.Fill; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated); // create the pie series NPieSeries pie = new NPieSeries(); chart.Series.Add(pie); pie.PieStyle = PieStyle.SmoothEdgePie; pie.DataLabelStyle.Format = "<percent>"; pie.LabelMode = PieLabelMode.Center; pie.DataLabelStyle.TextStyle.BackplaneStyle.Visible = false; pie.DataLabelStyle.TextStyle.FontStyle.Style |= FontStyle.Bold; pie.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(12, NGraphicsUnit.Point); for (int i = 0; i < colors.Length; i++) { pie.AddDataPoint(new NDataPoint(Random.Next(10) + 5, new NColorFillStyle(colors[i]))); } // create a watermark and nest the chart inside NWatermark chartHostPanel = new NWatermark(); chartHostPanel.DockMode = PanelDockMode.Fill; chartHostPanel.ChildPanels.Add(chart); return(chartHostPanel); }
private void ConfigureControl(NChartControl control, string sLabel) { control.BackgroundStyle.FrameStyle.Visible = false; // generate image map respones NHtmlImageMapResponse imageMapResponse = new NHtmlImageMapResponse(); control.ServerSettings.BrowserResponseSettings.BrowserResponsePairs.Clear(); control.ServerSettings.BrowserResponseSettings.DefaultResponse = imageMapResponse; // set a chart title NLabel title = control.Labels.AddHeader(sLabel); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL( new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); NLegend legend = control.Legends[0]; legend.SetPredefinedLegendStyle(PredefinedLegendStyle.Bottom); legend.Data.ExpandMode = LegendExpandMode.ColsFixed; legend.Data.ColCount = 2; legend.ShadowStyle.Type = ShadowType.GaussianBlur; NPieChart chart = new NPieChart(); control.Charts.Clear(); control.Charts.Add(chart); chart.DisplayOnLegend = legend; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights); chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated); chart.BoundsMode = BoundsMode.Fit; chart.Location = new NPointL( new NLength(15, NRelativeUnit.ParentPercentage), new NLength(25, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(70, NRelativeUnit.ParentPercentage), new NLength(50, NRelativeUnit.ParentPercentage)); NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie); pie.PieStyle = PieStyle.SmoothEdgePie; pie.LabelMode = PieLabelMode.Rim; pie.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point); pie.Legend.Mode = SeriesLegendMode.DataPoints; pie.Legend.Format = "<label> <percent>"; pie.DataLabelStyle.ArrowLength = new NLength(0f, NRelativeUnit.ParentPercentage); pie.DataLabelStyle.ArrowPointerLength = new NLength(0f, NRelativeUnit.ParentPercentage); pie.AddDataPoint(new NDataPoint(12, "Cars")); pie.AddDataPoint(new NDataPoint(42, "Trains")); pie.AddDataPoint(new NDataPoint(56, "Airplanes")); pie.AddDataPoint(new NDataPoint(23, "Buses")); pie.InteractivityStyles.Add(0, new NInteractivityStyle("Cars", CursorType.Hand)); pie.InteractivityStyles.Add(1, new NInteractivityStyle("Trains", CursorType.Hand)); pie.InteractivityStyles.Add(2, new NInteractivityStyle("Airplanes", CursorType.Hand)); pie.InteractivityStyles.Add(3, new NInteractivityStyle("Buses", CursorType.Hand)); NPostbackAttribute postbackAttribute = new NPostbackAttribute(); for (int i = 0; i < pie.InteractivityStyles.Count; i++) { ((NInteractivityStyle)pie.InteractivityStyles[i]).InteractivityAttributes.Add(postbackAttribute); pie.Detachments.Add(0); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(control.Document); }
protected void Page_Load(object sender, System.EventArgs e) { if (nChartControl1.RequiresInitialization) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // configure legend NLegend legend = nChartControl1.Legends[0]; legend.ShadowStyle.Type = ShadowType.GaussianBlur; legend.SetPredefinedLegendStyle(PredefinedLegendStyle.Left); legend.DockMode = PanelDockMode.Bottom; legend.Margins = new NMarginsL(0, 0, 0, 10); legend.Data.ExpandMode = LegendExpandMode.ColsFixed; legend.Data.ColCount = 2; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Product Analysis"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage)); // by default the chart contains a cartesian chart which cannot display pie series NPieChart chart = new NPieChart(); chart.Enable3D = true; nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(chart); chart.DisplayOnLegend = nChartControl1.Legends[0]; NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie); pie.AddDataPoint(new NDataPoint(23, ".NET Vision")); pie.AddDataPoint(new NDataPoint(56, "Chart")); pie.AddDataPoint(new NDataPoint(42, "Diagram")); pie.AddDataPoint(new NDataPoint(12, "User Interface")); pie.Legend.Mode = SeriesLegendMode.DataPoints; pie.Legend.Format = "<label> <percent>"; pie.PieStyle = PieStyle.SmoothEdgePie; pie.LabelMode = PieLabelMode.Spider; pie.LabelMode = PieLabelMode.Center; pie.DataLabelStyle.ArrowLength = new NLength(0f, NRelativeUnit.ParentPercentage); pie.DataLabelStyle.ArrowPointerLength = new NLength(0f, NRelativeUnit.ParentPercentage); chart.LightModel.EnableLighting = true; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated); chart.BoundsMode = BoundsMode.Fit; chart.Location = new NPointL( new NLength(10, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(80, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); // set up client side tooltips pie.InteractivityStyles.Add(0, new NInteractivityStyle(true, null, ".NET Vision")); pie.InteractivityStyles.Add(1, new NInteractivityStyle(true, null, "Chart")); pie.InteractivityStyles.Add(2, new NInteractivityStyle(true, null, "Diagram")); pie.InteractivityStyles.Add(3, new NInteractivityStyle(true, null, "User Interface")); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); } }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { nChartControl1.Controller.Tools.Clear(); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Nonoverlapping Pie Labels"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL( new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // no legend nChartControl1.Legends.Clear(); // setup chart m_PieChart = new NPieChart(); m_PieChart.Enable3D = true; nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(m_PieChart); m_PieChart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated); m_PieChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights); m_PieChart.Location = new NPointL( new NLength(15, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); m_PieChart.Size = new NSizeL( new NLength(70, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); // setup pie series m_PieSeries = (NPieSeries)m_PieChart.Series.Add(SeriesType.Pie); m_PieSeries.LabelMode = PieLabelMode.SpiderNoOverlap; m_PieSeries.DataLabelStyle.Format = "<label>\n<percent>"; m_PieSeries.Values.ValueFormatter = new NNumericValueFormatter("0.##"); double[] arrValues = { 4.17, 7.19, 5.62, 7.91, 15.28, 0.97, 1.3, 1.12, 8.54, 9.84, 2.05, 5.02, 1.42, 0.63, 3.01 }; for (int i = 0; i < arrValues.Length; i++) { m_PieSeries.Values.Add(arrValues[i]); } SetTexts(); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.BrightMultiColor); styleSheet.Apply(nChartControl1.Document); // init form controls NExampleHelpers.FillComboWithEnumValues(PieStyleComboBox, typeof(PieStyle)); PieStyleComboBox.SelectedIndex = 2; PieStyleComboBox_SelectionChanged(null, null); }
public override void Initialize() { base.Initialize(); nChartControl1.Controller.Tools.Clear(); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("3D Pie Chart Shapes"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup the legend NLegend legend = nChartControl1.Legends[0]; legend.SetPredefinedLegendStyle(PredefinedLegendStyle.BottomRight); NPieChart pieChart = new NPieChart(); pieChart.Enable3D = true; nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(pieChart); NPointLightSource ls = new NPointLightSource(); ls.CoordinateMode = LightSourceCoordinateMode.Camera; ls.Position = new NVector3DF(0, 0, 50); ls.Ambient = Color.FromArgb(30, 30, 30); ls.Diffuse = Color.FromArgb(180, 180, 180); ls.Specular = Color.FromArgb(100, 100, 100); pieChart.LightModel.LightSources.Clear(); pieChart.LightModel.LightSources.Add(ls); pieChart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated); pieChart.Depth = 10; pieChart.DisplayOnLegend = nChartControl1.Legends[0]; pieChart.Location = new NPointL(new NLength(20, NRelativeUnit.ParentPercentage), new NLength(20, NRelativeUnit.ParentPercentage)); pieChart.Size = new NSizeL(new NLength(60, NRelativeUnit.ParentPercentage), new NLength(60, NRelativeUnit.ParentPercentage)); pieChart.InnerRadius = new NLength(20, NRelativeUnit.ParentPercentage); NPieSeries pieSeries = (NPieSeries)pieChart.Series.Add(SeriesType.Pie); pieSeries.BorderStyle.Color = Color.LemonChiffon; pieSeries.DataLabelStyle.ArrowLength = new NLength(10, NGraphicsUnit.Point); pieSeries.DataLabelStyle.ArrowPointerLength = new NLength(0, NGraphicsUnit.Point); pieSeries.Legend.Mode = SeriesLegendMode.DataPoints; pieSeries.Legend.Format = "<label> <percent>"; pieSeries.AddDataPoint(new NDataPoint(24, "Cars", new NColorFillStyle(Color.FromArgb(169, 121, 11)))); pieSeries.AddDataPoint(new NDataPoint(18, "Airplanes", new NColorFillStyle(Color.FromArgb(157, 157, 92)))); pieSeries.AddDataPoint(new NDataPoint(32, "Trains", new NColorFillStyle(Color.FromArgb(98, 152, 92)))); pieSeries.AddDataPoint(new NDataPoint(23, "Ships", new NColorFillStyle(Color.FromArgb(111, 134, 181)))); pieSeries.AddDataPoint(new NDataPoint(19, "Buses", new NColorFillStyle(Color.FromArgb(179, 63, 92)))); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); // init form controls PieShapeCombo.FillFromEnum(typeof(PieStyle)); PieShapeCombo.SelectedIndex = (int)PieStyle.Ring; PieLabelModeCombo.FillFromEnum(typeof(PieLabelMode)); PieLabelModeCombo.SelectedIndex = 0; EdgePercentScroll.Value = (int)pieSeries.PieEdgePercent; OuterRadiusScroll.Value = (int)pieChart.Radius.Value; InnerRadiusScroll.Value = (int)pieChart.InnerRadius.Value; ArrowLengthScroll.Value = (int)pieSeries.DataLabelStyle.ArrowLength.Value; ArrowPointerLengthScroll.Value = (int)pieSeries.DataLabelStyle.ArrowPointerLength.Value; ConnectorLengthScroll.Value = (int)pieSeries.ConnectorLength.Value; LeadOffLengthScroll.Value = (int)pieSeries.LeadOffArrowLength.Value; BeginAngleScroll.Value = (int)pieChart.BeginAngle; TotalAngleScroll.Value = (int)pieChart.TotalAngle; }