private void NChartControl1_Click(object sender, EventArgs e) { NPostbackEventArgs eventArgs = e as NPostbackEventArgs; object selectedNode = eventArgs.Id.FindInDocument(nChartControl1.Document); if (selectedNode is NDataPoint) { NDataPoint dataPoint = (NDataPoint)selectedNode; dataPoint[DataPointValue.PieDetachment] = 10; NSeries series = (NSeries)dataPoint.ParentNode; series.StoreDataPoint(dataPoint.IndexInSeries, dataPoint); switch (dataPoint.IndexInSeries) { case 0: SalesOverTimeImg.ImageUrl = "NInteractiveCarSalesPage.aspx"; break; case 1: SalesOverTimeImg.ImageUrl = "NInteractiveTrainSalesPage.aspx"; break; case 2: SalesOverTimeImg.ImageUrl = "NInteractiveShipSalesPage.aspx"; break; case 3: SalesOverTimeImg.ImageUrl = "NInteractiveBusSalesPage.aspx"; break; } } }
private void GroupValues_Click(object sender, System.EventArgs e) { if (m_bGroupedData) { MessageBox.Show("Click the ungroup button first"); return; } // get a subset containing the pies which are smaller than the specified value NDataSeriesSubset smallerThanValue = m_Pie.Values.Filter(Nevron.Chart.CompareMethod.Less, m_dGroupValue); // determine the sum of the filtered pies double dOtherSliceValue = m_Pie.Values.Evaluate("SUM", smallerThanValue); // remove the data points contained in the for (int i = m_Pie.GetDataPointCount(); i >= 0; i--) { if (smallerThanValue.Contains(i)) { m_Pie.RemoveDataPointAt(i); } } // add a detached pie with the specified group label and color NDataPoint dp = new NDataPoint(dOtherSliceValue, m_sGroupLabel); dp[DataPointValue.PieDetachment] = 2; dp[DataPointValue.FillStyle] = new NColorFillStyle(m_GroupColor); dp[DataPointValue.StrokeStyle] = new NStrokeStyle(1, m_GroupColor); m_Pie.AddDataPoint(dp); m_bGroupedData = true; nChartControl1.Refresh(); }
public override void OnMouseMove(object sender, NMouseEventArgs e) { m_SelectedSeries = null; NHitTestCacheService hitTestService = GetView().GetServiceOfType(typeof(NHitTestCacheService)) as NHitTestCacheService; if (hitTestService == null) { return; } INNode node = hitTestService.HitTest(new NPointF(e.X, e.Y)); if (node == null) { return; } NDataPoint dataPoint = node as NDataPoint; if (dataPoint != null) { m_SelectedSeries = dataPoint.ParentNode as NSeries; } }
private void NChartControl1_Click(object sender, EventArgs e) { NPostbackEventArgs eventArgs = e as NPostbackEventArgs; object selectedObject = eventArgs.Id.FindInDocument(nChartControl1.Document); if (selectedObject is NDataPoint) { NDataPoint dataPoint = (NDataPoint)selectedObject; dataPoint[DataPointValue.FillStyle] = new NColorFillStyle(Color.Red); NSeries series = (NSeries)dataPoint.ParentNode; series.StoreDataPoint(dataPoint.IndexInSeries, dataPoint); return; } if (selectedObject is NLabel) { ((NLabel)selectedObject).TextStyle.FillStyle = new NColorFillStyle(Color.Red); return; } if (selectedObject is NLegend) { ((NLegend)selectedObject).FillStyle = new NColorFillStyle(Color.Red); return; } if (selectedObject is NLegendItemCellData) { NLegendItemCellData licd = selectedObject as NLegendItemCellData; NLegend legend = nChartControl1.Legends[0]; SelectDataItem(legend.Data.Items.IndexOf(licd)); return; } if (selectedObject is NChartWall) { ((NChartWall)selectedObject).FillStyle = new NColorFillStyle(Color.Red); return; } if (selectedObject is NAxisStripe) { ((NAxisStripe)selectedObject).FillStyle = new NColorFillStyle(Color.Red); return; } if (selectedObject is NAxis) { NAxis axis = selectedObject as NAxis; NStandardScaleConfigurator scaleConfigurator = (NStandardScaleConfigurator)axis.ScaleConfigurator; scaleConfigurator.RulerStyle.BorderStyle.Color = Color.Red; scaleConfigurator.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.Red); } }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Series Appearance Attributes"); 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)); // no legend nChartControl1.Legends.Clear(); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Enable3D = true; m_Chart.Axis(StandardAxis.Depth).Visible = false; // apply lighting and projectection m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalHalf); // add interlaced stripe to the Y axis NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); stripStyle.Interlaced = true; ((NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle); // setup bar series m_Bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); m_Bar.DataLabelStyle.Visible = false; m_Bar.FillStyle = new NColorFillStyle(LightGreen); m_Bar.Name = "Bar"; // fill data m_Bar.AddDataPoint(new NDataPoint(10)); m_Bar.AddDataPoint(new NDataPoint(20)); m_Bar.AddDataPoint(new NDataPoint(30)); // set an individual Fill Style and Stroke Style for data point #3 NDataPoint dp = new NDataPoint(25); dp[DataPointValue.FillStyle] = new NGradientFillStyle(LightOrange, DarkOrange); dp[DataPointValue.StrokeStyle] = new NStrokeStyle(1, DarkOrange, LinePattern.Dot, 0, 1); m_Bar.AddDataPoint(dp); m_Bar.AddDataPoint(new NDataPoint(29)); m_Bar.AddDataPoint(new NDataPoint(27)); // apply layout ConfigureStandardLayout(m_Chart, title, null); }
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); }
private void ChartTypeComboBox_SelectedIndexChanged(object sender, System.EventArgs e) { m_Chart.Series.Clear(); NXYScatterSeries series = null; switch (ChartTypeComboBox.SelectedIndex) { case 0: // point series = (NXYScatterSeries)m_Chart.Series.Add(SeriesType.Point); series.Name = "Point series"; break; case 1: // line series = (NXYScatterSeries)m_Chart.Series.Add(SeriesType.Line); series.Name = "Line series"; series.MarkerStyle.Visible = true; break; case 2: // smooth line series = (NXYScatterSeries)m_Chart.Series.Add(SeriesType.SmoothLine); series.Name = "Smooth line series"; series.MarkerStyle.Visible = true; ((NSmoothLineSeries)series).Use1DInterpolationForXYScatter = false; break; case 3: // bar series = (NXYScatterSeries)m_Chart.Series.Add(SeriesType.Bar); series.Name = "Bar series"; series.MarkerStyle.Visible = false; break; default: Debug.Assert(false); break; } series.DataLabelStyle.Visible = false; NDataPoint dp = new NDataPoint(); series.UseXValues = true; for (int i = 0; i < 10; i++) { dp[DataPointValue.Y] = Random.Next(100); dp[DataPointValue.X] = Random.Next(100); dp[DataPointValue.Label] = "Item" + i.ToString(); series.AddDataPoint(dp); } nChartControl1.Refresh(); }
private void NChartControl2_Click(object sender, EventArgs e) { NChart chart = nChartControl2.Charts[0]; NPostbackEventArgs eventArgs = (NPostbackEventArgs)e; NDataPoint dp = eventArgs.Id.FindInDocument(nChartControl2.Document) as NDataPoint; if (dp != null) { int dataItemID = dp.IndexInSeries; NPieSeries pie = (NPieSeries)chart.Series[0]; pie.Detachments[dataItemID] = 10; } }
protected void ChangeData() { m_Bar.ClearDataPoints(); NDataPoint dp = new NDataPoint(); for (int i = 0; i < m_nBarCount; i++) { dp[DataPointValue.Value] = m_nBarCount / 2 - Random.Next(m_nBarCount); m_Bar.AddDataPoint(dp); } nChartControl1.Refresh(); }
protected void ChangeData() { int nBarCount = 10; NBarSeries bar = (NBarSeries)nChartControl1.Charts[0].Series[0]; bar.ClearDataPoints(); NDataPoint dp = new NDataPoint(); for (int i = 0; i < nBarCount; i++) { dp[DataPointValue.Value] = nBarCount / 2 - Random.Next(nBarCount); bar.AddDataPoint(dp); } }
private void GenerateDateTimeData(NLineSeries s, int nCount) { s.ClearDataPoints(); DateTime dateTime = DateTime.Now.AddMilliseconds(-nCount * nChartControl1.AsyncRefreshInterval); double dPrev = 100; double value; NDataPoint dataPoint; for (int i = 0; i < nCount; i++) { GenerateDataPoint(dPrev, new NRange1DD(50, 350), out value); dataPoint = new NDataPoint(value); s.AddDataPoint(dataPoint); dPrev = (double)s.Values[s.Values.Count - 1]; dateTime = dateTime.AddMilliseconds(nChartControl1.AsyncRefreshInterval); s.XValues.Add(dateTime); } }
/// <summary> /// /// </summary> /// <param name="arg"></param> void OnResetColorsButtonClick(NEventArgs arg) { int seriesCount = m_Chart.Series.Count; for (int i = 0; i < seriesCount; i++) { NSeries series = m_Chart.Series[i]; int dataPointCount = series.GetDataPointsChild().GetChildrenCount(); for (int j = 0; j < dataPointCount; j++) { NDataPoint dataPoint = (NDataPoint)series.GetDataPointsChild().GetChildAt(j); dataPoint.ClearLocalValue(NDataPoint.FillProperty); dataPoint.ClearLocalValue(NDataPoint.StrokeProperty); } } }
protected void nChartControl1_AsyncMouseOver(object sender, EventArgs e) { NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs; if (args.ItemId == null) { return; } NElementAtomIdentifier id = new NElementAtomIdentifier(args.ItemId); NDataPoint dataPoint = id.FindInDocument(nChartControl1.Document) as NDataPoint; if (dataPoint == null) { return; } NRootPanel rootPanel = nChartControl1.Document.RootPanel; NPieSeries pieSeries = rootPanel.Charts[0].Series[0] as NPieSeries; pieSeries.FillStyles[dataPoint.IndexInSeries] = new NColorFillStyle(Color.White); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Data Pan Tool<br/><font size = '12pt'>Demonstrates how to configure scrollbars with sliders and to enable data panning</font>"); header.DockMode = PanelDockMode.Top; header.Margins = new NMarginsL(10, 10, 10, 10); header.TextStyle.TextFormat = TextFormat.XML; header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); nChartControl1.Panels.Add(header); // configure the chart NCartesianChart chart = new NCartesianChart(); chart.DockMode = PanelDockMode.Fill; chart.Margins = new NMarginsL(10, 0, 10, 10); chart.Axis(StandardAxis.Depth).Visible = false; chart.BoundsMode = BoundsMode.Stretch; nChartControl1.Panels.Add(chart); // add some dummy data NPointSeries pointSeries = (NPointSeries)chart.Series.Add(SeriesType.Point); pointSeries.UseXValues = true; pointSeries.Name = "Point Series"; pointSeries.BorderStyle.Width = new NLength(1, NGraphicsUnit.Pixel);; pointSeries.BorderStyle.Color = Color.DarkRed; pointSeries.DataLabelStyle.Visible = false; pointSeries.Size = new NLength(5, NGraphicsUnit.Point); NDataPoint dp = new NDataPoint(); // add xy values for (int i = 0; i < 200; i++) { dp[DataPointValue.X] = Random.Next(100); dp[DataPointValue.Y] = Random.Next(100); dp[DataPointValue.Label] = "Item" + i.ToString(); pointSeries.AddDataPoint(dp); } // configure chart axes // set the primary X axis in FixedPageSize mode double pageSize = 10; NAxis primaryX = chart.Axis(StandardAxis.PrimaryX); NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // add an interlaced strip to the Y axis NScaleStripStyle xInterlacedStrip = new NScaleStripStyle(); xInterlacedStrip.SetShowAtWall(ChartWallType.Back, true); xInterlacedStrip.FillStyle = new NColorFillStyle(Color.FromArgb(40, Color.LightGray)); linearScale.StripStyles.Add(xInterlacedStrip); primaryX.ScaleConfigurator = linearScale; NNumericAxisPagingView xPagingView = new NNumericAxisPagingView(new NRange1DD(0, pageSize)); xPagingView.MinPageLength = 1.0; primaryX.PagingView = xPagingView; primaryX.ScrollBar.Visible = true; primaryX.ScrollBar.ViewRangeChanged += new EventHandler(OnXViewRangeChanged); // set the primary Y axis in FixedPageSize mode NAxis primaryY = chart.Axis(StandardAxis.PrimaryY); linearScale = new NLinearScaleConfigurator(); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // add an interlaced strip to the Y axis NScaleStripStyle yInterlacedStrip = new NScaleStripStyle(); yInterlacedStrip.SetShowAtWall(ChartWallType.Back, true); yInterlacedStrip.FillStyle = new NColorFillStyle(Color.FromArgb(40, Color.LightGray)); linearScale.StripStyles.Add(yInterlacedStrip); primaryY.ScaleConfigurator = linearScale; NNumericAxisPagingView yPagingView = new NNumericAxisPagingView(new NRange1DD(0, pageSize)); yPagingView.MinPageLength = 1.0; primaryY.PagingView = yPagingView; primaryY.ScrollBar.Visible = true; primaryY.ScrollBar.ViewRangeChanged += new EventHandler(OnYViewRangeChanged); // disable the reset button chart.Axis(StandardAxis.PrimaryX).ScrollBar.ResetButton.Visible = false; chart.Axis(StandardAxis.PrimaryY).ScrollBar.ResetButton.Visible = false; m_DataPanTool = new NDataPanTool(); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(m_DataPanTool); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); m_DataPanTool.Cancel += new EventHandler(OnCancel); // init form controls XAxisPageSizeNumericUpDown.Value = (decimal)10; YAxisPageSizeNumericUpDown.Value = (decimal)10; ShowScrollbarSlidersCheckBox.Checked = true; RepaintChartWhileDraggingCheckBox.Checked = m_DataPanTool.RepaintChartWhileDragging; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithColorNames(GroupedPieColorDropDownList); GroupedPieColorDropDownList.SelectedIndex = 20; // init form controls ThresholdValueTextBox.Text = "34"; GroupedPieLabelTextBox.Text = "Other"; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Grouped Pie Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.ContentAlignment = ContentAlignment.BottomRight; title.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup legend NLegend legend = nChartControl1.Legends[0]; legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterLeftBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterRightBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterTopBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.FillStyle.SetTransparencyPercent(70); legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.VerticalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); // by default the control contains a Cartesian chart -> remove it and create a Pie chart NChart chart = new NPieChart(); nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(chart); chart.Enable3D = true; chart.DisplayOnLegend = nChartControl1.Legends[0]; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated); chart.BoundsMode = BoundsMode.Fit; 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)); // setup pie series NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie); pie.Legend.Mode = SeriesLegendMode.None; pie.PieStyle = PieStyle.SmoothEdgePie; int count = 10; pie.Values.FillRandomRange(Random, count, 1, 100); for (int i = 0; i < count; i++) { pie.Detachments.Add(0); pie.Labels.Add(arrLabels[i]); pie.FillStyles[i] = arrCustomColors2[i % arrCustomColors2.Length]; } if (GroupPiesCheckBox.Checked == true) { try { Color groupColor = WebExamplesUtilities.ColorFromDropDownList(GroupedPieColorDropDownList); double dGroupValue = Int32.Parse(ThresholdValueTextBox.Text); // get a subset containing the pies which are smaller than the specified value NDataSeriesSubset smallerThanValue = pie.Values.Filter(Nevron.Chart.CompareMethod.Less, dGroupValue); // determine the sum of the filtered pies double dOtherSliceValue = pie.Values.Evaluate("SUM", smallerThanValue); // remove the data points contained in the for (int i = pie.GetDataPointCount(); i >= 0; i--) { if (smallerThanValue.Contains(i)) { pie.RemoveDataPointAt(i); } } // add a detached pie with the specified group label and color NDataPoint dp = new NDataPoint(dOtherSliceValue, GroupedPieLabelTextBox.Text); dp[DataPointValue.PieDetachment] = 1.0; dp[DataPointValue.FillStyle] = new NColorFillStyle(groupColor); dp[DataPointValue.StrokeStyle] = new NStrokeStyle(1, groupColor); pie.AddDataPoint(dp); } catch { } } else { } }