Esempio n. 1
0
        public PieChartEntryView InstantiatePieChartEntryView(string name, Transform parent, Vector2 pivot)
        {
            PieChartEntryView entryView = CreateBaseGameObject(name, parent, pivot)
                                          .AddComponent <PieChartEntryView> ();
            RectTransform transform = entryView.GetComponent <RectTransform> ();

            transform.anchorMin = new Vector2(0.5f, 0.5f);
            transform.anchorMax = new Vector2(0.5f, 0.5f);

            return(entryView);
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
        private void UpdateEntryViewsInstances(int requiredCount)
        {
            int currentCount = entryViews.Count;

            int missingCount = requiredCount - currentCount;

            while (missingCount > 0)
            {
                entryViews.Add(CreateEntryView());
                missingCount--;
            }

            int redundantCount = currentCount - requiredCount;

            while (redundantCount > 0)
            {
                PieChartEntryView target = entryViews[entryViews.Count - 1];
                DestroyDelayed(target.gameObject);
                entryViews.Remove(target);
                redundantCount--;
            }
        }