private void SetupTimeScale(NAxis 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;

            axis.ScaleConfigurator = scaleX;
        }
        private void UpdateScale()
        {
            NValueTimelineScaleConfigurator timelineScale = m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NValueTimelineScaleConfigurator;

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

            nChartControl1.Refresh();
        }
Beispiel #3
0
        protected void ConfigureStockVolumesChart()
        {
            m_ChartStockVolumes = new NCartesianChart();
            nChartControl1.Panels.Add(m_ChartStockVolumes);

            m_ChartStockVolumes.Location   = new NPointL(new NLength(7, NRelativeUnit.ParentPercentage), new NLength(55, NRelativeUnit.ParentPercentage));
            m_ChartStockVolumes.Size       = new NSizeL(new NLength(84, NRelativeUnit.ParentPercentage), new NLength(35, NRelativeUnit.ParentPercentage));
            m_ChartStockVolumes.BoundsMode = BoundsMode.Stretch;
            m_ChartStockVolumes.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.FromArgb(230, 230, 230));

            // setup Y axis
            NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator();

            scaleY.MajorGridStyle.ShowAtWalls  = new ChartWallType[] { ChartWallType.Back };
            scaleY.InnerMajorTickStyle.Visible = false;
            m_ChartStockVolumes.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY;

            // 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;
            m_ChartStockVolumes.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;

            // enable paging and scrollbar
            m_ChartStockVolumes.Axis(StandardAxis.PrimaryX).PagingView        = new NDateTimeAxisPagingView();
            m_ChartStockVolumes.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;

            // add a Bar series for the Volume values
            m_Volume      = (NBarSeries)m_ChartStockVolumes.Series.Add(SeriesType.Bar);
            m_Volume.Name = "Volume";
            m_Volume.DataLabelStyle.Visible   = false;
            m_Volume.DataLabelStyle.Format    = "<xvalue>";
            m_Volume.DataLabelStyle.VertAlign = VertAlign.Center;
            m_Volume.UseXValues     = true;
            m_Volume.InflateMargins = true;
            m_Volume.FillStyle      = new NColorFillStyle(Color.FromArgb(119, 208, 151));

            // add some stock items
            for (int i = 0; i < m_Stock.Values.Count; i++)
            {
                m_Volume.Values.Add(100 + Random.Next(1000));
                m_Volume.XValues.Add(m_Stock.XValues[i]);
            }
        }
Beispiel #4
0
        private void ThirdRowTextStyleButton_Click(object sender, EventArgs e)
        {
            NValueTimelineScaleConfigurator valueTimelineScale = m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NValueTimelineScaleConfigurator;
            NTextStyle result = null;

            if (NTextStyleTypeEditor.Edit(valueTimelineScale.ThirdRow.LabelStyle.TextStyle, out result))
            {
                valueTimelineScale.ThirdRow.LabelStyle.TextStyle = result;
                nChartControl1.Refresh();
            }
        }
Beispiel #5
0
        public NevronChartForm( )
        {
            InitializeComponent();

            NChart chart = this.nevronChart.Charts[0];

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

            // 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);
        }
Beispiel #6
0
        private void ConfigureScaleRow(int rowIndex, NCheckBox visibleCheckBox, NComboBox rowModeComboBox, NComboBox rowUnitComboBox, NNumericUpDown rowUnitCountUpDown)
        {
            NValueTimelineScaleConfigurator valueTimelineScale = m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NValueTimelineScaleConfigurator;
            NTimelineScaleRow scaleRow;

            if (rowIndex == 0)
            {
                scaleRow = valueTimelineScale.FirstRow;
            }
            else if (rowIndex == 1)
            {
                scaleRow = valueTimelineScale.SecondRow;
            }
            else
            {
                scaleRow = valueTimelineScale.ThirdRow;
            }

            scaleRow.Visible = visibleCheckBox.Checked;

            bool enableUnitControls = false;

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

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

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

            rowUnitComboBox.Enabled    = enableUnitControls;
            rowUnitCountUpDown.Enabled = enableUnitControls;
        }
        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);
        }
Beispiel #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithColorNames(UpStickColorDropDownList, KnownColor.Black);
                WebExamplesUtilities.FillComboWithColorNames(DownStickColorDropDownList, KnownColor.Crimson);

                // init form controls
                ShowHighLowCheckBox.Checked = true;
                ShowOpenCheckBox.Checked    = true;
                ShowCloseCheckBox.Checked   = true;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Stick Stock Chart");

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

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

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

            chart.BoundsMode = BoundsMode.Stretch;

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

            // 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
            NStockSeries stock = (NStockSeries)chart.Series.Add(SeriesType.Stock);

            stock.CandleStyle            = CandleStyle.Stick;
            stock.CandleWidth            = new NLength(1.3f, NRelativeUnit.ParentPercentage);
            stock.DataLabelStyle.Visible = false;
            stock.UseXValues             = true;
            stock.InflateMargins         = true;
            stock.UpStrokeStyle.Width    = new NLength(1, NGraphicsUnit.Point);
            stock.DownStrokeStyle.Width  = new NLength(1, NGraphicsUnit.Point);
            stock.ShowClose   = ShowCloseCheckBox.Checked;
            stock.ShowOpen    = ShowOpenCheckBox.Checked;
            stock.ShowHighLow = ShowHighLowCheckBox.Checked;

            stock.UpStrokeStyle.Color   = WebExamplesUtilities.ColorFromDropDownList(UpStickColorDropDownList);
            stock.DownStrokeStyle.Color = WebExamplesUtilities.ColorFromDropDownList(DownStickColorDropDownList);

            // add some stock items
            const int count = 40;

            GenerateOHLCData(stock, count);
            FillStockDates(stock, count);

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);
        }
Beispiel #9
0
        /// <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;
        }
Beispiel #10
0
        private void ConfigureStockValuesChart()
        {
            m_ChartStockValues = (NCartesianChart)nChartControl1.Charts[0];

            m_ChartStockValues.Location   = new NPointL(new NLength(7, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage));
            m_ChartStockValues.Size       = new NSizeL(new NLength(84, NRelativeUnit.ParentPercentage), new NLength(35, NRelativeUnit.ParentPercentage));
            m_ChartStockValues.BoundsMode = BoundsMode.Stretch;
            m_ChartStockValues.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.FromArgb(230, 230, 230));

            // setup Y axis
            NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator();

            scaleY.MajorGridStyle.ShowAtWalls  = new ChartWallType[] { ChartWallType.Back };
            scaleY.InnerMajorTickStyle.Visible = false;
            m_ChartStockValues.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY;

            // 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;
            m_ChartStockValues.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;

            // create stock series
            m_Stock                          = (NStockSeries)m_ChartStockValues.Series.Add(SeriesType.Stock);
            m_Stock.Name                     = "Stock Prices";
            m_Stock.UpFillStyle              = new NColorFillStyle(Color.FromArgb(149, 171, 238));
            m_Stock.UpStrokeStyle.Color      = Color.RoyalBlue;
            m_Stock.DownFillStyle            = new NColorFillStyle(Color.White);
            m_Stock.DownStrokeStyle.Color    = Color.RoyalBlue;
            m_Stock.HighLowStrokeStyle.Color = Color.RoyalBlue;
            m_Stock.InflateMargins           = true;
            m_Stock.UseXValues               = true;
            m_Stock.CandleWidth              = new NLength(1.6f, NRelativeUnit.ParentPercentage);

            // show the date time value in the legend
            m_Stock.Legend.Format          = "<xvalue>";
            m_Stock.XValues.ValueFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.Date);
            m_Stock.Legend.Mode            = SeriesLegendMode.DataPoints;

            // configure data labels
            m_Stock.DataLabelStyle.Visible   = false;
            m_Stock.DataLabelStyle.Format    = "<xvalue>";
            m_Stock.DataLabelStyle.VertAlign = VertAlign.Center;

            // add stock date time values
            GenerateOHLCData(m_Stock, 150, 12 * 4);

            // add stock date time values
            for (int nMonth = 1; nMonth <= 12; nMonth++)
            {
                for (int nDay = 1; nDay <= 28; nDay += 7)
                {
                    m_Stock.XValues.Add(new DateTime(2003, nMonth, nDay).ToOADate());
                }
            }
        }
Beispiel #11
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Stick Stock Chart");

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

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

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

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

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

            // add a stock series
            m_Stock                        = (NStockSeries)chart.Series.Add(SeriesType.Stock);
            m_Stock.CandleStyle            = CandleStyle.Stick;
            m_Stock.DataLabelStyle.Visible = false;
            m_Stock.UpStrokeStyle.Width    = new NLength(1, NGraphicsUnit.Point);
            m_Stock.UpStrokeStyle.Color    = Color.Black;
            m_Stock.DownStrokeStyle.Width  = new NLength(1, NGraphicsUnit.Point);
            m_Stock.DownStrokeStyle.Color  = Color.Crimson;
            m_Stock.CandleWidth            = new NLength(1.3f, NRelativeUnit.ParentPercentage);
            m_Stock.UseXValues             = true;
            m_Stock.InflateMargins         = true;

            // add some stock items
            const int count = 50;

            GenerateOHLCData(m_Stock, 100.0, count, new NRange1DD(60, 140));
            FillStockDates(m_Stock, count);

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

            // init form controls
            ShowHighLow.Checked = true;
            ShowOpen.Checked    = true;
            ShowClose.Checked   = true;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithValues(PeriodDropDownList, 0, 100, 10);
                PeriodDropDownList.SelectedIndex = 2;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            NFunctionCalculator calc = new NFunctionCalculator();

            nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.None;

            NChart chart = nChartControl1.Charts[0];

            chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);
            chart.BoundsMode = BoundsMode.Stretch;
            chart.Location   = new NPointL(
                new NLength(5, NRelativeUnit.ParentPercentage),
                new NLength(20, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(90, NRelativeUnit.ParentPercentage),
                new NLength(75, NRelativeUnit.ParentPercentage));

            NLegend legend = nChartControl1.Legends[0];

            legend.Data.ExpandMode = LegendExpandMode.ColsOnly;
            legend.Location        = new NPointL(
                new NLength(98, NRelativeUnit.ParentPercentage),
                new NLength(12, NRelativeUnit.ParentPercentage));

            // align the chart and the legend
            NSideGuideline guideline = new NSideGuideline(PanelSide.Right);

            guideline.Targets.Add(legend);
            guideline.Targets.Add(chart);
            nChartControl1.Document.RootPanel.Guidelines.Add(guideline);

            // setup X axis
            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;
            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;

            // setup primary Y axis
            NAxis axisY1 = chart.Axis(StandardAxis.PrimaryY);

            axisY1.Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 45, 100);

            NLinearScaleConfigurator scaleY1 = (NLinearScaleConfigurator)axisY1.ScaleConfigurator;

            scaleY1.RulerStyle.Height                   = new NLength(2, NGraphicsUnit.Pixel);
            scaleY1.MajorGridStyle.ShowAtWalls          = new ChartWallType[] { ChartWallType.Back };
            scaleY1.InnerMajorTickStyle.LineStyle.Width = new NLength(0);

            // setup secondary Y axis
            NAxis axisY2 = chart.Axis(StandardAxis.SecondaryY);

            axisY2.Visible = true;
            axisY2.Anchor  = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 0, 40);

            NLinearScaleConfigurator scaleY2 = (NLinearScaleConfigurator)axisY2.ScaleConfigurator;

            scaleY2.RulerStyle.Height                   = new NLength(2, NGraphicsUnit.Pixel);
            scaleY2.MajorGridStyle.ShowAtWalls          = new ChartWallType[] { ChartWallType.Back };
            scaleY2.InnerMajorTickStyle.LineStyle.Width = new NLength(0);

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

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

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

            // Add line series for ADX
            NLineSeries lineADX = (NLineSeries)chart.Series.Add(SeriesType.Line);

            lineADX.DisplayOnAxis(StandardAxis.PrimaryY, false);
            lineADX.DisplayOnAxis(StandardAxis.SecondaryY, true);
            lineADX.BorderStyle.Color = Color.LimeGreen;
            lineADX.Name = "ADX";
            lineADX.DataLabelStyle.Visible = false;

            // Add line series for +DI
            NLineSeries lineDIPos = (NLineSeries)chart.Series.Add(SeriesType.Line);

            lineDIPos.MultiLineMode = MultiLineMode.Overlapped;
            lineDIPos.DisplayOnAxis(StandardAxis.PrimaryY, false);
            lineDIPos.DisplayOnAxis(StandardAxis.SecondaryY, true);
            lineDIPos.BorderStyle.Color = Color.Red;
            lineDIPos.Name = "+DI";
            lineDIPos.DataLabelStyle.Visible = false;

            // Add line series for -DI
            NLineSeries lineDINeg = (NLineSeries)chart.Series.Add(SeriesType.Line);

            lineDINeg.MultiLineMode = MultiLineMode.Overlapped;
            lineDINeg.DisplayOnAxis(StandardAxis.PrimaryY, false);
            lineDINeg.DisplayOnAxis(StandardAxis.SecondaryY, true);
            lineDINeg.BorderStyle.Color = Color.Blue;
            lineDINeg.Name = "-DI";
            lineDINeg.DataLabelStyle.Visible = false;

            // add arguments for function calculator
            stock.CloseValues.Name = "close";
            stock.HighValues.Name  = "high";
            stock.LowValues.Name   = "low";
            calc.Arguments.Add(stock.CloseValues);
            calc.Arguments.Add(stock.HighValues);
            calc.Arguments.Add(stock.LowValues);

            // form controls
            lineDIPos.Visible = ShowPosDICheckBox.Checked;
            lineDINeg.Visible = ShowNegDICheckBox.Checked;
            lineADX.Visible   = ShowADXCheckBox.Checked;

            // add header
            NLabel header = nChartControl1.Labels.AddHeader("Directional Movement");

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

            GenerateData(stock);

            UpdateFunctions(stock, lineDIPos, lineDINeg, lineADX, calc);
        }
        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;
        }
        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();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Panels.Clear();

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

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

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

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

            axis.ScrollBar.Visible = true;
            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;

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

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

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

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

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

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

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

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

            GenerateData(dtStart, dtEnd, span);
        }
Beispiel #16
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Directional Movement");

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

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

            // setup X axis
            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;
            m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;

            // setup primary Y axis
            NAxis axisY1 = m_Chart.Axis(StandardAxis.PrimaryY);

            axisY1.Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 45, 100);

            NLinearScaleConfigurator scaleY1 = (NLinearScaleConfigurator)axisY1.ScaleConfigurator;

            scaleY1.RulerStyle.Height                   = new NLength(2, NGraphicsUnit.Pixel);
            scaleY1.MajorGridStyle.ShowAtWalls          = new ChartWallType[] { ChartWallType.Back };
            scaleY1.InnerMajorTickStyle.LineStyle.Width = new NLength(0);

            // setup secondary Y axis
            NAxis axisY2 = m_Chart.Axis(StandardAxis.SecondaryY);

            axisY2.Visible = true;
            axisY2.Anchor  = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 0, 40);

            NLinearScaleConfigurator scaleY2 = (NLinearScaleConfigurator)axisY2.ScaleConfigurator;

            scaleY2.RulerStyle.Height                   = new NLength(2, NGraphicsUnit.Pixel);
            scaleY2.MajorGridStyle.ShowAtWalls          = new ChartWallType[] { ChartWallType.Back };
            scaleY2.InnerMajorTickStyle.LineStyle.Width = new NLength(0);

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

            // 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.UpStrokeStyle.Color    = color1;
            m_Stock.DownStrokeStyle.Color  = color2;
            m_Stock.Legend.Mode            = SeriesLegendMode.None;
            m_Stock.CandleWidth            = new NLength(0.5f, NRelativeUnit.ParentPercentage);
            m_Stock.UseXValues             = true;
            m_Stock.InflateMargins         = true;

            // Add line series for ADX
            m_LineADX = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
            m_LineADX.DisplayOnAxis(StandardAxis.PrimaryY, false);
            m_LineADX.DisplayOnAxis(StandardAxis.SecondaryY, true);
            m_LineADX.BorderStyle.Color = Color.LimeGreen;
            m_LineADX.Name = "ADX";
            m_LineADX.DataLabelStyle.Visible = false;
            m_LineADX.UseXValues             = true;

            // Add line series for +DI
            m_LineDIPos = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
            m_LineDIPos.MultiLineMode = MultiLineMode.Overlapped;
            m_LineDIPos.DisplayOnAxis(StandardAxis.PrimaryY, false);
            m_LineDIPos.DisplayOnAxis(StandardAxis.SecondaryY, true);
            m_LineDIPos.BorderStyle.Color = color2;
            m_LineDIPos.Name = "+DI";
            m_LineDIPos.DataLabelStyle.Visible = false;
            m_LineDIPos.UseXValues             = true;

            // Add line series for -DI
            m_LineDINeg = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
            m_LineDINeg.MultiLineMode = MultiLineMode.Overlapped;
            m_LineDINeg.DisplayOnAxis(StandardAxis.PrimaryY, false);
            m_LineDINeg.DisplayOnAxis(StandardAxis.SecondaryY, true);
            m_LineDINeg.BorderStyle.Color = color1;
            m_LineDINeg.Name = "-DI";
            m_LineDINeg.DataLabelStyle.Visible = false;
            m_LineDINeg.UseXValues             = true;

            // add arguments for function calculator
            m_Stock.CloseValues.Name = "close";
            m_Stock.HighValues.Name  = "high";
            m_Stock.LowValues.Name   = "low";
            m_Calc.Arguments.Add(m_Stock.CloseValues);
            m_Calc.Arguments.Add(m_Stock.HighValues);
            m_Calc.Arguments.Add(m_Stock.LowValues);

            // form controls
            m_PeriodScroll.Value   = 14;
            m_ShowPosCheck.Checked = true;
            m_ShowNegCheck.Checked = true;
            m_ShowADXCheck.Checked = true;

            GenerateData();
            UpdateFunctions();
        }