protected void nChartControl1_AsyncRefresh(object sender, EventArgs e) { NLineSeries line = (NLineSeries)nChartControl1.Charts[0].Series[0]; if (line == null) { return; } if (line.Values.Count == 0) { return; } double dPrev = (double)line.Values[line.Values.Count - 1]; double value; GenerateDataPoint(dPrev, new NRange1DD(50, 350), out value); line.Values.RemoveAt(0); line.XValues.RemoveAt(0); line.Values.Add(value); int nLast = (line.XValues.Count > 0 ? line.XValues.Count - 1 : 0); double dLastValue = (double)line.XValues[nLast]; line.XValues.Add(DateTime.Now); UpdateIndicators(nChartControl1.Document); }
protected static void UpdateIndicators(NDocument document) { NLineSeries line = (NLineSeries)document.RootPanel.Charts[0].Series[0]; double min = (double)line.Values[line.Values.FindMinValue()]; double max = (double)line.Values[line.Values.FindMaxValue()]; NGaugePanel panel1 = document.RootPanel.ChildPanels[2] as NGaugePanel; NGaugePanel panel2 = document.RootPanel.ChildPanels[3] as NGaugePanel; NGaugePanel panel3 = document.RootPanel.ChildPanels[4] as NGaugePanel; NNeedleValueIndicator minIndicator = panel1.Indicators[1] as NNeedleValueIndicator; NNeedleValueIndicator maxIndicator = panel2.Indicators[1] as NNeedleValueIndicator; NNeedleValueIndicator avgIndicator = panel3.Indicators[1] as NNeedleValueIndicator; minIndicator.Value = min; maxIndicator.Value = max; int count = line.Values.Count; double sum = 0; for (int i = 0; i < count; i++) { sum += (double)line.Values[i]; } if (count > 0) { avgIndicator.Value = sum / count; } else { avgIndicator.Value = 0; } }
private void LineDepthScroll_Scroll(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e) { NLineSeries line = (NLineSeries)nChartControl1.Charts[0].Series[0]; line.DepthPercent = LineDepthScroll.Value; nChartControl1.Refresh(); }
private void LineSizeScroll_ValueChanged(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e) { NLineSeries line = (NLineSeries)nChartControl1.Charts[0].Series[0]; line.LineSize = new NLength(LineSizeScroll.Value / 40.0f, NRelativeUnit.ParentPercentage); nChartControl1.Refresh(); }
private void LineStyleComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { NLineSeries line = (NLineSeries)nChartControl1.Charts[0].Series[0]; switch (LineStyleComboBox.SelectedIndex) { case 0: // simple line line.LineSegmentShape = LineSegmentShape.Line; line.DepthPercent = 0; break; case 1: // tape line.LineSegmentShape = LineSegmentShape.Tape; line.DepthPercent = 50; break; case 2: // tube line.LineSegmentShape = LineSegmentShape.Tube; line.DepthPercent = 10; break; case 3: // ellipsoid line.LineSegmentShape = LineSegmentShape.Ellipsoid; line.DepthPercent = 10; break; } nChartControl1.Refresh(); }
private void UpdateFunctions(NStockSeries stock, NLineSeries lineDIPos, NLineSeries lineDINeg, NLineSeries lineADX, NFunctionCalculator calc) { StringBuilder sb = new StringBuilder(); int nPeriod = PeriodDropDownList.SelectedIndex * 10; sb.AppendFormat("DI_POS(close; high; low; {0})", nPeriod); calc.Expression = sb.ToString(); lineDIPos.Values = calc.Calculate(); lineDIPos.XValues = (NDataSeriesDouble)stock.XValues.Clone(); lineDIPos.UseXValues = true; PosDITextBox.Text = calc.Expression; sb.Remove(0, sb.Length); sb.AppendFormat("DI_NEG(close; high; low; {0})", nPeriod); calc.Expression = sb.ToString(); lineDINeg.Values = calc.Calculate(); lineDINeg.XValues = (NDataSeriesDouble)stock.XValues.Clone(); lineDINeg.UseXValues = true; NegDITextBox.Text = calc.Expression; sb.Remove(0, sb.Length); sb.AppendFormat("MMA(DMI(close; high; low; {0}); {0})", nPeriod); calc.Expression = sb.ToString(); lineADX.Values = calc.Calculate(); lineADX.XValues = (NDataSeriesDouble)stock.XValues.Clone(); lineADX.UseXValues = true; ADXTextBox.Text = calc.Expression; }
private void UpdateTimeSpan() { DateTime startDate = StartDateCalendar.SelectedDate; DateTime endDate = EndDateCalendar.SelectedDate; if (startDate > endDate) { DateTime temp = startDate; startDate = endDate; endDate = temp; } // Get the line series from the chart NLineSeries line = (NLineSeries)m_Chart.Series[0]; TimeSpan span = endDate - startDate; span = new TimeSpan(span.Ticks / 30); line.Values.Clear(); line.XValues.Clear(); if (span.Ticks > 0) { while (startDate < endDate) { line.XValues.Add(startDate); startDate += span; line.Values.Add(Random.Next(100)); } } }
private NLineSeries CreateLineSeries(NColor lightColor, NColor color, int begin, int end) { // Add a line series NLineSeries line = new NLineSeries(); for (int i = 0; i < 5; i++) { line.DataPoints.Add(new NLineDataPoint(m_Random.Next(begin, end))); } line.Stroke = new NStroke(2, color); NDataLabelStyle dataLabelStyle = new NDataLabelStyle(); dataLabelStyle.Format = "<value>"; dataLabelStyle.TextStyle.Background.Visible = false; dataLabelStyle.ArrowStroke.Width = 0; dataLabelStyle.ArrowLength = 10; dataLabelStyle.TextStyle.Font = new NFont("Arial", 8); dataLabelStyle.TextStyle.Background.Visible = true; line.DataLabelStyle = dataLabelStyle; NMarkerStyle markerStyle = new NMarkerStyle(); markerStyle.Visible = true; markerStyle.Border = new NStroke(color); markerStyle.Fill = new NColorFill(lightColor); markerStyle.Shape = ENPointShape.Ellipse; markerStyle.Size = new NSize(5, 5); line.MarkerStyle = markerStyle; return(line); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Series Marker Attribute"); 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 NChart chart = nChartControl1.Charts[0]; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Enable3D = true; // 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)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle); chart.Axis(StandardAxis.Depth).Visible = false; m_Line = (NLineSeries)chart.Series.Add(SeriesType.Line); m_Line.LineSegmentShape = LineSegmentShape.Tape; m_Line.InflateMargins = true; m_Line.DepthPercent = 50; m_Line.Legend.Mode = SeriesLegendMode.DataPoints; m_Line.Name = "Line Series"; m_Line.Values.FillRandom(Random, 6); m_Line.DataLabelStyle.Visible = false; m_Line.ShadowStyle.Type = ShadowType.GaussianBlur; m_Line.ShadowStyle.Offset = new NPointL(2, 2); m_Line.ShadowStyle.Color = Color.FromArgb(88, 0, 0, 0); m_Line.ShadowStyle.FadeLength = new NLength(5); m_Line.MarkerStyle.Visible = true; NMarkerStyle marker = new NMarkerStyle(); marker.FillStyle = new NColorFillStyle(Color.Red); marker.PointShape = PointShape.Cylinder; marker.Visible = true; m_Line.MarkerStyles[3] = marker; // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); StyleCombo.FillFromEnum(typeof(PointShape)); SelectMarkerCombo.Items.Add("Edit Default Marker"); SelectMarkerCombo.Items.Add("Edit Marker #3"); SelectMarkerCombo.SelectedIndex = 0; VisibleCheck.Checked = true; }
public void OnAutoUpdate(NAspNetThinWebControl control) { NThinChartControl chartControl = (NThinChartControl)control; NLineSeries line = (NLineSeries)chartControl.Charts[0].Series[0]; if (line == null) { return; } if (line.Values.Count == 0) { return; } double dPrev = (double)line.Values[line.Values.Count - 1]; double yValue = GenerateDataPoint(dPrev, new NRange1DD(50, 350)); line.Values.RemoveAt(0); line.XValues.RemoveAt(0); line.Values.Add(yValue); line.XValues.Add(DateTime.Now.ToOADate()); chartControl.UpdateView(); }
private NLineSeries SetupIndicatorChart(NCartesianChart chart) { NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY.InnerMajorTickStyle.Length = new NLength(0); NCartesianAxisCollection axes = (NCartesianAxisCollection)chart.Axes; NAxis axisY = axes.AddCustomAxis(AxisOrientation.Vertical, AxisDockZone.FrontLeft); axisY.Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 0, 20); axisY.ScaleConfigurator = scaleY; axisY.Visible = true; // Add line series for function NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.DataLabelStyle.Visible = false; line.BorderStyle.Color = Color.Blue; line.DisplayOnAxis(StandardAxis.PrimaryY, false); line.DisplayOnAxis(axisY.AxisId, true); line.UseXValues = true; return(line); }
private void LineStyleCombo_SelectedIndexChanged(object sender, System.EventArgs e) { NLineSeries line = (NLineSeries)nChartControl1.Charts[0].Series[0]; bool bSimpleLine = (LineStyleCombo.SelectedIndex == 0); switch (LineStyleCombo.SelectedIndex) { case 0: // simple line line.LineSegmentShape = LineSegmentShape.Line; line.DepthPercent = 0; break; case 1: // tape line.LineSegmentShape = LineSegmentShape.Tape; line.DepthPercent = 50; break; case 2: // tube line.LineSegmentShape = LineSegmentShape.Tube; line.DepthPercent = 10; break; case 3: // ellipsoid line.LineSegmentShape = LineSegmentShape.Ellipsoid; line.DepthPercent = 10; break; } LineFillColorButton.Enabled = !bSimpleLine; nChartControl1.Refresh(); }
private void GenerateData(object sender, System.EventArgs e) { DateTime startDate = DateTime.Now; DateTime endDate = DateTime.Now.Add(new TimeSpan(30, 0, 0, 0, 0)); if (startDate > endDate) { DateTime temp = startDate; startDate = endDate; endDate = temp; } // Get the line series from the chart NLineSeries line = (NLineSeries)m_Chart.Series[0]; TimeSpan span = endDate - startDate; span = new TimeSpan(span.Ticks / 30); line.Values.Clear(); line.XValues.Clear(); if (span.Ticks > 0) { while (startDate < endDate) { line.XValues.Add(startDate); startDate += span; line.Values.Add(Random.Next(100)); } } }
void OnGenerateRandomDataButtonClick(NEventArgs arg) { DateTime startDate = m_StartDateTimeBox.SelectedDate; DateTime endDate = m_EndDateTimeBox.SelectedDate; if (startDate > endDate) { DateTime temp = startDate; startDate = endDate; endDate = temp; } // Get the line series from the chart NLineSeries line = (NLineSeries)m_Chart.Series[0]; TimeSpan span = endDate - startDate; span = new TimeSpan(span.Ticks / 30); line.DataPoints.Clear(); if (span.Ticks > 0) { Random random = new Random(); while (startDate < endDate) { line.DataPoints.Add(new NLineDataPoint(NDateTimeHelpers.ToOADate(startDate), random.Next(100))); startDate += span; } } }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Average, Median, Min, Max"); 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.Cylinder; m_Bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); m_Bar.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, Color.LightSteelBlue, Color.MidnightBlue); m_Bar.Values.FillRandomRange(Random, 12, 0, 50); // form controls m_bSkipUpdate = true; m_FunctionCombo.Items.Add("Average"); m_FunctionCombo.Items.Add("Median"); m_FunctionCombo.Items.Add("Min"); m_FunctionCombo.Items.Add("Max"); m_FunctionCombo.SelectedIndex = 0; 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; m_bSkipUpdate = false; m_FunctionCombo_SelectedIndexChanged(null, null); }
private void GenerateNewData() { NLineSeries line = (NLineSeries)nChartControl1.Charts[0].Series[0]; GenerateDateTimeData(line, 100); UpdateIndicators(nChartControl1.Document); }
public override void OnAsyncRefresh(string webControlId, System.Web.HttpContext context, NStateObject state, EventArgs args) { NChartSessionStateObject chartState = state as NChartSessionStateObject; NRootPanel rootPanel = chartState.Document.RootPanel; NLineSeries line = (NLineSeries)chartState.Document.RootPanel.Charts[0].Series[0]; if (line == null) { return; } if (line.Values.Count == 0) { return; } double dPrev = (double)line.Values[line.Values.Count - 1]; double value; GenerateDataPoint(dPrev, new NRange1DD(50, 350), out value); line.Values.RemoveAt(0); line.XValues.RemoveAt(0); line.Values.Add(value); int nLast = (line.XValues.Count > 0 ? line.XValues.Count - 1 : 0); double dLastValue = (double)line.XValues[nLast]; line.XValues.Add(DateTime.Now); UpdateIndicators(chartState.Document); }
public override void Initialize(NThinChartControl control) { control.BackgroundStyle.FrameStyle.Visible = false; control.Panels.Clear(); control.Width = 600; control.Height = 300; NStandardFrameStyle frame = control.BackgroundStyle.FrameStyle as NStandardFrameStyle; frame.InnerBorderWidth = new NLength(0); // set a chart title // set a chart title NLabel title = control.Labels.AddHeader("Auto Update"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // setup Line chart NCartesianChart chart = new NCartesianChart(); control.Panels.Add(chart); NRangeTimelineScaleConfigurator rangeTimeline = new NRangeTimelineScaleConfigurator(); rangeTimeline.FirstRow.MinTickDistance = new NLength(40); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = rangeTimeline; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // 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); scaleY.StripStyles.Add(stripStyle); NLineSeries line = new NLineSeries(); line.UseXValues = true; line.DataLabelStyle.Visible = false; line.BorderStyle.Color = Color.DarkOrange; line.BorderStyle.Width = new NLength(2); chart.Series.Add(line); // generate some data GenerateNewData(control); ApplyLayoutTemplate(0, control, chart, title, null); // set auto update Callback control.AutoUpdateCallback = new NAutoUpdateCallback(); // enable auto update control.ServerSettings.AutoUpdateInterval = 200; control.ServerSettings.EnableAutoUpdate = true; }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Real Time Line"); 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 NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.BoundsMode = BoundsMode.Stretch; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Black); // styleSheet.Apply(nChartControl1.Document); NAxis axis1 = chart.Axis(StandardAxis.PrimaryY); ConfigureAxis(axis1, 0, 30, "Signal 1"); NAxis axis2 = chart.Axis(StandardAxis.SecondaryY); ConfigureAxis(axis2, 35, 65, "Signal 2"); NAxis axis3 = ((NCartesianAxisCollection)chart.Axes).AddCustomAxis(AxisOrientation.Vertical, AxisDockZone.FrontRight); ConfigureAxis(axis3, 70, 100, "Signal 3"); m_Line1 = CreateLineSeries(); chart.Series.Add(m_Line1); m_Line2 = CreateLineSeries(); chart.Series.Add(m_Line2); m_Line2.DisplayOnAxis(StandardAxis.PrimaryY, false); m_Line2.DisplayOnAxis(StandardAxis.SecondaryY, true); m_Line3 = CreateLineSeries(); chart.Series.Add(m_Line3); m_Line3.DisplayOnAxis(StandardAxis.PrimaryY, false); m_Line3.DisplayOnAxis(axis3.AxisId, true); m_ValueArray1 = new double[m_NewDataPointsPerTick]; m_ValueArray2 = new double[m_NewDataPointsPerTick]; m_ValueArray3 = new double[m_NewDataPointsPerTick]; ConfigureStandardLayout(chart, title, null); UseHardwareAccelerationCheckBox.Checked = true; StartTimer(); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("3D Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.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.Perspective2); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); // 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)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle); // add a line series NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.Name = "Line Series"; line.InflateMargins = true; line.DataLabelStyle.Visible = false; line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Cylinder; line.MarkerStyle.Width = new NLength(1.5f, NRelativeUnit.ParentPercentage); line.MarkerStyle.Height = new NLength(1.5f, NRelativeUnit.ParentPercentage); line.Values.FillRandom(new Random(), 8); // apply layout ConfigureStandardLayout(chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); NExampleHelpers.FillComboWithEnumValues(LineStyleComboBox, typeof(LineSegmentShape)); LineStyleComboBox.SelectedIndex = (int)line.LineSegmentShape; AxisRoundToTickCheckBox.IsChecked = true; InflateMarginsCheckBox.IsChecked = true; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Series Marker Attribute"); 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 NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // 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)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle); chart.Axis(StandardAxis.Depth).Visible = false; NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.LineSegmentShape = LineSegmentShape.Tape; line.InflateMargins = true; line.DepthPercent = 50; line.Legend.Mode = SeriesLegendMode.DataPoints; line.Name = "Line Series"; line.Values.FillRandom(Random, 6); line.DataLabelStyle.Visible = false; line.ShadowStyle.Type = ShadowType.GaussianBlur; line.ShadowStyle.Offset = new NPointL(2, 2); line.ShadowStyle.Color = Color.FromArgb(88, 0, 0, 0); line.ShadowStyle.FadeLength = new NLength(5); line.MarkerStyle.Visible = true; NMarkerStyle marker = new NMarkerStyle(); marker.FillStyle = new NColorFillStyle(Color.Red); marker.PointShape = PointShape.Custom; // Create a custom shape for this marker N2DSmartShapeFactory factory = new N2DSmartShapeFactory(new NColorFillStyle(Color.Red), new NStrokeStyle(1.0f, Color.Black), null); marker.CustomShape = factory.CreateShape(SmartShape2D.Trapezoid); marker.Visible = true; line.MarkerStyles[3] = marker; // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); }
protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddFooter("Volume Indicators"); 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(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup charts NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(90, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); SetupTimeScale(chart.Axis(StandardAxis.PrimaryX)); NStockSeries stock = SetupStockChart(chart); NAreaSeries volume = SetupVolumeChart(chart); NLineSeries line = SetupIndicatorChart(chart); // form controls if (!IsPostBack) { FunctionDropDownList.Items.Add("Accumulation Distribution"); FunctionDropDownList.Items.Add("Chaikin Oscillator"); FunctionDropDownList.Items.Add("Ease of Movement"); FunctionDropDownList.Items.Add("Money Flow Index"); FunctionDropDownList.Items.Add("Negative Volume Index"); FunctionDropDownList.Items.Add("On Balance Volume"); FunctionDropDownList.Items.Add("Positive Volume Index"); FunctionDropDownList.Items.Add("Price and Volume Trend"); FunctionDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithValues(ParameterDropDownList, 0, 100, 10); ParameterDropDownList.SelectedIndex = 1; } NFunctionCalculator function = new NFunctionCalculator(); // generate data GenerateData(stock, volume, line); GenerateVolumeData(volume, prevVolumeValue, numDataPoits); UpdateFunction(stock, volume, line, function); line.Values = function.Calculate(); line.XValues = (NDataSeriesDouble)stock.XValues.Clone(); volume.XValues = (NDataSeriesDouble)stock.XValues.Clone(); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Series Markers"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // setup chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // 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)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle); chart.Axis(StandardAxis.Depth).Visible = false; NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.LineSegmentShape = LineSegmentShape.Tape; line.InflateMargins = true; line.DepthPercent = 50; line.Legend.Mode = SeriesLegendMode.DataPoints; line.Name = "Line Series"; line.Values.FillRandom(Random, 6); line.DataLabelStyle.Visible = false; line.ShadowStyle.Type = ShadowType.GaussianBlur; line.ShadowStyle.Offset = new NPointL(2, 2); line.ShadowStyle.Color = Color.FromArgb(88, 0, 0, 0); line.ShadowStyle.FadeLength = new NLength(5); line.MarkerStyle.Visible = true; NMarkerStyle marker = new NMarkerStyle(); marker.FillStyle = new NColorFillStyle(Color.Red); marker.PointShape = PointShape.Custom; // Create a custom shape for this marker N2DSmartShapeFactory factory = new N2DSmartShapeFactory(new NColorFillStyle(Color.Red), new NStrokeStyle(1.0f, Color.Black), null); marker.CustomShape = factory.CreateShape(SmartShape2D.Trapezoid); marker.Visible = true; line.MarkerStyles[3] = marker; // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]); }
protected void Page_Load(object sender, EventArgs e) { if (!NThinChartControl1.Initialized) { NThinChartControl1.BackgroundStyle.FrameStyle.Visible = false; NThinChartControl1.Panels.Clear(); NStandardFrameStyle frame = NThinChartControl1.BackgroundStyle.FrameStyle as NStandardFrameStyle; frame.InnerBorderWidth = new NLength(0); // set a chart title // set a chart title NLabel title = NThinChartControl1.Labels.AddHeader("Auto Update"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // setup Line chart NCartesianChart chart = new NCartesianChart(); NThinChartControl1.Panels.Add(chart); NRangeTimelineScaleConfigurator rangeTimeline = new NRangeTimelineScaleConfigurator(); rangeTimeline.FirstRow.MinTickDistance = new NLength(40); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = rangeTimeline; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // 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); scaleY.StripStyles.Add(stripStyle); NLineSeries line = new NLineSeries(); line.UseXValues = true; line.DataLabelStyle.Visible = false; line.BorderStyle.Color = Color.DarkOrange; line.BorderStyle.Width = new NLength(2); chart.Series.Add(line); // generate some data GenerateNewData(); NThinChartControl1.AutoUpdateCallback = new NAutoUpdateCallback(); ApplyLayoutTemplate(0, NThinChartControl1, chart, title, null); NThinChartControl1.ServerSettings.EnableTiledZoom = true; NThinChartControl1.ServerSettings.AutoUpdateInterval = 200; NThinChartControl1.ServerSettings.EnableAutoUpdate = true; } if (!IsPostBack) { AutoUpdateIntervalTextBox.Text = NThinChartControl1.ServerSettings.AutoUpdateInterval.ToString(); } }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("2D Line 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)); // no legend nChartControl1.Legends.Clear(); // configure the chart NChart chart = nChartControl1.Charts[0]; 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)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle); NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.Name = "Line Series"; line.InflateMargins = true; line.DataLabelStyle.Format = "<value>"; line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Cylinder; line.MarkerStyle.Width = new NLength(1.5f, NRelativeUnit.ParentPercentage); line.MarkerStyle.Height = new NLength(1.5f, NRelativeUnit.ParentPercentage); line.ShadowStyle.Type = ShadowType.GaussianBlur; line.ShadowStyle.Offset = new NPointL(3, 3); line.ShadowStyle.FadeLength = new NLength(5); line.ShadowStyle.Color = Color.FromArgb(55, 0, 0, 0); line.Values.FillRandom(Random, 8); // apply layout ConfigureStandardLayout(chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // init form controls LineStyleCombo.FillFromEnum(typeof(LineSegmentShape)); LineStyleCombo.SelectedIndex = 0; RoundToTickCheck.Checked = true; InflateMarginsCheck.Checked = true; }
private void GenerateXYZData(NLineSeries line) { int numberOfTurns = NumberOfTurnsDropDownList.SelectedIndex + 3; int numberOfPointsInTurn = (NumberOfPointsInTurnDropDownList.SelectedIndex + 1) * 10000; for (int i = 0; i < numberOfTurns; i++) { AddTurn(line, numberOfPointsInTurn); } }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("3D Sampled Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); // no legend nChartControl1.Legends.Clear(); // configure the chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 70; chart.Height = 70; chart.Depth = 70; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.Depth).ScaleConfigurator = new NLinearScaleConfigurator(); // 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)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle); // add a line series m_Line = (NLineSeries)chart.Series.Add(SeriesType.Line); m_Line.Name = "Line Series"; m_Line.InflateMargins = true; m_Line.DataLabelStyle.Visible = false; m_Line.MarkerStyle.Visible = false; m_Line.UseXValues = true; m_Line.UseZValues = true; m_Line.SamplingMode = SeriesSamplingMode.Enabled; SampleDistanceScrollBar.Value = (int)m_Line.SampleDistance.Value; // apply layout ConfigureStandardLayout(chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); Add40KDataButton_Click(null, null); }
public override void Initialize() { base.Initialize(); // create a title NLabel title = new NLabel("Hit Testing Scale Elements"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // hide the legend nChartControl1.Legends[0].Visible = false; // configure chart NChart chart = nChartControl1.Charts[0]; chart.Axis(StandardAxis.Depth).Visible = false; // add interlace stripe NLinearScaleConfigurator scaleY = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; scaleY.Title.Text = "Y Axis Title"; 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); scaleY.StripStyles.Add(stripStyle); // add the line NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.LineSegmentShape = LineSegmentShape.Line; line.DataLabelStyle.Visible = false; line.Legend.Mode = SeriesLegendMode.DataPoints; line.InflateMargins = true; line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Cylinder; line.MarkerStyle.Width = new NLength(1.5f, NRelativeUnit.ParentPercentage); line.MarkerStyle.Height = new NLength(1.5f, NRelativeUnit.ParentPercentage); line.Name = "Line Series"; line.UseXValues = true; // add xy values line.AddDataPoint(new NDataPoint(15, 10)); line.AddDataPoint(new NDataPoint(25, 23)); line.AddDataPoint(new NDataPoint(45, 12)); ConfigureAxis(chart.Axis(StandardAxis.PrimaryX)); ConfigureAxis(chart.Axis(StandardAxis.PrimaryY)); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); nChartControl1.MouseMove += new MouseEventHandler(nChartControl1_MouseMove); }
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(); }
private void ConfigureChart() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Annotations"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); title.TextStyle.TextFormat = TextFormat.XML; title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); m_Legend = nChartControl1.Legends[0]; m_Chart = nChartControl1.Charts[0]; m_Chart.Enable3D = true; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); m_Chart.Axis(StandardAxis.Depth).Visible = false; // add the line series m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line.Name = "Cumulative"; m_Line.DataLabelStyle.Visible = false; m_Line.MarkerStyle.Visible = true; m_Line.MarkerStyle.PointShape = PointShape.Cylinder; m_Line.MarkerStyle.FillStyle = new NColorFillStyle(Color.LimeGreen); m_Line.MarkerStyle.Width = new NLength(1.5f, NRelativeUnit.ParentPercentage); m_Line.MarkerStyle.Height = new NLength(1.5f, NRelativeUnit.ParentPercentage); m_Line.ShadowStyle.Type = ShadowType.GaussianBlur; m_Line.ShadowStyle.Color = Color.FromArgb(80, 0, 0, 0); m_Line.ShadowStyle.Offset = new NPointL(2, 2); m_Line.ShadowStyle.FadeLength = new NLength(4); // add the bar series m_Bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); m_Bar.Name = "Bar Series"; m_Bar.DataLabelStyle.Visible = false; m_Bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); m_Bar.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant2, Color.DarkBlue, Color.CornflowerBlue); m_Bar.ShadowStyle.Type = ShadowType.GaussianBlur; m_Bar.ShadowStyle.Color = Color.FromArgb(80, 0, 0, 0); m_Bar.ShadowStyle.Offset = new NPointL(3, 3); m_Bar.ShadowStyle.FadeLength = new NLength(4); // fill with random data and sort in descending order m_Bar.Values.FillRandom(Random, 10); m_Bar.Values.Sort(DataSeriesSortOrder.Descending); // generate a data series cumulative sum of the bar values NFunctionCalculator fc = new NFunctionCalculator(); fc.Expression = "CUMSUM(Value)"; fc.Arguments.Add(m_Bar.Values); m_Line.Values = fc.Calculate(); }
/// <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 the use of Savitzky-Golay smoothing filter. /// </summary> void DataSmoothing() { // Set up example description nRichDescription.Text = "Smoothing discrete data with random normal noise using a 5th degree Savitzky-Golay filter. \n\nWhen using the Savitzky-Golay filter class, both the degree of the fitting polynomial and the filter width can be easily controlled. Good defaults are available."; // Create an interesting noisy sampled signal to smooth. DoubleVector xs = new DoubleVector(50, 0, Math.PI / 25); RandomNumberGenerator rand = new RandGenNormal(0.0, noiselevel_); DoubleVector raw_data = 10.0 * NMathFunctions.Tanh(NMathFunctions.Sin(xs)) + 0.2 * new DoubleVector(xs.Length, rand); // Create the filter and smooth the data MovingWindowFilter filter = new MovingWindowFilter(10, 10, MovingWindowFilter.SavitzkyGolayCoefficients(10, 10, 5)); DoubleVector smoothed_data = filter.Filter(raw_data, MovingWindowFilter.BoundaryOption.PadWithZeros); SetupChartLayout("Data Smoothing"); NChart chart = nChartControl1.Charts[0]; SetupChartAxes(chart); // Create a point series to display the raw data NPointSeries point = new NPointSeries(); chart.Series.Add(point); // Tell the series to regard the X values point.UseXValues = true; // Points must fit in the chart area point.InflateMargins = true; // No data labels point.DataLabelStyle.Visible = false; // Set up the data look and feel point.FillStyle = new NColorFillStyle(Color.SkyBlue); point.BorderStyle = new NStrokeStyle(1.0f, Color.DarkGray); point.PointShape = PointShape.Ellipse; point.Size = new NLength(4.0f); // Name points point.Name = "Observations"; // Load data into points collection point.XValues.AddRange(xs.DataBlock.Data); point.Values.AddRange(raw_data.DataBlock.Data); // Create a line series to display the smoothed data NLineSeries smoothline = new NLineSeries(); chart.Series.Add(smoothline); smoothline.UseXValues = true; smoothline.DataLabelStyle.Visible = false; smoothline.BorderStyle = new NStrokeStyle(2.0f, Color.Tomato); // Name smooth line smoothline.Name = "Savitzky-Golay Smoothed Data"; // Load the smoothed data into the line series smoothline.XValues.AddRange(xs.DataBlock.Data); smoothline.Values.AddRange(smoothed_data.DataBlock.Data); nChartControl1.Refresh(); }
/// <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(); }
/// <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(); }
private void callPersonalGraph(string projectName, string ScenarioName, int idx) { nChartControl1.Clear(); //rData.getRData()[0].taskName 이런식으로 인덱스 줘서 사용하면 될 듯 m_FuncCalculator = new NFunctionCalculator(); nChartControl1.Legends.Clear(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Task x 소요 시간"); //title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Regular); title.TextStyle.FontStyle = new NFontStyle(pfc.Families[0].ToString(), 18, FontStyle.Regular); 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)); //m_Chart.Axis(StandardAxis.Depth).Visible = false; // 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.Color = Color.DarkGreen; m_Line.MarkerStyle.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel); m_Line.MarkerStyle.Width = new NLength(1.2f, NRelativeUnit.ParentPercentage); m_Line.MarkerStyle.Height = new NLength(1.2f, NRelativeUnit.ParentPercentage); m_Line.MarkerStyle.PointShape = PointShape.Cylinder; m_Line.MarkerStyle.FillStyle = new NColorFillStyle(Color.Gold); m_Line.BorderStyle.Color = Color.DarkGreen; m_Line.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel); m_Line.Legend.Mode = SeriesLegendMode.None; m_Line.DataLabelStyle.Format = "<value>"; m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.0"); m_Line.ShadowStyle.Type = ShadowType.GaussianBlur; m_Line.ShadowStyle.Offset = new NPointL(2, 2); m_Line.ShadowStyle.Color = Color.FromArgb(120, 0, 0, 0); m_Line.ShadowStyle.FadeLength = new NLength(5); // 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.0"); m_Bar.MultiBarMode = MultiBarMode.Stacked; m_Bar.DataLabelStyle.Visible = true; // 바에 보이는 값 //m_Bar.Legend.Mode = SeriesLegendMode.None; // 범례 안보이게 하는 거 m_Bar.BarShape = BarShape.Cylinder; m_Bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); m_Bar.FillStyle = new NColorFillStyle(Color.DarkKhaki); m_Bar.ShadowStyle.Type = ShadowType.Solid; m_Bar.ShadowStyle.Offset = new NPointL(2, 2); m_Bar.ShadowStyle.Color = Color.FromArgb(80, 0, 0, 0); //m_Bar.Values.FillRandomRange(new Random(), 14, 0, 100); NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); //m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.ResetButton.Visible = false; NNumericAxisPagingView numericPagingView = new NNumericAxisPagingView(new NRange1DD(0, 10)); m_Chart.Axis(StandardAxis.PrimaryX).PagingView = numericPagingView; m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleConfiguratorX.AutoLabels = false; foreach (ResultData.ResultInfo temp in rData.getRData()) { // 현재 찾고자 하는 프로젝트와 시나리오랑 같으면 if (temp.projectName == projectName && temp.taskName == ScenarioName) { if (idx == -1 /*&& temp.isMin == true*/) // ***************************************************************************************************************** check { ImgAverageInfo.Clear(); // 해당 시나리오 값에서 이동한 path 이미지들 값 가져오기 foreach (ResultData.ImgTime imgTemp in temp.pathInfo) { bool inList = false; float timeValue = System.Convert.ToSingle(imgTemp.timeImg); // 리스트 내에 같은 값 찾기 if (ImgAverageInfo.Count != 0) { foreach (ImgAverageTime inListImg in ImgAverageInfo) { // 같은게 있다면 if (inListImg.imgName == imgTemp.imgName) { inListImg.count += 1; inListImg.imgTime += timeValue; inList = true; break; } } } // 리스트 내에 없다면 if (inList == false) ImgAverageInfo.Add(new ImgAverageTime() { imgName = imgTemp.imgName, imgTime = timeValue, count = 1 }); } } // Idx랑 같으면 else if (temp.idx == idx) { // 해당 시나리오 값에서 이동한 path 이미지들 값 가져오기 foreach (ResultData.ImgTime imgTemp in temp.pathInfo) { scaleConfiguratorX.Labels.Add(imgTemp.imgName); m_Bar.Values.Add(imgTemp.timeImg); } } } } if (idx == -1) { foreach (ImgAverageTime listImg in ImgAverageInfo) { scaleConfiguratorX.Labels.Add(listImg.imgName); m_Bar.Values.Add(listImg.imgTime / listImg.count); } } //m_FuncCalculator.Arguments.Add(m_Line.Values); m_FuncCalculator.Arguments.Add(m_Bar.Values); m_FuncCalculator.Expression = "CUMSUM(values)"; m_Line.Values = m_FuncCalculator.Calculate(); m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.0"); // form controls /*m_FunctionCombo.Items.Add("Power"); m_FunctionCombo.Items.Add("Cumulative"); m_FunctionCombo.Items.Add("Exponential Average"); m_FunctionCombo.SelectedIndex = 0;*/ nChartControl1.Refresh(); }