private void AxisAnchorsModeCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            NChart chart = nChartControl1.Charts[0];

            NAxisAnchor anchorY = null;
            NAxisAnchor anchorX = null;
            NAxisAnchor anchorZ = null;

            switch (AxisAnchorsModeCombo.SelectedIndex)
            {
            case 0:
                anchorY = new NBestVisibilityAxisAnchor(AxisOrientation.Vertical);
                anchorX = new NBestVisibilityAxisAnchor(AxisOrientation.Horizontal);
                anchorZ = new NBestVisibilityAxisAnchor(AxisOrientation.Depth);
                break;

            case 1:
                anchorY = new NAutoSideAxisAnchor(AxisOrientation.Vertical);
                anchorX = new NAutoSideAxisAnchor(AxisOrientation.Horizontal);
                anchorZ = new NAutoSideAxisAnchor(AxisOrientation.Depth);
                break;

            case 2:
                anchorY = new NDockAxisAnchor(AxisDockZone.FrontLeft);
                anchorX = new NDockAxisAnchor(AxisDockZone.FrontBottom);
                anchorZ = new NDockAxisAnchor(AxisDockZone.BottomRight);
                break;
            }

            chart.Axis(StandardAxis.PrimaryY).Anchor = anchorY;
            chart.Axis(StandardAxis.PrimaryX).Anchor = anchorX;
            chart.Axis(StandardAxis.Depth).Anchor    = anchorZ;

            nChartControl1.Refresh();
        }
Esempio n. 2
0
        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)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel header = new NLabel("Axis Ruler Caps<br/> <font size = '9pt'>Demonstrates how to change the caps of the axis ruler</font>");

            header.DockMode                              = PanelDockMode.Top;
            header.TextStyle.FontStyle                   = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            header.TextStyle.ShadowStyle.Type            = ShadowType.LinearBlur;
            header.TextStyle.TextFormat                  = TextFormat.XML;
            header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left;
            header.FitAlignment                          = ContentAlignment.MiddleLeft;
            header.Margins = new NMarginsL(5, 0, 0, 5);

            nChartControl1.Panels.Add(header);

            NCartesianChart chart = new NCartesianChart();

            chart.DockMode   = PanelDockMode.Fill;
            chart.BoundsMode = BoundsMode.Stretch;
            chart.Margins    = new NMarginsL(5, 10, 10, 5);
            nChartControl1.Panels.Add(chart);

            Random random = new Random();

            // feed some random data
            NPointSeries point = new NPointSeries();

            point.DataLabelStyle.Visible = false;
            point.UseXValues             = true;
            point.Size = new NLength(5);
            point.BorderStyle.Width = new NLength(0);

            // fill in some random data
            for (int j = 0; j < 30; j++)
            {
                point.Values.Add(5 + random.Next(90));
                point.XValues.Add(5 + random.Next(90));
            }

            chart.Series.Add(point);

            // configure scales
            NLinearScaleConfigurator xScale = new NLinearScaleConfigurator();

            xScale.RoundToTickMax = true;
            xScale.RoundToTickMin = true;
            xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            xScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41)));

            // add an interlaced strip to the X axis
            NScaleStripStyle xInterlacedStrip = new NScaleStripStyle();

            xInterlacedStrip.SetShowAtWall(ChartWallType.Back, true);
            xInterlacedStrip.Interlaced = true;
            xInterlacedStrip.FillStyle  = new NColorFillStyle(Color.FromArgb(40, Color.LightGray));
            xScale.StripStyles.Add(xInterlacedStrip);

            NCartesianAxis xAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryX);

            xAxis.ScaleConfigurator = xScale;
            xAxis.View = new NRangeAxisView(new NRange1DD(0, 100));

            NDockAxisAnchor xAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontBottom);

            xAxisAnchor.BeforeSpace = new NLength(10);
            xAxis.Anchor            = xAxisAnchor;

            NLinearScaleConfigurator yScale = new NLinearScaleConfigurator();

            yScale.RoundToTickMax = true;
            yScale.RoundToTickMin = true;
            yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            yScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41)));

            // add an interlaced strip to the Y axis
            NScaleStripStyle yInterlacedStrip = new NScaleStripStyle();

            yInterlacedStrip.SetShowAtWall(ChartWallType.Back, true);
            yInterlacedStrip.Interlaced = true;
            yInterlacedStrip.FillStyle  = new NColorFillStyle(Color.FromArgb(40, Color.LightGray));
            yScale.StripStyles.Add(yInterlacedStrip);

            NCartesianAxis yAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryY);

            yAxis.ScaleConfigurator = yScale;
            yAxis.View = new NRangeAxisView(new NRange1DD(0, 100));

            NDockAxisAnchor yAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontLeft);

            yAxisAnchor.BeforeSpace = new NLength(10);
            yAxis.Anchor            = yAxisAnchor;

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            // update form controls
            if (!IsPostBack)
            {
                PaintOnScaleBreaksCheckBox.Checked = false;

                WebExamplesUtilities.FillComboWithEnumValues(BeginCapStyleDropDownList, typeof(CapStyle));
                BeginCapStyleDropDownList.SelectedIndex = (int)CapStyle.Ellipse;

                WebExamplesUtilities.FillComboWithEnumValues(ScaleBreakCapStyleDropDownList, typeof(CapStyle));
                ScaleBreakCapStyleDropDownList.SelectedIndex = (int)CapStyle.LeftCrossLine;

                WebExamplesUtilities.FillComboWithEnumValues(EndCapStyleDropDownList, typeof(CapStyle));
                EndCapStyleDropDownList.SelectedIndex = (int)CapStyle.Arrow;
            }

            UpdateRulerStyleForAxis(xAxis);
            UpdateRulerStyleForAxis(yAxis);
        }
Esempio n. 4
0
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Axis Ruler Caps<br/> <font size = '9pt'>Demonstrates how to change the caps of the axis ruler</font>");

            title.DockMode             = PanelDockMode.Top;
            title.Margins              = new NMarginsL(10, 10, 10, 10);
            title.TextStyle.TextFormat = TextFormat.XML;
            title.TextStyle.FontStyle  = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.FitAlignment         = ContentAlignment.BottomCenter;
            title.Location             = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

            nChartControl1.Panels.Add(title);

            NCartesianChart chart = new NCartesianChart();

            chart.DockMode   = PanelDockMode.Fill;
            chart.BoundsMode = BoundsMode.Stretch;
            chart.Margins    = new NMarginsL(10, 0, 20, 10);
            nChartControl1.Panels.Add(chart);

            Random random = new Random();

            // feed some random data
            NPointSeries point = new NPointSeries();

            point.DataLabelStyle.Visible = false;
            point.UseXValues             = true;
            point.Size = new NLength(5);
            point.BorderStyle.Width = new NLength(0);

            // fill in some random data
            for (int j = 0; j < 30; j++)
            {
                point.Values.Add(5 + random.Next(90));
                point.XValues.Add(5 + random.Next(90));
            }

            chart.Series.Add(point);

            // configure scales
            NLinearScaleConfigurator xScale = new NLinearScaleConfigurator();

            xScale.RoundToTickMax = true;
            xScale.RoundToTickMin = true;
            xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            xScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41)));

            // add an interlaced strip to the X axis
            NScaleStripStyle xInterlacedStrip = new NScaleStripStyle();

            xInterlacedStrip.SetShowAtWall(ChartWallType.Back, true);
            xInterlacedStrip.Interlaced = true;
            xInterlacedStrip.FillStyle  = new NColorFillStyle(Color.FromArgb(40, Color.LightGray));
            xScale.StripStyles.Add(xInterlacedStrip);

            NCartesianAxis xAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryX);

            xAxis.ScaleConfigurator = xScale;
            xAxis.View = new NRangeAxisView(new NRange1DD(0, 100));

            NDockAxisAnchor xAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontBottom);

            xAxisAnchor.BeforeSpace = new NLength(10);
            xAxis.Anchor            = xAxisAnchor;

            NLinearScaleConfigurator yScale = new NLinearScaleConfigurator();

            yScale.RoundToTickMax = true;
            yScale.RoundToTickMin = true;
            yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            yScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41)));

            // add an interlaced strip to the Y axis
            NScaleStripStyle yInterlacedStrip = new NScaleStripStyle();

            yInterlacedStrip.SetShowAtWall(ChartWallType.Back, true);
            yInterlacedStrip.Interlaced = true;
            yInterlacedStrip.FillStyle  = new NColorFillStyle(Color.FromArgb(40, Color.LightGray));
            yScale.StripStyles.Add(yInterlacedStrip);

            NCartesianAxis yAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryY);

            yAxis.ScaleConfigurator = yScale;
            yAxis.View = new NRangeAxisView(new NRange1DD(0, 100));

            NDockAxisAnchor yAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontLeft);

            yAxisAnchor.BeforeSpace = new NLength(10);
            yAxis.Anchor            = yAxisAnchor;

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            // Init form controls
            BeginCapComboBox.FillFromEnum(typeof(CapStyle));
            EndCapComboBox.FillFromEnum(typeof(CapStyle));
            ScaleBreakCapComboBox.FillFromEnum(typeof(CapStyle));

            BeginCapComboBox.SelectedIndex      = (int)CapStyle.Ellipse;
            EndCapComboBox.SelectedIndex        = (int)CapStyle.Arrow;
            ScaleBreakCapComboBox.SelectedIndex = (int)CapStyle.LeftCrossLine;
            WidthNumericUpDown.Value            = (decimal)5;
            HeightNumericUpDown.Value           = (decimal)5;
        }
Esempio n. 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Chart Walls<br/><font size = '9pt'>Demonstrates how to enable automatic wall visibility and automatic axis anchors</font>");

            title.TextStyle.FontStyle                   = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type            = ShadowType.LinearBlur;
            title.TextStyle.TextFormat                  = TextFormat.XML;
            title.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center;
            nChartControl1.Panels.Add(title);

            NChart chart = new NCartesianChart();

            nChartControl1.Panels.Add(chart);
            chart.Enable3D = true;
            chart.Width    = 55;
            chart.Height   = 25;
            chart.Depth    = 40;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);

            // add interlaced stripe to the 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,
                ChartWallType.Right,
                ChartWallType.Front
            };

            NStandardScaleConfigurator scaleY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;

            scaleY.StripStyles.Add(stripStyle);

            // create several series
            for (int i = 0; i < 4; i++)
            {
                NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
                bar.Values.FillRandom(Random, 6);
                bar.DataLabelStyle.Visible = false;
            }

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            // update form controls
            if (!IsPostBack)
            {
                RotationTextBox.Text  = chart.Projection.Rotation.ToString();
                ElevationTextBox.Text = chart.Projection.Elevation.ToString();
                LightsInCameraSpaceCheckBox.Checked = true;
                AutoWallsVisibilityCheckBox.Checked = true;

                AxisAnchorsModeDropDownList.Items.Add("Best Visibility");
                AxisAnchorsModeDropDownList.Items.Add("Auto Side");
                AxisAnchorsModeDropDownList.Items.Add("Manual");
                AxisAnchorsModeDropDownList.SelectedIndex = 0;
            }

            // configure lights
            NPointLightSource lightSource = new NPointLightSource();

            lightSource.Position = new NVector3DF(2, 2, 50);
            lightSource.Ambient  = Color.FromArgb(64, 64, 64);
            lightSource.Diffuse  = Color.FromArgb(255, 255, 255);
            lightSource.Specular = Color.FromArgb(100, 100, 100);

            chart.LightModel.LightSources.Clear();
            chart.LightModel.LightSources.Add(lightSource);
            chart.LightModel.GlobalAmbientLight = Color.FromArgb(0, 0, 0);

            if (LightsInCameraSpaceCheckBox.Checked)
            {
                lightSource.CoordinateMode = LightSourceCoordinateMode.Camera;
                lightSource.Position       = new NVector3DF(0, 0, 50);
            }
            else
            {
                lightSource.CoordinateMode = LightSourceCoordinateMode.Model;
                lightSource.Position       = new NVector3DF(100, 95, 110);
            }

            chart.Projection.Rotation  = (float)Convert.ToDouble(RotationTextBox.Text);
            chart.Projection.Elevation = (float)Convert.ToDouble(ElevationTextBox.Text);


            // update walls visiblity
            if (AutoWallsVisibilityCheckBox.Checked)
            {
                foreach (NChartWall wall in chart.Walls)
                {
                    wall.VisibilityMode = WallVisibilityMode.Auto;
                }
            }
            else
            {
                chart.Wall(ChartWallType.Left).VisibilityMode  = WallVisibilityMode.Visible;
                chart.Wall(ChartWallType.Back).VisibilityMode  = WallVisibilityMode.Visible;
                chart.Wall(ChartWallType.Floor).VisibilityMode = WallVisibilityMode.Visible;
                chart.Wall(ChartWallType.Front).VisibilityMode = WallVisibilityMode.Hidden;
                chart.Wall(ChartWallType.Top).VisibilityMode   = WallVisibilityMode.Hidden;
                chart.Wall(ChartWallType.Right).VisibilityMode = WallVisibilityMode.Hidden;
            }

            // update axis anchors
            NAxisAnchor anchorY = null;
            NAxisAnchor anchorX = null;
            NAxisAnchor anchorZ = null;

            switch (AxisAnchorsModeDropDownList.SelectedIndex)
            {
            case 0:
                anchorY = new NBestVisibilityAxisAnchor(AxisOrientation.Vertical);
                anchorX = new NBestVisibilityAxisAnchor(AxisOrientation.Horizontal);
                anchorZ = new NBestVisibilityAxisAnchor(AxisOrientation.Depth);
                break;

            case 1:
                anchorY = new NAutoSideAxisAnchor(AxisOrientation.Vertical);
                anchorX = new NAutoSideAxisAnchor(AxisOrientation.Horizontal);
                anchorZ = new NAutoSideAxisAnchor(AxisOrientation.Depth);
                break;

            case 2:
                anchorY = new NDockAxisAnchor(AxisDockZone.FrontLeft);
                anchorX = new NDockAxisAnchor(AxisDockZone.FrontBottom);
                anchorZ = new NDockAxisAnchor(AxisDockZone.BottomRight);
                break;
            }

            chart.Axis(StandardAxis.PrimaryY).Anchor = anchorY;
            chart.Axis(StandardAxis.PrimaryX).Anchor = anchorX;
            chart.Axis(StandardAxis.Depth).Anchor    = anchorZ;

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);
        }