コード例 #1
0
 internal static void ResetTooltipParamsByItemFormatter(Tooltip tooltip, BaseChart chart)
 {
     if (!string.IsNullOrEmpty(tooltip.titleFormatter))
     {
         if (IsIgnoreFormatter(tooltip.titleFormatter))
         {
             tooltip.context.data.title = string.Empty;
         }
         else
         {
             tooltip.context.data.title = tooltip.titleFormatter;
             FormatterHelper.ReplaceContent(ref tooltip.context.data.title, 0,
                                            tooltip.numericFormatter, null, chart);
         }
     }
     for (int i = tooltip.context.data.param.Count - 1; i >= 0; i--)
     {
         var param = tooltip.context.data.param[i];
         if (IsIgnoreFormatter(param.itemFormatter))
         {
             tooltip.context.data.param.RemoveAt(i);
         }
     }
     foreach (var param in tooltip.context.data.param)
     {
         if (!string.IsNullOrEmpty(param.itemFormatter))
         {
             param.columns.Clear();
             var content = param.itemFormatter;
             FormatterHelper.ReplaceSerieLabelContent(ref content,
                                                      param.numericFormatter,
                                                      param.dataCount,
                                                      param.value,
                                                      param.total,
                                                      param.serieName,
                                                      param.category,
                                                      param.serieData.name,
                                                      param.color,
                                                      param.serieData);
             foreach (var item in content.Split('|'))
             {
                 param.columns.Add(item);
             }
         }
     }
 }
コード例 #2
0
        public static string GetFormatterContent(Serie serie, MarkLineData data)
        {
            var serieLabel       = data.label;
            var numericFormatter = serieLabel.numericFormatter;

            if (string.IsNullOrEmpty(serieLabel.formatter))
            {
                var content = ChartCached.NumberToStr(data.runtimeValue, numericFormatter);
                return(serieLabel.formatterFunction == null? content:
                       serieLabel.formatterFunction(data.index, data.runtimeValue, null, content));
            }
            else
            {
                var content = serieLabel.formatter;
                FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, data.runtimeValue,
                                                         0, serie.serieName, data.name, data.name, Color.clear, null);
                return(serieLabel.formatterFunction == null? content:
                       serieLabel.formatterFunction(data.index, data.runtimeValue, null, content));
            }
        }
コード例 #3
0
        public static string GetFormatterContent(Serie serie, SerieData serieData,
                                                 double dataValue, double dataTotal, LabelStyle serieLabel, Color color)
        {
            if (serieLabel == null)
            {
                serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
            }
            var numericFormatter = serieLabel == null ? "" : serieLabel.numericFormatter;
            var serieName        = serie.serieName;
            var dataName         = serieData != null ? serieData.name : null;

            if (string.IsNullOrEmpty(serieLabel.formatter))
            {
                var currentContent = ChartCached.NumberToStr(dataValue, numericFormatter);
                if (serieLabel.formatterFunction == null)
                {
                    return(currentContent);
                }
                else
                {
                    return(serieLabel.formatterFunction(serieData.index, dataValue, null, currentContent));
                }
            }
            else
            {
                var content = serieLabel.formatter;
                FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue,
                                                         dataTotal, serieName, dataName, dataName, color, serieData);
                if (serieLabel.formatterFunction == null)
                {
                    return(content);
                }
                else
                {
                    return(serieLabel.formatterFunction(serieData.index, dataValue, null, content));
                }
            }
        }