Esempio 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);
        }
Esempio n. 2
0
        public void DrawPlot(CGContext context, IPointDataSource dataSource, IEnumerable <IPointEntry> highlightedEntries, IViewPort viewPort, IXAxis xAxis, IYAxis yAxis)
        {
            var visibleSourceRange = VisibleSourceXRange(xAxis, viewPort);

            var visibleSourceRangeStart = Math.Floor(visibleSourceRange.Item1);

            var visibleSourceRangeEnd = Math.Ceiling(visibleSourceRange.Item2);

            if (Style.BezierCurve)
            {//для отображения кривых нужны дополнительные точки для рассчета опорных точек
             //TODO учитывать масштаб
                visibleSourceRangeStart--;
                visibleSourceRangeEnd++;
            }

            var visibleEntries = dataSource.GetEntriesInRange(visibleSourceRangeStart, visibleSourceRangeEnd);

            Draw(context, visibleEntries, highlightedEntries, viewPort, xAxis, yAxis, Style);
        }