Exemplo n.º 1
0
        public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue)
        {
            var timestamp  = (int)value;
            var dateTime   = DateTimeUtil.GetDateTime(timestamp);
            var dateString = string.Empty;

            if (string.IsNullOrEmpty(numericFormatter))
            {
                dateString = DateTimeUtil.GetDateTimeFormatString(dateTime, maxValue - minValue);
            }
            else
            {
                dateString = dateTime.ToString(numericFormatter);
            }
            if (!string.IsNullOrEmpty(m_Formatter))
            {
                var content = m_Formatter;
                FormatterHelper.ReplaceAxisLabelContent(ref content, dateString);
                return(GetFormatterFunctionContent(labelIndex, value, m_TextLimit.GetLimitContent(content)));
            }
            else
            {
                return(GetFormatterFunctionContent(labelIndex, value, m_TextLimit.GetLimitContent(dateString)));
            }
        }
Exemplo n.º 2
0
 public string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
 {
     if (showAsPositiveNumber && value < 0)
     {
         value = Math.Abs(value);
     }
     if (string.IsNullOrEmpty(m_Formatter))
     {
         if (isLog)
         {
             return(GetFormatterFunctionContent(labelIndex, value, ChartCached.NumberToStr(value, numericFormatter)));
         }
         if (minValue >= -1 && minValue <= 1 && maxValue >= -1 && maxValue <= 1)
         {
             int minAcc = ChartHelper.GetFloatAccuracy(minValue);
             int maxAcc = ChartHelper.GetFloatAccuracy(maxValue);
             int curAcc = ChartHelper.GetFloatAccuracy(value);
             int acc    = Mathf.Max(Mathf.Max(minAcc, maxAcc), curAcc);
             return(GetFormatterFunctionContent(labelIndex, value, ChartCached.FloatToStr(value, numericFormatter, acc)));
         }
         return(GetFormatterFunctionContent(labelIndex, value, ChartCached.NumberToStr(value, numericFormatter)));
     }
     else
     {
         var content = m_Formatter;
         FormatterHelper.ReplaceAxisLabelContent(ref content, numericFormatter, value);
         return(GetFormatterFunctionContent(labelIndex, value, content));
     }
 }
Exemplo n.º 3
0
        public string GetFormatterContent(int labelIndex, string category)
        {
            if (string.IsNullOrEmpty(category))
            {
                return(GetFormatterFunctionContent(labelIndex, category, category));
            }

            if (string.IsNullOrEmpty(m_Formatter))
            {
                return(GetFormatterFunctionContent(labelIndex, category, m_TextLimit.GetLimitContent(category)));
            }
            else
            {
                var content = m_Formatter;
                FormatterHelper.ReplaceAxisLabelContent(ref content, category);
                return(GetFormatterFunctionContent(labelIndex, category, m_TextLimit.GetLimitContent(content)));
            }
        }
Exemplo n.º 4
0
        public string GetFormatterIndicatorContent(string indicatorName)
        {
            if (string.IsNullOrEmpty(indicatorName))
            {
                return(indicatorName);
            }

            if (string.IsNullOrEmpty(m_AxisName.labelStyle.formatter))
            {
                return(indicatorName);
            }
            else
            {
                var content = m_AxisName.labelStyle.formatter;
                FormatterHelper.ReplaceAxisLabelContent(ref content, indicatorName);
                return(content);
            }
        }