Exemple #1
0
    private float FindMaxValueIn2DList <T, R>(List <T> val, ExtractDataListFromList <T, R> extractDataDelegate, ExtractFloatFromData <R> extractIntDelegate)
    {
        float max = 0;

        for (int i = 0; i < val.Count; i++)
        {
            for (int j = 0; j < extractDataDelegate(val[i]).Count; j++)
            {
                float value = extractIntDelegate((extractDataDelegate(val[i]))[j]);
                max = max > value ? max : value;
            }
        }

        return(max);
    }
Exemple #2
0
 public void UpdateLines <T, R>(List <T> list, ExtractDataListFromList <T, R> extractDataDelegate, ExtractFloatFromData <R> extractfloatDelegate, ExtractNameFromList <T> extractNamesDelegate)
 {
     BackToInit();
     MakeChart(list, extractDataDelegate, extractfloatDelegate, extractNamesDelegate);
 }
Exemple #3
0
    private void MakePoints <T, R>(List <T> vals, ExtractDataListFromList <T, R> extractDataDelegate, ExtractFloatFromData <R> extractfloatDelegate)
    {
        RectTransform rectTransform = GetComponent <RectTransform>();
        Vector2       rectSize      = new Vector2(rectTransform.rect.width, rectTransform.rect.height);
        Vector2       rectSize02    = rectTransform.sizeDelta;

        _chartHeight = rectSize.y;

        _longestList  = FindLongestListCount <T, R>(vals, extractDataDelegate);
        _highestValue = FindMaxValueIn2DList(vals, extractDataDelegate, extractfloatDelegate);

        for (int i = 0; i < _longestList /*가장 많이 실행한 훈련의 크기*/; i++)
        {
            //Make Bar & Set it as child of this object.
            Transform newBarHolder = Instantiate(_barHoldPrefab, _barGroup);
            newBarHolder.gameObject.SetActive(true);
            //이부분은 차트에서 한 column을 생성한다.
            for (int j = 0; j < vals.Count /*훈련의 갯수*/; j++)
            {
                if (extractDataDelegate(vals[j]).Count < i + 1)
                {
                    continue;
                }

                //Make Bar & Set it as child of this object
                Bar newBar = Instantiate(_barPrefab, newBarHolder.transform);
                newBar.gameObject.SetActive(true);

                R data = extractDataDelegate(vals[j])[i];

                newBar.data = data;

                if (_isBarChart)
                {
                    newBar.bar.GetComponent <Image>().color = GetColor(j);
                }

                float         value           = extractfloatDelegate(data);
                RectTransform rt              = newBar.bar.rectTransform;
                float         normalizedValue = ((float)value / (float)_highestValue) * _chartHeightRatio;
                //Setting value's text
                newBar.barValue.text = value.ToString();
                //Setting bar's height
                rt.sizeDelta = new Vector2(rt.sizeDelta.x, _chartHeight * normalizedValue);

                //Save Bar information into BarHolder

                if (i == 0)
                {
                    BarManager barManager = new BarManager();
                    barManager.bars.Add(newBar);
                    barManager.index = j;
                    barManagers.Add(barManager);
                }
                else
                {
                    barManagers[j].bars.Add(newBar);
                }
            }
            //Save BarHolder information into List


            //일정비율 이상이면 그 간격으로 유지하기 위해 그 크기만큼 Chart area를 넓혀준다.
            if (i > _chartAreaIntervalRatio)
            {
                ExpandChartArea(rectSize);
            }
        }
    }
Exemple #4
0
    public void MakeChart <T, R>(List <T> list, ExtractDataListFromList <T, R> extractDataDelegate, ExtractFloatFromData <R> extractFloatDelegate, ExtractNameFromList <T> extractNamesDelegate)
    {
        _makeType = 6;
        MakePoints <T, R>(list, extractDataDelegate, extractFloatDelegate);
        MakeLines();
        MakeLabels(extractNamesDelegate(list));
        MakeChartBackLine();

        _paramData = new List <object>();
        _paramData.Add(list);
        _paramData.Add(extractDataDelegate);
        _paramData.Add(extractFloatDelegate);
        _paramData.Add(extractNamesDelegate);
    }