コード例 #1
0
ファイル: DrawSerieRing.cs プロジェクト: zcf112/UnityDemo
 public bool OnLegendButtonClick(int index, string legendName, bool show)
 {
     if (!SeriesHelper.ContainsSerie(chart.series, SerieType.Ring))
     {
         return(false);
     }
     if (!LegendHelper.IsSerieLegend(chart.series, legendName, SerieType.Ring))
     {
         return(false);
     }
     LegendHelper.CheckDataShow(chart.series, legendName, show);
     chart.UpdateLegendColor(legendName, show);
     chart.RefreshChart();
     return(true);
 }
コード例 #2
0
 public bool OnLegendButtonExit(int index, string legendName)
 {
     if (!SeriesHelper.ContainsSerie(chart.series, SerieType.Ring))
     {
         return(false);
     }
     if (!LegendHelper.IsSerieLegend(chart.series, legendName, SerieType.Ring))
     {
         return(false);
     }
     m_IsEnterLegendButtom = false;
     LegendHelper.CheckDataHighlighted(chart.series, legendName, false);
     chart.RefreshChart();
     return(true);
 }
コード例 #3
0
        internal virtual void UpdateLegendColor(string legendName, bool active)
        {
            var legendIndex = m_LegendRealShowName.IndexOf(legendName);

            if (legendIndex >= 0)
            {
                foreach (var legend in m_Legends)
                {
                    var iconColor    = LegendHelper.GetIconColor(legend, legendIndex, m_Theme, m_Series, legendName, active);
                    var contentColor = LegendHelper.GetContentColor(legend, m_Theme, active);
                    legend.UpdateButtonColor(legendName, iconColor);
                    legend.UpdateContentColor(legendName, contentColor);
                }
            }
        }
コード例 #4
0
        private void InitLegend()
        {
            m_Legend.OnChanged();
            var legendObject = ChartHelper.AddObject(s_LegendObjectName, transform, m_ChartMinAnchor,
                                                     m_ChartMaxAnchor, m_ChartPivot, new Vector2(chartWidth, chartHeight));

            legendObject.hideFlags = chartHideFlags;
            SeriesHelper.UpdateSerieNameList(m_Series, ref m_LegendRealShowName);
            List <string> datas;

            if (m_Legend.show && m_Legend.data.Count > 0)
            {
                datas = new List <string>();
                for (int i = 0; i < m_LegendRealShowName.Count; i++)
                {
                    if (m_Legend.data.Contains(m_LegendRealShowName[i]))
                    {
                        datas.Add(m_LegendRealShowName[i]);
                    }
                }
            }
            else
            {
                datas = m_LegendRealShowName;
            }
            int totalLegend = 0;

            for (int i = 0; i < datas.Count; i++)
            {
                if (!SeriesHelper.IsLegalLegendName(datas[i]))
                {
                    continue;
                }
                totalLegend++;
            }
            m_Legend.RemoveButton();
            ChartHelper.HideAllObject(legendObject);
            if (!m_Legend.show)
            {
                return;
            }
            for (int i = 0; i < datas.Count; i++)
            {
                if (!SeriesHelper.IsLegalLegendName(datas[i]))
                {
                    continue;
                }
                string legendName = m_Legend.GetFormatterContent(datas[i]);
                var    readIndex  = m_LegendRealShowName.IndexOf(datas[i]);
                var    active     = IsActiveByLegend(datas[i]);
                var    bgColor    = LegendHelper.GetIconColor(m_Legend, readIndex, themeInfo, active);
                var    item       = LegendHelper.AddLegendItem(m_Legend, i, datas[i], legendObject.transform, m_ThemeInfo,
                                                               legendName, bgColor, active);
                m_Legend.SetButton(legendName, item, totalLegend);
                ChartHelper.ClearEventListener(item.button.gameObject);
                ChartHelper.AddEventListener(item.button.gameObject, EventTriggerType.PointerDown, (data) =>
                {
                    if (data.selectedObject == null || m_Legend.selectedMode == Legend.SelectedMode.None)
                    {
                        return;
                    }
                    var temp            = data.selectedObject.name.Split('_');
                    string selectedName = temp[1];
                    int clickedIndex    = int.Parse(temp[0]);
                    if (m_Legend.selectedMode == Legend.SelectedMode.Multiple)
                    {
                        OnLegendButtonClick(clickedIndex, selectedName, !IsActiveByLegend(selectedName));
                    }
                    else
                    {
                        var btnList = m_Legend.buttonList.Values.ToArray();
                        if (btnList.Length == 1)
                        {
                            OnLegendButtonClick(0, selectedName, !IsActiveByLegend(selectedName));
                        }
                        else
                        {
                            for (int n = 0; n < btnList.Length; n++)
                            {
                                temp         = btnList[n].name.Split('_');
                                selectedName = btnList[n].legendName;
                                var index    = btnList[n].index;
                                OnLegendButtonClick(n, selectedName, index == clickedIndex ? true : false);
                            }
                        }
                    }
                });
                ChartHelper.AddEventListener(item.button.gameObject, EventTriggerType.PointerEnter, (data) =>
                {
                    if (item.button == null)
                    {
                        return;
                    }
                    var temp            = item.button.name.Split('_');
                    string selectedName = temp[1];
                    int index           = int.Parse(temp[0]);
                    OnLegendButtonEnter(index, selectedName);
                });
                ChartHelper.AddEventListener(item.button.gameObject, EventTriggerType.PointerExit, (data) =>
                {
                    if (item.button == null)
                    {
                        return;
                    }
                    var temp            = item.button.name.Split('_');
                    string selectedName = temp[1];
                    int index           = int.Parse(temp[0]);
                    OnLegendButtonExit(index, selectedName);
                });
            }
            if (m_Legend.selectedMode == Legend.SelectedMode.Single)
            {
                for (int n = 0; n < m_LegendRealShowName.Count; n++)
                {
                    OnLegendButtonClick(n, m_LegendRealShowName[n], n == 0 ? true : false);
                }
            }
            LegendHelper.ResetItemPosition(m_Legend, m_ChartPosition, m_ChartWidth, m_ChartHeight);
        }
コード例 #5
0
 protected override void OnLegendButtonExit(int index, string legendName)
 {
     m_IsEnterLegendButtom = false;
     LegendHelper.CheckDataHighlighted(m_Series, legendName, false);
     RefreshChart();
 }
コード例 #6
0
 protected override void OnLegendButtonClick(int index, string legendName, bool show)
 {
     LegendHelper.CheckDataShow(m_Series, legendName, show);
     UpdateLegendColor(legendName, show);
     RefreshChart();
 }