Beispiel #1
0
 private void OnEntryClick(int index, PieEntry entry)
 {
     for (int i = 0; i < clickDelegates.Count; i++)
     {
         clickDelegates[i].Invoke(index, entry);
     }
 }
Beispiel #2
0
        private void UpdateValueIndicatorView(PieChartValueIndicator view,
                                              PieEntry entry,
                                              float rotation,
                                              float percentValue)
        {
            float   entryCenterAngle   = rotation + (percentValue / 2 * 360);
            bool    leftSide           = entryCenterAngle % 360f > 180f;
            int     leftSideMultiplier = leftSide ? -1 : 1;
            Vector2 position0          = MathUtils.GetPositionOnCircle(entryCenterAngle,
                                                                       GetChartRadius() + ENTRY_INDICATOR_LINE_SPACING +
                                                                       (selectedEntries.Contains(entry) ? SELECTED_ENTRY_OFFSET : 0f));
            Vector2 position1 = MathUtils.GetPositionOnCircle(entryCenterAngle,
                                                              GetChartRadius() + Config.ValueIndicatorLineLength + ENTRY_INDICATOR_LINE_SPACING +
                                                              (selectedEntries.Contains(entry) ? SELECTED_ENTRY_OFFSET : 0f));
            Vector2 position2     = position1 + new Vector2(Config.ValueIndicatorLineLength * leftSideMultiplier, 0f);
            Vector2 positionLabel = position2 + new Vector2(ENTRY_INDICATOR_LINE_SPACING * leftSideMultiplier, 0f);
            var     linePoints    = new List <Vector2> {
                position0 - positionLabel,
                position1 - positionLabel,
                position2 - positionLabel
            };

            view.GetComponent <RectTransform>().anchoredPosition = positionLabel;
            view.Label          = CreateValueIndicatorLabel(entry, percentValue);
            view.FontSize       = Config.ValueIndicatorFontSize;
            view.IndicatorColor = Config.ValueIndicatorColor;
            view.LinePoints     = linePoints;
            view.ReversedLabel  = leftSide;
        }
Beispiel #3
0
        public void DeselectEntryAtPosition(int position)
        {
            PieEntry entry = data.DataSet.GetEntryAt(position);

            if (entry != null && selectedEntries.Contains(entry))
            {
                selectedEntries.Remove(entry);
                SetDirty();
            }
        }
 private void OnEntryClick(int index, PieEntry entry)
 {
     if (!pieChart.IsEntryAtPositionSelected(index))
     {
         pieChart.SelectEntryAtPosition(index);
     }
     else
     {
         pieChart.DeselectEntryAtPosition(index);
     }
 }
Beispiel #5
0
        private void FillEntryView(PieChartEntryView view,
                                   PieEntry entry,
                                   float totalValue,
                                   float percentValue,
                                   float rotation)
        {
            view.TotalValue         = totalValue;
            view.Entry              = entry;
            view.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, -rotation));

            float   centerAngle = rotation + (percentValue / 2 * 360);
            Vector2 position    = selectedEntries.Contains(entry) ?
                                  MathUtils.GetPositionOnCircle(centerAngle, SELECTED_ENTRY_OFFSET) :
                                  Vector2.zero;

            float diameter = GetChartRadius() * 2;

            view.GetComponent <RectTransform>().sizeDelta        = new Vector2(diameter, diameter);
            view.GetComponent <RectTransform>().anchoredPosition = position;
        }
Beispiel #6
0
 private String CreateValueIndicatorLabel(PieEntry entry, float percentValue)
 {
     return(String.Format("{0}: {1}%", entry.Label, (percentValue * 100).ToString("0.00")));
 }
Beispiel #7
0
 private bool ShouldValueIndicatorBeEnabled(PieEntry entry)
 {
     return(Config.ValueIndicatorVisibility == PieChartConfig.ValueIndicatorVisibilityMode.ALWAYS ||
            (Config.ValueIndicatorVisibility == PieChartConfig.ValueIndicatorVisibilityMode.ONLY_SELECTED && selectedEntries.Contains(entry)));
 }