private void SetupLineChart(NCartesianChart chart) { chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); chart.LightModel.EnableLighting = false; chart.Axis(StandardAxis.Depth).Visible = false; chart.Wall(ChartWallType.Floor).Visible = false; chart.Wall(ChartWallType.Left).Visible = false; chart.DockMargins = new NMarginsL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage), new NLength(5, NRelativeUnit.ParentPercentage)); chart.BoundsMode = BoundsMode.Stretch; // setup X axis NAxis axis = chart.Axis(StandardAxis.PrimaryX); NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator(); dateTimeScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; dateTimeScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); dateTimeScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, false); dateTimeScale.InnerMajorTickStyle.Length = new NLength(0); dateTimeScale.MaxTickCount = 8; dateTimeScale.MajorTickMode = MajorTickMode.AutoMaxCount; dateTimeScale.AutoDateTimeUnits = new NDateTimeUnit[] { NDateTimeUnit.Second }; dateTimeScale.RoundToTickMin = false; dateTimeScale.RoundToTickMax = false; dateTimeScale.EnableUnitSensitiveFormatting = false; dateTimeScale.LabelValueFormatter = new NDateTimeValueFormatter("T"); axis.ScaleConfigurator = dateTimeScale; // setup Y axis axis = chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)axis.ScaleConfigurator; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, false); linearScale.InnerMajorTickStyle.Length = new NLength(0); 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 the line series NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.Name = "Price"; line.Legend.Mode = SeriesLegendMode.None; line.DataLabelStyle.Visible = false; line.FillStyle = new NColorFillStyle(Color.RoyalBlue); line.UseXValues = true; }
private void SetupStockChart(NCartesianChart chart) { chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); chart.LightModel.EnableLighting = false; chart.Axis(StandardAxis.Depth).Visible = false; chart.Wall(ChartWallType.Floor).Visible = false; chart.Wall(ChartWallType.Left).Visible = false; chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(90, NRelativeUnit.ParentPercentage), new NLength(50, NRelativeUnit.ParentPercentage)); // setup X axis NAxis axis = chart.Axis(StandardAxis.PrimaryX); NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)axis.ScaleConfigurator; ordinalScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, false); ordinalScale.InnerMajorTickStyle.Length = new NLength(0); // setup Y axis axis = chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)axis.ScaleConfigurator; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, false); linearScale.InnerMajorTickStyle.Length = new NLength(0); 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 the stock series m_Stock = (NStockSeries)chart.Series.Add(SeriesType.Stock); m_Stock.Name = "Price"; m_Stock.Legend.Mode = SeriesLegendMode.None; m_Stock.DataLabelStyle.Visible = false; m_Stock.CandleStyle = CandleStyle.Stick; m_Stock.UpStrokeStyle.Color = Color.RoyalBlue; m_Stock.OpenValues.Name = "open"; m_Stock.HighValues.Name = "high"; m_Stock.LowValues.Name = "low"; m_Stock.CloseValues.Name = "close"; m_Stock.CandleWidth = new NLength(0.5f, NRelativeUnit.ParentPercentage); }
protected void ConfigureStockVolumesChart() { m_ChartStockVolumes = new NCartesianChart(); nChartControl1.Panels.Add(m_ChartStockVolumes); m_ChartStockVolumes.Location = new NPointL(new NLength(7, NRelativeUnit.ParentPercentage), new NLength(55, NRelativeUnit.ParentPercentage)); m_ChartStockVolumes.Size = new NSizeL(new NLength(84, NRelativeUnit.ParentPercentage), new NLength(35, NRelativeUnit.ParentPercentage)); m_ChartStockVolumes.BoundsMode = BoundsMode.Stretch; m_ChartStockVolumes.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.FromArgb(230, 230, 230)); // setup Y axis NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY.InnerMajorTickStyle.Visible = false; m_ChartStockVolumes.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // setup X axis NValueTimelineScaleConfigurator scaleX = new NValueTimelineScaleConfigurator(); scaleX.FirstRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.FirstRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(225, 225, 225)); scaleX.FirstRow.UseGridStyle = true; scaleX.FirstRow.InnerTickStyle.Visible = false; scaleX.SecondRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.SecondRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(215, 215, 215)); scaleX.SecondRow.UseGridStyle = true; scaleX.SecondRow.InnerTickStyle.Visible = false; scaleX.ThirdRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.ThirdRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(205, 205, 205)); scaleX.ThirdRow.UseGridStyle = true; scaleX.ThirdRow.InnerTickStyle.Visible = false; m_ChartStockVolumes.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // enable paging and scrollbar m_ChartStockVolumes.Axis(StandardAxis.PrimaryX).PagingView = new NDateTimeAxisPagingView(); m_ChartStockVolumes.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; // add a Bar series for the Volume values m_Volume = (NBarSeries)m_ChartStockVolumes.Series.Add(SeriesType.Bar); m_Volume.Name = "Volume"; m_Volume.DataLabelStyle.Visible = false; m_Volume.DataLabelStyle.Format = "<xvalue>"; m_Volume.DataLabelStyle.VertAlign = VertAlign.Center; m_Volume.UseXValues = true; m_Volume.InflateMargins = true; m_Volume.FillStyle = new NColorFillStyle(Color.FromArgb(119, 208, 151)); // add some stock items for (int i = 0; i < m_Stock.Values.Count; i++) { m_Volume.Values.Add(100 + Random.Next(1000)); m_Volume.XValues.Add(m_Stock.XValues[i]); } }
private NChart CreateAnchorPanelChart() { NChart chart = null; NSeries series = null; switch (MiniChartTypeComboBox.SelectedIndex) { case 0: // Pie chart = new NPieChart(); series = (NSeries)chart.Series.Add(SeriesType.Pie); break; case 1: // Doughnut { chart = new NPieChart(); NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie); pie.PieStyle = PieStyle.Torus; series = pie; break; } case 2: // Bar chart = new NCartesianChart(); chart.Wall(ChartWallType.Back).Visible = false; chart.Axis(StandardAxis.PrimaryX).Visible = false; chart.Axis(StandardAxis.PrimaryY).Visible = false; chart.Axis(StandardAxis.Depth).Visible = false; series = (NSeries)chart.Series.Add(SeriesType.Bar); break; case 3: // Area chart = new NCartesianChart(); chart.Wall(ChartWallType.Back).Visible = false; chart.Axis(StandardAxis.PrimaryX).Visible = false; chart.Axis(StandardAxis.PrimaryY).Visible = false; chart.Axis(StandardAxis.Depth).Visible = false; series = (NSeries)chart.Series.Add(SeriesType.Area); break; } chart.BoundsMode = BoundsMode.Fit; chart.DockMode = PanelDockMode.Fill; series.DataLabelStyle.Visible = false; NDataPoint dp = new NDataPoint(); for (int i = 0; i < 5; i++) { dp[DataPointValue.Value] = 5 + Random.Next(10); dp[DataPointValue.FillStyle] = new NColorFillStyle(RandomColor()); series.AddDataPoint(dp); } return(chart); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Range Timeline Scale"); header.DockMode = PanelDockMode.Top; header.Margins = new NMarginsL(2, 2, 0, 5); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.FitAlignment = ContentAlignment.MiddleLeft; header.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); nChartControl1.Panels.Add(header); // setup chart m_Chart = new NCartesianChart(); nChartControl1.Panels.Add(m_Chart); m_Chart.DockMode = PanelDockMode.Fill; m_Chart.Margins = new NMarginsL(2, 0, 2, 2); m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); m_Chart.LightModel.EnableLighting = false; m_Chart.Axis(StandardAxis.Depth).Visible = false; m_Chart.Wall(ChartWallType.Floor).Visible = false; m_Chart.Wall(ChartWallType.Left).Visible = false; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Height = 40; // setup X axis NAxis axis = m_Chart.Axis(StandardAxis.PrimaryX); axis.ScrollBar.Visible = true; NRangeTimelineScaleConfigurator timelineScale = new NRangeTimelineScaleConfigurator(); timelineScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); timelineScale.SecondRow.GridStyle.SetShowAtWall(ChartWallType.Back, true); timelineScale.ThirdRow.GridStyle.SetShowAtWall(ChartWallType.Back, true); axis.ScaleConfigurator = timelineScale; // setup primary Y axis axis = m_Chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)axis.ScaleConfigurator; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, false); linearScale.InnerMajorTickStyle.Length = new NLength(0); // add interlaced stripe NScaleStripStyle stripStyle = new NScaleStripStyle(); stripStyle.FillStyle = new NColorFillStyle(Color.Beige); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); stripStyle.Interlaced = true; linearScale.StripStyles.Add(stripStyle); // Setup the stock series m_Stock = (NStockSeries)m_Chart.Series.Add(SeriesType.Stock); m_Stock.DataLabelStyle.Visible = false; m_Stock.CandleStyle = CandleStyle.Stick; m_Stock.CandleWidth = new NLength(0.5f, NRelativeUnit.ParentPercentage); m_Stock.UpStrokeStyle.Color = Color.RoyalBlue; m_Stock.Legend.Mode = SeriesLegendMode.None; m_Stock.CloseValues.Name = "close"; m_Stock.UseXValues = true; // init form controls if (!IsPostBack) { FirstRowVisibleCheckBox.Checked = true; SecondRowVisibleCheckBox.Checked = true; ThirdRowVisibleCheckBox.Checked = true; RandomDataTypeDropDownList.Items.Add("Daily"); RandomDataTypeDropDownList.Items.Add("Weekly"); RandomDataTypeDropDownList.Items.Add("Monthly"); RandomDataTypeDropDownList.Items.Add("Yearly"); RandomDataTypeDropDownList.SelectedIndex = 2; } timelineScale.FirstRow.Visible = FirstRowVisibleCheckBox.Checked; timelineScale.SecondRow.Visible = SecondRowVisibleCheckBox.Checked; timelineScale.ThirdRow.Visible = ThirdRowVisibleCheckBox.Checked; DateTime dtNow = DateTime.Now; DateTime dtEnd = dtNow; DateTime dtStart = dtNow; NDateTimeSpan span = new NDateTimeSpan(); switch (RandomDataTypeDropDownList.SelectedIndex) { case 0: // generate data for 30 days dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 17, 0, 0, 0); dtStart = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0, 0); span = new NDateTimeSpan(5, NDateTimeUnit.Minute); break; case 1: // generate data for 30 weeks dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0, 0); dtStart = NDateTimeUnit.Week.Add(dtEnd, -30); span = new NDateTimeSpan(1, NDateTimeUnit.Day); break; case 2: // generate data for 30 months dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0, 0); dtStart = NDateTimeUnit.Month.Add(dtEnd, -30); span = new NDateTimeSpan(1, NDateTimeUnit.Week); break; case 3: // generate data for 30 years dtEnd = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0, 0); dtStart = NDateTimeUnit.Year.Add(dtEnd, -30); span = new NDateTimeSpan(1, NDateTimeUnit.Month); break; } GenerateData(dtStart, dtEnd, span); }
private void ConfigureStockValuesChart() { m_ChartStockValues = (NCartesianChart)nChartControl1.Charts[0]; m_ChartStockValues.Location = new NPointL(new NLength(7, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); m_ChartStockValues.Size = new NSizeL(new NLength(84, NRelativeUnit.ParentPercentage), new NLength(35, NRelativeUnit.ParentPercentage)); m_ChartStockValues.BoundsMode = BoundsMode.Stretch; m_ChartStockValues.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.FromArgb(230, 230, 230)); // setup Y axis NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY.InnerMajorTickStyle.Visible = false; m_ChartStockValues.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // setup X axis NValueTimelineScaleConfigurator scaleX = new NValueTimelineScaleConfigurator(); scaleX.FirstRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.FirstRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(225, 225, 225)); scaleX.FirstRow.UseGridStyle = true; scaleX.FirstRow.InnerTickStyle.Visible = false; scaleX.SecondRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.SecondRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(215, 215, 215)); scaleX.SecondRow.UseGridStyle = true; scaleX.SecondRow.InnerTickStyle.Visible = false; scaleX.ThirdRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.ThirdRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(205, 205, 205)); scaleX.ThirdRow.UseGridStyle = true; scaleX.ThirdRow.InnerTickStyle.Visible = false; m_ChartStockValues.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // create stock series m_Stock = (NStockSeries)m_ChartStockValues.Series.Add(SeriesType.Stock); m_Stock.Name = "Stock Prices"; m_Stock.UpFillStyle = new NColorFillStyle(Color.FromArgb(149, 171, 238)); m_Stock.UpStrokeStyle.Color = Color.RoyalBlue; m_Stock.DownFillStyle = new NColorFillStyle(Color.White); m_Stock.DownStrokeStyle.Color = Color.RoyalBlue; m_Stock.HighLowStrokeStyle.Color = Color.RoyalBlue; m_Stock.InflateMargins = true; m_Stock.UseXValues = true; m_Stock.CandleWidth = new NLength(1.6f, NRelativeUnit.ParentPercentage); // show the date time value in the legend m_Stock.Legend.Format = "<xvalue>"; m_Stock.XValues.ValueFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.Date); m_Stock.Legend.Mode = SeriesLegendMode.DataPoints; // configure data labels m_Stock.DataLabelStyle.Visible = false; m_Stock.DataLabelStyle.Format = "<xvalue>"; m_Stock.DataLabelStyle.VertAlign = VertAlign.Center; // add stock date time values GenerateOHLCData(m_Stock, 150, 12 * 4); // add stock date time values for (int nMonth = 1; nMonth <= 12; nMonth++) { for (int nDay = 1; nDay <= 28; nDay += 7) { m_Stock.XValues.Add(new DateTime(2003, nMonth, nDay).ToOADate()); } } }
/// <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); }
protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Custom Scale Decorations 2"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.Margins = new NMarginsL(10, 10, 10, 10); title.DockMode = PanelDockMode.Top; NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.BoundsMode = BoundsMode.Stretch; chart.DockMode = PanelDockMode.Fill; chart.Margins = new NMarginsL(10, 0, 10, 10); chart.BackgroundFillStyle = new NColorFillStyle(Color.FromArgb(231, 231, 233)); chart.MaxDockZoneMargins = new NMarginsL(100000, 100000, 100000, 100000); NStrokeBorderStyle strokeBorder = new NStrokeBorderStyle(); strokeBorder.StrokeStyle.Color = Color.FromArgb(192, 192, 192); chart.BorderStyle = strokeBorder; int dpCount = 4; double[] bar1Values = new double[dpCount]; double[] bar2Values = new double[dpCount]; NLabelInfo[] xLabels = new NLabelInfo[dpCount]; // add some dummy data Random rand = new Random(); for (int i = 0; i < dpCount; i++) { bar1Values[i] = rand.Next(100); bar2Values[i] = rand.Next(100); xLabels[i] = new NLabelInfo(i, "Label" + i.ToString(), Color.FromArgb(100, 100, 100), i % 2 == 0 ? Color.Red : Color.Orange); } NLabelInfo[] yLabels = new NLabelInfo[9]; for (int i = 0; i < 9; i++) { yLabels[i].Text = ((i + 1) * 10).ToString() + "%"; yLabels[i].Value = (i + 1) * 10; yLabels[i].ForeColor = Color.FromArgb(100, 100, 100); yLabels[i].BackColor = Color.Transparent; } // add two bars series in cluster mode NBarSeries bar1 = new NBarSeries(); bar1.Values.AddRange(bar1Values); bar1.DataLabelStyle.Visible = false; bar1.MultiBarMode = MultiBarMode.Clustered; bar1.FillStyle = new NColorFillStyle(Color.FromArgb(21, 153, 215)); bar1.FillStyle.ImageFiltersStyle.Filters.Add(new NBevelAndEmbossImageFilter()); bar1.WidthPercent = 50; bar1.GapPercent = 20; chart.Series.Add(bar1); NBarSeries bar2 = new NBarSeries(); bar2.Values.AddRange(bar2Values); bar2.DataLabelStyle.Visible = false; bar2.MultiBarMode = MultiBarMode.Clustered; bar2.FillStyle = new NColorFillStyle(Color.FromArgb(113, 127, 138)); bar2.FillStyle.ImageFiltersStyle.Filters.Add(new NBevelAndEmbossImageFilter()); bar2.WidthPercent = 50; bar2.GapPercent = 20; chart.Series.Add(bar2); // add custom labels to the x axis NLinearScaleConfigurator xScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScale; chart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new NRange1DD(-0.5, xLabels.Length - 0.5), true, true); xScale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(100, 100, 100)); xScale.AutoLabels = false; xScale.OuterMajorTickStyle.Visible = false; xScale.InnerMajorTickStyle.Visible = false; xScale.LabelStyle.Offset = new NLength(10); xScale.RulerStyle.BorderStyle.Width = new NLength(0); xScale.RulerStyle.Height = new NLength(0); NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(240, 240, 240)), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); xScale.StripStyles.Add(stripStyle); // hide the back wall chart.Wall(ChartWallType.Back).Visible = false; // configure the Y axis chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 100), true, true); NLinearScaleConfigurator yScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; yScale.AutoLabels = false; yScale.MajorTickMode = MajorTickMode.CustomTicks; yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); yScale.MajorGridStyle.LineStyle.Color = Color.FromArgb(192, 192, 192); yScale.OuterMajorTickStyle.Visible = false; yScale.InnerMajorTickStyle.Visible = false; yScale.RulerStyle.BorderStyle.Width = new NLength(0); yScale.RulerStyle.Height = new NLength(0); yScale.CreateNewLevelForCustomLabels = true; // add labels NAxis xAxis = chart.Axis(StandardAxis.PrimaryX); NAxis yAxis = chart.Axis(StandardAxis.PrimaryY); AddLabels(xAxis, true, xLabels); AddLabels(yAxis, true, yLabels); // create cross NCustomWallDecorator xDecorator = new NCustomWallDecorator(); xDecorator.WallDecorations.Add(new NGridLine(-0.5, new NStrokeStyle(Color.FromArgb(190, 190, 190)), new ChartWallType[] { ChartWallType.Back }, true)); xAxis.Scale.WallDecorators.Add(xDecorator); NCustomWallDecorator yDecorator = new NCustomWallDecorator(); yDecorator.WallDecorations.Add(new NGridLine(0, new NStrokeStyle(Color.FromArgb(190, 190, 190)), new ChartWallType[] { ChartWallType.Back }, true)); yAxis.Scale.WallDecorators.Add(yDecorator); }
protected void Page_Load(object sender, EventArgs e) { NThinChartControl1.StateId = "Chart1"; if (!NThinChartControl1.Initialized) { // enable jittering (full scene antialiasing) NThinChartControl1.Settings.JitterMode = JitterMode.Enabled; NThinChartControl1.ServerSettings.EnableTiledZoom = true; NThinChartControl1.Panels.Clear(); // apply background image border NImageFrameStyle frame = new NImageFrameStyle(); frame.Type = ImageFrameType.Raised; frame.BackgroundColor = Color.White; frame.BorderStyle.Color = Color.Gainsboro; NThinChartControl1.BackgroundStyle.FrameStyle = frame; NThinChartControl1.BackgroundStyle.FillStyle = new NGradientFillStyle(Color.White, Color.GhostWhite); // set a chart title NLabel title = new NLabel("Toolbar Configuration"); NThinChartControl1.Panels.Add(title); title.DockMode = PanelDockMode.Top; title.Padding = new NMarginsL(4, 6, 4, 6); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // configure the legend NLegend legend = new NLegend(); NThinChartControl1.Panels.Add(legend); legend.DockMode = PanelDockMode.Right; legend.Padding = new NMarginsL(1, 1, 3, 3); legend.FillStyle.SetTransparencyPercent(50); legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterLeftBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterRightBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterTopBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.VerticalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); // configure the chart NCartesianChart chart = new NCartesianChart(); NThinChartControl1.Panels.Add(chart); chart.Enable3D = true; chart.Fit3DAxisContent = true; chart.DisplayOnLegend = legend; chart.BoundsMode = BoundsMode.Fit; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.DockMode = PanelDockMode.Fill; chart.Padding = new NMarginsL( new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage)); chart.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(Color.White, Color.Gray); // setup the X axis NAxis axisX = chart.Axis(StandardAxis.PrimaryX); axisX.ScrollBar.Visible = true; NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)axisX.ScaleConfigurator; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleX.AutoLabels = false; // add interlaced stripe for the Y axis NAxis axisY = chart.Axis(StandardAxis.PrimaryY); axisY.ScrollBar.Visible = true; NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)axisY.ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; scaleY.StripStyles.Add(stripStyle); // hide the depth axis chart.Axis(StandardAxis.Depth).Visible = false; // add a bar series and fill it with data NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Name = "Simple Bar Chart"; bar.BarShape = BarShape.SmoothEdgeBar; bar.Legend.Mode = SeriesLegendMode.DataPoints; bar.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point); bar.DataLabelStyle.Visible = false; AddDataPoint(scaleX, bar, 16, "Spain", @"http://en.wikipedia.org/wiki/Spain"); AddDataPoint(scaleX, bar, 42, "France", @"http://en.wikipedia.org/wiki/France"); AddDataPoint(scaleX, bar, 56, "Germany", @"http://en.wikipedia.org/wiki/Germany"); AddDataPoint(scaleX, bar, 23, "Italy", @"http://en.wikipedia.org/wiki/Italy"); AddDataPoint(scaleX, bar, 47, "UK", @"http://en.wikipedia.org/wiki/UK"); AddDataPoint(scaleX, bar, 38, "Sweden", @"http://en.wikipedia.org/wiki/Sweden"); // add the index of the bar to highlight NThinChartControl1.CustomData = 0; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(bar); // configure toolbar NThinChartControl1.Toolbar.Visible = true; NThinChartControl1.Controller.SetActivePanel(chart); NThinChartControl1.AutoUpdateCallback = new NAutoUpdateCallback(); //NThinChartControl1.Controller.EnableAutoUpdate = true; NTrackballTool tbt = new NTrackballTool(); tbt.Exclusive = true; tbt.Enabled = true; NThinChartControl1.Controller.Tools.Add(tbt); // add a data zoom tool NDataZoomTool dataZoomTool = new NDataZoomTool(); dataZoomTool.Exclusive = true; dataZoomTool.Enabled = false; NThinChartControl1.Controller.Tools.Add(dataZoomTool); // add a data pan tool NDataPanTool dataPanTool = new NDataPanTool(); dataPanTool.Exclusive = true; dataPanTool.Enabled = false; NThinChartControl1.Controller.Tools.Add(dataPanTool); // add a tooltip tool NThinChartControl1.Controller.Tools.Add(new NTooltipTool()); // add a cursor change tool NThinChartControl1.Controller.Tools.Add(new NCursorTool()); // add a browser redirect tool NThinChartControl1.Controller.Tools.Add(new NBrowserRedirectTool()); NThinChartControl1.Toolbar.Visible = true; NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveStateAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as PDF", new NPdfImageFormat(), true, new NSize(), 300))); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as SVG", new NSvgImageFormat(), true, new NSize(), 96))); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as XAML", new NXamlImageFormat(), true, new NSize(), 96))); NSaveImageAction sia = new NSaveImageAction("Bitmap.bmp", new NBitmapImageFormat(), true, new NSize(), 96); sia.Tooltip = "Print or Save as Bitmap"; NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(sia)); NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator()); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NTogglePanelSelectorToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataZoomToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataPanToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleTrackballToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator()); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleAutoUpdateAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleChart3DAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleChartLightingAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator()); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleTooltipToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleBrowserRedirectToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleCursorToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator()); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new ShowDataLabelsAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new HideDataLabelsAction())); NThinChartControl1.CustomRequestCallback = new CustomRequestCallback(); } }
private NChart CreateAnchorPanelChart() { NChart chart = null; NSeries series = null; NLinearScaleConfigurator linearScale; switch (MiniChartTypeDropDownList.SelectedIndex) { case 0: // Pie chart = new NPieChart(); series = (NSeries)chart.Series.Add(SeriesType.Pie); SetDataPointColors(series); break; case 1: // Doughnut chart = new NPieChart(); NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie); pie.PieStyle = PieStyle.Ring; ((NPieChart)chart).InnerRadius = new NLength(25, NRelativeUnit.ParentPercentage); series = pie; SetDataPointColors(series); break; case 2: // Bar chart = new NCartesianChart(); chart.Wall(ChartWallType.Back).Visible = false; chart.Axis(StandardAxis.PrimaryX).Visible = false; chart.Axis(StandardAxis.PrimaryY).Visible = false; chart.Axis(StandardAxis.Depth).Visible = false; linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScale.MajorGridStyle.LineStyle.Width = new NLength(0); series = (NSeries)chart.Series.Add(SeriesType.Bar); SetDataPointColors(series); break; case 3: // Area chart = new NCartesianChart(); chart.Wall(ChartWallType.Back).Visible = false; chart.Axis(StandardAxis.PrimaryX).Visible = false; chart.Axis(StandardAxis.PrimaryY).Visible = false; chart.Axis(StandardAxis.Depth).Visible = false; linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScale.MajorGridStyle.LineStyle.Width = new NLength(0); series = (NSeries)chart.Series.Add(SeriesType.Area); series.FillStyle = new NColorFillStyle(DarkOrange); break; } chart.BoundsMode = BoundsMode.Fit; chart.DockMode = PanelDockMode.Fill; series.DataLabelStyle.Visible = false; for (int i = 0; i < 5; i++) { series.Values.Add(5 + Random.Next(10)); } return(chart); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // setup chart 1 NChart chart1 = new NCartesianChart(); nChartControl1.Charts.Add(chart1); chart1.BoundsMode = BoundsMode.Stretch; chart1.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.FromArgb(220, 220, 235)); // setup X axis NAxis axisX = chart1.Axis(StandardAxis.PrimaryX); NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.InnerMajorTickStyle.Visible = false; scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; axisX.ScaleConfigurator = scaleX; ((NDockAxisAnchor)axisX.Anchor).AxisDockZone = AxisDockZone.FrontTop; // setup Y axis chart1.Axis(StandardAxis.PrimaryY).ScaleConfigurator.InnerMajorTickStyle.Visible = false; // add a line series NLineSeries line1 = new NLineSeries(); chart1.Series.Add(line1); line1.DataLabelStyle.Visible = false; line1.BorderStyle = new NStrokeStyle(2, Color.Peru); line1.FillStyle = new NColorFillStyle(Color.Peru); // setup chart 2 NChart chart2 = new NCartesianChart(); nChartControl1.Charts.Add(chart2); chart2.BoundsMode = BoundsMode.Stretch; chart2.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.FromArgb(220, 220, 235)); // setup X axis scaleX = new NLinearScaleConfigurator(); scaleX.InnerMajorTickStyle.Visible = false; scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; chart2.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // setup Y axis chart2.Axis(StandardAxis.PrimaryY).ScaleConfigurator.InnerMajorTickStyle.Visible = false; // add a line series NLineSeries line2 = new NLineSeries(); chart2.Series.Add(line2); line2.DataLabelStyle.Visible = false; line2.BorderStyle = new NStrokeStyle(2, Color.Olive); line2.FillStyle = new NColorFillStyle(Color.Olive); // fill some data for (int i = 0; i < 100; i++) { line1.Values.Add(Math.Sin(i * 0.05) * (Random.NextDouble() + 1.0)); line2.Values.Add(Math.Cos(i * 0.1) * (Random.NextDouble() + 1.0)); } // init form controls LeftMarginScrollBar.Value = 10; TopMarginScrollBar.Value = 12; RightMarginScrollBar.Value = 90; BottomMarginScrollBar.Value = 88; }
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)); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Chart Walls<br/><font size = '9pt'>Demonstrates how to enable automatic wall visibility and automatic axis anchors</font>"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.TextStyle.TextFormat = TextFormat.XML; title.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center; nChartControl1.Panels.Add(title); NChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.Enable3D = true; chart.Width = 55; chart.Height = 25; chart.Depth = 40; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); // add interlaced stripe to the Y axis 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, ChartWallType.Right, ChartWallType.Front }; NStandardScaleConfigurator scaleY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.StripStyles.Add(stripStyle); // create several series for (int i = 0; i < 4; i++) { NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Values.FillRandom(Random, 6); bar.DataLabelStyle.Visible = false; } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // update form controls if (!IsPostBack) { RotationTextBox.Text = chart.Projection.Rotation.ToString(); ElevationTextBox.Text = chart.Projection.Elevation.ToString(); LightsInCameraSpaceCheckBox.Checked = true; AutoWallsVisibilityCheckBox.Checked = true; AxisAnchorsModeDropDownList.Items.Add("Best Visibility"); AxisAnchorsModeDropDownList.Items.Add("Auto Side"); AxisAnchorsModeDropDownList.Items.Add("Manual"); AxisAnchorsModeDropDownList.SelectedIndex = 0; } // configure lights NPointLightSource lightSource = new NPointLightSource(); lightSource.Position = new NVector3DF(2, 2, 50); lightSource.Ambient = Color.FromArgb(64, 64, 64); lightSource.Diffuse = Color.FromArgb(255, 255, 255); lightSource.Specular = Color.FromArgb(100, 100, 100); chart.LightModel.LightSources.Clear(); chart.LightModel.LightSources.Add(lightSource); chart.LightModel.GlobalAmbientLight = Color.FromArgb(0, 0, 0); if (LightsInCameraSpaceCheckBox.Checked) { lightSource.CoordinateMode = LightSourceCoordinateMode.Camera; lightSource.Position = new NVector3DF(0, 0, 50); } else { lightSource.CoordinateMode = LightSourceCoordinateMode.Model; lightSource.Position = new NVector3DF(100, 95, 110); } chart.Projection.Rotation = (float)Convert.ToDouble(RotationTextBox.Text); chart.Projection.Elevation = (float)Convert.ToDouble(ElevationTextBox.Text); // update walls visiblity if (AutoWallsVisibilityCheckBox.Checked) { foreach (NChartWall wall in chart.Walls) { wall.VisibilityMode = WallVisibilityMode.Auto; } } else { chart.Wall(ChartWallType.Left).VisibilityMode = WallVisibilityMode.Visible; chart.Wall(ChartWallType.Back).VisibilityMode = WallVisibilityMode.Visible; chart.Wall(ChartWallType.Floor).VisibilityMode = WallVisibilityMode.Visible; chart.Wall(ChartWallType.Front).VisibilityMode = WallVisibilityMode.Hidden; chart.Wall(ChartWallType.Top).VisibilityMode = WallVisibilityMode.Hidden; chart.Wall(ChartWallType.Right).VisibilityMode = WallVisibilityMode.Hidden; } // update axis anchors NAxisAnchor anchorY = null; NAxisAnchor anchorX = null; NAxisAnchor anchorZ = null; switch (AxisAnchorsModeDropDownList.SelectedIndex) { case 0: anchorY = new NBestVisibilityAxisAnchor(AxisOrientation.Vertical); anchorX = new NBestVisibilityAxisAnchor(AxisOrientation.Horizontal); anchorZ = new NBestVisibilityAxisAnchor(AxisOrientation.Depth); break; case 1: anchorY = new NAutoSideAxisAnchor(AxisOrientation.Vertical); anchorX = new NAutoSideAxisAnchor(AxisOrientation.Horizontal); anchorZ = new NAutoSideAxisAnchor(AxisOrientation.Depth); break; case 2: anchorY = new NDockAxisAnchor(AxisDockZone.FrontLeft); anchorX = new NDockAxisAnchor(AxisDockZone.FrontBottom); anchorZ = new NDockAxisAnchor(AxisDockZone.BottomRight); break; } chart.Axis(StandardAxis.PrimaryY).Anchor = anchorY; chart.Axis(StandardAxis.PrimaryX).Anchor = anchorX; chart.Axis(StandardAxis.Depth).Anchor = anchorZ; // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
public override void Initialize() { base.Initialize(); nChartControl1.Controller.Tools.Add(new NTrackballTool()); nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Chart Aspect 3D"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.DockMode = PanelDockMode.Top; title.Margins = new NMarginsL(10, 10, 10, 0); nChartControl1.Panels.Add(title); // setup chart NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.DockMode = PanelDockMode.Fill; chart.Margins = new NMarginsL(new NLength(10)); chart.Padding = new NMarginsL(2); chart.Enable3D = true; chart.Width = 50; chart.Height = 50; chart.Depth = 50; chart.BoundsMode = BoundsMode.Fit; chart.ContentAlignment = ContentAlignment.BottomRight; chart.Location = new NPointL(new NLength(15, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(70, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); chart.Wall(ChartWallType.Back).Width = 0.01f; chart.Wall(ChartWallType.Floor).Width = 0.01f; chart.Wall(ChartWallType.Left).Width = 0.01f; // apply predefined projection and lighting chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.BrightCameraLight); // add axis labels NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.Depth).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Labels.Add("Miami"); ordinalScale.Labels.Add("Chicago"); ordinalScale.Labels.Add("Los Angeles"); ordinalScale.Labels.Add("New York"); ordinalScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0); ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); // 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); int barsCount = 7; // add the first bar NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar1.MultiBarMode = MultiBarMode.Series; bar1.Name = "Bar1"; bar1.DataLabelStyle.Visible = false; bar1.BorderStyle.Color = Color.FromArgb(210, 210, 255); // add the second bar NBarSeries bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar2.MultiBarMode = MultiBarMode.Series; bar2.Name = "Bar2"; bar2.DataLabelStyle.Visible = false; bar2.BorderStyle.Color = Color.FromArgb(210, 255, 210); // add the third bar NBarSeries bar3 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar3.MultiBarMode = MultiBarMode.Series; bar3.Name = "Bar3"; bar3.DataLabelStyle.Visible = false; bar3.BorderStyle.Color = Color.FromArgb(255, 255, 210); // add the second bar NBarSeries bar4 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar4.MultiBarMode = MultiBarMode.Series; bar4.Name = "Bar4"; bar4.DataLabelStyle.Visible = false; bar4.BorderStyle.Color = Color.FromArgb(255, 210, 210); // fill with random data bar1.Values.FillRandomRange(Random, barsCount, 10, 40); bar2.Values.FillRandomRange(Random, barsCount, 30, 60); bar3.Values.FillRandomRange(Random, barsCount, 50, 80); bar4.Values.FillRandomRange(Random, barsCount, 70, 100); // setup trackball interactivity 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); // init form controls for (int i = 1; i <= 5; i++) { XProportionCombo.Items.Add(i.ToString()); YProportionCombo.Items.Add(i.ToString()); ZProportionCombo.Items.Add(i.ToString()); } XProportionCombo.SelectedIndex = 0; YProportionCombo.SelectedIndex = 0; ZProportionCombo.SelectedIndex = 0; FitAxisContentCheckBox.Checked = true; ShowContentAreaCheckBox.Checked = false; }
private void InitMap(NChartControl nChartControl) { // configure the chart NCartesianChart chart = (NCartesianChart)nChartControl.Charts[0]; chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalTop); chart.BoundsMode = BoundsMode.Stretch; chart.Enable3D = true; chart.Fit3DAxisContent = false; // No Legend & No Update nChartControl.Legends.Clear(); nChartControl.ServiceManager.LegendUpdateService.UpdateAutoLegends(); nChartControl.ServiceManager.LegendUpdateService.Stop(); chart.Width = _gridSizeX; chart.Height = 20; chart.Depth = _gridSizeY; // Wall Setup NChartWall backWall = chart.Wall(ChartWallType.Back); backWall.Visible = false; NChartWall leftWall = chart.Wall(ChartWallType.Left); leftWall.Visible = false; // 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; NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; chart.Axis(StandardAxis.SecondaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 50.0f, 50.0f); // Axis Visable Setup. //chart.Axis(StandardAxis.PrimaryX).Visible = false; chart.Axis(StandardAxis.PrimaryY).Visible = false; //chart.Axis(StandardAxis.Depth).Visible = false; for (int i = 0; i < _gridSizeY; i++) { // add the first line NBarSeries bar = new NBarSeries(); chart.Series.Add(bar); bar.WidthPercent = 100.0f; bar.DepthPercent = 100.0f; bar.EnableDepthSort = false; bar.DataLabelStyle.Visible = false; //bar.Values.ValueFormatter = new NNumericValueFormatter("0.0"); bar.Values.EmptyDataPoints.ValueMode = EmptyDataPointsValueMode.Skip; //bar.Values.Clear(); bar.FillStyles.StorageType = IndexedStorageType.Array; bar.DataPointOriginIndex = 0; // turn off bar border to improve performance bar.BorderStyle.Width = new NLength(0.5f); } nChartControl.Settings.RenderSurface = RenderSurface.Window; nChartControl.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl.Controller.Tools.Add(new NTrackballTool()); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Value Timeline Scale<br/><font size = '9pt'>Demonstrates how to use a timeline scale to show date/time information on the X axis</font>"); header.DockMode = PanelDockMode.Top; header.Margins = new NMarginsL(0, 10, 0, 10); header.TextStyle.TextFormat = TextFormat.XML; header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); nChartControl1.Panels.Add(header); // setup chart m_Chart = new NCartesianChart(); nChartControl1.Panels.Add(m_Chart); m_Chart.DockMode = PanelDockMode.Fill; m_Chart.Margins = new NMarginsL(10, 0, 10, 10); m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); m_Chart.LightModel.EnableLighting = false; m_Chart.Axis(StandardAxis.Depth).Visible = false; m_Chart.Wall(ChartWallType.Floor).Visible = false; m_Chart.Wall(ChartWallType.Left).Visible = false; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Height = 40; 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)); NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); m_Chart.RangeSelections.Add(rangeSelection); // setup X axis NAxis axis = m_Chart.Axis(StandardAxis.PrimaryX); axis.ScrollBar.Visible = true; NValueTimelineScaleConfigurator timeLineScale = new NValueTimelineScaleConfigurator(); timeLineScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); timeLineScale.SecondRow.GridStyle.SetShowAtWall(ChartWallType.Back, true); timeLineScale.ThirdRow.GridStyle.SetShowAtWall(ChartWallType.Back, true); axis.ScaleConfigurator = timeLineScale; // setup primary Y axis axis = m_Chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)axis.ScaleConfigurator; // configure ticks and grid lines linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.InnerMajorTickStyle.Length = new NLength(0); // add interlaced stripe NScaleStripStyle stripStyle = new NScaleStripStyle(); stripStyle.FillStyle = new NColorFillStyle(Color.Beige); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); stripStyle.Interlaced = true; linearScale.StripStyles.Add(stripStyle); // Setup the stock series m_Stock = (NStockSeries)m_Chart.Series.Add(SeriesType.Stock); m_Stock.DataLabelStyle.Visible = false; m_Stock.CandleStyle = CandleStyle.Stick; m_Stock.CandleWidth = new NLength(0.5f, NRelativeUnit.ParentPercentage); m_Stock.UpStrokeStyle.Color = Color.RoyalBlue; m_Stock.Legend.Mode = SeriesLegendMode.None; m_Stock.CloseValues.Name = "close"; m_Stock.UseXValues = true; // configure interactivity nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); // update form controls FirstRowVisibleCheckBox.Checked = true; SecondRowVisibleCheckBox.Checked = true; ThirdRowVisibleCheckBox.Checked = true; // generate some data MonthlyDataButton_Click(null, null); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Chart Aspect 3D"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.DockMode = PanelDockMode.Top; title.Margins = new NMarginsL(10, 10, 10, 0); nChartControl1.Panels.Add(title); // setup chart NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.DockMode = PanelDockMode.Fill; chart.Margins = new NMarginsL(new NLength(10)); chart.Padding = new NMarginsL(2); chart.Enable3D = true; chart.Width = 50; chart.Height = 50; chart.Depth = 50; chart.BoundsMode = BoundsMode.Fit; chart.ContentAlignment = ContentAlignment.BottomRight; chart.Location = new NPointL(new NLength(15, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(70, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); chart.Wall(ChartWallType.Back).Width = 0.01f; chart.Wall(ChartWallType.Floor).Width = 0.01f; chart.Wall(ChartWallType.Left).Width = 0.01f; // apply predefined projection and lighting chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.BrightCameraLight); // add axis labels NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.Depth).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Labels.Add("Miami"); ordinalScale.Labels.Add("Chicago"); ordinalScale.Labels.Add("Los Angeles"); ordinalScale.Labels.Add("New York"); ordinalScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0); ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); // 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); int barsCount = 7; // add the first bar NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar1.MultiBarMode = MultiBarMode.Series; bar1.Name = "Bar1"; bar1.DataLabelStyle.Visible = false; bar1.BorderStyle.Color = Color.FromArgb(210, 210, 255); // add the second bar NBarSeries bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar2.MultiBarMode = MultiBarMode.Series; bar2.Name = "Bar2"; bar2.DataLabelStyle.Visible = false; bar2.BorderStyle.Color = Color.FromArgb(210, 255, 210); // add the third bar NBarSeries bar3 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar3.MultiBarMode = MultiBarMode.Series; bar3.Name = "Bar3"; bar3.DataLabelStyle.Visible = false; bar3.BorderStyle.Color = Color.FromArgb(255, 255, 210); // add the second bar NBarSeries bar4 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar4.MultiBarMode = MultiBarMode.Series; bar4.Name = "Bar4"; bar4.DataLabelStyle.Visible = false; bar4.BorderStyle.Color = Color.FromArgb(255, 210, 210); // fill with random data bar1.Values.FillRandomRange(Random, barsCount, 10, 40); bar2.Values.FillRandomRange(Random, barsCount, 30, 60); bar3.Values.FillRandomRange(Random, barsCount, 50, 80); bar4.Values.FillRandomRange(Random, barsCount, 70, 100); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); if (!IsPostBack) { // init form controls WebExamplesUtilities.FillComboWithValues(XProportionDropDownList, 1, 5, 1); XProportionDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithValues(YProportionDropDownList, 1, 5, 1); YProportionDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithValues(DepthProportionDropDownList, 1, 5, 1); DepthProportionDropDownList.SelectedIndex = 0; Fit3DAxisContentCheckBox.Checked = true; ShowContentAreaCheckBox.Checked = false; } chart.Width = (XProportionDropDownList.SelectedIndex + 1) * 10; chart.Height = (YProportionDropDownList.SelectedIndex + 1) * 10; chart.Depth = (DepthProportionDropDownList.SelectedIndex + 1) * 10; float max = Math.Max(Math.Max(chart.Width, chart.Height), chart.Depth); float scale = 50 / max; chart.Width *= scale; chart.Height *= scale; chart.Depth *= scale; chart.Fit3DAxisContent = Fit3DAxisContentCheckBox.Checked; if (ShowContentAreaCheckBox.Checked) { chart.BorderStyle = new NStrokeBorderStyle(); } else { chart.BorderStyle = null; } }