예제 #1
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);
        }
예제 #2
0
        private void GenerateData(NStockSeries s, NWorkCalendar calendar, double dPrevClose, int nCount)
        {
            DateTime  now = DateTime.Now;
            NTimeline timeline = calendar.CreateTimeline(new NDateTimeRange(now, now + new TimeSpan(730, 0, 0, 0, 0)));
            double    open, high, low, close;

            s.ClearDataPoints();

            Random random = new Random();

            for (int nIndex = 0; nIndex < nCount; nIndex++)
            {
                open = dPrevClose;

                if (dPrevClose < 25 || random.NextDouble() > 0.5)
                {
                    // upward price change
                    close = open + (2 + (random.NextDouble() * 20));
                    high  = close + (random.NextDouble() * 10);
                    low   = open - (random.NextDouble() * 10);
                }
                else
                {
                    // downward price change
                    close = open - (2 + (random.NextDouble() * 20));
                    high  = open + (random.NextDouble() * 10);
                    low   = close - (random.NextDouble() * 10);
                }

                if (low < 1)
                {
                    low = 1;
                }

                dPrevClose = close;

                s.OpenValues.Add(open);
                s.HighValues.Add(high);
                s.LowValues.Add(low);
                s.CloseValues.Add(close);
                s.XValues.Add(now.ToOADate());

                // advance to next working day
                now = timeline.AddTimeSpan(now, new NDateTimeSpan(1, NDateTimeUnit.Day));
            }
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Weekly Schedule Work Calendar";

            // configure chart
            m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);

            NRangeSeries ranges = new NRangeSeries();

            m_Chart.Series.Add(ranges);

            ranges.DataLabelStyle = new NDataLabelStyle(false);
            ranges.UseXValues     = true;

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

            NRangeTimelineScale rangeTimeline = new NRangeTimelineScale();

            rangeTimeline.EnableCalendar = true;
            m_Chart.Axes[ENCartesianAxis.PrimaryX].Scale = rangeTimeline;

            NLinearScale yScale = (NLinearScale)m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale;

            yScale.MajorGridLines.Visible = true;

            // add interlaced strip
            NScaleStrip strip = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);

            strip.Interlaced = true;
            yScale.Strips.Add(strip);

            yScale.Title.Text = "Weekly Workload in %";

            NWorkCalendar workCalendar = rangeTimeline.Calendar;

            // show only the working days on the scale
            NWeekDayRule weekDayRule = new NWeekDayRule(ENWeekDayBit.Monday | ENWeekDayBit.Tuesday | ENWeekDayBit.Wednesday | ENWeekDayBit.Thursday | ENWeekDayBit.Friday);

            workCalendar.Rules.Add(weekDayRule);

            // generate data for week working days
            for (int i = 0; i < 21; i++)
            {
                if (dt.DayOfWeek != DayOfWeek.Saturday && dt.DayOfWeek != DayOfWeek.Sunday)
                {
                    ranges.DataPoints.Add(new NRangeDataPoint(NDateTimeHelpers.ToOADate(dt), 0, NDateTimeHelpers.ToOADate(dt + new TimeSpan(1, 0, 0, 0)), rand.NextDouble() * 70 + 30.0d));
                }

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

            ConfigureInteractivity(m_Chart);

            chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false));

            return(chartView);
        }
예제 #4
0
        private void AddData(NCartesianChart chart, NWorkCalendar calendar)
        {
            const int nNumberOfWeeks  = 20;
            const int nWorkDaysInWeek = 5;
            const int nTotalWorkDays  = nNumberOfWeeks * nWorkDaysInWeek;
            const int nHistoricalDays = 20;

            NLineSeries lineSMA = new NLineSeries();

            lineSMA.Name = "SMA(20)";
            lineSMA.DataLabelStyle.Visible = false;
            lineSMA.BorderStyle.Color      = Color.DarkOrange;
            lineSMA.UseXValues             = true;

            // create the stock series
            NStockSeries stock = new NStockSeries();

            chart.Series.Add(stock);
            stock.DisplayOnAxis(StandardAxis.PrimaryX, true);

            stock.Name                   = "Stock Data";
            stock.Legend.Mode            = SeriesLegendMode.None;
            stock.DataLabelStyle.Visible = false;
            stock.CandleStyle            = CandleStyle.Bar;
            stock.CandleWidth            = new NLength(0.8f, NRelativeUnit.ParentPercentage);
            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;
            stock.OpenValues.Name        = "open";
            stock.CloseValues.Name       = "close";
            stock.HighValues.Name        = "high";
            stock.LowValues.Name         = "low";

            int period = 20;

            // add the bollinger bands as high low area
            NHighLowSeries highLow = new NHighLowSeries();

            chart.Series.Add(highLow);
            highLow.DisplayOnAxis(StandardAxis.SecondaryX, true);

            highLow.Name = "BB(" + period.ToString() + ", 2)";
            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
            GenerateData(stock, calendar, 300, nTotalWorkDays + nHistoricalDays);

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

            fc.Arguments.Add(stock.CloseValues);

            // calculate the bollinger bands
            fc.Expression           = "BOLLINGER(close;" + period.ToString() + "; 2)";
            highLow.HighValues      = fc.Calculate();
            highLow.HighValues.Name = "BollingerUpper";

            fc.Expression          = "BOLLINGER(close; " + period.ToString() + "; -2)";
            highLow.LowValues      = fc.Calculate();
            highLow.LowValues.Name = "BollingerLower";
            highLow.XValues.InsertRange(0, stock.XValues);

            // calculate the simple moving average
            fc.Expression  = "SMA(close; " + period.ToString() + ")";
            lineSMA.Values = fc.Calculate();
            lineSMA.XValues.InsertRange(0, stock.XValues);

            // remove first period from line SMA
            lineSMA.Values.RemoveRange(0, period);
            lineSMA.XValues.RemoveRange(0, period);

            // remove first period from high low
            highLow.XValues.RemoveRange(0, period);
            highLow.HighValues.RemoveRange(0, period);
            highLow.LowValues.RemoveRange(0, period);

            // remove first period from stock
            stock.OpenValues.RemoveRange(0, period);
            stock.HighValues.RemoveRange(0, period);
            stock.LowValues.RemoveRange(0, period);
            stock.CloseValues.RemoveRange(0, period);
            stock.XValues.RemoveRange(0, period);
        }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Daily Schedule Work Calendar";

            // configure chart
            m_Chart = (NCartesianChart)chartView.Surface.Charts[0];
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);

            NRangeSeries ranges = new NRangeSeries();

            m_Chart.Series.Add(ranges);

            ranges.DataLabelStyle = new NDataLabelStyle(false);
            ranges.UseXValues     = true;

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

            NRangeTimelineScale rangeTimeline = new NRangeTimelineScale();

            rangeTimeline.EnableCalendar                 = true;
            rangeTimeline.InflateViewRangeEnd            = false;
            rangeTimeline.InflateViewRangeBegin          = false;
            m_Chart.Axes[ENCartesianAxis.PrimaryX].Scale = rangeTimeline;

            NLinearScale yScale = (NLinearScale)m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale;

            yScale.MajorGridLines.Visible = true;

            // add interlaced strip
            NScaleStrip strip = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);

            strip.Interlaced = true;
            yScale.Strips.Add(strip);

            yScale.Title.Text = "Daily Workload in %";

            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.DataPoints.Add(new NRangeDataPoint(NDateTimeHelpers.ToOADate(dt), 0, NDateTimeHelpers.ToOADate(dt + new TimeSpan(1, 0, 0)), rand.NextDouble() * 70 + 30.0d));
                }

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

            ConfigureInteractivity(m_Chart);

            chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false));

            return(chartView);
        }
예제 #6
0
        private NWorkCalendar CreateWorkCalendar()
        {
            // create calendar
            NWorkCalendar 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.Equals(WeekDayBit.None)))
                {
                    // cannot select all week days as non working as this leads to a scale with no
                    // working days...
                    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     = MonthDayDropDownList.SelectedIndex + 1;
                monthDayRule.Working = MonthDayWorkingCheckBox.Checked;
                m_Calendar.Rules.Add(monthDayRule);
            }

            return(m_Calendar);
        }
예제 #7
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);
        }
        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;
        }
예제 #9
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();
            }
        }