private NLineSeries SetupIndicatorChart(NCartesianChart chart) { NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY.InnerMajorTickStyle.Length = new NLength(0); NCartesianAxisCollection axes = (NCartesianAxisCollection)chart.Axes; NAxis axisY = axes.AddCustomAxis(AxisOrientation.Vertical, AxisDockZone.FrontLeft); axisY.Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 0, 20); axisY.ScaleConfigurator = scaleY; axisY.Visible = true; // Add line series for function NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.DataLabelStyle.Visible = false; line.BorderStyle.Color = Color.Blue; line.DisplayOnAxis(StandardAxis.PrimaryY, false); line.DisplayOnAxis(axisY.AxisId, true); line.UseXValues = true; return(line); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Average, Median, Min, Max"); 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)); // setup chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; 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)); // add a line series for the function m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line.MarkerStyle.Visible = true; m_Line.MarkerStyle.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); m_Line.MarkerStyle.FillStyle = new NColorFillStyle(Color.Crimson); m_Line.BorderStyle.Color = Color.Red; m_Line.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel); m_Line.Legend.Mode = SeriesLegendMode.None; m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.00"); m_Line.DisplayOnAxis(StandardAxis.PrimaryX, false); m_Line.DisplayOnAxis(StandardAxis.SecondaryX, true); // add the bar series m_Bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); m_Bar.Name = "Bar1"; m_Bar.Values.Name = "values"; m_Bar.Values.ValueFormatter = new NNumericValueFormatter("0.00"); m_Bar.MultiBarMode = MultiBarMode.Series; m_Bar.DataLabelStyle.Visible = false; m_Bar.Legend.Mode = SeriesLegendMode.DataPoints; m_Bar.BarShape = BarShape.Cylinder; m_Bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); m_Bar.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, Color.LightSteelBlue, Color.MidnightBlue); m_Bar.Values.FillRandomRange(Random, 12, 0, 50); // form controls m_bSkipUpdate = true; m_FunctionCombo.Items.Add("Average"); m_FunctionCombo.Items.Add("Median"); m_FunctionCombo.Items.Add("Min"); m_FunctionCombo.Items.Add("Max"); m_FunctionCombo.SelectedIndex = 0; m_GroupingCombo.Items.Add("Do not group"); m_GroupingCombo.Items.Add("Group by every 2 values"); m_GroupingCombo.Items.Add("Group by every 3 values"); m_GroupingCombo.Items.Add("Group by every 4 values"); m_GroupingCombo.SelectedIndex = 0; m_bSkipUpdate = false; m_FunctionCombo_SelectedIndexChanged(null, null); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Real Time Line"); 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)); // setup chart NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.BoundsMode = BoundsMode.Stretch; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Black); // styleSheet.Apply(nChartControl1.Document); NAxis axis1 = chart.Axis(StandardAxis.PrimaryY); ConfigureAxis(axis1, 0, 30, "Signal 1"); NAxis axis2 = chart.Axis(StandardAxis.SecondaryY); ConfigureAxis(axis2, 35, 65, "Signal 2"); NAxis axis3 = ((NCartesianAxisCollection)chart.Axes).AddCustomAxis(AxisOrientation.Vertical, AxisDockZone.FrontRight); ConfigureAxis(axis3, 70, 100, "Signal 3"); m_Line1 = CreateLineSeries(); chart.Series.Add(m_Line1); m_Line2 = CreateLineSeries(); chart.Series.Add(m_Line2); m_Line2.DisplayOnAxis(StandardAxis.PrimaryY, false); m_Line2.DisplayOnAxis(StandardAxis.SecondaryY, true); m_Line3 = CreateLineSeries(); chart.Series.Add(m_Line3); m_Line3.DisplayOnAxis(StandardAxis.PrimaryY, false); m_Line3.DisplayOnAxis(axis3.AxisId, true); m_ValueArray1 = new double[m_NewDataPointsPerTick]; m_ValueArray2 = new double[m_NewDataPointsPerTick]; m_ValueArray3 = new double[m_NewDataPointsPerTick]; ConfigureStandardLayout(chart, title, null); UseHardwareAccelerationCheckBox.Checked = true; StartTimer(); }
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("Axis Docking and Anchor Percentages<br/> <font size = '9pt'>Demonstrates how to dock axes without creating a new zone level</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 nChartControl1.Legends[0].Mode = LegendMode.Disabled; // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Enable3D = true; m_Chart.BoundsMode = BoundsMode.Fit; // apply predefined lighting and projection m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); // configure primary Y NAxis primaryY = m_Chart.Axis(StandardAxis.PrimaryY); primaryY.Anchor.BeginPercent = 0; primaryY.Anchor.EndPercent = 30; // configure secondary Y NAxis secondaryY = m_Chart.Axis(StandardAxis.SecondaryY); secondaryY.Visible = true; secondaryY.Anchor.BeginPercent = 30; secondaryY.Anchor.EndPercent = 70; // configure a custom axis docked to the front left left chart zone NAxis customY = ((NCartesianAxisCollection)m_Chart.Axes).AddCustomAxis(AxisOrientation.Vertical, AxisDockZone.FrontLeft); customY.Visible = true; customY.Anchor.BeginPercent = 70; customY.Anchor.EndPercent = 100; m_CustomAxisId = customY.AxisId; // Setup the line series NLineSeries l1 = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); l1.Values.FillRandom(Random, 5); l1.LineSegmentShape = LineSegmentShape.Tape; l1.DataLabelStyle.Format = "<value>"; NLineSeries l2 = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); l2.Values.FillRandom(Random, 5); l2.LineSegmentShape = LineSegmentShape.Tape; l2.DataLabelStyle.Format = "<value>"; l2.DisplayOnAxis(StandardAxis.SecondaryY, true); l2.DisplayOnAxis(StandardAxis.PrimaryY, false); NLineSeries l3 = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); l3.Values.FillRandom(Random, 5); l3.LineSegmentShape = LineSegmentShape.Tape; l3.DataLabelStyle.Format = "<value>"; l3.DisplayOnAxis(m_CustomAxisId, true); l3.DisplayOnAxis(StandardAxis.PrimaryY, false); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // set up the appearance of the axes according to the filling/stroke // applied to the line series from the style sheet primaryY.ScaleConfigurator = ConfigureScale(l1.FillStyle, l1.BorderStyle.Color); secondaryY.ScaleConfigurator = ConfigureScale(l2.FillStyle, l2.BorderStyle.Color); customY.ScaleConfigurator = ConfigureScale(l3.FillStyle, l3.BorderStyle.Color); // init form controls hScrollBar1.Value = 30; hScrollBar2.Value = 70; hScrollBar2.Minimum = hScrollBar1.Value + 10; hScrollBar1.Maximum = hScrollBar2.Value - 10; Scroll2BeginLabel.Text = hScrollBar2.Minimum.ToString(); Scroll1EndLabel.Text = hScrollBar1.Maximum.ToString(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Axis Docking<br/> <font size = '9pt'>Demonstrates how to use of the dock axis anchor and how to add custom axes</font>"); title.TextStyle.TextFormat = TextFormat.XML; title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center; 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 = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); m_RedAxis = m_Chart.Axis(StandardAxis.PrimaryY); m_GreenAxis = m_Chart.Axis(StandardAxis.SecondaryY); m_GreenAxis.Visible = true; // Add a custom vertical axis m_BlueAxis = ((NCartesianAxisCollection)m_Chart.Axes).AddCustomAxis(AxisOrientation.Vertical, AxisDockZone.FrontLeft); // create three line series and dispay them on three vertical axes (red, green and blue axis) NLineSeries line1 = CreateLineSeries(Color.Red, Color.DarkRed, 10, 20); NLineSeries line2 = CreateLineSeries(Color.Green, Color.DarkGreen, 50, 100); NLineSeries line3 = CreateLineSeries(Color.Blue, Color.DarkBlue, 100, 200); line1.DisplayOnAxis(StandardAxis.PrimaryY, true); line2.DisplayOnAxis(StandardAxis.PrimaryY, false); line2.DisplayOnAxis(StandardAxis.SecondaryY, true); line3.DisplayOnAxis(StandardAxis.PrimaryY, false); line3.DisplayOnAxis(m_BlueAxis.AxisId, true); // now configure the axis appearance NLinearScaleConfigurator linearScale; // setup the red axis linearScale = new NLinearScaleConfigurator(); m_RedAxis.ScaleConfigurator = linearScale; linearScale.RulerStyle.FillStyle = new NColorFillStyle(Color.DarkRed); linearScale.RulerStyle.BorderStyle.Color = Color.Red; linearScale.InnerMajorTickStyle.LineStyle.Color = Color.Red; linearScale.OuterMajorTickStyle.LineStyle.Color = Color.Red; linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; linearScale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.DarkRed); // setup the green axis linearScale = new NLinearScaleConfigurator(); m_GreenAxis.ScaleConfigurator = linearScale; linearScale.RulerStyle.FillStyle = new NColorFillStyle(Color.DarkGreen); linearScale.RulerStyle.BorderStyle.Color = Color.Green; linearScale.InnerMajorTickStyle.LineStyle.Color = Color.Green; linearScale.OuterMajorTickStyle.LineStyle.Color = Color.Green; linearScale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.DarkGreen); linearScale.RulerStyle.FillStyle = new NColorFillStyle(Color.DarkBlue); linearScale.RulerStyle.BorderStyle.Color = Color.Blue; linearScale.InnerMajorTickStyle.LineStyle.Color = Color.Blue; linearScale.OuterMajorTickStyle.LineStyle.Color = Color.Blue; linearScale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.DarkBlue); RedAxisZoneCombo.SelectedIndex = 0; GreenAxisZoneCombo.SelectedIndex = 0; BlueAxisZoneCombo.SelectedIndex = 0; UpdateAxisAnchors(); }
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) { if (!IsPostBack) { FunctionDropDownList.Items.Add("Average"); FunctionDropDownList.Items.Add("Min"); FunctionDropDownList.Items.Add("Max"); FunctionDropDownList.SelectedIndex = 0; GroupingDropDownList.Items.Add("Do not group"); GroupingDropDownList.Items.Add("Group by every 2 values"); GroupingDropDownList.Items.Add("Group by every 3 values"); GroupingDropDownList.Items.Add("Group by every 4 values"); GroupingDropDownList.SelectedIndex = 0; DataDropDownList.Items.Add("Positive"); DataDropDownList.Items.Add("Positive and Negative"); DataDropDownList.SelectedIndex = 0; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // add header NLabel header = nChartControl1.Labels.AddHeader("Average, Min, Max"); 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)); nFuncCalculator = new NFunctionCalculator(); // setup legend NLegend legend = nChartControl1.Legends[0]; legend.Location = new NPointL(legend.Location.X, new NLength(15, NRelativeUnit.ParentPercentage)); legend.Data.MarkSize = new NSizeL(5, 5); // setup chart nChart = nChartControl1.Charts[0]; nChart.Enable3D = true; nChart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); nChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); nChart.BoundsMode = BoundsMode.Stretch; nChart.Location = new NPointL( new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); nChart.Size = new NSizeL( new NLength(70, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); nChart.Axis(StandardAxis.Depth).Visible = false; nChart.Wall(ChartWallType.Left).Visible = false; nChart.Wall(ChartWallType.Floor).Visible = false; // setup X axis NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)nChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.DisplayDataPointsBetweenTicks = false; // add a line series for the function nLine = (NLineSeries)nChart.Series.Add(SeriesType.Line); nLine.MarkerStyle.Visible = true; nLine.MarkerStyle.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); nLine.MarkerStyle.FillStyle = new NColorFillStyle(Color.Crimson); nLine.BorderStyle.Color = Color.Red; nLine.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel); nLine.Legend.Mode = SeriesLegendMode.None; nLine.Values.ValueFormatter = new NNumericValueFormatter("0.00"); nLine.DisplayOnAxis(StandardAxis.PrimaryX, false); nLine.DisplayOnAxis(StandardAxis.SecondaryX, true); nLine.Legend.TextStyle = new NTextStyle(new NFontStyle("Arial", 7)); // add the bar series nBar = (NBarSeries)nChart.Series.Add(SeriesType.Bar); nBar.Name = "Bar1"; nBar.Values.Name = "values"; nBar.Values.ValueFormatter = new NNumericValueFormatter("0.00"); nBar.MultiBarMode = MultiBarMode.Series; nBar.DataLabelStyle.Visible = false; nBar.Legend.Mode = SeriesLegendMode.DataPoints; nBar.BarShape = BarShape.Cylinder; nBar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); nBar.FillStyle = new NColorFillStyle(Color.DarkSalmon); nBar.Values.FillRandomRange(Random, 12, 0, 50); nBar.Legend.TextStyle = new NTextStyle(new NFontStyle("Arial", 7)); if (DataDropDownList.SelectedIndex == 0) { nBar.Values.FillRandomRange(Random, 12, 0, 50); } else { nBar.Values.FillRandomRange(Random, 12, -25, 25); } BuildExpression(); CalcFunction(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithPercents(RedAxisEndPercentDropDownList, 1); WebExamplesUtilities.FillComboWithPercents(BlueAxisEndPercentDropDownList, 1); RedAxisEndPercentDropDownList.SelectedIndex = 40; BlueAxisEndPercentDropDownList.SelectedIndex = 60; } nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Axis Docking and Anchor Percentages<br/> <font size = '9pt'>Demonstrates how to dock axes without creating a new zone level</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 nChartControl1.Legends[0].Mode = LegendMode.Disabled; nChart = nChartControl1.Charts[0]; nChart.Enable3D = true; nChart.BoundsMode = BoundsMode.Fit; nChart.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); nChart.Size = new NSizeL(new NLength(96, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); // apply predefined lighting and projection nChart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); nChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); // configure primary Y NAxis primaryY = nChart.Axis(StandardAxis.PrimaryY); primaryY.Anchor.BeginPercent = 0; primaryY.Anchor.EndPercent = 30; // configure secondary Y NAxis secondaryY = nChart.Axis(StandardAxis.SecondaryY); secondaryY.Visible = true; secondaryY.Anchor.BeginPercent = 30; secondaryY.Anchor.EndPercent = 70; // configure a custom axis docked to the front left left chart zone NAxis customY = ((NCartesianAxisCollection)nChart.Axes).AddCustomAxis(AxisOrientation.Vertical, AxisDockZone.FrontLeft); customY.Visible = true; customY.Anchor.BeginPercent = 70; customY.Anchor.EndPercent = 100; nCustomAxisId = customY.AxisId; // Setup the line series NLineSeries l1 = (NLineSeries)nChart.Series.Add(SeriesType.Line); l1.Values.FillRandom(Random, 5); l1.LineSegmentShape = LineSegmentShape.Tape; l1.DataLabelStyle.Format = "<value>"; NLineSeries l2 = (NLineSeries)nChart.Series.Add(SeriesType.Line); l2.Values.FillRandom(Random, 5); l2.LineSegmentShape = LineSegmentShape.Tape; l2.DataLabelStyle.Format = "<value>"; l2.DisplayOnAxis(StandardAxis.SecondaryY, true); l2.DisplayOnAxis(StandardAxis.PrimaryY, false); NLineSeries l3 = (NLineSeries)nChart.Series.Add(SeriesType.Line); l3.Values.FillRandom(Random, 5); l3.LineSegmentShape = LineSegmentShape.Tape; l3.DataLabelStyle.Format = "<value>"; l3.DisplayOnAxis(nCustomAxisId, true); l3.DisplayOnAxis(StandardAxis.PrimaryY, false); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // set up the appearance of the axes according to the filling/stroke // applied to the line series from the style sheet primaryY.ScaleConfigurator = ConfigureScale(l1.FillStyle, l1.BorderStyle.Color); secondaryY.ScaleConfigurator = ConfigureScale(l2.FillStyle, l2.BorderStyle.Color); customY.ScaleConfigurator = ConfigureScale(l3.FillStyle, l3.BorderStyle.Color); RecalcAxes(); }
protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { RedAxisZoneDropDownList.Items.Add("Front Left"); RedAxisZoneDropDownList.Items.Add("Front Right"); GreenAxisZoneDropDownList.Items.Add("Front Left"); GreenAxisZoneDropDownList.Items.Add("Front Right"); BlueAxisZoneDropDownList.Items.Add("Front Left"); BlueAxisZoneDropDownList.Items.Add("Front Right"); } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Axis Docking<br/> <font size = '9pt'>Demonstrates how to use of the dock axis anchor and how to add custom 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)); // remove all legends nChartControl1.Legends.Clear(); // setup chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(17, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL( new NLength(90, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); m_RedAxis = m_Chart.Axis(StandardAxis.PrimaryY); m_GreenAxis = m_Chart.Axis(StandardAxis.SecondaryY); m_GreenAxis.Visible = true; // Add a custom vertical axis m_BlueAxis = ((NCartesianAxisCollection)m_Chart.Axes).AddCustomAxis(AxisOrientation.Vertical, AxisDockZone.FrontLeft); // create three line series and dispay them on three vertical axes (red, green and blue axis) NLineSeries line1 = CreateLineSeries(Color.Red, Color.DarkRed, 10, 20); NLineSeries line2 = CreateLineSeries(Color.Green, Color.DarkGreen, 50, 100); NLineSeries line3 = CreateLineSeries(Color.Blue, Color.DarkBlue, 100, 200); line1.DisplayOnAxis(StandardAxis.PrimaryY, true); line2.DisplayOnAxis(StandardAxis.PrimaryY, false); line2.DisplayOnAxis(StandardAxis.SecondaryY, true); line3.DisplayOnAxis(StandardAxis.PrimaryY, false); line3.DisplayOnAxis(m_BlueAxis.AxisId, true); // now configure the axis appearance NLinearScaleConfigurator linearScale; // setup the red axis linearScale = new NLinearScaleConfigurator(); m_RedAxis.ScaleConfigurator = linearScale; linearScale.RulerStyle.FillStyle = new NColorFillStyle(Color.DarkRed); linearScale.RulerStyle.BorderStyle.Color = Color.Red; linearScale.InnerMajorTickStyle.LineStyle.Color = Color.Red; linearScale.OuterMajorTickStyle.LineStyle.Color = Color.Red; linearScale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.DarkRed); // setup the green axis linearScale = new NLinearScaleConfigurator(); m_GreenAxis.ScaleConfigurator = linearScale; linearScale.RulerStyle.FillStyle = new NColorFillStyle(Color.DarkGreen); linearScale.RulerStyle.BorderStyle.Color = Color.Green; linearScale.InnerMajorTickStyle.LineStyle.Color = Color.Green; linearScale.OuterMajorTickStyle.LineStyle.Color = Color.Green; linearScale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.DarkGreen); // setup the blue axis linearScale = new NLinearScaleConfigurator(); m_BlueAxis.ScaleConfigurator = linearScale; linearScale.RulerStyle.FillStyle = new NColorFillStyle(Color.DarkBlue); linearScale.RulerStyle.BorderStyle.Color = Color.Blue; linearScale.InnerMajorTickStyle.LineStyle.Color = Color.Blue; linearScale.OuterMajorTickStyle.LineStyle.Color = Color.Blue; linearScale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.DarkBlue); UpdateAxisAnchors(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Pareto Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // no legend nChartControl1.Legends.Clear(); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; // setup the X axis NAxis axisX = m_Chart.Axis(StandardAxis.PrimaryX); NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)axisX.ScaleConfigurator; scaleX.InnerMajorTickStyle.Visible = false; // Setup the primary Y axis NAxis axisY1 = m_Chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator scaleY1 = (NLinearScaleConfigurator)axisY1.ScaleConfigurator; scaleY1.InnerMajorTickStyle.Visible = false; scaleY1.Title.Text = "Number of Occurences"; // 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); scaleY1.StripStyles.Add(stripStyle); // Setup the secondary Y axis NLinearScaleConfigurator scaleY2 = new NLinearScaleConfigurator(); scaleY2.LabelValueFormatter = new NNumericValueFormatter("0%"); scaleY2.InnerMajorTickStyle.Visible = false; scaleY2.Title.Text = "Cumulative Percent"; NAxis axisY2 = m_Chart.Axis(StandardAxis.SecondaryY); axisY2.Visible = true; axisY2.ScaleConfigurator = scaleY2; axisY2.View = new NRangeAxisView(new NRange1DD(0, 1), true, true); // add the line series m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line.Name = "Cumulative %"; m_Line.DataLabelStyle.Visible = false; 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.ShadowStyle.Type = ShadowType.GaussianBlur; m_Line.ShadowStyle.Color = Color.FromArgb(80, 0, 0, 0); m_Line.ShadowStyle.Offset = new NPointL(2, 2); m_Line.ShadowStyle.FadeLength = new NLength(4); m_Line.DisplayOnAxis(StandardAxis.PrimaryY, false); m_Line.DisplayOnAxis(StandardAxis.SecondaryY, true); // add the bar series m_Bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); m_Bar.Name = "Bar Series"; m_Bar.DataLabelStyle.Visible = false; m_Bar.ShadowStyle.Type = ShadowType.GaussianBlur; m_Bar.ShadowStyle.Color = Color.FromArgb(60, 0, 0, 0); m_Bar.ShadowStyle.Offset = new NPointL(3, 3); m_Bar.ShadowStyle.FadeLength = new NLength(4); // fill with random data and sort in descending order m_Bar.Values.FillRandomRange(Random, 10, 100, 700); m_Bar.Values.Sort(DataSeriesSortOrder.Descending); // calculate cumulative sum of the bar values int count = m_Bar.Values.Count; double cs = 0; double[] arrCumulative = new double[count]; for (int i = 0; i < count; i++) { cs += m_Bar.Values.GetDoubleValue(i); arrCumulative[i] = cs; } if (cs > 0) { for (int i = 0; i < count; i++) { arrCumulative[i] /= cs; } m_Line.Values.AddRange(arrCumulative); } // apply layout ConfigureStandardLayout(m_Chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // init form controls StyleCombo.FillFromEnum(typeof(BarShape)); StyleCombo.SelectedIndex = 0; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithValues(PeriodDropDownList, 0, 100, 10); PeriodDropDownList.SelectedIndex = 2; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; NFunctionCalculator calc = new NFunctionCalculator(); nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.None; NChart chart = nChartControl1.Charts[0]; chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(20, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(90, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); NLegend legend = nChartControl1.Legends[0]; legend.Data.ExpandMode = LegendExpandMode.ColsOnly; legend.Location = new NPointL( new NLength(98, NRelativeUnit.ParentPercentage), new NLength(12, NRelativeUnit.ParentPercentage)); // align the chart and the legend NSideGuideline guideline = new NSideGuideline(PanelSide.Right); guideline.Targets.Add(legend); guideline.Targets.Add(chart); nChartControl1.Document.RootPanel.Guidelines.Add(guideline); // 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; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // setup primary Y axis NAxis axisY1 = chart.Axis(StandardAxis.PrimaryY); axisY1.Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 45, 100); NLinearScaleConfigurator scaleY1 = (NLinearScaleConfigurator)axisY1.ScaleConfigurator; scaleY1.RulerStyle.Height = new NLength(2, NGraphicsUnit.Pixel); scaleY1.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY1.InnerMajorTickStyle.LineStyle.Width = new NLength(0); // setup secondary Y axis NAxis axisY2 = chart.Axis(StandardAxis.SecondaryY); axisY2.Visible = true; axisY2.Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 0, 40); NLinearScaleConfigurator scaleY2 = (NLinearScaleConfigurator)axisY2.ScaleConfigurator; scaleY2.RulerStyle.Height = new NLength(2, NGraphicsUnit.Pixel); scaleY2.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY2.InnerMajorTickStyle.LineStyle.Width = new NLength(0); Color color1 = Color.FromArgb(100, 100, 150); Color color2 = Color.FromArgb(200, 120, 120); Color color3 = Color.FromArgb(100, 150, 100); // setup the stock series NStockSeries stock = (NStockSeries)chart.Series.Add(SeriesType.Stock); stock.DataLabelStyle.Visible = false; stock.CandleStyle = CandleStyle.Stick; stock.UpStrokeStyle.Color = color1; stock.DownStrokeStyle.Color = color2; stock.Legend.Mode = SeriesLegendMode.None; stock.CandleWidth = new NLength(0.5f, NRelativeUnit.ParentPercentage); stock.UseXValues = true; stock.InflateMargins = true; // Add line series for ADX NLineSeries lineADX = (NLineSeries)chart.Series.Add(SeriesType.Line); lineADX.DisplayOnAxis(StandardAxis.PrimaryY, false); lineADX.DisplayOnAxis(StandardAxis.SecondaryY, true); lineADX.BorderStyle.Color = Color.LimeGreen; lineADX.Name = "ADX"; lineADX.DataLabelStyle.Visible = false; // Add line series for +DI NLineSeries lineDIPos = (NLineSeries)chart.Series.Add(SeriesType.Line); lineDIPos.MultiLineMode = MultiLineMode.Overlapped; lineDIPos.DisplayOnAxis(StandardAxis.PrimaryY, false); lineDIPos.DisplayOnAxis(StandardAxis.SecondaryY, true); lineDIPos.BorderStyle.Color = Color.Red; lineDIPos.Name = "+DI"; lineDIPos.DataLabelStyle.Visible = false; // Add line series for -DI NLineSeries lineDINeg = (NLineSeries)chart.Series.Add(SeriesType.Line); lineDINeg.MultiLineMode = MultiLineMode.Overlapped; lineDINeg.DisplayOnAxis(StandardAxis.PrimaryY, false); lineDINeg.DisplayOnAxis(StandardAxis.SecondaryY, true); lineDINeg.BorderStyle.Color = Color.Blue; lineDINeg.Name = "-DI"; lineDINeg.DataLabelStyle.Visible = false; // add arguments for function calculator stock.CloseValues.Name = "close"; stock.HighValues.Name = "high"; stock.LowValues.Name = "low"; calc.Arguments.Add(stock.CloseValues); calc.Arguments.Add(stock.HighValues); calc.Arguments.Add(stock.LowValues); // form controls lineDIPos.Visible = ShowPosDICheckBox.Checked; lineDINeg.Visible = ShowNegDICheckBox.Checked; lineADX.Visible = ShowADXCheckBox.Checked; // add header NLabel header = nChartControl1.Labels.AddHeader("Directional Movement"); 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)); GenerateData(stock); UpdateFunctions(stock, lineDIPos, lineDINeg, lineADX, calc); }
public override void Initialize() { base.Initialize(); // Enable GPU acceleration nChartControl1.Settings.RenderSurface = RenderSurface.Window; nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Surface Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(Color.Gray); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 25.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); // setup axes NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); ordinalScale.DisplayDataPointsBetweenTicks = false; ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); ordinalScale.DisplayDataPointsBetweenTicks = false; chart.Axis(StandardAxis.SecondaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 100.0f, 100.0f); chart.Axis(StandardAxis.SecondaryY).Visible = false; m_ContourLineSeries = new NLineSeries(); chart.Series.Add(m_ContourLineSeries); m_ContourLineSeries.UseXValues = true; m_ContourLineSeries.UseZValues = true; m_ContourLineSeries.BorderStyle.Width = new NLength(2); m_ContourLineSeries.BorderStyle.Color = Color.Red; m_ContourLineSeries.DataLabelStyle.Visible = false; m_ContourLineSeries.DisplayOnAxis((int)StandardAxis.PrimaryY, false); m_ContourLineSeries.DisplayOnAxis((int)StandardAxis.SecondaryY, true); m_ContourLineSeries.Legend.Mode = SeriesLegendMode.None; m_CrossSectionPlane = new NAxisConstLine(); m_CrossSectionPlane.Mode = ConstLineMode.Plane; m_CrossSectionPlane.FillStyle = new NColorFillStyle(Color.FromArgb(25, Color.Blue)); chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(m_CrossSectionPlane); // add the surface series NGridSurfaceSeries surface = (NGridSurfaceSeries)chart.Series.Add(SeriesType.GridSurface); surface.Name = "Surface"; surface.Legend.Mode = SeriesLegendMode.SeriesLogic; surface.PositionValue = 10.0; surface.Data.SetGridSize(31, 32); surface.SyncPaletteWithAxisScale = false; surface.PaletteSteps = 8; surface.ValueFormatter.FormatSpecifier = "0.00"; surface.FillStyle = new NColorFillStyle(Color.YellowGreen); surface.Isolines.Add(new NSurfaceIsoline(10, new NStrokeStyle(2.0f, Color.Blue))); surface.FrameColorMode = SurfaceFrameColorMode.Uniform; FillData(surface); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); PlaneValueNumericUpDown.Value = 10; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithEnumValues(BarShapeDropDownList, typeof(BarShape)); BarShapeDropDownList.SelectedIndex = 0; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Pareto Chart"); 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 the X axis NAxis axisX = chart.Axis(StandardAxis.PrimaryX); NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)axisX.ScaleConfigurator; scaleX.InnerMajorTickStyle.Visible = false; // setup the primary Y axis NAxis axisY1 = chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator scaleY1 = (NLinearScaleConfigurator)axisY1.ScaleConfigurator; scaleY1.InnerMajorTickStyle.Visible = false; scaleY1.Title.Text = "Number of Occurences"; // 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); scaleY1.StripStyles.Add(stripStyle); // setup the secondary Y axis NLinearScaleConfigurator scaleY2 = new NLinearScaleConfigurator(); scaleY2.LabelValueFormatter = new NNumericValueFormatter("0%"); scaleY2.InnerMajorTickStyle.Visible = false; scaleY2.Title.Text = "Cumulative Percent"; NAxis axisY2 = chart.Axis(StandardAxis.SecondaryY); axisY2.Visible = true; axisY2.ScaleConfigurator = scaleY2; axisY2.View = new NRangeAxisView(new NRange1DD(0, 1), true, true); // add a line series for the cumulative value NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); line.Name = "Cumulative"; line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Cylinder; line.DataLabelStyle.Visible = false; line.DisplayOnAxis(StandardAxis.PrimaryY, false); line.DisplayOnAxis(StandardAxis.SecondaryY, true); // add a bar series NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Name = "Bar Series"; bar.DataLabelStyle.Visible = false; bar.InflateMargins = true; bar.BarShape = (BarShape)BarShapeDropDownList.SelectedIndex; // fill with random data and sort in descending order bar.Values.FillRandom(Random, 10); bar.Values.Sort(DataSeriesSortOrder.Descending); // calculate cumulative sum of the bar values int count = bar.Values.Count; double cs = 0; double[] arrCumulative = new double[count]; for (int i = 0; i < count; i++) { cs += bar.Values.GetDoubleValue(i); arrCumulative[i] = cs; } if (cs > 0) { for (int i = 0; i < count; i++) { arrCumulative[i] /= cs; } line.Values.AddRange(arrCumulative); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Directional Movement"); 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)); // setup chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; 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)); // 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; m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // setup primary Y axis NAxis axisY1 = m_Chart.Axis(StandardAxis.PrimaryY); axisY1.Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 45, 100); NLinearScaleConfigurator scaleY1 = (NLinearScaleConfigurator)axisY1.ScaleConfigurator; scaleY1.RulerStyle.Height = new NLength(2, NGraphicsUnit.Pixel); scaleY1.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY1.InnerMajorTickStyle.LineStyle.Width = new NLength(0); // setup secondary Y axis NAxis axisY2 = m_Chart.Axis(StandardAxis.SecondaryY); axisY2.Visible = true; axisY2.Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 0, 40); NLinearScaleConfigurator scaleY2 = (NLinearScaleConfigurator)axisY2.ScaleConfigurator; scaleY2.RulerStyle.Height = new NLength(2, NGraphicsUnit.Pixel); scaleY2.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY2.InnerMajorTickStyle.LineStyle.Width = new NLength(0); Color color1 = Color.FromArgb(100, 100, 150); Color color2 = Color.FromArgb(200, 120, 120); Color color3 = Color.FromArgb(100, 150, 100); // 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.UpStrokeStyle.Color = color1; m_Stock.DownStrokeStyle.Color = color2; m_Stock.Legend.Mode = SeriesLegendMode.None; m_Stock.CandleWidth = new NLength(0.5f, NRelativeUnit.ParentPercentage); m_Stock.UseXValues = true; m_Stock.InflateMargins = true; // Add line series for ADX m_LineADX = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_LineADX.DisplayOnAxis(StandardAxis.PrimaryY, false); m_LineADX.DisplayOnAxis(StandardAxis.SecondaryY, true); m_LineADX.BorderStyle.Color = Color.LimeGreen; m_LineADX.Name = "ADX"; m_LineADX.DataLabelStyle.Visible = false; m_LineADX.UseXValues = true; // Add line series for +DI m_LineDIPos = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_LineDIPos.MultiLineMode = MultiLineMode.Overlapped; m_LineDIPos.DisplayOnAxis(StandardAxis.PrimaryY, false); m_LineDIPos.DisplayOnAxis(StandardAxis.SecondaryY, true); m_LineDIPos.BorderStyle.Color = color2; m_LineDIPos.Name = "+DI"; m_LineDIPos.DataLabelStyle.Visible = false; m_LineDIPos.UseXValues = true; // Add line series for -DI m_LineDINeg = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_LineDINeg.MultiLineMode = MultiLineMode.Overlapped; m_LineDINeg.DisplayOnAxis(StandardAxis.PrimaryY, false); m_LineDINeg.DisplayOnAxis(StandardAxis.SecondaryY, true); m_LineDINeg.BorderStyle.Color = color1; m_LineDINeg.Name = "-DI"; m_LineDINeg.DataLabelStyle.Visible = false; m_LineDINeg.UseXValues = true; // add arguments for function calculator m_Stock.CloseValues.Name = "close"; m_Stock.HighValues.Name = "high"; m_Stock.LowValues.Name = "low"; m_Calc.Arguments.Add(m_Stock.CloseValues); m_Calc.Arguments.Add(m_Stock.HighValues); m_Calc.Arguments.Add(m_Stock.LowValues); // form controls m_PeriodScroll.Value = 14; m_ShowPosCheck.Checked = true; m_ShowNegCheck.Checked = true; m_ShowADXCheck.Checked = true; GenerateData(); UpdateFunctions(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Covariance, Correlation"); 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)); // chart functions m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; 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)); // add a line series for the function m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line.MarkerStyle.Visible = true; m_Line.MarkerStyle.BorderStyle.Color = Color.DarkGreen; m_Line.MarkerStyle.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel); m_Line.MarkerStyle.Width = new NLength(1f, NRelativeUnit.ParentPercentage); m_Line.MarkerStyle.Height = new NLength(1f, NRelativeUnit.ParentPercentage); m_Line.MarkerStyle.PointShape = PointShape.Cylinder; m_Line.MarkerStyle.FillStyle = new NColorFillStyle(Color.Beige); m_Line.BorderStyle.Color = Color.Green; m_Line.BorderStyle.Width = new NLength(3, NGraphicsUnit.Pixel); m_Line.Legend.Mode = SeriesLegendMode.None; m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.00"); m_Line.DisplayOnAxis(StandardAxis.PrimaryX, false); m_Line.DisplayOnAxis(StandardAxis.SecondaryX, true); // add the line series m_Line1 = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line1.Name = "Line1"; m_Line1.Values.Name = "values1"; m_Line1.Values.ValueFormatter = new NNumericValueFormatter("0.00"); m_Line1.DataLabelStyle.Visible = false; m_Line1.BorderStyle.Color = Color.DarkKhaki; m_Line1.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel); m_Line1.Legend.Mode = SeriesLegendMode.Series; m_Line1.Values.FillRandomRange(Random, 12, 0, 50); // add the line series m_Line2 = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line2.Name = "Line2"; m_Line2.Values.Name = "values2"; m_Line2.Values.ValueFormatter = new NNumericValueFormatter("0.00"); m_Line2.DataLabelStyle.Visible = false; m_Line2.BorderStyle.Color = Color.DarkCyan; m_Line2.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel); m_Line2.Legend.Mode = SeriesLegendMode.Series; m_Line2.Values.FillRandomRange(Random, 12, 0, 50); // form controls m_bSkipUpdate = true; m_FunctionCombo.Items.Add("Covariance"); m_FunctionCombo.Items.Add("Correlation"); m_FunctionCombo.SelectedIndex = 0; m_GroupingCombo.Items.Add("Do not group"); m_GroupingCombo.Items.Add("Group by every 2 values"); m_GroupingCombo.Items.Add("Group by every 3 values"); m_GroupingCombo.Items.Add("Group by every 4 values"); m_GroupingCombo.SelectedIndex = 0; m_bSkipUpdate = false; FunctionCombo_SelectedIndexChanged(null, null); }