private void SetupFemaleChart() { // female chart setup m_ChartFemale.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); m_ChartFemale.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalHorizontalLeft); // setup Y axis NAxis axisY = m_ChartFemale.Axis(StandardAxis.PrimaryY); axisY.ScaleConfigurator.InnerMajorTickStyle.Visible = false; axisY.Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, false, 0, 100); // add manual labels to the female chart NAxis axisX = m_ChartFemale.Axis(StandardAxis.PrimaryX); NOrdinalScaleConfigurator scaleX = axisX.ScaleConfigurator as NOrdinalScaleConfigurator; scaleX.Invert = true; scaleX.InnerMajorTickStyle.Visible = false; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleX.LabelFitModes = new LabelFitMode[] { LabelFitMode.AutoScale }; scaleX.AutoLabels = false; scaleX.Labels.AddRange(AgeLabels); // populate the female chart m_barF = (NBarSeries)m_ChartFemale.Series.Add(SeriesType.Bar); m_barF.FillStyle = new NGradientFillStyle(BeautifulRed, Color.White); m_barF.BorderStyle.Color = BeautifulRed; m_barF.DataLabelStyle.Format = "<value>"; m_barF.DataLabelStyle.VertAlign = VertAlign.Center; m_barF.DataLabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 7); m_barF.Values.Add(210); // 0 - 4 m_barF.Values.Add(215); // 5 - 9 m_barF.Values.Add(219); // 10 - 14 m_barF.Values.Add(225); // 15 - 19 m_barF.Values.Add(245); // 20 - 24 m_barF.Values.Add(289); // 25 - 29 m_barF.Values.Add(355); // 30 - 34 m_barF.Values.Add(355); // 35 - 39 m_barF.Values.Add(380); // 40 - 44 m_barF.Values.Add(320); // 45 - 49 m_barF.Values.Add(250); // 50 - 54 m_barF.Values.Add(190); // 55 - 59 m_barF.Values.Add(112); // 60 - 64 m_barF.Values.Add(110); // 65 - 69 m_barF.Values.Add(90); // 70 - 74 m_barF.Values.Add(55); // 75 - 79 m_barF.Values.Add(45); // 80 + }
private void SetupMaleChart() { // chart setup m_ChartMale.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalRight); m_ChartMale.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalHorizontalRight); // setup Y axis NAxis axisY = m_ChartMale.Axis(StandardAxis.PrimaryY); axisY.ScaleConfigurator.InnerMajorTickStyle.Visible = false; // add labels to the male chart X axis NAxis axisX = m_ChartMale.Axis(StandardAxis.PrimaryX); NOrdinalScaleConfigurator scaleX = axisX.ScaleConfigurator as NOrdinalScaleConfigurator; scaleX.InnerMajorTickStyle.Visible = false; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleX.LabelFitModes = new LabelFitMode[] { LabelFitMode.AutoScale }; scaleX.AutoLabels = false; scaleX.Labels.AddRange(AgeLabels); // populate the male chart m_barM = (NBarSeries)m_ChartMale.Series.Add(SeriesType.Bar); m_barM.FillStyle = new NGradientFillStyle(Blue, Color.White); m_barM.BorderStyle.Color = Blue; m_barM.DataLabelStyle.Format = "<value>"; m_barM.DataLabelStyle.VertAlign = VertAlign.Center; m_barM.DataLabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 7); m_barM.Values.Add(200); // 0 - 4 m_barM.Values.Add(210); // 5 - 9 m_barM.Values.Add(205); // 10 - 14 m_barM.Values.Add(225); // 15 - 19 m_barM.Values.Add(250); // 20 - 24 m_barM.Values.Add(290); // 25 - 29 m_barM.Values.Add(340); // 30 - 34 m_barM.Values.Add(340); // 35 - 39 m_barM.Values.Add(370); // 40 - 44 m_barM.Values.Add(310); // 45 - 49 m_barM.Values.Add(260); // 50 - 54 m_barM.Values.Add(180); // 55 - 59 m_barM.Values.Add(120); // 60 - 64 m_barM.Values.Add(115); // 65 - 69 m_barM.Values.Add(100); // 70 - 74 m_barM.Values.Add(50); // 75 - 79 m_barM.Values.Add(35); // 80 + }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Axis Min Max"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); NChart chart = nChartControl1.Charts[0]; // subscribe for the BeforePaint event of the chart chart.PaintCallback = new PaintCallback(this); NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScale.RoundToTickMin = false; linearScale.RoundToTickMax = false; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dash; // add interlace stripe to the Y axis 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); NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dash; NewPointSeries(chart); NewPointSeries(chart); GenerateData(6); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); }
private void SetupFemaleChart() { // female chart setup m_ChartFemale.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft); // setup Y axis NAxis axisY = m_ChartFemale.Axis(StandardAxis.PrimaryY); axisY.ScaleConfigurator.InnerMajorTickStyle.Visible = false; axisY.Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, false, 0, 100); // add manual labels to the female chart NOrdinalScaleConfigurator ordinalScale = m_ChartFemale.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.MajorTickMode = MajorTickMode.CustomStep; ordinalScale.CustomStep = 1; // populate the female chart m_barF = (NBarSeries)m_ChartFemale.Series.Add(SeriesType.Bar); m_barF.BorderStyle.Color = DarkOrange; m_barF.DataLabelStyle.Format = "<value>"; m_barF.DataLabelStyle.VertAlign = VertAlign.Center; m_barF.DataLabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 7); m_barF.Values.Add(210); // 0 - 4 m_barF.Values.Add(215); // 5 - 9 m_barF.Values.Add(219); // 10 - 14 m_barF.Values.Add(225); // 15 - 19 m_barF.Values.Add(245); // 20 - 24 m_barF.Values.Add(289); // 25 - 29 m_barF.Values.Add(355); // 30 - 34 m_barF.Values.Add(355); // 35 - 39 m_barF.Values.Add(380); // 40 - 44 m_barF.Values.Add(320); // 45 - 49 m_barF.Values.Add(250); // 50 - 54 m_barF.Values.Add(190); // 55 - 59 m_barF.Values.Add(112); // 60 - 64 m_barF.Values.Add(110); // 65 - 69 m_barF.Values.Add(90); // 70 - 74 m_barF.Values.Add(55); // 75 - 79 m_barF.Values.Add(45); // 80 + }
private void UpdateLabels() { // add custom labels to the Y axis NChart chart = nChartControl1.Charts[0]; NOrdinalScaleConfigurator scale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; for (int i = 0; i < scale.CustomLabels.Count; i++) { NCustomRangeLabel rangeLabel = (NCustomRangeLabel)scale.CustomLabels[i]; rangeLabel.Style.TickMode = (RangeLabelTickMode)LabelTickModeComboBox.SelectedIndex; rangeLabel.Style.VisibilityMode = (ScaleLabelVisibilityMode)LabelVisibilityModeComboBox.SelectedIndex; rangeLabel.Style.FitMode = FitModeFromIndex(LabelFitModeComboBox.SelectedIndex); rangeLabel.Style.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, (float)LabelAngleNumericUpDown.Value); rangeLabel.Style.TickPadding = new NLength((float)TickPaddingNumericUpDown.Value, NGraphicsUnit.Point); rangeLabel.Style.TickOffset = new NLength((float)TickOffsetNumericUpDown.Value, NGraphicsUnit.Point); rangeLabel.Style.Offset = new NLength((float)TextOffsetNumericUpDown.Value, NGraphicsUnit.Point); rangeLabel.Style.TextPadding = new NLength((float)TextPaddingNumericUpDown.Value, NGraphicsUnit.Point); } nChartControl1.Refresh(); }
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); }
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]); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } nChartControl1.Panels.Clear(); nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = new NLabel("Flash Interactivity"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.DockMode = PanelDockMode.Top; title.InteractivityStyle.UrlLink.Url = "http://www.apple.com"; nChartControl1.Panels.Add(title); NDockPanel contentPanel = new NDockPanel(); nChartControl1.Panels.Add(contentPanel); contentPanel.DockMode = PanelDockMode.Fill; // configure the chart NCartesianChart chart = new NCartesianChart(); contentPanel.ChildPanels.Add(chart); chart.Location = new NPointL(0, 0); chart.Size = new NSizeL(new NLength(100, NRelativeUnit.ParentPercentage), new NLength(60, NRelativeUnit.ParentPercentage)); chart.Enable3D = false; chart.Axis(StandardAxis.Depth).Visible = false; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.BrightCameraLight); chart.Margins = new NMarginsL(5, 5, 5, 5); chart.BoundsMode = BoundsMode.Stretch; chart.DockMode = PanelDockMode.Fill; // configure axes NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Labels.Add("2004"); ordinalScale.Labels.Add("2005"); ordinalScale.Labels.Add("2006"); ordinalScale.Labels.Add("2007"); ordinalScale.Labels.Add("2008"); ordinalScale.Labels.Add("2009"); // add interlace stripe NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; linearScale.Title.Text = "Sales in Thousands USD"; linearScale.MinTickDistance = new NLength(15); 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); // create series NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); NBarSeries bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); NBarSeries bar3 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar1.MultiBarMode = MultiBarMode.Clustered; bar2.MultiBarMode = MultiBarMode.Clustered; bar3.MultiBarMode = MultiBarMode.Clustered; // configure common settings bar1.Name = "Apple"; bar2.InteractivityStyle.UrlLink.Url = "http://www.apple.com"; bar1.DataLabelStyle.Visible = false; bar2.Name = "Nokia"; bar2.InteractivityStyle.UrlLink.Url = "http://www.nokia.com"; bar2.DataLabelStyle.Visible = false; bar3.Name = "HTC"; bar3.InteractivityStyle.UrlLink.Url = "http://www.htc.com"; bar3.DataLabelStyle.Visible = false; // fill with random data bar1.Values.FillRandomRange(Random, 6, 10, 100); bar2.Values.FillRandomRange(Random, 6, 10, 100); bar3.Values.FillRandomRange(Random, 6, 10, 100); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // apply animation theme NAnimationTheme animationTheme = new NAnimationTheme(); animationTheme.AnimateSeriesSequentially = true; animationTheme.AnimateDataPointsSequentially = false; animationTheme.AnimateChartsSequentially = false; animationTheme.WallsAnimationDuration = 1; animationTheme.AxesAnimationDuration = 1; animationTheme.SeriesAnimationDuration = 1; animationTheme.AnimationThemeType = AnimationThemeType.ScaleAndFade; // animationTheme.Apply(nChartControl1.Document); NImageResponse swfResponse = new NImageResponse(); swfResponse.ImageFormat = new NSwfImageFormat(); nChartControl1.ImageAcquisitionMode = ClientSideImageAcquisitionMode.TempFile; nChartControl1.ServerSettings.BrowserResponseSettings.DefaultResponse = swfResponse; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = new NLabel("Gantt"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); // no legend nChartControl1.Legends.Clear(); // configure the chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.Projection.ViewerRotation = 270; chart.Axis(StandardAxis.Depth).Visible = false; // setup the value axis NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator(); dateTimeScale.LabelValueFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.Date); dateTimeScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; // add interlaced stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; stripStyle.Interlaced = true; dateTimeScale.StripStyles.Add(stripStyle); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = dateTimeScale; chart.Axis(StandardAxis.PrimaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontRight, true, 0, 100); // label the X axis NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Labels.Add("Market Research"); ordinalScale.Labels.Add("Specifications"); ordinalScale.Labels.Add("Architecture"); ordinalScale.Labels.Add("Project Planning"); ordinalScale.Labels.Add("Detailed Design"); ordinalScale.Labels.Add("Development"); ordinalScale.Labels.Add("Test Plan"); ordinalScale.Labels.Add("Testing and QA"); ordinalScale.Labels.Add("Documentation"); // create a floatbar series NFloatBarSeries floatBar = (NFloatBarSeries)chart.Series.Add(SeriesType.FloatBar); floatBar.BeginValues.ValueFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.Date); floatBar.EndValues.ValueFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.Date); floatBar.DataLabelStyle.Visible = false; AddDataPoint(floatBar, new DateTime(2009, 2, 2), new DateTime(2009, 2, 16)); AddDataPoint(floatBar, new DateTime(2009, 2, 16), new DateTime(2009, 3, 2)); AddDataPoint(floatBar, new DateTime(2009, 3, 2), new DateTime(2009, 3, 16)); AddDataPoint(floatBar, new DateTime(2009, 3, 9), new DateTime(2009, 3, 23)); AddDataPoint(floatBar, new DateTime(2009, 3, 16), new DateTime(2009, 3, 30)); AddDataPoint(floatBar, new DateTime(2009, 3, 23), new DateTime(2009, 4, 27)); AddDataPoint(floatBar, new DateTime(2009, 4, 13), new DateTime(2009, 4, 27)); AddDataPoint(floatBar, new DateTime(2009, 4, 20), new DateTime(2009, 5, 4)); AddDataPoint(floatBar, new DateTime(2009, 4, 27), new DateTime(2009, 5, 4)); // apply layout ConfigureStandardLayout(chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("3D Floating Bars"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); // no legend nChartControl1.Legends.Clear(); // 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.SoftTopLeft); // 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 < monthLetters.Length; i++) { scaleX.CustomLabels.Add(new NCustomValueLabel(i, monthLetters[i])); } // add interlaced stripe to the Y axis NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; stripStyle.Interlaced = true; linearScale.StripStyles.Add(stripStyle); // create the float bar series NFloatBarSeries floatBar = (NFloatBarSeries)chart.Series.Add(SeriesType.FloatBar); floatBar.DataLabelStyle.Visible = false; floatBar.DataLabelStyle.VertAlign = VertAlign.Center; floatBar.DataLabelStyle.Format = "<begin> - <end>"; // add bars floatBar.AddDataPoint(new NFloatBarDataPoint(2, 10)); floatBar.AddDataPoint(new NFloatBarDataPoint(5, 16)); floatBar.AddDataPoint(new NFloatBarDataPoint(9, 17)); floatBar.AddDataPoint(new NFloatBarDataPoint(12, 21)); floatBar.AddDataPoint(new NFloatBarDataPoint(8, 18)); floatBar.AddDataPoint(new NFloatBarDataPoint(7, 18)); floatBar.AddDataPoint(new NFloatBarDataPoint(3, 11)); floatBar.AddDataPoint(new NFloatBarDataPoint(5, 12)); floatBar.AddDataPoint(new NFloatBarDataPoint(8, 17)); floatBar.AddDataPoint(new NFloatBarDataPoint(6, 15)); floatBar.AddDataPoint(new NFloatBarDataPoint(3, 10)); floatBar.AddDataPoint(new NFloatBarDataPoint(1, 7)); // apply layout ConfigureStandardLayout(chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // init form controls BarShapeCombo.FillFromEnum(typeof(BarShape)); BarShapeCombo.SelectedIndex = 0; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { EnableInitialPositioningCheckBox.Checked = true; EnableLabelAdjustmentCheckBox.Checked = true; InvertForDownwardDPCheckBox.Checked = true; InvertIfOutOfBoundsCheckBox.Checked = true; LocationProposalsDropDownList.Items.Clear(); LocationProposalsDropDownList.Items.Add("Top"); LocationProposalsDropDownList.Items.Add("Top - Bottom"); LocationProposalsDropDownList.Items.Add("Top - Bottom - Left - Right"); LocationProposalsDropDownList.SelectedIndex = 1; HiddenField1.Value = Random.Next().ToString(); } nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Step 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); // step line series NStepLineSeries series1 = (NStepLineSeries)chart.Series.Add(SeriesType.StepLine); series1.InflateMargins = true; series1.BorderStyle = new NStrokeStyle(new NLength(1.2f, NGraphicsUnit.Point), GreyBlue); series1.DataLabelStyle.Visible = true; series1.DataLabelStyle.VertAlign = VertAlign.Top; series1.DataLabelStyle.ArrowLength = new NLength(12); series1.DataLabelStyle.ArrowStrokeStyle.Color = DarkOrange; series1.DataLabelStyle.TextStyle.BackplaneStyle.StandardFrameStyle.InnerBorderColor = DarkOrange; series1.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8); // label layout settings chart.LabelLayout.EnableInitialPositioning = EnableInitialPositioningCheckBox.Checked; chart.LabelLayout.EnableLabelAdjustment = EnableLabelAdjustmentCheckBox.Checked; series1.LabelLayout.UseLabelLocations = true; series1.LabelLayout.OutOfBoundsLocationMode = OutOfBoundsLocationMode.PushWithinBounds; series1.LabelLayout.InvertLocationsForInvertedDataPoints = InvertForDownwardDPCheckBox.Checked; series1.LabelLayout.InvertLocationsIfIgnored = InvertIfOutOfBoundsCheckBox.Checked; switch (LocationProposalsDropDownList.SelectedIndex) { case 0: series1.LabelLayout.LabelLocations = new LabelLocation[] { LabelLocation.Top }; break; case 1: series1.LabelLayout.LabelLocations = new LabelLocation[] { LabelLocation.Top, LabelLocation.Bottom }; break; case 2: series1.LabelLayout.LabelLocations = new LabelLocation[] { LabelLocation.Top, LabelLocation.Bottom, LabelLocation.Left, LabelLocation.Right }; break; } series1.LabelLayout.EnableDataPointSafeguard = true; series1.LabelLayout.DataPointSafeguardSize = new NSizeL( new NLength(1.3f, NRelativeUnit.ParentPercentage), new NLength(1.3f, NRelativeUnit.ParentPercentage)); // fill with random data GenerateData(series1); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Interlaced Stripes"); 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)); // setup chart m_Chart = (NCartesianChart)nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL( new NLength(90, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.DisplayDataPointsBetweenTicks = false; NLineSeries line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); line.Name = "Line Series"; line.DataLabelStyle.Format = "<value>"; line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Sphere; line.MarkerStyle.FillStyle = new NColorFillStyle(Color.Red); line.LineSegmentShape = LineSegmentShape.Tape; line.BorderStyle.Width = new NLength(2, NGraphicsUnit.Point); line.BorderStyle.Color = Color.DarkSlateBlue; line.DataLabelStyle.Visible = false; line.Legend.Mode = SeriesLegendMode.None; line.Values.FillRandom(Random, 20); line.ShadowStyle.Type = ShadowType.GaussianBlur; line.ShadowStyle.Offset = new NPointL(3, 3); line.ShadowStyle.FadeLength = new NLength(5); line.ShadowStyle.Color = Color.FromArgb(55, 0, 0, 0); m_YAxisInterlaceStyle = new NScaleStripStyle(); m_YAxisInterlaceStyle.SetShowAtWall(ChartWallType.Back, true); m_YAxisInterlaceStyle.SetShowAtWall(ChartWallType.Left, true); m_YAxisInterlaceStyle.Interlaced = true; m_YAxisInterlaceStyle.FillStyle = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, Color.FromArgb(125, Color.PaleTurquoise), Color.FromArgb(125, Color.MediumAquamarine)); m_YAxisInterlaceStyle.Begin = 0; m_YAxisInterlaceStyle.End = 10; m_YAxisInterlaceStyle.Infinite = true; m_YAxisInterlaceStyle.Interval = 1; m_YAxisInterlaceStyle.Length = 1; m_XAxisInterlaceStyle = new NScaleStripStyle(); m_XAxisInterlaceStyle.SetShowAtWall(ChartWallType.Back, true); m_XAxisInterlaceStyle.SetShowAtWall(ChartWallType.Floor, true); m_XAxisInterlaceStyle.Interlaced = true; m_XAxisInterlaceStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.SteelBlue), Color.FromArgb(125, Color.SlateGray)); m_XAxisInterlaceStyle.Begin = 0; m_XAxisInterlaceStyle.End = 10; m_XAxisInterlaceStyle.Infinite = true; m_XAxisInterlaceStyle.Interval = 1; m_XAxisInterlaceStyle.Length = 1; if (!Page.IsPostBack) { YAxisInterlacedStripesCheckBox.Checked = true; } UpdateInterlaceStirpes(); }
/// <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 Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 60; chart.Height = 25; chart.Depth = 45; chart.Projection.Type = ProjectionType.Perspective; chart.Projection.Elevation = 28; chart.Projection.Rotation = -17; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); // add interlaced stripe to the Y axis NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(System.Drawing.Color.Beige), null, true, 0, 0, 1, 1); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); stripStyle.Interlaced = true; ((NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle); // show the X axis gridlines NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); // add the first line NLineSeries line1 = (NLineSeries)chart.Series.Add(SeriesType.Line); line1.MultiLineMode = MultiLineMode.Series; line1.LineSegmentShape = LineSegmentShape.Tape; line1.DataLabelStyle.Visible = false; line1.DepthPercent = 50; line1.Name = "Line 1"; // add the second line NLineSeries line2 = (NLineSeries)chart.Series.Add(SeriesType.Line); line2.MultiLineMode = MultiLineMode.Series; line2.LineSegmentShape = LineSegmentShape.Tape; line2.DataLabelStyle.Visible = false; line2.DepthPercent = 50; line2.Name = "Line 2"; // add the third line NLineSeries line3 = (NLineSeries)chart.Series.Add(SeriesType.Line); line3.MultiLineMode = MultiLineMode.Series; line3.LineSegmentShape = LineSegmentShape.Tape; line3.DataLabelStyle.Visible = false; line3.DepthPercent = 50; line3.Name = "Line 3"; line1.Values.FillRandom(Random, 7); line2.Values.FillRandom(Random, 7); line3.Values.FillRandom(Random, 7); // 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(); // configure the trackball NTrackballTool trackballTool = new NTrackballTool(); trackballTool.ProjectionChanged += new EventHandler(OnProjectionChanged); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(trackballTool); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Axis Labels Orientation"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.DockMode = PanelDockMode.Top; title.Margins = new NMarginsL(10, 10, 10, 10); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); title.SendToBack(); // no legend nChartControl1.Legends.Clear(); // setup the chart m_Chart = (NCartesianChart)nChartControl1.Charts[0]; m_Chart.Enable3D = true; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); m_Chart.Depth = 50; m_Chart.Width = 50; m_Chart.Height = 50; m_Chart.BorderStyle = new NStrokeBorderStyle(BorderShape.RoundedRect); m_Chart.BoundsMode = BoundsMode.Fit; m_Chart.DockMode = PanelDockMode.Fill; m_Chart.Margins = new NMarginsL(30, 0, 30, 30); m_Chart.Padding = new NMarginsL(5, 5, 5, 5); m_Chart.BackgroundFillStyle = new NGradientFillStyle(Color.White, Color.LightGray); // setup Y axis NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.Title.Text = "Values"; // add interlaced stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; stripStyle.Interlaced = true; scaleY.StripStyles.Add(stripStyle); m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // configure the x axis labels (categories) NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleX.AutoLabels = false; scaleX.Title.Text = "Categories Title"; scaleX.MajorTickMode = MajorTickMode.CustomStep; scaleX.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; for (int j = 0; j < categoriesCount; j++) { scaleX.Labels.Add("Category " + j.ToString()); } // configure the depth axis labels (series) NOrdinalScaleConfigurator scaleZ = m_Chart.Axis(StandardAxis.Depth).ScaleConfigurator as NOrdinalScaleConfigurator; scaleZ.AutoLabels = false; scaleZ.Title.Text = "Series Title"; scaleZ.MajorTickMode = MajorTickMode.CustomStep; scaleZ.Labels.Add("Series 1"); scaleZ.Labels.Add("Series 2"); scaleZ.Labels.Add("Series 3"); scaleZ.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); scaleZ.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; // add series for (int i = 0; i < 3; i++) { NBarSeries bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); bar.InflateMargins = true; bar.BarShape = BarShape.SmoothEdgeBar; bar.DataLabelStyle.Visible = false; bar.Name = "Series " + i.ToString(); bar.Values.FillRandomRange(Random, categoriesCount, 10, 30); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); // initialize controls on the form AngleModeComboBox.FillFromEnum(typeof(ScaleLabelAngleMode)); AngleModeComboBox.SelectedIndex = (int)ScaleLabelAngleMode.Scale; Use3DCheckBox.Checked = true; OnProjectionChanged(null, 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); }
private void UpdateRegions() { m_Bar1.Values.Clear(); m_Bar2.Values.Clear(); // add custom labels to the X axis NChart chart = nChartControl1.Charts[0]; NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.Labels.Clear(); ordinalScale.CustomLabels.Clear(); if (NorthAmericaCheckBox.Checked) { ordinalScale.Labels.Add("USA"); ordinalScale.Labels.Add("Canada"); ordinalScale.Labels.Add("Mexico"); NCustomRangeLabel rangeLabel = new NCustomRangeLabel(); rangeLabel.Text = "Sales for North America"; rangeLabel.Range = new NRange1DD(0, 2); ordinalScale.CustomLabels.Add(rangeLabel); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); } if (EuropeCheckBox.Checked) { ordinalScale.Labels.Add("Germany"); ordinalScale.Labels.Add("UK"); ordinalScale.Labels.Add("France"); NCustomRangeLabel rangeLabel = new NCustomRangeLabel(); rangeLabel.Text = "Sales for Europe"; rangeLabel.Range = new NRange1DD(m_Bar1.Values.Count, m_Bar1.Values.Count + 2); ordinalScale.CustomLabels.Add(rangeLabel); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); } if (AsiaCheckBox.Checked) { ordinalScale.Labels.Add("Japan"); ordinalScale.Labels.Add("China"); ordinalScale.Labels.Add("South Korea"); NCustomRangeLabel rangeLabel = new NCustomRangeLabel(); rangeLabel.Text = "Sales for Asia"; rangeLabel.Range = new NRange1DD(m_Bar1.Values.Count, m_Bar1.Values.Count + 2); ordinalScale.CustomLabels.Add(rangeLabel); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); } if (SouthAmericaCheckBox.Checked) { ordinalScale.Labels.Add("Brazil"); ordinalScale.Labels.Add("Argentina"); ordinalScale.Labels.Add("Venezuela"); NCustomRangeLabel rangeLabel = new NCustomRangeLabel(); rangeLabel.Text = "Sales for South America"; rangeLabel.Range = new NRange1DD(m_Bar1.Values.Count, m_Bar1.Values.Count + 2); ordinalScale.CustomLabels.Add(rangeLabel); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar1.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); m_Bar2.Values.Add(Random.Next(10, 300)); } UpdateLabels(); nChartControl1.Refresh(); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Company Sales by Region<br/><font size = '9pt'>Demonstrates how to use custom range labels to denote ranges on a scale</font>"); header.DockMode = PanelDockMode.Top; header.Margins = new NMarginsL(0, 10, 0, 10); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); header.TextStyle.TextFormat = TextFormat.XML; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); nChartControl1.Panels.Add(header); NLegend legend = new NLegend(); legend.Margins = new NMarginsL(10, 0, 10, 0); legend.DockMode = PanelDockMode.Right; legend.FitAlignment = ContentAlignment.TopCenter; nChartControl1.Panels.Add(legend); NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.DisplayOnLegend = legend; chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; chart.Margins = new NMarginsL(10, 0, 0, 10); chart.Axis(StandardAxis.Depth).Visible = false; // add range selection NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rangeSelection); // add the first bar m_Bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); m_Bar1.Name = "Coca Cola"; m_Bar1.MultiBarMode = MultiBarMode.Series; m_Bar1.DataLabelStyle.Format = "<value>"; // add the second bar m_Bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); m_Bar2.Name = "Pepsi"; m_Bar2.MultiBarMode = MultiBarMode.Clustered; m_Bar2.DataLabelStyle.Format = "<value>"; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // add custom labels to the X axis NAxis xAxis = chart.Axis(StandardAxis.PrimaryX); xAxis.ScrollBar.Visible = true; NOrdinalScaleConfigurator ordinalScale = xAxis.ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.OuterMajorTickStyle.Visible = false; ordinalScale.InnerMajorTickStyle.Visible = false; // add custom labels to the Y axis chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 320)); NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; linearScale.RoundToTickMax = false; NCustomRangeLabel rangeLabel = new NCustomRangeLabel(new NRange1DD(240, 320), "Target Volume"); rangeLabel.Style.TickMode = RangeLabelTickMode.Center; rangeLabel.Style.WrapText = true; rangeLabel.Style.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0); linearScale.CustomLabels.Add(rangeLabel); // 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); // configure interactivity nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); // init form controls LabelTickModeComboBox.FillFromEnum(typeof(RangeLabelTickMode)); LabelVisibilityModeComboBox.FillFromEnum(typeof(ScaleLabelVisibilityMode)); LabelFitModeComboBox.FillFromEnum(typeof(RangeLabelFitMode)); NRangeScaleLabelStyle defaultStyle = new NRangeScaleLabelStyle(); LabelTickModeComboBox.SelectedIndex = (int)defaultStyle.TickMode; LabelVisibilityModeComboBox.SelectedIndex = (int)defaultStyle.VisibilityMode; LabelFitModeComboBox.SelectedIndex = (int)defaultStyle.FitMode; LabelAngleNumericUpDown.Value = (decimal)defaultStyle.Angle.CustomAngle; TickPaddingNumericUpDown.Value = (decimal)defaultStyle.TickPadding.Value; TickOffsetNumericUpDown.Value = (decimal)defaultStyle.TickOffset.Value; TextOffsetNumericUpDown.Value = (decimal)defaultStyle.Offset.Value; TextPaddingNumericUpDown.Value = (decimal)defaultStyle.TextPadding.Value; // add some data NorthAmericaCheckBox.Checked = true; EuropeCheckBox.Checked = true; AsiaCheckBox.Checked = true; SouthAmericaCheckBox.Checked = true; }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Animation Themes"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.DockMode = PanelDockMode.Top; title.Margins = new NMarginsL(0, 10, 0, 0); nChartControl1.Panels.Add(title); NDockPanel contentPanel = new NDockPanel(); nChartControl1.Panels.Add(contentPanel); contentPanel.DockMode = PanelDockMode.Fill; // configure the chart NCartesianChart chart = new NCartesianChart(); contentPanel.ChildPanels.Add(chart); chart.Location = new NPointL(0, 0); chart.Size = new NSizeL(new NLength(100, NRelativeUnit.ParentPercentage), new NLength(60, NRelativeUnit.ParentPercentage)); chart.Enable3D = false; chart.Axis(StandardAxis.Depth).Visible = false; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.BrightCameraLight); chart.Margins = new NMarginsL(10, 10, 10, 10); chart.BoundsMode = BoundsMode.Stretch; chart.DockMode = PanelDockMode.Top; // configure the legend NLegend legend = new NLegend(); chart.ChildPanels.Add(legend); chart.DisplayOnLegend = legend; chart.PositionChildPanelsInContentBounds = true; legend.DockMode = PanelDockMode.Top; legend.FitAlignment = ContentAlignment.BottomRight; legend.Location = new NPointL(new NLength(100, NRelativeUnit.ParentPercentage), new NLength(0)); legend.Margins = new NMarginsL(0, 5, 5, 0); legend.OuterLeftBorderStyle.Width = new NLength(0); legend.OuterRightBorderStyle.Width = new NLength(0); legend.OuterTopBorderStyle.Width = new NLength(0); legend.OuterBottomBorderStyle.Width = new NLength(0); legend.VerticalBorderStyle.Width = new NLength(0); legend.FillStyle.SetTransparencyPercent(50); // configure axes NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Labels.Add("2004"); ordinalScale.Labels.Add("2005"); ordinalScale.Labels.Add("2006"); ordinalScale.Labels.Add("2007"); ordinalScale.Labels.Add("2008"); ordinalScale.Labels.Add("2009"); // add interlace stripe NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; linearScale.Title.Text = "Sales in Thousands USD"; 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); NDockPanel gaugesPanel = new NDockPanel(); gaugesPanel.DockMode = PanelDockMode.Fill; gaugesPanel.Margins = new NMarginsL(20, 0, 10, 0); gaugesPanel.PositionChildPanelsInContentBounds = true; contentPanel.ChildPanels.Add(gaugesPanel); string[] companyNames = new string[] { "Company A", "Company B", "Company C" }; for (int i = 0; i < 3; i++) { NDockPanel gaugeContainer = new NDockPanel(); gaugeContainer.Location = new NPointL(new NLength(i * 35, NRelativeUnit.ParentPercentage), new NLength(0)); gaugeContainer.Size = new NSizeL(new NLength(30, NRelativeUnit.ParentPercentage), new NLength(100, NRelativeUnit.ParentPercentage)); gaugeContainer.ChildPanels.Add(CreateGaugeLabel(companyNames[i])); gaugeContainer.ChildPanels.Add(CreateGauge()); gaugesPanel.ChildPanels.Add(gaugeContainer); } // init form controls ChartTypeCombo.Items.Add("Bar"); ChartTypeCombo.Items.Add("Line"); ChartTypeCombo.Items.Add("Area"); ChartTypeCombo.SelectedIndex = 0; AggregationComboBox.Items.Add("None"); AggregationComboBox.Items.Add("Stacked"); AggregationComboBox.Items.Add("Clustered"); AggregationComboBox.SelectedIndex = 1; AnimationThemeTypeComboBox.FillFromEnum(typeof(AnimationThemeType)); AnimationThemeTypeComboBox.SelectedIndex = (int)AnimationThemeType.ScaleAndFade; AxesAnimationDurationUpDown.Value = (decimal)3; WallsAnimationDurationUpDown.Value = (decimal)3; SeriesAnimationDurationUpDown.Value = (decimal)3; IndicatorsAnimationDurationUpDown.Value = (decimal)3; GenerateNewDataButton_Click(null, null); CalculateIndicatorValues(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FunctionDropDownList.Items.Add("Average"); FunctionDropDownList.Items.Add("Min"); FunctionDropDownList.Items.Add("Max"); FunctionDropDownList.SelectedIndex = 0; GroupingDropDownList.Items.Add("Do not group"); GroupingDropDownList.Items.Add("Group by every 2 values"); GroupingDropDownList.Items.Add("Group by every 3 values"); GroupingDropDownList.Items.Add("Group by every 4 values"); GroupingDropDownList.SelectedIndex = 0; DataDropDownList.Items.Add("Positive"); DataDropDownList.Items.Add("Positive and Negative"); DataDropDownList.SelectedIndex = 0; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // add header NLabel header = nChartControl1.Labels.AddHeader("Average, Min, Max"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); nFuncCalculator = new NFunctionCalculator(); // setup legend NLegend legend = nChartControl1.Legends[0]; legend.Location = new NPointL(legend.Location.X, new NLength(15, NRelativeUnit.ParentPercentage)); legend.Data.MarkSize = new NSizeL(5, 5); // setup chart nChart = nChartControl1.Charts[0]; nChart.Enable3D = true; nChart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); nChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); nChart.BoundsMode = BoundsMode.Stretch; nChart.Location = new NPointL( new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); nChart.Size = new NSizeL( new NLength(70, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); nChart.Axis(StandardAxis.Depth).Visible = false; nChart.Wall(ChartWallType.Left).Visible = false; nChart.Wall(ChartWallType.Floor).Visible = false; // setup X axis NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)nChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.DisplayDataPointsBetweenTicks = false; // add a line series for the function nLine = (NLineSeries)nChart.Series.Add(SeriesType.Line); nLine.MarkerStyle.Visible = true; nLine.MarkerStyle.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); nLine.MarkerStyle.FillStyle = new NColorFillStyle(Color.Crimson); nLine.BorderStyle.Color = Color.Red; nLine.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel); nLine.Legend.Mode = SeriesLegendMode.None; nLine.Values.ValueFormatter = new NNumericValueFormatter("0.00"); nLine.DisplayOnAxis(StandardAxis.PrimaryX, false); nLine.DisplayOnAxis(StandardAxis.SecondaryX, true); nLine.Legend.TextStyle = new NTextStyle(new NFontStyle("Arial", 7)); // add the bar series nBar = (NBarSeries)nChart.Series.Add(SeriesType.Bar); nBar.Name = "Bar1"; nBar.Values.Name = "values"; nBar.Values.ValueFormatter = new NNumericValueFormatter("0.00"); nBar.MultiBarMode = MultiBarMode.Series; nBar.DataLabelStyle.Visible = false; nBar.Legend.Mode = SeriesLegendMode.DataPoints; nBar.BarShape = BarShape.Cylinder; nBar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); nBar.FillStyle = new NColorFillStyle(Color.DarkSalmon); nBar.Values.FillRandomRange(Random, 12, 0, 50); nBar.Legend.TextStyle = new NTextStyle(new NFontStyle("Arial", 7)); if (DataDropDownList.SelectedIndex == 0) { nBar.Values.FillRandomRange(Random, 12, 0, 50); } else { nBar.Values.FillRandomRange(Random, 12, -25, 25); } BuildExpression(); CalcFunction(); }
/// <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.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 25.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); // setup axes NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); ordinalScale.DisplayDataPointsBetweenTicks = false; ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); ordinalScale.DisplayDataPointsBetweenTicks = false; // add the surface series NGridSurfaceSeries surface = (NGridSurfaceSeries)chart.Series.Add(SeriesType.GridSurface); surface.Name = "Surface"; surface.Legend.Mode = SeriesLegendMode.SeriesLogic; surface.PositionValue = 10.0; surface.ShadingMode = ShadingMode.Smooth; surface.SmoothPalette = false; surface.SyncPaletteWithAxisScale = false; surface.PaletteSteps = 8; surface.ValueFormatter.FormatSpecifier = "0.00"; surface.FillStyle = new NColorFillStyle(Color.YellowGreen); surface.Data.SetGridSize(32, 32); FillData(surface); // 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; // form controls PositionModeComboBox.IsEnabled = false; CustomValueScrollBar.IsEnabled = false; }
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); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataLabelFormatDropDownList.Items.Add("high"); DataLabelFormatDropDownList.Items.Add("low"); DataLabelFormatDropDownList.Items.Add("high low"); DataLabelFormatDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithEnumValues(MarkerShapeDropDownList, typeof(PointShape)); MarkerShapeDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithColorNames(HighAreaColorDropDownList, KnownColor.LightSlateGray); WebExamplesUtilities.FillComboWithColorNames(LowAreaColorDropDownList, KnownColor.DarkOrange); WebExamplesUtilities.FillComboWithValues(MarkerSizeDropDownList, 0, 5, 1); MarkerSizeDropDownList.SelectedIndex = 2; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("2D High-Low Chart"); 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.BoundsMode = BoundsMode.Stretch; // setup X axis NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleX.DisplayDataPointsBetweenTicks = false; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorGridStyle.LineStyle.Color = Color.LightGray; // add interlace stripe 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); NHighLowSeries highLow = (NHighLowSeries)chart.Series.Add(SeriesType.HighLow); highLow.Name = "High-Low Series"; highLow.InflateMargins = true; highLow.Legend.Mode = SeriesLegendMode.SeriesLogic; highLow.MarkerStyle.FillStyle = new NColorFillStyle(Red); highLow.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(7); highLow.LowValues.ValueFormatter = new NNumericValueFormatter("0.#"); highLow.HighValues.ValueFormatter = new NNumericValueFormatter("0.#"); highLow.HighFillStyle = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(HighAreaColorDropDownList)); highLow.LowFillStyle = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(LowAreaColorDropDownList)); highLow.DropLines = ShowDropLinesCheckBox.Checked; highLow.DataLabelStyle.Visible = ShowDataLabelsCheckBox.Checked; switch (DataLabelFormatDropDownList.SelectedIndex) { case 0: highLow.DataLabelStyle.Format = "<high_value>"; break; case 1: highLow.DataLabelStyle.Format = "<low_value>"; break; case 2: highLow.DataLabelStyle.Format = "<high_value> - <low_value>"; break; } MarkerShapeDropDownList.Enabled = ShowMarkersCheckBox.Checked; MarkerSizeDropDownList.Enabled = ShowMarkersCheckBox.Checked; highLow.MarkerStyle.Visible = ShowMarkersCheckBox.Checked; highLow.MarkerStyle.PointShape = (PointShape)MarkerShapeDropDownList.SelectedIndex; highLow.MarkerStyle.Width = new NLength((float)MarkerSizeDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage); highLow.MarkerStyle.Height = new NLength((float)MarkerSizeDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage); GenerateData(highLow); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]); }
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); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { //nChartControl1.Settings.RenderSurface = RenderSurface.Window; nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.None; 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("Grid Surface with Custom Colors"); 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.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 25.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); // setup axes NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); ordinalScale.DisplayDataPointsBetweenTicks = false; ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); ordinalScale.DisplayDataPointsBetweenTicks = false; // add the surface series NGridSurfaceSeries surface = new NGridSurfaceSeries(); chart.Series.Add(surface); surface.ShadingMode = ShadingMode.Smooth; surface.FillMode = SurfaceFillMode.CustomColors; surface.FrameMode = SurfaceFrameMode.None; surface.FrameColorMode = SurfaceFrameColorMode.CustomColors; surface.FrameStrokeStyle.Color = Color.Red; surface.FrameStrokeStyle.Width = new NLength(4); surface.Data.UseColors = true; surface.Data.SetGridSize(50, 50); // define a custom palette surface.Palette.Clear(); surface.Palette.Add(-3, DarkOrange); surface.Palette.Add(-2.5, LightOrange); surface.Palette.Add(-1, LightGreen); surface.Palette.Add(0, Turqoise); surface.Palette.Add(2, Blue); surface.Palette.Add(3, Purple); surface.Palette.Add(4, BeautifulRed); // generate data GenerateSurfaceData(surface); // apply layout ConfigureStandardLayout(chart, title, null); HasFillingCheckBox.IsChecked = true; FrameModeComboBox.Items.Add("None"); FrameModeComboBox.Items.Add("Mesh"); FrameModeComboBox.Items.Add("Dots"); FrameModeComboBox.SelectedIndex = 0; SmoothShadingCheckBox.IsChecked = true; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { 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, System.Drawing.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); SurfaceSizeComboBox.Items.Add("500 x 500"); SurfaceSizeComboBox.Items.Add("1024 x 1024"); FillModeComboBox.Items.Add("Uniform"); FillModeComboBox.Items.Add("Zone Texture"); FillModeComboBox.Items.Add("Zone Texture - Smooth"); // init form controls UseHardwareAccelerationCheckBox.IsChecked = true; SurfaceSizeComboBox.SelectedIndex = 0; FillModeComboBox.SelectedIndex = 1; }
public override void Initialize() { base.Initialize(); // Enable GPU acceleration nChartControl1.Settings.RenderSurface = RenderSurface.Window; nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Surface Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // setup chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 60.0f; chart.Depth = 60.0f; chart.Height = 25.0f; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft); // setup axes NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); ordinalScale.DisplayDataPointsBetweenTicks = false; ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); ordinalScale.DisplayDataPointsBetweenTicks = false; // add the surface series NGridSurfaceSeries surface = (NGridSurfaceSeries)chart.Series.Add(SeriesType.GridSurface); surface.Name = "Surface"; surface.Legend.Mode = SeriesLegendMode.SeriesLogic; surface.PositionValue = 10.0; surface.Data.SetGridSize(100, 100); surface.SyncPaletteWithAxisScale = false; surface.PaletteSteps = 8; surface.ValueFormatter.FormatSpecifier = "0.00"; surface.FillStyle = new NColorFillStyle(Color.YellowGreen); FillData(surface); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); // form controls fillModeCombo.SelectedIndex = 2; smoothShadingCheck.Checked = true; frameModeCombo.SelectedIndex = 2; frameColorModeCombo.SelectedIndex = 0; smoothPaletteCheck.Checked = false; positionModeCombo.SelectedIndex = 0; customValueScroll.Value = 10; PaletteLegendModeComboBox.SelectedIndex = (int)PaletteLegendMode.GradientAxis; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Bubble Scale"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); m_Chart.Axis(StandardAxis.Depth).Visible = false; NLinearScaleConfigurator linearScale = m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; linearScale.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); linearScale.StripStyles.Add(stripStyle); NOrdinalScaleConfigurator ordinalScale = m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); // add a bubble series m_Bubble = (NBubbleSeries)m_Chart.Series.Add(SeriesType.Bubble); m_Bubble.DataLabelStyle.VertAlign = VertAlign.Center; m_Bubble.DataLabelStyle.Visible = false; m_Bubble.MinSize = new NLength(7.0f, NRelativeUnit.ParentPercentage); m_Bubble.MaxSize = new NLength(16.0f, NRelativeUnit.ParentPercentage); for (int i = 0; i < 10; i++) { m_Bubble.Values.Add(i); m_Bubble.Sizes.Add(i * 10 + 10); } m_Bubble.InflateMargins = true; NPalette palette = new NPalette(); palette.SmoothPalette = true; palette.Clear(); palette.Add(0, Color.Green); palette.Add(60, Color.Yellow); palette.Add(120, Color.Red); m_Bubble.Palette = palette; nChartControl1.Legends[0].Header.Text = "Bubble Size"; m_Bubble.Legend.Mode = SeriesLegendMode.SeriesLogic; m_Bubble.BubbleSizeScale.TextOffset = new NLength(0); m_Bubble.BubbleSizeScale.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center; m_Bubble.BubbleSizeScale.Mode = BubbleSizeScaleMode.ConcentricDown; // apply layout ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]); }
protected void Page_Load(object sender, EventArgs e) { NThinChartControl1.StateId = "Chart1"; if (!NThinChartControl1.Initialized) { // enable jittering (full scene antialiasing) NThinChartControl1.Settings.JitterMode = JitterMode.Enabled; NThinChartControl1.ServerSettings.EnableTiledZoom = true; NThinChartControl1.Panels.Clear(); // apply background image border NImageFrameStyle frame = new NImageFrameStyle(); frame.Type = ImageFrameType.Raised; frame.BackgroundColor = Color.White; frame.BorderStyle.Color = Color.Gainsboro; NThinChartControl1.BackgroundStyle.FrameStyle = frame; NThinChartControl1.BackgroundStyle.FillStyle = new NGradientFillStyle(Color.White, Color.GhostWhite); // set a chart title NLabel title = new NLabel("Toolbar Configuration"); NThinChartControl1.Panels.Add(title); title.DockMode = PanelDockMode.Top; title.Padding = new NMarginsL(4, 6, 4, 6); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // configure the legend NLegend legend = new NLegend(); NThinChartControl1.Panels.Add(legend); legend.DockMode = PanelDockMode.Right; legend.Padding = new NMarginsL(1, 1, 3, 3); legend.FillStyle.SetTransparencyPercent(50); 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.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.VerticalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); // configure the chart NCartesianChart chart = new NCartesianChart(); NThinChartControl1.Panels.Add(chart); chart.Enable3D = true; chart.Fit3DAxisContent = true; chart.DisplayOnLegend = legend; chart.BoundsMode = BoundsMode.Fit; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1); chart.DockMode = PanelDockMode.Fill; chart.Padding = new NMarginsL( new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage)); chart.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(Color.White, Color.Gray); // setup the X axis NAxis axisX = chart.Axis(StandardAxis.PrimaryX); axisX.ScrollBar.Visible = true; NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)axisX.ScaleConfigurator; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleX.AutoLabels = false; // add interlaced stripe for the Y axis NAxis axisY = chart.Axis(StandardAxis.PrimaryY); axisY.ScrollBar.Visible = true; NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)axisY.ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; scaleY.StripStyles.Add(stripStyle); // hide the depth axis chart.Axis(StandardAxis.Depth).Visible = false; // add a bar series and fill it with data NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Name = "Simple Bar Chart"; bar.BarShape = BarShape.SmoothEdgeBar; bar.Legend.Mode = SeriesLegendMode.DataPoints; bar.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point); bar.DataLabelStyle.Visible = false; AddDataPoint(scaleX, bar, 16, "Spain", @"http://en.wikipedia.org/wiki/Spain"); AddDataPoint(scaleX, bar, 42, "France", @"http://en.wikipedia.org/wiki/France"); AddDataPoint(scaleX, bar, 56, "Germany", @"http://en.wikipedia.org/wiki/Germany"); AddDataPoint(scaleX, bar, 23, "Italy", @"http://en.wikipedia.org/wiki/Italy"); AddDataPoint(scaleX, bar, 47, "UK", @"http://en.wikipedia.org/wiki/UK"); AddDataPoint(scaleX, bar, 38, "Sweden", @"http://en.wikipedia.org/wiki/Sweden"); // add the index of the bar to highlight NThinChartControl1.CustomData = 0; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(bar); // configure toolbar NThinChartControl1.Toolbar.Visible = true; NThinChartControl1.Controller.SetActivePanel(chart); NThinChartControl1.AutoUpdateCallback = new NAutoUpdateCallback(); //NThinChartControl1.Controller.EnableAutoUpdate = true; NTrackballTool tbt = new NTrackballTool(); tbt.Exclusive = true; tbt.Enabled = true; NThinChartControl1.Controller.Tools.Add(tbt); // add a data zoom tool NDataZoomTool dataZoomTool = new NDataZoomTool(); dataZoomTool.Exclusive = true; dataZoomTool.Enabled = false; NThinChartControl1.Controller.Tools.Add(dataZoomTool); // add a data pan tool NDataPanTool dataPanTool = new NDataPanTool(); dataPanTool.Exclusive = true; dataPanTool.Enabled = false; NThinChartControl1.Controller.Tools.Add(dataPanTool); // add a tooltip tool NThinChartControl1.Controller.Tools.Add(new NTooltipTool()); // add a cursor change tool NThinChartControl1.Controller.Tools.Add(new NCursorTool()); // add a browser redirect tool NThinChartControl1.Controller.Tools.Add(new NBrowserRedirectTool()); NThinChartControl1.Toolbar.Visible = true; NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveStateAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as PDF", new NPdfImageFormat(), true, new NSize(), 300))); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as SVG", new NSvgImageFormat(), true, new NSize(), 96))); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as XAML", new NXamlImageFormat(), true, new NSize(), 96))); NSaveImageAction sia = new NSaveImageAction("Bitmap.bmp", new NBitmapImageFormat(), true, new NSize(), 96); sia.Tooltip = "Print or Save as Bitmap"; NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(sia)); NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator()); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NTogglePanelSelectorToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataZoomToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataPanToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleTrackballToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator()); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleAutoUpdateAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleChart3DAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleChartLightingAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator()); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleTooltipToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleBrowserRedirectToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleCursorToolAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator()); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new ShowDataLabelsAction())); NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new HideDataLabelsAction())); NThinChartControl1.CustomRequestCallback = new CustomRequestCallback(); } }
protected void Page_Load(object sender, EventArgs e) { // init form controls if (!IsPostBack) { PrimaryXAxisAutoLabelsCheckBox.Checked = true; PrimaryXAxisInvertCheckBox.Checked = true; DepthAxisAutoLabelsCheckBox.Checked = true; DepthAxisInvertAxisCheckBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Ordinal 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)); // setup the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Enable3D = true; // set projection and lighting m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); // set sizes m_Chart.Depth = 50; m_Chart.BoundsMode = BoundsMode.Fit; m_Chart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL( new NLength(90, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); // add interlace stripe NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; 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 series Color[] seriesColors = new Color[] { Color.Crimson, Color.Orange, Color.OliveDrab }; int dataItemsCount = 6; for (int i = 0; i < seriesColors.Length; i++) { NBarSeries bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); bar.FillStyle = new NColorFillStyle(seriesColors[i]); bar.Name = "Series " + i.ToString(); bar.Values.FillRandomRange(Random, dataItemsCount, 10, 30); bar.InflateMargins = true; bar.DataLabelStyle.Visible = false; } NOrdinalScaleConfigurator oridnalScale = m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; oridnalScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.AutoScale }; for (int i = 0; i < dataItemsCount; i++) { oridnalScale.Labels.Add("Category " + i.ToString()); } oridnalScale = m_Chart.Axis(StandardAxis.Depth).ScaleConfigurator as NOrdinalScaleConfigurator; oridnalScale.Labels.Add("Series 1"); oridnalScale.Labels.Add("Series 2"); oridnalScale.Labels.Add("Series 3"); oridnalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); oridnalScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.AutoScale }; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); }
protected void Page_Load(object sender, System.EventArgs e) { // init form controls if (!IsPostBack) { AngleModeDropDownList.Items.Add("View"); AngleModeDropDownList.Items.Add("Scale"); AngleModeDropDownList.SelectedIndex = 1; AllowFlipCheckBox.Checked = false; FitAxisContentInBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Axis Labels Orientation"); nChartControl1.Panels.Add(header); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.Margins = new NMarginsL(10, 10, 10, 4); header.DockMode = PanelDockMode.Top; // setup the chart NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.Enable3D = true; chart.Fit3DAxisContent = FitAxisContentInBox.Checked; chart.DockMode = PanelDockMode.Fill; chart.BorderStyle = new NStrokeBorderStyle(BorderShape.RoundedRect); chart.BackgroundFillStyle = new NGradientFillStyle(Color.White, Color.LightGray); chart.Margins = new NMarginsL(10, 0, 10, 10); chart.Padding = new NMarginsL(2, 2, 2, 2); // set predefined projection and lighting chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); chart.Depth = 50; chart.Width = 50; chart.Height = 50; chart.BoundsMode = BoundsMode.Fit; chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); // add interlaced stripe NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; 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); // add series Color[] seriesColors = new Color[] { Color.Crimson, Color.Orange, Color.OliveDrab }; int dataItemsCount = 6; for (int i = 0; i < seriesColors.Length; i++) { NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.BarShape = BarShape.SmoothEdgeBar; bar.FillStyle = new NColorFillStyle(seriesColors[i]); bar.Name = "Series " + i.ToString(); bar.Values.FillRandomRange(Random, dataItemsCount, 10, 30); bar.InflateMargins = true; bar.DataLabelStyle.Visible = false; } // configure the x axis labels (categories) NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Title.Text = "Categories Title"; ordinalScale.MajorTickMode = MajorTickMode.CustomStep; ordinalScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; for (int i = 0; i < dataItemsCount; i++) { ordinalScale.Labels.Add("S" + i.ToString()); } // configure the depth axis labels (series) ordinalScale = chart.Axis(StandardAxis.Depth).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Title.Text = "Series Title"; ordinalScale.MajorTickMode = MajorTickMode.CustomStep; ordinalScale.Labels.Add("S1"); ordinalScale.Labels.Add("S2"); ordinalScale.Labels.Add("S3"); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; // set title to Y axis NNumericScaleConfigurator numericScale = chart.Axis((int)StandardAxis.PrimaryY).ScaleConfigurator as NNumericScaleConfigurator; numericScale.Title.Text = "Values"; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // read the form control values float customAngle; if (!float.TryParse(CustomAngleTextBox.Text, out customAngle) || customAngle < 0 || customAngle > 360) { customAngle = 0f; CustomAngleTextBox.Text = customAngle.ToString(); } // update scale labels angle int count = chart.Axes.Count; NScaleLabelAngle angle = new NScaleLabelAngle((ScaleLabelAngleMode)Enum.Parse(typeof(ScaleLabelAngleMode), AngleModeDropDownList.SelectedItem.Value), customAngle, AllowFlipCheckBox.Checked); // update the x axis NAxis axis = (NAxis)chart.Axes[(int)StandardAxis.PrimaryX]; NStandardScaleConfigurator scale = axis.ScaleConfigurator as NStandardScaleConfigurator; scale.LabelStyle.Angle = angle; // update the depth axis axis = (NAxis)chart.Axes[(int)StandardAxis.Depth]; scale = axis.ScaleConfigurator as NStandardScaleConfigurator; scale.LabelStyle.Angle = angle; }