Example #1
0
        private void InitRadar(Radar radar)
        {
            float txtWid = 100;
            float txtHig = 20;

            radar.painter          = chart.GetPainter(radar.index);
            radar.refreshComponent = delegate()
            {
                ChartHelper.HideAllObject(chart.transform, INDICATOR_TEXT + "_" + radar.index);
                radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight);
                for (int i = 0; i < radar.indicatorList.Count; i++)
                {
                    var indicator = radar.indicatorList[i];
                    var pos       = radar.GetIndicatorPosition(i);
                    var textStyle = indicator.textStyle;
                    var objName   = INDICATOR_TEXT + "_" + radar.index + "_" + i;
                    var txt       = ChartHelper.AddTextObject(objName, chart.transform, new Vector2(0.5f, 0.5f),
                                                              new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(txtWid, txtHig),
                                                              textStyle, chart.theme.radar);
                    txt.gameObject.hideFlags = chart.chartHideFlags;
                    txt.SetAlignment(textStyle.GetAlignment(TextAnchor.MiddleCenter));
                    txt.SetText(radar.indicatorList[i].name);
                    txt.SetActive(radar.indicator);
                    var offset = new Vector3(textStyle.offset.x, textStyle.offset.y);
                    AxisHelper.AdjustCircleLabelPos(txt, pos, radar.runtimeCenterPos, txtHig, offset);
                }
                chart.RefreshBasePainter();
            };
            radar.refreshComponent.Invoke();
        }
 private void InitIndicator()
 {
     ChartHelper.HideAllObject(transform, INDICATOR_TEXT);
     for (int n = 0; n < m_Radars.Count; n++)
     {
         Radar radar = m_Radars[n];
         radar.UpdateRadarCenter(chartPosition, chartWidth, chartHeight);
         int   indicatorNum = radar.indicatorList.Count;
         float txtWid       = 100;
         float txtHig       = 20;
         for (int i = 0; i < indicatorNum; i++)
         {
             var        indicator = radar.indicatorList[i];
             var        pos       = radar.GetIndicatorPosition(i);
             TextAnchor anchor    = TextAnchor.MiddleCenter;
             var        textStyle = indicator.textStyle;
             var        textColor = ChartHelper.IsClearColor(textStyle.color) ? (Color)m_ThemeInfo.axisTextColor : textStyle.color;
             var        txt       = ChartHelper.AddTextObject(INDICATOR_TEXT + "_" + n + "_" + i, transform, m_ThemeInfo.font,
                                                              textColor, anchor, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                              new Vector2(txtWid, txtHig), textStyle.fontSize, textStyle.rotate, textStyle.fontStyle, textStyle.lineSpacing);
             txt.gameObject.hideFlags = chartHideFlags;
             txt.text = radar.indicatorList[i].name;
             txt.gameObject.SetActive(radar.indicator);
             var offset = new Vector3(textStyle.offset.x, textStyle.offset.y);
             AxisHelper.AdjustCircleLabelPos(txt, pos, radar.runtimeCenterPos, txtHig, offset);
         }
     }
 }
 private void InitIndicator()
 {
     ChartHelper.HideAllObject(chart.transform, INDICATOR_TEXT);
     for (int n = 0; n < chart.radars.Count; n++)
     {
         Radar radar = chart.radars[n];
         radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight);
         int   indicatorNum = radar.indicatorList.Count;
         float txtWid       = 100;
         float txtHig       = 20;
         for (int i = 0; i < indicatorNum; i++)
         {
             var indicator = radar.indicatorList[i];
             var pos       = radar.GetIndicatorPosition(i);
             var textStyle = indicator.textStyle;
             var objName   = INDICATOR_TEXT + "_" + n + "_" + i;
             var txt       = ChartHelper.AddTextObject(objName, chart.transform, new Vector2(0.5f, 0.5f),
                                                       new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(txtWid, txtHig),
                                                       textStyle, chart.theme.radar);
             txt.gameObject.hideFlags = chart.chartHideFlags;
             txt.SetAlignment(TextAnchor.MiddleCenter);
             txt.SetText(radar.indicatorList[i].name);
             txt.SetActive(radar.indicator);
             var offset = new Vector3(textStyle.offset.x, textStyle.offset.y);
             AxisHelper.AdjustCircleLabelPos(txt, pos, radar.runtimeCenterPos, txtHig, offset);
         }
     }
 }
Example #4
0
 private void InitIndicator()
 {
     ChartHelper.HideAllObject(transform, INDICATOR_TEXT);
     for (int n = 0; n < m_Radars.Count; n++)
     {
         Radar radar = m_Radars[n];
         radar.UpdateRadarCenter(chartPosition, chartWidth, chartHeight);
         int   indicatorNum = radar.indicatorList.Count;
         float txtWid       = 100;
         float txtHig       = 20;
         for (int i = 0; i < indicatorNum; i++)
         {
             var        indicator = radar.indicatorList[i];
             var        pos       = radar.GetIndicatorPosition(i);
             TextAnchor anchor    = TextAnchor.MiddleCenter;
             var        textStyle = indicator.textStyle;
             var        textColor = ChartHelper.IsClearColor(textStyle.color) ? (Color)m_ThemeInfo.axisTextColor : textStyle.color;
             var        txt       = ChartHelper.AddTextObject(INDICATOR_TEXT + "_" + n + "_" + i, transform, m_ThemeInfo.font,
                                                              textColor, anchor, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f),
                                                              new Vector2(txtWid, txtHig), textStyle.fontSize, textStyle.rotate, textStyle.fontStyle, textStyle.lineSpacing);
             txt.gameObject.hideFlags = chartHideFlags;
             txt.text = radar.indicatorList[i].name;
             txt.gameObject.SetActive(radar.indicator);
             var txtWidth  = txt.preferredWidth;
             var sizeDelta = new Vector2(txt.preferredWidth, txt.preferredHeight);
             txt.GetComponent <RectTransform>().sizeDelta = sizeDelta;
             var diff = pos.x - radar.runtimeCenterPos.x;
             if (diff < -1f) //left
             {
                 pos = new Vector3(pos.x - txtWidth / 2, pos.y);
             }
             else if (diff > 1f) //right
             {
                 pos = new Vector3(pos.x + txtWidth / 2, pos.y);
             }
             else
             {
                 float y = pos.y > radar.runtimeCenterPos.y ? pos.y + txtHig / 2 : pos.y - txtHig / 2;
                 pos = new Vector3(pos.x, y);
             }
             txt.transform.localPosition = pos + new Vector3(textStyle.offset.x, textStyle.offset.y);
         }
     }
 }
 private void InitIndicator()
 {
     ChartHelper.HideAllObject(transform, INDICATOR_TEXT);
     for (int n = 0; n < m_Radars.Count; n++)
     {
         Radar radar = m_Radars[n];
         radar.UpdateRadarCenter(chartWidth, chartHeight);
         int   indicatorNum = radar.indicatorList.Count;
         float txtWid       = 100;
         float txtHig       = 20;
         for (int i = 0; i < indicatorNum; i++)
         {
             var        indicator = radar.indicatorList[i];
             var        pos       = radar.GetIndicatorPosition(i);
             TextAnchor anchor    = TextAnchor.MiddleCenter;
             var        diff      = pos.x - radar.centerPos.x;
             if (diff < -1f)
             {
                 pos    = new Vector3(pos.x - 5, pos.y);
                 anchor = TextAnchor.MiddleRight;
             }
             else if (diff > 1f)
             {
                 anchor = TextAnchor.MiddleLeft;
                 pos    = new Vector3(pos.x + txtWid + 5, pos.y);
             }
             else
             {
                 anchor = TextAnchor.MiddleCenter;
                 float y = pos.y > radar.centerPos.y ? pos.y + txtHig / 2 : pos.y - txtHig / 2;
                 pos = new Vector3(pos.x + txtWid / 2, y);
             }
             var  textColor = indicator.color == Color.clear ? (Color)m_ThemeInfo.axisTextColor : indicator.color;
             Text txt       = ChartHelper.AddTextObject(INDICATOR_TEXT + "_" + n + "_" + i, transform, m_ThemeInfo.font,
                                                        textColor, anchor, Vector2.zero, Vector2.zero, new Vector2(1, 0.5f),
                                                        new Vector2(txtWid, txtHig));
             txt.transform.localPosition = pos;
             txt.text = radar.indicatorList[i].name;
             txt.gameObject.SetActive(radar.indicator);
         }
     }
 }