示例#1
0
        private Vector2 GetLabelPivot(AxisLabelRendererExtry entry)
        {
            if (entry.Orientation == AxisOrientation.HORIZONTAL)
            {
                switch (entry.Gravity)
                {
                case AxisLabelGravity.START:
                    return(PivotValue.TOP_MIDDLE);

                case AxisLabelGravity.END:
                    return(PivotValue.BOTTOM_MIDDLE);
                }
            }
            else
            {
                switch (entry.Gravity)
                {
                case AxisLabelGravity.START:
                    return(PivotValue.MIDDLE_RIGHT);

                case AxisLabelGravity.END:
                    return(PivotValue.MIDDLE_LEFT);
                }
            }

            return(PivotValue.CENTER);
        }
示例#2
0
        private TextAnchor GetLabelAlignment(AxisLabelRendererExtry entry)
        {
            if (entry.Orientation == AxisOrientation.HORIZONTAL)
            {
                switch (entry.Gravity)
                {
                case AxisLabelGravity.START:
                    return(TextAnchor.UpperCenter);

                case AxisLabelGravity.END:
                    return(TextAnchor.LowerCenter);
                }
            }
            else
            {
                switch (entry.Gravity)
                {
                case AxisLabelGravity.START:
                    return(TextAnchor.MiddleRight);

                case AxisLabelGravity.END:
                    return(TextAnchor.MiddleLeft);
                }
            }

            return(TextAnchor.MiddleCenter);
        }
示例#3
0
        private Vector2 CreateLabelPositionForEntry(AxisLabelRendererExtry entry, Vector2 rendererSize, float margin)
        {
            if (entry.Orientation == AxisOrientation.HORIZONTAL)
            {
                switch (entry.Gravity)
                {
                case AxisLabelGravity.START:
                    return(new Vector2(entry.PositionOnAxis, -margin));

                case AxisLabelGravity.END:
                    return(new Vector2(entry.PositionOnAxis, rendererSize.y + margin));
                }
            }
            else
            {
                switch (entry.Gravity)
                {
                case AxisLabelGravity.START:
                    return(new Vector2(-margin, entry.PositionOnAxis));

                case AxisLabelGravity.END:
                    return(new Vector2(rendererSize.x + margin, entry.PositionOnAxis));
                }
            }

            return(Vector2.zero);
        }
示例#4
0
 private void UpdateLabel(ChartLabel label,
                          AxisLabelConfig config,
                          AxisLabelRendererExtry entry,
                          Vector2 rendererSize)
 {
     label.SetLabelColor(config.LabelColor);
     label.SetLabelTextSize(config.LabelSize);
     label.SetLabelTextAlignment(GetLabelAlignment(entry));
     label.SetLabelText(entry.Text);
     label.GetComponent <RectTransform> ().pivot = GetLabelPivot(entry);
     label.transform.localPosition = CreateLabelPositionForEntry(entry, rendererSize, config.LabelMargin);
 }
示例#5
0
        public List <AxisLabelRendererExtry> getLabelRendererEntries()
        {
            List <AxisLabelRendererExtry> entries = new List <AxisLabelRendererExtry> ();
            int minLabelIndex = GetMinLabelIndex();
            int maxLabelIndex = GetMaxLabelIndex();

            for (int i = minLabelIndex; i < minLabelIndex + labelCount; i++)
            {
                AxisLabelRendererExtry entry = new AxisLabelRendererExtry();
                entry.PositionOnAxis = GetLabelAxisPosition(i, maxLabelIndex);
                entry.Gravity        = labelsGravity;
                entry.Text           = GetLabelValueText(i - minLabelIndex, entry.PositionOnAxis);
                entry.Orientation    = GetEntryAxisOrientation();
                entries.Add(entry);
            }

            return(entries);
        }
示例#6
0
        public List <AxisLabelRendererExtry> getLabelRendererEntries()
        {
            List <AxisLabelRendererExtry> entries = new List <AxisLabelRendererExtry> ();

            if (barChartPositioner == null)
            {
                return(entries);
            }

            int entriesCount          = barChartPositioner.GetVisibleEntriesRange();
            int axisFirstVisibleIndex = (int)barChartPositioner.axisBounds.XMin;

            for (int i = axisFirstVisibleIndex; i < entriesCount + axisFirstVisibleIndex; i++)
            {
                AxisLabelRendererExtry entry = new AxisLabelRendererExtry();
                entry.PositionOnAxis = barChartPositioner.GetBarCenterPosition(i).x;
                entry.Gravity        = labelsGravity;
                entry.Text           = GetLabelValueText(i, axisFirstVisibleIndex, entriesCount + axisFirstVisibleIndex);
                entry.Orientation    = AxisOrientation.HORIZONTAL;
                entries.Add(entry);
            }

            return(entries);
        }