Esempio n. 1
0
    ///<summary>
    /// Update labels
    ///</summary>
    public void UpdateLabels()
    {
        for (int i = 0; i < dataSet.Rows; i++)
        {
            for (int j = 0; j < dataSet.Columns; j++)
            {
                LabelPosition labelPos = barChart.GetLabelPosition(i, j, barLabelPos.value);
                if (labelPos != null)
                {
                    barLabels[i * dataSet.Columns + j].transform.parent.gameObject.SetActive(barLabelToggle.isOn);
                    barLabels[i * dataSet.Columns + j].text = labelPos.value.ToString("0.00");
                    barLabels[i * dataSet.Columns + j].transform.parent.gameObject.GetComponent <RectTransform>().anchoredPosition = labelPos.position;
                }

                labelPos = lineChart.GetLabelPosition(i, j);
                if (labelPos != null)
                {
                    lineLabels[i * dataSet.Columns + j].gameObject.SetActive(lineLabelToggle.isOn);
                    lineLabels[i * dataSet.Columns + j].text = labelPos.value.ToString("0.00");
                    lineLabels[i * dataSet.Columns + j].rectTransform.anchoredPosition = labelPos.position;
                }
            }
        }
        barLabelPos.interactable = barLabelToggle.isOn;

        LabelPosition[] positions = barChart.GetAxisXPositions();
        if (positions != null)
        {
            for (int i = 0; i < positions.Length; i++)
            {
                barXLabels[i].gameObject.SetActive(barLabelToggle.isOn);
                barXLabels[i].GetComponent <RectTransform>().anchoredPosition = positions[i].position;
            }
        }

        positions = barChart.GetAxisYPositions();
        if (positions != null)
        {
            for (int i = 0; i < barYLabels.Count; i++)
            {
                if (positions.Length - 1 < i)
                {
                    barYLabels[i].gameObject.SetActive(false);
                }
                else
                {
                    barYLabels[i].gameObject.SetActive(barLabelToggle.isOn);
                    barYLabels[i].text = positions[i].value.ToString("0.0");
                    barYLabels[i].GetComponent <RectTransform>().anchoredPosition = positions[i].position;
                }
            }
        }

        positions = lineChart.GetAxisXPositions();
        if (positions != null)
        {
            for (int i = 0; i < positions.Length; i++)
            {
                lineXLabels[i].gameObject.SetActive(lineLabelToggle.isOn);
                lineXLabels[i].GetComponent <RectTransform>().anchoredPosition = positions[i].position;
            }
        }

        positions = lineChart.GetAxisYPositions();
        if (positions != null)
        {
            for (int i = 0; i < lineYLabels.Count; i++)
            {
                if (positions.Length - 1 < i)
                {
                    lineYLabels[i].gameObject.SetActive(false);
                }
                else
                {
                    lineYLabels[i].gameObject.SetActive(lineLabelToggle.isOn);
                    lineYLabels[i].text = positions[i].value.ToString("0.0");
                    lineYLabels[i].GetComponent <RectTransform>().anchoredPosition = positions[i].position;
                }
            }
        }
    }
Esempio n. 2
0
    ///<summary>
    /// Update labels
    ///</summary>
    public void UpdateLabels()
    {
        for (int i = 0; i < _dataSet.Rows; i++)
        {
            for (int j = 0; j < _dataSet.Columns; j++)
            {
                LabelPosition labelPos = _barChart.GetLabelPosition(i, j, 1.0f);
                if (labelPos != null)
                {
                    string str = recordType == RECORD_TYPE.MUSC ? labelPos.value.ToString("0") : PublicFunction.ConvertTimeToString((int)labelPos.value);
                    _barLabels[i * _dataSet.Columns + j].transform.parent.gameObject.SetActive(true);
                    _barLabels[i * _dataSet.Columns + j].text = str;
                    _barLabels[i * _dataSet.Columns + j].transform.parent.gameObject.GetComponent <RectTransform>().anchoredPosition = labelPos.position;
                }
            }
        }

        for (int i = 0; i < _dataSetLine.Rows; i++)
        {
            for (int j = 0; j < _dataSetLine.Columns; j++)
            {
                LabelPosition labelPos = _lineChart.GetLabelPosition(i, j);
                if (labelPos != null)
                {
                    string str = recordType == RECORD_TYPE.MUSC ? labelPos.value.ToString("0") : PublicFunction.ConvertTimeToString((int)labelPos.value);
                    _lineLabels[i * _dataSetLine.Columns + j].gameObject.SetActive(true);
                    _lineLabels[i * _dataSetLine.Columns + j].text = str;
                    _lineLabels[i * _dataSetLine.Columns + j].rectTransform.anchoredPosition = labelPos.position;
                }
            }
        }

        LabelPosition[] positions = _barChart.GetAxisXPositions();
        if (positions != null)
        {
            for (int i = 0; i < positions.Length; i++)
            {
                _barXLabels[i].gameObject.SetActive(true);
                _barXLabels[i].GetComponent <RectTransform>().anchoredPosition = positions[i].position;
            }
        }

        positions = _barChart.GetAxisYPositions();
        if (positions != null)
        {
            for (int i = 0; i < 5; i++)
            {
                if (positions.Length - 1 < i)
                {
                    _barYLabels[i].gameObject.SetActive(false);
                }
                else
                {
                    string str = recordType == RECORD_TYPE.MUSC ? positions[i].value.ToString("0") : PublicFunction.ConvertTimeToString((int)positions[i].value);
                    _barYLabels[i].gameObject.SetActive(true);
                    _barYLabels[i].text = str;
                    _barYLabels[i].GetComponent <RectTransform>().anchoredPosition = positions[i].position;
                }
            }
        }

        positions = _lineChart.GetAxisXPositions();
        if (positions != null)
        {
            for (int i = 0; i < positions.Length; i++)
            {
                _lineXLabels[i].gameObject.SetActive(true);
                _lineXLabels[i].GetComponent <RectTransform>().anchoredPosition = positions[i].position;
            }
        }

        positions = _lineChart.GetAxisYPositions();
        if (positions != null)
        {
            for (int i = 0; i < 5; i++)
            {
                if (positions.Length - 1 < i)
                {
                    _lineYLabels[i].gameObject.SetActive(false);
                }
                else
                {
                    string str = recordType == RECORD_TYPE.MUSC ? positions[i].value.ToString("0") : PublicFunction.ConvertTimeToString((int)positions[i].value);
                    _lineYLabels[i].gameObject.SetActive(true);
                    _lineYLabels[i].text = str;
                    _lineYLabels[i].GetComponent <RectTransform>().anchoredPosition = positions[i].position;
                }
            }
        }
    }