Exemplo n.º 1
0
        /// <summary>
        /// Returns an array of Highlight objects for the given index. The Highlight
        /// objects give information about the value at the selected index and the
        /// DataSet it belongs to. INFORMATION: This method does calculations at <paramref name="index"/>
        /// runtime. Do not over-use in performance critical situations.
        /// <returns></returns>
        protected List <Highlight> GetHighlightsAtIndex(int index)
        {
            highlightBuffer.Clear();

            float phaseX     = Chart.Animator.PhaseX;
            float phaseY     = Chart.Animator.PhaseY;
            float sliceangle = Chart.SliceAngle;
            float factor     = Chart.Factor;

            var data = Chart.Data;

            for (int i = 0; i < data.DataSetCount; i++)
            {
                IDataSet <RadarEntry> dataSet = data[i];

                Entry entry = dataSet[index];

                float y = entry.Y - Chart.YChartMin;

                var pOut = ChartUtil.GetPosition(
                    Chart.CenterOffsets, y * factor * phaseY,
                    sliceangle * index * phaseX + Chart.RotationAngle);

                highlightBuffer.Add(new Highlight(index, entry.Y, pOut.X, pOut.Y, i, dataSet.AxisDependency));
            }

            return(highlightBuffer);
        }
        public override void RenderAxisLabels(SKCanvas c)
        {
            if (!YAxis.IsEnabled || !YAxis.IsDrawLabelsEnabled)
            {
                return;
            }

            AxisLabelPaint.Typeface = YAxis.Typeface;
            AxisLabelPaint.TextSize = YAxis.TextSize;
            AxisLabelPaint.Color    = YAxis.TextColor;

            // calculate the factor that is needed for transforming the value to
            // pixels
            float factor = Chart.Factor;
            var   center = Chart.CenterOffsets;

            int from = YAxis.DrawBottomYLabelEntry ? 0 : 1;
            int to   = YAxis.DrawTopYLabelEntry
                    ? YAxis.EntryCount
                    : (YAxis.EntryCount - 1);

            float xOffset = YAxis.XLabelOffset;

            for (int j = from; j < to; j++)
            {
                float r = (YAxis.entries[j] - YAxis.axisMinimum) * factor;

                var pOut = ChartUtil.GetPosition(center, r, Chart.RotationAngle);

                var label = YAxis.GetFormattedLabel(j);

                c.DrawText(label, pOut.X + xOffset, pOut.Y, AxisLabelPaint);
            }
        }
        public override void RenderLimitLines(SKCanvas c)
        {
            var limitLines = YAxis.LimitLines;

            if (limitLines == null)
            {
                return;
            }

            float sliceangle = Chart.SliceAngle;

            // calculate the factor that is needed for transforming the value to
            // pixels
            float factor = Chart.Factor;

            var center = Chart.CenterOffsets;

            for (int i = 0; i < limitLines.Count; i++)
            {
                LimitLine l = limitLines[i];

                if (!l.IsEnabled)
                {
                    continue;
                }

                LimitLinePaint.Color       = l.LineColor;
                LimitLinePaint.PathEffect  = l.DashPathEffect;
                LimitLinePaint.StrokeWidth = l.LineWidth;

                float r = (l.Limit - Chart.YChartMin) * factor;

                var limitPath = RenderLimitLinesPathBuffer;
                limitPath.Reset();


                int entryCount = Chart.Data.GetMaxEntryCountSet().EntryCount;
                for (int j = 0; j < entryCount; j++)
                {
                    var pOut = ChartUtil.GetPosition(center, r, sliceangle * j + Chart.RotationAngle);

                    if (j == 0)
                    {
                        limitPath.MoveTo(pOut.X, pOut.Y);
                    }
                    else
                    {
                        limitPath.LineTo(pOut.X, pOut.Y);
                    }
                }
                limitPath.Close();

                c.DrawPath(limitPath, LimitLinePaint);
            }
        }
        public override void RenderAxisLabels(SKCanvas c)
        {
            if (!XAxis.IsEnabled || !XAxis.IsDrawLabelsEnabled)
            {
                return;
            }

            float labelRotationAngleDegrees = XAxis.LabelRotationAngle;
            var   drawLabelAnchor           = LabelAnchor;

            AxisLabelPaint.Typeface = XAxis.Typeface;
            AxisLabelPaint.TextSize = XAxis.TextSize;
            AxisLabelPaint.Color    = XAxis.TextColor;

            float sliceangle = Chart.SliceAngle;

            // calculate the factor that is needed for transforming the value to
            // pixels
            float factor = Chart.Factor;

            var center     = Chart.CenterOffsets;
            int entryCount = Chart.Data.GetMaxEntryCountSet().EntryCount;

            for (int i = 0; i < entryCount; i++)
            {
                var label = XAxis.ValueFormatter.GetFormattedValue(i, XAxis);

                float angle = (sliceangle * i + Chart.RotationAngle) % 360f;

                SKPoint pOut = ChartUtil.GetPosition(center, Chart.YRange * factor
                                                     + XAxis.LabelRotatedWidth / 2f, angle);

                DrawLabel(c, label, pOut.X, pOut.Y - XAxis.LabelRotatedHeight / 2.0f,
                          drawLabelAnchor, labelRotationAngleDegrees);
            }
        }