public MyCustomBezierSeries(NChart chart, NCustomSeries series) { m_Chart = chart; m_Series = series; PointFill = new NColorFillStyle(Color.Red); ControlPointFill = new NColorFillStyle(Color.DarkOliveGreen); BezierStroke = new NStrokeStyle(1, Color.Indigo); TangentStroke = new NStrokeStyle(1, Color.OliveDrab); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Custom Series"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // obtain a reference to the default chart NChart chart = nChartControl1.Charts[0]; // configure X axis NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; // add a custom series and set its callback object NCustomSeries customSeries = new NCustomSeries(); chart.Series.Add(customSeries); // create a paint callback object for the custom series MyCustomBezierSeries callback = new MyCustomBezierSeries(chart, customSeries); customSeries.Callback = callback; callback.Points = new NPointF[] { new NPointF(10, 20), new NPointF(55, 60), new NPointF(65, 180), new NPointF(110, 102), new NPointF(150, 99), new NPointF(225, 180), new NPointF(190, 202), new NPointF(160, 221), new NPointF(230, 45), new NPointF(200, 21), }; // apply layout ConfigureStandardLayout(chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); }
protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Custom Series"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend nChartControl1.Legends.Clear(); // setup chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // setup Y axis NAxis axisY = chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator linearScaleConfigurator = (NLinearScaleConfigurator)axisY.ScaleConfigurator; linearScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // add interlaced 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); linearScaleConfigurator.StripStyles.Add(stripStyle); // configure X axis NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; // add a custom series and set its callback object NCustomSeries customSeries = new NCustomSeries(); chart.Series.Add(customSeries); // create a paint callback object for the custom series MyCustomBezierSeries callback = new MyCustomBezierSeries(chart, customSeries); customSeries.Callback = callback; callback.Points = new NPointF[] { new NPointF(10, 20), new NPointF(55, 60), new NPointF(65, 180), new NPointF(110, 102), new NPointF(150, 99), new NPointF(225, 180), new NPointF(190, 202), new NPointF(160, 221), new NPointF(230, 45), new NPointF(200, 21), }; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); }