public override void Initialize() { base.Initialize(); // create a title NLabel title = new NLabel("Hit Testing Scale Elements"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // hide the legend nChartControl1.Legends[0].Visible = false; // configure chart NChart chart = nChartControl1.Charts[0]; chart.Axis(StandardAxis.Depth).Visible = false; // add interlace stripe NLinearScaleConfigurator scaleY = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; scaleY.Title.Text = "Y Axis Title"; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); scaleY.StripStyles.Add(stripStyle); // add the line NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.LineSegmentShape = LineSegmentShape.Line; line.DataLabelStyle.Visible = false; line.Legend.Mode = SeriesLegendMode.DataPoints; line.InflateMargins = true; line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Cylinder; line.MarkerStyle.Width = new NLength(1.5f, NRelativeUnit.ParentPercentage); line.MarkerStyle.Height = new NLength(1.5f, NRelativeUnit.ParentPercentage); line.Name = "Line Series"; line.UseXValues = true; // add xy values line.AddDataPoint(new NDataPoint(15, 10)); line.AddDataPoint(new NDataPoint(25, 23)); line.AddDataPoint(new NDataPoint(45, 12)); ConfigureAxis(chart.Axis(StandardAxis.PrimaryX)); ConfigureAxis(chart.Axis(StandardAxis.PrimaryY)); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); nChartControl1.MouseMove += new MouseEventHandler(nChartControl1_MouseMove); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("XY Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; // add interlaced stripe to the Y axis NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); stripStyle.Interlaced = true; linearScale.StripStyles.Add(stripStyle); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); // add the line m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line.LineSegmentShape = LineSegmentShape.Line; m_Line.DataLabelStyle.Visible = false; m_Line.Legend.Mode = SeriesLegendMode.DataPoints; m_Line.InflateMargins = true; m_Line.MarkerStyle.Visible = true; 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.Name = "Line Series"; m_Line.UseXValues = true; // add xy values m_Line.AddDataPoint(new NDataPoint(15, 10)); m_Line.AddDataPoint(new NDataPoint(25, 23)); m_Line.AddDataPoint(new NDataPoint(45, 12)); m_Line.AddDataPoint(new NDataPoint(55, 21)); m_Line.AddDataPoint(new NDataPoint(61, 16)); m_Line.AddDataPoint(new NDataPoint(67, 19)); m_Line.AddDataPoint(new NDataPoint(72, 11)); // apply layout ConfigureStandardLayout(m_Chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); }
private void GenerateDateTimeData(NLineSeries s, int nCount) { s.ClearDataPoints(); DateTime dateTime = DateTime.Now.AddMilliseconds(-nCount * nChartControl1.AsyncRefreshInterval); double dPrev = 100; double value; NDataPoint dataPoint; for (int i = 0; i < nCount; i++) { GenerateDataPoint(dPrev, new NRange1DD(50, 350), out value); dataPoint = new NDataPoint(value); s.AddDataPoint(dataPoint); dPrev = (double)s.Values[s.Values.Count - 1]; dateTime = dateTime.AddMilliseconds(nChartControl1.AsyncRefreshInterval); s.XValues.Add(dateTime); } }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("XY Scatter Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // setup chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // setup X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Floor }; scaleX.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); scaleX.StripStyles.Add(stripStyle); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // add the line NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.Name = "Line Series"; line.LineSegmentShape = LineSegmentShape.Line; line.InflateMargins = true; line.DataLabelStyle.Visible = false; line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Cylinder; line.Legend.Mode = SeriesLegendMode.None; // instruct the series to use X values line.UseXValues = true; // add XY data points Random random = new Random(); line.AddDataPoint(new NDataPoint(15 + random.Next(10), 10)); line.AddDataPoint(new NDataPoint(25 + random.Next(10), 23)); line.AddDataPoint(new NDataPoint(45 + random.Next(10), 12)); line.AddDataPoint(new NDataPoint(55 + random.Next(10), 21)); line.AddDataPoint(new NDataPoint(61 + random.Next(10), 16)); line.AddDataPoint(new NDataPoint(67 + random.Next(10), 19)); line.AddDataPoint(new NDataPoint(72 + random.Next(10), 11)); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }