public override void Initialize() { base.Initialize(); // set a chart title NLabel title = new NLabel("Date Time Work Calendar<br/><font size = '9pt'>Demonstrates how to skip date time ranges using Week and Month rules</font>"); title.TextStyle.TextFormat = TextFormat.XML; title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); nChartControl1.Panels.Add(title); m_Chart = (NCartesianChart)nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; // add interlace stripes NLinearScaleConfigurator linearScale = m_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); // enable range selection NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); m_Chart.RangeSelections.Add(rangeSelection); // enable zooming and scrolling m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; m_Chart.Axis(StandardAxis.PrimaryX).PagingView = new NDateTimeAxisPagingView(); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); nChartControl1.Controller.Tools.Add(new NDataPanTool()); // apply layout ConfigureStandardLayout(m_Chart, title, null); // update form controls m_Updating = true; EnableWeekRuleCheckBox.Checked = true; MondayCheckBox.Checked = true; TuesdayCheckBox.Checked = true; WednesdayCheckBox.Checked = true; ThursdayCheckBox.Checked = true; FridayCheckBox.Checked = true; EnableMonthDayRuleCheckBox.Checked = true; MonthDayUpDown.Value = 1; WorkRadioButton.Checked = true; m_Updating = false; CreateWorkCalendar(); }
private void ConfigureRangeSelections() { NRangeSelection stockValueRangeSelection = new NRangeSelection(); NRangeSelection stockVolumeRangeSelection = new NRangeSelection(); stockValueRangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); stockVolumeRangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); // each range selection is master of the other. When the users click on one of the // charts this will result in an automatic update of the other range selection. stockValueRangeSelection.Slaves.Add(stockVolumeRangeSelection); stockVolumeRangeSelection.Slaves.Add(stockValueRangeSelection); m_ChartStockValues.RangeSelections.Add(stockValueRangeSelection); m_ChartStockVolumes.RangeSelections.Add(stockVolumeRangeSelection); }
private void UpdateDataZoomTool() { NCartesianChart chart = (NCartesianChart)(nChartControl1.Charts[0]); chart.RangeSelections.Clear(); NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.MinHorizontalPageSize = 0; rangeSelection.MinVerticalPageSize = 0; rangeSelection.ZoomOutResetsAxis = ZoomOutResetsAxesCheckBox.Checked; if (SelectionAxesComboBox.SelectedIndex == 0) { rangeSelection.HorizontalAxisId = (int)StandardAxis.PrimaryX; rangeSelection.VerticalAxisId = (int)StandardAxis.PrimaryY; } else { rangeSelection.HorizontalAxisId = (int)StandardAxis.Depth; rangeSelection.VerticalAxisId = (int)StandardAxis.PrimaryY; } rangeSelection.PreserveAspectRatio = PreserveAspectRatioCheckBox.Checked; rangeSelection.HorizontalValueSnapper = GetAxisValueSnapperFromIndex(HorizontalAxisSnapModeComboBox.SelectedIndex); rangeSelection.VerticalValueSnapper = GetAxisValueSnapperFromIndex(VerticalAxisSnapModeComboBox.SelectedIndex); rangeSelection.ZoomOutResetsAxis = ZoomOutResetsAxesCheckBox.Checked; chart.RangeSelections.Add(rangeSelection); m_DataZoomTool.AlwaysZoomIn = AlwaysZoomInCheckBox.Checked; if (WheelZoomCheckBox.Checked) { m_DataZoomTool.WheelZoomAtMouse = true; m_DataZoomTool.BeginDragMouseCommand = new NMouseCommand(MouseAction.Wheel, MouseButton.None, 0); } else { m_DataZoomTool.BeginDragMouseCommand = new NMouseCommand(MouseAction.Down, MouseButton.Left, 1); } }
void UpdateDataWindow(string webControlId, System.Web.HttpContext context, NStateObject state, NPointF ptViewPoint) { NChartSessionStateObject chartState = state as NChartSessionStateObject; NRootPanel rootPanel = chartState.Document.RootPanel; NCartesianChart chart = rootPanel.Charts[0] as NCartesianChart; NVector2DD vecScalePoint = new NVector2DD(); NAxis xAxis = chart.Axis(StandardAxis.PrimaryX); NAxis yAxis = chart.Axis(StandardAxis.PrimaryY); using (NChartRasterView view = new NChartRasterView(chartState.Document, chartState.Size, NResolution.ScreenResolution)) { view.RecalcLayout(); NViewToScale2DTransformation viewToScale = new NViewToScale2DTransformation( view.Context, chart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY ); if (viewToScale.Transform(ptViewPoint, ref vecScalePoint)) { double rangeMin = vecScalePoint.X - DataWindowWidth / 2; rangeMin = xAxis.Scale.ViewRange.GetValueInRange(rangeMin); double rangeMax = rangeMin + DataWindowWidth; rangeMax = xAxis.Scale.ViewRange.GetValueInRange(rangeMax); rangeMin = rangeMax - DataWindowWidth; NRangeSelection selection = chart.RangeSelections[0] as NRangeSelection; selection.HorizontalAxisRange = new NRange1DD(rangeMin, rangeMax); selection.VerticalAxisRange = new NRange1DD(-waveDataWave1Factor, waveDataWave1Factor); } } }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Dynamic Y Axis Range"); 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)); NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rangeSelection); ChartTypeComboBox.Items.Add("Area"); ChartTypeComboBox.Items.Add("Bar"); ChartTypeComboBox.Items.Add("Box And Whiskers"); ChartTypeComboBox.Items.Add("Error Bar"); ChartTypeComboBox.Items.Add("Float Bar"); ChartTypeComboBox.Items.Add("Line"); ChartTypeComboBox.Items.Add("Point"); ChartTypeComboBox.Items.Add("Stock"); ChartTypeComboBox.SelectedIndex = 0; // enable interactivity nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); }
void CreatePreviewChart() { nChartControl1.HttpHandlerCallback = new PreviewHttpHandlerCallback(); if (nChartControl1.RequiresInitialization) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Legends.Clear(); // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Wave Preview"); 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(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage)); // setup a Smooth Line chart NCartesianChart chart = nChartControl1.Charts[0] as NCartesianChart; chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL( new NLength(4, NRelativeUnit.ParentPercentage), new NLength(25, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(88, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); // setup X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.InnerMajorTickStyle.Visible = false; // add interlace stripe to the Y axis NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(0xfe, 0xed, 0xe2)), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); scaleY.StripStyles.Add(stripStyle); // add the line NSmoothLineSeries line = (NSmoothLineSeries)chart.Series.Add(SeriesType.SmoothLine); line.Name = "Wave"; line.Legend.Mode = SeriesLegendMode.None; line.UseXValues = false; line.UseZValues = false; line.InflateMargins = true; line.DataLabelStyle.Visible = false; line.MarkerStyle.Visible = false; line.BorderStyle.Width = new NLength(1, NGraphicsUnit.Pixel); // initialize data points for (int i = 0; i < waveDataLenth; i++) { line.Values.Add(waveData[i]); } // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // select a default window NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron); Color selectionBorderColor = palette.SeriesColors[2]; Color selectionFillColor = Color.FromArgb(64, palette.SeriesColors[1]); NRangeSelection selection = new NRangeSelection((int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY); selection.BorderStyle = new NStrokeStyle(1, selectionBorderColor); selection.FillStyle = new NColorFillStyle(selectionFillColor); selection.HorizontalAxisRange = new NRange1DD(0, defaultDataWindowWidth); selection.VerticalAxisRange = new NRange1DD(-waveDataWave1Factor, waveDataWave1Factor); selection.Visible = true; chart.RangeSelections.Add(selection); } }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Time Span Scale"); 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(); // setup chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // add a range selection, snapped to the vertical axis min/max values NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rangeSelection); // add interlaced stripe to the Y axis 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); // Add a line series m_Line = new NLineSeries(); chart.Series.Add(m_Line); m_Line.UseXValues = true; m_Line.UseXValues = true; m_Line.DataLabelStyle.Visible = false; m_Line.SamplingMode = SeriesSamplingMode.Enabled; // create a date time scale m_TimeSpanScale = new NTimeSpanScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = m_TimeSpanScale; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); NAxis xAxis = chart.Axis(StandardAxis.PrimaryX); xAxis.ScrollBar.Visible = true; // init form controls EnableUnitSensitiveFormattingCheckBox.Checked = true; MillisecondCheckBox.Checked = true; SecondCheckBox.Checked = true; MinuteCheckBox.Checked = true; HourCheckBox.Checked = true; DayCheckBox.Checked = true; WeekCheckBox.Checked = true; UpdateDateTimeScale(); StepUnitComboBox.Items.Add("Millisecond"); StepUnitComboBox.Items.Add("Second"); StepUnitComboBox.Items.Add("Minute"); StepUnitComboBox.Items.Add("Hour"); StepUnitComboBox.Items.Add("Day"); StepUnitComboBox.Items.Add("Week"); StepUnitComboBox.SelectedIndex = 2; timer1.Start(); nChartControl1.Refresh(); }
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; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Stock Data Grouping"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); // no legend nChartControl1.Legends.Clear(); // setup chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; NRangeSelection rs = new NRangeSelection(); rs.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rs); // setup X axis NValueTimelineScaleConfigurator scaleX = new NValueTimelineScaleConfigurator(); 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.FirstRow.InnerTickStyle.Visible = false; 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.SecondRow.InnerTickStyle.Visible = false; scaleX.ThirdRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.ThirdRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(205, 205, 205)); scaleX.ThirdRow.UseGridStyle = true; scaleX.ThirdRow.InnerTickStyle.Visible = false; // 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; chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.OuterMajorTickStyle.Length = new NLength(3, NGraphicsUnit.Point); scaleY.InnerMajorTickStyle.Visible = false; NFillStyle stripFill = new NColorFillStyle(Color.FromArgb(234, 233, 237)); NScaleStripStyle stripStyle = new NScaleStripStyle(stripFill, null, true, 1, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; stripStyle.Interlaced = true; scaleY.StripStyles.Add(stripStyle); // setup stock series m_Stock = (NStockSeries)chart.Series.Add(SeriesType.Stock); m_Stock.DataLabelStyle.Visible = false; m_Stock.UpFillStyle = new NColorFillStyle(Color.White); m_Stock.UpStrokeStyle.Color = Color.Black; m_Stock.DownFillStyle = new NColorFillStyle(Color.Crimson); m_Stock.DownStrokeStyle.Color = Color.Crimson; m_Stock.HighLowStrokeStyle.Color = Color.Black; m_Stock.CandleWidth = new NLength(1.2f, NRelativeUnit.ParentPercentage); m_Stock.UseXValues = true; m_Stock.InflateMargins = true; m_Stock.DataLabelStyle.Format = "open - <open>\r\nclose - <close>"; // add some stock items const int numDataPoints = 10000; GenerateOHLCData(m_Stock, 100.0, numDataPoints, new NRange1DD(60, 140)); FillStockDates(m_Stock, numDataPoints, DateTime.Now - new TimeSpan((int)(numDataPoints * 1.2), 0, 0, 0)); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); // apply layout ConfigureStandardLayout(chart, title, null); // update form controls CustomDateTimeSpanComboBox.Items.Add("1 Week"); CustomDateTimeSpanComboBox.Items.Add("2 Weeks"); CustomDateTimeSpanComboBox.Items.Add("1 Month"); CustomDateTimeSpanComboBox.Items.Add("3 Months"); NExampleHelpers.FillComboWithEnumValues(GroupingModeComboBox, typeof(StockGroupingMode)); CustomDateTimeSpanComboBox.SelectedIndex = 2; GroupingModeComboBox.SelectedIndex = (int)StockGroupingMode.AutoDateTimeSpan; }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Company Sales by Region<br/><font size = '9pt'>Demonstrates how to use custom range labels to denote ranges on a scale</font>"); header.DockMode = PanelDockMode.Top; header.Margins = new NMarginsL(0, 10, 0, 10); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); header.TextStyle.TextFormat = TextFormat.XML; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); nChartControl1.Panels.Add(header); NLegend legend = new NLegend(); legend.Margins = new NMarginsL(10, 0, 10, 0); legend.DockMode = PanelDockMode.Right; legend.FitAlignment = ContentAlignment.TopCenter; nChartControl1.Panels.Add(legend); NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.DisplayOnLegend = legend; chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; chart.Margins = new NMarginsL(10, 0, 0, 10); chart.Axis(StandardAxis.Depth).Visible = false; // add range selection NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rangeSelection); // add the first bar m_Bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); m_Bar1.Name = "Coca Cola"; m_Bar1.MultiBarMode = MultiBarMode.Series; m_Bar1.DataLabelStyle.Format = "<value>"; // add the second bar m_Bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); m_Bar2.Name = "Pepsi"; m_Bar2.MultiBarMode = MultiBarMode.Clustered; m_Bar2.DataLabelStyle.Format = "<value>"; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // add custom labels to the X axis NAxis xAxis = chart.Axis(StandardAxis.PrimaryX); xAxis.ScrollBar.Visible = true; NOrdinalScaleConfigurator ordinalScale = xAxis.ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.OuterMajorTickStyle.Visible = false; ordinalScale.InnerMajorTickStyle.Visible = false; // add custom labels to the Y axis chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 320)); NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; linearScale.RoundToTickMax = false; NCustomRangeLabel rangeLabel = new NCustomRangeLabel(new NRange1DD(240, 320), "Target Volume"); rangeLabel.Style.TickMode = RangeLabelTickMode.Center; rangeLabel.Style.WrapText = true; rangeLabel.Style.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0); linearScale.CustomLabels.Add(rangeLabel); // 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); linearScale.StripStyles.Add(stripStyle); // configure interactivity nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); // init form controls LabelTickModeComboBox.FillFromEnum(typeof(RangeLabelTickMode)); LabelVisibilityModeComboBox.FillFromEnum(typeof(ScaleLabelVisibilityMode)); LabelFitModeComboBox.FillFromEnum(typeof(RangeLabelFitMode)); NRangeScaleLabelStyle defaultStyle = new NRangeScaleLabelStyle(); LabelTickModeComboBox.SelectedIndex = (int)defaultStyle.TickMode; LabelVisibilityModeComboBox.SelectedIndex = (int)defaultStyle.VisibilityMode; LabelFitModeComboBox.SelectedIndex = (int)defaultStyle.FitMode; LabelAngleNumericUpDown.Value = (decimal)defaultStyle.Angle.CustomAngle; TickPaddingNumericUpDown.Value = (decimal)defaultStyle.TickPadding.Value; TickOffsetNumericUpDown.Value = (decimal)defaultStyle.TickOffset.Value; TextOffsetNumericUpDown.Value = (decimal)defaultStyle.Offset.Value; TextPaddingNumericUpDown.Value = (decimal)defaultStyle.TextPadding.Value; // add some data NorthAmericaCheckBox.Checked = true; EuropeCheckBox.Checked = true; AsiaCheckBox.Checked = true; SouthAmericaCheckBox.Checked = true; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Date Time Scale"); 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(); // setup chart m_Chart = (NCartesianChart)nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; // add a range selection, snapped to the vertical axis min/max values NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); m_Chart.RangeSelections.Add(rangeSelection); // add interlaced stripe to the Y axis NLinearScaleConfigurator linearScale = m_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); // Add a line series NLineSeries line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); line.UseXValues = true; line.DataLabelStyle.Visible = false; line.InflateMargins = true; line.MarkerStyle.Visible = true; line.MarkerStyle.BorderStyle.Color = Color.DarkRed; 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(); m_DateTimeScale = dateTimeScale; m_DateTimeScale.LabelStyle.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 90); m_DateTimeScale.LabelStyle.ContentAlignment = ContentAlignment.MiddleLeft; m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); NAxis xAxis = m_Chart.Axis(StandardAxis.PrimaryX); xAxis.ScrollBar.Visible = true; // configure interactivity nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); // init form controls EndDateTimePicker.Value = CultureInfo.CurrentCulture.Calendar.AddYears(StartDateTimePicker.Value, 2); EnableUnitSensitiveFormattingCheckBox.Checked = true; DayCheckBox.Checked = true; WeekCheckBox.Checked = true; MonthCheckBox.Checked = true; QuarterCheckBox.Checked = true; YearCheckBox.Checked = true; UpdateDateTimeScale(); GenerateDataButton_Click(null, null); nChartControl1.Refresh(); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Quarterly Company Sales<br/><font size = '9pt'>Demonstrates how to use hierarchical scale configurators as well as data zooming and scrolling</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); NLegend legend = new NLegend(); legend.Margins = new NMarginsL(10, 0, 10, 0); legend.DockMode = PanelDockMode.Right; legend.FitAlignment = ContentAlignment.TopCenter; nChartControl1.Panels.Add(legend); NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rangeSelection); chart.DisplayOnLegend = legend; chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; chart.Margins = new NMarginsL(10, 0, 0, 10); chart.Axis(StandardAxis.Depth).Visible = false; // add the first bar m_Bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); m_Bar1.Name = "Coca Cola"; m_Bar1.MultiBarMode = MultiBarMode.Series; m_Bar1.DataLabelStyle.Visible = false; // add the second bar m_Bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); m_Bar2.Name = "Pepsi"; m_Bar2.MultiBarMode = MultiBarMode.Clustered; m_Bar2.DataLabelStyle.Visible = false; NAxis xAxis = chart.Axis(StandardAxis.PrimaryX); xAxis.ScrollBar.Visible = true; // add custom labels to the Y axis NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; // 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); linearScale.StripStyles.Add(stripStyle); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // configure interactivity nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); // first row combo boxes FirstRowIndividualModeComboBox.FillFromEnum(typeof(RangeLabelTickMode)); FirstRowIndividualModeComboBox.SelectedIndex = (int)RangeLabelTickMode.Separators; FirstRowSeparatorModeComboBox.FillFromEnum(typeof(FirstRowGridStyle)); FirstRowSeparatorModeComboBox.SelectedIndex = (int)FirstRowGridStyle.Individual; GroupRowIndividualModeComboBox.FillFromEnum(typeof(RangeLabelTickMode)); GroupRowIndividualModeComboBox.SelectedIndex = (int)RangeLabelTickMode.Separators; GroupRowSeparatorModeComboBox.FillFromEnum(typeof(GroupRowGridStyle)); GroupRowSeparatorModeComboBox.SelectedIndex = (int)GroupRowGridStyle.Individual; CreateSeparatorForEachLevelCheckBox.Checked = true; ChangeDataButton_Click(null, null); UpdateScale(); }
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("Range Selection Resize and Panning"); title.DockMode = PanelDockMode.Top; 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)); nChartControl1.Panels.Add(title); // configure chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; // switch the x to linear scale chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator(); // create the range selection m_RangeSelection = new NRangeSelection(); m_RangeSelection.AllowHorizontalResize = true; m_RangeSelection.AllowVerticalResize = true; m_RangeSelection.AllowPan = true; m_RangeSelection.PaintInverted = true; m_RangeSelection.HorizontalAxisRange = new Nevron.GraphicsCore.NRange1DD(20, 40); m_RangeSelection.VerticalAxisRange = new Nevron.GraphicsCore.NRange1DD(20, 40); m_RangeSelection.Visible = true; m_RangeSelection.ShowGrippers = true; chart.RangeSelections.Add(m_RangeSelection); m_RangeSelection.HorizontalAxisRangeChanged += new EventHandler(OnRangeSelectionHorizontalAxisRangeChanged); m_RangeSelection.VerticalAxisRangeChanged += new EventHandler(OnRangeSelectionVerticalAxisRangeChanged); NPointSeries point = new NPointSeries(); point.UseXValues = true; point.InflateMargins = true; point.Size = new NLength(5); point.DataLabelStyle.Visible = false; Random random = new Random(); for (int i = 0; i < 100; i++) { point.Values.Add(random.Next(100)); point.XValues.Add(random.Next(100)); } chart.Series.Add(point); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NRangeSelectionMoveResizeTool()); AllowHorizontalResizeCheckBox.Checked = m_RangeSelection.AllowHorizontalResize; AllowVerticalResizeCheckBox.Checked = m_RangeSelection.AllowVerticalResize; AllowPanCheckBox.Checked = m_RangeSelection.AllowPan; PaintInvertedCheckBox.Checked = m_RangeSelection.PaintInverted; }
public void InitNChart(ref NChartControl ncc, out NCartesianChart chart) { // 2D line chart ncc.Settings.RenderDevice = RenderDevice.GDI; // Add tools to chart controller ncc.Controller.Tools.Add(new NSelectorTool()); ncc.Controller.Tools.Add(new NDataZoomTool()); //ncc.Controller.Tools.Add(new NDataPanTool()); ncc.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(OnChartMouseDoubleClick); ncc.MouseMove += new System.Windows.Forms.MouseEventHandler(OnChartMouseMove); chart = (NCartesianChart)ncc.Charts[0]; // Set range selections property NRangeSelection rangeSelection = new NRangeSelection(); // Reset Axis when zoom out rangeSelection.ZoomOutResetsAxis = true; chart.RangeSelections.Add(rangeSelection); // Set chart axis property chart.Axis(StandardAxis.Depth).Visible = false; SetMapProperty(); }
protected void Page_Load(object sender, EventArgs e) { NStockSeries stock; if (!IsPostBack) { // set a chart title nChartControl1.BackgroundStyle.FrameStyle.Visible = false; NLabel title = nChartControl1.Labels.AddHeader("Stock Data Grouping"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend nChartControl1.Legends.Clear(); // setup chart NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; NRangeSelection rs = new NRangeSelection(); rs.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rs); // setup X axis NValueTimelineScaleConfigurator scaleX = new NValueTimelineScaleConfigurator(); 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.FirstRow.InnerTickStyle.Visible = false; 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.SecondRow.InnerTickStyle.Visible = false; scaleX.ThirdRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.ThirdRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(205, 205, 205)); scaleX.ThirdRow.UseGridStyle = true; scaleX.ThirdRow.InnerTickStyle.Visible = false; // 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; chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.OuterMajorTickStyle.Length = new NLength(3, NGraphicsUnit.Point); scaleY.InnerMajorTickStyle.Visible = false; NFillStyle stripFill = new NColorFillStyle(Color.FromArgb(234, 233, 237)); NScaleStripStyle stripStyle = new NScaleStripStyle(stripFill, null, true, 1, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; stripStyle.Interlaced = true; scaleY.StripStyles.Add(stripStyle); // setup stock series stock = (NStockSeries)chart.Series.Add(SeriesType.Stock); stock.DataLabelStyle.Visible = false; stock.UpFillStyle = new NColorFillStyle(Color.White); stock.UpStrokeStyle.Color = Color.Black; stock.DownFillStyle = new NColorFillStyle(Color.Crimson); stock.DownStrokeStyle.Color = Color.Crimson; stock.HighLowStrokeStyle.Color = Color.Black; stock.CandleWidth = new NLength(1.2f, NRelativeUnit.ParentPercentage); stock.UseXValues = true; stock.InflateMargins = true; stock.DataLabelStyle.Format = "open - <open>\r\nclose - <close>"; // add some stock items const int numDataPoints = 1000; WebExamplesUtilities.GenerateOHLCData(stock, 100.0, numDataPoints, new NRange1DD(60, 140)); FillStockDates(stock, numDataPoints, DateTime.Now - new TimeSpan((int)(numDataPoints * 1.2), 0, 0, 0)); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); // update form controls CustomDateTimeSpanDropDownList.Items.Add("1 Week"); CustomDateTimeSpanDropDownList.Items.Add("2 Weeks"); CustomDateTimeSpanDropDownList.Items.Add("1 Month"); CustomDateTimeSpanDropDownList.Items.Add("3 Months"); WebExamplesUtilities.FillComboWithEnumNames(GroupingModeDropDownList, typeof(StockGroupingMode)); CustomDateTimeSpanDropDownList.SelectedIndex = 2; GroupingModeDropDownList.SelectedIndex = (int)StockGroupingMode.SynchronizeWithMajorTick; WebExamplesUtilities.FillComboWithPercents(GroupPercendWidthDropDownList, 10); GroupPercendWidthDropDownList.SelectedIndex = 2; WebExamplesUtilities.FillComboWithValues(MinGroupDistanceDropDownList, 2, 20, 2); MinGroupDistanceDropDownList.SelectedIndex = 2; } else { stock = (NStockSeries)nChartControl1.Charts[0].Series[0]; } MinGroupDistanceDropDownList.Enabled = false; CustomDateTimeSpanDropDownList.Enabled = false; GroupPercendWidthDropDownList.Enabled = true; switch (GroupingModeDropDownList.SelectedIndex) { case (int)StockGroupingMode.None: stock.GroupingMode = StockGroupingMode.None; GroupPercendWidthDropDownList.Enabled = false; break; case (int)StockGroupingMode.AutoDateTimeSpan: stock.GroupingMode = StockGroupingMode.AutoDateTimeSpan; MinGroupDistanceDropDownList.Enabled = true; break; case (int)StockGroupingMode.CustomDateTimeSpan: stock.GroupingMode = StockGroupingMode.CustomDateTimeSpan; CustomDateTimeSpanDropDownList.Enabled = true; break; case (int)StockGroupingMode.SynchronizeWithMajorTick: stock.GroupingMode = StockGroupingMode.SynchronizeWithMajorTick; break; default: break; } stock.MinAutoGroupLength = new NLength((float)MinGroupDistanceDropDownList.SelectedIndex * 2 + 2, NGraphicsUnit.Point); switch (CustomDateTimeSpanDropDownList.SelectedIndex) { case 0: // 1 Week stock.CustomGroupStep = new NDateTimeSpan(1, NDateTimeUnit.Week); break; case 1: // 2 Weeks stock.CustomGroupStep = new NDateTimeSpan(2, NDateTimeUnit.Week); break; case 2: // 1 Month stock.CustomGroupStep = new NDateTimeSpan(1, NDateTimeUnit.Month); break; case 3: // 3 Months stock.CustomGroupStep = new NDateTimeSpan(3, NDateTimeUnit.Month); break; } stock.GroupPercentWidth = (float)GroupPercendWidthDropDownList.SelectedIndex * 10; }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); if (!IsPostBack) { // init form controls ShowLevelSeparatorsCheckBox.Checked = true; Show2007DataCheckBox.Checked = true; } // set a chart title NLabel header = new NLabel("Quarterly Company Sales<br/><font size = '9pt'>Demonstrates how to use hierarchical scale configurators</font>"); header.DockMode = PanelDockMode.Top; header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.TextStyle.TextFormat = TextFormat.XML; header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left; header.FitAlignment = ContentAlignment.MiddleLeft; header.Margins = new NMarginsL(5, 0, 10, 10); nChartControl1.Panels.Add(header); NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); NLegend legend = new NLegend(); legend.Margins = new NMarginsL(10, 0, 10, 0); legend.DockMode = PanelDockMode.Right; legend.FitAlignment = ContentAlignment.TopCenter; legend.Data.ExpandMode = LegendExpandMode.ColsOnly; legend.FillStyle = new NColorFillStyle(Color.FromArgb(125, Color.White)); legend.HorizontalBorderStyle.Width = new NLength(0); legend.VerticalBorderStyle.Width = new NLength(0); legend.OuterTopBorderStyle.Width = new NLength(0); legend.OuterLeftBorderStyle.Width = new NLength(0); legend.OuterBottomBorderStyle.Width = new NLength(0); legend.OuterRightBorderStyle.Width = new NLength(0); chart.ChildPanels.Add(legend); NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rangeSelection); chart.DisplayOnLegend = legend; chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; chart.Margins = new NMarginsL(5, 0, 5, 10); chart.Axis(StandardAxis.Depth).Visible = false; // first determine how many months we will show int monthCount = 12; if (Show2007DataCheckBox.Checked) { monthCount += 12; } // add the first bar NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar1.Name = "Coca Cola"; bar1.MultiBarMode = MultiBarMode.Series; bar1.DataLabelStyle.Visible = false; bar1.Values.FillRandomRange(Random, monthCount, 10, 200); // add the second bar NBarSeries bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar2.Name = "Pepsi"; bar2.MultiBarMode = MultiBarMode.Clustered; bar2.DataLabelStyle.Visible = false; // fill with random data bar2.Values.FillRandomRange(Random, monthCount, 10, 300); NAxis xAxis = chart.Axis(StandardAxis.PrimaryX); xAxis.ScrollBar.Visible = true; // add custom labels to the Y axis NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; // 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); linearScale.StripStyles.Add(stripStyle); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); UpdateScale(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ShowNorthAmericaCheckBox.Checked = true; ShowEuropeCheckBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Company Sales by Region<br/><font size = '9pt'>Demonstrates how to use custom range labels to denote ranges on a scale</font>"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.TextStyle.TextFormat = TextFormat.XML; header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left; header.DockMode = PanelDockMode.Top; header.FitAlignment = ContentAlignment.MiddleLeft; header.Margins = new NMarginsL(5, 0, 10, 10); header.Location = new NPointL(new NLength(3, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); nChartControl1.Panels.Add(header); NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); // configure the legend and add it as child panel of the chart NLegend legend = new NLegend(); legend.Margins = new NMarginsL(10, 0, 10, 0); legend.DockMode = PanelDockMode.Right; legend.FitAlignment = ContentAlignment.TopCenter; legend.Data.ExpandMode = LegendExpandMode.ColsOnly; legend.FillStyle = new NColorFillStyle(Color.FromArgb(125, Color.White)); legend.HorizontalBorderStyle.Width = new NLength(0); legend.VerticalBorderStyle.Width = new NLength(0); legend.OuterTopBorderStyle.Width = new NLength(0); legend.OuterLeftBorderStyle.Width = new NLength(0); legend.OuterBottomBorderStyle.Width = new NLength(0); legend.OuterRightBorderStyle.Width = new NLength(0); chart.ChildPanels.Add(legend); chart.DisplayOnLegend = legend; chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; chart.Margins = new NMarginsL(2, 0, 2, 2); chart.Axis(StandardAxis.Depth).Visible = false; // add range selection NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); chart.RangeSelections.Add(rangeSelection); // add the first bar m_Bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); m_Bar1.Name = "Coca Cola"; m_Bar1.MultiBarMode = MultiBarMode.Series; m_Bar1.DataLabelStyle.Format = "<value>"; // add the second bar m_Bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); m_Bar2.Name = "Pepsi"; m_Bar2.MultiBarMode = MultiBarMode.Clustered; m_Bar2.DataLabelStyle.Format = "<value>"; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // add custom labels to the X axis NAxis xAxis = chart.Axis(StandardAxis.PrimaryX); xAxis.ScrollBar.Visible = true; NOrdinalScaleConfigurator ordinalScale = xAxis.ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.OuterMajorTickStyle.Visible = false; ordinalScale.InnerMajorTickStyle.Visible = false; // add custom labels to the Y axis chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 320)); NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; linearScale.RoundToTickMax = false; NCustomRangeLabel rangeLabel = new NCustomRangeLabel(new NRange1DD(240, 320), "Target Volume"); rangeLabel.Style.TickMode = RangeLabelTickMode.Center; rangeLabel.Style.WrapText = true; rangeLabel.Style.Angle = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0); linearScale.CustomLabels.Add(rangeLabel); // 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); linearScale.StripStyles.Add(stripStyle); UpdateRegions(); }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Value Timeline Scale<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; NValueTimelineScaleConfigurator timeLineScale = new NValueTimelineScaleConfigurator(); 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; // configure ticks and grid lines linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); 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()); // update form controls FirstRowVisibleCheckBox.Checked = true; SecondRowVisibleCheckBox.Checked = true; ThirdRowVisibleCheckBox.Checked = true; // generate some data MonthlyDataButton_Click(null, null); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = new NLabel("Real Time Stock"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); nChartControl1.Panels.Add(title); m_Chart = (NCartesianChart)nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; // add interlace stripes NLinearScaleConfigurator linearScale = m_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); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NRangeTimelineScaleConfigurator(); // enable range selection NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); m_Chart.RangeSelections.Add(rangeSelection); // enable zooming and scrolling m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; m_Chart.Axis(StandardAxis.PrimaryX).PagingView = new NDateTimeAxisPagingView(); m_LineSMA = new NLineSeries(); // create a line series for the simple moving average m_Chart.Series.Add(m_LineSMA); m_LineSMA.Name = "SMA(20)"; m_LineSMA.DataLabelStyle.Visible = false; m_LineSMA.BorderStyle.Color = Color.DarkOrange; m_LineSMA.UseXValues = true; // create the stock series m_Stock = new NStockSeries(); m_Chart.Series.Add(m_Stock); m_Stock.DisplayOnAxis(StandardAxis.PrimaryX, true); m_Stock.Name = "Stock Data"; m_Stock.Legend.Mode = SeriesLegendMode.None; m_Stock.DataLabelStyle.Visible = false; m_Stock.CandleStyle = CandleStyle.Bar; m_Stock.CandleWidth = new NLength(0.8f, NRelativeUnit.ParentPercentage); m_Stock.InflateMargins = true; m_Stock.UseXValues = true; m_Stock.UpFillStyle = new NColorFillStyle(LightGreen); m_Stock.UpStrokeStyle.Color = Color.Black; m_Stock.DownFillStyle = new NColorFillStyle(Red); m_Stock.DownStrokeStyle.Color = Color.Black; m_Stock.OpenValues.Name = "open"; m_Stock.CloseValues.Name = "close"; m_Stock.HighValues.Name = "high"; m_Stock.LowValues.Name = "low"; nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); nChartControl1.Controller.Tools.Add(new NDataPanTool()); // apply layout ConfigureStandardLayout(m_Chart, title, null); NumberOfDataPointsComboBox.Items.Add("1000"); NumberOfDataPointsComboBox.Items.Add("5000"); NumberOfDataPointsComboBox.Items.Add("10000"); NumberOfDataPointsComboBox.SelectedIndex = 1; AddData(); UseHardwareAccelerationCheckBox.IsChecked = true; nChartControl1.Settings.RenderSurface = RenderSurface.Window; StartTimer(); }
public override void Initialize() { base.Initialize(); const int nNumberOfWeeks = 20; const int nWorkDaysInWeek = 5; const int nDaysInWeek = 7; const int nTotalWorkDays = nNumberOfWeeks * nWorkDaysInWeek; const int nTotalDays = nNumberOfWeeks * nDaysInWeek; const int nHistoricalDays = 20; NLabel title = nChartControl1.Labels.AddHeader("Financial Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); 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.Fit; m_Chart.Location = new NPointL(new NLength(7, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL(new NLength(86, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); m_Chart.Height = 30; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); m_Chart.Wall(ChartWallType.Floor).Visible = false; m_Chart.Wall(ChartWallType.Left).Visible = false; m_Chart.Wall(ChartWallType.Back).Width = 0; m_Chart.Wall(ChartWallType.Back).FillStyle = new NColorFillStyle(Color.FromArgb(239, 245, 239)); m_Chart.Axis(StandardAxis.Depth).Visible = false; // setup y axis NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.LineStyle.Color = Color.Gray; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, false); // setup x axis NAxis axisX1 = m_Chart.Axis(StandardAxis.PrimaryX); linearScale = new NLinearScaleConfigurator(); axisX1.ScaleConfigurator = linearScale; linearScale.AutoLabels = false; linearScale.MinorTickCount = 4; linearScale.MajorTickMode = MajorTickMode.CustomStep; linearScale.CustomStep = 5; linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; linearScale.OuterMajorTickStyle.Length = new NLength(4, NGraphicsUnit.Point); linearScale.InnerMajorTickStyle.Length = new NLength(0, NGraphicsUnit.Point); linearScale.InnerMinorTickStyle.Length = new NLength(0, NGraphicsUnit.Point); linearScale.OuterMinorTickStyle.Length = new NLength(2, NGraphicsUnit.Point); linearScale.OuterMinorTickStyle.LineStyle.Color = Color.Brown; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, false); linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.LabelStyle.ValueScale = 0.2; // create a line series for the simple moving average m_LineSMA = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_LineSMA.Name = "SMA(20)"; m_LineSMA.DataLabelStyle.Visible = false; m_LineSMA.BorderStyle.Color = Color.DarkOrange; // create the stock series m_Stock = (NStockSeries)m_Chart.Series.Add(SeriesType.Stock); m_Stock.Name = "Stock Data"; m_Stock.Legend.Mode = SeriesLegendMode.None; m_Stock.DataLabelStyle.Visible = false; m_Stock.CandleStyle = CandleStyle.Bar; m_Stock.CandleWidth = new NLength(5, NGraphicsUnit.Point); m_Stock.InflateMargins = false; m_Stock.UpFillStyle = new NColorFillStyle(LightOrange); m_Stock.UpStrokeStyle.Color = Color.Black; m_Stock.DownFillStyle = new NColorFillStyle(DarkOrange); m_Stock.DownStrokeStyle.Color = Color.Black; m_Stock.DisplayOnAxis(StandardAxis.PrimaryX, true); m_Stock.InflateMargins = true; m_Stock.OpenValues.Name = "open"; m_Stock.CloseValues.Name = "close"; m_Stock.HighValues.Name = "high"; m_Stock.LowValues.Name = "low"; // add the bollinger bands as high low area m_HighLow = (NHighLowSeries)m_Chart.Series.Add(SeriesType.HighLow); m_HighLow.Name = "BB(20, 2)"; m_HighLow.DataLabelStyle.Visible = false; m_HighLow.HighFillStyle = new NColorFillStyle(Color.FromArgb(80, 130, 134, 168)); m_HighLow.HighBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); m_HighLow.DisplayOnAxis(StandardAxis.SecondaryX, true); // generate some stock data GenerateOHLCData(m_Stock, 300, nTotalWorkDays + nHistoricalDays); // create a function calculator NFunctionCalculator fc = new NFunctionCalculator(); fc.Arguments.Add(m_Stock.CloseValues); // calculate the bollinger bands fc.Expression = "BOLLINGER(close; 20; 2)"; m_HighLow.HighValues = fc.Calculate(); m_HighLow.HighValues.Name = "BollingerUpper"; fc.Expression = "BOLLINGER(close; 20; -2)"; m_HighLow.LowValues = fc.Calculate(); m_HighLow.LowValues.Name = "BollingerLower"; // calculate the simple moving average fc.Expression = "SMA(close; 20)"; m_LineSMA.Values = fc.Calculate(); // remove data that won't be charted m_Stock.HighValues.RemoveRange(0, nHistoricalDays); m_Stock.LowValues.RemoveRange(0, nHistoricalDays); m_Stock.OpenValues.RemoveRange(0, nHistoricalDays); m_Stock.CloseValues.RemoveRange(0, nHistoricalDays); m_HighLow.HighValues.RemoveRange(0, nHistoricalDays); m_HighLow.LowValues.RemoveRange(0, nHistoricalDays); m_LineSMA.Values.RemoveRange(0, nHistoricalDays); GenerateDateLabels(nTotalDays); CandleStyleCombo.Items.Add("Candle"); CandleStyleCombo.Items.Add("Stick"); CandleStyleCombo.SelectedIndex = 0; NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); ((NCartesianChart)m_Chart).RangeSelections.Add(rangeSelection); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); nChartControl1.Controller.Tools.Add(new NDataPanTool()); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = new NLabel("Range Selection Resize and Panning"); title.DockMode = PanelDockMode.Top; 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)); nChartControl1.Panels.Add(title); // configure chart NDockPanel dockPanel = new NDockPanel(); dockPanel.Margins = new NMarginsL(10); dockPanel.DockMode = PanelDockMode.Fill; nChartControl1.Panels.Add(dockPanel); m_Chart1 = new NCartesianChart(); m_Chart1.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator(); m_Chart1.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; m_Chart1.Axis(StandardAxis.PrimaryX).ScrollBar.ResetButton.Visible = false; m_Chart1.Size = new NSizeL(new NLength(0), new NLength(50, NRelativeUnit.ParentPercentage)); m_Chart1.DockMode = PanelDockMode.Top; m_Chart1.BoundsMode = BoundsMode.Stretch; dockPanel.ChildPanels.Add(m_Chart1); NAreaSeries area1 = new NAreaSeries(); area1.UseXValues = true; area1.DataLabelStyle.Visible = false; m_Chart1.Series.Add(area1); m_Chart2 = new NCartesianChart(); m_Chart2.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NValueTimelineScaleConfigurator(); m_Chart2.Size = new NSizeL(new NLength(0), new NLength(50, NRelativeUnit.ParentPercentage)); m_Chart2.DockMode = PanelDockMode.Top; m_Chart2.BoundsMode = BoundsMode.Stretch; dockPanel.ChildPanels.Add(m_Chart2); NAreaSeries area2 = new NAreaSeries(); area2.UseXValues = true; area2.DataLabelStyle.Visible = false; m_Chart2.Series.Add(area2); NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.Visible = true; rangeSelection.PaintInverted = true; rangeSelection.ShowGrippers = true; rangeSelection.AllowVerticalResize = false; rangeSelection.AllowHorizontalResize = true; rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); rangeSelection.GripperSize = new NSizeL(5, 20); m_Chart2.RangeSelections.Add(rangeSelection); GenerateOHLCData(area1, 100, 1000); area2.Values = (NDataSeriesDouble)area1.Values.Clone(); area2.XValues = (NDataSeriesDouble)area1.XValues.Clone(); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NRangeSelectionMoveResizeTool()); nChartControl1.RecalcLayout(); // link the x axes of the charts m_Chart1.Axis(StandardAxis.PrimaryX).Scale.RulerRangeChanged += new EventHandler(Scale_RulerRangeChanged); rangeSelection.HorizontalAxisRangeChanged += new EventHandler(rangeSelection_HorizontalAxisRangeChanged); rangeSelection.HorizontalAxisRange = new NRange1DD((double)area2.XValues[0], (double)area2.XValues[100]); }