Beispiel #1
0
        /// <summary>
        /// Create a URL for a <see cref="CurveItem" /> that includes the index of the
        /// point that was selected.
        /// </summary>
        /// <remarks>
        /// An "index" parameter is added to the <see cref="Url" /> property for this
        /// link to indicate which point was selected.  Further, if the
        /// X or Y axes that correspond to this <see cref="CurveItem" /> are of
        /// <see cref="AxisType.Text" />, then an
        /// additional parameter will be added containing the text value that
        /// corresponds to the <paramref name="index" /> of the selected point.
        /// The <see cref="XAxis" /> text parameter will be labeled "xtext", and
        /// the <see cref="YAxis" /> text parameter will be labeled "ytext".
        /// </remarks>
        /// <param name="index">The zero-based index of the selected point</param>
        /// <param name="pane">The <see cref="GraphPane" /> of interest</param>
        /// <param name="curve">The <see cref="CurveItem" /> for which to
        /// make the url string.</param>
        /// <returns>A string containing the url with an index parameter added.</returns>
        public virtual string MakeCurveItemUrl(GraphPane pane, CurveItem curve, int index)
        {
            string url = _url;

            if (url.IndexOf('?') >= 0)
            {
                url += "&index=" + index.ToString();
            }
            else
            {
                url += "?index=" + index.ToString();
            }

            Axis xAxis = curve.GetXAxis(pane);

            if (xAxis.Type == AxisType.Text && index >= 0 &&
                xAxis.Scale.TextLabels != null &&
                index <= xAxis.Scale.TextLabels.Length)
            {
                url += "&xtext=" + xAxis.Scale.TextLabels[index];
            }

            Axis yAxis = curve.GetYAxis(pane);

            if (yAxis != null && yAxis.Type == AxisType.Text && index >= 0 &&
                yAxis.Scale.TextLabels != null &&
                index <= yAxis.Scale.TextLabels.Length)
            {
                url += "&ytext=" + yAxis.Scale.TextLabels[index];
            }

            return(url);
        }
Beispiel #2
0
        private bool HandlePointValues(PointF mousePt, ZedGraphControl sender)
        {
            int       iPt;
            GraphPane pane;
            object    nearestObj;

            using (Graphics g = this.CreateGraphics())
            {
                if (sender.MasterPane.FindNearestPaneObject(mousePt,
                                                            g, out pane, out nearestObj, out iPt))
                {
                    if (nearestObj is CurveItem && iPt >= 0)
                    {
                        CurveItem curve = (CurveItem)nearestObj;
                        // Provide Callback for User to customize the tooltips
                        PointPair pt = curve.Points[iPt];

                        if (pt.Tag is string)
                        {
                            this.toolTip1.SetToolTip(this, (string)pt.Tag);
                        }
                        else
                        {
                            double       xVal, yVal, lowVal;
                            ValueHandler valueHandler = new ValueHandler(pane, false);
                            if ((curve is BarItem || curve is ErrorBarItem || curve is HiLowBarItem) &&
                                pane.BarSettings.Base != BarBase.X)
                            {
                                valueHandler.GetValues(curve, iPt, out yVal, out lowVal, out xVal);
                            }
                            else
                            {
                                valueHandler.GetValues(curve, iPt, out xVal, out lowVal, out yVal);
                            }

                            string xStr = MakeValueLabel(curve.GetXAxis(pane), xVal, iPt, curve.IsOverrideOrdinal);
                            string yStr = MakeValueLabel(curve.GetYAxis(pane), yVal, iPt, curve.IsOverrideOrdinal);

                            this.toolTip1.SetToolTip(sender, xStr + "\n" + yStr);
                            this.toolTip1.ForeColor = curve.Color;
                            this.toolTip1.BackColor = Color.Black;
                            toolTip1.Active         = true;
                            //this.pointToolTip.SetToolTip( this,
                            //  curve.Points[iPt].ToString( this.pointValueFormat ) );
                        }
                    }
                    else
                    {
                        toolTip1.Active = false;
                    }
                }
                else
                {
                    toolTip1.Active = false;
                }

                //g.Dispose();
            }
            return(true);
        }
        private static Point TransformToFormPoint(CurveItem curve, GraphPane gp, int iPt)
        {
            //todo : make sure that it is for form
            int x = (int)(curve.GetXAxis(gp).Scale.Transform(curve.Points[iPt].X) + 0.5);
            int y = (int)(curve.GetYAxis(gp).Scale.Transform(curve.Points[iPt].Y) + 0.5);

            return(new Point(x, y));
        }
Beispiel #4
0
        public DataFrameBuilder(GraphPane graphPane, CurveItem curveItem)
        {
            GraphPane = graphPane;
            CurveItem = curveItem;
            var msPointList = curveItem.Points as MSPointList;

            if (msPointList != null)
            {
                Points = msPointList.FullList;
            }
            else
            {
                Points = curveItem.Points;
            }
            XAxis     = curveItem.GetXAxis(graphPane);
            YAxis     = curveItem.GetYAxis(graphPane);
            BaseAxis  = curveItem.BaseAxis(graphPane);
            ValueAxis = curveItem.ValueAxis(graphPane);
        }
Beispiel #5
0
        public void DrawFilled(Graphics g, GraphPane pane, CurveItem curve, float scaleFactor)
        {
            var source = this;

            var yAxis = curve.GetYAxis(pane);
            var xAxis = curve.GetXAxis(pane);

            var basePix = yAxis.Scale.Transform(0.0);

            using (var pen = source.GetPen(pane, scaleFactor))
            {
                var list1 = new List <PointF>();
                var list2 = new List <PointF>();
                for (var i = 0; i < curve.Points.Count; i++)
                {
                    var pt = curve.Points[i];

                    if (pt.X != PointPair.Missing &&
                        pt.Y != PointPair.Missing &&
                        !Double.IsNaN(pt.X) &&
                        !Double.IsNaN(pt.Y) &&
                        !Double.IsInfinity(pt.X) &&
                        !Double.IsInfinity(pt.Y) &&
                        (!xAxis.Scale.IsLog || pt.X > 0.0) &&
                        (!yAxis.Scale.IsLog || pt.Y > 0.0))
                    {
                        var pixY = yAxis.Scale.Transform(curve.IsOverrideOrdinal, i, pt.Y);
                        var pixX = xAxis.Scale.Transform(curve.IsOverrideOrdinal, i, pt.X);
                        var pixZ = yAxis.Scale.Transform(curve.IsOverrideOrdinal, i, pt.Z);
                        list1.Add(new PointF(pixX, pixY));
                        list2.Add(new PointF(pixX, pixZ));
                    }
                }
                list2.Reverse();
                list1.AddRange(list2);
                var points = list1.ToArray();

                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.FillPolygon(Fill.Brush, points);

                g.DrawPolygon(pen, points);
            }
        }