Exemplo n.º 1
0
        public bool Tap(CGPoint tapContentLocation, IChartView chartView, IPointDataSource pointDataSource, IPointHighlightHandler highlightHandler, IXAxis xAxis, IYAxis yAxis)
        {
            double sourcePositionStart = xAxis.GetSourceValue(tapContentLocation.X - TapDistance);

            var sourcePositionEnd = xAxis.GetSourceValue(tapContentLocation.X + TapDistance);

            var entriesInTapRange = pointDataSource
                                    .GetEntriesInRange(sourcePositionStart, sourcePositionEnd)
                                    .Select((IPointEntry entry) => new { Entry = entry, Distance = GetDistance(tapContentLocation, entry, xAxis, yAxis) })
                                    .Where((t) => t.Distance <= TapDistance)
                                    .OrderBy(p => p.Distance);

            var entryNearestToTap = entriesInTapRange.FirstOrDefault();

            if (entryNearestToTap != null)
            {
                highlightHandler.TapOnEntries(Multiselect ? entriesInTapRange.Select(t => t.Entry) : new List <IPointEntry> {
                    entryNearestToTap.Entry
                });
            }
            else
            {
                highlightHandler.TapOnNoEntry();
            }

            return(entryNearestToTap != null);
        }
Exemplo n.º 2
0
        protected virtual void DrawLabels(CGContext context, IViewPort viewPort, IXAxis xAxis, nfloat axisLineStart, nfloat axisLineEnd, nfloat axisYPosition, TextStyle textStyle)
        {
            var visibleSourceRangeStart = Math.Floor(xAxis.GetSourceValue(viewPort.ViewPortContentOffset.X));

            var visibleSourceRangeEnd = Math.Ceiling(xAxis.GetSourceValue(viewPort.ViewPortContentOffset.X + viewPort.ViewPortSize.Width));

            var labels = new List <Tuple <double, string> >();

            for (double i = visibleSourceRangeStart; i <= visibleSourceRangeEnd; i += Step)
            {
                var text = ValueFormatter(i);

                if (!string.IsNullOrEmpty(text))
                {
                    labels.Add(new Tuple <double, string>(i, text));
                }
            }

            DrawLabels(context, viewPort, xAxis, axisYPosition, axisLineStart, axisLineEnd, textStyle, labels);
        }
Exemplo n.º 3
0
 protected Tuple <double, double> VisibleSourceXRange(IXAxis xAxis, IViewPort viewPort)
 => new Tuple <double, double>(xAxis.GetSourceValue(viewPort.ViewPortContentOffset.X), xAxis.GetSourceValue(viewPort.ViewPortContentOffset.X + viewPort.ViewPortSize.Width));