コード例 #1
0
        private void ConfigureInteractivity(NChart chart)
        {
            NInteractor interactor = new NInteractor();

            NRectangleZoomTool rectangleZoomTool = new NRectangleZoomTool();

            rectangleZoomTool.Enabled = true;
            rectangleZoomTool.VerticalValueSnapper = new NAxisRulerMinMaxSnapper();
            interactor.Add(rectangleZoomTool);

            NDataPanTool dataPanTool = new NDataPanTool();

            dataPanTool.StartMouseButtonEvent = ENMouseButtonEvent.RightButtonDown;
            dataPanTool.EndMouseButtonEvent   = ENMouseButtonEvent.RightButtonUp;
            dataPanTool.Enabled = true;
            interactor.Add(dataPanTool);

            chart.Interactor = interactor;
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Rectangle Zoom Tool";

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

            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

            // setup X axis
            NLinearScale scaleX = new NLinearScale();

            scaleX.MajorGridLines = new NScaleGridLines();
            scaleX.MajorGridLines.Stroke.DashStyle       = ENDashStyle.Dot;
            m_Chart.Axes[ENCartesianAxis.PrimaryX].Scale = scaleX;

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

            scaleY.MajorGridLines = new NScaleGridLines();
            scaleY.MajorGridLines.Stroke.DashStyle       = ENDashStyle.Dot;
            m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale = scaleY;

            // add a point series
            m_Point                = new NPointSeries();
            m_Point.Name           = "Point Series";
            m_Point.DataLabelStyle = new NDataLabelStyle(false);
            m_Point.Fill           = new NColorFill(new NColor(NColor.DarkOrange, 160));
            m_Point.Size           = 5;
            m_Point.Shape          = ENPointShape.Rectangle;
            m_Point.UseXValues     = true;
            m_Chart.Series.Add(m_Point);

            // add some sample data
            NDataPointCollection <NPointDataPoint> dataPoints = m_Point.DataPoints;

            Random random = new Random();

            for (int i = 0; i < 1000; i++)
            {
                double u1 = random.NextDouble();
                double u2 = random.NextDouble();

                if (u1 == 0)
                {
                    u1 += 0.0001;
                }

                if (u2 == 0)
                {
                    u2 += 0.0001;
                }

                double z0 = Math.Sqrt(-2 * Math.Log(u1)) * Math.Cos(2 * Math.PI * u2);
                double z1 = Math.Sqrt(-2 * Math.Log(u1)) * Math.Sin(2 * Math.PI * u2);

                dataPoints.Add(new NPointDataPoint(z0, z1));
            }

            m_Chart.Enabled = true;
            NInteractor interactor = new NInteractor();

            m_RectangleZoomTool         = new NRectangleZoomTool();
            m_RectangleZoomTool.Enabled = true;
            interactor.Add(m_RectangleZoomTool);

            NDataPanTool dataPanTool = new NDataPanTool();

            dataPanTool.StartMouseButtonEvent = ENMouseButtonEvent.RightButtonDown;
            dataPanTool.EndMouseButtonEvent   = ENMouseButtonEvent.RightButtonUp;
            dataPanTool.Enabled = true;
            interactor.Add(dataPanTool);

            m_Chart.Interactor = interactor;


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

            return(chartView);
        }