public override void Initialize(NThinChartControl control)
        {
            control.BackgroundStyle.FrameStyle.Visible = false;
            control.Panels.Clear();
            control.Width  = 600;
            control.Height = 300;
            NStandardFrameStyle frame = control.BackgroundStyle.FrameStyle as NStandardFrameStyle;

            frame.InnerBorderWidth = new NLength(0);

            // set a chart title
            // set a chart title
            NLabel title = control.Labels.AddHeader("Auto Update");

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

            // setup Line chart
            NCartesianChart chart = new NCartesianChart();

            control.Panels.Add(chart);
            NRangeTimelineScaleConfigurator rangeTimeline = new NRangeTimelineScaleConfigurator();

            rangeTimeline.FirstRow.MinTickDistance = new NLength(40);
            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = rangeTimeline;

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

            scaleY.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);
            scaleY.StripStyles.Add(stripStyle);

            NLineSeries line = new NLineSeries();

            line.UseXValues             = true;
            line.DataLabelStyle.Visible = false;
            line.BorderStyle.Color      = Color.DarkOrange;
            line.BorderStyle.Width      = new NLength(2);
            chart.Series.Add(line);

            // generate some data
            GenerateNewData(control);

            ApplyLayoutTemplate(0, control, chart, title, null);

            // set auto update Callback
            control.AutoUpdateCallback = new NAutoUpdateCallback();

            // enable auto update
            control.ServerSettings.AutoUpdateInterval = 200;
            control.ServerSettings.EnableAutoUpdate   = true;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!NThinChartControl1.Initialized)
            {
                NThinChartControl1.BackgroundStyle.FrameStyle.Visible = false;
                NThinChartControl1.Panels.Clear();
                NStandardFrameStyle frame = NThinChartControl1.BackgroundStyle.FrameStyle as NStandardFrameStyle;
                frame.InnerBorderWidth = new NLength(0);

                // set a chart title
                // set a chart title
                NLabel title = NThinChartControl1.Labels.AddHeader("Auto Update");
                title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
                title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

                // setup Line chart
                NCartesianChart chart = new NCartesianChart();
                NThinChartControl1.Panels.Add(chart);
                NRangeTimelineScaleConfigurator rangeTimeline = new NRangeTimelineScaleConfigurator();
                rangeTimeline.FirstRow.MinTickDistance = new NLength(40);
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = rangeTimeline;

                // setup Y axis
                NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
                scaleY.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);
                scaleY.StripStyles.Add(stripStyle);

                NLineSeries line = new NLineSeries();
                line.UseXValues             = true;
                line.DataLabelStyle.Visible = false;
                line.BorderStyle.Color      = Color.DarkOrange;
                line.BorderStyle.Width      = new NLength(2);
                chart.Series.Add(line);

                // generate some data
                GenerateNewData();

                NThinChartControl1.AutoUpdateCallback = new NAutoUpdateCallback();
                ApplyLayoutTemplate(0, NThinChartControl1, chart, title, null);

                NThinChartControl1.ServerSettings.EnableTiledZoom    = true;
                NThinChartControl1.ServerSettings.AutoUpdateInterval = 200;
                NThinChartControl1.ServerSettings.EnableAutoUpdate   = true;
            }

            if (!IsPostBack)
            {
                AutoUpdateIntervalTextBox.Text = NThinChartControl1.ServerSettings.AutoUpdateInterval.ToString();
            }
        }
        private void EnableWorkCalendar_CheckedChanged(object sender, EventArgs e)
        {
            NRangeTimelineScaleConfigurator scaleX = nChartControl1.Charts[0].Axis(StandardAxis.PrimaryX).ScaleConfigurator as NRangeTimelineScaleConfigurator;

            if (scaleX != null)
            {
                scaleX.EnableCalendar = EnableWorkCalendar.Checked;
                nChartControl1.Refresh();
            }
        }
Esempio n. 4
0
        public void InitChart(NCartesianChart chart)
        {
            // set layout related properties
            chart.BoundsMode = BoundsMode.Stretch;
            chart.DockMode   = PanelDockMode.Fill;
            chart.Margins    = new NMarginsL(10, 0, 10, 10);
            nChartControl1.Panels.Add(chart);

            // add interlace stripes
            NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
            NScaleStripStyle         stripStyle  = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);

            stripStyle.Interlaced  = true;
            stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
            linearScale.StripStyles.Add(stripStyle);

            // show X axis zooming and scrolling
            chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;

            // apply work calendar to the X axis
            NWorkCalendar calendar    = new NWorkCalendar();
            NWeekDayRule  weekDayRule = new NWeekDayRule();
            WeekDayBit    weekDays    = WeekDayBit.None;

            weekDays            |= WeekDayBit.Monday;
            weekDays            |= WeekDayBit.Tuesday;
            weekDays            |= WeekDayBit.Wednesday;
            weekDays            |= WeekDayBit.Thursday;
            weekDays            |= WeekDayBit.Friday;
            weekDayRule.WeekDays = weekDays;
            weekDayRule.Schedule.SetHourRange(0, 24, false);
            calendar.Rules.Add(weekDayRule);

            // apply calendar to scale
            NRangeTimelineScaleConfigurator timeline = new NRangeTimelineScaleConfigurator();

            timeline.FirstRow.GridStyle.ShowAtWalls  = new ChartWallType[] { ChartWallType.Back };
            timeline.FirstRow.GridStyle.LineStyle    = new NStrokeStyle(1, Color.FromArgb(225, 225, 225));
            timeline.FirstRow.UseGridStyle           = true;
            timeline.SecondRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
            timeline.SecondRow.GridStyle.LineStyle   = new NStrokeStyle(1, Color.FromArgb(215, 215, 215));
            timeline.SecondRow.UseGridStyle          = true;
            timeline.ThirdRow.GridStyle.ShowAtWalls  = new ChartWallType[] { ChartWallType.Back };
            timeline.ThirdRow.GridStyle.LineStyle    = new NStrokeStyle(1, Color.FromArgb(205, 205, 205));
            timeline.ThirdRow.UseGridStyle           = true;

            timeline.EnableCalendar = false;
            timeline.Calendar       = calendar;
            timeline.ThirdRow.EnableUnitSensitiveFormatting = false;

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

            // generate data for this calendar
            AddData(chart, calendar);
        }
Esempio n. 5
0
        private void UpdateScale()
        {
            NRangeTimelineScaleConfigurator timelineScale = m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NRangeTimelineScaleConfigurator;

            timelineScale.FirstRow.Visible          = FirstRowVisibleCheckBox.Checked;
            timelineScale.SecondRow.Visible         = SecondRowVisibleCheckBox.Checked;
            timelineScale.ThirdRow.Visible          = ThirdRowVisibleCheckBox.Checked;
            timelineScale.CreateSeparatorForEachRow = CreateSeparatorForEachRowCheckBox.Checked;

            nChartControl1.Refresh();
        }
        private void UpdateScale()
        {
            if (m_Chart == null)
            {
                return;
            }

            ConfigureScaleRow(0, FirstRowVisibleCheckBox, FirstRowModeComboBox, FirstRowUnitComboBox, FirstRowUnitCountUpDown);
            ConfigureScaleRow(1, SecondRowVisibleCheckBox, SecondRowModeComboBox, SecondRowUnitComboBox, SecondRowUnitCountUpDown);
            ConfigureScaleRow(2, ThirdRowVisibleCheckBox, ThirdRowModeComboBox, ThirdRowUnitComboBox, ThirdRowUnitCountUpDown);

            NRangeTimelineScaleConfigurator rangeTimelineScale = m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NRangeTimelineScaleConfigurator;

            rangeTimelineScale.LevelTopPadding    = new NLength((float)TopLevelPaddingUpDown.Value, NGraphicsUnit.Point);
            rangeTimelineScale.LevelBottomPadding = new NLength((float)BottomLevelPaddingUpDown.Value, NGraphicsUnit.Point);

            nChartControl1.Refresh();
        }
        private void ConfigureScaleRow(int rowIndex, NCheckBox visibleCheckBox, NComboBox rowModeComboBox, NComboBox rowUnitComboBox, NNumericUpDown rowUnitCountUpDown)
        {
            NRangeTimelineScaleConfigurator rangeTimelineScale = m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NRangeTimelineScaleConfigurator;
            NTimelineScaleRow scaleRow;

            if (rowIndex == 0)
            {
                scaleRow = rangeTimelineScale.FirstRow;
                ((NRangeTimelineScaleRow)scaleRow).LabelStyle.FitMode = RangeLabelFitMode.Clip;
            }
            else if (rowIndex == 1)
            {
                scaleRow = rangeTimelineScale.SecondRow;
            }
            else
            {
                scaleRow = rangeTimelineScale.ThirdRow;
            }

            scaleRow.Visible = visibleCheckBox.Checked;

            bool enableUnitControls = false;

            switch ((TimelineScaleRowTickMode)rowModeComboBox.SelectedIndex)
            {
            case TimelineScaleRowTickMode.AutoMinDistance:
                scaleRow.TickMode = TimelineScaleRowTickMode.AutoMinDistance;
                break;

            case TimelineScaleRowTickMode.AutoMaxCount:
                scaleRow.TickMode = TimelineScaleRowTickMode.AutoMaxCount;
                break;

            case TimelineScaleRowTickMode.Custom:
                enableUnitControls  = true;
                scaleRow.TickMode   = TimelineScaleRowTickMode.Custom;
                scaleRow.CustomStep = new NDateTimeSpan((int)rowUnitCountUpDown.Value, NDateTimeUnit.GetFromEnum((DateTimeUnit)rowUnitComboBox.SelectedIndex));
                break;
            }

            rowUnitComboBox.Enabled    = enableUnitControls;
            rowUnitCountUpDown.Enabled = enableUnitControls;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Settings.JitterMode = JitterMode.Enabled;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Float Bar Connector Lines");

            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
            NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;
            chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft);
            chart.Axis(StandardAxis.Depth).Visible = false;

            // setup the value axis
            NRangeTimelineScaleConfigurator dateTimeScale = new NRangeTimelineScaleConfigurator();

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

            // fill data
            DateTime start = DateTime.Now;
            DateTime end   = start + new TimeSpan(10, 0, 0, 0);

            TaskCollection tasks = new TaskCollection();

            tasks.Add(new Task("Write Proposal",
                               new DateTime(2001, 4, 1),
                               new DateTime(2001, 4, 5),
                               new uint[] { 1, 2 }));

            tasks.Add(new Task("Obtain Approval",
                               new DateTime(2001, 4, 12),
                               new DateTime(2001, 9, 4),
                               new uint[] { 9 }));

            tasks.Add(new Task("Requirements Analysis",
                               new DateTime(2001, 4, 9),
                               new DateTime(2001, 5, 5),
                               new uint[] { 3 }));

            tasks.Add(new Task("Design Phase",
                               new DateTime(2001, 5, 6),
                               new DateTime(2001, 5, 30),
                               new uint[] { 4 }));

            tasks.Add(new Task("Design Signoff",
                               new DateTime(2001, 6, 2),
                               new DateTime(2001, 6, 2),
                               new uint[] { 5 }));

            tasks.Add(new Task("Alpha Implementation",
                               new DateTime(2001, 6, 3),
                               new DateTime(2001, 7, 31),
                               new uint[] { 6 }));

            tasks.Add(new Task("Design Review",
                               new DateTime(2001, 8, 1),
                               new DateTime(2001, 8, 8),
                               new uint[] { 7 }));

            tasks.Add(new Task("Revised Design Signoff",
                               new DateTime(2001, 8, 10),
                               new DateTime(2001, 8, 10),
                               new uint[] { 8 }));

            tasks.Add(new Task("Beta Implementation",
                               new DateTime(2001, 8, 12),
                               new DateTime(2001, 9, 12),
                               new uint[] { 9 }));

            tasks.Add(new Task("Testing",
                               new DateTime(2001, 9, 13),
                               new DateTime(2001, 10, 31),
                               new uint[] { 10 }));

            tasks.Add(new Task("Final Implementation",
                               new DateTime(2001, 11, 1),
                               new DateTime(2001, 11, 15),
                               new uint[] { 11 }));

            tasks.Add(new Task("Signoff",
                               new DateTime(2001, 11, 28),
                               new DateTime(2001, 11, 30),
                               new uint[] { 12 }));

            tasks.ConfigureChart(chart);

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

            styleSheet.Apply(nChartControl1.Document);

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

            NFloatBarSeries floatBar = (NFloatBarSeries)nChartControl1.Charts[0].Series[0];

            floatBar.ShowGanttConnectorLines = ShowGanttConnectorLinesCheckBox.Checked;
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel header = nChartControl1.Labels.AddFooter("Price Indicators");

            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
            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.Height     = 40;
            chart.Location   = new NPointL(
                new NLength(5, NRelativeUnit.ParentPercentage),
                new NLength(15, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(90, NRelativeUnit.ParentPercentage),
                new NLength(80, NRelativeUnit.ParentPercentage));

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

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

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

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

            linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
            linearScale.InnerMajorTickStyle.Length = new NLength(0);

            // line series for the function
            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.ShadowStyle.Type       = ShadowType.GaussianBlur;
            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.Stick;
            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.CandleWidth              = new NLength(1, NRelativeUnit.ParentPercentage);
            stock.InflateMargins           = true;
            stock.UseXValues = true;

            GenerateData(stock);

            if (!IsPostBack)
            {
                FunctionDropDownList.Items.Add("Median Price");
                FunctionDropDownList.Items.Add("Typical Price");
                FunctionDropDownList.Items.Add("Weighted Close");
                FunctionDropDownList.SelectedIndex = 0;
            }

            CalculateFunction(stock, line);
        }
Esempio n. 10
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel header = nChartControl1.Labels.AddHeader("Bollinger Bands /\n Envelopes");

            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
            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.Height     = 40;
            chart.Location   = new NPointL(
                new NLength(5, NRelativeUnit.ParentPercentage),
                new NLength(25, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(90, NRelativeUnit.ParentPercentage),
                new NLength(73, NRelativeUnit.ParentPercentage));

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

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

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

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

            linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
            linearScale.InnerMajorTickStyle.Length = new NLength(0);

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

            lineUpper.DataLabelStyle.Visible = false;
            lineUpper.BorderStyle.Color      = Color.Green;

            // Add line series for lower band
            NLineSeries lineLower = (NLineSeries)chart.Series.Add(SeriesType.Line);

            lineLower.DataLabelStyle.Visible = false;
            lineLower.BorderStyle.Color      = Color.Green;

            // Add line series for Simple Moving Average
            NLineSeries lineSMA = (NLineSeries)chart.Series.Add(SeriesType.Line);

            lineSMA.DataLabelStyle.Visible = false;
            lineSMA.BorderStyle.Color      = Color.Orange;
            lineSMA.Name = "Simple Moving Average";

            Color color1 = Color.FromArgb(100, 100, 150);
            Color color2 = Color.FromArgb(200, 120, 120);

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

            stock.DataLabelStyle.Visible = false;
            stock.CandleStyle            = CandleStyle.Stick;
            stock.CandleWidth            = new NLength(0.5f, NRelativeUnit.ParentPercentage);
            stock.UpStrokeStyle.Color    = color1;
            stock.DownStrokeStyle.Color  = color2;
            stock.Legend.Mode            = SeriesLegendMode.None;
            stock.CloseValues.Name       = "close";
            stock.UseXValues             = true;
            stock.InflateMargins         = true;

            // Add arguments
            NFunctionCalculator upperCalculator = new NFunctionCalculator();
            NFunctionCalculator lowerCalculator = new NFunctionCalculator();
            NFunctionCalculator SMACalculator   = new NFunctionCalculator();

            upperCalculator.Arguments.Add(stock.CloseValues);
            lowerCalculator.Arguments.Add(stock.CloseValues);
            SMACalculator.Arguments.Add(stock.CloseValues);

            GenerateData(stock);

            // form controls
            if (!IsPostBack)
            {
                FunctionDropDownList.Items.Add("Bollinger Bands");
                FunctionDropDownList.Items.Add("Envelopes");
                FunctionDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithValues(PeriodDropDownList, 0, 100, 10);
                PeriodDropDownList.SelectedIndex = 2;

                WebExamplesUtilities.FillComboWithValues(DeviationDropDownList, 0, 20, 1);
                DeviationDropDownList.SelectedIndex = 2;

                ShowPricesCheckBox.Checked = true;
                ShowSMACheckBox.Checked    = true;
            }

            UpdateExpressions(lineUpper, lineLower, upperCalculator, lowerCalculator, SMACalculator);
            CalculateFunctions(stock, lineUpper, lineLower, lineSMA, upperCalculator, lowerCalculator, SMACalculator);
            stock.Visible   = ShowPricesCheckBox.Checked;
            lineSMA.Visible = ShowSMACheckBox.Checked;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!NThinChartControl1.Initialized)
            {
                // enable jittering (full scene antialiasing)
                NThinChartControl1.Settings.JitterMode = JitterMode.Enabled;

                NThinChartControl1.BackgroundStyle.FrameStyle.Visible = false;
                NThinChartControl1.Panels.Clear();

                // add header
                NLabel header = NThinChartControl1.Labels.AddHeader("General Thin Web Functionality");
                header.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
                header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
                header.Margins  = new NMarginsL(10, 10, 10, 10);
                header.DockMode = PanelDockMode.Top;

                NChart chart = new NCartesianChart();
                NThinChartControl1.Panels.Add(chart);
                chart.BoundsMode = BoundsMode.Stretch;
                chart.DockMode   = PanelDockMode.Fill;
                chart.Margins    = new NMarginsL(10, 0, 10, 10);

                // setup X axis
                NRangeTimelineScaleConfigurator scaleX = new NRangeTimelineScaleConfigurator();
                // set configurator
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;

                // enable the scrollbar
                chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;

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

                // 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);
                scaleY.StripStyles.Add(stripStyle);

                // 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.OpenValues.Name          = "open";
                stock.HighValues.Name          = "high";
                stock.LowValues.Name           = "low";
                stock.CloseValues.Name         = "close";
                stock.UseXValues = true;

                GenerateData(stock);
                NFunctionCalculator functionCalculator = new NFunctionCalculator();
                BuildExpression(functionCalculator, stock, line);

                line.XValues = (NDataSeriesDouble)stock.XValues.Clone();
                line.Values  = functionCalculator.Calculate();

                NThinChartControl1.ServerSettings.EnableTiledZoom = true;

                // configure toolbar
                NThinChartControl1.Toolbar.Visible = true;
                NThinChartControl1.Controller.SetActivePanel(chart);

                // add a data zoom tool
                NDataZoomTool dataZoomTool = new NDataZoomTool();
                dataZoomTool.Exclusive      = true;
                dataZoomTool.Enabled        = true;
                dataZoomTool.AllowYAxisZoom = 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());

                NThinChartControl1.Toolbar.Visible = true;
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as PNG", new NPngImageFormat(), true, new NSize(0, 0), 96)));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator());

                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataZoomToolAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataPanToolAction()));
            }
        }
Esempio n. 12
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();
        }
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = new NLabel("Daily Workload in Percents<br/><font size = '9pt'>Demonstrates how to skip hours in the working days, per day using the daily schedule object</font>");

            title.TextStyle.TextFormat = TextFormat.XML;
            title.TextStyle.FontStyle  = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            nChartControl1.Panels.Add(title);

            NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;

            NRangeSelection rangeSelection = new NRangeSelection();

            rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper();
            chart.RangeSelections.Add(rangeSelection);
            chart.BoundsMode = BoundsMode.Stretch;

            NRangeSeries ranges = new NRangeSeries();

            ranges.DataLabelStyle.Visible = false;
            ranges.UseXValues             = true;

            DateTime dt   = new DateTime(2014, 4, 14);
            Random   rand = new Random();

            NRangeTimelineScaleConfigurator rangeTimeline = new NRangeTimelineScaleConfigurator();

            rangeTimeline.EnableCalendar = true;
            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = rangeTimeline;
            chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;

            chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator.Title.Text = "Daily Workload in %";
            chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 100), true, true);

            NWorkCalendar      workCalendar      = rangeTimeline.Calendar;
            NDateTimeRangeRule dateTimeRangeRule = null;

            for (int i = 0; i < 120; i++)
            {
                int hourOfTheDay = i % 24;
                if (hourOfTheDay < 8 || hourOfTheDay > 18)
                {
                    DateTime curDate = new DateTime(dt.Year, dt.Month, dt.Day, 0, 0, 0);

                    if (dateTimeRangeRule != null)
                    {
                        if (dateTimeRangeRule.Range.Begin != curDate)
                        {
                            dateTimeRangeRule = null;
                        }
                    }

                    if (dateTimeRangeRule == null)
                    {
                        dateTimeRangeRule = new NDateTimeRangeRule(new NDateTimeRange(curDate, curDate + new TimeSpan(24, 0, 0)), true);
                        workCalendar.Rules.Add(dateTimeRangeRule);
                    }

                    dateTimeRangeRule.Schedule.SetHourRange(dt.Hour, dt.Hour + 1, true);
                }
                else
                {
                    ranges.Values.Add(0);
                    ranges.Y2Values.Add(rand.NextDouble() * 70 + 30.0d);
                    ranges.XValues.Add((dt + new TimeSpan(1, 0, 0)).ToOADate());
                    ranges.X2Values.Add(dt.ToOADate());
                }

                dt += new TimeSpan(1, 0, 0);
            }

            chart.Series.Add(ranges);

            // apply layout
            ConfigureStandardLayout(chart, title, null);

            nChartControl1.Controller.Tools.Add(new NSelectorTool());
            nChartControl1.Controller.Tools.Add(new NAxisScrollTool());
            nChartControl1.Controller.Tools.Add(new NDataZoomTool());
            nChartControl1.Controller.Tools.Add(new NDataPanTool());

            // init form controls
            EnableWorkCalendar.Checked = true;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel header = new NLabel("Range Timeline Scale");

            header.DockMode                   = PanelDockMode.Top;
            header.Margins                    = new NMarginsL(2, 2, 0, 5);
            header.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            header.ContentAlignment           = ContentAlignment.BottomRight;
            header.FitAlignment               = ContentAlignment.MiddleLeft;
            header.Location                   = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));
            nChartControl1.Panels.Add(header);

            // setup chart
            m_Chart = new NCartesianChart();
            nChartControl1.Panels.Add(m_Chart);
            m_Chart.DockMode = PanelDockMode.Fill;
            m_Chart.Margins  = new NMarginsL(2, 0, 2, 2);
            m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);
            m_Chart.LightModel.EnableLighting         = false;
            m_Chart.Axis(StandardAxis.Depth).Visible  = false;
            m_Chart.Wall(ChartWallType.Floor).Visible = false;
            m_Chart.Wall(ChartWallType.Left).Visible  = false;
            m_Chart.BoundsMode = BoundsMode.Stretch;
            m_Chart.Height     = 40;

            // setup X axis
            NAxis axis = m_Chart.Axis(StandardAxis.PrimaryX);

            axis.ScrollBar.Visible = true;
            NRangeTimelineScaleConfigurator timelineScale = new NRangeTimelineScaleConfigurator();

            timelineScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            timelineScale.SecondRow.GridStyle.SetShowAtWall(ChartWallType.Back, true);
            timelineScale.ThirdRow.GridStyle.SetShowAtWall(ChartWallType.Back, true);
            axis.ScaleConfigurator = timelineScale;

            // setup primary Y axis
            axis = m_Chart.Axis(StandardAxis.PrimaryY);
            NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)axis.ScaleConfigurator;

            linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, false);
            linearScale.InnerMajorTickStyle.Length = new NLength(0);

            // add interlaced stripe
            NScaleStripStyle stripStyle = new NScaleStripStyle();

            stripStyle.FillStyle = new NColorFillStyle(Color.Beige);
            stripStyle.SetShowAtWall(ChartWallType.Back, true);
            stripStyle.SetShowAtWall(ChartWallType.Left, true);
            stripStyle.Interlaced = true;
            linearScale.StripStyles.Add(stripStyle);

            // Setup the stock series
            m_Stock = (NStockSeries)m_Chart.Series.Add(SeriesType.Stock);
            m_Stock.DataLabelStyle.Visible = false;
            m_Stock.CandleStyle            = CandleStyle.Stick;
            m_Stock.CandleWidth            = new NLength(0.5f, NRelativeUnit.ParentPercentage);
            m_Stock.UpStrokeStyle.Color    = Color.RoyalBlue;
            m_Stock.Legend.Mode            = SeriesLegendMode.None;
            m_Stock.CloseValues.Name       = "close";
            m_Stock.UseXValues             = true;

            // init form controls
            if (!IsPostBack)
            {
                FirstRowVisibleCheckBox.Checked  = true;
                SecondRowVisibleCheckBox.Checked = true;
                ThirdRowVisibleCheckBox.Checked  = true;

                RandomDataTypeDropDownList.Items.Add("Daily");
                RandomDataTypeDropDownList.Items.Add("Weekly");
                RandomDataTypeDropDownList.Items.Add("Monthly");
                RandomDataTypeDropDownList.Items.Add("Yearly");
                RandomDataTypeDropDownList.SelectedIndex = 2;
            }

            timelineScale.FirstRow.Visible  = FirstRowVisibleCheckBox.Checked;
            timelineScale.SecondRow.Visible = SecondRowVisibleCheckBox.Checked;
            timelineScale.ThirdRow.Visible  = ThirdRowVisibleCheckBox.Checked;

            DateTime      dtNow   = DateTime.Now;
            DateTime      dtEnd   = dtNow;
            DateTime      dtStart = dtNow;
            NDateTimeSpan span    = new NDateTimeSpan();

            switch (RandomDataTypeDropDownList.SelectedIndex)
            {
            case 0:
                // generate data for 30 days
                dtEnd   = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 17, 0, 0, 0);
                dtStart = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0, 0);
                span    = new NDateTimeSpan(5, NDateTimeUnit.Minute);
                break;

            case 1:
                // generate data for 30 weeks
                dtEnd   = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0, 0);
                dtStart = NDateTimeUnit.Week.Add(dtEnd, -30);
                span    = new NDateTimeSpan(1, NDateTimeUnit.Day);
                break;

            case 2:
                // generate data for 30 months
                dtEnd   = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0, 0);
                dtStart = NDateTimeUnit.Month.Add(dtEnd, -30);
                span    = new NDateTimeSpan(1, NDateTimeUnit.Week);
                break;

            case 3:
                // generate data for 30 years
                dtEnd   = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 7, 0, 0, 0);
                dtStart = NDateTimeUnit.Year.Add(dtEnd, -30);
                span    = new NDateTimeSpan(1, NDateTimeUnit.Month);
                break;
            }

            GenerateData(dtStart, dtEnd, span);
        }
Esempio n. 15
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = new NLabel("Gantt Chart");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);

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

            // configure the chart
            NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;
            chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft);
            chart.Axis(StandardAxis.Depth).Visible = false;

            // setup the value axis
            NRangeTimelineScaleConfigurator dateTimeScale = new NRangeTimelineScaleConfigurator();

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

            // fill data
            DateTime start = DateTime.Now;
            DateTime end   = start + new TimeSpan(10, 0, 0, 0);

            TaskCollection tasks = new TaskCollection();

            tasks.Add(new Task("Write Proposal",
                               new DateTime(2001, 4, 1),
                               new DateTime(2001, 4, 5),
                               new uint[] { 1, 2 }));

            tasks.Add(new Task("Obtain Approval",
                               new DateTime(2001, 4, 12),
                               new DateTime(2001, 9, 4),
                               new uint[] { 9 }));

            tasks.Add(new Task("Requirements Analysis",
                               new DateTime(2001, 4, 9),
                               new DateTime(2001, 5, 5),
                               new uint[] { 3 }));

            tasks.Add(new Task("Design Phase",
                               new DateTime(2001, 5, 6),
                               new DateTime(2001, 5, 30),
                               new uint[] { 4 }));

            tasks.Add(new Task("Design Signoff",
                               new DateTime(2001, 6, 2),
                               new DateTime(2001, 6, 2),
                               new uint[] { 5 }));

            tasks.Add(new Task("Alpha Implementation",
                               new DateTime(2001, 6, 3),
                               new DateTime(2001, 7, 31),
                               new uint[] { 6 }));

            tasks.Add(new Task("Design Review",
                               new DateTime(2001, 8, 1),
                               new DateTime(2001, 8, 8),
                               new uint[] { 7 }));

            tasks.Add(new Task("Revised Design Signoff",
                               new DateTime(2001, 8, 10),
                               new DateTime(2001, 8, 10),
                               new uint[] { 8 }));

            tasks.Add(new Task("Beta Implementation",
                               new DateTime(2001, 8, 12),
                               new DateTime(2001, 9, 12),
                               new uint[] { 9 }));

            tasks.Add(new Task("Testing",
                               new DateTime(2001, 9, 13),
                               new DateTime(2001, 10, 31),
                               new uint[] { 10 }));

            tasks.Add(new Task("Final Implementation",
                               new DateTime(2001, 11, 1),
                               new DateTime(2001, 11, 15),
                               new uint[] { 11 }));

            tasks.Add(new Task("Signoff",
                               new DateTime(2001, 11, 28),
                               new DateTime(2001, 11, 30),
                               new uint[] { 12 }));

            tasks.ConfigureChart(chart);

            // apply layout
            ConfigureStandardLayout(chart, title, null);

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

            styleSheet.Apply(nChartControl1.Document);

            nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
            nChartControl1.Controller.Tools.Add(new NFloatBarDragPointTool());

            // init form controls
            ShowGanttConnectorLinesCheckBox.Checked = true;
        }
Esempio n. 16
0
        private NCartesianChart CreateStockChart()
        {
            NCartesianChart chart = new NCartesianChart();

            chart.DockMode            = PanelDockMode.Top;
            chart.Size                = new NSizeL(new NLength(0), new NLength(60, NRelativeUnit.ParentPercentage));
            chart.DockMargins         = new NMarginsL(10, 10, 10, 10);
            chart.BackgroundFillStyle = new NColorFillStyle(Color.FromArgb(125, Color.White));
            chart.BoundsMode          = BoundsMode.Stretch;
            chart.Padding             = new NMarginsL(10, 10, 10, 10);

            // 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 Y axis
            NAxis axis = chart.Axis(StandardAxis.PrimaryY);
            NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)axis.ScaleConfigurator;

            scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            scaleY.MajorGridStyle.SetShowAtWall(ChartWallType.Left, false);
            scaleY.InnerMajorTickStyle.Length = new NLength(0);

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

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

            // setup the stock series
            m_Stock                        = (NStockSeries)chart.Series.Add(SeriesType.Stock);
            m_Stock.Name                   = "Price";
            m_Stock.Legend.Mode            = SeriesLegendMode.None;
            m_Stock.DataLabelStyle.Visible = false;
            m_Stock.CandleStyle            = CandleStyle.Stick;
            m_Stock.UpStrokeStyle.Color    = Color.RoyalBlue;
            m_Stock.OpenValues.Name        = "open";
            m_Stock.HighValues.Name        = "high";
            m_Stock.LowValues.Name         = "low";
            m_Stock.CloseValues.Name       = "close";
            m_Stock.CandleWidth            = new NLength(0.5f, NRelativeUnit.ParentPercentage);
            m_Stock.UseXValues             = true;
            m_Stock.InflateMargins         = true;

            return(chart);
        }
Esempio n. 17
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Bollinger Bands / Envelopes");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.ContentAlignment    = ContentAlignment.BottomCenter;
            title.Location            = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

            // setup chart
            m_Chart            = nChartControl1.Charts[0];
            m_Chart.BoundsMode = BoundsMode.Stretch;
            m_Chart.Location   = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage));
            m_Chart.Size       = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage));

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

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

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

            // setup Y axis
            NAxis axis = m_Chart.Axis(StandardAxis.PrimaryY);
            NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)axis.ScaleConfigurator;

            linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
            linearScale.InnerMajorTickStyle.Length = new NLength(0);

            // Add line series for the upper band
            m_LineUpper = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
            m_LineUpper.DataLabelStyle.Visible = false;
            m_LineUpper.BorderStyle.Color      = Color.Green;
            m_LineUpper.UseXValues             = true;

            // Add line series for lower band
            m_LineLower = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
            m_LineLower.DataLabelStyle.Visible = false;
            m_LineLower.BorderStyle.Color      = Color.Green;
            m_LineLower.UseXValues             = true;

            // Add line series for Simple Moving Average
            m_LineSMA = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
            m_LineSMA.DataLabelStyle.Visible = false;
            m_LineSMA.BorderStyle.Color      = Color.Orange;
            m_LineSMA.Name       = "Simple Moving Average";
            m_LineSMA.UseXValues = true;

            Color color1 = Color.FromArgb(100, 100, 150);
            Color color2 = Color.FromArgb(200, 120, 120);

            // Setup the stock series
            m_Stock = (NStockSeries)m_Chart.Series.Add(SeriesType.Stock);
            m_Stock.DataLabelStyle.Visible = false;
            m_Stock.CandleStyle            = CandleStyle.Stick;
            m_Stock.CandleWidth            = new NLength(0.5f, NRelativeUnit.ParentPercentage);
            m_Stock.UpStrokeStyle.Color    = color1;
            m_Stock.DownStrokeStyle.Color  = color2;
            m_Stock.Legend.Mode            = SeriesLegendMode.None;
            m_Stock.CloseValues.Name       = "close";
            m_Stock.UseXValues             = true;
            m_Stock.InflateMargins         = true;

            // Add arguments
            m_UpperCalculator.Arguments.Add(m_Stock.CloseValues);
            m_LowerCalculator.Arguments.Add(m_Stock.CloseValues);
            m_SMACalculator.Arguments.Add(m_Stock.CloseValues);

            GenerateData();

            // form controls
            m_FunctionCombo.Items.Add("Bollinger Bands");
            m_FunctionCombo.Items.Add("Envelopes");

            m_Updating = false;

            m_FunctionCombo.SelectedIndex = 0;
            m_ShowPricesCheck.Checked     = true;
            m_ShowAverageCheck.Checked    = true;
        }
Esempio n. 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // init form controls
            if (!IsPostBack)
            {
                EnableWeekRuleCheckBox.Checked = true;

                MondayCheckBox.Checked    = true;
                TuesdayCheckBox.Checked   = true;
                WednesdayCheckBox.Checked = true;
                ThursdayCheckBox.Checked  = true;
                FridayCheckBox.Checked    = true;

                EnableMonthDayRuleCheckBox.Checked = true;

                WebExamplesUtilities.FillComboWithValues(MonthDayDropDownList, 1, 31, 1);
                MonthDayWorkingCheckBox.Checked = false;

                ZoomModeDropDownList.Items.Add("First 7 Days");
                ZoomModeDropDownList.Items.Add("First 31 Days");
                ZoomModeDropDownList.SelectedIndex = 0;
            }
            else
            {
                bool enableWeekDays = EnableWeekRuleCheckBox.Checked;

                MondayCheckBox.Enabled    = enableWeekDays;
                TuesdayCheckBox.Enabled   = enableWeekDays;
                WednesdayCheckBox.Enabled = enableWeekDays;
                ThursdayCheckBox.Enabled  = enableWeekDays;
                FridayCheckBox.Enabled    = enableWeekDays;
                SaturdayCheckBox.Enabled  = enableWeekDays;
                SundayCheckBox.Enabled    = enableWeekDays;

                bool enableMonthDayRules = EnableMonthDayRuleCheckBox.Checked;

                MonthDayDropDownList.Enabled    = enableMonthDayRules;
                MonthDayWorkingCheckBox.Enabled = enableMonthDayRules;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = new NLabel("Date Time Work Calendar");

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

            NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;

            // add interlace stripe
            NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
            NScaleStripStyle         stripStyle  = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);

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

            // enable range selection
            NRangeSelection rangeSelection = new NRangeSelection();

            rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper();
            chart.RangeSelections.Add(rangeSelection);

            // enable zooming and scrolling
            chart.Axis(StandardAxis.PrimaryX).PagingView = new NDateTimeAxisPagingView();

            // apply calendar to scale
            NRangeTimelineScaleConfigurator timeline = new NRangeTimelineScaleConfigurator();

            timeline.EnableCalendar = true;
            m_Calendar        = CreateWorkCalendar();
            timeline.Calendar = m_Calendar;
            timeline.ThirdRow.EnableUnitSensitiveFormatting = false;

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

            // generate data for this calendar
            AddData(chart);

            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);
        }
Esempio n. 19
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Moving Averages");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.ContentAlignment    = ContentAlignment.BottomCenter;
            title.Location            = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

            // setup chart
            m_Chart            = nChartControl1.Charts[0];
            m_Chart.BoundsMode = BoundsMode.Stretch;
            m_Chart.Location   = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage));
            m_Chart.Size       = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage));

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

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

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

            // setup Y axis
            NAxis axis = m_Chart.Axis(StandardAxis.PrimaryY);
            NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)axis.ScaleConfigurator;

            linearScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
            linearScale.InnerMajorTickStyle.Length = new NLength(0);

            // line series for the function
            m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
            m_Line.DataLabelStyle.Visible = false;
            m_Line.BorderStyle.Color      = Color.Crimson;
            m_Line.BorderStyle.Width      = new NLength(2, NGraphicsUnit.Pixel);
            m_Line.UseXValues             = true;

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

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

            GenerateData();

            // form controls
            m_bSkipUpdate = true;
            m_ApplyToCombo.SelectedIndex = 3;
            m_bSkipUpdate = false;

            m_FunctionCombo.Items.Add("Simple Moving Average");
            m_FunctionCombo.Items.Add("Weighted Moving Average");
            m_FunctionCombo.Items.Add("Exponential Moving Average");
            m_FunctionCombo.Items.Add("Modified Moving Average");
            m_FunctionCombo.SelectedIndex = 0;
        }
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel header = new NLabel("Range Timeline Scale Advanced<br/><font size = '9pt'>Demonstrates how to use a timeline scale to show date/time information on the X axis</font>");

            header.DockMode             = PanelDockMode.Top;
            header.Margins              = new NMarginsL(0, 10, 0, 10);
            header.TextStyle.TextFormat = TextFormat.XML;
            header.TextStyle.FontStyle  = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            header.ContentAlignment     = ContentAlignment.BottomRight;
            header.Location             = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));
            nChartControl1.Panels.Add(header);

            // setup chart
            m_Chart = new NCartesianChart();
            nChartControl1.Panels.Add(m_Chart);
            m_Chart.DockMode = PanelDockMode.Fill;
            m_Chart.Margins  = new NMarginsL(10, 0, 10, 10);
            m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);
            m_Chart.LightModel.EnableLighting         = false;
            m_Chart.Axis(StandardAxis.Depth).Visible  = false;
            m_Chart.Wall(ChartWallType.Floor).Visible = false;
            m_Chart.Wall(ChartWallType.Left).Visible  = false;
            m_Chart.BoundsMode = BoundsMode.Stretch;
            m_Chart.Height     = 40;

            m_Chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage));
            m_Chart.Size     = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage));

            NRangeSelection rangeSelection = new NRangeSelection();

            rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper();
            m_Chart.RangeSelections.Add(rangeSelection);

            // setup X axis
            NAxis axis = m_Chart.Axis(StandardAxis.PrimaryX);

            axis.ScrollBar.Visible = true;
            NRangeTimelineScaleConfigurator timeLineScale = new NRangeTimelineScaleConfigurator();

            timeLineScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            timeLineScale.SecondRow.GridStyle.SetShowAtWall(ChartWallType.Back, true);
            timeLineScale.ThirdRow.GridStyle.SetShowAtWall(ChartWallType.Back, true);
            axis.ScaleConfigurator = timeLineScale;

            // setup primary Y axis
            axis = m_Chart.Axis(StandardAxis.PrimaryY);
            NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)axis.ScaleConfigurator;

            linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, false);
            linearScale.InnerMajorTickStyle.Length = new NLength(0);

            // add interlaced stripe
            NScaleStripStyle stripStyle = new NScaleStripStyle();

            stripStyle.FillStyle = new NColorFillStyle(Color.Beige);
            stripStyle.SetShowAtWall(ChartWallType.Back, true);
            stripStyle.SetShowAtWall(ChartWallType.Left, true);
            stripStyle.Interlaced = true;
            linearScale.StripStyles.Add(stripStyle);

            // Setup the stock series
            m_Stock = (NStockSeries)m_Chart.Series.Add(SeriesType.Stock);
            m_Stock.DataLabelStyle.Visible = false;
            m_Stock.CandleStyle            = CandleStyle.Stick;
            m_Stock.CandleWidth            = new NLength(0.5f, NRelativeUnit.ParentPercentage);
            m_Stock.UpStrokeStyle.Color    = Color.RoyalBlue;
            m_Stock.Legend.Mode            = SeriesLegendMode.None;
            m_Stock.CloseValues.Name       = "close";
            m_Stock.UseXValues             = true;

            // configure interactivity
            nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
            nChartControl1.Controller.Tools.Add(new NAxisScrollTool());
            nChartControl1.Controller.Tools.Add(new NDataZoomTool());

            // generate some data
            MonthlyDataButton_Click(null, null);

            // init form controls
            FirstRowModeComboBox.FillFromEnum(typeof(TimelineScaleRowTickMode));
            FirstRowModeComboBox.SelectedIndex = (int)TimelineScaleRowTickMode.AutoMinDistance;
            FirstRowUnitComboBox.FillFromEnum(typeof(DateTimeUnit));
            FirstRowUnitComboBox.SelectedIndex = 0;
            FirstRowUnitCountUpDown.Value      = 1;
            FirstRowVisibleCheckBox.Checked    = true;

            SecondRowModeComboBox.FillFromEnum(typeof(TimelineScaleRowTickMode));
            SecondRowModeComboBox.SelectedIndex = (int)TimelineScaleRowTickMode.AutoMinDistance;
            SecondRowUnitComboBox.FillFromEnum(typeof(DateTimeUnit));
            SecondRowUnitComboBox.SelectedIndex = 0;
            SecondRowUnitCountUpDown.Value      = 1;
            SecondRowVisibleCheckBox.Checked    = true;

            ThirdRowModeComboBox.FillFromEnum(typeof(TimelineScaleRowTickMode));
            ThirdRowModeComboBox.SelectedIndex = (int)TimelineScaleRowTickMode.AutoMinDistance;
            ThirdRowUnitComboBox.FillFromEnum(typeof(DateTimeUnit));
            ThirdRowUnitComboBox.SelectedIndex = 0;
            ThirdRowUnitCountUpDown.Value      = 1;
            ThirdRowVisibleCheckBox.Checked    = true;

            TopLevelPaddingUpDown.Value    = (decimal)2;
            BottomLevelPaddingUpDown.Value = (decimal)2;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CandleStyleDropDownList.Items.Add("Candle");
                CandleStyleDropDownList.Items.Add("Stick");
                CandleStyleDropDownList.SelectedIndex = 0;
            }

            const int nNumberOfWeeks  = 20;
            const int nWorkDaysInWeek = 5;
            const int nTotalWorkDays  = nNumberOfWeeks * nWorkDaysInWeek;

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set chart title
            NLabel title = nChartControl1.Labels.AddHeader("Financial Chart");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            title.ContentAlignment           = ContentAlignment.BottomCenter;
            title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

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

            chart.BoundsMode = BoundsMode.Stretch;
            chart.Location   = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(12, NRelativeUnit.ParentPercentage));
            chart.Size       = new NSizeL(new NLength(90, NRelativeUnit.ParentPercentage), new NLength(84, NRelativeUnit.ParentPercentage));
            chart.Height     = 30;

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

            scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            scaleY.MajorGridStyle.LineStyle.Color   = Color.Gray;
            scaleY.MajorGridStyle.ShowAtWalls       = new ChartWallType[] { ChartWallType.Back };

            // add interlaced 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);

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

            // create a line series for the simple moving average
            NLineSeries lineSMA = (NLineSeries)chart.Series.Add(SeriesType.Line);

            lineSMA.Name = "SMA(20)";
            lineSMA.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);
            lineSMA.DataLabelStyle.Visible            = false;
            lineSMA.BorderStyle.Color = Color.DarkOrange;
            lineSMA.UseXValues        = true;

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

            stock.Name                   = "Stock Data";
            stock.Legend.Mode            = SeriesLegendMode.None;
            stock.DataLabelStyle.Visible = false;
            stock.CandleStyle            = CandleStyle.Bar;
            stock.CandleWidth            = new NLength(2, NGraphicsUnit.Point);
            stock.InflateMargins         = true;
            stock.UseXValues             = true;
            stock.UpFillStyle            = new NColorFillStyle(Green);
            stock.UpStrokeStyle.Color    = Color.Black;
            stock.DownFillStyle          = new NColorFillStyle(DarkOrange);
            stock.DownStrokeStyle.Color  = Color.Black;

            // add the bollinger bands as high low area
            NHighLowSeries highLow = (NHighLowSeries)chart.Series.Add(SeriesType.HighLow);

            highLow.Name = "BB(20, 2)";
            highLow.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);
            highLow.DataLabelStyle.Visible            = false;
            highLow.HighFillStyle         = new NColorFillStyle(Color.FromArgb(80, 130, 134, 168));
            highLow.HighBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
            highLow.UseXValues            = true;

            // generate some stock data
            WebExamplesUtilities.GenerateOHLCData(stock, 400, nTotalWorkDays + 20);
            FillStockDates(stock, nTotalWorkDays + 20);

            // create a function calculator
            NFunctionCalculator fc = new NFunctionCalculator();

            stock.CloseValues.Name = "close";
            fc.Arguments.Add(stock.CloseValues);

            // calculate the bollinger bands
            fc.Expression      = "BOLLINGER(close; 20; 2)";
            highLow.HighValues = fc.Calculate();

            fc.Expression     = "BOLLINGER(close; 20; -2)";
            highLow.LowValues = fc.Calculate();

            // calculate the simple moving average
            fc.Expression  = "SMA(close; 20)";
            lineSMA.Values = fc.Calculate();

            // remove data that won't be charted
            stock.HighValues.RemoveRange(0, 20);
            stock.LowValues.RemoveRange(0, 20);
            stock.OpenValues.RemoveRange(0, 20);
            stock.CloseValues.RemoveRange(0, 20);
            stock.XValues.RemoveRange(0, 20);

            highLow.HighValues.RemoveRange(0, 20);
            highLow.LowValues.RemoveRange(0, 20);
            highLow.XValues = (NDataSeriesDouble)stock.XValues.Clone();

            lineSMA.Values.RemoveRange(0, 20);
            lineSMA.XValues = (NDataSeriesDouble)stock.XValues.Clone();

            stock.CandleStyle = (CandleStyle)CandleStyleDropDownList.SelectedIndex;
            lineSMA.Visible   = SMACheckBox.Checked;
            highLow.Visible   = SBBCheckBox.Checked;
        }
Esempio n. 22
0
        private void CreateWorkCalendar()
        {
            if (m_Updating)
            {
                return;
            }

            if (m_Chart != null)
            {
                m_Chart.Axis(StandardAxis.PrimaryX).PagingView.Enabled = false;
                m_Chart.Axis(StandardAxis.PrimaryY).PagingView.Enabled = false;
            }

            // create calendar
            m_Calendar = new NWorkCalendar();

            // use week days
            if (EnableWeekRuleCheckBox.Checked)
            {
                NWeekDayRule weekDayRule = new NWeekDayRule();

                WeekDayBit weekDays = WeekDayBit.None;
                if (MondayCheckBox.Checked)
                {
                    weekDays |= WeekDayBit.Monday;
                }

                if (TuesdayCheckBox.Checked)
                {
                    weekDays |= WeekDayBit.Tuesday;
                }

                if (WednesdayCheckBox.Checked)
                {
                    weekDays |= WeekDayBit.Wednesday;
                }

                if (ThursdayCheckBox.Checked)
                {
                    weekDays |= WeekDayBit.Thursday;
                }

                if (FridayCheckBox.Checked)
                {
                    weekDays |= WeekDayBit.Friday;
                }

                if (SaturdayCheckBox.Checked)
                {
                    weekDays |= WeekDayBit.Saturday;
                }

                if (SundayCheckBox.Checked)
                {
                    weekDays |= WeekDayBit.Sunday;
                }

                if (weekDays == WeekDayBit.None)
                {
                    // cannot select all week days as non working as this leads to a scale with no
                    // working days...
                    MessageBox.Show("You cannot select all weekdays as non working.");
                    return;
                }

                weekDayRule.WeekDays = weekDays;
                weekDayRule.Schedule.SetHourRange(0, 24, false);
                m_Calendar.Rules.Add(weekDayRule);
            }

            if (EnableMonthDayRuleCheckBox.Checked)
            {
                NMonthDayRule monthDayRule = new NMonthDayRule();

                monthDayRule.Months = MonthBit.January |
                                      MonthBit.February |
                                      MonthBit.March |
                                      MonthBit.April |
                                      MonthBit.May |
                                      MonthBit.June |
                                      MonthBit.July |
                                      MonthBit.August |
                                      MonthBit.September |
                                      MonthBit.October |
                                      MonthBit.November |
                                      MonthBit.December;

                monthDayRule.Day     = (int)MonthDayUpDown.Value;
                monthDayRule.Working = WorkRadioButton.Checked;
                m_Calendar.Rules.Add(monthDayRule);
            }

            // apply calendar to scale
            NRangeTimelineScaleConfigurator timeline = new NRangeTimelineScaleConfigurator();

            timeline.FirstRow.GridStyle.ShowAtWalls  = new ChartWallType[] { ChartWallType.Back };
            timeline.FirstRow.GridStyle.LineStyle    = new NStrokeStyle(1, Color.FromArgb(225, 225, 225));
            timeline.FirstRow.UseGridStyle           = true;
            timeline.SecondRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
            timeline.SecondRow.GridStyle.LineStyle   = new NStrokeStyle(1, Color.FromArgb(215, 215, 215));
            timeline.SecondRow.UseGridStyle          = true;
            timeline.ThirdRow.GridStyle.ShowAtWalls  = new ChartWallType[] { ChartWallType.Back };
            timeline.ThirdRow.GridStyle.LineStyle    = new NStrokeStyle(1, Color.FromArgb(205, 205, 205));
            timeline.ThirdRow.UseGridStyle           = true;

            timeline.EnableCalendar = true;
            timeline.Calendar       = m_Calendar;
            timeline.ThirdRow.EnableUnitSensitiveFormatting = false;

            if (m_Chart != null)
            {
                m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = timeline;
            }

            // generate data for this calendar
            AddData();

            if (nChartControl1 != null)
            {
                nChartControl1.Refresh();
            }
        }