public string GetFormatterContent(string serieName, string dataName, float dataValue, float dataTotal = 0)
 {
     if (string.IsNullOrEmpty(m_Formatter))
     {
         return(ChartCached.FloatToStr(dataValue, 0, m_ForceENotation));
     }
     else
     {
         var content = m_Formatter.Replace("{a}", serieName);
         content = content.Replace("{b}", dataName);
         content = content.Replace("{c}", ChartCached.FloatToStr(dataValue, 0, m_ForceENotation));
         content = content.Replace("{c:f0}", ChartCached.IntToStr((int)Mathf.Round(dataValue)));
         content = content.Replace("{c:f1}", ChartCached.FloatToStr(dataValue, 1));
         content = content.Replace("{c:f2}", ChartCached.FloatToStr(dataValue, 2));
         if (dataTotal > 0)
         {
             var percent = dataValue / dataTotal * 100;
             content = content.Replace("{d}", ChartCached.FloatToStr(percent, 1));
             content = content.Replace("{d:f0}", ChartCached.IntToStr((int)Mathf.Round(percent)));
             content = content.Replace("{d:f1}", ChartCached.FloatToStr(percent, 1));
             content = content.Replace("{d:f2}", ChartCached.FloatToStr(percent, 2));
         }
         content = content.Replace("\\n", "\n");
         content = content.Replace("<br/>", "\n");
         return(content);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 获得所有系列名,不包含空名字。
 /// </summary>
 /// <returns></returns>
 public List<string> GetSerieNameList()
 {
     serieNameList.Clear();
     for (int n = 0; n < m_Series.Count; n++)
     {
         var serie = m_Series[n];
         switch (serie.type)
         {
             case SerieType.Pie:
             case SerieType.Radar:
                 for (int i = 0; i < serie.data.Count; i++)
                 {
                     if (string.IsNullOrEmpty(serie.data[i].name))
                         serieNameList.Add(ChartCached.IntToStr(i));
                     else if (!serieNameList.Contains(serie.data[i].name))
                         serieNameList.Add(serie.data[i].name);
                 }
                 break;
             default:
                 if (string.IsNullOrEmpty(serie.name))
                     serieNameList.Add(ChartCached.IntToStr(n));
                 else if (!serieNameList.Contains(serie.name))
                     serieNameList.Add(serie.name);
                 break;
         }
     }
     return serieNameList;
 }
Beispiel #3
0
        public static string GetFormatterContent(Serie serie, SerieData serieData,
                                                 float dataValue, float dataTotal, SerieLabel serieLabel = null)
        {
            if (serieLabel == null)
            {
                serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
            }
            var numericFormatter = GetLabelNumericFormatter(serie, serieData);
            var serieName        = serie.name;
            var dataName         = serieData != null ? serieData.name : null;

            if (string.IsNullOrEmpty(serieLabel.formatter))
            {
                return(ChartCached.NumberToStr(dataValue, numericFormatter));
            }
            else
            {
                var content = serieLabel.formatter.Replace("{a}", serieName);
                content = content.Replace("{b}", dataName);
                content = content.Replace("{c}", ChartCached.NumberToStr(dataValue, numericFormatter));
                content = content.Replace("{c:f0}", ChartCached.IntToStr((int)Mathf.Round(dataValue)));
                content = content.Replace("{c:f1}", ChartCached.FloatToStr(dataValue, string.Empty, 1));
                content = content.Replace("{c:f2}", ChartCached.FloatToStr(dataValue, string.Empty, 2));
                var percent = dataValue == 0 && dataTotal == 0 ? 0 : dataValue / dataTotal * 100;
                content = content.Replace("{d}", ChartCached.NumberToStr(percent, numericFormatter));
                content = content.Replace("{d:f0}", ChartCached.IntToStr((int)Mathf.Round(percent)));
                content = content.Replace("{d:f1}", ChartCached.FloatToStr(percent, string.Empty, 1));
                content = content.Replace("{d:f2}", ChartCached.FloatToStr(percent, string.Empty, 2));
                content = content.Replace("\\n", "\n");
                content = content.Replace("<br/>", "\n");
                return(content);
            }
        }
Beispiel #4
0
        public string GetFormatterContent(float value, float minValue, float maxValue)
        {
            if (string.IsNullOrEmpty(m_Formatter))
            {
                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(ChartCached.FloatToStr(value, acc, m_ForceENotation));
                }
                else if (value - (int)value == 0)
                {
                    return(ChartCached.IntToStr((int)value));
                }
                else
                {
                    return(ChartCached.FloatToStr(value, 1));
                }
            }
            else if (m_Formatter.Contains("{value"))
            {
                var content = m_Formatter;
                if (content.Contains("{value:f2}"))
                {
                    content = m_Formatter.Replace("{value:f2}", ChartCached.FloatToStr(value, 2));
                }
                else if (content.Contains("{value:f1}"))
                {
                    content = m_Formatter.Replace("{value:f1}", ChartCached.FloatToStr(value, 1));
                }
                else if (content.Contains("{value}"))
                {
                    if (value - (int)value == 0)
                    {
                        content = m_Formatter.Replace("{value}", ChartCached.IntToStr((int)value));
                    }
                    else
                    {
                        content = m_Formatter.Replace("{value}", ChartCached.FloatToStr(value, 1));
                    }
                }

                content = content.Replace("\\n", "\n");
                content = content.Replace("<br/>", "\n");
                return(content);
            }
            else
            {
                return(value.ToString(m_Formatter));
            }
        }
        public string GetFormatterContent(float value, float minValue, float maxValue, bool isLog = false)
        {
            if (showAsPositiveNumber && value < 0)
            {
                value = Mathf.Abs(value);
            }
            if (string.IsNullOrEmpty(m_Formatter))
            {
                if (isLog)
                {
                    return(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(ChartCached.FloatToStr(value, numericFormatter, acc));
                }
                return(ChartCached.NumberToStr(value, numericFormatter));
            }
            else if (m_Formatter.Contains("{value"))
            {
                var content = m_Formatter;
                if (content.Contains("{value:f0}"))
                {
                    content = m_Formatter.Replace("{value:f0}", ChartCached.IntToStr((int)value));
                }
                if (content.Contains("{value:f2}"))
                {
                    content = m_Formatter.Replace("{value:f2}", ChartCached.FloatToStr(value, string.Empty, 2));
                }
                else if (content.Contains("{value:f1}"))
                {
                    content = m_Formatter.Replace("{value:f1}", ChartCached.FloatToStr(value, string.Empty, 1));
                }
                else if (content.Contains("{value}"))
                {
                    content = m_Formatter.Replace("{value}", ChartCached.NumberToStr((int)value, numericFormatter));
                }

                content = content.Replace("\\n", "\n");
                content = content.Replace("<br/>", "\n");
                return(content);
            }
            else
            {
                return(value.ToString(m_Formatter));
            }
        }
Beispiel #6
0
        /// <summary>
        /// 获得所有系列名,不包含空名字。
        /// </summary>
        /// <returns></returns>
        internal static void UpdateSerieNameList(Series series, ref List <string> serieNameList)
        {
            serieNameList.Clear();
            for (int n = 0; n < series.list.Count; n++)
            {
                var serie = series.GetSerie(n);
                switch (serie.type)
                {
                case SerieType.Pie:
                case SerieType.Radar:
                case SerieType.Ring:
                    for (int i = 0; i < serie.data.Count; i++)
                    {
                        if (serie.type == SerieType.Pie && serie.IsIgnoreValue(serie.data[i].GetData(1)))
                        {
                            continue;
                        }
                        if (string.IsNullOrEmpty(serie.data[i].name))
                        {
                            serieNameList.Add(ChartCached.IntToStr(i));
                        }
                        else if (!serieNameList.Contains(serie.data[i].name))
                        {
                            serieNameList.Add(serie.data[i].name);
                        }
                    }
                    break;

                default:
                    if (string.IsNullOrEmpty(serie.name))
                    {
                        serieNameList.Add(ChartCached.IntToStr(n));
                    }
                    else if (!serieNameList.Contains(serie.name))
                    {
                        serieNameList.Add(serie.name);
                    }
                    break;
                }
            }
        }
        public string GetFormatterContent(float value)
        {
            if (string.IsNullOrEmpty(m_Formatter))
            {
                if (value - (int)value == 0)
                {
                    return(ChartCached.IntToStr((int)value));
                }
                else
                {
                    return(ChartCached.FloatToStr(value, 1));
                }
            }
            else
            {
                var content = m_Formatter;
                if (content.Contains("{value:f2}"))
                {
                    content = m_Formatter.Replace("{value:f2}", ChartCached.FloatToStr(value, 2));
                }
                else if (content.Contains("{value:f1}"))
                {
                    content = m_Formatter.Replace("{value:f1}", ChartCached.FloatToStr(value, 1));
                }
                else if (content.Contains("{value}"))
                {
                    if (value - (int)value == 0)
                    {
                        content = m_Formatter.Replace("{value}", ChartCached.IntToStr((int)value));
                    }
                    else
                    {
                        content = m_Formatter.Replace("{value}", ChartCached.FloatToStr(value, 1));
                    }
                }

                content = content.Replace("\\n", "\n");
                content = content.Replace("<br/>", "\n");
                return(content);
            }
        }
Beispiel #8
0
 /// <summary>
 /// 获得所有系列名,不包含空名字。
 /// </summary>
 /// <returns></returns>
 public static void UpdateSerieNameList(BaseChart chart, ref List <string> serieNameList)
 {
     serieNameList.Clear();
     for (int n = 0; n < chart.series.list.Count; n++)
     {
         var serie = chart.series.GetSerie(n);
         if (serie.type == SerieType.Pie ||
             serie.type == SerieType.Radar ||
             serie.type == SerieType.Ring ||
             (serie.type == SerieType.Custom && chart.GetCustomSerieDataNameForColor()))
         {
             for (int i = 0; i < serie.data.Count; i++)
             {
                 if (serie.type == SerieType.Pie && serie.IsIgnoreValue(serie.data[i]))
                 {
                     continue;
                 }
                 if (string.IsNullOrEmpty(serie.data[i].name))
                 {
                     serieNameList.Add(ChartCached.IntToStr(i));
                 }
                 else if (!serieNameList.Contains(serie.data[i].name))
                 {
                     serieNameList.Add(serie.data[i].name);
                 }
             }
         }
         else
         {
             if (string.IsNullOrEmpty(serie.name))
             {
                 serieNameList.Add(ChartCached.IntToStr(n));
             }
             else if (!serieNameList.Contains(serie.name))
             {
                 serieNameList.Add(serie.name);
             }
         }
     }
 }
 public static string Cancat(string str1, int i)
 {
     s_Builder.Length = 0;
     s_Builder.Append(str1).Append(ChartCached.IntToStr(i));
     return(s_Builder.ToString());
 }