Exemplo n.º 1
0
        void nChartControl1_MouseMove(object sender, MouseEventArgs e)
        {
            NViewToScale2DTransformation view2Scale = new NViewToScale2DTransformation(nChartControl1.Charts[0], (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY);

            NVector2DD pointScale = new NVector2DD();

            view2Scale.Transform(new NPointF(e.X, e.Y), ref pointScale);

            this.ValueTextBox.Text = m_HeatMap.GetValueFromPosition(new NPointD(pointScale.X, pointScale.Y)).ToString();
        }
        protected void nChartControl2_AsyncCustomCommand(object sender, EventArgs e)
        {
            NCallbackCustomCommandArgs args = e as NCallbackCustomCommandArgs;

            switch (args.Command.Name)
            {
            case "displayDataWindow":
                double dataWindowWidth = double.Parse(args.Command.Arguments["width"] as string);

                NCartesianChart   zoomChart = nChartControl2.Charts[0] as NCartesianChart;
                NSmoothLineSeries zoomLine  = zoomChart.Series[0] as NSmoothLineSeries;

                NCartesianChart previewChart = nChartControl1.Charts[0] as NCartesianChart;
                NAxis           previewXAxis = previewChart.Axis(StandardAxis.PrimaryX);

                NPointF    ptViewPoint   = new NPointF(float.Parse(args.Command.Arguments["x"] as string), 0);
                NVector2DD vecScalePoint = new NVector2DD();

                using (NChartRasterView view = new NChartRasterView(nChartControl1.Document, nChartControl1.Dimensions, NResolution.ScreenResolution))
                {
                    view.RecalcLayout();

                    NViewToScale2DTransformation viewToScale = new NViewToScale2DTransformation(
                        view.Context,
                        previewChart,
                        (int)StandardAxis.PrimaryX,
                        (int)StandardAxis.PrimaryY
                        );

                    if (viewToScale.Transform(ptViewPoint, ref vecScalePoint))
                    {
                        double rangeMin = vecScalePoint.X - dataWindowWidth / 2;
                        rangeMin = previewXAxis.Scale.ViewRange.GetValueInRange(rangeMin);

                        double rangeMax = rangeMin + dataWindowWidth;
                        rangeMax = previewXAxis.Scale.ViewRange.GetValueInRange(rangeMax);

                        rangeMin = rangeMax - dataWindowWidth;

                        // reinitialize data points
                        zoomLine.XValues.Clear();
                        zoomLine.Values.Clear();
                        for (int i = (int)rangeMin; i <= (int)rangeMax; i++)
                        {
                            zoomLine.XValues.Add(i);
                            zoomLine.Values.Add(waveData[i]);
                        }
                    }
                }
                break;
            }
        }
Exemplo n.º 3
0
            /// <summary>
            /// Overriden to perform dragging
            /// </summary>
            /// <param name=`$:7` ></param>
            /// <param name=`$:8` ></param>
            public override void OnDoDrag(object sender, NMouseEventArgs e)
            {
                NChart chart = this.GetDocument().Charts[0];
                NViewToScale2DTransformation viewToScale = new NViewToScale2DTransformation(this.GetChartControlView().Context, chart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY);

                NVector2DD pointScale = new NVector2DD();

                if (viewToScale.Transform(new NPointF(e.X, e.Y), ref pointScale))
                {
                    // clamp y value to ruler range
                    double yValue = chart.Axis(StandardAxis.PrimaryX).Scale.RulerRange.GetValueInRange(pointScale.X);
                    m_ConstLine.Value = yValue;

                    chart.Refresh();
                    Repaint();
                }
            }
            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);
                    }
                }
            }
        void OnChartControl1MouseMove(object sender, MouseEventArgs e)
        {
            nChartControl1.RecalcLayout();
            NViewToScale2DTransformation viewScale = new NViewToScale2DTransformation(nChartControl1.Charts[0], (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY);

            NVector2DD value = new NVector2DD();

            viewScale.Transform(new Nevron.GraphicsCore.NPointF(e.X, e.Y), ref value);

            m_XCursor.Value = value.X;
            m_YCursor.Value = value.Y;

            m_Point.Values.Clear();
            m_Point.XValues.Clear();
            m_Point.FillStyles.Clear();

            List <double> xIntersections = m_Line.IntersectWithXValue(value.X);

            for (int i = 0; i < xIntersections.Count; i++)
            {
                m_Point.XValues.Add(value.X);
                m_Point.Values.Add(xIntersections[i]);
                m_Point.FillStyles[m_Point.Values.Count - 1] = new NColorFillStyle(Color.Red);
            }

            List <double> yIntersections = m_Line.IntersectWithYValue(value.Y);

            for (int i = 0; i < yIntersections.Count; i++)
            {
                m_Point.Values.Add(value.Y);
                m_Point.XValues.Add(yIntersections[i]);
                m_Point.FillStyles[m_Point.Values.Count - 1] = new NColorFillStyle(Color.Blue);
            }

            nChartControl1.Refresh();
        }