Beispiel #1
0
 protected virtual void InitLegend()
 {
     for (int i = 0; i < legend.dataList.Count; i++)
     {
         //LegendData data = legend.dataList[i];
         Button btn = ChartUtils.AddButtonObject(LEGEND_TEXT + "_" + i, transform, themeInfo.font,
                                                 themeInfo.textColor, Vector2.zero, Vector2.zero, Vector2.zero,
                                                 new Vector2(legend.itemWidth, legend.itemHeight));
         legend.SetDataButton(i, btn);
         Color bcolor = themeInfo.GetColor(i);
         btn.gameObject.SetActive(legend.show);
         btn.transform.localPosition              = GetLegendPosition(i);
         btn.GetComponent <Image>().color         = bcolor;
         btn.GetComponentInChildren <Text>().text = legend.dataList[i];
         btn.onClick.AddListener(delegate() {
             int index = int.Parse(btn.name.Split('_')[1]);
             legend.SetShowData(index, !legend.IsShowSeries(index));
             btn.GetComponent <Image>().color = legend.IsShowSeries(index) ?
                                                themeInfo.GetColor(index) : themeInfo.unableColor;
             OnYMaxValueChanged();
             OnLegendButtonClicked();
             RefreshChart();
         });
     }
 }
 private void InitLineButton()
 {
     for (int i = 0; i < lineList.Count; i++)
     {
         if (lineList[i].button)
         {
             continue;
         }
         Button btn = ChartUtils.AddButtonObject("button" + i, transform, font, Vector2.zero,
                                                 Vector2.zero, Vector2.zero, new Vector2(50, 20));
         btn.transform.localPosition = new Vector3(i * 50, chartHig + 30, 0);
         lineList[i].button          = btn;
     }
 }
 private void InitHideAndShowButton()
 {
     if (lineList.Count <= 0)
     {
         return;
     }
     btnAll = ChartUtils.AddButtonObject("buttonall", transform, font, Vector2.zero,
                                         Vector2.zero, Vector2.zero, new Vector2(graduationWidth, 20));
     btnAll.transform.localPosition = new Vector3(-graduationWidth, chartHig + 30, 0);
     btnAll.GetComponentInChildren <Text>().text = isShowAll ? "HIDE" : "SHOW";
     btnAll.GetComponent <Image>().color         = backgroundColor;
     btnAll.onClick.AddListener(delegate()
     {
         isShowAll = !isShowAll;
         btnAll.GetComponentInChildren <Text>().text = isShowAll ? "HIDE" : "SHOW";
         foreach (var line in lineList)
         {
             line.visible = isShowAll;
         }
     });
 }
Beispiel #4
0
        private void InitLegend()
        {
            for (int i = 0; i < legend.dataList.Count; i++)
            {
                LegendData data = legend.dataList[i];
                Button     btn  = ChartUtils.AddButtonObject(LEGEND_TEXT + i, transform, themeInfo.font,
                                                             themeInfo.textColor, Vector2.zero, Vector2.zero, Vector2.zero,
                                                             new Vector2(legend.itemWidth, legend.itemHeight));
                btn.name = data.key;
                legend.dataList[i].button = btn;
                Color bcolor = data.show ? themeInfo.GetColor(i) : themeInfo.unableColor;
                btn.gameObject.SetActive(legend.show);
                btn.transform.localPosition              = GetLegendPosition(i);
                btn.GetComponent <Image>().color         = bcolor;
                btn.GetComponentInChildren <Text>().text = data.text;
                //btn.onClick.AddListener(delegate ()
                //{
                //    Debug.Log(btn.name + "Clicked!");
                //    //data.show = !data.show;
                //    //btn.GetComponent<Image>().color = data.show ? themeInfo.GetColor(i) : themeInfo.unableColor;
                //    //OnYMaxValueChanged();
                //    //OnLegendButtonClicked();
                //    //RefreshChart();
                //});
            }

            checkTheme = theme;

            checkLegend.checkDataListCount = legend.dataList.Count;
            checkLegend.itemWidth          = legend.itemWidth;
            checkLegend.itemHeight         = legend.itemHeight;
            checkLegend.itemGap            = legend.itemGap;
            checkLegend.left     = legend.left;
            checkLegend.right    = legend.right;
            checkLegend.bottom   = legend.bottom;
            checkLegend.top      = legend.top;
            checkLegend.location = legend.location;
            checkLegend.show     = legend.show;
        }
Beispiel #5
0
 private void InitLegend()
 {
     for (int i = 0; i < legend.dataList.Count; i++)
     {
         LegendData data = legend.dataList[i];
         Button     btn  = ChartUtils.AddButtonObject(LEGEND_TEXT + i, transform, font, Vector2.zero,
                                                      Vector2.zero, Vector2.zero, new Vector2(legend.dataWid, legend.dataHig));
         legend.dataList[i].button = btn;
         Color bcolor = data.show ? data.color : Color.grey;
         btn.gameObject.SetActive(legend.show);
         btn.transform.localPosition              = GetLegendPosition(i);
         btn.GetComponent <Image>().color         = bcolor;
         btn.GetComponentInChildren <Text>().text = data.text;
         btn.onClick.AddListener(delegate()
         {
             data.show = !data.show;
             btn.GetComponent <Image>().color = data.show ? data.color : Color.grey;
             OnYMaxValueChanged();
             OnLegendButtonClicked();
             RefreshChart();
         });
     }
 }