public static string GetFormatterContent(Serie serie, SerieData serieData,
                                                 double dataValue, double dataTotal, SerieLabel serieLabel, Color color)
        {
            if (serieLabel == null)
            {
                serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
            }
            var numericFormatter = serieLabel == null ? serie.label.numericFormatter : serieLabel.numericFormatter;
            var serieName        = serie.name;
            var dataName         = serieData != null ? serieData.name : null;

            if (serieLabel.formatterFunction != null)
            {
                return(serieLabel.formatterFunction(serieData.index, dataValue));
            }
            if (string.IsNullOrEmpty(serieLabel.formatter))
            {
                return(ChartCached.NumberToStr(dataValue, numericFormatter));
            }
            else
            {
                var content = serieLabel.formatter;
                FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, dataValue,
                                                         dataTotal, serieName, dataName, color);
                return(content);
            }
        }
예제 #2
0
        public static string GetFormatterContent(Serie serie, MarkLineData data)
        {
            var serieLabel       = data.label;
            var numericFormatter = serieLabel.numericFormatter;

            if (serieLabel.formatterFunction != null)
            {
                return(serieLabel.formatterFunction(data.index, data.runtimeValue));
            }
            if (string.IsNullOrEmpty(serieLabel.formatter))
            {
                return(ChartCached.NumberToStr(data.runtimeValue, numericFormatter));
            }
            else
            {
                var content = serieLabel.formatter;
                FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, data.runtimeValue,
                                                         0, serie.name, data.name, Color.clear);
                return(content);
            }
        }
예제 #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;
                FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, dataValue,
                                                         dataTotal, serieName, dataName);
                return(content);
            }
        }
예제 #4
0
        public static void InitRadarTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, Radar radar,
                                            ThemeInfo themeInfo)
        {
            if (!serie.show)
            {
                return;
            }
            if (serie.radarIndex != radar.index)
            {
                return;
            }
            var dataIndex = tooltip.runtimeDataIndex[1];
            var serieData = serie.GetSerieData(dataIndex);

            if (!serieData.show)
            {
                return;
            }
            var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData);

            switch (serie.radarType)
            {
            case RadarType.Multiple:
                if (radar.isAxisTooltip)
                {
                    var dimension = tooltip.runtimeDataIndex[2];
                    if (!string.IsNullOrEmpty(serie.name))
                    {
                        sb.Append(serie.name).Append("\n");
                    }
                    var total = serie.GetDataTotal(dimension);
                    var first = true;
                    for (int i = 0; i < serie.dataCount; i++)
                    {
                        var sd = serie.GetSerieData(i);
                        if (!sd.show)
                        {
                            continue;
                        }
                        var key           = sd.name;
                        var value         = sd.GetData(dimension);
                        var itemFormatter = GetItemFormatter(tooltip, serie, sd);
                        numericFormatter = GetItemNumericFormatter(tooltip, serie, sd);
                        if (!first)
                        {
                            sb.Append("\n");
                        }
                        first = false;
                        sb.Append("<color=#").Append(themeInfo.GetColorStr(i)).Append(">● </color>");
                        if (string.IsNullOrEmpty(itemFormatter))
                        {
                            if (string.IsNullOrEmpty(key))
                            {
                                key = radar.indicatorList[dataIndex].name;
                            }
                            if (string.IsNullOrEmpty(key))
                            {
                                sb.AppendFormat("{0}\n", ChartCached.FloatToStr(value, numericFormatter));
                            }
                            else
                            {
                                sb.AppendFormat("{0}: {1}\n", key, ChartCached.FloatToStr(value, numericFormatter));
                            }
                        }
                        else
                        {
                            string content = itemFormatter;
                            FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, value, total, serie.name, sd.name);
                            sb.Append(content);
                        }
                    }
                }
                else
                {
                    if (serie.index != tooltip.runtimeDataIndex[0])
                    {
                        return;
                    }
                    sb.Append(serieData.name);
                    for (int i = 0; i < radar.indicatorList.Count; i++)
                    {
                        string key   = radar.indicatorList[i].name;
                        float  value = serieData.GetData(i);
                        if ((i == 0 && !string.IsNullOrEmpty(serieData.name)) || i > 0)
                        {
                            sb.Append(FormatterHelper.PH_NN);
                        }
                        sb.AppendFormat("{0}: {1}", key, ChartCached.FloatToStr(value, numericFormatter));
                    }
                }
                break;

            case RadarType.Single:
                var key2           = serieData.name;
                var value2         = serieData.GetData(1);
                var total2         = serie.GetDataTotal(1);
                var itemFormatter2 = GetItemFormatter(tooltip, serie, serieData);
                if (string.IsNullOrEmpty(itemFormatter2))
                {
                    if (string.IsNullOrEmpty(key2))
                    {
                        key2 = radar.indicatorList[dataIndex].name;
                    }
                    sb.AppendFormat("{0}: {1}", key2, ChartCached.FloatToStr(value2, numericFormatter));
                }
                else
                {
                    string content = itemFormatter2;
                    FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, value2, total2, serie.name, serieData.name);
                    sb.Append(content);
                }

                break;
            }
        }