public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = new NLabel("Step Line Intersections");

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

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

            // configure the chart
            NChart chart = nChartControl1.Charts[0];

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

            m_Line                        = (NStepLineSeries)chart.Series.Add(SeriesType.StepLine);
            m_Line.Name                   = "Series 1";
            m_Line.DepthPercent           = 50;
            m_Line.LineSize               = 2;
            m_Line.DataLabelStyle.Visible = false;
            m_Line.MarkerStyle.Visible    = false;
            m_Line.Values.FillRandom(Random, 12);

            m_Point                        = (NPointSeries)chart.Series.Add(SeriesType.Point);
            m_Point.UseXValues             = true;
            m_Point.DataLabelStyle.Visible = false;
            m_Point.Size                   = new NLength(6);

            m_XCursor = new NAxisCursor();
            m_XCursor.BeginEndAxis = (int)StandardAxis.PrimaryY;
            m_YCursor = new NAxisCursor();
            m_YCursor.BeginEndAxis = (int)StandardAxis.PrimaryX;

            chart.Axis(StandardAxis.PrimaryX).Cursors.Add(m_XCursor);
            chart.Axis(StandardAxis.PrimaryY).Cursors.Add(m_YCursor);

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

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            LineSegmentRouteCombo.FillFromEnum(typeof(LineSegmentRoute));
            LineSegmentRouteCombo.SelectedIndex = 1;

            nChartControl1.MouseMove += new MouseEventHandler(OnChartControl1MouseMove);
        }
Exemplo n.º 2
0
        private void ConfigureAxisCursors()
        {
            NAxisCursor stockValueAxisCursor  = new NAxisCursor();
            NAxisCursor stockVolumeAxisCursor = new NAxisCursor();

            stockValueAxisCursor.BeginEndAxis  = (int)StandardAxis.PrimaryY;
            stockVolumeAxisCursor.BeginEndAxis = (int)StandardAxis.PrimaryY;

            // each cursor is master of the other. When the users click on one of the
            // charts this will result in an automatic update of the other cursor
            stockValueAxisCursor.Slaves.Add(stockVolumeAxisCursor);
            stockVolumeAxisCursor.Slaves.Add(stockValueAxisCursor);

            m_ChartStockValues.Axis(StandardAxis.PrimaryX).Cursors.Add(stockValueAxisCursor);
            m_ChartStockVolumes.Axis(StandardAxis.PrimaryX).Cursors.Add(stockVolumeAxisCursor);
        }
Exemplo n.º 3
0
        void OnXCursorValueChanged(object sender, EventArgs e)
        {
            NAxisCursor xCursor = (NAxisCursor)sender;

            List <NVector2DD> intersections = m_HeatMap.Get2DIntersections(new NPointD(xCursor.Value, 0), new NPointD(xCursor.Value, m_HeatMap.Data.GridSizeY));

            m_XCrossLineSeries.Values.Clear();
            m_XCrossLineSeries.XValues.Clear();

            for (int i = 0; i < intersections.Count; i++)
            {
                m_XCrossLineSeries.Values.Add(intersections[i].Y);
                m_XCrossLineSeries.XValues.Add(intersections[i].X);
            }

            nChartControl1.Refresh();
        }
Exemplo n.º 4
0
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.AutoRefresh = false;

            HorizontalAxisSnapModeComboBox.Items.Add("None");
            HorizontalAxisSnapModeComboBox.Items.Add("Ruler");
            HorizontalAxisSnapModeComboBox.Items.Add("Major ticks");
            HorizontalAxisSnapModeComboBox.Items.Add("Minor ticks");
            HorizontalAxisSnapModeComboBox.Items.Add("Ruler Min/Max");
            HorizontalAxisSnapModeComboBox.Items.Add("Nearest Value");

            VerticalAxisSnapModeComboBox.Items.Add("None");
            VerticalAxisSnapModeComboBox.Items.Add("Ruler");
            VerticalAxisSnapModeComboBox.Items.Add("Major ticks");
            VerticalAxisSnapModeComboBox.Items.Add("Minor ticks");
            VerticalAxisSnapModeComboBox.Items.Add("Ruler Min/Max");
            VerticalAxisSnapModeComboBox.Items.Add("Nearest Value");

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Data Cursor Tool");

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

            // configure chart
            m_Chart = nChartControl1.Charts[0];
            m_Chart.Series.Clear();
            m_Chart.BoundsMode = BoundsMode.Stretch;

            m_Chart.Depth  = 55.0f;
            m_Chart.Width  = 55.0f;
            m_Chart.Height = 55.0f;

            m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = GetScaleConfigurator();
            m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = GetScaleConfigurator();
            m_Chart.Axis(StandardAxis.Depth).ScaleConfigurator    = GetScaleConfigurator();

            m_Chart.Location = new NPointL(
                new NLength(10, NRelativeUnit.ParentPercentage),
                new NLength(12, NRelativeUnit.ParentPercentage));
            m_Chart.Size = new NSizeL(
                new NLength(80, NRelativeUnit.ParentPercentage),
                new NLength(78, NRelativeUnit.ParentPercentage));

            // add point series
            NPointSeries point1 = (NPointSeries)m_Chart.Series.Add(SeriesType.Point);

            point1.Name                   = "Point 1";
            point1.PointShape             = PointShape.Bar;
            point1.Size                   = new NLength(5, NGraphicsUnit.Point);
            point1.FillStyle              = new NColorFillStyle(Color.Red);
            point1.BorderStyle.Color      = Color.Pink;
            point1.DataLabelStyle.Visible = false;
            point1.UseXValues             = true;
            point1.UseZValues             = true;
            point1.InflateMargins         = true;

            // fill with random data
            int itemCount = 70;

            point1.Values.FillRandomRange(Random, itemCount, 0, 50);
            point1.XValues.FillRandomRange(Random, itemCount, 0, 50);
            point1.ZValues.FillRandomRange(Random, itemCount, 0, 50);

            // add cursors
            m_HorizontalAxisCursor = new NAxisCursor();
            m_HorizontalAxisCursor.BeginEndAxis  = (int)StandardAxis.PrimaryY;
            m_HorizontalAxisCursor.ValueChanged += new EventHandler(OnValueChanged);

            m_VerticalAxisCursor = new NAxisCursor();
            m_VerticalAxisCursor.BeginEndAxis  = (int)StandardAxis.PrimaryX;
            m_VerticalAxisCursor.ValueChanged += new EventHandler(OnValueChanged);

            NAxis primaryXAxis = m_Chart.Axis(StandardAxis.PrimaryX);
            NAxis primaryYAxis = m_Chart.Axis(StandardAxis.PrimaryY);
            NAxis depthAxis    = m_Chart.Axis(StandardAxis.Depth);

            primaryXAxis.Cursors.Add(m_HorizontalAxisCursor);
            primaryYAxis.Cursors.Add(m_VerticalAxisCursor);

            m_HorizontalAxisCursor.SynchronizeOnMouseAction = MouseAction.None;
            m_VerticalAxisCursor.SynchronizeOnMouseAction   = MouseAction.None;

            nChartControl1.Controller.Selection.Add(m_Chart);
            nChartControl1.Controller.Tools.Add(new NDataCursorTool());

            MouseMoveCheckBox.Checked = true;
            HorizontalAxisSnapModeComboBox.SelectedIndex = 0;
            VerticalAxisSnapModeComboBox.SelectedIndex   = 0;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Called to initialize the example
        /// </summary>
        /// <param name="chartControl"></param>
        public override void Create()
        {
            // turn off the legend
            nChartControl1.Legends[0].Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Intersect Line with X/Y Value");

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

            // configure the chart
            NChart m_Chart = nChartControl1.Charts[0];

            m_HorizontalAxisCursor = new NAxisCursor();
            m_HorizontalAxisCursor.BeginEndAxis  = (int)StandardAxis.PrimaryY;
            m_HorizontalAxisCursor.ValueChanged += new EventHandler(OnAxisCursorValueChanged);

            m_VerticalAxisCursor = new NAxisCursor();
            m_VerticalAxisCursor.BeginEndAxis  = (int)StandardAxis.PrimaryX;
            m_VerticalAxisCursor.ValueChanged += new EventHandler(OnAxisCursorValueChanged);

            m_Chart.Axis(StandardAxis.PrimaryX).Cursors.Add(m_HorizontalAxisCursor);
            m_Chart.Axis(StandardAxis.PrimaryY).Cursors.Add(m_VerticalAxisCursor);

            m_HorizontalAxisCursor.SynchronizeOnMouseAction |= MouseAction.Move;
            m_VerticalAxisCursor.SynchronizeOnMouseAction   |= MouseAction.Move;

            // 2D line chart
            m_Chart.Series.Clear();
            m_Chart.BoundsMode = BoundsMode.Stretch;

            m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = GetScaleConfigurator();
            m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = GetScaleConfigurator();
            m_Chart.Axis(StandardAxis.Depth).Visible = false;

            NAxisCollection axes = m_Chart.Axes;

            m_Chart.Location = new NPointL(
                new NLength(10, NRelativeUnit.ParentPercentage),
                new NLength(12, NRelativeUnit.ParentPercentage));
            m_Chart.Size = new NSizeL(
                new NLength(80, NRelativeUnit.ParentPercentage),
                new NLength(78, NRelativeUnit.ParentPercentage));

            // add point series
            m_Point                        = (NPointSeries)m_Chart.Series.Add(SeriesType.Point);
            m_Point.UseXValues             = true;
            m_Point.FillStyle              = new NColorFillStyle(Color.Red);
            m_Point.DataLabelStyle.Visible = false;
            m_Point.Size                   = new NLength(2);

            m_Line                        = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
            m_Line.Name                   = "Point 1";
            m_Line.FillStyle              = new NColorFillStyle(Color.Red);
            m_Line.BorderStyle.Color      = Color.Pink;
            m_Line.DataLabelStyle.Visible = false;
            m_Line.UseXValues             = true;
            m_Line.InflateMargins         = true;

            // fill with random data
            Random rand   = new Random();
            double radius = 1000;
            double angle  = 0;

            double rStep = 10;
            double aStep = 10;

            for (int i = 0; i < 1000; i++)
            {
                double y = Math.Sin(angle * 0.0174533f) * radius;
                double x = Math.Cos(angle * 0.0174533f) * radius;

                m_Line.XValues.Add(x);
                m_Line.Values.Add(y);

                radius += rStep;
                angle  += aStep;
            }

            nChartControl1.Controller.Tools.Clear();
            nChartControl1.Controller.Selection.SelectedObjects.Add(m_Chart);
            nChartControl1.Controller.Tools.Add(new NDataCursorTool());
        }
Exemplo n.º 6
0
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Heat Map Cross Section");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue);
            title.DockMode            = PanelDockMode.Top;
            nChartControl1.Panels.Add(title);

            {
                NCartesianChart heatMapChart = new NCartesianChart();
                nChartControl1.Panels.Add(heatMapChart);

                heatMapChart.DockMode   = PanelDockMode.Left;
                heatMapChart.Size       = new NSizeL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(0));
                heatMapChart.BoundsMode = BoundsMode.Stretch;
                heatMapChart.Margins    = new NMarginsL(10);
                heatMapChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator            = new NLinearScaleConfigurator();
                heatMapChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator.Title.Text = "X Value";
                heatMapChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator.Title.Text = "Y Value";

                // create the heat map
                m_HeatMap = new NHeatMapSeries();
                heatMapChart.Series.Add(m_HeatMap);

                m_HeatMap.Palette.Add(0.0, Color.Purple);
                m_HeatMap.Palette.Add(1.5, Color.MediumSlateBlue);
                m_HeatMap.Palette.Add(3.0, Color.CornflowerBlue);
                m_HeatMap.Palette.Add(4.5, Color.LimeGreen);
                m_HeatMap.Palette.Add(6.0, Color.LightGreen);
                m_HeatMap.Palette.Add(7.5, Color.Yellow);
                m_HeatMap.Palette.Add(9.0, Color.Orange);
                m_HeatMap.Palette.Add(10.5, Color.Red);
                m_HeatMap.XValuesMode      = HeatMapValuesMode.OriginAndStep;
                m_HeatMap.YValuesMode      = HeatMapValuesMode.OriginAndStep;
                m_HeatMap.InterpolateImage = true;

                m_HeatMap.ContourDisplayMode = ContourDisplayMode.None;
                m_HeatMap.Legend.Mode        = SeriesLegendMode.SeriesLogic;
                m_HeatMap.Legend.Format      = "<zone_value>";

                m_XCursor = new NAxisCursor();
                m_XCursor.BeginEndAxis      = (int)StandardAxis.PrimaryY;
                m_XCursor.StrokeStyle.Width = new NLength(2);
                heatMapChart.Axis(StandardAxis.PrimaryX).Cursors.Add(m_XCursor);
                m_XCursor.ValueChanged += new EventHandler(OnXCursorValueChanged);

                m_YCursor = new NAxisCursor();
                m_YCursor.BeginEndAxis      = (int)StandardAxis.PrimaryX;
                m_YCursor.StrokeStyle.Width = new NLength(2);
                heatMapChart.Axis(StandardAxis.PrimaryY).Cursors.Add(m_YCursor);
                m_YCursor.ValueChanged += new EventHandler(OnYCursorValueChanged);

                GenerateData();
            }

            {
                NDockPanel dockPanel = new NDockPanel();
                dockPanel.DockMode = PanelDockMode.Fill;
                dockPanel.PositionChildPanelsInContentBounds = true;
                dockPanel.Margins = new NMarginsL(10);

                NCartesianChart xCrossSectionChart;
                CreateCrossSectionChart(out xCrossSectionChart, out m_XCrossLineSeries);
                xCrossSectionChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator.Title.Text = "X Value";
                xCrossSectionChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator.Title.Text = "Value";
                dockPanel.ChildPanels.Add(xCrossSectionChart);

                NCartesianChart yCrossSectionChart;
                CreateCrossSectionChart(out yCrossSectionChart, out m_YCrossLineSeries);
                yCrossSectionChart.Axis(StandardAxis.PrimaryX).ScaleConfigurator.Title.Text = "Y Value";
                yCrossSectionChart.Axis(StandardAxis.PrimaryY).ScaleConfigurator.Title.Text = "Value";
                dockPanel.ChildPanels.Add(yCrossSectionChart);

                nChartControl1.Panels.Add(dockPanel);

                // align the two charts
                NSideGuideline guideline = new NSideGuideline(PanelSide.Left);

                guideline.Targets.Add(xCrossSectionChart);
                guideline.Targets.Add(yCrossSectionChart);

                nChartControl1.Document.RootPanel.Guidelines.Add(guideline);
            }

            m_XCursor.Value = m_GridSizeX / 2.0;
            m_YCursor.Value = m_GridSizeY / 2.0;

            nChartControl1.Controller.Tools.Add(new NSelectorTool());
            nChartControl1.Controller.Tools.Add(new NAxisCursorDragTool());
        }