Example #1
0
 /// <summary>
 /// 获得指定区域缩放的类目数据列表
 /// </summary>
 /// <param name="dataZoom">区域缩放</param>
 /// <returns></returns>
 internal List <string> GetDataList(DataZoom dataZoom)
 {
     if (dataZoom != null && dataZoom.enable && dataZoom.IsContainsAxis(this))
     {
         UpdateFilterData(dataZoom);
         return(filterData);
     }
     else
     {
         return(m_Data.Count > 0 ? m_Data : m_RuntimeData);
     }
 }
Example #2
0
 /// <summary>
 /// 更新dataZoom对应的类目数据列表
 /// </summary>
 /// <param name="dataZoom"></param>
 internal void UpdateFilterData(DataZoom dataZoom)
 {
     if (dataZoom != null && dataZoom.enable && dataZoom.IsContainsAxis(this))
     {
         var data  = GetDataList();
         var range = Mathf.RoundToInt(data.Count * (dataZoom.end - dataZoom.start) / 100);
         if (range <= 0)
         {
             range = 1;
         }
         int start = 0, end = 0;
         if (dataZoom.runtimeInvert)
         {
             end   = Mathf.CeilToInt(data.Count * dataZoom.end / 100);
             start = end - range;
             if (start < 0)
             {
                 start = 0;
             }
         }
         else
         {
             start = Mathf.FloorToInt(data.Count * dataZoom.start / 100);
             end   = start + range;
             if (end > data.Count)
             {
                 end = data.Count;
             }
         }
         if (start != filterStart || end != filterEnd || dataZoom.minShowNum != filterMinShow || m_NeedUpdateFilterData)
         {
             filterStart            = start;
             filterEnd              = end;
             filterMinShow          = dataZoom.minShowNum;
             m_NeedUpdateFilterData = false;
             if (data.Count > 0)
             {
                 if (range < dataZoom.minShowNum)
                 {
                     if (dataZoom.minShowNum > data.Count)
                     {
                         range = data.Count;
                     }
                     else
                     {
                         range = dataZoom.minShowNum;
                     }
                 }
                 filterData = data.GetRange(start, range);
             }
             else
             {
                 filterData = data;
             }
         }
         else if (end == 0)
         {
             filterData = emptyFliter;
         }
     }
 }