/// <summary> /// Adds a step line series to the chart /// </summary> /// <param name="chart"></param> /// <param name="name"></param> /// <param name="vector"></param> /// <param name="xstart"></param> /// <param name="xincrement"></param> void AddStepLineSeries(NChart chart, string name, DoubleVector vector, double xstart, double xincrement) { NStepLineSeries stepline = new NStepLineSeries(); chart.Series.Add(stepline); // Name the line stepline.Name = name; // Tell the series to regard the X values stepline.UseXValues = true; // No data labels stepline.DataLabelStyle.Visible = false; // Set the line color stepline.BorderStyle = new NStrokeStyle(1.0f, Color.Gray, LinePattern.Dash); // Fill X values for (int i = 0; i < vector.Length; i++) { stepline.XValues.Add(xstart + xincrement * i); } // Fill Y values stepline.Values.AddRange(vector.DataBlock.Data); }
public void PointOfChartSelected (NChart chart, NChartPoint point) { if (m_prevSelectedPoint != null && m_prevSelectedPoint.Tooltip != null) m_prevSelectedPoint.Tooltip.SetVisible (false, 0.25f); if (point != null) { if (point.Tooltip != null) { if (point == m_prevSelectedPoint) { m_prevSelectedPoint = null; } else { m_prevSelectedPoint = point; UpdateTooltipText (point); point.Tooltip.SetVisible (true, 0.25f); } } else { m_prevSelectedPoint = point; point.Tooltip = CreateTooltip (); UpdateTooltipText (point); point.Tooltip.SetVisible (true, 0.25f); } } else { m_prevSelectedPoint = null; } }
public override void Initialize() { base.Initialize(); 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(""); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.TextFormat = TextFormat.XML; title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 50.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); // setup axes NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorTickMode = MajorTickMode.AutoMaxCount; scaleY.MaxTickCount = 5; NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale = new NLinearScaleConfigurator(); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale; // setup surface series m_Surface = new NVertexSurfaceSeries(); chart.Series.Add(m_Surface); m_Surface.Name = "Surface"; m_Surface.SyncPaletteWithAxisScale = false; m_Surface.PaletteSteps = 8; m_Surface.ValueFormatter.FormatSpecifier = "0.00"; m_Surface.FillMode = SurfaceFillMode.ZoneTexture; m_Surface.ShadingMode = ShadingMode.Smooth; m_Surface.SmoothPalette = true; // apply layout ConfigureStandardLayout(chart, title, null); VertexPrimitiveCombo.FillFromEnum(typeof(VertexPrimitive)); VertexPrimitiveCombo.SelectedIndex = (int)VertexPrimitive.Points; }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Surface With Empty Data Points"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // setup legend NLegend legend = nChartControl1.Legends[0]; legend.VerticalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); 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.FillStyle = new NColorFillStyle(Color.Transparent); legend.Data.MarkSize = new NSizeL( new NLength(8, NGraphicsUnit.Pixel), new NLength(8, NGraphicsUnit.Pixel)); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Projection.Type = ProjectionType.Perspective; chart.Projection.Elevation = 28; chart.Projection.Rotation = -18; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); chart.Width = 70.0f; chart.Depth = 70.0f; chart.Height = 30.0f; if (IsPostBack) { chart.Projection.Rotation = (float)Convert.ToDouble(RotationTextBox.Text); chart.Projection.Elevation = (float)Convert.ToDouble(ElevationTextBox.Text); } else { RotationTextBox.Text = chart.Projection.Rotation.ToString(); ElevationTextBox.Text = chart.Projection.Elevation.ToString(); smoothShadingCheck.Checked = true; } // setup Y axis NLinearScaleConfigurator linearScaleConfigurator = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScaleConfigurator.LabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 8); // 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); linearScaleConfigurator.StripStyles.Add(stripStyle); // setup X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Back }; scaleX.RoundToTickMin = false; scaleX.RoundToTickMax = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // setup Z axis NLinearScaleConfigurator scaleZ = new NLinearScaleConfigurator(); scaleZ.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Left }; scaleZ.RoundToTickMin = false; scaleZ.RoundToTickMax = false; chart.Axis(StandardAxis.Depth).ScaleConfigurator = scaleZ; // add the surface series NGridSurfaceSeries surface = (NGridSurfaceSeries)chart.Series.Add(SeriesType.GridSurface); surface.Name = "Surface"; surface.Legend.Mode = SeriesLegendMode.SeriesLogic; surface.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point); surface.PositionValue = 10.0; surface.Data.SetGridSize(40, 40); surface.SyncPaletteWithAxisScale = false; surface.PaletteSteps = 8; surface.ValueFormatter.FormatSpecifier = "0.0"; FillData(surface); if (smoothShadingCheck.Checked) { surface.ShadingMode = ShadingMode.Smooth; } else { surface.ShadingMode = ShadingMode.Flat; } // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, legend); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("XYZ Scatter Smooth Line"); 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.Enable3D = true; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.Depth = 55.0f; chart.Width = 55.0f; chart.Height = 55.0f; // setup Y axis NLinearScaleConfigurator linearScaleConfigurator = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScaleConfigurator.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); linearScaleConfigurator.StripStyles.Add(stripStyle); // setup X axis linearScaleConfigurator = new NLinearScaleConfigurator(); linearScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScaleConfigurator.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Floor }; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScaleConfigurator; // setup Z axis linearScaleConfigurator = new NLinearScaleConfigurator(); linearScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScaleConfigurator.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Left, ChartWallType.Floor }; chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScaleConfigurator; // setup the smooth line series NSmoothLineSeries line = (NSmoothLineSeries)chart.Series.Add(SeriesType.SmoothLine); line.Name = "Smooth Line"; line.InflateMargins = true; line.Legend.Mode = SeriesLegendMode.None; line.DataLabelStyle.Visible = false; line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Sphere; line.MarkerStyle.AutoDepth = false; line.MarkerStyle.Width = new NLength(1.4f, NRelativeUnit.ParentPercentage); line.MarkerStyle.Height = new NLength(1.4f, NRelativeUnit.ParentPercentage); line.MarkerStyle.Depth = new NLength(1.4f, NRelativeUnit.ParentPercentage); line.UseXValues = true; line.UseZValues = true; ChangeData(line); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { EnableInitialPositioningCheckBox.Checked = true; EnableLabelAdjustmentCheckBox.Checked = true; HiddenField1.Value = Random.Next().ToString(); } nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Stack Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); // configure the chart NChart chart = nChartControl1.Charts[0]; // configure X axis NOrdinalScaleConfigurator scaleX = new NOrdinalScaleConfigurator(); scaleX.DisplayDataPointsBetweenTicks = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // configure Y axis NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // add interlaced stripe for Y axis NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY.StripStyles.Add(stripStyle); // line series 1 NLineSeries series1 = (NLineSeries)chart.Series.Add(SeriesType.Line); series1.Name = "Line 1"; series1.InflateMargins = true; series1.MarkerStyle.Visible = true; series1.MarkerStyle.FillStyle = new NColorFillStyle(DarkOrange); series1.MarkerStyle.PointShape = PointShape.Ellipse; series1.MarkerStyle.Width = new NLength(1.0f, NRelativeUnit.ParentPercentage); series1.MarkerStyle.Height = new NLength(1.0f, NRelativeUnit.ParentPercentage); series1.DataLabelStyle.Visible = true; series1.DataLabelStyle.VertAlign = VertAlign.Top; series1.DataLabelStyle.ArrowLength = new NLength(10); series1.DataLabelStyle.ArrowStrokeStyle.Color = DarkOrange; series1.DataLabelStyle.TextStyle.BackplaneStyle.StandardFrameStyle.InnerBorderColor = DarkOrange; series1.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8); // line series 2 NLineSeries series2 = (NLineSeries)chart.Series.Add(SeriesType.Line); series2.Name = "Line 2"; series2.InflateMargins = true; series2.MultiLineMode = MultiLineMode.Stacked; series2.MarkerStyle.Visible = true; series2.MarkerStyle.FillStyle = new NColorFillStyle(Green); series2.MarkerStyle.PointShape = PointShape.Pyramid; series2.MarkerStyle.Width = new NLength(1.0f, NRelativeUnit.ParentPercentage); series2.MarkerStyle.Height = new NLength(1.0f, NRelativeUnit.ParentPercentage); series2.DataLabelStyle.Visible = true; series2.DataLabelStyle.VertAlign = VertAlign.Top; series2.DataLabelStyle.ArrowLength = new NLength(10); series2.DataLabelStyle.ArrowStrokeStyle.Color = Green; series2.DataLabelStyle.TextStyle.BackplaneStyle.StandardFrameStyle.InnerBorderColor = Green; series2.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8); // label layout settings chart.LabelLayout.EnableInitialPositioning = EnableInitialPositioningCheckBox.Checked; chart.LabelLayout.EnableLabelAdjustment = EnableLabelAdjustmentCheckBox.Checked; NSizeL safeguardSize = new NSizeL( new NLength(1.6f, NRelativeUnit.ParentPercentage), new NLength(1.6f, NRelativeUnit.ParentPercentage)); series1.LabelLayout.UseLabelLocations = true; series1.LabelLayout.OutOfBoundsLocationMode = OutOfBoundsLocationMode.PushWithinBounds; series1.LabelLayout.InvertLocationsIfIgnored = true; series1.LabelLayout.EnableDataPointSafeguard = true; series1.LabelLayout.DataPointSafeguardSize = safeguardSize; series2.LabelLayout.UseLabelLocations = true; series2.LabelLayout.OutOfBoundsLocationMode = OutOfBoundsLocationMode.PushWithinBounds; series2.LabelLayout.InvertLocationsIfIgnored = true; series2.LabelLayout.EnableDataPointSafeguard = true; series2.LabelLayout.DataPointSafeguardSize = safeguardSize; // fill with random data GenerateData(chart); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Train Sales"); 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)); nChartControl1.Legends[0].Mode = LegendMode.Disabled; NChart chart = nChartControl1.Charts[0]; // perform manual stretch float fAspect = ((float)nChartControl1.Width.Value / (float)nChartControl1.Height.Value); // perform manual stretch if (fAspect > 1) { chart.Width = 86 * fAspect; chart.Height = 70; } else { chart.Width = 86; chart.Height = 70 * fAspect; } chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(18, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(86, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); chart.Wall(ChartWallType.Floor).Visible = false; chart.Wall(ChartWallType.Left).Visible = false; chart.Axis(StandardAxis.Depth).Visible = false; chart.Axis(StandardAxis.Depth).Visible = false; NOrdinalScaleConfigurator ordinalScaleConfigurator = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScaleConfigurator.InnerMajorTickStyle.LineStyle.Width = new NLength(0, NGraphicsUnit.Pixel); ordinalScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; ordinalScaleConfigurator.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, false); ordinalScaleConfigurator.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); NDockAxisAnchor anchor = new NDockAxisAnchor(AxisDockZone.FrontBottom, false, 5, 95); chart.Axis(StandardAxis.PrimaryX).Anchor = anchor; NLinearScaleConfigurator linearSclaeConfigurator = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearSclaeConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Name = "Bar Series"; bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); bar.FillStyle = new NColorFillStyle(Color.MediumPurple); bar.DataLabelStyle.Visible = false; bar.InflateMargins = true; // fill with random data Random random = new Random(); bar.Values.FillRandom(random, 10); // generate a data series cumulative sum of the bar values NFunctionCalculator fc = new NFunctionCalculator(); fc.Expression = "CUMSUM(Value)"; fc.Arguments.Add(bar.Values); // display this data series as line line.Name = "Cumulative"; line.Values = fc.Calculate(); line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Cylinder; line.DataLabelStyle.Visible = false; line.DataLabelStyle.ArrowStrokeStyle.Width = new NLength(0, NGraphicsUnit.Pixel); bar.BarShape = BarShape.Cylinder; for (int i = 0; i < bar.Values.Count; i++) { bar.FillStyles[i] = new NColorFillStyle(WebExamplesUtilities.RandomColor()); } bar.Legend.Mode = SeriesLegendMode.DataPoints; line.Legend.Mode = SeriesLegendMode.None; NImageResponse imageResponse = new NImageResponse(); imageResponse.StreamImageToBrowser = true; nChartControl1.ServerSettings.BrowserResponseSettings.DefaultResponse = imageResponse; nChartControl1.RenderControl(null); }
/// <summary> /// Displays a custom label at the secondary Y axis /// </summary> /// <param name="chart"></param> /// <param name="value"></param> /// <param name="label"></param> void SetValueLabel(NChart chart, double value, string label, bool showValue) { NScaleConfigurator scaleY2 = chart.Axis(StandardAxis.SecondaryY).ScaleConfigurator; string text = showValue ? string.Format("{0} = {1:0.###}", label, value) : label; NCustomValueLabel cl = new NCustomValueLabel(value, text); cl.Style.TextStyle.FontStyle = new NFontStyle("Arial", 8); cl.Style.ContentAlignment = ContentAlignment.TopCenter; scaleY2.CustomLabels.Add(cl); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { EnableInitialPositioningCheckBox.Checked = true; EnableLabelAdjustmentCheckBox.Checked = true; HiddenField1.Value = Random.Next().ToString(); } nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Cluster Stack Bar Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); // configure the chart NChart chart = nChartControl1.Charts[0]; // configure Y axis NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // add interlaced stripe for Y axis NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY.StripStyles.Add(stripStyle); NSizeL dataPointSafeguardSize = new NSizeL( new NLength(1.3f, NRelativeUnit.ParentPercentage), new NLength(1.3f, NRelativeUnit.ParentPercentage)); // series 1 NBarSeries series1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); series1.Name = "Bar 1"; series1.FillStyle = new NColorFillStyle(DarkOrange); series1.DataLabelStyle.Visible = true; series1.DataLabelStyle.VertAlign = VertAlign.Center; series1.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8); // series 2 NBarSeries series2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); series2.Name = "Bar 2"; series2.MultiBarMode = MultiBarMode.Stacked; series2.FillStyle = new NColorFillStyle(Green); series2.DataLabelStyle.Visible = true; series2.DataLabelStyle.VertAlign = VertAlign.Center; series2.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8); // series 3 NBarSeries series3 = (NBarSeries)chart.Series.Add(SeriesType.Bar); series3.Name = "Bar 3"; series3.MultiBarMode = MultiBarMode.Clustered; series3.FillStyle = new NColorFillStyle(Red); series3.DataLabelStyle.Visible = true; series3.DataLabelStyle.VertAlign = VertAlign.Top; series3.DataLabelStyle.ArrowLength = new NLength(10); series3.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8); // generate random data GenerateData(chart); // enable initial labels positioning chart.LabelLayout.EnableInitialPositioning = EnableInitialPositioningCheckBox.Checked; // enable label adjustment chart.LabelLayout.EnableLabelAdjustment = EnableLabelAdjustmentCheckBox.Checked; // series 1 data points must not be overlapped series1.LabelLayout.EnableDataPointSafeguard = true; series1.LabelLayout.DataPointSafeguardSize = dataPointSafeguardSize; // do not use label location proposals for series 1 series1.LabelLayout.UseLabelLocations = false; // series 2 data points must not be overlapped series2.LabelLayout.EnableDataPointSafeguard = true; series2.LabelLayout.DataPointSafeguardSize = dataPointSafeguardSize; // do not use label location proposals for series 2 series2.LabelLayout.UseLabelLocations = false; // series 3 data points must not be overlapped series3.LabelLayout.EnableDataPointSafeguard = true; series3.LabelLayout.DataPointSafeguardSize = dataPointSafeguardSize; // series 3 data labels can be placed above and below the origin point series3.LabelLayout.UseLabelLocations = true; series3.LabelLayout.LabelLocations = new LabelLocation[] { LabelLocation.Top, LabelLocation.Bottom }; series3.LabelLayout.InvertLocationsIfIgnored = false; series3.LabelLayout.OutOfBoundsLocationMode = OutOfBoundsLocationMode.PushWithinBounds; // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
public void TimeIndexChangedTo (NChart chart, double timeIndex) { // Do nothing, this demo does not cover the changing of the time index. }
void SetupChartAxes(NChart chart) { NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dash; scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY.InnerMajorTickStyle.Visible = false; chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.MajorGridStyle.LineStyle.Pattern = LinePattern.Dash; scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.InnerMajorTickStyle.Visible = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; }
internal void ApplyLayoutTemplate(int template, NChart chart, NLabel title, NLegend legend) { nChartControl1.Panels.Clear(); if (title != null) { nChartControl1.Panels.Add(title); title.Dock = DockStyle.Top; title.Padding = new NMarginsL(5, 8, 5, 4); } if (legend != null) { nChartControl1.Panels.Add(legend); legend.Dock = DockStyle.Right; legend.Padding = new NMarginsL(1, 1, 5, 5); } if (chart != null) { nChartControl1.Panels.Add(chart); float topPad = (title == null) ? 11 : 8; float rightPad = (legend == null) ? 11 : 4; if (chart.Enable3D || (chart.BoundsMode == BoundsMode.None)) { chart.BoundsMode = BoundsMode.Fit; } chart.Dock = DockStyle.Fill; chart.Padding = new NMarginsL( new NLength(11, NRelativeUnit.ParentPercentage), new NLength(topPad, NRelativeUnit.ParentPercentage), new NLength(rightPad, NRelativeUnit.ParentPercentage), new NLength(11, NRelativeUnit.ParentPercentage)); } }
public void PointSelected (NChart nChart, NChartPoint nChartPoint) { // Disable highlight. if (prevSelectedPoint != null) prevSelectedPoint.Highlight (NChartTypes.HighlightType.None, 0.25f, 0.0f); if (nChartPoint != null) { if (nChartPoint == prevSelectedPoint) { prevSelectedPoint = null; // Return to normal zoom. if (zoomed) { zoomed = false; mNChartView.Chart.ZoomTo (1.0f, 0.25f, 0.0f); } } else { prevSelectedPoint = nChartPoint; if (!zoomed) { zoomed = true; mNChartView.Chart.ZoomTo (0.85f, 0.25f, 0.0f); } // Set shift to highlight. nChartPoint.HighlightShift = 0.2f; // Set color to highlight. nChartPoint.HighlightColor = Color.Red; // Highlight point by shift and color. nChartPoint.Highlight (NChartTypes.HighlightType.Shift | NChartTypes.HighlightType.Color, 0.25f, 0.0f); } } else { prevSelectedPoint = null; // Return to normal zoom. if (zoomed) { zoomed = false; mNChartView.Chart.ZoomTo (1.0f, 0.25f, 0.0f); } } }
private void callLowHighGraph(string projectName, string ScenarioName) { nChartControl1.Clear(); nChartControl1.Legends.Clear(); NLabel title = nChartControl1.Labels.AddHeader("이미지별 최대 최소 시간"); //title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Bold); title.TextStyle.FontStyle = new NFontStyle(pfc.Families[0].ToString(), 18, FontStyle.Regular); //title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; // add a High-Low series m_HighLow = (NHighLowSeries)m_Chart.Series.Add(SeriesType.HighLow); m_HighLow.Name = "High-Low Series"; m_HighLow.HighFillStyle = new NColorFillStyle(Color.FromArgb(68, 90, 108)); m_HighLow.HighBorderStyle = new NStrokeStyle(Color.FromArgb(254, 181, 25)); //m_HighLow.LowFillStyle = new NColorFillStyle(DarkOrange); m_HighLow.DataLabelStyle.Visible = true; m_HighLow.DataLabelStyle.Format = " <high_value>\n<low_value>"; m_HighLow.LowValues.ValueFormatter = new NNumericValueFormatter("0.##"); m_HighLow.HighValues.ValueFormatter = new NNumericValueFormatter("0.##"); m_HighLow.DropLines = true; m_HighLow.ClearDataPoints(); NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); //m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.ResetButton.Visible = false; NNumericAxisPagingView numericPagingView = new NNumericAxisPagingView(new NRange1DD(0, 10)); m_Chart.Axis(StandardAxis.PrimaryX).PagingView = numericPagingView; m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleConfiguratorX.AutoLabels = false; // data 값을 다 불러와서 foreach (ResultData.ResultInfo temp in rData.getRData()) { // 현재 찾고자 하는 프로젝트와 시나리오랑 같으면 if (temp.projectName == projectName && temp.taskName == ScenarioName) { // 해당 시나리오 값에서 이동한 path 이미지들 값 가져오기 foreach (ResultData.ImgTime imgTemp in temp.pathInfo) { bool inList = false; float timeValue = System.Convert.ToSingle(imgTemp.timeImg); // 리스트 내에 같은 값 찾기 if (ImgTimeInfo.Count != 0) { foreach (ImgTime inListImg in ImgTimeInfo) { // 같은게 있다면 if (inListImg.imgName == imgTemp.imgName) { // 현재 값이 high 보다 크다면 if (inListImg.High <= timeValue) inListImg.High = timeValue; else if (inListImg.Low >= timeValue) inListImg.Low = timeValue; inList = true; break; } } } // 리스트 내에 없다면 if (inList == false) ImgTimeInfo.Add(new ImgTime() { imgName = imgTemp.imgName, High = timeValue, Low = timeValue }); } } } foreach (ImgTime listImg in ImgTimeInfo) { scaleConfiguratorX.Labels.Add(listImg.imgName); m_HighLow.HighValues.Add(listImg.High); m_HighLow.LowValues.Add(listImg.Low); } nChartControl1.Refresh(); }
private void callPersonalGraph(string projectName, string ScenarioName, int idx) { nChartControl1.Clear(); //rData.getRData()[0].taskName 이런식으로 인덱스 줘서 사용하면 될 듯 m_FuncCalculator = new NFunctionCalculator(); nChartControl1.Legends.Clear(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Task x 소요 시간"); //title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Regular); title.TextStyle.FontStyle = new NFontStyle(pfc.Families[0].ToString(), 18, FontStyle.Regular); 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)); //m_Chart.Axis(StandardAxis.Depth).Visible = false; // 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(1.2f, NRelativeUnit.ParentPercentage); m_Line.MarkerStyle.Height = new NLength(1.2f, NRelativeUnit.ParentPercentage); m_Line.MarkerStyle.PointShape = PointShape.Cylinder; m_Line.MarkerStyle.FillStyle = new NColorFillStyle(Color.Gold); m_Line.BorderStyle.Color = Color.DarkGreen; m_Line.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel); m_Line.Legend.Mode = SeriesLegendMode.None; m_Line.DataLabelStyle.Format = "<value>"; m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.0"); m_Line.ShadowStyle.Type = ShadowType.GaussianBlur; m_Line.ShadowStyle.Offset = new NPointL(2, 2); m_Line.ShadowStyle.Color = Color.FromArgb(120, 0, 0, 0); m_Line.ShadowStyle.FadeLength = new NLength(5); // 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.0"); m_Bar.MultiBarMode = MultiBarMode.Stacked; m_Bar.DataLabelStyle.Visible = true; // 바에 보이는 값 //m_Bar.Legend.Mode = SeriesLegendMode.None; // 범례 안보이게 하는 거 m_Bar.BarShape = BarShape.Cylinder; m_Bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); m_Bar.FillStyle = new NColorFillStyle(Color.DarkKhaki); m_Bar.ShadowStyle.Type = ShadowType.Solid; m_Bar.ShadowStyle.Offset = new NPointL(2, 2); m_Bar.ShadowStyle.Color = Color.FromArgb(80, 0, 0, 0); //m_Bar.Values.FillRandomRange(new Random(), 14, 0, 100); NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); //m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.ResetButton.Visible = false; NNumericAxisPagingView numericPagingView = new NNumericAxisPagingView(new NRange1DD(0, 10)); m_Chart.Axis(StandardAxis.PrimaryX).PagingView = numericPagingView; m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleConfiguratorX.AutoLabels = false; foreach (ResultData.ResultInfo temp in rData.getRData()) { // 현재 찾고자 하는 프로젝트와 시나리오랑 같으면 if (temp.projectName == projectName && temp.taskName == ScenarioName) { if (idx == -1 /*&& temp.isMin == true*/) // ***************************************************************************************************************** check { ImgAverageInfo.Clear(); // 해당 시나리오 값에서 이동한 path 이미지들 값 가져오기 foreach (ResultData.ImgTime imgTemp in temp.pathInfo) { bool inList = false; float timeValue = System.Convert.ToSingle(imgTemp.timeImg); // 리스트 내에 같은 값 찾기 if (ImgAverageInfo.Count != 0) { foreach (ImgAverageTime inListImg in ImgAverageInfo) { // 같은게 있다면 if (inListImg.imgName == imgTemp.imgName) { inListImg.count += 1; inListImg.imgTime += timeValue; inList = true; break; } } } // 리스트 내에 없다면 if (inList == false) ImgAverageInfo.Add(new ImgAverageTime() { imgName = imgTemp.imgName, imgTime = timeValue, count = 1 }); } } // Idx랑 같으면 else if (temp.idx == idx) { // 해당 시나리오 값에서 이동한 path 이미지들 값 가져오기 foreach (ResultData.ImgTime imgTemp in temp.pathInfo) { scaleConfiguratorX.Labels.Add(imgTemp.imgName); m_Bar.Values.Add(imgTemp.timeImg); } } } } if (idx == -1) { foreach (ImgAverageTime listImg in ImgAverageInfo) { scaleConfiguratorX.Labels.Add(listImg.imgName); m_Bar.Values.Add(listImg.imgTime / listImg.count); } } //m_FuncCalculator.Arguments.Add(m_Line.Values); m_FuncCalculator.Arguments.Add(m_Bar.Values); m_FuncCalculator.Expression = "CUMSUM(values)"; m_Line.Values = m_FuncCalculator.Calculate(); m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.0"); // form controls /*m_FunctionCombo.Items.Add("Power"); m_FunctionCombo.Items.Add("Cumulative"); m_FunctionCombo.Items.Add("Exponential Average"); m_FunctionCombo.SelectedIndex = 0;*/ nChartControl1.Refresh(); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Stacked Bar Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Enable3D = true; m_Chart.Width = 65; m_Chart.Height = 40; m_Chart.Axis(StandardAxis.Depth).Visible = false; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.BrightCameraLight); // add interlace stripe 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 the first bar m_Bar1 = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); m_Bar1.Name = "Bar1"; m_Bar1.MultiBarMode = MultiBarMode.Series; // add the second bar m_Bar2 = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); m_Bar2.Name = "Bar2"; m_Bar2.MultiBarMode = MultiBarMode.Stacked; // add the third bar m_Bar3 = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); m_Bar3.Name = "Bar3"; m_Bar3.MultiBarMode = MultiBarMode.Stacked; // setup value formatting m_Bar1.Values.ValueFormatter = new NNumericValueFormatter("0.###"); m_Bar2.Values.ValueFormatter = new NNumericValueFormatter("0.###"); m_Bar3.Values.ValueFormatter = new NNumericValueFormatter("0.###"); // position data labels in the center of the bars m_Bar1.DataLabelStyle.VertAlign = VertAlign.Center; m_Bar2.DataLabelStyle.VertAlign = VertAlign.Center; m_Bar3.DataLabelStyle.VertAlign = VertAlign.Center; m_Bar1.DataLabelStyle.ArrowLength = new NLength(0); m_Bar2.DataLabelStyle.ArrowLength = new NLength(0); m_Bar3.DataLabelStyle.ArrowLength = new NLength(0); // apply layout ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // init form controls InitLabelsCombo(FirstAreaDataLabelsComboBox); InitLabelsCombo(SecondAreaDataLabelsComboBox); InitLabelsCombo(ThirdAreaDataLabelsComboBox); StackModeComboBox.Items.Add("Stacked"); StackModeComboBox.Items.Add("Stacked %"); StackModeComboBox.SelectedIndex = 0; NExampleHelpers.FillComboWithEnumValues(BarShapeComboBox, typeof(BarShape)); BarShapeComboBox.SelectedIndex = 0; PositiveDataButton_Click(null, null); ShowDataLabelsCheckBox_Checked(null, null); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Multi Series Area Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); // apply predefined projection and lighting NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Width = 65.0f; chart.Height = 40.0f; chart.Depth = 40.0f; // add interlace stripe NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); // add the first area NAreaSeries area1 = (NAreaSeries)chart.Series.Add(SeriesType.Area); area1.MultiAreaMode = MultiAreaMode.Series; area1.DataLabelStyle.Visible = false; area1.Name = "Area 1"; area1.Values.FillRandomRange(Random, 15, 10, 40); // add the second area NAreaSeries area2 = (NAreaSeries)chart.Series.Add(SeriesType.Area); area2.MultiAreaMode = MultiAreaMode.Series; area2.DataLabelStyle.Visible = false; area2.Name = "Area 2"; area2.Values.FillRandomRange(Random, 15, 30, 60); // add the third area NAreaSeries area3 = (NAreaSeries)chart.Series.Add(SeriesType.Area); area3.MultiAreaMode = MultiAreaMode.Series; area3.DataLabelStyle.Visible = false; area3.Name = "Area 3"; area3.Values.FillRandomRange(Random, 15, 50, 80); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); }
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("Date/Time Smooth Area"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // no legend nChartControl1.Legends.Clear(); // setup chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale; dateTimeScale.LabelValueFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.Date); dateTimeScale.LabelGenerationMode = LabelGenerationMode.Stagger2; NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); // 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); linearScale.StripStyles.Add(stripStyle); // add the area series NSmoothAreaSeries area = (NSmoothAreaSeries)chart.Series.Add(SeriesType.SmoothArea); area.DataLabelStyle.Visible = false; area.MarkerStyle.Visible = true; area.MarkerStyle.PointShape = PointShape.Cylinder; area.MarkerStyle.AutoDepth = false; area.MarkerStyle.Width = new NLength(1.4f, NRelativeUnit.ParentPercentage); area.MarkerStyle.Height = new NLength(1.4f, NRelativeUnit.ParentPercentage); area.MarkerStyle.Depth = new NLength(1.4f, NRelativeUnit.ParentPercentage); area.UseXValues = true; ShowMarkersCheck.Checked = true; RoundToTickCheck.Checked = true; ShowDropLinesCheck.Checked = false; AreaOriginModeCombo.FillFromEnum(typeof(SeriesOriginMode)); AreaOriginModeCombo.SelectedIndex = 0; OriginValueTextBox.Text = "0"; GenerateYValues(nValuesCount); GenerateXValues(nValuesCount); // 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, EventArgs e) { if (!IsPostBack) { // fill the combo LineStyleDropDownList.Items.Add("Line"); LineStyleDropDownList.Items.Add("Tape"); LineStyleDropDownList.Items.Add("Tube"); LineStyleDropDownList.Items.Add("Ellipsoid"); LineStyleDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithEnumValues(MarkerShapeDropDownList, typeof(PointShape)); MarkerShapeDropDownList.SelectedIndex = 1; WebExamplesUtilities.FillComboWithPercents(LineDepthDropDownList, 10); LineDepthDropDownList.SelectedIndex = 4; WebExamplesUtilities.FillComboWithValues(LineWidthDropDownList, 0, 5, 1); LineWidthDropDownList.SelectedIndex = 1; WebExamplesUtilities.FillComboWithColorNames(LineColorDropDownList, KnownColor.DarkSalmon); WebExamplesUtilities.FillComboWithColorNames(LineFillColorDropDownList, KnownColor.LightSalmon); WebExamplesUtilities.FillComboWithValues(MarkerSizeDropDownList, 0, 10, 1); MarkerSizeDropDownList.SelectedIndex = 2; ShowMarkersCheckBox.Checked = true; LeftAxisRoundToTickCheckBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("3D Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective2); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Axis(StandardAxis.Depth).Visible = false; // setup Y axis NLinearScaleConfigurator scaleY = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; scaleY.RoundToTickMin = LeftAxisRoundToTickCheckBox.Checked; scaleY.RoundToTickMax = LeftAxisRoundToTickCheckBox.Checked; // add Y axis 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); scaleY.StripStyles.Add(stripStyle); // setup X axis NOrdinalScaleConfigurator scaleX = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleX.DisplayDataPointsBetweenTicks = false; // setup the line series NLineSeries nLine = (NLineSeries)chart.Series.Add(SeriesType.Line); nLine.Values.FillRandom(Random, 10); nLine.DataLabelStyle.Visible = false; nLine.Legend.Mode = SeriesLegendMode.DataPoints; nLine.BorderStyle.Width = new NLength(LineWidthDropDownList.SelectedIndex, NGraphicsUnit.Pixel); nLine.DepthPercent = LineDepthDropDownList.SelectedIndex * 10; nLine.BorderStyle.Color = WebExamplesUtilities.ColorFromDropDownList(LineColorDropDownList); nLine.FillStyle = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(LineFillColorDropDownList)); nLine.InflateMargins = InflateMarginsCheckBox.Checked; nLine.MarkerStyle.Visible = ShowMarkersCheckBox.Checked; bool bSimpleLine = (LineStyleDropDownList.SelectedIndex == 0); switch (LineStyleDropDownList.SelectedIndex) { case 0: // simple line nLine.LineSegmentShape = LineSegmentShape.Line; break; case 1: // tape nLine.LineSegmentShape = LineSegmentShape.Tape; break; case 2: // tube nLine.LineSegmentShape = LineSegmentShape.Tube; break; case 3: // elipsoid nLine.LineSegmentShape = LineSegmentShape.Ellipsoid; break; } LineDepthDropDownList.Enabled = !bSimpleLine; LineFillColorDropDownList.Enabled = !bSimpleLine; MarkerShapeDropDownList.Enabled = ShowMarkersCheckBox.Checked; MarkerSizeDropDownList.Enabled = ShowMarkersCheckBox.Checked; if (nLine.MarkerStyle.Visible) { nLine.MarkerStyle.PointShape = (PointShape)MarkerShapeDropDownList.SelectedIndex; nLine.MarkerStyle.Height = new NLength((float)MarkerSizeDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage); nLine.MarkerStyle.Width = new NLength((float)MarkerSizeDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage); nLine.MarkerStyle.FillStyle = new NColorFillStyle(Red); nLine.MarkerStyle.BorderStyle.Color = WebExamplesUtilities.ColorFromDropDownList(LineColorDropDownList); } // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
public void PointSelected (NChart nChart, NChartPoint nChartPoint) { if (prevSelectedPoint != null) prevSelectedPoint.Tooltip.SetVisibleAnimated (false, 0.25f); if (nChartPoint != null) { if (nChartPoint.Tooltip != null) { if (nChartPoint == prevSelectedPoint) prevSelectedPoint = null; else { prevSelectedPoint = nChartPoint; UpdateTooltipText (nChartPoint); nChartPoint.Tooltip.SetVisibleAnimated (true, 0.25f); } } else { prevSelectedPoint = nChartPoint; nChartPoint.Tooltip = CreateTooltip (); UpdateTooltipText (nChartPoint); nChartPoint.Tooltip.SetVisibleAnimated (true, 0.25f); } } else prevSelectedPoint = null; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.None; 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, System.Drawing.FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.BoundsMode = BoundsMode.Fit; chart.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 10.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.Projection.Elevation = 45; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); // setup Y axis NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.RoundToTickMax = false; scaleY.RoundToTickMin = false; scaleY.MinTickDistance = new NLength(10, NGraphicsUnit.Point); scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Left, ChartWallType.Back }; scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // setup X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.RoundToTickMax = false; scaleX.RoundToTickMin = false; scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Back }; scaleX.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // setup Z axis NLinearScaleConfigurator scaleZ = new NLinearScaleConfigurator(); scaleZ.RoundToTickMax = false; scaleZ.RoundToTickMin = false; scaleZ.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Left }; scaleZ.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; chart.Axis(StandardAxis.Depth).ScaleConfigurator = scaleZ; // add the surface series NTriangulatedSurfaceSeries surface = (NTriangulatedSurfaceSeries)chart.Series.Add(SeriesType.TriangulatedSurface); surface.Name = "Surface"; surface.Legend.Mode = SeriesLegendMode.SeriesLogic; surface.SyncPaletteWithAxisScale = false; surface.ValueFormatter.FormatSpecifier = "0.00"; surface.FillStyle = new NColorFillStyle(Color.YellowGreen); FillData(); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); // form controls FillModeComboBox.Items.Add("None"); FillModeComboBox.Items.Add("Uniform"); FillModeComboBox.Items.Add("Zone"); FrameModeComboBox.Items.Add("None"); FrameModeComboBox.Items.Add("Mesh"); FrameModeComboBox.Items.Add("Contour"); FrameModeComboBox.Items.Add("Mesh-Contour"); FrameModeComboBox.Items.Add("Dots"); FrameColorModeComboBox.Items.Add("Uniform"); FrameColorModeComboBox.Items.Add("Zone"); PositionModeComboBox.Items.Add("Axis Begin"); PositionModeComboBox.Items.Add("Axis End"); PositionModeComboBox.Items.Add("Custom Value"); SmoothShadingCheckBox.IsChecked = true; SmoothPaletteCheckBox.IsChecked = false; FillModeComboBox.SelectedIndex = 2; FrameModeComboBox.SelectedIndex = 2; FrameColorModeComboBox.SelectedIndex = 0; PositionModeComboBox.SelectedIndex = 0; CustomValueScrollBar.Value = 0.1f; PositionModeComboBox.IsEnabled = false; CustomValueScrollBar.IsEnabled = false; DrawFlatCheckBox_Checked(null, null); SmoothShadingCheckBox_Checked(null, null); SmoothPaletteCheckBox_Checked(null, null); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = new NLabel("3D Vector Field"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // no legend nChartControl1.Legends.Clear(); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Projection.Type = ProjectionType.Perspective; chart.Projection.Rotation = -18; chart.Projection.Elevation = 13; chart.Depth = 55.0f; chart.Width = 55.0f; chart.Height = 55.0f; // setup X axis NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale.RoundToTickMin = false; linearScale.RoundToTickMax = false; linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { }; // setup Y axis linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; linearScale.RoundToTickMin = false; linearScale.RoundToTickMax = false; linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { }; // setup Z axis linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale; linearScale.RoundToTickMin = false; linearScale.RoundToTickMax = false; linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { }; // setup shape series NVectorSeries vectorSeries = (NVectorSeries)chart.Series.Add(SeriesType.Vector); vectorSeries.FillStyle = new NColorFillStyle(Color.Red); vectorSeries.BorderStyle.Color = Color.DarkRed; vectorSeries.Legend.Mode = SeriesLegendMode.None; vectorSeries.DataLabelStyle.Visible = false; vectorSeries.InflateMargins = true; vectorSeries.UseXValues = true; vectorSeries.UseZValues = true; vectorSeries.MinArrowHeadSize = new NSizeL(2, 3); vectorSeries.MaxArrowHeadSize = new NSizeL(4, 6); // fill data FillData(vectorSeries); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // fill the combo WebExamplesUtilities.FillComboWithValues(XValueDropDownList, 10, 90, 10); WebExamplesUtilities.FillComboWithValues(YValueDropDownList, 10, 90, 10); } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Intersect Line With X/Y Value"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; NChart chart = nChartControl1.Charts[0]; // 2D line chart chart.BoundsMode = BoundsMode.Stretch; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = GetScaleConfigurator(); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = GetScaleConfigurator(); chart.Axis(StandardAxis.Depth).Visible = false; NAxisCollection axes = chart.Axes; // add point series NPointSeries point = (NPointSeries)chart.Series.Add(SeriesType.Point); point.UseXValues = true; point.FillStyle = new NColorFillStyle(Color.Red); point.DataLabelStyle.Visible = false; point.Size = new NLength(2); NLineSeries line = new NLineSeries(); chart.Series.Add(line); line.Name = "Point 1"; line.FillStyle = new NColorFillStyle(Color.Red); line.BorderStyle.Color = Color.Pink; line.DataLabelStyle.Visible = false; line.UseXValues = true; line.InflateMargins = true; // fill with data Random rand = new Random(); double radius = 0; double angle = 0; int dataPointCount = 1000; double rStep = 50.0 / dataPointCount; double aStep = 10.0; for (int i = 0; i < dataPointCount; i++) { double y = Math.Sin(angle * 0.0174533f) * radius; double x = Math.Cos(angle * 0.0174533f) * radius; line.XValues.Add(50.0 + x); line.Values.Add(50.0 + y); radius += rStep; angle += aStep; } point.XValues.Clear(); point.Values.Clear(); NAxisConstLine horizontalAxisCursor = new NAxisConstLine(); NAxisConstLine verticalAxisCursor = new NAxisConstLine(); chart.Axis(StandardAxis.PrimaryX).ConstLines.Add(horizontalAxisCursor); chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(verticalAxisCursor); double xValue = (XValueDropDownList.SelectedIndex + 1) * 10; double yValue = (YValueDropDownList.SelectedIndex + 1) * 10; horizontalAxisCursor.Value = xValue; List <double> intersections = line.IntersectWithXValue(xValue); for (int i = 0; i < intersections.Count; i++) { point.XValues.Add(xValue); point.Values.Add(intersections[i]); } verticalAxisCursor.Value = yValue; intersections = line.IntersectWithYValue(yValue); for (int i = 0; i < intersections.Count; i++) { point.XValues.Add(intersections[i]); point.Values.Add(yValue); } // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
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); }
public override void Initialize() { base.Initialize(); nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.None; // add a trackball tool so that the user can rotate the chart nChartControl1.Controller.Tools.Clear(); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Surface"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); title.Cache = true; // no legend nChartControl1.Legends.Clear(); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 55.0f; chart.Depth = 55.0f; chart.Height = 4.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.AutoLabels = false; scaleY.MajorTickMode = MajorTickMode.AutoMaxCount; scaleY.MaxTickCount = 5; 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; // add the surface series NGridSurfaceSeries surface = (NGridSurfaceSeries)chart.Series.Add(SeriesType.GridSurface); surface.Name = "Surface"; surface.FrameMode = SurfaceFrameMode.None; surface.ShadingMode = ShadingMode.Smooth; surface.AutomaticPalette = true; surface.SyncPaletteWithAxisScale = false; // NOTE: Cell triangulation mode is important for performance. Use Diagonal1 or Diagonal2 for faster rendering. surface.CellTriangulationMode = SurfaceCellTriangulationMode.Diagonal1; NColorFillStyle fill = new NColorFillStyle(); fill.MaterialStyle.Ambient = Color.FromArgb(122, 125, 110); fill.MaterialStyle.Diffuse = Color.FromArgb(122, 125, 110); fill.MaterialStyle.Specular = Color.DimGray; surface.FillStyle = fill; // apply layout ConfigureStandardLayout(chart, title, null); // init form controls useHardwareAccelerationCheck.Checked = true; surfaceSizeCombo.SelectedIndex = 0; fillModeCombo.SelectedIndex = 1; }
protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { WebExamplesUtilities.FillComboWithEnumValues(YLabelGenerationModeDropDownList, typeof(LabelGenerationMode)); WebExamplesUtilities.FillComboWithEnumValues(XLabelGenerationModeDropDownList, typeof(LabelGenerationMode)); WebExamplesUtilities.FillComboWithValues(XTicksPerLabelDropDownList, 1, 10, 1); WebExamplesUtilities.FillComboWithValues(YTicksPerLabelDropDownList, 1, 10, 1); } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Axis Labels"); 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)); // 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(4, NRelativeUnit.ParentPercentage), new NLength(13, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL( new NLength(90, NRelativeUnit.ParentPercentage), new NLength(82, NRelativeUnit.ParentPercentage)); NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleConfiguratorY.MajorTickMode = MajorTickMode.AutoMaxCount; scaleConfiguratorY.MaxTickCount = 50; // 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; scaleConfiguratorY.StripStyles.Add(stripStyle); NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleConfiguratorX.AutoLabels = false; scaleConfiguratorX.Labels.Add("France"); scaleConfiguratorX.Labels.Add("Italy"); scaleConfiguratorX.Labels.Add("Germany"); scaleConfiguratorX.Labels.Add("Norway"); scaleConfiguratorX.Labels.Add("Spain"); scaleConfiguratorX.Labels.Add("Belgium"); scaleConfiguratorX.Labels.Add("Greece"); scaleConfiguratorX.Labels.Add("Austria"); scaleConfiguratorX.Labels.Add("Sweden"); scaleConfiguratorX.Labels.Add("Finland"); scaleConfiguratorX.Labels.Add("Poland"); scaleConfiguratorX.Labels.Add("Denmark"); NBarSeries series1 = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); series1.Name = "Product A"; series1.DataLabelStyle.Visible = false; GenerateData(series1.Values, 12); NBarSeries series2 = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); series2.MultiBarMode = MultiBarMode.Clustered; series2.Name = "Product B"; series2.DataLabelStyle.Visible = false; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); GenerateData(series2.Values, 12); UpdateScale(); }
protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Clustered Float Bar"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // configure the chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Axis(StandardAxis.Depth).Visible = false; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); // setup X axis NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; // add interlace stripe NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; scaleY.StripStyles.Add(stripStyle); // setup the bar series NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Name = "Bar"; bar.DataLabelStyle.Visible = false; bar.Values.FillRandomRange(Random, 8, 7, 15); // setup the floatbar series NFloatBarSeries floatbar = (NFloatBarSeries)chart.Series.Add(SeriesType.FloatBar); floatbar.MultiFloatBarMode = MultiFloatBarMode.Clustered; floatbar.Name = "Floatbar"; floatbar.DataLabelStyle.Visible = false; floatbar.AddDataPoint(new NFloatBarDataPoint(3.1, 5.2)); floatbar.AddDataPoint(new NFloatBarDataPoint(4.0, 6.1)); floatbar.AddDataPoint(new NFloatBarDataPoint(2.0, 6.4)); floatbar.AddDataPoint(new NFloatBarDataPoint(5.3, 7.3)); floatbar.AddDataPoint(new NFloatBarDataPoint(3.8, 8.4)); floatbar.AddDataPoint(new NFloatBarDataPoint(4.0, 7.7)); floatbar.AddDataPoint(new NFloatBarDataPoint(2.9, 4.1)); floatbar.AddDataPoint(new NFloatBarDataPoint(5.0, 7.2)); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]); }
private void BuildNewNChart(byte[] m_map_content) { try { DataTable dt = (DataTable)gridControl1.DataSource; nChartControl1 = new NChartControl(); nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.HighSpeed; nChartControl1.Controller.Tools.Add(new NSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); nChartControl1.MouseWheel += new MouseEventHandler(nChartControl1_MouseWheel); nChartControl1.MouseDown += new MouseEventHandler(nChartControl1_MouseDown); nChartControl1.MouseUp += new MouseEventHandler(nChartControl1_MouseUp); nChartControl1.Dock = DockStyle.Fill; xtraTabPage2.Controls.Add(nChartControl1); //nChartControl1.Charts.Clear(); NChart chart = nChartControl1.Charts[0]; nChartControl1.Legends.Clear(); chart.Enable3D = true; chart.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 35.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleConfiguratorX.MaxTickCount = dt.Rows.Count; scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount; //scaleConfiguratorX.AutoLabels = true; NScaleTitleStyle titleStyleX = (NScaleTitleStyle)scaleConfiguratorX.Title; titleStyleX.Text = Y_axis_name; //<GS-08032010> as waarden nog omzetten indien noodzakelijk (MAP etc) scaleConfiguratorX.AutoLabels = false; scaleConfiguratorX.Labels.Clear(); for (int t = y_axisvalues.Length - 1; t >= 0; t--) { string yvalue = y_axisvalues.GetValue(t).ToString(); //if (Y_axis_name == "MAP" || Y_axis_name == "Pressure error (bar)") { try { float v = (float)Convert.ToDouble(yvalue); yvalue = v.ToString("F2"); } catch (Exception cE) { logger.Debug(cE.Message); } } scaleConfiguratorX.Labels.Add(yvalue); } NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator; scaleConfiguratorY.MajorTickMode = MajorTickMode.AutoMaxCount; scaleConfiguratorY.MaxTickCount = dt.Columns.Count; //scaleConfiguratorY.AutoLabels = true; NScaleTitleStyle titleStyleY = (NScaleTitleStyle)scaleConfiguratorY.Title; titleStyleY.Text = X_axis_name; scaleConfiguratorY.AutoLabels = false; scaleConfiguratorY.Labels.Clear(); for (int t = 0; t < x_axisvalues.Length; t++) { string xvalue = x_axisvalues.GetValue(t).ToString(); //if (X_axis_name == "MAP" || X_axis_name == "Pressure error (bar)") { try { float v = (float)Convert.ToDouble(xvalue); xvalue = v.ToString("F2"); } catch (Exception cE) { logger.Debug(cE.Message); } } scaleConfiguratorY.Labels.Add(xvalue); } NStandardScaleConfigurator scaleConfiguratorZ = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleConfiguratorZ.MajorTickMode = MajorTickMode.AutoMaxCount; NScaleTitleStyle titleStyleZ = (NScaleTitleStyle)scaleConfiguratorZ.Title; titleStyleZ.Text = Z_axis_name; scaleConfiguratorZ.AutoLabels = true; chart.Wall(ChartWallType.Back).Visible = false; chart.Wall(ChartWallType.Left).Visible = false; chart.Wall(ChartWallType.Right).Visible = false; chart.Wall(ChartWallType.Floor).Visible = false; NMeshSurfaceSeries surface = null; chart.Series.Clear(); if (chart.Series.Count == 0) { surface = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface); } else { surface = (NMeshSurfaceSeries)chart.Series[0]; } surface.Name = "Surface"; surface.PositionValue = 10.0; surface.Palette.Clear(); surface.Data.SetGridSize(dt.Columns.Count, dt.Rows.Count); surface.ValueFormatter.FormatSpecifier = "0.00"; surface.FillMode = SurfaceFillMode.Zone; // <GS-08032010> surface.SmoothPalette = true; surface.FrameColorMode = SurfaceFrameColorMode.Uniform; surface.FillStyle.SetTransparencyPercent(25); surface.FrameMode = SurfaceFrameMode.MeshContour; double diff = m_realMaxValue - m_realMinValue; surface.Palette.Add(m_realMinValue, Color.Green); surface.Palette.Add(m_realMinValue + 0.25 * diff, Color.Yellow); surface.Palette.Add(m_realMinValue + 0.50 * diff, Color.Orange); surface.Palette.Add(m_realMinValue + 0.75 * diff, Color.OrangeRed); surface.Palette.Add(m_realMinValue + diff, Color.Red); surface.PaletteSteps = 4; surface.AutomaticPalette = false; FillData(surface, dt); // hier nChartControl1.Refresh(); } catch (Exception E) { logger.Debug("Failed to refresh mesh chart: " + E.Message); } }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Date Time Scale"); 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)); NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // add a strip line style NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); 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); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; // create line serie and dispay them on vertical axis NLineSeries line = new NLineSeries(); chart.Series.Add(line); line.UseXValues = true; line.Name = "Line"; line.DataLabelStyle.Visible = false; line.InflateMargins = true; NTimeSpanScaleConfigurator timeSpanScale = new NTimeSpanScaleConfigurator(); timeSpanScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.View, 90); timeSpanScale.LabelStyle.ContentAlignment = ContentAlignment.MiddleLeft; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = timeSpanScale; chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(85, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); if (!IsPostBack) { SampleTimeRangeDropDownList.Items.Add("Milliseconds"); SampleTimeRangeDropDownList.Items.Add("Seconds"); SampleTimeRangeDropDownList.Items.Add("Minutes"); SampleTimeRangeDropDownList.Items.Add("Hours"); SampleTimeRangeDropDownList.Items.Add("Days"); SampleTimeRangeDropDownList.Items.Add("Weeks"); SampleTimeRangeDropDownList.SelectedIndex = 2; // minutes EnableUnitSensitiveFormattingCheckBox.Checked = true; } UpdateTimeSpanScale(timeSpanScale); FillDummyData(line); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = new NLabel("XY Bars"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Enable3D = true; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalHalf); m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); m_Chart.Axis(StandardAxis.Depth).Visible = false; // switch the categories axis in numeric mode m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator(); // add interlaced stripe 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.PrimaryY).ScaleConfigurator = linearScale; // create the shape series m_Shape = (NShapeSeries)m_Chart.Series.Add(SeriesType.Shape); // show information about the data points in the legend m_Shape.Legend.Mode = SeriesLegendMode.DataPoints; // show the Y size and label in the legend m_Shape.Legend.Format = "<ysize> <label>"; // show the Y size and label in the data point labels m_Shape.DataLabelStyle.Format = "<ysize> <label>"; // use custom X positions m_Shape.UseXValues = true; // X sizes are specified in Model units (the default is Scale) // this will make the bars size independant from the scale of the X axis m_Shape.XSizesUnits = MeasurementUnits.Model; // this will require to set the InflateMargins flag to true since in this mode // scale is determined only by the X positions of the shape and will not take // into account the size of the bars. m_Shape.InflateMargins = true; // position all shapes at the series Z order m_Shape.UseZValues = false; // add the bars // add Bar1 m_Shape.AddDataPoint(new NShapeDataPoint( 10, // Y center of bar -> half its Y size 12, // X position 0, // Z position - not used since UseZValue is set to false 10, // X size - 10 model units 20, // Y size of bar 0.66, // Z size - 2 thirds of series depth "Bar1", // label new NColorFillStyle(Color.LightGreen) )); // add Bar2 m_Shape.AddDataPoint(new NShapeDataPoint( 20, // Y center of bar -> half its Y size 34, // X position - not used since UseXValue is set to false 0, // Z position - not used since UseZValue is set to false 10, // X size - 10 model units 40, // Y size of bar 0.33, // Z size - 1 third of series depth "Bar2", // label new NColorFillStyle(Color.LightCoral) )); // add Bar3 m_Shape.AddDataPoint(new NShapeDataPoint( 15, // Y center of bar -> half its Y size 50, // X position - not used since UseXValue is set to false 0, // Z position - not used since UseZValue is set to false 10, // X size - 10 model units 30, // Y size of bar 0.5, // Z size - half series depth "Bar3", // label new NColorFillStyle(Color.LightSalmon) )); // apply layout ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); // init form controls InflateMarginsCheckBox.Checked = true; AxesRoundToTickCheck.Checked = true; StyleCombo.SelectedIndex = 0; }
public override void Initialize() { base.Initialize(); NChart chart = nChartControl1.Charts[0]; nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("XYZ Stack Bar"); 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)); // set predefined projection and lighting chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.BrightCameraLight); chart.Width = 50; chart.Height = 35; chart.Depth = 50; chart.Enable3D = true; // configure the axes NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); // add interlace stripes to the Y axis 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); linearScale = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); AddBarSeries(chart, MultiBarMode.Series); AddBarSeries(chart, MultiBarMode.Stacked); AddBarSeries(chart, MultiBarMode.Stacked); AddBarSeries(chart, MultiBarMode.Stacked); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); GenerateData(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Axis Value Crossing <br/> <font size = '9pt'>Demonstrates how to use of the value cross anchor</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; m_Chart = nChartControl1.Charts[0]; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights); // configure scales NLinearScaleConfigurator yScaleConfigurator = (NLinearScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; NScaleStripStyle yStripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(40, Color.LightGray)), null, true, 0, 0, 1, 1); yStripStyle.SetShowAtWall(ChartWallType.Back, true); yStripStyle.Interlaced = true; yScaleConfigurator.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); yScaleConfigurator.StripStyles.Add(yStripStyle); NLinearScaleConfigurator xScaleConfigurator = new NLinearScaleConfigurator(); NScaleStripStyle xStripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(40, Color.LightGray)), null, true, 0, 0, 1, 1); xStripStyle.SetShowAtWall(ChartWallType.Back, true); xStripStyle.Interlaced = true; xScaleConfigurator.StripStyles.Add(xStripStyle); xScaleConfigurator.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScaleConfigurator; // cross X and Y axes m_Chart.Axis(StandardAxis.PrimaryX).Anchor = new NCrossAxisAnchor(AxisOrientation.Horizontal, new NValueAxisCrossing(m_Chart.Axis(StandardAxis.PrimaryY), 0)); m_Chart.Axis(StandardAxis.PrimaryX).Anchor.RulerOrientation = RulerOrientation.Right; m_Chart.Axis(StandardAxis.PrimaryY).Anchor = new NCrossAxisAnchor(AxisOrientation.Vertical, new NValueAxisCrossing(m_Chart.Axis(StandardAxis.PrimaryX), 0)); m_Chart.Axis(StandardAxis.Depth).Visible = false; m_Chart.Wall(ChartWallType.Floor).Visible = false; m_Chart.Wall(ChartWallType.Left).Visible = false; // setup bubble series NBubbleSeries bubble = (NBubbleSeries)m_Chart.Series.Add(SeriesType.Bubble); bubble.Name = "Bubble Series"; bubble.InflateMargins = true; bubble.DataLabelStyle.Visible = false; bubble.UseXValues = true; bubble.BubbleShape = PointShape.Sphere; // fill with random data bubble.Values.FillRandomRange(Random, 10, -20, 20); bubble.XValues.FillRandomRange(Random, 10, -20, 20); bubble.Sizes.FillRandomRange(Random, 10, 1, 6); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); // init form controls LeftAxisScroll.Minimum = -30; LeftAxisScroll.Maximum = 30; LeftAxisScroll.Value = 0; BottomAxisScroll.Minimum = -30; BottomAxisScroll.Maximum = 30; BottomAxisScroll.Value = 0; LeftAxisLabel.Text = LeftAxisScroll.Value.ToString(); BottomAxisLabel.Text = BottomAxisScroll.Value.ToString(); LeftUsePositionCheck.Checked = true; BottomUsePositionCheck.Checked = true; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Moving Averages"); 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 NRangeTimelineScaleConfigurator scaleX = new NRangeTimelineScaleConfigurator(); 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.SecondRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.SecondRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(215, 215, 215)); scaleX.SecondRow.UseGridStyle = true; scaleX.ThirdRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.ThirdRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(205, 205, 205)); scaleX.ThirdRow.UseGridStyle = true; // calendar NWeekDayRule wdr = new NWeekDayRule(WeekDayBit.All); wdr.Saturday = false; wdr.Sunday = false; scaleX.Calendar.Rules.Add(wdr); scaleX.EnableCalendar = true; // set configurator m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // setup Y axis NAxis axis = m_Chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)axis.ScaleConfigurator; linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; linearScale.InnerMajorTickStyle.Length = new NLength(0); // line series for the function m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line.DataLabelStyle.Visible = false; m_Line.BorderStyle.Color = Color.Crimson; m_Line.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel); m_Line.UseXValues = true; Color customColor = Color.FromArgb(100, 100, 150); // setup the stock series m_Stock = (NStockSeries)m_Chart.Series.Add(SeriesType.Stock); m_Stock.DataLabelStyle.Visible = false; m_Stock.CandleStyle = CandleStyle.Bar; m_Stock.HighLowStrokeStyle.Color = customColor; m_Stock.UpStrokeStyle.Color = customColor; m_Stock.DownStrokeStyle.Color = customColor; m_Stock.UpFillStyle = new NColorFillStyle(Color.White); m_Stock.DownFillStyle = new NColorFillStyle(customColor); m_Stock.Legend.Mode = SeriesLegendMode.None; m_Stock.OpenValues.Name = "open"; m_Stock.HighValues.Name = "high"; m_Stock.LowValues.Name = "low"; m_Stock.CloseValues.Name = "close"; m_Stock.CandleWidth = new NLength(1, NRelativeUnit.ParentPercentage); m_Stock.InflateMargins = true; m_Stock.UseXValues = true; GenerateData(); // form controls m_bSkipUpdate = true; m_ApplyToCombo.SelectedIndex = 3; m_bSkipUpdate = false; m_FunctionCombo.Items.Add("Simple Moving Average"); m_FunctionCombo.Items.Add("Weighted Moving Average"); m_FunctionCombo.Items.Add("Exponential Moving Average"); m_FunctionCombo.Items.Add("Modified Moving Average"); m_FunctionCombo.SelectedIndex = 0; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Linear Scale"); 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(10, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); m_Chart.Axis(StandardAxis.Depth).Visible = false; // configure the y axis NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); // add a strip line style 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); m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_Line.Legend.Mode = SeriesLegendMode.None; m_Line.InflateMargins = false; m_Line.MarkerStyle.Visible = true; m_Line.MarkerStyle.PointShape = PointShape.Ellipse; m_Line.MarkerStyle.Width = new NLength(5, NGraphicsUnit.Point); m_Line.MarkerStyle.Height = new NLength(5, NGraphicsUnit.Point); m_Line.MarkerStyle.AutoDepth = true; m_Line.DataLabelStyle.Format = "<value>"; m_Line.DataLabelStyle.ArrowStrokeStyle.Color = Color.CornflowerBlue; m_Line.Values.FillRandomRange(Random, 10, 0, 100); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // update controls AutoMinDistanceRadioButton.Checked = true; MaxCountUpDown.Value = (decimal)linearScale.MaxTickCount; MinDistanceUpDown.Value = (decimal)linearScale.MinTickDistance.Value; CustomStepUpDown.Value = (decimal)linearScale.CustomStep; m_Updating = false; UpdateScale(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Real Time Area"); 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(); // configure the chart NChart chart = nChartControl1.Charts[0]; chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); chart.BoundsMode = BoundsMode.Stretch; // configure the y axis NAxis yAxis = chart.Axis(StandardAxis.PrimaryY); yAxis.View = new NRangeAxisView(new NRange1DD(0, 100)); 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; // add the first line NAreaSeries area = new NAreaSeries(); chart.Series.Add(area); area.SamplingMode = SeriesSamplingMode.Enabled; area.UseXValues = true; area.DataLabelStyle.Visible = false; area.Values.ValueFormatter = new NNumericValueFormatter("0.0"); area.Values.EmptyDataPoints.ValueMode = EmptyDataPointsValueMode.Skip; // apply layout ConfigureStandardLayout(chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // turn off area border to improve performance after you apply the style sheet area.BorderStyle.Width = new NLength(0); NumberOfDataPointsComboBox.Items.Add("1000"); NumberOfDataPointsComboBox.Items.Add("5000"); NumberOfDataPointsComboBox.Items.Add("10000"); NumberOfDataPointsComboBox.SelectedIndex = 0; NewDataPointsPerTickComboBox.Items.Add("10"); NewDataPointsPerTickComboBox.Items.Add("50"); NewDataPointsPerTickComboBox.Items.Add("100"); NewDataPointsPerTickComboBox.SelectedIndex = 1; UseHardwareAccelerationCheckBox.Checked = true; StartTimer(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Stacked Area Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // setup the chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 65; chart.Height = 40; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective2); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); // setup X axis NOrdinalScaleConfigurator scaleX = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; scaleX.AutoLabels = false; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleX.DisplayDataPointsBetweenTicks = false; for (int i = 0; i < categoriesCount; i++) { scaleX.CustomLabels.Add(new NCustomValueLabel(i, (2000 + i).ToString())); } // add interlaced stripe for Y axis NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; NLinearScaleConfigurator scaleY = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; scaleY.StripStyles.Add(stripStyle); // hide Z axis chart.Axis(StandardAxis.Depth).Visible = false; // add the first area NAreaSeries area0 = (NAreaSeries)chart.Series.Add(SeriesType.Area); area0.MultiAreaMode = MultiAreaMode.Series; area0.Name = "Product A"; SetupDataLabels(area0); // add the second Area NAreaSeries area1 = (NAreaSeries)chart.Series.Add(SeriesType.Area); area1.MultiAreaMode = MultiAreaMode.Stacked; area1.Name = "Product B"; SetupDataLabels(area1); // add the third Area NAreaSeries area2 = (NAreaSeries)chart.Series.Add(SeriesType.Area); area2.MultiAreaMode = MultiAreaMode.Stacked; area2.Name = "Product C"; SetupDataLabels(area2); // fill with random data area0.Values.FillRandomRange(Random, categoriesCount, 20, 50); area1.Values.FillRandomRange(Random, categoriesCount, 20, 50); area2.Values.FillRandomRange(Random, categoriesCount, 20, 50); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // init form controls InitLabelsCombo(FirstAreaDataLabelsCombo); InitLabelsCombo(SecondAreaDataLabelsCombo); InitLabelsCombo(ThirdAreaDataLabelsCombo); StackModeCombo.Items.Add("Stack"); StackModeCombo.Items.Add("Stack 100%"); StackModeCombo.SelectedIndex = 0; ShowDataLabelsCheck_CheckedChanged(null, null); }
protected override void OnTimerTick(object sender, EventArgs e) { base.OnTimerTick(sender, e); int nMaxCount = GetNumberOfDataPoints(); if (nMaxCount == 0) { return; } int newDataPoints = GetNewDataPointsPerTick(); double dValueX = 0; NChart chart = nChartControl1.Charts[0]; NAreaSeries area = (NAreaSeries)chart.Series[0]; NAxis axisX = chart.Axis(StandardAxis.PrimaryX); double minValue = 0; double maxValue = 100; // add 100 new random points for (int i = 0; i < newDataPoints; i++) { if (m_nDirectionChangeCounter == 0) { m_nDirectionChangeCounter = 100; m_Direction = (m_Direction + Random.NextDouble() - 0.5) / 4.0; } m_nDirectionChangeCounter--; if (m_Value + m_Direction > maxValue) { m_Value = maxValue; m_Direction = 0; m_nDirectionChangeCounter = 0; } else if (m_Value + m_Direction < minValue) { m_Value = minValue; m_Direction = 0; m_nDirectionChangeCounter = 0; } else { m_Value += m_Direction; } double dValueY = m_Value; int nIndex = m_nCounter % nMaxCount; dValueX = m_nCounter; if (nIndex >= area.Values.Count) { area.Values.Add(dValueY); area.XValues.Add(dValueX); } else { area.Values[area.DataPointOriginIndex] = dValueY; area.XValues[area.DataPointOriginIndex] = dValueX; area.DataPointOriginIndex++; if (area.DataPointOriginIndex >= area.Values.Count) { area.DataPointOriginIndex = 0; } } m_nCounter++; } nChartControl1.Refresh(); }
/// <summary> /// Configures the axis /// </summary> /// <param name="chart">Nevron chart</param> /// <param name="stats">Chart stats, and configuration details.</param> void SetupChartAxes(NChart chart, IAttributeChartStats stats) { NAxis axisY1 = chart.Axis(StandardAxis.PrimaryY); NAxis axisY2 = chart.Axis(StandardAxis.SecondaryY); NAxis axisX = chart.Axis(StandardAxis.PrimaryX); NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.MajorGridStyle.LineStyle.Pattern = LinePattern.Dash; scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.InnerMajorTickStyle.Visible = false; scaleX.Title.Text = stats.TimeLabel; scaleX.Title.TextStyle.FontStyle = new NFontStyle("Arial", 9, FontStyle.Bold); scaleX.ViewRangeInflateMode = ScaleViewRangeInflateMode.Logical; scaleX.LogicalInflate = new NRange1DD(0.5, 0.5); axisX.ScaleConfigurator = scaleX; NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dash; scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY.InnerMajorTickStyle.Visible = false; scaleY.Title.Text = stats.DefectLabel; scaleY.Title.TextStyle.FontStyle = new NFontStyle("Arial", 9, FontStyle.Bold); axisY1.ScaleConfigurator = scaleY; NLinearScaleConfigurator scaleY2 = new NLinearScaleConfigurator(); scaleY2.OuterMajorTickStyle.Visible = false; scaleY2.InnerMajorTickStyle.Visible = false; scaleY2.RulerStyle.BorderStyle.Width = new NLength(0); scaleY2.AutoLabels = false; axisY2.ScaleConfigurator = scaleY2; axisY2.Visible = true; // the scale of the secodary Y axis must be the same as the primary Y axis scale axisY1.Slaves.Add(axisY2); }
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); }
private void Init2dGraph() { nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.HighQuality; nChartControl1.Legends.Clear(); // no legend NChart chart2d = nChartControl1.Charts[0]; NSmoothLineSeries surface = null; if (chart2d.Series.Count == 0) { surface = (NSmoothLineSeries)chart2d.Series.Add(SeriesType.SmoothLine); } else { surface = (NSmoothLineSeries)chart2d.Series[0]; } chart2d.BoundsMode = BoundsMode.Stretch; NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart2d.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); 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); NSmoothLineSeries line = null; if (chart2d.Series.Count == 0) { line = (NSmoothLineSeries)chart2d.Series.Add(SeriesType.SmoothLine); } else { line = (NSmoothLineSeries)chart2d.Series[0]; } line.Name = "Power (bhp)"; line.Legend.Mode = SeriesLegendMode.Series; line.UseXValues = true; line.UseZValues = false; line.DataLabelStyle.Visible = true; line.Values.ValueFormatter = new Nevron.Dom.NNumericValueFormatter("0"); line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Sphere; line.MarkerStyle.AutoDepth = true; line.MarkerStyle.Width = new NLength(1.4f, NRelativeUnit.ParentPercentage); line.MarkerStyle.Height = new NLength(1.4f, NRelativeUnit.ParentPercentage); line.MarkerStyle.Depth = new NLength(1.4f, NRelativeUnit.ParentPercentage); //line.HorizontalAxes = y_axisvalues; NSmoothLineSeries line2 = null; if (chart2d.Series.Count == 1) { line2 = (NSmoothLineSeries)chart2d.Series.Add(SeriesType.SmoothLine); } else { line2 = (NSmoothLineSeries)chart2d.Series[1]; } line2.Name = "Torque (Nm)"; line2.Legend.Mode = SeriesLegendMode.Series; line2.UseXValues = true; line2.UseZValues = false; line2.Values.ValueFormatter = new Nevron.Dom.NNumericValueFormatter("0"); line2.MarkerStyle.Visible = true; line2.MarkerStyle.PointShape = PointShape.Sphere; line2.MarkerStyle.AutoDepth = true; line2.MarkerStyle.Width = new NLength(1.4f, NRelativeUnit.ParentPercentage); line2.MarkerStyle.Height = new NLength(1.4f, NRelativeUnit.ParentPercentage); line2.MarkerStyle.Depth = new NLength(1.4f, NRelativeUnit.ParentPercentage); NSmoothLineSeries line3 = null; if (chart2d.Series.Count == 2) { line3 = (NSmoothLineSeries)chart2d.Series.Add(SeriesType.SmoothLine); } else { line3 = (NSmoothLineSeries)chart2d.Series[2]; } line3.Name = "Injector DC"; line3.Legend.Mode = SeriesLegendMode.Series; line3.UseXValues = true; line3.UseZValues = false; line3.DataLabelStyle.Visible = true; line3.Values.ValueFormatter = new Nevron.Dom.NNumericValueFormatter("0.0"); line3.MarkerStyle.Visible = true; line3.MarkerStyle.PointShape = PointShape.Sphere; line3.MarkerStyle.AutoDepth = true; line3.MarkerStyle.Width = new NLength(1.4f, NRelativeUnit.ParentPercentage); line3.MarkerStyle.Height = new NLength(1.4f, NRelativeUnit.ParentPercentage); line3.MarkerStyle.Depth = new NLength(1.4f, NRelativeUnit.ParentPercentage); surface.Name = "Surface"; //surface.Legend.Mode = SeriesLegendMode.SeriesLogic; //surface.PositionValue = 10.0; for (int i = 0; i < x_axisvalues.Length; i++) { surface.XValues.Add(x_axisvalues.GetValue(i)); } NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Nevron); styleSheet.Apply(nChartControl1.Document); }
public void PointOfChartSelected (NChart chart, NChartPoint point) { // Disable highlight. if (m_prevSelectedPoint != null) m_prevSelectedPoint.HighlightWithMask ((uint)NChartHighlightType.None, 0.25f, 0.0f); if (point != null) { if (point == m_prevSelectedPoint) { m_prevSelectedPoint = null; // Return to normal zoom. if (m_zoomed) { m_zoomed = false; m_view.Chart.ZoomTo (1.0f, 0.25f, 0.0f); } } else { m_prevSelectedPoint = point; if (!m_zoomed) { m_zoomed = true; m_view.Chart.ZoomTo (0.85f, 0.25f, 0.0f); } // Set shift to highlight. point.HighlightShift = 0.2f; // Set color to highlight. point.HighlightColor = UIColor.Red; // Highlight point by shift and color. point.HighlightWithMask ((uint)NChartHighlightType.Shift | (uint)NChartHighlightType.Color, 0.25f, 0.0f); } } else { m_prevSelectedPoint = null; // Return to normal zoom. if (m_zoomed) { m_zoomed = false; m_view.Chart.ZoomTo (1.0f, 0.25f, 0.0f); } } }