public override void Initialize() { base.Initialize(); nChartControl1.Controller.Tools.Add(new NTrackballTool()); nChartControl1.Panels.Clear(); m_Header = new NLabel("Nevron Chart for .NET"); m_Header.DockMode = PanelDockMode.Top; m_Header.ContentAlignment = ContentAlignment.MiddleCenter; m_Header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); m_Header.TextStyle.FillStyle = new NGradientFillStyle(Color.LightBlue, Color.DarkBlue); m_Header.TextStyle.BackplaneStyle.Visible = true; m_Header.TextStyle.BackplaneStyle.FillStyle.SetTransparencyPercent(50); m_Header.TextStyle.BorderStyle.Width = new NLength(1); m_Header.TextStyle.BorderStyle.Color = Color.LightBlue; m_Header.Margins = new NMarginsL(0, 10, 0, 10); nChartControl1.Panels.Add(m_Header); m_Footer = new NLabel("Copyright 1998 - 2011"); m_Footer.DockMode = PanelDockMode.Bottom; m_Footer.TextStyle.FontStyle = new NFontStyle("Times New Roman", 12, FontStyle.Italic); m_Footer.ContentAlignment = ContentAlignment.MiddleLeft; m_Footer.TextStyle.FontStyle.EmSize = new NLength(9, NGraphicsUnit.Point); m_Footer.TextStyle.FillStyle = new NGradientFillStyle(Color.LightBlue, Color.DarkBlue); m_Footer.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; m_Footer.Margins = new NMarginsL(0, 10, 0, 10); nChartControl1.Panels.Add(m_Footer); NCartesianChart chart = new NCartesianChart(); chart.Axis(StandardAxis.Depth).Visible = false; chart.BoundsMode = BoundsMode.Stretch; chart.DockMode = PanelDockMode.Fill; chart.DockMargins = new NMarginsL(20, 20, 20, 20); NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant2, Color.DarkRed, Color.Red); bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); bar.DataLabelStyle.Visible = false; bar.ShadowStyle.Type = ShadowType.GaussianBlur; bar.ShadowStyle.Offset = new NPointL(3, 3); bar.ShadowStyle.Color = Color.FromArgb(80, 0, 0, 0); bar.ShadowStyle.FadeLength = new NLength(5); bar.Values.AddRange(monthValues); nChartControl1.Panels.Add(chart); HeaderTextBox.Text = m_Header.Text; FooterTextBox.Text = m_Footer.Text; nChartControl1.Refresh(); }
private void TextFillStyleButton_Click(object sender, System.EventArgs e) { NLabel label = nChartControl1.Labels[0]; NFillStyle fillStyleResult; if (NFillStyleTypeEditor.Edit(label.TextStyle.FillStyle, out fillStyleResult)) { label.TextStyle.FillStyle = fillStyleResult; nChartControl1.Refresh(); } }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Panel Zoom Tool"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 25.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); // setup axes NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); ordinalScale.DisplayDataPointsBetweenTicks = false; ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); ordinalScale.DisplayDataPointsBetweenTicks = false; // add the surface series NGridSurfaceSeries surface = (NGridSurfaceSeries)chart.Series.Add(SeriesType.GridSurface); surface.Name = "Surface"; surface.FillMode = SurfaceFillMode.None; surface.FrameMode = SurfaceFrameMode.Mesh; surface.Data.SetGridSize(30, 30); surface.SyncPaletteWithAxisScale = false; surface.ValueFormatter.FormatSpecifier = "0.00"; FillData(surface); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); m_PanelZoomTool = new NPanelZoomTool(); nChartControl1.Controller.Selection.SelectedObjects.Add(chart); nChartControl1.Controller.Tools.Add(m_PanelZoomTool); PreserveAspectRatioCheckBox.Checked = true; ZoomInBoundsOnlyCheckBox.Checked = true; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = new NLabel("Heat Map"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // create the heat map (will be updated on timer tick) m_HeatMap = new NHeatMapSeries(); m_HeatMap.Data.SetGridSize(m_SizeX, m_SizeY); m_HeatMap.Data.SetValues(double.NaN); m_HeatMap.Legend.Mode = SeriesLegendMode.SeriesLogic; // used to display palette information m_HeatMap.Legend.PaletteLegendMode = PaletteLegendMode.GradientAxis; m_HeatMap.Legend.PaletteScaleStepMode = PaletteScaleStepMode.SynchronizeWithScaleConfigurator; NNumericScaleConfigurator numericScale = m_HeatMap.Legend.PaletteScaleConfigurator as NNumericScaleConfigurator; numericScale.MajorTickMode = MajorTickMode.CustomStep; numericScale.CustomStep = 10; m_HeatMap.Palette.Mode = PaletteMode.AutoMinMaxColor; m_HeatMap.Palette.PositiveColor = Color.FromArgb(125, Color.Red); m_HeatMap.Palette.ZeroColor = Color.FromArgb(125, Color.Blue); m_HeatMap.Palette.SmoothPalette = true; chart.Series.Add(m_HeatMap); // add background image NRangeSeries range = new NRangeSeries(); range.UseXValues = true; range.DataLabelStyle.Visible = false; range.Legend.Mode = SeriesLegendMode.None; range.Values.Add(0); range.Y2Values.Add(m_SizeY); range.XValues.Add(0); range.X2Values.Add(m_SizeX); Bitmap bitmap = NResourceHelper.BitmapFromResource(this.GetType(), "USMap.png", "Nevron.Examples.Chart.Wpf.Resources.Images"); range.FillStyle = new NImageFillStyle(bitmap); chart.Series.Add(range); this.StartTimer(); ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = new NLabel("2D Vector Field"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // no legend nChartControl1.Legends.Clear(); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = false; chart.Width = 55.0f; chart.Height = 55.0f; // setup X axis NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale.RoundToTickMin = false; linearScale.RoundToTickMax = false; linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { }; linearScale.InnerMajorTickStyle.Visible = false; // setup Y axis linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; linearScale.RoundToTickMin = false; linearScale.RoundToTickMax = false; linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { }; linearScale.InnerMajorTickStyle.Visible = false; // setup shape series NVectorSeries vectorSeries = (NVectorSeries)chart.Series.Add(SeriesType.Vector); vectorSeries.FillStyle = new NColorFillStyle(Color.Red); vectorSeries.BorderStyle.Color = Color.DarkRed; vectorSeries.DataLabelStyle.Visible = false; vectorSeries.InflateMargins = true; vectorSeries.UseXValues = true; vectorSeries.MinArrowHeadSize = new NSizeL(2, 3); vectorSeries.MaxArrowHeadSize = new NSizeL(4, 6); // fill data FillData(vectorSeries); // apply layout ConfigureStandardLayout(chart, title, null); }
private void CreateSampleChart() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Tracking Mouse Events"); 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 = nChartControl1.Charts[0]; // add interlace stripe NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); // apply lighting and projection chart.Enable3D = true; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); // add line series NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.Name = "Line"; line.LineSegmentShape = LineSegmentShape.Tape; line.DataLabelStyle.Visible = false; line.Values.FillRandomRange(Random, 10, 10, 30); // add bar series NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Name = "Bar"; bar.DataLabelStyle.Visible = false; bar.Values.FillRandomRange(Random, 10, 40, 60); // add area series NAreaSeries area = (NAreaSeries)chart.Series.Add(SeriesType.Area); area.Name = "Area"; area.DataLabelStyle.Visible = false; area.Values.FillRandomRange(Random, 10, 60, 100); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); nChartControl1.Refresh(); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Ternary Point Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); NLegend legend = new NLegend(); nChartControl1.Panels.Add(legend); // setup chart NTernaryChart ternaryChart = new NTernaryChart(); nChartControl1.Panels.Add(ternaryChart); ternaryChart.DisplayOnLegend = legend; ConfigureAxis(ternaryChart.Axis(StandardAxis.TernaryA)); ConfigureAxis(ternaryChart.Axis(StandardAxis.TernaryB)); ConfigureAxis(ternaryChart.Axis(StandardAxis.TernaryC)); m_Point = new NTernaryPointSeries(); ternaryChart.Series.Add(m_Point); // setup point series m_Point.Name = "Ternary Point Series"; Random rand = new Random(); for (int i = 0; i < 20; i++) { // will be automatically normalized so that the sum of a, b, c value is 100 double aValue = rand.Next(100); double bValue = rand.Next(100); double cValue = rand.Next(100); m_Point.AValues.Add(aValue); m_Point.BValues.Add(bValue); m_Point.CValues.Add(cValue); } // apply layout ConfigureStandardLayout(ternaryChart, title, legend); // init form controls PointStyleCombo.FillFromEnum(typeof(PointShape)); PointStyleCombo.SelectedIndex = 0; DifferentColorsCheck.Checked = true; PointSizeScroll.Value = 3; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = new NLabel("3D Step Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // no legend nChartControl1.Legends.Clear(); // configure the chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 65; chart.Height = 40; chart.Axis(StandardAxis.Depth).Visible = false; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); m_Line = (NStepLineSeries)chart.Series.Add(SeriesType.StepLine); m_Line.Name = "Series 1"; m_Line.DepthPercent = 50; m_Line.LineSize = 2; m_Line.DataLabelStyle.Visible = false; m_Line.DataLabelStyle.Format = "<value>"; m_Line.MarkerStyle.Visible = true; m_Line.Values.FillRandom(Random, 8); // apply layout ConfigureStandardLayout(chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); LineStyleCombo.FillFromEnum(typeof(LineSegmentShape)); LineStyleCombo.SelectedIndex = 1; RoundToTickCheck.Checked = true; InflateMarginsCheck.Checked = true; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Cluster Bar Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalHalf); m_Chart.Axis(StandardAxis.Depth).Visible = false; // add interlace stripe NLinearScaleConfigurator linearScale = m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); // add a bar series m_Bar1 = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); m_Bar1.Name = "Bar1"; m_Bar1.MultiBarMode = MultiBarMode.Series; m_Bar1.DataLabelStyle.Format = "<value>"; m_Bar1.Values.ValueFormatter = new NNumericValueFormatter("0.###"); // add another bar series m_Bar2 = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); m_Bar2.Name = "Bar2"; m_Bar2.MultiBarMode = MultiBarMode.Clustered; m_Bar2.DataLabelStyle.Format = "<value>"; m_Bar2.Values.ValueFormatter = new NNumericValueFormatter("0.###"); // fill with random data m_Bar1.Values.FillRandomRange(Random, 5, 10, 100); m_Bar2.Values.FillRandomRange(Random, 5, 10, 500); // apply layout ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); NExampleHelpers.FillComboWithEnumValues(BarStyleComboBox, typeof(BarShape)); BarStyleComboBox.SelectedIndex = 0; }
protected NLabel CreateGaugeLabel(string text) { NLabel label = new NLabel(text); label.TextStyle.FillStyle = new NColorFillStyle(Color.White); label.TextStyle.FontStyle.EmSize = new NLength(8); label.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); label.ContentAlignment = ContentAlignment.TopCenter; label.BoundsMode = BoundsMode.Fit; return(label); }
/// <summary> /// Initializing constructor. /// </summary> /// <param name="content"></param> public NExampleCategoryHeader(string text) { Box1 = CreateHomeButton(); NLabel label = new NLabel(text); label.Cursor = new NCursor(ENPredefinedCursor.Hand); label.HorizontalPlacement = ENHorizontalPlacement.Center; label.VerticalPlacement = ENVerticalPlacement.Center; label.MouseUp += OnLabelMouseUp; Box2 = label; }
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; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Sum"); 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 chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); // add a line series for the function m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line.MarkerStyle.Visible = true; m_Line.MarkerStyle.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); m_Line.MarkerStyle.FillStyle = new NColorFillStyle(Color.Crimson); m_Line.BorderStyle.Color = Color.Red; m_Line.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel); m_Line.Legend.Mode = SeriesLegendMode.None; m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.00"); m_Line.DisplayOnAxis(StandardAxis.PrimaryX, false); m_Line.DisplayOnAxis(StandardAxis.SecondaryX, true); // add the bar series m_Bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); m_Bar.Name = "Bar1"; m_Bar.Values.Name = "values"; m_Bar.Values.ValueFormatter = new NNumericValueFormatter("0.00"); m_Bar.MultiBarMode = MultiBarMode.Series; m_Bar.DataLabelStyle.Visible = false; m_Bar.Legend.Mode = SeriesLegendMode.DataPoints; m_Bar.BarShape = BarShape.SmoothEdgeBar; m_Bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);; m_Bar.FillStyle = new NColorFillStyle(Color.Orange); m_Bar.Values.FillRandomRange(Random, 12, 0, 50); // set the function argument m_FuncCalculator.Arguments.Add(m_Bar.Values); // form controls m_GroupingCombo.Items.Add("Do not group"); m_GroupingCombo.Items.Add("Group by every 2 values"); m_GroupingCombo.Items.Add("Group by every 3 values"); m_GroupingCombo.Items.Add("Group by every 4 values"); m_GroupingCombo.SelectedIndex = 0; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = new NLabel("2D Step Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); // no legend nChartControl1.Legends.Clear(); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; NLinearScaleConfigurator linearScale = m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); m_StepLine = (NStepLineSeries)m_Chart.Series.Add(SeriesType.StepLine); m_StepLine.Name = "Series 1"; m_StepLine.BorderStyle.Color = Color.SlateBlue; m_StepLine.BorderStyle.Width = new NLength(2); m_StepLine.DataLabelStyle.VertAlign = VertAlign.Center; m_StepLine.DataLabelStyle.Format = "<value>"; m_StepLine.DataLabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.White); m_StepLine.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(1.4f, NRelativeUnit.RootPercentage); m_StepLine.DataLabelStyle.TextStyle.BackplaneStyle.Visible = false; m_StepLine.MarkerStyle.Visible = true; m_StepLine.MarkerStyle.PointShape = PointShape.Cylinder; m_StepLine.MarkerStyle.BorderStyle.Color = Color.SlateBlue; m_StepLine.ShadowStyle.Type = ShadowType.GaussianBlur; m_StepLine.ShadowStyle.Offset = new NPointL(3, 3); m_StepLine.ShadowStyle.FadeLength = new NLength(5); m_StepLine.ShadowStyle.Color = Color.FromArgb(55, 0, 0, 0); m_StepLine.Values.FillRandom(Random, 8); // apply layout ConfigureStandardLayout(m_Chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); LeftAxisRoundToTickCheckBox.IsChecked = true; InflateMarginsCheckBox.IsChecked = true; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("2D Point Chart Droplines"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // setup chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // add interlace stripe NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); // setup point series m_Point = (NPointSeries)chart.Series.Add(SeriesType.Point); m_Point.Name = "Point Series"; m_Point.InflateMargins = true; m_Point.UseXValues = true; m_Point.Size = new NLength(10, NGraphicsUnit.Point); m_Point.DataLabelStyle.Visible = false; for (int i = 0; i < 360; i += 5) { double value = Math.Sin(NMath.Degree2Rad * i) * 20; m_Point.XValues.Add(i); m_Point.Values.Add(value); } // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); // init form controls ShowVerticalDropLinesCheckBox.Checked = true; HorizontalDropLinesOriginUpDown.Value = 0; VerticalDropLinesOriginModeComboBox.FillFromEnum(typeof(DropLineOriginMode)); VerticalDropLinesOriginModeComboBox.SelectedIndex = (int)DropLineOriginMode.ScaleMin; ShowHorizontalDropLinesCheckBox.Checked = true; VerticalDropLinesOriginUpDown.Value = 0; HorizontalDropLinesOriginModeComboBox.FillFromEnum(typeof(DropLineOriginMode)); HorizontalDropLinesOriginModeComboBox.SelectedIndex = (int)DropLineOriginMode.ScaleMin; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // remove all legends nChartControl1.Legends.Clear(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Renko Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); NChart chart = nChartControl1.Charts[0]; // setup X axis NPriceScaleConfigurator priceConfigurator = new NPriceScaleConfigurator(); priceConfigurator.InnerMajorTickStyle.LineStyle.Width = new NLength(0); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = priceConfigurator; // setup Y axis NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.StripStyles.Add(stripStyle); // setup Renko series NRenkoSeries renko = (NRenkoSeries)chart.Series.Add(SeriesType.Renko); renko.UseXValues = true; GenerateData(renko); // apply layout ConfigureStandardLayout(chart, title, null); BoxSizeComboBox.Items.Add("0.5"); BoxSizeComboBox.Items.Add("1"); BoxSizeComboBox.Items.Add("2"); BoxSizeComboBox.Items.Add("2%"); BoxSizeComboBox.Items.Add("5%"); BoxSizeComboBox.Items.Add("10%"); BoxWidthPercentComboBox.Items.Add("50%"); BoxWidthPercentComboBox.Items.Add("75%"); BoxWidthPercentComboBox.Items.Add("100%"); BoxSizeComboBox.SelectedIndex = 1; BoxWidthPercentComboBox.SelectedIndex = 2; }
protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Gauge Labels Orientation"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.Location = new NPointL(new NLength(3, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); nChartControl1.Panels.Add(header); // create the radial gauge CreateRadialGauge(); // update form controls if (!IsPostBack) { angleModeDropDownList.Items.Add("View"); angleModeDropDownList.Items.Add("Scale"); angleModeDropDownList.SelectedIndex = 1; BeginAngleTextBox.Text = "90"; SweepAngleTextBox.Text = "270"; allowFlipCheckBox.Checked = false; } UpdateScaleLabelAngle(); // apply begin and sweep angles float beginAngle; if (!float.TryParse(BeginAngleTextBox.Text, out beginAngle)) { beginAngle = 0f; CustomAngleTextBox.Text = beginAngle.ToString(); } m_RadialGauge.BeginAngle = beginAngle; float sweepAngle; if (!float.TryParse(SweepAngleTextBox.Text, out sweepAngle)) { sweepAngle = 270; SweepAngleTextBox.Text = sweepAngle.ToString(); } m_RadialGauge.SweepAngle = sweepAngle; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { nChartControl1.Panels.Clear(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Ternary Bubble Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); NLegend legend = new NLegend(); nChartControl1.Panels.Add(legend); // setup chart NTernaryChart ternaryChart = new NTernaryChart(); nChartControl1.Panels.Add(ternaryChart); ternaryChart.DisplayOnLegend = legend; ConfigureAxis(ternaryChart.Axis(StandardAxis.TernaryA)); ConfigureAxis(ternaryChart.Axis(StandardAxis.TernaryB)); ConfigureAxis(ternaryChart.Axis(StandardAxis.TernaryC)); // add a bubble series NTernaryBubbleSeries bubbleSeries = new NTernaryBubbleSeries(); ternaryChart.Series.Add(bubbleSeries); bubbleSeries.DataLabelStyle.VertAlign = VertAlign.Center; bubbleSeries.DataLabelStyle.Visible = false; bubbleSeries.Legend.Mode = SeriesLegendMode.DataPoints; bubbleSeries.MinSize = new NLength(2.0f, NGraphicsUnit.Point); bubbleSeries.MaxSize = new NLength(20, NGraphicsUnit.Point); bubbleSeries.Legend.Mode = SeriesLegendMode.DataPoints; bubbleSeries.Legend.Format = "<size>"; Random rand = new Random(); for (int i = 0; i < 20; i++) { // will be automatically normalized so that the sum of a, b, c value is 100 double aValue = rand.Next(100); double bValue = rand.Next(100); double cValue = rand.Next(100); bubbleSeries.AValues.Add(aValue); bubbleSeries.BValues.Add(bValue); bubbleSeries.CValues.Add(cValue); bubbleSeries.Sizes.Add(10 + rand.Next(90)); } // apply layout ConfigureStandardLayout(ternaryChart, title, nChartControl1.Legends[0]); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.HighSpeed; nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.None; nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // set a chart title NLabel title = new NLabel("Surface With Empty Data Points"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 25.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); // setup axes NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); ordinalScale.DisplayDataPointsBetweenTicks = false; ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); ordinalScale.DisplayDataPointsBetweenTicks = false; // add the surface series NGridSurfaceSeries surface = (NGridSurfaceSeries)chart.Series.Add(SeriesType.GridSurface); surface.Name = "Surface"; surface.Legend.Mode = SeriesLegendMode.SeriesLogic; surface.PositionValue = 10.0; surface.Data.SetGridSize(40, 40); surface.SyncPaletteWithAxisScale = false; surface.PaletteSteps = 8; surface.ValueFormatter.FormatSpecifier = "0.000"; surface.FillMode = SurfaceFillMode.ZoneTexture; FillData(surface); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); }
public override void Initialize() { base.Initialize(); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); nChartControl1.Legends.Clear(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Chart Walls"); 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(3, NRelativeUnit.ParentPercentage)); m_Chart = nChartControl1.Charts[0]; m_Chart.Enable3D = true; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); m_Chart.Axis(StandardAxis.Depth).Visible = false; // 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); NBarSeries bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); bar.Values.FillRandom(Random, 6); bar.Name = "Bars"; bar.DataLabelStyle.Visible = false; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); // init form controls LeftVisibleCheck.Checked = m_Chart.Wall(ChartWallType.Left).Visible; BackVisibleCheck.Checked = m_Chart.Wall(ChartWallType.Back).Visible; RightVisibleCheck.Checked = m_Chart.Wall(ChartWallType.Right).Visible; FloorVisibleCheck.Checked = m_Chart.Wall(ChartWallType.Floor).Visible; LeftWidthScroll.Value = 20; BackWidthScroll.Value = 20; RightWidthScroll.Value = 20; FloorWidthScroll.Value = 20; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Horizontal Bar 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)); // setup the chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterRight); chart.Width = 40; chart.Height = 65; chart.Axis(StandardAxis.PrimaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, true, 0, 100); chart.Axis(StandardAxis.Depth).Visible = false; // add interlace stripe to the Y axis NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); // add a bar series NBarSeries b1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); b1.MultiBarMode = MultiBarMode.Series; b1.Name = "Bar 1"; b1.DataLabelStyle.Format = "<value>"; b1.Legend.Mode = SeriesLegendMode.DataPoints; b1.Values.AddRange(new double[] { 10, 27, 43, 71, 89, 93 }); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); // init form controls StyleCombo.FillFromEnum(typeof(BarShape)); StyleCombo.SelectedIndex = 0; }
private NDockPanel CreateConceptCarReviewPanel() { NDockPanel dockPanel = new NDockPanel(); dockPanel.DockMode = PanelDockMode.Fill; m_ReviewLabel = new NLabel("Select concept car to review"); m_ReviewLabel.DockMode = PanelDockMode.Top; m_ReviewLabel.TextStyle.ShadowStyle.Type = ShadowType.Solid; m_ReviewLabel.TextStyle.FontStyle = new NFontStyle("Times New Roman", 20, FontStyle.Italic); m_ReviewLabel.TextStyle.FillStyle = new NGradientFillStyle(Nevron.GraphicsCore.GradientStyle.Horizontal, GradientVariant.Variant1, Color.DarkKhaki, Color.White); m_ReviewLabel.BoundsMode = BoundsMode.None; m_ReviewLabel.ContentAlignment = ContentAlignment.MiddleCenter; m_ReviewLabel.UseAutomaticSize = false; m_ReviewLabel.Size = new NSizeL( new NLength(100, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); dockPanel.ChildPanels.Add(m_ReviewLabel); // setup chart NChart chart = new NCartesianChart(); chart.Enable3D = true; chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Fit; chart.Padding = new NMarginsL(20, 20, 20, 20); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.Axis(StandardAxis.Depth).Visible = false; NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleX.AutoLabels = false; scaleX.Labels.Add("Design"); scaleX.Labels.Add("Functionality"); scaleX.Labels.Add("Price"); scaleX.Labels.Add("Speed"); NBarSeries bar = new NBarSeries(); chart.Series.Add(bar); bar.BarShape = BarShape.SmoothEdgeBar; bar.DataLabelStyle.Format = "<value>"; bar.Values.AddRange(new double[] { 0, 0, 0, 0 }); // apply predefined style sheet to the pie NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.CoolMultiColor).Apply(bar); dockPanel.ChildPanels.Add(chart); return(dockPanel); }
public override void Initialize() { base.Initialize(); nChartControl1.BackgroundStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.FromArgb(230, 230, 244)); // add label NLabel title = nChartControl1.Labels.AddHeader("Advanced Gradient Fill Style"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup chart and axes m_Chart = nChartControl1.Charts[0]; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective); m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.SoftTopLeft); m_Chart.Axis(StandardAxis.Depth).Visible = false; NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.LineStyle.Color = Color.White; linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.LineStyle.Color = Color.White; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); // set walls advanced gradient NAdvancedGradientFillStyle ag = AzureLight(); m_Chart.Wall(ChartWallType.Back).FillStyle = ag; m_Chart.Wall(ChartWallType.Left).FillStyle = ag; m_Chart.Wall(ChartWallType.Floor).FillStyle = ag; // create bubble chart m_Bubble = (NBubbleSeries)m_Chart.Series.Add(SeriesType.Bubble); m_Bubble.DataLabelStyle.Visible = false; m_Bubble.Legend.Mode = SeriesLegendMode.DataPoints; m_Bubble.BubbleShape = PointShape.Sphere; m_Bubble.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); m_Bubble.UseXValues = true; m_Bubble.InflateMargins = true; m_Bubble.FillStyle = TheEye(); GenerateData(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Axis Ticks"); 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)); // turn off the legend nChartControl1.Legends[0].Mode = LegendMode.Disabled; m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScale.MinorTickCount = 3; // add interlaced stripe 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; linearScale.StripStyles.Add(stripStyle); NBarSeries bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); bar.Values.FillRandom(Random, 5); bar.FillStyle = new NColorFillStyle(Color.DarkOrchid); bar.DataLabelStyle.Format = "<value>"; bar.Name = "Bars"; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); // init form controls OuterMajorTickLengthScrollBar.Value = (int)(linearScale.OuterMajorTickStyle.Length.Value); InnerMajorTickLengthScrollBar.Value = (int)(linearScale.InnerMajorTickStyle.Length.Value); OuterMinorTickLengthScrollBar.Value = (int)(linearScale.OuterMinorTickStyle.Length.Value); InnerMinorTickLengthScrollBar.Value = (int)(linearScale.InnerMinorTickStyle.Length.Value); ShowOuterMajorTicksCheckBox.Checked = true; ShowInnerMajorTicksCheckBox.Checked = true; ShowOuterMinorTicksCheckBox.Checked = true; ShowInnerMinorTicksCheckBox.Checked = true; }
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); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("XY Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; // add interlaced stripe to the Y axis NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); 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; linearScale.StripStyles.Add(stripStyle); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); // add the line m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line.LineSegmentShape = LineSegmentShape.Line; m_Line.DataLabelStyle.Visible = false; m_Line.Legend.Mode = SeriesLegendMode.DataPoints; m_Line.InflateMargins = true; m_Line.MarkerStyle.Visible = true; m_Line.MarkerStyle.PointShape = PointShape.Cylinder; m_Line.MarkerStyle.Width = new NLength(1.5f, NRelativeUnit.ParentPercentage); m_Line.MarkerStyle.Height = new NLength(1.5f, NRelativeUnit.ParentPercentage); m_Line.Name = "Line Series"; m_Line.UseXValues = true; // add xy values m_Line.AddDataPoint(new NDataPoint(15, 10)); m_Line.AddDataPoint(new NDataPoint(25, 23)); m_Line.AddDataPoint(new NDataPoint(45, 12)); m_Line.AddDataPoint(new NDataPoint(55, 21)); m_Line.AddDataPoint(new NDataPoint(61, 16)); m_Line.AddDataPoint(new NDataPoint(67, 19)); m_Line.AddDataPoint(new NDataPoint(72, 11)); // apply layout ConfigureStandardLayout(m_Chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); }
protected override NWidget CreateExampleControls() { NStackPanel stack = new NStackPanel(); stack.VerticalSpacing = 10; // Create the predefined tests list box NListBox testListBox = new NListBox(); testListBox.Items.Add(CreateTestListBoxItem(new NRichTextBorders())); testListBox.Items.Add(CreateTestListBoxItem(new NRichTextLists())); testListBox.Items.Add(CreateTestListBoxItem(new NRichTextTables())); testListBox.Items.Add(CreateTestListBoxItem(new NRichTextTextStyles())); testListBox.Items.Add(CreateTestListBoxItem(new NRichTextElementPositioning())); testListBox.Selection.Selected += OnTestListBoxItemSelected; // Add the list box in a group box stack.Add(new NGroupBox("Predefined text documents", testListBox)); // Create the Load from file group box NDockPanel dockPanel = new NDockPanel(); dockPanel.HorizontalSpacing = 3; dockPanel.VerticalSpacing = 3; NButton loadButton = new NButton("Load"); loadButton.Click += OnLoadButtonClick; NDockLayout.SetDockArea(loadButton, ENDockArea.Bottom); dockPanel.Add(loadButton); m_FileNameTextBox = new NTextBox(); m_FileNameTextBox.VerticalPlacement = ENVerticalPlacement.Center; NDockLayout.SetDockArea(m_FileNameTextBox, ENDockArea.Center); dockPanel.Add(m_FileNameTextBox); NButton browseButton = new NButton("..."); browseButton.Click += OnBrowseButtonClick; NDockLayout.SetDockArea(browseButton, ENDockArea.Right); dockPanel.Add(browseButton); stack.Add(new NGroupBox("Load from file", dockPanel)); m_ElapsedTimeLabel = new NLabel(); stack.Add(m_ElapsedTimeLabel); // Select the initial test testListBox.Selection.SingleSelect(testListBox.Items[0]); return(stack); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Axis Ticks Appearance"); 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)); // turn off the legend nChartControl1.Legends[0].Mode = LegendMode.Disabled; m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScale.OuterMajorTickStyle.FillStyle = new NColorFillStyle(Color.Red); // hide all tick except the outer major just to demonstrate the shape / fill / stroke control linearScale.InnerMajorTickStyle.Visible = false; linearScale.InnerMinorTickStyle.Visible = false; linearScale.OuterMinorTickStyle.Visible = false; // add interlaced stripe 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; linearScale.StripStyles.Add(stripStyle); NBarSeries bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); bar.Values.FillRandom(Random, 5); bar.FillStyle = new NColorFillStyle(Color.DarkOrchid); bar.DataLabelStyle.Format = "<value>"; bar.Name = "Bars"; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); TickShapeComboBox.FillFromEnum(typeof(ScaleTickShape)); TickShapeComboBox.SelectedIndex = (int)ScaleTickShape.Triangle; TickWidthScrollBar.Value = 4; TickHeightScrollBar.Value = 8; }
protected override NWidget CreateExampleControls() { NStackPanel stack = new NStackPanel(); for (int i = 0, count = m_PairBoxes.Length; i < count; i++) { // Create the pair box property editors NPairBox pairBox = m_PairBoxes[i]; NList <NPropertyEditor> editors = NDesigner.GetDesigner(pairBox).CreatePropertyEditors(pairBox, NPairBox.FillModeProperty, NPairBox.FitModeProperty ); NUniSizeBox box1 = (NUniSizeBox)pairBox.Box1; editors.Add(NDesigner.GetDesigner(box1).CreatePropertyEditor( box1, NUniSizeBox.UniSizeModeProperty )); NUniSizeBox box2 = (NUniSizeBox)pairBox.Box2; editors.Add(NDesigner.GetDesigner(box2).CreatePropertyEditor( box2, NUniSizeBox.UniSizeModeProperty )); // Create the properties stack panel NStackPanel propertyStack = new NStackPanel(); for (int j = 0, editorCount = editors.Count; j < editorCount; j++) { propertyStack.Add(editors[j]); } // Add the box 1 preferred height editor NPropertyEditor editor = NDesigner.GetDesigner(box1.Content).CreatePropertyEditor(box1.Content, NWidget.PreferredHeightProperty); NLabel label = editor.GetFirstDescendant <NLabel>(); label.Text = "Box 1 Preferred Height:"; propertyStack.Add(editor); // Add the box 2 preferred height editor editor = NDesigner.GetDesigner(box2.Content).CreatePropertyEditor(box2.Content, NWidget.PreferredHeightProperty); label = editor.GetFirstDescendant <NLabel>(); label.Text = "Box 2 Preferred Height:"; propertyStack.Add(editor); // Create a group box for the properties NGroupBox groupBox = new NGroupBox("Pair Box " + (i + 1).ToString()); groupBox.Content = propertyStack; stack.Add(groupBox); } return(new NUniSizeBoxGroup(stack)); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = new NLabel("Wafer Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // configure chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; m_HeatMap = new NHeatMapSeries(); chart.Series.Add(m_HeatMap); NHeatMapData data = m_HeatMap.Data; m_HeatMap.Palette.Mode = PaletteMode.AutoFixedEntryCount; m_HeatMap.Palette.AutoPaletteColors = new NArgbColorValue[] { new NArgbColorValue(Color.Green), new NArgbColorValue(Color.Red) }; m_HeatMap.Palette.SmoothPalette = true; int gridSizeX = 100; int gridSizeY = 100; data.SetGridSize(gridSizeX, gridSizeY); int centerX = gridSizeX / 2; int centerY = gridSizeY / 2; int radius = gridSizeX / 2; Random rand = new Random(); for (int y = 0; y < gridSizeY; y++) { for (int x = 0; x < gridSizeX; x++) { int dx = x - centerX; int dy = y - centerY; double pointDistance = Math.Sqrt(dx * dx + dy * dy); if (pointDistance < radius) { // assign value data.SetValue(x, y, pointDistance + rand.Next(20)); } else { data.SetValue(x, y, double.NaN); } } } }
/// <summary> /// Demonstrates polynomial least squares curve fitting /// </summary> void CurveFitting() { // Set up example description nRichDescription.Text = "A 4th degree polynomial is fitted to the noisy sampled data. \n\nFitting a polynomial of any degree is accomplished in one line of code specifing the polynomial degree, and arrays of the x and y values. "; // Build the data sets using some random normal noise DoubleVector x = new DoubleVector("[0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 2.1 2.2 2.3 2.4 2.5]"); DoubleVector y = new DoubleVector("[0 0.112462916018285 0.222702589210478 0.328626759459127 0.428392355046668 0.520499877813047 0.603856090847926 0.677801193837419 0.742100964707661 0.796908212422832 0.842700792949715 0.880205069574082 0.910313978229635 0.934007944940652 0.952285119762649 0.966105146475311 0.976348383344644 0.983790458590775 0.989090501635731 0.992790429235257 0.995322265018953 0.997020533343667 0.998137153702018 0.998856823402643 0.999311486103355 0.999593047982555]"); RandomNumberGenerator rand = new RandGenNormal(0.0, noiselevel_); y = y + 0.025 * (new DoubleVector(y.Length, rand)); // Build the least squares polynomial fit and make readable display label int polynomialdeg = 4; PolynomialLeastSquares pls = new PolynomialLeastSquares(polynomialdeg, x, y); // Build fitted polynomial DoubleVector xs = new DoubleVector(100, 0, 0.025); DoubleVector ys = pls.FittedPolynomial.Evaluate(xs); // Build the chart SetupChartLayout("Curve Fitting"); NChart chart = nChartControl1.Charts[0]; SetupChartAxes(chart); // Draw the raw data points NPointSeries point = new NPointSeries(); chart.Series.Add(point); point.UseXValues = true; point.DataLabelStyle.Visible = false; // set some appearance properties point.FillStyle = new NColorFillStyle(Color.SkyBlue); point.BorderStyle = new NStrokeStyle(1.0f, Color.DarkGray); point.PointShape = PointShape.Star; point.Size = new NLength(6.0f); // Points must fit in the chart area point.InflateMargins = true; // Name points data set point.Name = "Observations"; // Add data points from the NMath DoubleVectors to the point series point.Values.AddRange(y.DataBlock.Data); point.XValues.AddRange(x.DataBlock.Data); // Build polynomial line series and style it NLineSeries polyline = new NLineSeries(); chart.Series.Add(polyline); polyline.UseXValues = true; polyline.DataLabelStyle.Visible = false; polyline.BorderStyle = new NStrokeStyle(2.0f, Color.Tomato); // Name polynomial fit polyline.Name = polynomialdeg.ToString() + "th Degree Polynomial"; // Load the polynomial data into the line series polyline.XValues.AddRange(xs.DataBlock.Data); polyline.Values.AddRange(ys.DataBlock.Data); // Create a label to display the polynomial NLabel label = new NLabel(); label.BoundsMode = BoundsMode.None; label.ContentAlignment = ContentAlignment.MiddleLeft; label.Location = new NPointL( new NLength(92, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); label.TextStyle.TextFormat = TextFormat.XML; label.TextStyle.FontStyle = new NFontStyle("Arial", 9); label.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Center; label.TextStyle.BackplaneStyle.Visible = true; label.TextStyle.BackplaneStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(180, 255, 255, 255), Color.FromArgb(180, 233, 233, 255)); label.TextStyle.BackplaneStyle.Shape = BackplaneShape.Rectangle; label.TextStyle.BackplaneStyle.StandardFrameStyle.InnerBorderColor = Color.FromArgb(200, 200, 255); label.Text = "Equation for fitted polynomial:<br /><font size='10' color = 'tomato'><b>"; label.Text += FormatPolymonial(pls.FittedPolynomial.Coeff.ToArray()); label.Text += "</b></font>"; chart.ChildPanels.Add(label); nChartControl1.Refresh(); }
void SetupChartLayout(string titleText) { nChartControl1.Panels.Clear(); NLabel title = new NLabel(); nChartControl1.Panels.Add(title); title.Dock = DockStyle.Top; title.Padding = new NMarginsL(5, 8, 5, 4); title.Text = titleText; title.TextStyle.FontStyle = new NFontStyle("Verdana", 12, FontStyle.Bold | FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(68, 90, 108)); NLegend legend = new NLegend(); nChartControl1.Panels.Add(legend); legend.Dock = DockStyle.Bottom; legend.Data.ExpandMode = LegendExpandMode.ColsOnly; legend.Data.MarkSize = new NSizeL(new NLength(8), new NLength(8)); legend.Data.CellMargins = new NMarginsL(5, 3, 5, 3); legend.Padding = new NMarginsL(1, 1, 1, 7); NChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.DisplayOnLegend = legend; chart.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.FromArgb(233, 233, 255)); chart.BoundsMode = BoundsMode.Stretch; chart.Dock = DockStyle.Fill; chart.PositionChildPanelsInContentBounds = true; chart.Padding = new NMarginsL( new NLength(6, NRelativeUnit.ParentPercentage), new NLength(6, NRelativeUnit.ParentPercentage), new NLength(6, NRelativeUnit.ParentPercentage), new NLength(6, NRelativeUnit.ParentPercentage)); }
private void InitializeComponent() { /* * Window setup * */ this.Text = "Dagobar"; this.Size = new System.Drawing.Size(16 * windowCoeff, 9 * windowCoeff); this.MinimumSize = new System.Drawing.Size(this.Width / 2, this.Height / 2); #region "Controls Setup & Layout Setup" textBoxSend = new NTextBox(); textBoxSend.Font = new Nevron.Nov.Graphics.NFont("Lucidia Console", 12); textBoxSend.VerticalPlacement = Nevron.Nov.Layout.ENVerticalPlacement.Center; textBoxSend.Margins = new Nevron.Nov.Graphics.NMargins(1, 3, 0, 3); textBoxSend.KeyUp += textBoxSend_KeyUp; buttonSend = new NButton("Envoyer"); buttonSend.PreferredWidth = 100; buttonSend.Content.HorizontalPlacement = Nevron.Nov.Layout.ENHorizontalPlacement.Center; buttonSend.Margins = new Nevron.Nov.Graphics.NMargins(3.0); buttonSend.Click += buttonSend_Click; panelSend = new NStackPanel(); panelSend.Direction = Nevron.Nov.Layout.ENHVDirection.LeftToRight; panelSend.FillMode = Nevron.Nov.Layout.ENStackFillMode.First; panelSend.Add(textBoxSend); panelSend.Add(buttonSend); listBoxChat = new NListBox(); listBoxChat.Margins = new Nevron.Nov.Graphics.NMargins(1.0); panelChat = new NStackPanel(); panelChat.Direction = Nevron.Nov.Layout.ENHVDirection.TopToBottom; panelChat.FillMode = Nevron.Nov.Layout.ENStackFillMode.First; panelChat.Add(listBoxChat); panelChat.Add(panelSend); labelChannel = new NLabel("/--/"); labelChannel.HorizontalPlacement = Nevron.Nov.Layout.ENHorizontalPlacement.Center; labelChannel.Font = new Nevron.Nov.Graphics.NFont("Lucidia Console", 14); listBoxUsers = new NListBox(); listBoxUsers.Margins = new Nevron.Nov.Graphics.NMargins(1.0); panelUsers = new NStackPanel(); panelUsers.Direction = Nevron.Nov.Layout.ENHVDirection.TopToBottom; panelUsers.FillMode = Nevron.Nov.Layout.ENStackFillMode.Last; panelUsers.Add(labelChannel); panelUsers.Add(listBoxUsers); panelUsers.PreferredWidth = 150; panelTabChat = new NStackPanel(); panelTabChat.FillMode = Nevron.Nov.Layout.ENStackFillMode.First; panelTabChat.Direction = Nevron.Nov.Layout.ENHVDirection.LeftToRight; panelTabChat.Add(panelChat); panelTabChat.Add(panelUsers); panelMain = new NStackPanel(); panelMain.Direction = Nevron.Nov.Layout.ENHVDirection.LeftToRight; panelMain.FillMode = Nevron.Nov.Layout.ENStackFillMode.Last; panelMain.Add(panelTabChat); panelRibbonInformations = new NStackPanel(); panelRibbonInformations.FillMode = Nevron.Nov.Layout.ENStackFillMode.Equal; labelRibbonChannel = new NLabel("Chaîne : /--/"); labelRibbonChannel.HorizontalPlacement = Nevron.Nov.Layout.ENHorizontalPlacement.Center; labelRibbonViewers = new NLabel("Nombre de spectateurs : /--/"); labelRibbonViewers.HorizontalPlacement = Nevron.Nov.Layout.ENHorizontalPlacement.Center; labelRibbonVersion = new NLabel("Version : " + Properties.Settings.Default.Version); labelRibbonVersion.HorizontalPlacement = Nevron.Nov.Layout.ENHorizontalPlacement.Center; panelRibbonInformations.Add(labelRibbonChannel); panelRibbonInformations.Add(labelRibbonViewers); panelRibbonInformations.Add(labelRibbonVersion); ribbonGroupInformations = new NRibbonGroup("Informations"); ribbonGroupInformations.Header.DialogLauncherButton.Visibility = ENVisibility.Hidden; ribbonGroupInformations.PreferredHeight = 64; ribbonGroupInformations.Items.Add(panelRibbonInformations); listBoxPlugins = new NListBox(); listBoxPlugins.VScrollMode = ENScrollMode.Always; listBoxPlugins.PreferredHeight = 64; listBoxPlugins.PreferredWidth = 256; ribbonGroupPlugins = new NRibbonGroup("Plugins"); ribbonGroupPlugins.Header.DialogLauncherButton.Visibility = ENVisibility.Hidden; ribbonGroupPlugins.Items.Add(listBoxPlugins); ribbonButtonConfiguration = new NRibbonButton("Configuration", NImage.FromFile(Application.StartupPath + @"\Resources\settings.png"), NImage.FromFile(Application.StartupPath + @"\Resources\settings.png")); ribbonButtonConfiguration.PreferredWidth = 86; ribbonButtonConfiguration.Click += ribbonButtonConfiguration_Click; ribbonButtonChannel = new NRibbonButton("Changer de chaîne", NImage.FromFile(Application.StartupPath + @"\Resources\move_shit_around.png"), NImage.FromFile(Application.StartupPath + @"\Resources\move_shit_around.png")); ribbonButtonChannel.PreferredWidth = 86; ribbonButtonChannel.Click += ribbonButtonChannel_Click; ribbonButtonQuit = new NRibbonButton("Quitter", NImage.FromFile(Application.StartupPath + @"\Resources\quit.png"), NImage.FromFile(Application.StartupPath + @"\Resources\quit.png")); ribbonButtonQuit.PreferredWidth = 86; ribbonButtonQuit.Click += ribbonButtonQuit_Click; ribbonGroupActions = new NRibbonGroup("Actions"); ribbonGroupActions.Header.DialogLauncherButton.Visibility = ENVisibility.Hidden; ribbonGroupActions.Items.Add(ribbonButtonConfiguration); ribbonGroupActions.Items.Add(ribbonButtonChannel); ribbonGroupActions.Items.Add(ribbonButtonQuit); ribbonTagPageMain = new NRibbonTabPage("Dagobar"); ribbonTagPageMain.Groups.Add(ribbonGroupInformations); ribbonTagPageMain.Groups.Add(ribbonGroupPlugins); ribbonTagPageMain.Groups.Add(ribbonGroupActions); ribbon = new NRibbon(); ribbon.Tab.TabPages.Add(ribbonTagPageMain); panelRibbon = new NStackPanel(); panelRibbon.FillMode = Nevron.Nov.Layout.ENStackFillMode.Last; panelRibbon.Add(ribbon); panelRibbon.Add(panelMain); #endregion // Create main control controlMain = new NNovWidgetHost<NStackPanel>(panelRibbon); controlMain.Dock = DockStyle.Fill; }
internal void ApplyLayoutTemplate(int template, NChart chart, NLabel title, NLegend legend) { nChartControl1.Panels.Clear(); if (title != null) { nChartControl1.Panels.Add(title); title.Dock = DockStyle.Top; title.Padding = new NMarginsL(5, 8, 5, 4); } if (legend != null) { nChartControl1.Panels.Add(legend); legend.Dock = DockStyle.Right; legend.Padding = new NMarginsL(1, 1, 5, 5); } if (chart != null) { nChartControl1.Panels.Add(chart); float topPad = (title == null) ? 11 : 8; float rightPad = (legend == null) ? 11 : 4; if (chart.Enable3D || (chart.BoundsMode == BoundsMode.None)) { chart.BoundsMode = BoundsMode.Fit; } chart.Dock = DockStyle.Fill; chart.Padding = new NMarginsL( new NLength(11, NRelativeUnit.ParentPercentage), new NLength(topPad, NRelativeUnit.ParentPercentage), new NLength(rightPad, NRelativeUnit.ParentPercentage), new NLength(11, NRelativeUnit.ParentPercentage)); } }
/// <summary> /// Builds the attribute chart /// </summary> /// <param name="attributes">statistics for an attribute chart</param> private void BuildChart(IAttributeChartStats stats) { int nppoints = stats.Statistic.Length; double xstart = stats.TimeStart; double xincrement = stats.TimeSampleInterval; this.nControlChart.Panels.Clear(); // // Set up chart title. // NLabel title = new NLabel(); this.nControlChart.Panels.Add(title); title.Dock = DockStyle.Top; title.Padding = new NMarginsL(5, 8, 5, 4); title.Text = stats.ChartTitle; title.TextStyle.FontStyle = new NFontStyle("Verdana", 12, FontStyle.Bold | FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(68, 90, 108)); // // Set up the chart // NChart chart = new NCartesianChart(); this.nControlChart.Charts.Add(chart); chart.BoundsMode = BoundsMode.Stretch; chart.Dock = DockStyle.Fill; chart.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.FromArgb(233, 233, 255)); chart.Padding = new NMarginsL( new NLength(6, NRelativeUnit.ParentPercentage), new NLength(6, NRelativeUnit.ParentPercentage), new NLength(6, NRelativeUnit.ParentPercentage), new NLength(6, NRelativeUnit.ParentPercentage)); SetupChartAxes(chart, stats); // // First set up a point series for the outliers so it's on-top in z-order. // NPointSeries outlierPoints = new NPointSeries(); chart.Series.Add(outlierPoints); // Name the series outlierPoints.Name = "Control Limit Violations"; // Tell the series to regard the X values outlierPoints.UseXValues = true; // Points must fit in the chart area outlierPoints.InflateMargins = true; // No data labels outlierPoints.DataLabelStyle.Visible = false; // Set the point appearance properties outlierPoints.FillStyle = new NColorFillStyle(Color.Red); outlierPoints.BorderStyle = new NStrokeStyle(1.0f, Color.Black); outlierPoints.PointShape = PointShape.Cross; outlierPoints.Size = new NLength(6.0f); // Add the statistic for (int i = 0; i < nppoints; i++) { double statValue = stats.Statistic[i]; // Do not display a marker if the point is an outlier if ((statValue > stats.UCL[i]) || (statValue < stats.LCL[i])) { outlierPoints.XValues.Add(xstart + xincrement * i); outlierPoints.Values.Add(statValue); } } // // Set up the statistic line series // NLineSeries line = new NLineSeries(); chart.Series.Add(line); line.Name = "Statistic"; line.UseXValues = true; line.InflateMargins = true; line.DataLabelStyle.Visible = false; line.BorderStyle = new NStrokeStyle(1.6f, Color.Tomato); // Set up the marker style for the regular points line.MarkerStyle.Visible = true; line.MarkerStyle.FillStyle = new NColorFillStyle(Color.SkyBlue); line.MarkerStyle.BorderStyle = new NStrokeStyle(1.0f, Color.Tomato); line.MarkerStyle.PointShape = PointShape.Sphere; line.MarkerStyle.Width = new NLength(4.0f); line.MarkerStyle.Height = new NLength(4.0f); // Add the statistic for (int i = 0; i < nppoints; i++) { line.XValues.Add(xstart + xincrement * i); double statValue = stats.Statistic[i]; // Do not display a marker if the point is an outlier if ((statValue > stats.UCL[i]) || (statValue < stats.LCL[i])) { NMarkerStyle outlierMarker = new NMarkerStyle(); outlierMarker.Visible = false; line.MarkerStyles[i] = outlierMarker; } } line.Values.AddRange(stats.Statistic.DataBlock.Data); // // Set up the UCL and LCL lines // if (stats.ConstControlLimits) { bool showLCL = (stats.LCL.Length > 0); bool showUCL = (stats.UCL.Length > 0); if (showLCL) { double lclValue = stats.LCL[0]; // Set up the LCL const line NAxisConstLine lcl = new NAxisConstLine(); lcl.StrokeStyle = new NStrokeStyle(1.0f, Color.Gray, LinePattern.Dash); lcl.Value = lclValue; lcl.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(lcl); // Show LCL label SetValueLabel(chart, lclValue, "LCL", true); } if (showUCL) { double uclValue = stats.UCL[0]; // Set up the UCL const line NAxisConstLine ucl = new NAxisConstLine(); ucl.Value = uclValue; ucl.StrokeStyle = new NStrokeStyle(1.0f, Color.Gray, LinePattern.Dash); ucl.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(ucl); // Show UCL label SetValueLabel(chart, uclValue, "UCL", true); } // Ensure that the UCL and LCL values are visible NRange1DD clRange = new NRange1DD(); if (showLCL && showUCL) { clRange.Begin = stats.LCL[0]; clRange.End = stats.UCL[0]; } else if (showLCL) { clRange.End = clRange.Begin = stats.LCL[0]; } else if (showUCL) { clRange.End = clRange.Begin = stats.UCL[0]; } clRange.Inflate(0.5); chart.Axis(StandardAxis.PrimaryY).UpdateScale(); chart.Axis(StandardAxis.PrimaryY).SynchronizeScaleWithConfigurator = false; // custom tick inflator NCustomRangeInflator inflator = new NCustomRangeInflator(new NRange1DD[] { clRange }); inflator.InflateBegin = true; inflator.InflateEnd = true; chart.Axis(StandardAxis.PrimaryY).Scale.ContentRangeInflators.Add(inflator); } else { // Set up the UCL line series AddStepLineSeries(chart, "UCL", stats.UCL, xstart, xincrement); // Set up the LCL line series AddStepLineSeries(chart, "LCL", stats.LCL, xstart, xincrement); // Show UCL label if (stats.UCL.Length > 0) { int lastIndexUCL = stats.UCL.Length - 1; SetValueLabel(chart, stats.UCL[lastIndexUCL], "UCL", false); } // Show LCL label if (stats.LCL.Length > 0) { int lastIndexLCL = stats.LCL.Length - 1; SetValueLabel(chart, stats.LCL[lastIndexLCL], "LCL", false); } } // // Set up the center line // NAxisConstLine cl1 = new NAxisConstLine(); cl1.StrokeStyle = new NStrokeStyle(1.0f, Color.DodgerBlue, LinePattern.Dot); cl1.Value = stats.CenterLine; cl1.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(cl1); // Show CL label SetValueLabel(chart, stats.CenterLine, "CL", true); }
/// <summary> /// Demonstrates linear reression in two dimensions. /// </summary> void LinearRegression() { // Set up example description nRichDescription.Text = "A linear regression model is computed from the sample data containing random normal noise. \n\nA point is then predicted from the model with a 95% confidence interval - meaning the predicted point is expected to lie within the confidence interval 95% of the time."; // First read in the independent (or predictor) values. This is a matrix // with one column and a row for each amounts measurement. DoubleVector raw_data = new DoubleVector(25, 0, 1); DoubleMatrix measurements = new DoubleMatrix(raw_data); // Next, read in the responses // Build a linear polynomial and add noise for interest RandomNumberGenerator rand = new RandGenNormal(0, noiselevel_); Polynomial poly = new Polynomial(new DoubleVector("0, 1")); DoubleVector responses = poly.Evaluate(raw_data) + new DoubleVector(raw_data.Length, rand); ; // Construct a linear regression. If we want our regression to calculate a // y-intercept we must send in true for the "addIntercept" parameter (the // third paramameter in the constructor). LinearRegression regression = new LinearRegression(measurements, responses, true); DoubleVector residues = regression.Residuals; // Use the linear regression class to make a prediction according to the model DoubleVector xvalues = new DoubleVector("30"); // Use the model to predict the observation at 30. Interval pi = regression.PredictionInterval(xvalues, 0.95); // Build some data points along the regression line for display DoubleMatrix abcissae = new DoubleMatrix(new DoubleVector(raw_data)); DoubleVector predicted_ys = regression.PredictedObservations(abcissae); // Build the chart SetupChartLayout("Linear Regression"); NChart chart = nChartControl1.Charts[0]; SetupChartAxes(chart); // Set up the line series NLineSeries line = new NLineSeries(); chart.Series.Add(line); // tell the series to regard the X values line.UseXValues = true; // no data labels line.DataLabelStyle.Visible = false; // Set the line color line.BorderStyle = new NStrokeStyle(2.0f, Color.Tomato); // name data set line.Name = "Linear Regression"; // Add the the Linear Regression line data to the line series line.XValues.AddRange(abcissae.DataBlock.Data); line.Values.AddRange(predicted_ys.DataBlock.Data); // Draw the raw data points NPointSeries point = new NPointSeries(); chart.Series.Add(point); point.UseXValues = true; point.DataLabelStyle.Visible = false; // Set the point appearance properties point.FillStyle = new NColorFillStyle(Color.SkyBlue); point.BorderStyle = new NStrokeStyle(1.0f,Color.DarkGray); point.PointShape = PointShape.Cross; point.Size = new NLength(6.0f); // Points must fit in the chart area point.InflateMargins = true; // Name point set point.Name = "Observations"; // set the point data point.Values.AddRange(responses.DataBlock.Data); point.XValues.AddRange(measurements.DataBlock.Data); double m = (pi.Min + pi.Max) / 2.0; // Display the predicted value with an error bar series NErrorBarSeries predicted_points = new NErrorBarSeries(); chart.Series.Add(predicted_points); predicted_points.Name = "Predicted Point"; predicted_points.UseXValues = true; predicted_points.InflateMargins = true; predicted_points.FillStyle = new NColorFillStyle(Color.Crimson); predicted_points.BorderStyle = new NStrokeStyle(1.0f, Color.DarkGray); predicted_points.DataLabelStyle.Visible = false; predicted_points.MarkerStyle.Visible = true; predicted_points.MarkerStyle.FillStyle = new NColorFillStyle(Color.Crimson); predicted_points.MarkerStyle.BorderStyle = new NStrokeStyle(1.0f, Color.DarkGray); predicted_points.MarkerStyle.PointShape = PointShape.Bar; predicted_points.MarkerStyle.Width = new NLength(5); predicted_points.MarkerStyle.Height = new NLength(5); predicted_points.SizeY = new NLength(5); // Fill the data for the predicted point predicted_points.XValues.AddRange(xvalues.DataBlock.Data); predicted_points.Values.Add(m); predicted_points.UpperErrorsY.Add(pi.Max - m); predicted_points.LowerErrorsY.Add(m - pi.Min); // Create a label to display the predicted value NLabel label = new NLabel(); label.BoundsMode = BoundsMode.None; label.ContentAlignment = ContentAlignment.BottomLeft; label.Location = new NPointL( new NLength(87, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage)); label.TextStyle.TextFormat = TextFormat.XML; label.TextStyle.FontStyle = new NFontStyle("Arial", 9); label.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Right; label.TextStyle.BackplaneStyle.Visible = true; label.TextStyle.BackplaneStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(130, 255, 255, 255), Color.FromArgb(130, 233, 233, 255)); label.TextStyle.BackplaneStyle.Shape = BackplaneShape.SmoothEdgeRectangle; label.TextStyle.BackplaneStyle.StandardFrameStyle.InnerBorderColor = Color.White; label.Text = "<font color = 'crimson'>" + m.ToString("0.###") + "</font> - predicted value with 95% confidence interval"; chart.ChildPanels.Add(label); nChartControl1.Refresh(); }