private void CheckDataZoomLabel(DataZoom dataZoom)
 {
     if (dataZoom.enable && dataZoom.supportSlider && dataZoom.showDetail)
     {
         Vector2 local;
         if (!chart.ScreenPointToChartPoint(Input.mousePosition, out local))
         {
             dataZoom.SetLabelActive(false);
             return;
         }
         if (dataZoom.IsInSelectedZoom(local) ||
             dataZoom.IsInStartZoom(local) ||
             dataZoom.IsInEndZoom(local))
         {
             dataZoom.SetLabelActive(true);
             RefreshDataZoomLabel();
         }
         else
         {
             dataZoom.SetLabelActive(false);
         }
     }
     if (m_CheckDataZoomLabel)
     {
         m_CheckDataZoomLabel = false;
         var xAxis      = chart.GetXAxis(dataZoom.xAxisIndexs[0]);
         var startIndex = (int)((xAxis.data.Count - 1) * dataZoom.start / 100);
         var endIndex   = (int)((xAxis.data.Count - 1) * dataZoom.end / 100);
         if (m_DataZoomLastStartIndex != startIndex || m_DataZoomLastEndIndex != endIndex)
         {
             m_DataZoomLastStartIndex = startIndex;
             m_DataZoomLastEndIndex   = endIndex;
             if (xAxis.data.Count > 0)
             {
                 dataZoom.SetStartLabelText(xAxis.data[startIndex]);
                 dataZoom.SetEndLabelText(xAxis.data[endIndex]);
             }
             chart.InitAxisX();
         }
         var start = dataZoom.runtimeX + dataZoom.runtimeWidth * dataZoom.start / 100;
         var end   = dataZoom.runtimeX + dataZoom.runtimeWidth * dataZoom.end / 100;
         var hig   = dataZoom.runtimeHeight;
         dataZoom.UpdateStartLabelPosition(new Vector3(start - 10, chart.chartY + dataZoom.bottom + hig / 2));
         dataZoom.UpdateEndLabelPosition(new Vector3(end + 10, chart.chartY + dataZoom.bottom + hig / 2));
     }
 }
Beispiel #2
0
        private void InitDataZoom()
        {
            var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom, transform, chartAnchorMin,
                                                       chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));

            dataZoomObject.transform.localPosition = Vector3.zero;
            ChartHelper.HideAllObject(dataZoomObject, s_DefaultDataZoom);
            m_DataZoom.startLabel = ChartHelper.AddTextObject(s_DefaultDataZoom + "start",
                                                              dataZoomObject.transform, m_ThemeInfo.font, m_ThemeInfo.textColor, TextAnchor.MiddleRight,
                                                              Vector2.zero, Vector2.zero, new Vector2(1, 0.5f), new Vector2(200, 20));
            m_DataZoom.endLabel = ChartHelper.AddTextObject(s_DefaultDataZoom + "end",
                                                            dataZoomObject.transform, m_ThemeInfo.font, m_ThemeInfo.textColor, TextAnchor.MiddleLeft,
                                                            Vector2.zero, Vector2.zero, new Vector2(0, 0.5f), new Vector2(200, 20));
            m_DataZoom.SetLabelActive(false);
            m_XAxis.UpdateFilterData(m_DataZoom);
            m_Series.UpdateFilterData(m_DataZoom);
            raycastTarget = m_DataZoom.show;
        }