Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                WebExamplesUtilities.FillComboWithColorNames(UpColorDropDownList, KnownColor.Red);
                WebExamplesUtilities.FillComboWithColorNames(DownColorDropDownList, KnownColor.Black);
                ProportionalXCheckBox.Checked = false;
                ProportionalYCheckBox.Checked = false;
                WebExamplesUtilities.FillComboWithFloatValues(BoxSizeDropdownlist, 0.5F, 10, 0.5F);
                BoxSizeDropdownlist.SelectedIndex = 9;
                WebExamplesUtilities.FillComboWithValues(ReversalAmountDropDownList, 1, 5, 1);
                ReversalAmountDropDownList.SelectedIndex = 2;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Point and Figure");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

            // no legend
            nChartControl1.Legends.Clear();

            // configure the chart
            NChart chart = nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;

            // setup X axis
            NPriceScaleConfigurator priceConfigurator = new NPriceScaleConfigurator();

            priceConfigurator.LabelValueFormatter                 = new NDateTimeValueFormatter(DateTimeValueFormat.Date);
            priceConfigurator.MajorTickMode                       = MajorTickMode.AutoMaxCount;
            priceConfigurator.MajorGridStyle.ShowAtWalls          = new ChartWallType[] { ChartWallType.Back };
            priceConfigurator.InnerMajorTickStyle.LineStyle.Width = new NLength(0);
            priceConfigurator.MaxTickCount = 8;

            NNumericRangeSamplerProvider provider = new NNumericRangeSamplerProvider();

            provider.SamplingMode = SamplingMode.CustomStep;
            provider.CustomStep   = 1;
            provider.UseOrigin    = true;
            provider.Origin       = -0.5;
            priceConfigurator.MajorGridStyle.RangeSamplerProvider = provider;

            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = priceConfigurator;

            // setup Y axis
            NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;

            scaleY.MajorTickMode                  = MajorTickMode.CustomStep;
            scaleY.CustomStep                     = 5;
            scaleY.OuterMajorTickStyle.Width      = new NLength(0);
            scaleY.InnerMajorTickStyle.Width      = new NLength(0);
            scaleY.AutoMinorTicks                 = true;
            scaleY.MinorTickCount                 = 1;
            scaleY.RoundToTickMin                 = false;
            scaleY.RoundToTickMax                 = false;
            scaleY.MajorGridStyle.LineStyle.Width = new NLength(0);
            scaleY.MinorGridStyle.LineStyle.Width = new NLength(1);
            scaleY.MinorGridStyle.ShowAtWalls     = new ChartWallType[] { ChartWallType.Back };

            float[] highValues = new float[20] {
                21.3F, 42.4F, 11.2F, 65.7F, 38.0F, 71.3F, 49.54F, 83.7F, 13.9F, 56.12F, 27.43F, 23.1F, 31.0F, 75.4F, 9.3F, 39.12F, 10.0F, 44.23F, 21.76F, 49.2F
            };
            float[] lowValues = new float[20] {
                12.1F, 14.32F, 8.43F, 36.0F, 13.5F, 47.34F, 24.54F, 68.11F, 6.87F, 23.3F, 12.12F, 14.54F, 25.0F, 37.2F, 3.9F, 23.11F, 1.9F, 14.0F, 8.23F, 34.21F
            };

            // setup Point & Figure series
            NPointAndFigureSeries pointAndFigure = (NPointAndFigureSeries)chart.Series.Add(SeriesType.PointAndFigure);

            pointAndFigure.UseXValues = true;

            // fill data
            pointAndFigure.HighValues.AddRange(highValues);
            pointAndFigure.LowValues.AddRange(lowValues);

            DateTime dt = new DateTime(2007, 1, 1);

            for (int i = 0; i < 20; i++)
            {
                pointAndFigure.XValues.Add(dt);
                dt = dt.AddDays(1);
            }

            double dBoxSize = Convert.ToDouble(BoxSizeDropdownlist.SelectedValue);

            pointAndFigure.BoxSize = dBoxSize;
            scaleY.CustomStep      = dBoxSize;

            pointAndFigure.ProportionalX         = ProportionalXCheckBox.Checked;
            pointAndFigure.ProportionalY         = ProportionalYCheckBox.Checked;
            pointAndFigure.ReversalAmount        = Convert.ToInt32(ReversalAmountDropDownList.SelectedValue);
            pointAndFigure.UpStrokeStyle.Color   = WebExamplesUtilities.ColorFromDropDownList(UpColorDropDownList);
            pointAndFigure.DownStrokeStyle.Color = WebExamplesUtilities.ColorFromDropDownList(DownColorDropDownList);

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // form controls
                FunctionDropDownList.Items.Add("Power");
                FunctionDropDownList.Items.Add("Cumulative");
                FunctionDropDownList.Items.Add("Exponential Average");
                FunctionDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithFloatValues(PowerDropDownList, -3, 3, 0.5f);
                PowerDropDownList.SelectedIndex = 10;

                WebExamplesUtilities.FillComboWithFloatValues(ExponentialWeightDropDownList, 0, 1, 0.1f);
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // add header
            NLabel header = nChartControl1.Labels.AddHeader("Functions");

            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));

            // align the 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);

            nFuncCalculator = new NFunctionCalculator();

            // 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.DataLabelStyle.Format = "<value>";
            nLine.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(7, NGraphicsUnit.Point);
            nLine.MarkerStyle.Visible           = true;
            nLine.MarkerStyle.Width             = new NLength(0.08f, NRelativeUnit.ParentPercentage);
            nLine.MarkerStyle.Height            = new NLength(0.08f, NRelativeUnit.ParentPercentage);
            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.Legend.TextStyle      = new NTextStyle(new NFontStyle("Arial", 7));
            nLine.Values.ValueFormatter = new NNumericValueFormatter("0.00");

            // 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.CornflowerBlue);
            nBar.Values.FillRandomRange(Random, 10, 0, 10);
            nBar.Legend.TextStyle = new NTextStyle(new NFontStyle("Arial", 7));

            nFuncCalculator.Arguments.Add(nBar.Values);
            nBar.Values.FillRandomRange(Random, 10, 0, 10);


            BuildExpression();
            CalculateFunction();
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            nFunction = new NFunctionCalculator();

            if (!IsPostBack)
            {
                FunctionDropDownList.Items.Add("Simple Moving Average");
                FunctionDropDownList.Items.Add("Weighted Moving Average");
                FunctionDropDownList.Items.Add("Exponential Moving Average");
                FunctionDropDownList.Items.Add("Modified Moving Average");
                FunctionDropDownList.SelectedIndex = 0;

                // form controls
                ApplyFunctionToDropDownList.Items.Add("Open");
                ApplyFunctionToDropDownList.Items.Add("High");
                ApplyFunctionToDropDownList.Items.Add("Low");
                ApplyFunctionToDropDownList.Items.Add("Close");
                ApplyFunctionToDropDownList.SelectedIndex = 3;

                WebExamplesUtilities.FillComboWithFloatValues(PeriodDropDownList, 0, 50, 1);
                PeriodDropDownList.SelectedIndex = 10;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // add header
            NLabel header = nChartControl1.Labels.AddHeader("Moving Averages");

            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));

            NLegend legend = nChartControl1.Legends[0];

            legend.Location = new NPointL(
                new NLength(98, NRelativeUnit.ParentPercentage),
                new NLength(12, NRelativeUnit.ParentPercentage));

            NChart chart = nChartControl1.Charts[0];

            chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);
            chart.LightModel.EnableLighting         = false;
            chart.Axis(StandardAxis.Depth).Visible  = false;
            chart.Wall(ChartWallType.Floor).Visible = false;
            chart.Wall(ChartWallType.Left).Visible  = false;
            chart.BoundsMode = BoundsMode.Stretch;
            chart.Location   = new NPointL(
                new NLength(5, NRelativeUnit.ParentPercentage),
                new NLength(20, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(90, NRelativeUnit.ParentPercentage),
                new NLength(75, NRelativeUnit.ParentPercentage));

            // align the chart and the legend
            NSideGuideline guideline = new NSideGuideline(PanelSide.Right);

            guideline.Targets.Add(legend);
            guideline.Targets.Add(chart);
            nChartControl1.Document.RootPanel.Guidelines.Add(guideline);

            // setup X axis
            NRangeTimelineScaleConfigurator scaleX = new NRangeTimelineScaleConfigurator();

            scaleX.FirstRow.GridStyle.ShowAtWalls  = new ChartWallType[] { ChartWallType.Back };
            scaleX.FirstRow.GridStyle.LineStyle    = new NStrokeStyle(1, Color.FromArgb(225, 225, 225));
            scaleX.FirstRow.UseGridStyle           = true;
            scaleX.SecondRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
            scaleX.SecondRow.GridStyle.LineStyle   = new NStrokeStyle(1, Color.FromArgb(215, 215, 215));
            scaleX.SecondRow.UseGridStyle          = true;
            scaleX.ThirdRow.GridStyle.ShowAtWalls  = new ChartWallType[] { ChartWallType.Back };
            scaleX.ThirdRow.GridStyle.LineStyle    = new NStrokeStyle(1, Color.FromArgb(205, 205, 205));
            scaleX.ThirdRow.UseGridStyle           = true;
            // calendar
            NWeekDayRule wdr = new NWeekDayRule(WeekDayBit.All);

            wdr.Saturday = false;
            wdr.Sunday   = false;
            scaleX.Calendar.Rules.Add(wdr);
            scaleX.EnableCalendar = true;
            // set configurator
            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;

            // setup primary Y axis
            NAxis axis = chart.Axis(StandardAxis.PrimaryY);
            NLinearScaleConfigurator linearScaleConfigurator = (NLinearScaleConfigurator)axis.ScaleConfigurator;

            linearScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            linearScaleConfigurator.MajorGridStyle.SetShowAtWall(ChartWallType.Left, false);
            linearScaleConfigurator.InnerMajorTickStyle.LineStyle.Width = new NLength(0, NGraphicsUnit.Pixel);

            // line series for the function
            NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line);

            line.DataLabelStyle.Visible = false;
            line.BorderStyle.Color      = Color.Red;
            line.BorderStyle.Width      = new NLength(2, NGraphicsUnit.Pixel);
            line.UseXValues             = true;

            Color customColor = Color.FromArgb(100, 100, 150);

            // setup the stock series
            NStockSeries stock = (NStockSeries)chart.Series.Add(SeriesType.Stock);

            stock.DataLabelStyle.Visible   = false;
            stock.CandleStyle              = CandleStyle.Bar;
            stock.CandleWidth              = new NLength(1, NRelativeUnit.ParentPercentage);
            stock.HighLowStrokeStyle.Color = customColor;
            stock.UpStrokeStyle.Color      = customColor;
            stock.DownStrokeStyle.Color    = customColor;
            stock.UpFillStyle              = new NColorFillStyle(Color.White);
            stock.DownFillStyle            = new NColorFillStyle(customColor);
            stock.Legend.Mode              = SeriesLegendMode.None;
            stock.OpenValues.Name          = "open";
            stock.HighValues.Name          = "high";
            stock.LowValues.Name           = "low";
            stock.CloseValues.Name         = "close";
            stock.UseXValues     = true;
            stock.InflateMargins = true;

            GenerateData(stock);
            BuildExpression(stock, line);

            line.XValues = (NDataSeriesDouble)stock.XValues.Clone();
            line.Values  = nFunction.Calculate();
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Settings.JitterMode         = JitterMode.Enabled;
            nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.HighSpeed;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Mesh Surface Chart");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

            // setup legend
            NLegend legend = nChartControl1.Legends[0];

            legend.VerticalBorderStyle.Width    = new NLength(0, NGraphicsUnit.Pixel);
            legend.HorizontalBorderStyle.Width  = new NLength(0, NGraphicsUnit.Pixel);
            legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
            legend.OuterLeftBorderStyle.Width   = new NLength(0, NGraphicsUnit.Pixel);
            legend.OuterRightBorderStyle.Width  = new NLength(0, NGraphicsUnit.Pixel);
            legend.OuterTopBorderStyle.Width    = new NLength(0, NGraphicsUnit.Pixel);
            legend.FillStyle     = new NColorFillStyle(Color.Transparent);
            legend.Data.MarkSize = new NSizeL(
                new NLength(8, NGraphicsUnit.Pixel),
                new NLength(8, NGraphicsUnit.Pixel));

            // setup chart
            NChart chart = nChartControl1.Charts[0];

            chart.Enable3D = true;
            chart.Width    = 70.0f;
            chart.Depth    = 70.0f;
            chart.Height   = 30.0f;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);

            if (!IsPostBack)
            {
                // form controls
                FrameStyleDropDownList.Items.Add("None");
                FrameStyleDropDownList.Items.Add("Mesh");
                FrameStyleDropDownList.Items.Add("Contour");
                FrameStyleDropDownList.Items.Add("Mesh-Contour");
                FrameStyleDropDownList.Items.Add("Dots");
                FrameStyleDropDownList.SelectedIndex = 2;

                PositionModeDropDownList.Items.Add("Axis Begin");
                PositionModeDropDownList.Items.Add("Axis End");
                PositionModeDropDownList.Items.Add("Custom Value");
                PositionModeDropDownList.SelectedIndex = 0;

                RotationTextBox.Text  = chart.Projection.Rotation.ToString();
                ElevationTextBox.Text = chart.Projection.Elevation.ToString();

                WebExamplesUtilities.FillComboWithPercents(TransparencyDropDownList, 10);
                WebExamplesUtilities.FillComboWithFloatValues(CustomValueDropDownList, 0, 1, 0.1f);
                CustomValueDropDownList.SelectedIndex = 5;
            }
            else
            {
                chart.Projection.Rotation  = (float)Convert.ToDouble(RotationTextBox.Text);
                chart.Projection.Elevation = (float)Convert.ToDouble(ElevationTextBox.Text);
            }

            // setup Y axis
            NLinearScaleConfigurator linearScaleConfigurator = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;

            linearScaleConfigurator.LabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 8);

            // add interlace stripe
            NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);

            stripStyle.Interlaced = true;
            stripStyle.SetShowAtWall(ChartWallType.Back, true);
            stripStyle.SetShowAtWall(ChartWallType.Left, true);
            linearScaleConfigurator.StripStyles.Add(stripStyle);

            // setup X axis
            linearScaleConfigurator = new NLinearScaleConfigurator();
            linearScaleConfigurator.RoundToTickMin = false;
            linearScaleConfigurator.RoundToTickMax = false;
            linearScaleConfigurator.LabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 8);
            linearScaleConfigurator.MajorGridStyle.ShowAtWalls     = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Back };
            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator    = linearScaleConfigurator;

            // setup Z axis
            linearScaleConfigurator = new NLinearScaleConfigurator();
            linearScaleConfigurator.RoundToTickMin = false;
            linearScaleConfigurator.RoundToTickMax = false;
            linearScaleConfigurator.LabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 8);
            linearScaleConfigurator.MajorGridStyle.ShowAtWalls     = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Left };
            chart.Axis(StandardAxis.Depth).ScaleConfigurator       = linearScaleConfigurator;

            // setup mesh surface series
            NMeshSurfaceSeries surface = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface);

            surface.Name        = "Surface";
            surface.Legend.Mode = SeriesLegendMode.SeriesLogic;
            surface.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);
            surface.FillMode      = SurfaceFillMode.Zone;
            surface.PositionValue = 0.5;
            surface.Data.SetGridSize(20, 20);
            surface.SyncPaletteWithAxisScale       = false;
            surface.PaletteSteps                   = 8;
            surface.ValueFormatter.FormatSpecifier = "0.00";
            surface.ShadingMode = ShadingMode.Smooth;

            FillDataXY(surface);

            if (PaletteFrameCheckBox.Checked)
            {
                surface.FrameColorMode = SurfaceFrameColorMode.Zone;
            }
            else
            {
                surface.FrameColorMode = SurfaceFrameColorMode.Uniform;
            }
            surface.DrawFlat      = DrawFlatCheckBox.Checked;
            surface.PositionMode  = (SurfacePositionMode)PositionModeDropDownList.SelectedIndex;
            surface.PositionValue = CustomValueDropDownList.SelectedIndex / 10.0;
            surface.FrameMode     = (SurfaceFrameMode)FrameStyleDropDownList.SelectedIndex;
            surface.FillStyle.SetTransparencyPercent(TransparencyDropDownList.SelectedIndex * 10);

            if (SmoothPaletteCheckBox.Checked)
            {
                surface.SmoothPalette = true;
                surface.Legend.Format = "<zone_value>";
            }
            else
            {
                surface.SmoothPalette = false;
                surface.Legend.Format = "<zone_begin> - <zone_end>";
            }

            PositionModeDropDownList.Enabled = DrawFlatCheckBox.Checked;
            CustomValueDropDownList.Enabled  = DrawFlatCheckBox.Checked;
            PaletteFrameCheckBox.Enabled     = (surface.FrameMode != SurfaceFrameMode.None);

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