Пример #1
0
        private void InitSplitY()
        {
            m_SplitYTextList.Clear();
            ChartHelper.HideAllObject(gameObject, "split_y");//old name
            float splitWidth = m_YAxis.GetScaleWidth(coordinateHig, m_DataZoom);

            var axisObj = ChartHelper.AddObject(s_DefaultAxisY, transform, chartAnchorMin,
                                                chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));

            axisObj.transform.localPosition = Vector3.zero;
            ChartHelper.HideAllObject(axisObj, s_DefaultAxisY);

            for (int i = 0; i < m_YAxis.GetSplitNumber(m_DataZoom); i++)
            {
                Text txt = ChartHelper.AddTextObject(s_DefaultAxisY + i, axisObj.transform,
                                                     m_ThemeInfo.font, m_ThemeInfo.axisTextColor, TextAnchor.MiddleRight, Vector2.zero,
                                                     Vector2.zero, new Vector2(1, 0.5f), new Vector2(m_Coordinate.left, 20),
                                                     m_Coordinate.fontSize, m_XAxis.textRotation);
                txt.transform.localPosition = GetSplitYPosition(splitWidth, i);
                txt.text = m_YAxis.GetScaleName(i, minValue, maxValue, m_DataZoom);
                txt.gameObject.SetActive(m_YAxis.show);
                m_SplitYTextList.Add(txt);
            }
            if (m_YAxis.axisName.show)
            {
                var color = m_YAxis.axisName.color == Color.clear ? (Color)m_ThemeInfo.axisTextColor :
                            m_YAxis.axisName.color;
                var  fontSize = m_YAxis.axisName.fontSize;
                var  gap      = m_YAxis.axisName.gap;
                Text axisName;
                switch (m_YAxis.axisName.location)
                {
                case Axis.AxisName.Location.Start:
                    axisName = ChartHelper.AddTextObject(s_DefaultAxisX + "_name", axisObj.transform,
                                                         m_ThemeInfo.font, color, TextAnchor.MiddleCenter, new Vector2(0.5f, 0.5f),
                                                         new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), fontSize,
                                                         m_YAxis.axisName.rotate);
                    axisName.transform.localPosition = new Vector2(coordinateX, coordinateY - gap);
                    break;

                case Axis.AxisName.Location.Middle:
                    axisName = ChartHelper.AddTextObject(s_DefaultAxisX + "_name", axisObj.transform,
                                                         m_ThemeInfo.font, color, TextAnchor.MiddleRight, new Vector2(1, 0.5f),
                                                         new Vector2(1, 0.5f), new Vector2(1, 0.5f), new Vector2(100, 20), fontSize,
                                                         m_YAxis.axisName.rotate);
                    axisName.transform.localPosition = new Vector2(coordinateX - gap,
                                                                   coordinateY + coordinateHig / 2);
                    break;

                case Axis.AxisName.Location.End:
                    axisName = ChartHelper.AddTextObject(s_DefaultAxisX + "_name", axisObj.transform,
                                                         m_ThemeInfo.font, color, TextAnchor.MiddleCenter, new Vector2(0.5f, 0.5f),
                                                         new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), fontSize,
                                                         m_YAxis.axisName.rotate);
                    axisName.transform.localPosition = new Vector2(coordinateX,
                                                                   coordinateY + coordinateHig + gap);
                    break;
                }
            }
        }
        private void InitSplitY()
        {
            m_SplitYTextList.Clear();
            float splitWidth = m_YAxis.GetScaleWidth(coordinateHig);

            var titleObject = ChartHelper.AddObject(s_DefaultSplitNameY, transform, chartAnchorMin,
                                                    chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));

            titleObject.transform.localPosition = Vector3.zero;
            ChartHelper.HideAllObject(titleObject, s_DefaultSplitNameY);

            for (int i = 0; i < m_YAxis.GetSplitNumber(); i++)
            {
                Text txt = ChartHelper.AddTextObject(s_DefaultSplitNameY + i, titleObject.transform,
                                                     m_ThemeInfo.font, m_ThemeInfo.textColor, TextAnchor.MiddleRight, Vector2.zero,
                                                     Vector2.zero, new Vector2(1, 0.5f), new Vector2(m_Coordinate.left, 20),
                                                     m_Coordinate.fontSize, m_XAxis.textRotation);
                txt.transform.localPosition = GetSplitYPosition(splitWidth, i);
                txt.text = m_YAxis.GetScaleName(i, minValue, maxValue);
                txt.gameObject.SetActive(m_YAxis.show);
                m_SplitYTextList.Add(txt);
            }
        }