private NDateTimeAxisPagingView GetHorizontalAxisPagingView() { NDateTimeAxisPagingView view = null; DateTime dt = new DateTime(2005, 5, 24, 11, 0, 0); switch (HorizontalPageSizeComboBox.SelectedIndex) { case 0: view = new NDateTimeAxisPagingView(dt, new NDateTimeSpan(1, NDateTimeUnit.Month)); break; case 1: view = new NDateTimeAxisPagingView(dt, new NDateTimeSpan(2, NDateTimeUnit.Month)); break; case 2: view = new NDateTimeAxisPagingView(dt, new NDateTimeSpan(3, NDateTimeUnit.Month)); break; default: Debug.Assert(false); break; } return(view); }
private void UpdateAxis() { if (m_Chart == null || m_Updating) { return; } m_Updating = true; NAxis axis = m_Chart.Axis(StandardAxis.PrimaryX); NDateTimeAxisPagingView pagingView = axis.PagingView as NDateTimeAxisPagingView; if (pagingView != null) { axis.ScrollBar.Visible = ShowScrollbarCheckBox.Checked; pagingView.Begin = StartDateTimePicker.Value; pagingView.Length = new NDateTimeSpan((int)BottomAxisPageSizeNumericUpDown.Value, NDateTimeUnit.Month); pagingView.AutoSmallChange = AutoSmallChangeCheckBox.Checked; pagingView.SmallChange = new NDateTimeSpan((long)SmallChangeNumericUpDown.Value, NDateTimeUnit.Day); } nChartControl1.Refresh(); m_Updating = false; }
protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { HighLightRangeDropDownList.Items.Add("Weekdays"); HighLightRangeDropDownList.Items.Add("Weekends"); HighLightRangeDropDownList.SelectedIndex = 0; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Strip Lines"); header.TextStyle.TextFormat = TextFormat.XML; 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)); // configure chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(13, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL( new NLength(94, NRelativeUnit.ParentPercentage), new NLength(85, NRelativeUnit.ParentPercentage)); // Add a line series NLineSeries line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); line.UseXValues = true; line.BorderStyle.Color = Color.DarkRed; line.DataLabelStyle.Visible = false; line.InflateMargins = true; line.MarkerStyle.Visible = true; line.MarkerStyle.BorderStyle.Color = Color.DarkRed; line.MarkerStyle.FillStyle = new NColorFillStyle(Color.Red); line.MarkerStyle.PointShape = PointShape.Cylinder; line.MarkerStyle.Width = new NLength(2, NRelativeUnit.ParentPercentage); line.MarkerStyle.Height = new NLength(2, NRelativeUnit.ParentPercentage); line.Legend.Mode = SeriesLegendMode.None; // create a date time scale NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator(); dateTimeScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.View, 90); dateTimeScale.LabelStyle.ContentAlignment = ContentAlignment.MiddleLeft; dateTimeScale.EnableUnitSensitiveFormatting = false; dateTimeScale.MajorTickMode = MajorTickMode.CustomStep; dateTimeScale.CustomStep = new NDateTimeSpan(1, NDateTimeUnit.Day); dateTimeScale.LabelValueFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.WeekDayShortName); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale; // create a strip line highlighting the working days NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(125, Color.Orange)), null, true, 0, 0, 2, 5); stripStyle.SetShowAtWall(ChartWallType.Back, true); NDateTimeRangeSamplerProvider provider = new NDateTimeRangeSamplerProvider(); provider.SamplingMode = SamplingMode.CustomStep; provider.UseOrigin = true; provider.Origin = new DateTime(2007, 2, 19); provider.CustomStep = new NDateTimeSpan(1, NDateTimeUnit.Day); stripStyle.RangeSamplerProvider = provider; // configure the x axis to use date time paging NDateTimeAxisPagingView dateTimePagingView = new NDateTimeAxisPagingView(DateTime.Now, new NDateTimeSpan(10, NDateTimeUnit.Day)); dateTimePagingView.Enabled = true; m_Chart.Axis(StandardAxis.PrimaryX).PagingView = dateTimePagingView; GenerateData(null, null); if (!Page.IsPostBack) { HighLightRangeDropDownList.SelectedIndex = 0; } UpdateHighlightRange(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Strip Lines"); title.TextStyle.TextFormat = TextFormat.XML; 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)); // no legend nChartControl1.Legends.Clear(); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; // Add a line series NLineSeries line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); line.UseXValues = true; line.BorderStyle.Color = Color.DarkRed; line.DataLabelStyle.Visible = false; line.InflateMargins = true; line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Cylinder; line.MarkerStyle.Width = new NLength(2, NRelativeUnit.ParentPercentage); line.MarkerStyle.Height = new NLength(2, NRelativeUnit.ParentPercentage); // create a date time scale NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator(); dateTimeScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 90); dateTimeScale.LabelStyle.ContentAlignment = ContentAlignment.MiddleLeft; dateTimeScale.EnableUnitSensitiveFormatting = false; dateTimeScale.MajorTickMode = MajorTickMode.CustomStep; dateTimeScale.CustomStep = new NDateTimeSpan(1, NDateTimeUnit.Day); dateTimeScale.LabelValueFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.WeekDayShortName); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale; // create a strip line highlighting the working days NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 2, 5); stripStyle.SetShowAtWall(ChartWallType.Back, true); NDateTimeRangeSamplerProvider provider = new NDateTimeRangeSamplerProvider(); provider.SamplingMode = SamplingMode.CustomStep; provider.UseOrigin = true; provider.Origin = new DateTime(2007, 2, 19); provider.CustomStep = new NDateTimeSpan(1, NDateTimeUnit.Day); stripStyle.RangeSamplerProvider = provider; // configure the x axis to use date time paging NDateTimeAxisPagingView dateTimePagingView = new NDateTimeAxisPagingView(DateTime.Now, new NDateTimeSpan(10, NDateTimeUnit.Day)); dateTimePagingView.Enabled = true; m_Chart.Axis(StandardAxis.PrimaryX).PagingView = dateTimePagingView; m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.ResetButton.Visible = false; nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); HighLightRangeComboBox.Items.Add("Weekdays"); HighLightRangeComboBox.Items.Add("Weekends"); HighLightRangeComboBox.SelectedIndex = 0; GenerateData(null, null); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Date / Time Axis Paging"); 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)); // no legend nChartControl1.Legends.Clear(); // setup chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; // configure the X and Y axes to use linear scale without tick rounding NValueTimelineScaleConfigurator timelineScale = new NValueTimelineScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = timelineScale; timelineScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.ResetButton.Visible = false; m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.ShowSliders = false; // add interlace stripe to the X axis NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(40, Color.LightGray)), null, true, 0, 0, 1, 1); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); timelineScale.StripStyles.Add(stripStyle); NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; // add interlace stripe to the Y axis stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(40, Color.LightGray)), null, true, 0, 0, 1, 1); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.StripStyles.Add(stripStyle); // configure a XY scatter point chart NPointSeries point = (NPointSeries)m_Chart.Series.Add(SeriesType.Point); point.UseXValues = true; point.Size = new NLength(5, NGraphicsUnit.Point); point.DataLabelStyle.Visible = false; point.Values.FillRandomRange(Random, 100, 0, 100); DateTime now = DateTime.Now; // add data for ten thousand days from now for (int i = 0; i < 1000; i++) { point.XValues.Add(now + new TimeSpan(i * 10, 0, 0, 0, 0)); } // configure the x and y axis paging NDateTimeAxisPagingView dateTimePagingView = new NDateTimeAxisPagingView(now, new NDateTimeSpan(1, NDateTimeUnit.Month)); dateTimePagingView.Enabled = true; m_Chart.Axis(StandardAxis.PrimaryX).PagingView = dateTimePagingView; // subscribe for the scrollbar value changed event m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.BeginValueChanged += new EventHandler(ScrollbarValueChanged); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); m_Updating = true; StartDateTimePicker.Value = now; BottomAxisPageSizeNumericUpDown.Value = 2; ShowScrollbarCheckBox.Checked = true; AutoSmallChangeCheckBox.Checked = true; m_Updating = false; nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Refresh(); UpdateAxis(); }