Esempio n. 1
0
        public LabelPosition[] GetAxisXPositions()
        {
            if (values.isEmpty)
            {
                return(null);
            }

            LabelPosition[] ret = new LabelPosition[values.Columns];

            float w   = rectTransform.rect.width / (float)(values.Columns * values.Rows + (values.Columns - 1));
            float gap = w * spacing;

            w = (rectTransform.rect.width - gap * (float)(values.Columns - 1)) / (float)(values.Columns * values.Rows);
            float rows = values.Rows;

            float x0 = -rectTransform.rect.width / 2.0f;
            float y0 = -rectTransform.rect.height / 2.0f;

            for (int i = 0; i < values.Columns; i++)
            {
                LabelPosition pos = new LabelPosition();
                pos.position = new Vector2(x0 + (((i + 0.5f) * rows) * w + (i * gap)), y0);
                ret[i]       = pos;
            }
            return(ret);
        }
Esempio n. 2
0
        public LabelPosition[] GetAxisYPositions()
        {
            if (values.isEmpty)
            {
                return(null);
            }

            List <LabelPosition> ret = new List <LabelPosition>();

            float range;
            float y0;

            if (min >= 0)
            {
                range = max;
                y0    = -rectTransform.rect.height / 2.0f;
            }
            else if (max <= 0)
            {
                range = Mathf.Abs(min);
                y0    = rectTransform.rect.height / 2.0f;
            }
            else
            {
                range = max - min;
                y0    = -rectTransform.rect.height / 2.0f + Mathf.Abs(min) / range * rectTransform.rect.height;
            }
            float tickRange = GetTickRange(range, 5);
            float x0        = -rectTransform.rect.width / 2.0f;

            float p = (min > 0) ? 0 : Mathf.Floor(min / tickRange) * tickRange;

            for (int i = 0; i < 5; i++)
            {
                if ((min >= 0 && p <= max) || (max <= 0 && p >= min) || (p >= min && p <= max))
                {
                    LabelPosition pos = new LabelPosition();
                    pos.position = new Vector2(x0, y0 + p / range * rectTransform.rect.height);
                    pos.value    = p;
                    ret.Add(pos);
                }
                p += tickRange;
            }
            // string s = string.Format("min: {0}, max: {1}, tickRange: {2} [{3}](", min, max, tickRange, ret.Count);
            // for (int i = 0; i < ret.Count; i++)
            // {
            //  s += ret[i].value + ", ";
            // }
            // s += ")";
            // Debug.Log(s);
            return(ret.ToArray());
        }
Esempio n. 3
0
        public LabelPosition[] GetAxisYPositions()
        {
            if (values.isEmpty)
            {
                return(null);
            }

            List <LabelPosition> ret = new List <LabelPosition>();

            float border = ((Thickness > PointSize || Point == PointType.NONE) ? Thickness : PointSize) * rectTransform.rect.width * 2;
            float height = rectTransform.rect.height - border;

            float range;
            float y0;

            if (min >= 0)
            {
                range = max;
                y0    = -height / 2.0f;
            }
            else if (max <= 0)
            {
                range = Mathf.Abs(min);
                y0    = height / 2.0f;
            }
            else
            {
                range = max - min;
                y0    = -height / 2.0f + Mathf.Abs(min) / range * height;
            }
            float tickRange = GetTickRange(range, 5);
            float x0        = -rectTransform.rect.width / 2.0f;

            float p = (min > 0) ? 0 : Mathf.Floor(min / tickRange) * tickRange;

            for (int i = 0; i < 5; i++)
            {
                if ((min >= 0 && p <= max) || (max <= 0 && p >= min) || (p >= min && p <= max))
                {
                    LabelPosition pos = new LabelPosition();
                    pos.position = new Vector2(x0, y0 + p / range * height);
                    pos.value    = p;
                    ret.Add(pos);
                }
                p += tickRange;
            }
            return(ret.ToArray());
        }
Esempio n. 4
0
        public LabelPosition GetLabelPosition(int column, float position = 0.5f)
        {
            if (sectors.Count <= column)
            {
                return(null);
            }

            LabelPosition retVal = new LabelPosition();

            retVal.value = values[column];

            Vector3 v = Quaternion.Euler(0, 0, -sectors[column].center) * Vector3.up * 0.5f;

            retVal.position = new Vector2(v.x * rectTransform.rect.width * position, v.y * rectTransform.rect.height * position);
            return(retVal);
        }
Esempio n. 5
0
        public LabelPosition GetLabelPosition(int row, int column)
        {
            if (points.Count <= row * values.Columns + column)
            {
                return(null);
            }

            LabelPosition retVal = new LabelPosition();

            retVal.value = values[row, column];

            Rect r = points[row * values.Columns + column].rect;

            retVal.position = new Vector2(r.center.x, r.center.y - r.height);
            return(retVal);
        }
Esempio n. 6
0
        public LabelPosition[] GetAxisXPositions()
        {
            if (points.Count == 0)
            {
                return(null);
            }

            LabelPosition[] ret = new LabelPosition[values.Columns];

            float y0 = -rectTransform.rect.height / 2.0f;

            for (int i = 0; i < values.Columns; i++)
            {
                LabelPosition pos = new LabelPosition();
                pos.position = new Vector2(points[i].rect.center.x, y0);
                ret[i]       = pos;
            }
            return(ret);
        }
Esempio n. 7
0
        public LabelPosition GetLabelPosition(int row, int column, float position = 0.5f)
        {
            if (bars.Count <= row * values.Columns + column)
            {
                return(null);
            }

            LabelPosition retVal = new LabelPosition();

            retVal.value = values[row, column];

            Rect r = bars[column * values.Rows + row].rect;

            if (values[row, column] < 0)
            {
                retVal.position = new Vector2(r.center.x, r.y + r.height * position);
            }
            else
            {
                retVal.position = new Vector2(r.center.x, (r.y + r.height) - r.height * position);
            }
            return(retVal);
        }