private void GenerateDataButton_Click(object sender, System.EventArgs e) { NBoxAndWhiskersSeries series = (NBoxAndWhiskersSeries)m_Chart.Series[0]; GenerateData(series, 5); nChartControl1.Refresh(); }
protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Data Distribution"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.ContentAlignment = ContentAlignment.BottomCenter; title.Margins = new NMarginsL(5, 5, 5, 5); title.DockMode = PanelDockMode.Top; title.Location = new NPointL( new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // no legend nChartControl1.Legends.Clear(); // create box and whiskers chart NChart boxChart = new NCartesianChart(); boxChart.Margins = new NMarginsL(5, 0, 5, 5); boxChart.BoundsMode = BoundsMode.Stretch; boxChart.DockMode = PanelDockMode.Right; boxChart.Size = new NSizeL(new NLength(20, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage)); // create point chart NChart pointChart = new NCartesianChart(); pointChart.Margins = new NMarginsL(5, 0, 0, 5); pointChart.BoundsMode = BoundsMode.Stretch; pointChart.DockMode = PanelDockMode.Fill; // create a guide line to align the chart bottoms NSideGuideline bottomChartGuideline = new NSideGuideline(PanelSide.Bottom); nChartControl1.Document.RootPanel.Guidelines.Add(bottomChartGuideline); bottomChartGuideline.Targets.Add(pointChart); bottomChartGuideline.Targets.Add(boxChart); // arrange panels nChartControl1.Panels.Add(title); nChartControl1.Panels.Add(boxChart); nChartControl1.Panels.Add(pointChart); SetupCharts(pointChart, boxChart); bool showAverage = ShowAverageCheckBox.Checked; bool showOutliers = ShowOutliersCheckBox.Checked; NPointSeries pointSeries = (NPointSeries)pointChart.Series[0]; NBoxAndWhiskersSeries boxSeries = (NBoxAndWhiskersSeries)boxChart.Series[0]; NBoxAndWhiskersDataPoint bwdp = new NBoxAndWhiskersDataPoint(pointSeries.Values, showAverage, showOutliers); boxSeries.ClearDataPoints(); boxSeries.AddDataPoint(bwdp); }
private void WhiskersWidthScroll_Scroll(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e) { NBoxAndWhiskersSeries series = (NBoxAndWhiskersSeries)nChartControl1.Charts[0].Series[0]; series.WhiskersWidthPercent = WhiskersWidthScroll.Value; nChartControl1.Refresh(); }
private void BoxWidthScroll_ValueChanged(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e) { NBoxAndWhiskersSeries series = (NBoxAndWhiskersSeries)nChartControl1.Charts[0].Series[0]; series.BoxWidth = new NLength(BoxWidthScroll.Value / 10.0f, NRelativeUnit.ParentPercentage); nChartControl1.Refresh(); }
private void WhiskersWidthScrollBar_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs <double> e) { NBoxAndWhiskersSeries series = (NBoxAndWhiskersSeries)nChartControl1.Charts[0].Series[0]; series.WhiskersWidthPercent = (float)WhiskersWidthScrollBar.Value * 100.0f; nChartControl1.Refresh(); }
private void ShadowStyleButton_Click(object sender, System.EventArgs e) { NShadowStyle shadowStyleResult; NBoxAndWhiskersSeries series = (NBoxAndWhiskersSeries)nChartControl1.Charts[0].Series[0]; if (NShadowStyleTypeEditor.Edit(series.ShadowStyle, out shadowStyleResult)) { series.ShadowStyle = shadowStyleResult; nChartControl1.Refresh(); } }
private void OutliersFillStyleButton_Click(object sender, System.EventArgs e) { NFillStyle fillStyleResult; NBoxAndWhiskersSeries series = (NBoxAndWhiskersSeries)nChartControl1.Charts[0].Series[0]; if (NFillStyleTypeEditor.Edit(series.OutliersFillStyle, out fillStyleResult)) { series.OutliersFillStyle = fillStyleResult; nChartControl1.Refresh(); } }
private void GenerateData(NBoxAndWhiskersSeries series, int nCount) { series.ClearDataPoints(); DateTime dt = new DateTime(2005, 5, 24, 11, 0, 0); Random random = new Random(); for (int i = 0; i < nCount; i++) { double boxLower = 1000 + Random.NextDouble() * 200; double boxUpper = boxLower + 200 + Random.NextDouble() * 200; double whiskersLower = boxLower - (20 + Random.NextDouble() * 300); double whiskersUpper = boxUpper + (20 + Random.NextDouble() * 300); double IQR = (boxUpper - boxLower); double median = boxLower + IQR * 0.25 + Random.NextDouble() * IQR * 0.5; double average = boxLower + IQR * 0.25 + Random.NextDouble() * IQR * 0.5; series.UpperBoxValues.Add(boxUpper); series.LowerBoxValues.Add(boxLower); series.UpperWhiskerValues.Add(whiskersUpper); series.LowerWhiskerValues.Add(whiskersLower); series.MedianValues.Add(median); series.AverageValues.Add(average); // generate date time value dt = dt.AddHours(12 + Random.NextDouble() * 60); series.XValues.Add(dt.ToOADate()); // generate outlier values int outliersCount = Random.Next(5); NDoubleList outliers = new NDoubleList(); for (int k = 0; k < outliersCount; k++) { double dOutlier = 0; if (Random.NextDouble() > 0.5) { dOutlier = boxUpper + IQR * 1.5 + Random.NextDouble() * 100; } else { dOutlier = boxLower - IQR * 1.5 - Random.NextDouble() * 100; } outliers.Add(dOutlier); } series.OutlierValues.Add(outliers); } }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Date Time Box and Whiskers"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // remove the legend nChartControl1.Legends.Clear(); // setup the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; linearScale.StripStyles.Add(stripStyle); NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale; NBoxAndWhiskersSeries series = (NBoxAndWhiskersSeries)m_Chart.Series.Add(SeriesType.BoxAndWhiskers); series.DataLabelStyle.Visible = false; series.UseXValues = true; series.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant4, LightOrange, DarkOrange); series.MedianStrokeStyle = new NStrokeStyle(Color.Indigo); series.AverageStrokeStyle = new NStrokeStyle(1, Color.DarkRed, LinePattern.Dot); series.OutliersBorderStyle = new NStrokeStyle(DarkFuchsia); series.OutliersFillStyle = new NColorFillStyle(Red); GenerateData(series, 5); // apply layout ConfigureStandardLayout(m_Chart, title, null); BoxWidthScroll.Value = 40; WhiskersWidthScroll.Value = 50; RoundToTickCheck.Checked = true; InflateMarginsCheck.Checked = true; }
void UpdateBoxAndWhiskers() { NChart pointChart = nChartControl1.Charts[0]; NChart boxChart = nChartControl1.Charts[1]; NPointSeries pointSeries = (NPointSeries)pointChart.Series[0]; NBoxAndWhiskersSeries boxSeries = (NBoxAndWhiskersSeries)boxChart.Series[0]; bool showAverage = ShowAverageCheck.Checked; bool showOutliers = ShowOutliersCheck.Checked; NBoxAndWhiskersDataPoint bwdp = new NBoxAndWhiskersDataPoint(pointSeries.Values, showAverage, showOutliers); boxSeries.ClearDataPoints(); boxSeries.AddDataPoint(bwdp); }
private void GenerateData(NBoxAndWhiskersSeries series, int nCount) { series.ClearDataPoints(); for (int i = 0; i < nCount; i++) { double boxLower = 1000 + Random.NextDouble() * 200; double boxUpper = boxLower + 200 + Random.NextDouble() * 200; double whiskersLower = boxLower - (20 + Random.NextDouble() * 300); double whiskersUpper = boxUpper + (20 + Random.NextDouble() * 300); double IQR = (boxUpper - boxLower); double median = boxLower + IQR * 0.25 + Random.NextDouble() * IQR * 0.5; double average = boxLower + IQR * 0.25 + Random.NextDouble() * IQR * 0.5; series.UpperBoxValues.Add(boxUpper); series.LowerBoxValues.Add(boxLower); series.UpperWhiskerValues.Add(whiskersUpper); series.LowerWhiskerValues.Add(whiskersLower); series.MedianValues.Add(median); series.AverageValues.Add(average); int outliersCount = Random.Next(5); NDoubleList outliers = new NDoubleList(); for (int k = 0; k < outliersCount; k++) { double dOutlier = 0; if (Random.NextDouble() > 0.5) { dOutlier = boxUpper + IQR * 1.5 + Random.NextDouble() * 100; } else { dOutlier = boxLower - IQR * 1.5 - Random.NextDouble() * 100; } outliers.Add(dOutlier); } series.OutlierValues.Add(outliers); } }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = new NLabel("Box and Whiskers"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // remove the legend nChartControl1.Legends.Clear(); // setup the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; // 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); NBoxAndWhiskersSeries series = (NBoxAndWhiskersSeries)m_Chart.Series.Add(SeriesType.BoxAndWhiskers); series.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant4, LightOrange, DarkOrange); series.DataLabelStyle.Visible = false; series.MedianStrokeStyle = new NStrokeStyle(Color.Indigo); series.AverageStrokeStyle = new NStrokeStyle(1, Color.DarkRed, LinePattern.Dot); series.OutliersBorderStyle = new NStrokeStyle(BeautifulRed); series.OutliersFillStyle = new NColorFillStyle(Red); GenerateData(series, 7); // apply layout ConfigureStandardLayout(m_Chart, title, null); BoxWidthScrollBar.Value = 0.7; WhiskersWidthScrollBar.Value = 0.5; LeftAxisRoundToTickCheckBox.IsChecked = true; InflateMarginsCheckBox.IsChecked = true; }
private void SetupCharts(NChart pointChart, NChart boxChart) { // data double[] arrValues = { 204.5, 190.6, 199.7, 131.8, 143.4, 215.1, 228.0, 209.2, 183.8, 169.5, 212.0, 254.9, 222.3, 201.0, 215.4, 191.3, 181.5, 207.0, 199.0, 210.0 }; // setup point chart NStandardScaleConfigurator scaleConfigurator; scaleConfigurator = pointChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NStandardScaleConfigurator; scaleConfigurator.InnerMajorTickStyle.LineStyle.Width = new NLength(0); scaleConfigurator = pointChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NStandardScaleConfigurator; scaleConfigurator.InnerMajorTickStyle.LineStyle.Width = new NLength(0); // setup point series NPointSeries point = (NPointSeries)pointChart.Series.Add(SeriesType.Point); point.InflateMargins = true; point.DataLabelStyle.Visible = false; point.Size = new NLength(10, NGraphicsUnit.Point); point.PointShape = PointShape.Ellipse; point.FillStyle = new NColorFillStyle(Color.Yellow); point.BorderStyle = new NStrokeStyle(GreyBlue); point.Values.AddRange(arrValues); // setup box and whiskers chart boxChart.Width = 10; boxChart.Axis(StandardAxis.PrimaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, false); boxChart.Axis(StandardAxis.PrimaryX).Visible = false; // setup box and whiskers series NBoxAndWhiskersSeries boxSeries = (NBoxAndWhiskersSeries)boxChart.Series.Add(SeriesType.BoxAndWhiskers); boxSeries.InflateMargins = true; boxSeries.DataLabelStyle.Visible = false; boxSeries.FillStyle = new NColorFillStyle(DarkOrange); boxSeries.OutliersSize = new NLength(3, NGraphicsUnit.Point); // create a box and whiskers data point and initialize it from the point series NBoxAndWhiskersDataPoint bwdp = new NBoxAndWhiskersDataPoint(point.Values, true, true); boxSeries.AddDataPoint(bwdp); // synchronize axes NAxis axis1 = pointChart.Axis(StandardAxis.PrimaryY); NAxis axis2 = boxChart.Axis(StandardAxis.PrimaryY); axis1.Slaves.Add(axis2); axis2.Slaves.Add(axis1); // set an axis stripe for the interquartile range double dQ1 = (double)bwdp[DataPointValue.LowerBoxValue]; double dQ3 = (double)bwdp[DataPointValue.UpperBoxValue]; NAxisStripe boxStripe = axis1.Stripes.Add(dQ1, dQ3); boxStripe.FillStyle = new NColorFillStyle(Color.FromArgb(150, LightGreen)); // set an axis stripe for the min / max range double dMin = (double)bwdp[DataPointValue.LowerWhiskerValue]; double dMax = (double)bwdp[DataPointValue.UpperWhiskerValue]; NAxisStripe whiskersStripe = axis1.Stripes.Add(dMin, dMax); whiskersStripe.FillStyle = new NColorFillStyle(Color.FromArgb(70, LightGreen)); }
private void ChartTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { NChart chart = nChartControl1.Charts[0]; chart.Series.Clear(); const int numDataPoints = 50; switch (ChartTypeComboBox.SelectedIndex) { case 0: // Area { NAreaSeries area = new NAreaSeries(); area.DataLabelStyle.Visible = false; area.VerticalAxisRangeMode = AxisRangeMode.ViewRange; GenerateData(area, 100.0, numDataPoints, new NRange1DD(60, 140)); chart.Series.Add(area); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator(); } break; case 1: // Bar { NBarSeries bar = new NBarSeries(); bar.DataLabelStyle.Visible = false; bar.VerticalAxisRangeMode = AxisRangeMode.ViewRange; GenerateData(bar, 100.0, numDataPoints, new NRange1DD(60, 140)); chart.Series.Add(bar); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator(); } break; case 2: // Box And Whiskers { NBoxAndWhiskersSeries boxAndWhiskers = new NBoxAndWhiskersSeries(); boxAndWhiskers.VerticalAxisRangeMode = AxisRangeMode.ViewRange; for (int i = 0; i < 40; i++) { double boxLower = 1000 + Random.NextDouble() * 200; double boxUpper = boxLower + 200 + Random.NextDouble() * 200; double whiskersLower = boxLower - (20 + Random.NextDouble() * 300); double whiskersUpper = boxUpper + (20 + Random.NextDouble() * 300); double IQR = (boxUpper - boxLower); double median = boxLower + IQR * 0.25 + Random.NextDouble() * IQR * 0.5; double average = boxLower + IQR * 0.25 + Random.NextDouble() * IQR * 0.5; boxAndWhiskers.UpperBoxValues.Add(boxUpper); boxAndWhiskers.LowerBoxValues.Add(boxLower); boxAndWhiskers.UpperWhiskerValues.Add(whiskersUpper); boxAndWhiskers.LowerWhiskerValues.Add(whiskersLower); boxAndWhiskers.MedianValues.Add(median); boxAndWhiskers.AverageValues.Add(average); int outliersCount = Random.Next(5); NDoubleList outliers = new NDoubleList(); for (int k = 0; k < outliersCount; k++) { double dOutlier = 0; if (Random.NextDouble() > 0.5) { dOutlier = boxUpper + IQR * 1.5 + Random.NextDouble() * 100; } else { dOutlier = boxLower - IQR * 1.5 - Random.NextDouble() * 100; } outliers.Add(dOutlier); } boxAndWhiskers.OutlierValues.Add(outliers); } chart.Series.Add(boxAndWhiskers); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator(); } break; case 3: // Error Bar { NErrorBarSeries errorBar = new NErrorBarSeries(); errorBar.VerticalAxisRangeMode = AxisRangeMode.ViewRange; double y; double x = 50.0; for (int i = 0; i < 50; i++) { y = 20 + Random.NextDouble() * 30; x += 2.0 + Random.NextDouble() * 2; errorBar.Values.Add(y); errorBar.LowerErrorsY.Add(1 + Random.NextDouble()); errorBar.UpperErrorsY.Add(1 + Random.NextDouble()); errorBar.XValues.Add(x); errorBar.LowerErrorsX.Add(1 + Random.NextDouble()); errorBar.UpperErrorsX.Add(1 + Random.NextDouble()); } chart.Series.Add(errorBar); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator(); } break; case 4: // "Float Bar"); { NFloatBarSeries floatBar = new NFloatBarSeries(); floatBar.VerticalAxisRangeMode = AxisRangeMode.ViewRange; // generate Y values for (int i = 0; i < 100; i++) { double dBeginValue = Random.NextDouble() * 5; double dEndValue = dBeginValue + 2 + Random.NextDouble(); floatBar.Values.Add(dBeginValue); floatBar.EndValues.Add(dEndValue); } // generate X values DateTime dt = new DateTime(2007, 5, 24, 11, 0, 0); for (int i = 0; i < 100; i++) { dt = dt.AddHours(12 + Random.NextDouble() * 60); floatBar.XValues.Add(dt); } chart.Series.Add(floatBar); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator(); } break; case 5: // Line { NLineSeries line = new NLineSeries(); line.DataLabelStyle.Visible = false; line.VerticalAxisRangeMode = AxisRangeMode.ViewRange; GenerateData(line, 100.0, numDataPoints, new NRange1DD(60, 140)); chart.Series.Add(line); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator(); } break; case 6: // Point { NPointSeries point = new NPointSeries(); point.DataLabelStyle.Visible = false; point.VerticalAxisRangeMode = AxisRangeMode.ViewRange; point.Size = new NLength(5); GenerateData(point, 100.0, numDataPoints, new NRange1DD(60, 140)); chart.Series.Add(point); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator(); } break; case 7: // Stock { // setup stock series NStockSeries stock = (NStockSeries)chart.Series.Add(SeriesType.Stock); stock.DataLabelStyle.Visible = false; stock.UpFillStyle = new NColorFillStyle(Color.White); stock.UpStrokeStyle.Color = Color.Black; stock.DownFillStyle = new NColorFillStyle(Color.Crimson); stock.DownStrokeStyle.Color = Color.Crimson; stock.HighLowStrokeStyle.Color = Color.Black; stock.CandleWidth = new NLength(1.2f, NRelativeUnit.ParentPercentage); stock.UseXValues = true; stock.InflateMargins = true; stock.VerticalAxisRangeMode = AxisRangeMode.ViewRange; // add some stock items GenerateOHLCData(stock, 100.0, numDataPoints, new NRange1DD(60, 140)); FillStockDates(stock, numDataPoints); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator(); } break; } nChartControl1.Refresh(); }
private void SetupCharts(NChart pointChart, NChart boxChart) { // data double[] arrValues = { 204.5, 190.6, 199.7, 131.8, 143.4, 215.1, 228.0, 209.2, 183.8, 169.5, 212.0, 254.9, 222.3, 201.0, 215.4, 191.3, 181.5, 207.0, 199.0, 210.0 }; // setup point chart NStandardScaleConfigurator scaleY1 = (NStandardScaleConfigurator)pointChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY1.InnerMajorTickStyle.Visible = false; scaleY1.MajorGridStyle.ShowAtWalls = new ChartWallType[0]; NOrdinalScaleConfigurator scaleX1 = (NOrdinalScaleConfigurator)pointChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleX1.InnerMajorTickStyle.Visible = false; scaleX1.DisplayDataPointsBetweenTicks = false; // setup point series NPointSeries point = (NPointSeries)pointChart.Series.Add(SeriesType.Point); point.InflateMargins = true; point.DataLabelStyle.Visible = false; point.Size = new NLength(1.5f, NRelativeUnit.RootPercentage); point.PointShape = PointShape.Ellipse; point.FillStyle = new NColorFillStyle(DarkOrange); point.BorderStyle = new NStrokeStyle(DarkOrange); point.Values.AddRange(arrValues); // setup box and whiskers chart boxChart.Width = 10; boxChart.Axis(StandardAxis.PrimaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, false); NStandardScaleConfigurator scaleY2 = (NStandardScaleConfigurator)boxChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY2.InnerMajorTickStyle.Visible = false; scaleY2.MajorGridStyle.ShowAtWalls = new ChartWallType[0]; boxChart.Axis(StandardAxis.PrimaryX).Visible = false; // setup box and whiskers series NBoxAndWhiskersSeries boxSeries = (NBoxAndWhiskersSeries)boxChart.Series.Add(SeriesType.BoxAndWhiskers); boxSeries.InflateMargins = true; boxSeries.DataLabelStyle.Visible = false; boxSeries.FillStyle = new NColorFillStyle(Red); boxSeries.OutliersFillStyle = new NColorFillStyle(DarkOrange); boxSeries.OutliersBorderStyle = new NStrokeStyle(DarkOrange); boxSeries.OutliersSize = new NLength(1.5f, NRelativeUnit.RootPercentage); boxSeries.MedianStrokeStyle = new NStrokeStyle(Color.Indigo); boxSeries.AverageStrokeStyle = new NStrokeStyle(1, Color.DarkRed, LinePattern.Dot); // create a box and whiskers data point and initialize it from the point series NBoxAndWhiskersDataPoint bwdp = new NBoxAndWhiskersDataPoint(point.Values, true, true); boxSeries.AddDataPoint(bwdp); // synchronize axes NAxis axis1 = pointChart.Axis(StandardAxis.PrimaryY); NAxis axis2 = boxChart.Axis(StandardAxis.PrimaryY); axis1.Slaves.Add(axis2); axis2.Slaves.Add(axis1); // set an axis stripe for the interquartile range double dQ1 = (double)bwdp[DataPointValue.LowerBoxValue]; double dQ3 = (double)bwdp[DataPointValue.UpperBoxValue]; NAxisStripe boxStripe = axis1.Stripes.Add(dQ1, dQ3); boxStripe.FillStyle = new NColorFillStyle(Color.FromArgb(50, GreyBlue)); // set an axis stripe for the min / max range double dMin = (double)bwdp[DataPointValue.LowerWhiskerValue]; double dMax = (double)bwdp[DataPointValue.UpperWhiskerValue]; NAxisStripe whiskersStripe = axis1.Stripes.Add(dMin, dMax); whiskersStripe.FillStyle = new NColorFillStyle(Color.FromArgb(30, GreyBlue)); }
protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithValues(BoxWidthDropDownList, 0, 100, 10); BoxWidthDropDownList.SelectedIndex = 7; WebExamplesUtilities.FillComboWithValues(WhiskersWidthDropDownList, 0, 100, 10); WhiskersWidthDropDownList.SelectedIndex = 5; LeftAxisRoundToTickCheckBox.Checked = true; InflateMarginsCheckBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Date Time Box and Whiskers"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend nChartControl1.Legends.Clear(); // setup chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // add interlaced stripe NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.RoundToTickMin = LeftAxisRoundToTickCheckBox.Checked; scaleY.RoundToTickMax = LeftAxisRoundToTickCheckBox.Checked; 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); NDateTimeScaleConfigurator timeScale = new NDateTimeScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = timeScale; timeScale.LabelGenerationMode = LabelGenerationMode.SingleLevel; timeScale.EnableUnitSensitiveFormatting = false; timeScale.LabelValueFormatter = new NDateTimeValueFormatter("dd MMM"); timeScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.Rotate90 }; // setup series NBoxAndWhiskersSeries series = (NBoxAndWhiskersSeries)chart.Series.Add(SeriesType.BoxAndWhiskers); series.DataLabelStyle.Visible = false; series.UseXValues = true; series.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant4, Red, DarkOrange); series.OutliersSize = new NLength(1.4f, NRelativeUnit.ParentPercentage); series.OutliersBorderStyle = new NStrokeStyle(GreyBlue); series.OutliersFillStyle = new NColorFillStyle(Red); series.MedianStrokeStyle = new NStrokeStyle(Color.Indigo); series.AverageStrokeStyle = new NStrokeStyle(1, Color.DarkRed, LinePattern.Dot); series.BoxWidth = new NLength(BoxWidthDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage); series.WhiskersWidthPercent = WhiskersWidthDropDownList.SelectedIndex * 10; series.InflateMargins = InflateMarginsCheckBox.Checked; GenerateData(series, 5); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }