private NCustomScaleBreak CreateCustomScaleBreak(NColor color, NRange range) { NCustomScaleBreak scaleBreak = new NCustomScaleBreak(); scaleBreak.Fill = new NColorFill(new NColor(color, 124)); scaleBreak.Length = 10; scaleBreak.Range = range; return(scaleBreak); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Custom Scale Breaks<br/> <font size = '9pt'>Demonstrates how to apply custom scale breaks to the chart axes</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)); // turn off the legend NLegend legend = nChartControl1.Legends[0]; legend.Mode = LegendMode.Disabled; NChart chart = nChartControl1.Charts[0]; Random random = new Random(); // create three random point series for (int i = 0; i < 3; i++) { NPointSeries point = new NPointSeries(); point.UseXValues = true; point.UseZValues = true; point.DataLabelStyle.Visible = false; 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)); point.ZValues.Add(5 + random.Next(90)); } chart.Series.Add(point); } // create scale breaks m_FirstHorzScaleBreak = new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(10, 20)); m_SecondHorzScaleBreak = new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Green)), null, new NLength(10)), new NRange1DD(80, 90)); m_FirstVertScaleBreak = new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Red)), null, new NLength(10)), new NRange1DD(10, 20)); m_SecondVertScaleBreak = new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Blue)), null, new NLength(10)), new NRange1DD(80, 90)); // initalize form controls FirstHorzBreakBeginUpDown.Value = (decimal)10; FirstHorzBreakEndUpDown.Value = (decimal)20; SecondHorzBreakBeginUpDown.Value = (decimal)80; SecondHorzBreakEndUpDown.Value = (decimal)90; FirstVertBreakBeginUpDown.Value = (decimal)10; FirstVertBreakEndUpDown.Value = (decimal)20; SecondVertBreakBeginUpDown.Value = (decimal)80; SecondVertBreakEndUpDown.Value = (decimal)90; // configure scales NLinearScaleConfigurator xScale = new NLinearScaleConfigurator(); xScale.RoundToTickMax = true; xScale.RoundToTickMin = true; xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); xScale.ScaleBreaks.Add(m_FirstHorzScaleBreak); xScale.ScaleBreaks.Add(m_SecondHorzScaleBreak); // 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); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScale; chart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new NRange1DD(0, 100)); NLinearScaleConfigurator yScale = new NLinearScaleConfigurator(); yScale.RoundToTickMax = true; yScale.RoundToTickMin = true; yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); yScale.ScaleBreaks.Add(m_FirstVertScaleBreak); yScale.ScaleBreaks.Add(m_SecondVertScaleBreak); // 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); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = yScale; chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 100)); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); }
/// <summary> /// /// </summary> /// <returns></returns> protected override NWidget CreateExampleContent() { NChartView chartView = CreateCartesianChartView(); // configure title chartView.Surface.Titles[0].Text = "Axis Ruler Caps"; // configure chart m_Chart = (NCartesianChart)chartView.Surface.Charts[0]; m_Chart.Padding = new NMargins(20); // configure axes m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear); // feed some random data NPointSeries point = new NPointSeries(); point.UseXValues = true; point.DataLabelStyle = new NDataLabelStyle(false); // fill in some random data Random random = new Random(); for (int j = 0; j < 30; j++) { point.DataPoints.Add(new NPointDataPoint(5 + random.Next(90), 5 + random.Next(90))); } m_Chart.Series.Add(point); // X Axis NLinearScale xScale = new NLinearScale(); xScale.MajorGridLines = CreateScaleGrid(); NCustomScaleBreak xScaleBreak = new NCustomScaleBreak(); xScaleBreak.Style = ENScaleBreakStyle.Line; xScaleBreak.Fill = new NColorFill(new NColor(NColor.Orange, 124)); xScaleBreak.Length = 20; xScaleBreak.Range = new NRange(29, 41); xScale.ScaleBreaks.Add(xScaleBreak); // add an interlaced strip to the X axis NScaleStrip xInterlacedStrip = new NScaleStrip(); xInterlacedStrip.Interlaced = true; xInterlacedStrip.Fill = new NColorFill(new NColor(NColor.LightGray, 125)); xScale.Strips.Add(xInterlacedStrip); NCartesianAxis xAxis = m_Chart.Axes[ENCartesianAxis.PrimaryX]; xAxis.Scale = xScale; // xAxis.ViewRangeMode = ENAxisViewRangeMode.FixedRange; // xAxis.MinViewRangeValue = 0; // xAxis.MaxViewRangeValue = 100; NDockCartesianAxisAnchor xAxisAnchor = new NDockCartesianAxisAnchor(ENCartesianAxisDockZone.Bottom); xAxisAnchor.BeforeSpace = 10; xAxis.Anchor = xAxisAnchor; // Y Axis NLinearScale yScale = new NLinearScale(); yScale.MajorGridLines = CreateScaleGrid(); NCustomScaleBreak yScaleBreak = new NCustomScaleBreak(); yScaleBreak.Style = ENScaleBreakStyle.Line; yScaleBreak.Fill = new NColorFill(new NColor(NColor.Orange, 124)); yScaleBreak.Length = 20; yScaleBreak.Range = new NRange(29, 41); yScale.ScaleBreaks.Add(yScaleBreak); // add an interlaced strip to the Y axis NScaleStrip yInterlacedStrip = new NScaleStrip(); yInterlacedStrip.Interlaced = true; yInterlacedStrip.Fill = new NColorFill(new NColor(NColor.LightGray, 125)); yInterlacedStrip.Interval = 1; yInterlacedStrip.Length = 1; yScale.Strips.Add(yInterlacedStrip); NCartesianAxis yAxis = m_Chart.Axes[ENCartesianAxis.PrimaryY]; yAxis.Scale = yScale; // yAxis.ViewRangeMode = ENAxisViewRangeMode.FixedRange; // yAxis.MinViewRangeValue = 0; // yAxis.MaxViewRangeValue = 100; NDockCartesianAxisAnchor yAxisAnchor = new NDockCartesianAxisAnchor(ENCartesianAxisDockZone.Left); yAxisAnchor.BeforeSpace = 10; yAxis.Anchor = yAxisAnchor; chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false)); return(chartView); }
protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Custom Scale Breaks<br/> <font size = '9pt'>Demonstrates how to apply custom scale breaks to the chart axes</font>"); header.TextStyle.TextFormat = TextFormat.XML; header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left; header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // turn off the legend NLegend legend = nChartControl1.Legends[0]; legend.Mode = LegendMode.Disabled; NChart chart = nChartControl1.Charts[0]; chart.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(19, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(92, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); chart.BoundsMode = BoundsMode.Stretch; Random random = new Random(); // create three random point series for (int i = 0; i < 3; i++) { NPointSeries point = new NPointSeries(); point.UseXValues = true; point.DataLabelStyle.Visible = false; 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); } // create scale breaks m_FirstHorzScaleBreak = new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(10, 20)); m_SecondHorzScaleBreak = new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Green)), null, new NLength(10)), new NRange1DD(80, 90)); m_FirstVertScaleBreak = new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Red)), null, new NLength(10)), new NRange1DD(10, 20)); m_SecondVertScaleBreak = new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Blue)), null, new NLength(10)), new NRange1DD(80, 90)); // configure scales NLinearScaleConfigurator xScale = new NLinearScaleConfigurator(); xScale.RoundToTickMax = true; xScale.RoundToTickMin = true; xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); xScale.ScaleBreaks.Add(m_FirstHorzScaleBreak); xScale.ScaleBreaks.Add(m_SecondHorzScaleBreak); // 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); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScale; chart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new NRange1DD(0, 100)); NLinearScaleConfigurator yScale = new NLinearScaleConfigurator(); yScale.RoundToTickMax = true; yScale.RoundToTickMin = true; yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); yScale.ScaleBreaks.Add(m_FirstVertScaleBreak); yScale.ScaleBreaks.Add(m_SecondVertScaleBreak); // 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); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = yScale; chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 100)); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // feed some random data UpdateScaleBreaks(); }