private void UpdateInterlaceStirpes() { if (m_Updating) { return; } NStandardScaleConfigurator standardScale = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; standardScale.StripStyles.Clear(); if (YAxisInterlacedStripesCheckBox.Checked) { standardScale.StripStyles.Add(m_YAxisInterlaceStyle); } m_YAxisInterlaceStyle.Begin = (int)YAxisInterlacedStripesBegin.Value; m_YAxisInterlaceStyle.End = (int)YAxisInterlacedStripesEnd.Value; m_YAxisInterlaceStyle.Infinite = YAxisInterlacedStripesInfinite.Checked; m_YAxisInterlaceStyle.Length = (int)YAxisInterlacedStripesLength.Value; m_YAxisInterlaceStyle.Interval = (int)YAxisInterlacedStripeInterval.Value; standardScale = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; standardScale.StripStyles.Clear(); if (XAxisInterlacedStripesCheckBox.Checked) { standardScale.StripStyles.Add(m_XAxisInterlaceStyle); } m_XAxisInterlaceStyle.Begin = (int)XAxisInterlacedStripesBegin.Value; m_XAxisInterlaceStyle.End = (int)XAxisInterlacedStripesEnd.Value; m_XAxisInterlaceStyle.Infinite = XAxisInterlacedStripesInfinite.Checked; m_XAxisInterlaceStyle.Length = (int)XAxisInterlacedStripesLength.Value; m_XAxisInterlaceStyle.Interval = (int)XAxisInterlacedStripeInterval.Value; nChartControl1.Refresh(); }
void UpdateDataWindow(string webControlId, System.Web.HttpContext context, NStateObject state, NPointF ptViewPoint) { NChartSessionStateObject chartState = state as NChartSessionStateObject; NRootPanel rootPanel = chartState.Document.RootPanel; NCartesianChart chart = rootPanel.Charts[0] as NCartesianChart; NVector2DD vecScalePoint = new NVector2DD(); NAxis xAxis = chart.Axis(StandardAxis.PrimaryX); NAxis yAxis = chart.Axis(StandardAxis.PrimaryY); using (NChartRasterView view = new NChartRasterView(chartState.Document, chartState.Size, NResolution.ScreenResolution)) { view.RecalcLayout(); NViewToScale2DTransformation viewToScale = new NViewToScale2DTransformation( view.Context, chart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY ); if (viewToScale.Transform(ptViewPoint, ref vecScalePoint)) { double rangeMin = vecScalePoint.X - DataWindowWidth / 2; rangeMin = xAxis.Scale.ViewRange.GetValueInRange(rangeMin); double rangeMax = rangeMin + DataWindowWidth; rangeMax = xAxis.Scale.ViewRange.GetValueInRange(rangeMax); rangeMin = rangeMax - DataWindowWidth; NRangeSelection selection = chart.RangeSelections[0] as NRangeSelection; selection.HorizontalAxisRange = new NRange1DD(rangeMin, rangeMax); selection.VerticalAxisRange = new NRange1DD(-waveDataWave1Factor, waveDataWave1Factor); } } }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Technical Price Indicators"); 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)); // configure the legend position nChartControl1.Legends[0].Location = new NPointL(new NLength(95, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup Stock chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); SetupTimeScale(chart.Axis(StandardAxis.PrimaryX)); SetupStockChart(chart); SetupIndicatorChart(chart); // generate data GenerateData(); // form controls m_FunctionCombo.Items.Add("Average True Range"); m_FunctionCombo.Items.Add("Chaikin's Volatility"); m_FunctionCombo.Items.Add("Commodity Channel Index"); m_FunctionCombo.Items.Add("Detrended Price Oscillator"); m_FunctionCombo.Items.Add("MACD"); m_FunctionCombo.Items.Add("Mass Index"); m_FunctionCombo.Items.Add("Momentum"); m_FunctionCombo.Items.Add("Momentum Div"); m_FunctionCombo.Items.Add("Performance"); m_FunctionCombo.Items.Add("Rate Of Change"); m_FunctionCombo.Items.Add("Relative Strength Index"); m_FunctionCombo.Items.Add("Standard Deviation"); m_FunctionCombo.Items.Add("Stochastic"); m_FunctionCombo.Items.Add("TRIX"); m_FunctionCombo.Items.Add("William's %R"); m_FunctionCombo.SelectedIndex = 0; m_PeriodScroll.Value = 10; }
private void OnYViewRangeChanged(object sender, EventArgs e) { if (nChartControl1 == null) { return; } NCartesianChart chart = nChartControl1.Charts[0] as NCartesianChart; if (chart != null) { m_Update = true; YAxisPageSizeNumericUpDown.Value = (decimal)chart.Axis(StandardAxis.PrimaryY).ScrollBar.ViewRange.GetLength(); m_Update = false; } }
private void YAxisPageSizeNumericUpDown_ValueChanged(object sender, System.EventArgs e) { if (nChartControl1 == null || m_Update) { return; } NCartesianChart chart = nChartControl1.Charts[0] as NCartesianChart; if (chart != null) { NNumericAxisPagingView pagingView = chart.Axis(StandardAxis.PrimaryY).PagingView as NNumericAxisPagingView; pagingView.Length = (double)YAxisPageSizeNumericUpDown.Value; nChartControl1.Refresh(); } }
private void GenerateData(DateTime dtStart, DateTime dtEnd, NDateTimeSpan span) { long count = span.GetSpanCountInRange(new NDateTimeRange(dtStart, dtEnd)); WebExamplesUtilities.GenerateOHLCData(m_Stock, 100, (int)count); m_Stock.XValues.Clear(); DateTime dtNow = dtStart; for (int i = 0; i < m_Stock.Values.Count; i++) { m_Stock.XValues.Add(dtNow.ToOADate()); dtNow = span.Add(dtNow); } m_Chart.Axis(StandardAxis.PrimaryX).PagingView.Enabled = false; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Volume Indicators<br/><font size = '10pt'>Demonstrates how to use build in financial functions</font>"); title.TextStyle.TextFormat = TextFormat.XML; 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)); // configure the legend position nChartControl1.Legends[0].Location = new NPointL(new NLength(95, 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(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); SetupTimeScale(chart.Axis(StandardAxis.PrimaryX)); SetupStockChart(chart); SetupVolumeChart(chart); SetupIndicatorChart(chart); // generate data GenerateData(); // form controls m_FunctionCombo.Items.Add("Accumulation Distribution"); m_FunctionCombo.Items.Add("Chaikin Oscillator"); m_FunctionCombo.Items.Add("Ease of Movement"); m_FunctionCombo.Items.Add("Money Flow Index"); m_FunctionCombo.Items.Add("Negative Volume Index"); m_FunctionCombo.Items.Add("On Balance Volume"); m_FunctionCombo.Items.Add("Positive Volume Index"); m_FunctionCombo.Items.Add("Price and Volume Trend"); m_FunctionCombo.SelectedIndex = 0; m_ParameterScroll.Value = 10; }
private void SetupIndicatorChart(NCartesianChart chart) { // setup Y axis NAxis axisY2 = chart.Axis(StandardAxis.SecondaryY); axisY2.Visible = true; axisY2.Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 0, 35); NLinearScaleConfigurator scaleY2 = (NLinearScaleConfigurator)axisY2.ScaleConfigurator; scaleY2.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY2.InnerMajorTickStyle.Length = new NLength(0); // Add line series for function m_Line = (NLineSeries)chart.Series.Add(SeriesType.Line); m_Line.DataLabelStyle.Visible = false; m_Line.BorderStyle.Color = Color.Blue; m_Line.UseXValues = true; m_Line.DisplayOnAxis(StandardAxis.PrimaryY, false); m_Line.DisplayOnAxis(StandardAxis.SecondaryY, true); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Dynamic Y Axis Range"); 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)); NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rangeSelection); ChartTypeComboBox.Items.Add("Area"); ChartTypeComboBox.Items.Add("Bar"); ChartTypeComboBox.Items.Add("Box And Whiskers"); ChartTypeComboBox.Items.Add("Error Bar"); ChartTypeComboBox.Items.Add("Float Bar"); ChartTypeComboBox.Items.Add("Line"); ChartTypeComboBox.Items.Add("Point"); ChartTypeComboBox.Items.Add("Stock"); ChartTypeComboBox.SelectedIndex = 0; // enable interactivity nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Stock Data Grouping"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); // no legend nChartControl1.Legends.Clear(); // setup chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; NRangeSelection rs = new NRangeSelection(); rs.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rs); // 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; // calendar NWeekDayRule wdr = new NWeekDayRule(WeekDayBit.All); wdr.Saturday = false; wdr.Sunday = false; scaleX.Calendar.Rules.Add(wdr); scaleX.EnableCalendar = true; // set configurator chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.OuterMajorTickStyle.Length = new NLength(3, NGraphicsUnit.Point); scaleY.InnerMajorTickStyle.Visible = false; NFillStyle stripFill = new NColorFillStyle(Color.FromArgb(234, 233, 237)); NScaleStripStyle stripStyle = new NScaleStripStyle(stripFill, null, true, 1, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; stripStyle.Interlaced = true; scaleY.StripStyles.Add(stripStyle); // setup stock series m_Stock = (NStockSeries)chart.Series.Add(SeriesType.Stock); m_Stock.DataLabelStyle.Visible = false; m_Stock.UpFillStyle = new NColorFillStyle(Color.White); m_Stock.UpStrokeStyle.Color = Color.Black; m_Stock.DownFillStyle = new NColorFillStyle(Color.Crimson); m_Stock.DownStrokeStyle.Color = Color.Crimson; m_Stock.HighLowStrokeStyle.Color = Color.Black; m_Stock.CandleWidth = new NLength(1.2f, NRelativeUnit.ParentPercentage); m_Stock.UseXValues = true; m_Stock.InflateMargins = true; m_Stock.DataLabelStyle.Format = "open - <open>\r\nclose - <close>"; // add some stock items const int numDataPoints = 10000; GenerateOHLCData(m_Stock, 100.0, numDataPoints, new NRange1DD(60, 140)); FillStockDates(m_Stock, numDataPoints, DateTime.Now - new TimeSpan((int)(numDataPoints * 1.2), 0, 0, 0)); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); // apply layout ConfigureStandardLayout(chart, title, null); // update form controls CustomDateTimeSpanComboBox.Items.Add("1 Week"); CustomDateTimeSpanComboBox.Items.Add("2 Weeks"); CustomDateTimeSpanComboBox.Items.Add("1 Month"); CustomDateTimeSpanComboBox.Items.Add("3 Months"); NExampleHelpers.FillComboWithEnumValues(GroupingModeComboBox, typeof(StockGroupingMode)); CustomDateTimeSpanComboBox.SelectedIndex = 2; GroupingModeComboBox.SelectedIndex = (int)StockGroupingMode.AutoDateTimeSpan; }
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) { 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); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = new NLabel("Range Selection Resize and Panning"); title.DockMode = PanelDockMode.Top; 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)); nChartControl1.Panels.Add(title); // configure chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; // switch the x to linear scale chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator(); // create the range selection m_RangeSelection = new NRangeSelection(); m_RangeSelection.AllowHorizontalResize = true; m_RangeSelection.AllowVerticalResize = true; m_RangeSelection.AllowPan = true; m_RangeSelection.PaintInverted = true; m_RangeSelection.HorizontalAxisRange = new Nevron.GraphicsCore.NRange1DD(20, 40); m_RangeSelection.VerticalAxisRange = new Nevron.GraphicsCore.NRange1DD(20, 40); m_RangeSelection.Visible = true; m_RangeSelection.ShowGrippers = true; chart.RangeSelections.Add(m_RangeSelection); m_RangeSelection.HorizontalAxisRangeChanged += new EventHandler(OnRangeSelectionHorizontalAxisRangeChanged); m_RangeSelection.VerticalAxisRangeChanged += new EventHandler(OnRangeSelectionVerticalAxisRangeChanged); NPointSeries point = new NPointSeries(); point.UseXValues = true; point.InflateMargins = true; point.Size = new NLength(5); point.DataLabelStyle.Visible = false; Random random = new Random(); for (int i = 0; i < 100; i++) { point.Values.Add(random.Next(100)); point.XValues.Add(random.Next(100)); } chart.Series.Add(point); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NRangeSelectionMoveResizeTool()); AllowHorizontalResizeCheckBox.Checked = m_RangeSelection.AllowHorizontalResize; AllowVerticalResizeCheckBox.Checked = m_RangeSelection.AllowVerticalResize; AllowPanCheckBox.Checked = m_RangeSelection.AllowPan; PaintInvertedCheckBox.Checked = m_RangeSelection.PaintInverted; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } nChartControl1.Panels.Clear(); nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = new NLabel("Flash Interactivity"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.DockMode = PanelDockMode.Top; title.InteractivityStyle.UrlLink.Url = "http://www.apple.com"; nChartControl1.Panels.Add(title); NDockPanel contentPanel = new NDockPanel(); nChartControl1.Panels.Add(contentPanel); contentPanel.DockMode = PanelDockMode.Fill; // configure the chart NCartesianChart chart = new NCartesianChart(); contentPanel.ChildPanels.Add(chart); chart.Location = new NPointL(0, 0); chart.Size = new NSizeL(new NLength(100, NRelativeUnit.ParentPercentage), new NLength(60, NRelativeUnit.ParentPercentage)); chart.Enable3D = false; chart.Axis(StandardAxis.Depth).Visible = false; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.BrightCameraLight); chart.Margins = new NMarginsL(5, 5, 5, 5); chart.BoundsMode = BoundsMode.Stretch; chart.DockMode = PanelDockMode.Fill; // configure axes NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Labels.Add("2004"); ordinalScale.Labels.Add("2005"); ordinalScale.Labels.Add("2006"); ordinalScale.Labels.Add("2007"); ordinalScale.Labels.Add("2008"); ordinalScale.Labels.Add("2009"); // add interlace stripe NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; linearScale.Title.Text = "Sales in Thousands USD"; linearScale.MinTickDistance = new NLength(15); 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); // create series NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); NBarSeries bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); NBarSeries bar3 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar1.MultiBarMode = MultiBarMode.Clustered; bar2.MultiBarMode = MultiBarMode.Clustered; bar3.MultiBarMode = MultiBarMode.Clustered; // configure common settings bar1.Name = "Apple"; bar2.InteractivityStyle.UrlLink.Url = "http://www.apple.com"; bar1.DataLabelStyle.Visible = false; bar2.Name = "Nokia"; bar2.InteractivityStyle.UrlLink.Url = "http://www.nokia.com"; bar2.DataLabelStyle.Visible = false; bar3.Name = "HTC"; bar3.InteractivityStyle.UrlLink.Url = "http://www.htc.com"; bar3.DataLabelStyle.Visible = false; // fill with random data bar1.Values.FillRandomRange(Random, 6, 10, 100); bar2.Values.FillRandomRange(Random, 6, 10, 100); bar3.Values.FillRandomRange(Random, 6, 10, 100); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // apply animation theme NAnimationTheme animationTheme = new NAnimationTheme(); animationTheme.AnimateSeriesSequentially = true; animationTheme.AnimateDataPointsSequentially = false; animationTheme.AnimateChartsSequentially = false; animationTheme.WallsAnimationDuration = 1; animationTheme.AxesAnimationDuration = 1; animationTheme.SeriesAnimationDuration = 1; animationTheme.AnimationThemeType = AnimationThemeType.ScaleAndFade; // animationTheme.Apply(nChartControl1.Document); NImageResponse swfResponse = new NImageResponse(); swfResponse.ImageFormat = new NSwfImageFormat(); nChartControl1.ImageAcquisitionMode = ClientSideImageAcquisitionMode.TempFile; nChartControl1.ServerSettings.BrowserResponseSettings.DefaultResponse = swfResponse; }
protected void Page_Load(object sender, System.EventArgs e) { // init form controls if (!IsPostBack) { AngleModeDropDownList.Items.Add("View"); AngleModeDropDownList.Items.Add("Scale"); AngleModeDropDownList.SelectedIndex = 1; AllowFlipCheckBox.Checked = false; FitAxisContentInBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Axis Labels Orientation"); nChartControl1.Panels.Add(header); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.Margins = new NMarginsL(10, 10, 10, 4); header.DockMode = PanelDockMode.Top; // setup the chart NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.Enable3D = true; chart.Fit3DAxisContent = FitAxisContentInBox.Checked; chart.DockMode = PanelDockMode.Fill; chart.BorderStyle = new NStrokeBorderStyle(BorderShape.RoundedRect); chart.BackgroundFillStyle = new NGradientFillStyle(Color.White, Color.LightGray); chart.Margins = new NMarginsL(10, 0, 10, 10); chart.Padding = new NMarginsL(2, 2, 2, 2); // set predefined projection and lighting chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); chart.Depth = 50; chart.Width = 50; chart.Height = 50; chart.BoundsMode = BoundsMode.Fit; chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); // add interlaced stripe NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(); stripStyle.FillStyle = new NColorFillStyle(Color.Beige); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); stripStyle.Interlaced = true; scaleConfiguratorY.StripStyles.Add(stripStyle); // add series Color[] seriesColors = new Color[] { Color.Crimson, Color.Orange, Color.OliveDrab }; int dataItemsCount = 6; for (int i = 0; i < seriesColors.Length; i++) { NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.BarShape = BarShape.SmoothEdgeBar; bar.FillStyle = new NColorFillStyle(seriesColors[i]); bar.Name = "Series " + i.ToString(); bar.Values.FillRandomRange(Random, dataItemsCount, 10, 30); bar.InflateMargins = true; bar.DataLabelStyle.Visible = false; } // configure the x axis labels (categories) NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Title.Text = "Categories Title"; ordinalScale.MajorTickMode = MajorTickMode.CustomStep; ordinalScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; for (int i = 0; i < dataItemsCount; i++) { ordinalScale.Labels.Add("S" + i.ToString()); } // configure the depth axis labels (series) ordinalScale = chart.Axis(StandardAxis.Depth).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Title.Text = "Series Title"; ordinalScale.MajorTickMode = MajorTickMode.CustomStep; ordinalScale.Labels.Add("S1"); ordinalScale.Labels.Add("S2"); ordinalScale.Labels.Add("S3"); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; // set title to Y axis NNumericScaleConfigurator numericScale = chart.Axis((int)StandardAxis.PrimaryY).ScaleConfigurator as NNumericScaleConfigurator; numericScale.Title.Text = "Values"; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // read the form control values float customAngle; if (!float.TryParse(CustomAngleTextBox.Text, out customAngle) || customAngle < 0 || customAngle > 360) { customAngle = 0f; CustomAngleTextBox.Text = customAngle.ToString(); } // update scale labels angle int count = chart.Axes.Count; NScaleLabelAngle angle = new NScaleLabelAngle((ScaleLabelAngleMode)Enum.Parse(typeof(ScaleLabelAngleMode), AngleModeDropDownList.SelectedItem.Value), customAngle, AllowFlipCheckBox.Checked); // update the x axis NAxis axis = (NAxis)chart.Axes[(int)StandardAxis.PrimaryX]; NStandardScaleConfigurator scale = axis.ScaleConfigurator as NStandardScaleConfigurator; scale.LabelStyle.Angle = angle; // update the depth axis axis = (NAxis)chart.Axes[(int)StandardAxis.Depth]; scale = axis.ScaleConfigurator as NStandardScaleConfigurator; scale.LabelStyle.Angle = angle; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader(this.Title); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.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(); // do not update automatic legends nChartControl1.ServiceManager.LegendUpdateService.UpdateAutoLegends(); nChartControl1.ServiceManager.LegendUpdateService.Stop(); // configure the chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.BoundsMode = BoundsMode.Fit; chart.Enable3D = true; chart.Fit3DAxisContent = false; // make the aspect 6:1:2 chart.Width = 60; chart.Height = 20; chart.Depth = 20; // configure the y axis NAxis yAxis = chart.Axis(StandardAxis.PrimaryY); yAxis.View = new NRangeAxisView(new NRange1DD(0, m_MaxValue)); NLinearScaleConfigurator linearScale = yAxis.ScaleConfigurator as NLinearScaleConfigurator; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); linearScale.MajorGridStyle.LineStyle.Color = Color.LightSteelBlue; linearScale.InnerMinorTickStyle.Visible = false; linearScale.InnerMajorTickStyle.Visible = false; linearScale.LabelFitModes = new LabelFitMode[0]; // configure the x axis NAxis xAxis = chart.Axis(StandardAxis.PrimaryX); linearScale = new NLinearScaleConfigurator(); linearScale.LabelFitModes = new LabelFitMode[0]; xAxis.ScaleConfigurator = linearScale; linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; linearScale.InnerMinorTickStyle.Visible = false; linearScale.InnerMajorTickStyle.Visible = false; chart.Axis(StandardAxis.Depth).Visible = false; // 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()); GridSizeXComboBox.Items.Add("10"); GridSizeXComboBox.Items.Add("50"); GridSizeXComboBox.Items.Add("100"); GridSizeYComboBox.Items.Add("10"); GridSizeYComboBox.Items.Add("50"); GridSizeYComboBox.Items.Add("100"); GridSizeXComboBox.SelectedIndex = 2; GridSizeYComboBox.SelectedIndex = 2; UseHardwareAccelerationCheckBox.IsChecked = true; nChartControl1.Settings.RenderSurface = RenderSurface.Window; StartTimer(); ConfigureStandardLayout(chart, title, null); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Multiple Axes Zooming and Scrolling"); 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)); // configure chart NCartesianChart chart = (NCartesianChart)(nChartControl1.Charts[0]); chart.RangeSelections.Add(new NRangeSelection()); // 2D line chart chart.BoundsMode = BoundsMode.Stretch; // configure axis paging and set a mimimum range length on the axisthis will prevent the user from zooming too much chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh); Color color1 = palette.SeriesColors[0]; Color color2 = palette.SeriesColors[3]; NAxis primaryY = chart.Axis(StandardAxis.PrimaryY); primaryY.ScaleConfigurator.Title.Text = "Primary Y Axis"; ApplyColorToAxis(primaryY, color1); primaryY.ScrollBar.Visible = true; primaryY.Scale.RulerRangeChanged += new EventHandler(Scale_RulerRangeChanged); NAxis secondaryY = chart.Axis(StandardAxis.SecondaryY); secondaryY.ScaleConfigurator.Title.Text = "Secondary Y Axis"; ApplyColorToAxis(secondaryY, color2); secondaryY.Visible = true; NLineSeries line1 = new NLineSeries(); line1.BorderStyle.Color = color1; line1.BorderStyle.Width = new NLength(2); chart.Series.Add(line1); line1.DataLabelStyle.Visible = false; NLineSeries line2 = new NLineSeries(); line2.BorderStyle.Color = color2; line2.BorderStyle.Width = new NLength(2); chart.Series.Add(line2); line2.DataLabelStyle.Visible = false; line2.DisplayOnAxis(StandardAxis.PrimaryY, false); line2.DisplayOnAxis(StandardAxis.SecondaryY, true); for (int i = 0; i < 720; i++) { double angle = i * NMath.Degree2Rad; double value1 = Math.Sin(angle); double value2 = Math.Sin(angle + 40) * 100; line1.Values.Add(value1); line2.Values.Add(value2); } nChartControl1.Controller.Tools.Add(new NSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); nChartControl1.Controller.Tools.Add(new NDataPanTool()); }
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(); } }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = new NLabel("Gantt Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // no legend nChartControl1.Legends.Clear(); // configure the chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); chart.Axis(StandardAxis.Depth).Visible = false; // setup the value axis NRangeTimelineScaleConfigurator dateTimeScale = new NRangeTimelineScaleConfigurator(); dateTimeScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; // add interlaced stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; stripStyle.Interlaced = true; dateTimeScale.StripStyles.Add(stripStyle); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = dateTimeScale; chart.Axis(StandardAxis.PrimaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, true, 0, 100); // fill data DateTime start = DateTime.Now; DateTime end = start + new TimeSpan(10, 0, 0, 0); TaskCollection tasks = new TaskCollection(); tasks.Add(new Task("Write Proposal", new DateTime(2001, 4, 1), new DateTime(2001, 4, 5), new uint[] { 1, 2 })); tasks.Add(new Task("Obtain Approval", new DateTime(2001, 4, 12), new DateTime(2001, 9, 4), new uint[] { 9 })); tasks.Add(new Task("Requirements Analysis", new DateTime(2001, 4, 9), new DateTime(2001, 5, 5), new uint[] { 3 })); tasks.Add(new Task("Design Phase", new DateTime(2001, 5, 6), new DateTime(2001, 5, 30), new uint[] { 4 })); tasks.Add(new Task("Design Signoff", new DateTime(2001, 6, 2), new DateTime(2001, 6, 2), new uint[] { 5 })); tasks.Add(new Task("Alpha Implementation", new DateTime(2001, 6, 3), new DateTime(2001, 7, 31), new uint[] { 6 })); tasks.Add(new Task("Design Review", new DateTime(2001, 8, 1), new DateTime(2001, 8, 8), new uint[] { 7 })); tasks.Add(new Task("Revised Design Signoff", new DateTime(2001, 8, 10), new DateTime(2001, 8, 10), new uint[] { 8 })); tasks.Add(new Task("Beta Implementation", new DateTime(2001, 8, 12), new DateTime(2001, 9, 12), new uint[] { 9 })); tasks.Add(new Task("Testing", new DateTime(2001, 9, 13), new DateTime(2001, 10, 31), new uint[] { 10 })); tasks.Add(new Task("Final Implementation", new DateTime(2001, 11, 1), new DateTime(2001, 11, 15), new uint[] { 11 })); tasks.Add(new Task("Signoff", new DateTime(2001, 11, 28), new DateTime(2001, 11, 30), new uint[] { 12 })); tasks.ConfigureChart(chart); // apply layout ConfigureStandardLayout(chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NFloatBarDragPointTool()); // init form controls ShowGanttConnectorLinesCheckBox.Checked = true; }
void CreatePreviewChart() { nChartControl1.HttpHandlerCallback = new PreviewHttpHandlerCallback(); if (nChartControl1.RequiresInitialization) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Legends.Clear(); // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Wave Preview"); 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(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage)); // setup a Smooth Line chart NCartesianChart chart = nChartControl1.Charts[0] as NCartesianChart; chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL( new NLength(4, NRelativeUnit.ParentPercentage), new NLength(25, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(88, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); // setup X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.InnerMajorTickStyle.Visible = false; // add interlace stripe to the Y axis NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(0xfe, 0xed, 0xe2)), 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 NSmoothLineSeries line = (NSmoothLineSeries)chart.Series.Add(SeriesType.SmoothLine); line.Name = "Wave"; line.Legend.Mode = SeriesLegendMode.None; line.UseXValues = false; line.UseZValues = false; line.InflateMargins = true; line.DataLabelStyle.Visible = false; line.MarkerStyle.Visible = false; line.BorderStyle.Width = new NLength(1, NGraphicsUnit.Pixel); // initialize data points for (int i = 0; i < waveDataLenth; i++) { line.Values.Add(waveData[i]); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // select a default window NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron); Color selectionBorderColor = palette.SeriesColors[2]; Color selectionFillColor = Color.FromArgb(64, palette.SeriesColors[1]); NRangeSelection selection = new NRangeSelection((int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY); selection.BorderStyle = new NStrokeStyle(1, selectionBorderColor); selection.FillStyle = new NColorFillStyle(selectionFillColor); selection.HorizontalAxisRange = new NRange1DD(0, defaultDataWindowWidth); selection.VerticalAxisRange = new NRange1DD(-waveDataWave1Factor, waveDataWave1Factor); selection.Visible = true; chart.RangeSelections.Add(selection); } }
void CreateZoomChart() { if (nChartControl2.RequiresInitialization) { // reset the data window width HttpContext.Current.Session["DataWindowWidth"] = defaultDataWindowWidth; // set up the chart control nChartControl2.BackgroundStyle.FrameStyle.Visible = false; nChartControl2.Legends.Clear(); // set a chart title NLabel header = nChartControl2.Labels.AddHeader("Wave Details"); 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(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage)); // setup a Smooth Line chart NCartesianChart chart = nChartControl2.Charts[0] as NCartesianChart; chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL( new NLength(4, NRelativeUnit.ParentPercentage), new NLength(25, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(88, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); // setup X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; scaleX.RoundToTickMin = false; scaleX.RoundToTickMax = false; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.InnerMajorTickStyle.Visible = false; // add interlace stripe to the Y axis NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(0xfe, 0xed, 0xe2)), 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 NSmoothLineSeries line = (NSmoothLineSeries)chart.Series.Add(SeriesType.SmoothLine); line.Name = "Wave"; line.Legend.Mode = SeriesLegendMode.None; line.UseXValues = true; line.InflateMargins = true; line.DataLabelStyle.Visible = false; line.MarkerStyle.Visible = false; line.BorderStyle.Width = new NLength(1, NGraphicsUnit.Pixel); // initialize data points for (int i = 0; i < defaultDataWindowWidth; i++) { line.XValues.Add(i); line.Values.Add(waveData[i]); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl2.Document); } }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Chart Aspect 2D"); 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); NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.DockMode = PanelDockMode.Fill; chart.Margins = new NMarginsL(new NLength(30)); chart.Padding = new NMarginsL(0); chart.BoundsMode = BoundsMode.Stretch; chart.UsePlotAspect = true; chart.Width = chart.Height = 50; // switch all axes to linear mode NLinearScaleConfigurator xScale = new NLinearScaleConfigurator(); xScale.Title.Text = "X Scale Title"; xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); xScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.View, 90, false); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScale; NLinearScaleConfigurator yScale = new NLinearScaleConfigurator(); yScale.Title.Text = "Y Scale Title"; yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = yScale; chart.Axis(StandardAxis.SecondaryX).ScaleConfigurator = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.SecondaryY).ScaleConfigurator = new NLinearScaleConfigurator(); // cross secondary X and Y axes chart.Axis(StandardAxis.SecondaryX).Anchor = new NCrossAxisAnchor(AxisOrientation.Horizontal, new NValueAxisCrossing(chart.Axis(StandardAxis.PrimaryY), 0)); chart.Axis(StandardAxis.SecondaryY).Anchor = new NCrossAxisAnchor(AxisOrientation.Vertical, new NValueAxisCrossing(chart.Axis(StandardAxis.PrimaryX), 0)); // show secondary axes chart.Axis(StandardAxis.SecondaryX).Visible = true; chart.Axis(StandardAxis.SecondaryY).Visible = true; // turn off labels for cross axes NLinearScaleConfigurator secondaryScaleX = chart.Axis(StandardAxis.SecondaryX).ScaleConfigurator as NLinearScaleConfigurator; secondaryScaleX.AutoLabels = false; NLinearScaleConfigurator secondaryScaleY = chart.Axis(StandardAxis.SecondaryY).ScaleConfigurator as NLinearScaleConfigurator; secondaryScaleY.AutoLabels = false; // add some dummy data NPointSeries point = new NPointSeries(); chart.Series.Add(point); point.DataLabelStyle.Visible = false; point.UseXValues = true; point.DisplayOnAxis((int)StandardAxis.SecondaryX, true); point.DisplayOnAxis((int)StandardAxis.SecondaryY, true); point.Size = new NLength(1); point.BorderStyle.Width = new NLength(0); point.ClusterMode = ClusterMode.Enabled; // add some random data in the range [-100, 100] Random rand = new Random(); for (int i = 0; i < 3000; i++) { point.Values.Add(rand.Next(200) - 100); point.XValues.Add(rand.Next(200) - 100); } // init form controls for (int i = 1; i <= 5; i++) { XProportionCombo.Items.Add(i.ToString()); YProportionCombo.Items.Add(i.ToString()); } FitAxisContentModeComboBox.FillFromEnum(typeof(Fit2DAxisContentMode)); FitAxisContentModeComboBox.SelectedIndex = (int)chart.Fit2DAxisContentMode; XProportionCombo.SelectedIndex = 0; YProportionCombo.SelectedIndex = 0; UsePlotAspectCheckBox.Checked = false; ShowContentAreaCheckBox.Checked = true; }
protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Interlaced Stripes"); 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 chart m_Chart = (NCartesianChart)nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL( new NLength(90, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.DisplayDataPointsBetweenTicks = false; NLineSeries line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); line.Name = "Line Series"; line.DataLabelStyle.Format = "<value>"; line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Sphere; line.MarkerStyle.FillStyle = new NColorFillStyle(Color.Red); line.LineSegmentShape = LineSegmentShape.Tape; line.BorderStyle.Width = new NLength(2, NGraphicsUnit.Point); line.BorderStyle.Color = Color.DarkSlateBlue; line.DataLabelStyle.Visible = false; line.Legend.Mode = SeriesLegendMode.None; line.Values.FillRandom(Random, 20); 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); m_YAxisInterlaceStyle = new NScaleStripStyle(); m_YAxisInterlaceStyle.SetShowAtWall(ChartWallType.Back, true); m_YAxisInterlaceStyle.SetShowAtWall(ChartWallType.Left, true); m_YAxisInterlaceStyle.Interlaced = true; m_YAxisInterlaceStyle.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, Color.FromArgb(125, Color.PaleTurquoise), Color.FromArgb(125, Color.MediumAquamarine)); m_YAxisInterlaceStyle.Begin = 0; m_YAxisInterlaceStyle.End = 10; m_YAxisInterlaceStyle.Infinite = true; m_YAxisInterlaceStyle.Interval = 1; m_YAxisInterlaceStyle.Length = 1; m_XAxisInterlaceStyle = new NScaleStripStyle(); m_XAxisInterlaceStyle.SetShowAtWall(ChartWallType.Back, true); m_XAxisInterlaceStyle.SetShowAtWall(ChartWallType.Floor, true); m_XAxisInterlaceStyle.Interlaced = true; m_XAxisInterlaceStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.SteelBlue), Color.FromArgb(125, Color.SlateGray)); m_XAxisInterlaceStyle.Begin = 0; m_XAxisInterlaceStyle.End = 10; m_XAxisInterlaceStyle.Infinite = true; m_XAxisInterlaceStyle.Interval = 1; m_XAxisInterlaceStyle.Length = 1; if (!Page.IsPostBack) { YAxisInterlacedStripesCheckBox.Checked = true; } UpdateInterlaceStirpes(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Date Time Scale"); title.TextStyle.TextFormat = TextFormat.XML; 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(); // setup chart m_Chart = (NCartesianChart)nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; // add a range selection, snapped to the vertical axis min/max values NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); m_Chart.RangeSelections.Add(rangeSelection); // add interlaced stripe to the Y axis NLinearScaleConfigurator linearScale = m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); // Add a line series NLineSeries line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); line.UseXValues = true; line.DataLabelStyle.Visible = false; line.InflateMargins = true; line.MarkerStyle.Visible = true; line.MarkerStyle.BorderStyle.Color = Color.DarkRed; line.MarkerStyle.PointShape = PointShape.Cylinder; line.MarkerStyle.Width = new NLength(2, NRelativeUnit.ParentPercentage); line.MarkerStyle.Height = new NLength(2, NRelativeUnit.ParentPercentage); // create a date time scale NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator(); m_DateTimeScale = dateTimeScale; m_DateTimeScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 90); m_DateTimeScale.LabelStyle.ContentAlignment = ContentAlignment.MiddleLeft; m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); NAxis xAxis = m_Chart.Axis(StandardAxis.PrimaryX); xAxis.ScrollBar.Visible = true; // configure interactivity nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); // init form controls EndDateTimePicker.Value = CultureInfo.CurrentCulture.Calendar.AddYears(StartDateTimePicker.Value, 2); EnableUnitSensitiveFormattingCheckBox.Checked = true; DayCheckBox.Checked = true; WeekCheckBox.Checked = true; MonthCheckBox.Checked = true; QuarterCheckBox.Checked = true; YearCheckBox.Checked = true; UpdateDateTimeScale(); GenerateDataButton_Click(null, null); nChartControl1.Refresh(); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Axis Ruler Caps<br/> <font size = '9pt'>Demonstrates how to change the caps of the axis ruler</font>"); header.DockMode = PanelDockMode.Top; header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.TextStyle.TextFormat = TextFormat.XML; header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left; header.FitAlignment = ContentAlignment.MiddleLeft; header.Margins = new NMarginsL(5, 0, 0, 5); nChartControl1.Panels.Add(header); NCartesianChart chart = new NCartesianChart(); chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; chart.Margins = new NMarginsL(5, 10, 10, 5); nChartControl1.Panels.Add(chart); Random random = new Random(); // feed some random data NPointSeries point = new NPointSeries(); point.DataLabelStyle.Visible = false; point.UseXValues = true; point.Size = new NLength(5); point.BorderStyle.Width = new NLength(0); // fill in some random data for (int j = 0; j < 30; j++) { point.Values.Add(5 + random.Next(90)); point.XValues.Add(5 + random.Next(90)); } chart.Series.Add(point); // configure scales NLinearScaleConfigurator xScale = new NLinearScaleConfigurator(); xScale.RoundToTickMax = true; xScale.RoundToTickMin = true; xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); xScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41))); // add an interlaced strip to the X axis NScaleStripStyle xInterlacedStrip = new NScaleStripStyle(); xInterlacedStrip.SetShowAtWall(ChartWallType.Back, true); xInterlacedStrip.Interlaced = true; xInterlacedStrip.FillStyle = new NColorFillStyle(Color.FromArgb(40, Color.LightGray)); xScale.StripStyles.Add(xInterlacedStrip); NCartesianAxis xAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryX); xAxis.ScaleConfigurator = xScale; xAxis.View = new NRangeAxisView(new NRange1DD(0, 100)); NDockAxisAnchor xAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontBottom); xAxisAnchor.BeforeSpace = new NLength(10); xAxis.Anchor = xAxisAnchor; NLinearScaleConfigurator yScale = new NLinearScaleConfigurator(); yScale.RoundToTickMax = true; yScale.RoundToTickMin = true; yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); yScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41))); // add an interlaced strip to the Y axis NScaleStripStyle yInterlacedStrip = new NScaleStripStyle(); yInterlacedStrip.SetShowAtWall(ChartWallType.Back, true); yInterlacedStrip.Interlaced = true; yInterlacedStrip.FillStyle = new NColorFillStyle(Color.FromArgb(40, Color.LightGray)); yScale.StripStyles.Add(yInterlacedStrip); NCartesianAxis yAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryY); yAxis.ScaleConfigurator = yScale; yAxis.View = new NRangeAxisView(new NRange1DD(0, 100)); NDockAxisAnchor yAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontLeft); yAxisAnchor.BeforeSpace = new NLength(10); yAxis.Anchor = yAxisAnchor; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // update form controls if (!IsPostBack) { PaintOnScaleBreaksCheckBox.Checked = false; WebExamplesUtilities.FillComboWithEnumValues(BeginCapStyleDropDownList, typeof(CapStyle)); BeginCapStyleDropDownList.SelectedIndex = (int)CapStyle.Ellipse; WebExamplesUtilities.FillComboWithEnumValues(ScaleBreakCapStyleDropDownList, typeof(CapStyle)); ScaleBreakCapStyleDropDownList.SelectedIndex = (int)CapStyle.LeftCrossLine; WebExamplesUtilities.FillComboWithEnumValues(EndCapStyleDropDownList, typeof(CapStyle)); EndCapStyleDropDownList.SelectedIndex = (int)CapStyle.Arrow; } UpdateRulerStyleForAxis(xAxis); UpdateRulerStyleForAxis(yAxis); }
public void InitNChart(ref NChartControl ncc, out NCartesianChart chart) { // 2D line chart ncc.Settings.RenderDevice = RenderDevice.GDI; // Add tools to chart controller ncc.Controller.Tools.Add(new NSelectorTool()); ncc.Controller.Tools.Add(new NDataZoomTool()); //ncc.Controller.Tools.Add(new NDataPanTool()); ncc.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(OnChartMouseDoubleClick); ncc.MouseMove += new System.Windows.Forms.MouseEventHandler(OnChartMouseMove); chart = (NCartesianChart)ncc.Charts[0]; // Set range selections property NRangeSelection rangeSelection = new NRangeSelection(); // Reset Axis when zoom out rangeSelection.ZoomOutResetsAxis = true; chart.RangeSelections.Add(rangeSelection); // Set chart axis property chart.Axis(StandardAxis.Depth).Visible = false; SetMapProperty(); }
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); }
public override void Initialize() { base.Initialize(); // configure the trackball NTrackballTool trackballTool = new NTrackballTool(); trackballTool.ProjectionChanged += new EventHandler(OnProjectionChanged); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(trackballTool); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Axis Labels Orientation"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.DockMode = PanelDockMode.Top; title.Margins = new NMarginsL(10, 10, 10, 10); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); title.SendToBack(); // no legend nChartControl1.Legends.Clear(); // setup the chart m_Chart = (NCartesianChart)nChartControl1.Charts[0]; m_Chart.Enable3D = true; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); m_Chart.Depth = 50; m_Chart.Width = 50; m_Chart.Height = 50; m_Chart.BorderStyle = new NStrokeBorderStyle(BorderShape.RoundedRect); m_Chart.BoundsMode = BoundsMode.Fit; m_Chart.DockMode = PanelDockMode.Fill; m_Chart.Margins = new NMarginsL(30, 0, 30, 30); m_Chart.Padding = new NMarginsL(5, 5, 5, 5); m_Chart.BackgroundFillStyle = new NGradientFillStyle(Color.White, Color.LightGray); // setup Y axis NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.Title.Text = "Values"; // add interlaced stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; stripStyle.Interlaced = true; scaleY.StripStyles.Add(stripStyle); m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // configure the x axis labels (categories) NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleX.AutoLabels = false; scaleX.Title.Text = "Categories Title"; scaleX.MajorTickMode = MajorTickMode.CustomStep; scaleX.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; for (int j = 0; j < categoriesCount; j++) { scaleX.Labels.Add("Category " + j.ToString()); } // configure the depth axis labels (series) NOrdinalScaleConfigurator scaleZ = m_Chart.Axis(StandardAxis.Depth).ScaleConfigurator as NOrdinalScaleConfigurator; scaleZ.AutoLabels = false; scaleZ.Title.Text = "Series Title"; scaleZ.MajorTickMode = MajorTickMode.CustomStep; scaleZ.Labels.Add("Series 1"); scaleZ.Labels.Add("Series 2"); scaleZ.Labels.Add("Series 3"); scaleZ.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); scaleZ.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; // add series for (int i = 0; i < 3; i++) { NBarSeries bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); bar.InflateMargins = true; bar.BarShape = BarShape.SmoothEdgeBar; bar.DataLabelStyle.Visible = false; bar.Name = "Series " + i.ToString(); bar.Values.FillRandomRange(Random, categoriesCount, 10, 30); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); // initialize controls on the form AngleModeComboBox.FillFromEnum(typeof(ScaleLabelAngleMode)); AngleModeComboBox.SelectedIndex = (int)ScaleLabelAngleMode.Scale; Use3DCheckBox.Checked = true; OnProjectionChanged(null, null); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Quarterly Company Sales<br/><font size = '9pt'>Demonstrates how to use hierarchical scale configurators as well as data zooming and scrolling</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); NLegend legend = new NLegend(); legend.Margins = new NMarginsL(10, 0, 10, 0); legend.DockMode = PanelDockMode.Right; legend.FitAlignment = ContentAlignment.TopCenter; nChartControl1.Panels.Add(legend); NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rangeSelection); chart.DisplayOnLegend = legend; chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; chart.Margins = new NMarginsL(10, 0, 0, 10); chart.Axis(StandardAxis.Depth).Visible = false; // add the first bar m_Bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); m_Bar1.Name = "Coca Cola"; m_Bar1.MultiBarMode = MultiBarMode.Series; m_Bar1.DataLabelStyle.Visible = false; // add the second bar m_Bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); m_Bar2.Name = "Pepsi"; m_Bar2.MultiBarMode = MultiBarMode.Clustered; m_Bar2.DataLabelStyle.Visible = false; NAxis xAxis = chart.Axis(StandardAxis.PrimaryX); xAxis.ScrollBar.Visible = true; // add custom labels to the Y axis NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // configure interactivity nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); // first row combo boxes FirstRowIndividualModeComboBox.FillFromEnum(typeof(RangeLabelTickMode)); FirstRowIndividualModeComboBox.SelectedIndex = (int)RangeLabelTickMode.Separators; FirstRowSeparatorModeComboBox.FillFromEnum(typeof(FirstRowGridStyle)); FirstRowSeparatorModeComboBox.SelectedIndex = (int)FirstRowGridStyle.Individual; GroupRowIndividualModeComboBox.FillFromEnum(typeof(RangeLabelTickMode)); GroupRowIndividualModeComboBox.SelectedIndex = (int)RangeLabelTickMode.Separators; GroupRowSeparatorModeComboBox.FillFromEnum(typeof(GroupRowGridStyle)); GroupRowSeparatorModeComboBox.SelectedIndex = (int)GroupRowGridStyle.Individual; CreateSeparatorForEachLevelCheckBox.Checked = true; ChangeDataButton_Click(null, null); UpdateScale(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("2D Sampled Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // no legend nChartControl1.Legends.Clear(); // configure the chart m_Chart = nChartControl1.Charts[0]; // add interlaced stripe to the Y axis NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; ((NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle); // add a line series m_Line = (NLineSeries)m_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.SamplingMode = SeriesSamplingMode.Enabled; m_Line.MarkerStyle.PointShape = PointShape.Cylinder; m_Line.MarkerStyle.Width = new NLength(1.5f, NRelativeUnit.ParentPercentage); m_Line.MarkerStyle.Height = new NLength(1.5f, NRelativeUnit.ParentPercentage); m_Line.UseXValues = true; SampleDistanceScroll.Value = (int)m_Line.SampleDistance.Value; // apply layout ConfigureStandardLayout(m_Chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); GeneratorModeCombo.Items.Add("Generator 1 (Continous Y)"); GeneratorModeCombo.Items.Add("Generator 2 (Random Y)"); GeneratorModeCombo.SelectedIndex = 0; UseXValuesCheckBox.Checked = true; NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.RangeSelections.Add(new NRangeSelection()); chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; chart.Axis(StandardAxis.PrimaryY).ScrollBar.Visible = true; nChartControl1.Controller.Selection.Add(chart); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); Add40KDataButton_Click(null, null); }