コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Range Timeline Scale";

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

            // configure axes
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);

            // setup X axis
            NCartesianAxis axis = m_Chart.Axes[ENCartesianAxis.PrimaryX];

            m_RangeTimelineScale = new NRangeTimelineScale();
            axis.Scale           = m_RangeTimelineScale;

            // setup primary Y axis
            axis = m_Chart.Axes[ENCartesianAxis.PrimaryY];
            NLinearScale linearScale = (NLinearScale)axis.Scale;

            // configure ticks and grid lines
            linearScale.MajorGridLines.Stroke   = new NStroke(NColor.LightGray);
            linearScale.InnerMajorTicks.Visible = false;

            // add interlaced stripe
            NScaleStrip strip = new NScaleStrip();

            strip.Fill       = new NColorFill(NColor.Beige);
            strip.Interlaced = true;
            linearScale.Strips.Add(strip);

            // Setup the stock series
            m_Stock = new NStockSeries();
            m_Chart.Series.Add(m_Stock);

            m_Stock.DataLabelStyle = new NDataLabelStyle(false);
            m_Stock.CandleShape    = ENCandleShape.Stick;
            m_Stock.CandleWidth    = 4;
            m_Stock.UseXValues     = true;

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

            OnWeeklyDataButtonClick(null);

            return(chartView);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }