private void UdpateTooltipLabel() { if (tooltip.type != Tooltip.Type.Corss) { return; } var m_Polar = GetPolar(tooltip.runtimePolarIndex); if (m_Polar == null) { return; } var m_AngleAxis = GetAngleAxis(m_Polar.index); var m_RadiusAxis = GetRadiusAxis(m_Polar.index); var cenPos = m_Polar.runtimeCenterPos; var radius = m_Polar.runtimeRadius; m_AngleAxis.SetTooltipLabelActive(true); m_RadiusAxis.SetTooltipLabelActive(true); m_AngleAxis.UpdateTooptipLabelText(ChartCached.FloatToStr(tooltip.runtimeAngle)); var tooltipAngle = tooltip.runtimeAngle + m_AngleAxis.runtimeStartAngle; var ep = ChartHelper.GetPos(cenPos, radius + 5, tooltipAngle, true); m_AngleAxis.UpdateTooltipLabelPos(ep); var dist = Vector2.Distance(pointerPos, cenPos); if (dist > radius) { dist = radius; } float min = m_RadiusAxis.runtimeMinValue; float max = m_RadiusAxis.runtimeMaxValue; var value = (float)(min + dist / radius * m_RadiusAxis.runtimeMinMaxRange); m_RadiusAxis.UpdateTooptipLabelText(ChartCached.FloatToStr(value)); m_RadiusAxis.UpdateTooltipLabelPos(ChartHelper.GetPos(cenPos, dist, m_AngleAxis.runtimeStartAngle, true)); }
/// <summary> /// 获得所有系列名,不包含空名字。 /// </summary> /// <returns></returns> internal 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: case SerieType.Ring: 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); }
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 = serieLabel == null ? serie.label.numericFormatter : serieLabel.numericFormatter; 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); } }
/// <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 (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 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)); if (dataTotal > 0) { var percent = 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); } }
public static string Cancat(string str1, int i) { s_Builder.Length = 0; s_Builder.Append(str1).Append(ChartCached.IntToStr(i)); return(s_Builder.ToString()); }
/// <summary> /// 替换字符串中的通配符,支持的通配符有{.}、{a}、{b}、{c}、{d}。 /// </summary> /// <param name="content">要替换的字符串</param> /// <param name="dataIndex">选中的数据项serieData索引</param> /// <param name="numericFormatter">默认的数字格式化</param> /// <param name="serie">选中的serie</param> /// <param name="series">所有serie</param> /// <param name="theme">用来获取指定index的颜色</param> /// <param name="category">选中的类目,一般用在折线图和柱状图</param> /// <param name="dataZoom">dataZoom</param> /// <returns></returns> public static bool ReplaceContent(ref string content, int dataIndex, string numericFormatter, Serie serie, Series series, ChartTheme theme, string category = null, DataZoom dataZoom = null) { var foundDot = false; var mc = s_Regex.Matches(content); foreach (var m in mc) { var old = m.ToString(); var args = s_RegexSub.Matches(m.ToString()); var argsCount = args.Count; if (argsCount <= 0) { continue; } int targetIndex = 0; char p = GetSerieIndex(args[0].ToString(), ref targetIndex); if (targetIndex >= 0) { serie = series.GetSerie(targetIndex); if (serie == null) { continue; } } else if (serie != null) { targetIndex = serie.index; } else { serie = series.GetSerie(0); targetIndex = 0; } if (serie == null) { continue; } if (p == '.') { var bIndex = targetIndex; if (argsCount >= 2) { var args1Str = args[1].ToString(); if (s_RegexN.IsMatch(args1Str)) { bIndex = int.Parse(args1Str); } } content = content.Replace(old, ChartCached.ColorToDotStr(theme.GetColor(bIndex))); foundDot = true; } else if (p == 'a' || p == 'A') { if (argsCount == 1) { content = content.Replace(old, serie.name); } } else if (p == 'b' || p == 'B') { var bIndex = dataIndex; if (argsCount >= 2) { var args1Str = args[1].ToString(); if (s_RegexN.IsMatch(args1Str)) { bIndex = int.Parse(args1Str); } } var needCategory = serie.type == SerieType.Line || serie.type == SerieType.Bar; if (needCategory) { content = content.Replace(old, category); } else { var serieData = serie.GetSerieData(bIndex, dataZoom); content = content.Replace(old, serieData.name); } } else if (p == 'c' || p == 'C' || p == 'd' || p == 'D') { var isPercent = p == 'd' || p == 'D'; var bIndex = dataIndex; var dimensionIndex = -1; if (argsCount >= 2) { var args1Str = args[1].ToString(); if (s_RegexFn.IsMatch(args1Str)) { numericFormatter = args1Str; } else if (s_RegexN_N.IsMatch(args1Str)) { var temp = args1Str.Split('-'); bIndex = int.Parse(temp[0]); dimensionIndex = int.Parse(temp[1]); } else if (s_RegexN.IsMatch(args1Str)) { dimensionIndex = int.Parse(args1Str); } else { Debug.LogError("unmatch:" + args1Str); continue; } } if (argsCount >= 3) { numericFormatter = args[2].ToString(); } if (dimensionIndex == -1) { dimensionIndex = 1; } if (numericFormatter == string.Empty) { numericFormatter = SerieHelper.GetNumericFormatter(serie, serie.GetSerieData(bIndex)); } var value = serie.GetData(bIndex, dimensionIndex, dataZoom); if (isPercent) { var total = serie.GetDataTotal(dimensionIndex); var percent = total == 0 ? 0 : value / serie.yTotal * 100; content = content.Replace(old, ChartCached.FloatToStr(percent, numericFormatter)); } else { content = content.Replace(old, ChartCached.FloatToStr(value, numericFormatter)); } } } content = s_RegexNewLine.Replace(content, PH_NN); return(foundDot); }
protected override void OnRefreshLabel() { var isYAxis = (m_YAxises[0].show && m_YAxises[0].type == Axis.AxisType.Category) || (m_YAxises[1].show && m_YAxises[1].type == Axis.AxisType.Category); for (int i = 0; i < m_Series.Count; i++) { var serie = m_Series.GetSerie(i); if (serie.type == SerieType.Bar && serie.show) { var zeroPos = Vector3.zero; if (serie.label.position == SerieLabel.Position.Bottom || serie.label.position == SerieLabel.Position.Center) { if (isYAxis) { var xAxis = m_XAxises[serie.axisIndex]; zeroPos = new Vector3(coordinateX + xAxis.zeroXOffset, coordinateY); } else { var yAxis = m_YAxises[serie.axisIndex]; zeroPos = new Vector3(coordinateX, coordinateY + yAxis.zeroYOffset); } } for (int j = 0; j < serie.data.Count; j++) { var serieData = serie.data[j]; if (serie.label.show) { var pos = serie.dataPoints[j]; switch (serie.label.position) { case SerieLabel.Position.Center: pos = isYAxis ? new Vector3(zeroPos.x + (pos.x - zeroPos.x) / 2, pos.y) : new Vector3(pos.x, zeroPos.y + (pos.y - zeroPos.y) / 2); break; case SerieLabel.Position.Bottom: pos = isYAxis ? new Vector3(zeroPos.x, pos.y) : new Vector3(pos.x, zeroPos.y); break; } var value = serieData.data[1]; serieData.SetLabelActive(true); serieData.SetLabelText(ChartCached.FloatToStr(value)); if (isYAxis) { if (value >= 0) { serieData.SetLabelPosition(new Vector3(pos.x + serie.label.distance, pos.y)); } else { serieData.SetLabelPosition(new Vector3(pos.x - serie.label.distance, pos.y)); } } else { if (value >= 0) { serieData.SetLabelPosition(new Vector3(pos.x, pos.y + serie.label.distance)); } else { serieData.SetLabelPosition(new Vector3(pos.x, pos.y - serie.label.distance)); } } } else { serieData.SetLabelActive(false); } } } } }
public static string GetFormatterContent(Tooltip tooltip, int dataIndex, Series series, ThemeInfo themeInfo, string category = null, DataZoom dataZoom = null, bool isCartesian = false, Radar radar = null) { if (string.IsNullOrEmpty(tooltip.formatter)) { var sb = ChartHelper.sb; var title = tooltip.titleFormatter; var formatTitle = !string.IsNullOrEmpty(title); var titleIsIgnroe = false; var needCategory = false; var first = true; var isScatter = false; sb.Length = 0; if ("{i}".Equals(tooltip.titleFormatter)) { title = string.Empty; formatTitle = false; titleIsIgnroe = true; } for (int i = 0; i < series.Count; i++) { var serie = series.GetSerie(i); if (serie.type == SerieType.Scatter || serie.type == SerieType.EffectScatter) { if (serie.show && IsSelectedSerie(tooltip, serie.index)) { isScatter = true; var itemFormatter = GetItemFormatter(tooltip, serie, null); if (string.IsNullOrEmpty(itemFormatter)) { if (!first) { sb.Append(FormatterHelper.PH_NN); } InitDefaultContent(ref sb, tooltip, serie, dataIndex, category, themeInfo, dataZoom, isCartesian, radar); first = false; continue; } var itemTitle = title; if (!string.IsNullOrEmpty(itemTitle)) { FormatterHelper.ReplaceContent(ref itemTitle, dataIndex, tooltip.numericFormatter, serie, series, themeInfo, category, dataZoom); sb.Append(itemTitle).Append(FormatterHelper.PH_NN); } var dataIndexList = tooltip.runtimeSerieIndex[serie.index]; foreach (var tempIndex in dataIndexList) { string content = itemFormatter; var foundDot = FormatterHelper.ReplaceContent(ref content, tempIndex, tooltip.numericFormatter, serie, series, themeInfo, category, dataZoom); if (!foundDot) { sb.Append(ChartCached.ColorToDotStr(themeInfo.GetColor(serie.index))); } sb.Append(content).Append(FormatterHelper.PH_NN); } } } else if (IsNeedTooltipSerie(serie, tooltip)) { var serieData = serie.GetSerieData(dataIndex, dataZoom); if (serieData == null) { continue; } var itemFormatter = GetItemFormatter(tooltip, serie, serieData); needCategory = needCategory || (serie.type == SerieType.Line || serie.type == SerieType.Bar); if (formatTitle) { FormatterHelper.ReplaceContent(ref title, dataIndex, tooltip.numericFormatter, serie, series, themeInfo, category, dataZoom); } if (serie.show) { if (string.IsNullOrEmpty(itemFormatter) || serie.type == SerieType.Radar) { if (!first) { sb.Append(FormatterHelper.PH_NN); } InitDefaultContent(ref sb, tooltip, serie, dataIndex, category, themeInfo, dataZoom, isCartesian, radar); first = false; continue; } string content = itemFormatter; FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, serie, series, themeInfo, category, dataZoom); if (!first) { sb.Append(FormatterHelper.PH_NN); } var dotColorIndex = serie.type == SerieType.Pie || serie.type == SerieType.Radar || serie.type == SerieType.Ring ? dataIndex : i; sb.Append(ChartCached.ColorToDotStr(themeInfo.GetColor(dotColorIndex))); sb.Append(content); first = false; } } } if (isScatter) { return(FormatterHelper.TrimAndReplaceLine(sb)); } else if (string.IsNullOrEmpty(title)) { if (needCategory && !titleIsIgnroe) { return(category + FormatterHelper.PH_NN + FormatterHelper.TrimAndReplaceLine(sb)); } else { return(FormatterHelper.TrimAndReplaceLine(sb)); } } else { title = FormatterHelper.TrimAndReplaceLine(title); return(title + FormatterHelper.PH_NN + FormatterHelper.TrimAndReplaceLine(sb)); } } else { string content = tooltip.formatter; FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, null, series, themeInfo, category, dataZoom); return(content); } }
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) { if (value - (int)value == 0) { return(ChartCached.IntToStr((int)value)); } else { return(ChartCached.FloatToStr(value)); } } 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: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, 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 static string GetFormatterContent(Tooltip tooltip, int dataIndex, Series series, ThemeInfo themeInfo, string category = null, DataZoom dataZoom = null, bool isCartesian = false) { if (string.IsNullOrEmpty(tooltip.formatter)) { var sb = ChartHelper.sb; var title = tooltip.titleFormatter; var formatTitle = !string.IsNullOrEmpty(title); var needCategory = false; var first = true; sb.Length = 0; for (int i = 0; i < series.Count; i++) { var serie = series.GetSerie(i); if (!serie.show) { continue; } var serieData = serie.GetSerieData(dataIndex, dataZoom); if (serieData == null) { continue; } var itemFormatter = GetItemFormatter(tooltip, serie, serieData); var percent = serieData.GetData(1) / serie.yTotal * 100; needCategory = needCategory || (serie.type == SerieType.Line || serie.type == SerieType.Bar); if (serie.show) { if (string.IsNullOrEmpty(itemFormatter)) { if (!first) { sb.Append("\n"); } InitDefaultContent(ref sb, tooltip, serie, dataIndex, category, themeInfo, dataZoom, isCartesian); first = false; continue; } string content = itemFormatter; content = content.Replace("{a}", serie.name); content = content.Replace("{b}", needCategory ? category : serieData.name); content = content.Replace("{c}", ChartCached.FloatToStr(serieData.GetData(1), 0, tooltip.forceENotation)); content = content.Replace("{d}", ChartCached.FloatToStr(percent, 1)); if (!first) { sb.Append("\n"); } sb.Append("<color=#").Append(themeInfo.GetColorStr(i)).Append(">● </color>"); sb.Append(content); first = false; } if (formatTitle) { if (i == 0) { title = title.Replace("{a}", serie.name); title = title.Replace("{b}", needCategory ? category : serieData.name); title = title.Replace("{c}", ChartCached.FloatToStr(serieData.GetData(1), 0, tooltip.forceENotation)); title = title.Replace("{d}", ChartCached.FloatToStr(percent, 1)); } title = title.Replace("{a" + i + "}", serie.name); title = title.Replace("{b" + i + "}", needCategory ? category : serieData.name); title = title.Replace("{c" + i + "}", ChartCached.FloatToStr(serieData.GetData(1), 0, tooltip.forceENotation)); title = title.Replace("{d" + i + "}", ChartCached.FloatToStr(percent, 1)); } } if (string.IsNullOrEmpty(title)) { if (needCategory) { return(category + "\n" + sb.ToString()); } else { return(sb.ToString()); } } else { title = title.Replace("\\n", "\n"); title = title.Replace("<br/>", "\n"); return(title + "\n" + sb.ToString()); } } else { string content = tooltip.formatter; for (int i = 0; i < series.Count; i++) { var serie = series.GetSerie(i); if (serie.show) { var needCategory = serie.type == SerieType.Line || serie.type == SerieType.Bar; var serieData = serie.GetSerieData(dataIndex, dataZoom); var percent = serieData.GetData(1) / serie.yTotal * 100; if (i == 0) { content = content.Replace("{a}", serie.name); content = content.Replace("{b}", needCategory ? category : serieData.name); content = content.Replace("{c}", ChartCached.FloatToStr(serieData.GetData(1), 0, tooltip.forceENotation)); content = content.Replace("{d}", ChartCached.FloatToStr(percent, 1)); } content = content.Replace("{a" + i + "}", serie.name); content = content.Replace("{b" + i + "}", needCategory ? category : serieData.name); content = content.Replace("{c" + i + "}", ChartCached.FloatToStr(serieData.GetData(1), 0, tooltip.forceENotation)); content = content.Replace("{d" + i + "}", ChartCached.FloatToStr(percent, 1)); } } content = content.Replace("\\n", "\n"); content = content.Replace("<br/>", "\n"); return(content); } }
internal string GetFormatterContent(int dataIndex, Series series, string category, DataZoom dataZoom = null) { if (string.IsNullOrEmpty(m_Formatter)) { if (string.IsNullOrEmpty(m_ItemFormatter)) { return(""); } else { var sb = ChartHelper.sb; var title = m_TitleFormatter; var formatTitle = !string.IsNullOrEmpty(title); var needCategory = false; var first = true; sb.Length = 0; for (int i = 0; i < series.Count; i++) { var serie = series.GetSerie(i); var serieData = serie.GetSerieData(dataIndex, dataZoom); var percent = serieData.GetData(1) / serie.yTotal * 100; needCategory = needCategory || (serie.type == SerieType.Line || serie.type == SerieType.Bar); if (serie.show) { string content = m_ItemFormatter; content = content.Replace("{a}", serie.name); content = content.Replace("{b}", needCategory ? category : serieData.name); content = content.Replace("{c}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation)); content = content.Replace("{d}", ChartCached.FloatToStr(percent, 1)); if (!first) { sb.Append("\n"); } sb.Append(content); first = false; } if (formatTitle) { if (i == 0) { title = title.Replace("{a}", serie.name); title = title.Replace("{b}", needCategory ? category : serieData.name); title = title.Replace("{c}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation)); title = title.Replace("{d}", ChartCached.FloatToStr(percent, 1)); } title = title.Replace("{a" + i + "}", serie.name); title = title.Replace("{b" + i + "}", needCategory ? category : serieData.name); title = title.Replace("{c" + i + "}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation)); title = title.Replace("{d" + i + "}", ChartCached.FloatToStr(percent, 1)); } } if (string.IsNullOrEmpty(title)) { if (needCategory) { return(category + "\n" + sb.ToString()); } else { return(sb.ToString()); } } else { title = title.Replace("\\n", "\n"); title = title.Replace("<br/>", "\n"); return(title + "\n" + sb.ToString()); } } } else { string content = m_Formatter; for (int i = 0; i < series.Count; i++) { var serie = series.GetSerie(i); if (serie.show) { var needCategory = serie.type == SerieType.Line || serie.type == SerieType.Bar; var serieData = serie.GetSerieData(dataIndex, dataZoom); var percent = serieData.GetData(1) / serie.yTotal * 100; if (i == 0) { content = content.Replace("{a}", serie.name); content = content.Replace("{b}", needCategory ? category : serieData.name); content = content.Replace("{c}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation)); content = content.Replace("{d}", ChartCached.FloatToStr(percent, 1)); } content = content.Replace("{a" + i + "}", serie.name); content = content.Replace("{b" + i + "}", needCategory ? category : serieData.name); content = content.Replace("{c" + i + "}", ChartCached.FloatToStr(serieData.GetData(1), 0, m_ForceENotation)); content = content.Replace("{d" + i + "}", ChartCached.FloatToStr(percent, 1)); } } content = content.Replace("\\n", "\n"); content = content.Replace("<br/>", "\n"); return(content); } }
public static string GetFormatterContent(Tooltip tooltip, int dataIndex, Series series, ThemeInfo themeInfo, string category = null, DataZoom dataZoom = null, bool isCartesian = false) { if (string.IsNullOrEmpty(tooltip.formatter)) { var sb = ChartHelper.sb; var title = tooltip.titleFormatter; var formatTitle = !string.IsNullOrEmpty(title); var needCategory = false; var first = true; var isScatter = false; sb.Length = 0; for (int i = 0; i < series.Count; i++) { var serie = series.GetSerie(i); if (serie.type == SerieType.Scatter || serie.type == SerieType.EffectScatter) { if (serie.show && IsSelectedSerie(tooltip, serie.index)) { isScatter = true; var itemFormatter = GetItemFormatter(tooltip, serie, null); if (string.IsNullOrEmpty(itemFormatter)) { if (!first) { sb.Append(PH_NN); } InitDefaultContent(ref sb, tooltip, serie, dataIndex, category, themeInfo, dataZoom, isCartesian); first = false; continue; } var itemTitle = title; if (!string.IsNullOrEmpty(itemTitle)) { Replace(ref itemTitle, PH_A, i, serie.name, true); sb.Append(itemTitle).Append(PH_NN); } var dataIndexList = tooltip.runtimeSerieDataIndex[serie.index]; foreach (var tempIndex in dataIndexList) { var foundDot = false; var serieData = serie.GetSerieData(tempIndex); string content = itemFormatter; Replace(ref content, PH_A, i, serie.name, true); Replace(ref content, PH_B, i, needCategory ? category : serieData.name, true); if (itemFormatter.IndexOf(PH_I) >= 0) { foundDot = true; Replace(ref content, PH_I, i, ChartCached.ColorToDotStr(themeInfo.GetColor(serie.index)), true); } for (int n = 0; n < serieData.data.Count; n++) { var valueStr = ChartCached.FloatToStr(serieData.GetData(n), 0, tooltip.forceENotation); Replace(ref content, GetPHCC(n), i, valueStr, true); } if (!foundDot) { sb.Append(ChartCached.ColorToDotStr(themeInfo.GetColor(serie.index))); } sb.Append(content).Append(PH_NN); } } } else { var serieData = serie.GetSerieData(dataIndex, dataZoom); if (serieData == null) { continue; } var itemFormatter = GetItemFormatter(tooltip, serie, serieData); var percent = serieData.GetData(1) / serie.yTotal * 100; needCategory = needCategory || (serie.type == SerieType.Line || serie.type == SerieType.Bar); if (formatTitle) { var valueStr = ChartCached.FloatToStr(serieData.GetData(1), 0, tooltip.forceENotation); Replace(ref title, PH_A, i, serie.name, true); Replace(ref title, PH_B, i, needCategory ? category : serieData.name, true); Replace(ref title, PH_C, i, valueStr, true); Replace(ref title, PH_D, i, ChartCached.FloatToStr(percent, 1), true); } if (serie.show) { if (string.IsNullOrEmpty(itemFormatter)) { if (!first) { sb.Append(PH_NN); } InitDefaultContent(ref sb, tooltip, serie, dataIndex, category, themeInfo, dataZoom, isCartesian); first = false; continue; } string content = itemFormatter; var valueStr = ChartCached.FloatToStr(serieData.GetData(1), 0, tooltip.forceENotation); Replace(ref content, PH_A, i, serie.name, true); Replace(ref content, PH_B, i, needCategory ? category : serieData.name, true); Replace(ref content, PH_C, i, valueStr, true); Replace(ref content, PH_D, i, ChartCached.FloatToStr(percent, 1), true); for (int n = 0; n < serieData.data.Count; n++) { valueStr = ChartCached.FloatToStr(serieData.GetData(n), 0, tooltip.forceENotation); Replace(ref content, GetPHCC(n), i, valueStr, true); } if (!first) { sb.Append(PH_NN); } sb.Append(ChartCached.ColorToDotStr(themeInfo.GetColor(i))); sb.Append(content); first = false; } } } if (isScatter) { return(TrimAndReplaceLine(sb)); } else if (string.IsNullOrEmpty(title)) { if (needCategory) { return(category + PH_NN + TrimAndReplaceLine(sb)); } else { return(TrimAndReplaceLine(sb)); } } else { title = title.Replace(PH_ON, PH_NN); title = title.Replace(PH_BR, PH_NN); return(title + PH_NN + TrimAndReplaceLine(sb)); } } else { string content = tooltip.formatter; for (int i = 0; i < series.Count; i++) { var serie = series.GetSerie(i); if (serie.show) { var needCategory = serie.type == SerieType.Line || serie.type == SerieType.Bar; var serieData = serie.GetSerieData(dataIndex, dataZoom); var percent = serieData.GetData(1) / serie.yTotal * 100; Replace(ref content, PH_A, i, serie.name); Replace(ref content, PH_B, i, needCategory ? category : serieData.name); Replace(ref content, PH_C, i, ChartCached.FloatToStr(serieData.GetData(1), 0, tooltip.forceENotation)); Replace(ref content, PH_D, i, ChartCached.FloatToStr(percent, 1)); Replace(ref content, PH_I, i, ChartCached.ColorToDotStr(themeInfo.GetColor(i))); for (int n = 0; n < serieData.data.Count; n++) { var valueStr = ChartCached.FloatToStr(serieData.GetData(n), 0, tooltip.forceENotation); if (i == 0) { Replace(ref content, GetPHCC(n), i, valueStr, true); } Replace(ref content, GetPHCC(i, n), i, valueStr, true); } } } content = content.Replace(PH_ON, PH_NN); content = content.Replace(PH_BR, PH_NN); return(content); } }
protected void InitAxis(Axis relativedAxis, Orient orient, float axisStartX, float axisStartY, float axisLength, float relativedLength) { Axis axis = component; chart.InitAxisRuntimeData(axis); var objName = ChartCached.GetComponentObjectName(axis); var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); axisObj.SetActive(axis.show); axisObj.hideFlags = chart.chartHideFlags; ChartHelper.HideAllObject(axisObj); axis.gameObject = axisObj; axis.context.labelObjectList.Clear(); if (!axis.show) { return; } var axisLabelTextStyle = axis.axisLabel.textStyle; var dataZoom = chart.GetDataZoomOfAxis(axis); var splitNumber = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom); var totalWidth = 0f; var eachWidth = AxisHelper.GetEachWidth(axis, axisLength, dataZoom); var gapWidth = axis.boundaryGap ? eachWidth / 2 : 0; var textWidth = axis.axisLabel.width > 0 ? axis.axisLabel.width : (orient == Orient.Horizonal ? AxisHelper.GetScaleWidth(axis, axisLength, 0, dataZoom) : (axisStartX - chart.chartX) ); var textHeight = axis.axisLabel.height > 0 ? axis.axisLabel.height : 20f; var isPercentStack = SeriesHelper.IsPercentStack <Bar>(chart.series); var inside = axis.axisLabel.inside; var defaultAlignment = orient == Orient.Horizonal ? TextAnchor.MiddleCenter : ((inside && axis.IsLeft()) || (!inside && axis.IsRight()) ? TextAnchor.MiddleLeft : TextAnchor.MiddleRight); if (axis.IsCategory() && axis.boundaryGap) { splitNumber -= 1; } for (int i = 0; i < splitNumber; i++) { var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom); var labelName = AxisHelper.GetLabelName(axis, axisLength, i, axis.context.minValue, axis.context.maxValue, dataZoom, isPercentStack); var label = ChartHelper.AddAxisLabelObject(splitNumber, i, ChartCached.GetAxisLabelName(i), axisObj.transform, new Vector2(textWidth, textHeight), axis, chart.theme.axis, labelName, Color.clear, defaultAlignment); if (i == 0) { axis.axisLabel.SetRelatedText(label.text, labelWidth); } var pos = GetLabelPosition(totalWidth + gapWidth, i); label.SetPosition(pos); CheckValueLabelActive(axis, i, label, pos); axis.context.labelObjectList.Add(label); totalWidth += labelWidth; } if (axis.axisName.show) { ChartLabel label = null; var relativedDist = (relativedAxis == null ? 0 : relativedAxis.context.offset); var zeroPos = new Vector3(axisStartX, axisStartY + relativedDist); var offset = axis.axisName.labelStyle.offset; var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor); if (orient == Orient.Horizonal) { var grid = chart.GetChartComponent <GridCoord>(axis.gridIndex); var posY = !axis.axisName.onZero && grid != null? grid.context.y : GetAxisLineXOrY() + offset.y; switch (axis.axisName.labelStyle.position) { case LabelStyle.Position.Start: label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleRight); label.SetActive(axis.axisName.labelStyle.show); label.SetPosition(axis.position == Axis.AxisPosition.Top ? new Vector2(zeroPos.x - offset.x, axisStartY + relativedLength + offset.y + axis.offset) : new Vector2(zeroPos.x - offset.x, posY)); break; case LabelStyle.Position.Middle: label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter); label.SetActive(axis.axisName.labelStyle.show); label.SetPosition(axis.position == Axis.AxisPosition.Top ? new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY + relativedLength - offset.y + axis.offset) : new Vector2(axisStartX + axisLength / 2 + offset.x, posY)); break; default: label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleLeft); label.SetActive(axis.axisName.labelStyle.show); label.SetPosition(axis.position == Axis.AxisPosition.Top ? new Vector2(axisStartX + axisLength + offset.x, axisStartY + relativedLength + offset.y + axis.offset) : new Vector2(axisStartX + axisLength + offset.x, posY)); break; } } else { var grid = chart.GetChartComponent <GridCoord>(axis.gridIndex); var posX = !axis.axisName.onZero && grid != null? grid.context.x : GetAxisLineXOrY() + offset.x; switch (axis.axisName.labelStyle.position) { case LabelStyle.Position.Start: label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter); label.SetActive(axis.axisName.labelStyle.show); label.SetPosition(axis.position == Axis.AxisPosition.Right ? new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY - offset.y) : new Vector2(posX, axisStartY - offset.y)); break; case LabelStyle.Position.Middle: label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter); label.SetActive(axis.axisName.labelStyle.show); label.SetPosition(axis.position == Axis.AxisPosition.Right ? new Vector2(axisStartX + relativedLength - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y) : new Vector2(posX, axisStartY + axisLength / 2 + offset.y)); break; default: //LabelStyle.Position label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter); label.SetActive(axis.axisName.labelStyle.show); label.SetPosition(axis.position == Axis.AxisPosition.Right ? new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY + axisLength + offset.y) : new Vector2(posX, axisStartY + axisLength + offset.y)); break; } } } }
private void InitRadiusAxis(RadiusAxis axis) { var m_Polar = GetPolar(axis.index); if (m_Polars == null) { return; } var m_AngleAxis = GetAngleAxis(m_Polar.index); if (m_AngleAxis == null) { return; } PolarHelper.UpdatePolarCenter(m_Polar, m_ChartPosition, m_ChartWidth, m_ChartHeight); axis.axisLabelTextList.Clear(); var radius = m_Polar.runtimeRadius; var objName = "axis_radius" + axis.index; var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin, graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight)); axisObj.transform.localPosition = Vector3.zero; axisObj.SetActive(axis.show && axis.axisLabel.show); axisObj.hideFlags = chartHideFlags; ChartHelper.HideAllObject(axisObj); var textStyle = axis.axisLabel.textStyle; var splitNumber = AxisHelper.GetSplitNumber(axis, radius, null); var totalWidth = 0f; var startAngle = m_AngleAxis.runtimeStartAngle; var cenPos = m_Polar.runtimeCenterPos; var txtHig = textStyle.GetFontSize(m_Theme.axis) + 2; var dire = ChartHelper.GetDire(startAngle, true).normalized; var tickWidth = axis.axisTick.GetLength(m_Theme.radiusAxis.tickWidth); var tickVetor = ChartHelper.GetVertialDire(dire) * (tickWidth + axis.axisLabel.margin); for (int i = 0; i < splitNumber; i++) { float labelWidth = AxisHelper.GetScaleWidth(axis, radius, i, null); bool inside = axis.axisLabel.inside; var txt = ChartHelper.AddTextObject(objName + i, axisObj.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(labelWidth, txtHig), textStyle, m_Theme.axis); if (i == 0) { axis.axisLabel.SetRelatedText(txt, labelWidth); } var isPercentStack = SeriesHelper.IsPercentStack(m_Series, SerieType.Bar); var labelName = AxisHelper.GetLabelName(axis, radius, i, axis.runtimeMinValue, axis.runtimeMaxValue, null, isPercentStack); txt.SetAlignment(TextAnchor.MiddleCenter); txt.SetText(labelName); txt.SetActive(axis.show && (axis.axisLabel.interval == 0 || i % (axis.axisLabel.interval + 1) == 0)); var pos = ChartHelper.GetPos(cenPos, totalWidth, startAngle, true) + tickVetor; txt.SetLocalPosition(pos); AxisHelper.AdjustRadiusAxisLabelPos(txt, pos, cenPos, txtHig, Vector3.zero); axis.axisLabelTextList.Add(txt); totalWidth += labelWidth; } if (tooltip.runtimeGameObject) { Vector2 privot = new Vector2(0.5f, 1); var labelParent = tooltip.runtimeGameObject.transform; var labelName = ChartCached.GetAxisTooltipLabel(objName); GameObject labelObj = ChartHelper.AddTooltipLabel(labelName, labelParent, m_Theme, privot); axis.SetTooltipLabel(labelObj); axis.SetTooltipLabelColor(m_Theme.tooltip.labelBackgroundColor, m_Theme.tooltip.labelTextColor); axis.SetTooltipLabelActive(axis.show && tooltip.show && tooltip.type == Tooltip.Type.Corss); } }
public static string GetPolarFormatterContent(Tooltip tooltip, Series series, ThemeInfo themeInfo, AngleAxis angleAxis) { if (string.IsNullOrEmpty(tooltip.formatter)) { var sb = ChartHelper.sb; sb.Length = 0; var title = tooltip.titleFormatter; var formatTitle = !string.IsNullOrEmpty(title); if ("{i}".Equals(tooltip.titleFormatter)) { title = string.Empty; formatTitle = false; } else if (string.IsNullOrEmpty(title)) { var angle = angleAxis.clockwise ? tooltip.runtimeAngle : 360 - tooltip.runtimeAngle; title = ChartCached.FloatToStr(angle); } foreach (var serie in series.list) { if (serie.show && IsSelectedSerie(tooltip, serie.index)) { if (formatTitle) { FormatterHelper.ReplaceContent(ref title, 0, tooltip.numericFormatter, serie, series, themeInfo, null, null); } var dataIndexList = tooltip.runtimeSerieIndex[serie.index]; for (int i = 0; i < dataIndexList.Count; i++) { var dataIndex = dataIndexList[i]; var serieData = serie.GetSerieData(dataIndex); var itemFormatter = GetItemFormatter(tooltip, serie, serieData); var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData); float xValue, yValue; serie.GetXYData(dataIndex, null, out xValue, out yValue); if (string.IsNullOrEmpty(itemFormatter)) { sb.Append("<color=#").Append(themeInfo.GetColorStr(serie.index)).Append(">● </color>"); if (!string.IsNullOrEmpty(serie.name)) { sb.Append(serie.name).Append(": "); } sb.AppendFormat("{0}", ChartCached.FloatToStr(xValue, numericFormatter)); if (i != dataIndexList.Count - 1) { sb.Append(FormatterHelper.PH_NN); } } else { string content = itemFormatter; FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, serie, series, themeInfo, null, null); var dotColorIndex = serie.type == SerieType.Pie || serie.type == SerieType.Radar || serie.type == SerieType.Ring ? dataIndex : serie.index; sb.Append(ChartCached.ColorToDotStr(themeInfo.GetColor(dotColorIndex))); sb.Append(content); } } sb.Append(FormatterHelper.PH_NN); } } if (string.IsNullOrEmpty(title)) { return(FormatterHelper.TrimAndReplaceLine(sb)); } else { title = FormatterHelper.TrimAndReplaceLine(title); return(title + FormatterHelper.PH_NN + FormatterHelper.TrimAndReplaceLine(sb)); } } else { string content = tooltip.formatter; FormatterHelper.ReplaceContent(ref content, 0, tooltip.numericFormatter, null, series, themeInfo, null, null); return(content); } }
private void InitAngleAxis(AngleAxis axis) { var m_Polar = GetPolar(axis.polarIndex); if (m_Polars == null) { return; } PolarHelper.UpdatePolarCenter(m_Polar, m_ChartPosition, m_ChartWidth, m_ChartHeight); var radius = m_Polar.runtimeRadius; axis.axisLabelTextList.Clear(); string objName = "axis_angle" + axis.index; var axisObj = ChartHelper.AddObject(objName, transform, graphAnchorMin, graphAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight)); axisObj.transform.localPosition = Vector3.zero; axisObj.SetActive(axis.show && axis.axisLabel.show); axisObj.hideFlags = chartHideFlags; ChartHelper.HideAllObject(axisObj); var splitNumber = AxisHelper.GetSplitNumber(axis, radius, null); var totalAngle = axis.runtimeStartAngle; var total = 360; var cenPos = m_Polar.runtimeCenterPos; var txtHig = axis.axisLabel.textStyle.GetFontSize(m_Theme.axis) + 2; var margin = axis.axisLabel.margin; var isCategory = axis.IsCategory(); var isPercentStack = SeriesHelper.IsPercentStack(m_Series, SerieType.Bar); for (int i = 0; i < splitNumber; i++) { float scaleAngle = AxisHelper.GetScaleWidth(axis, total, i, null); bool inside = axis.axisLabel.inside; var txt = ChartHelper.AddTextObject(objName + i, axisObj.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(scaleAngle, txtHig), axis.axisLabel.textStyle, m_Theme.axis); txt.SetAlignment(TextAnchor.MiddleCenter); txt.SetText(AxisHelper.GetLabelName(axis, total, i, axis.runtimeMinValue, axis.runtimeMaxValue, null, isPercentStack)); txt.SetActive(axis.show && (axis.axisLabel.interval == 0 || i % (axis.axisLabel.interval + 1) == 0)); var pos = ChartHelper.GetPos(cenPos, radius + margin, isCategory ? (totalAngle + scaleAngle / 2) : totalAngle, true); AxisHelper.AdjustCircleLabelPos(txt, pos, cenPos, txtHig, Vector3.zero); if (i == 0) { axis.axisLabel.SetRelatedText(txt, scaleAngle); } axis.axisLabelTextList.Add(txt); totalAngle += scaleAngle; } if (tooltip.runtimeGameObject) { Vector2 privot = new Vector2(0.5f, 0.5f); var labelParent = tooltip.runtimeGameObject.transform; GameObject labelObj = ChartHelper.AddTooltipLabel(ChartCached.GetAxisTooltipLabel(objName), labelParent, m_Theme, privot, privot, privot, new Vector2(10, txtHig)); axis.SetTooltipLabel(labelObj); axis.SetTooltipLabelColor(m_Theme.tooltip.labelBackgroundColor, m_Theme.tooltip.labelTextColor); axis.SetTooltipLabelActive(axis.show && tooltip.show && tooltip.type == Tooltip.Type.Corss); } }
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; } }
public static string GetFormatterContent(Tooltip tooltip, int dataIndex, Series series, ThemeInfo themeInfo, string category = null, DataZoom dataZoom = null, bool isCartesian = false) { if (string.IsNullOrEmpty(tooltip.formatter)) { var sb = ChartHelper.sb; var title = tooltip.titleFormatter; var formatTitle = !string.IsNullOrEmpty(title); var needCategory = false; var first = true; var isScatter = false; sb.Length = 0; for (int i = 0; i < series.Count; i++) { var serie = series.GetSerie(i); if (serie.type == SerieType.Scatter || serie.type == SerieType.EffectScatter) { if (serie.show && IsSelectedSerie(tooltip, serie.index)) { isScatter = true; var itemFormatter = GetItemFormatter(tooltip, serie, null); var numericFormatter = GetItemNumericFormatter(tooltip, serie, null); if (string.IsNullOrEmpty(itemFormatter)) { if (!first) { sb.Append(PH_NN); } InitDefaultContent(ref sb, tooltip, serie, dataIndex, category, themeInfo, dataZoom, isCartesian); first = false; continue; } var itemTitle = title; if (!string.IsNullOrEmpty(itemTitle)) { ReplaceContent(ref itemTitle, dataIndex, tooltip, serie, null, themeInfo, category, dataZoom, isCartesian); sb.Append(itemTitle).Append(PH_NN); } var dataIndexList = tooltip.runtimeSerieDataIndex[serie.index]; foreach (var tempIndex in dataIndexList) { string content = itemFormatter; var foundDot = ReplaceContent(ref content, tempIndex, tooltip, serie, null, themeInfo, category, dataZoom, isCartesian); if (!foundDot) { sb.Append(ChartCached.ColorToDotStr(themeInfo.GetColor(serie.index))); } sb.Append(content).Append(PH_NN); } } } else { var serieData = serie.GetSerieData(dataIndex, dataZoom); if (serieData == null) { continue; } var itemFormatter = GetItemFormatter(tooltip, serie, serieData); needCategory = needCategory || (serie.type == SerieType.Line || serie.type == SerieType.Bar); if (formatTitle) { ReplaceContent(ref title, dataIndex, tooltip, null, series, themeInfo, category, dataZoom, isCartesian); } if (serie.show) { if (string.IsNullOrEmpty(itemFormatter)) { if (!first) { sb.Append(PH_NN); } InitDefaultContent(ref sb, tooltip, serie, dataIndex, category, themeInfo, dataZoom, isCartesian); first = false; continue; } string content = itemFormatter; ReplaceContent(ref content, dataIndex, tooltip, serie, null, themeInfo, category, dataZoom, isCartesian); if (!first) { sb.Append(PH_NN); } sb.Append(ChartCached.ColorToDotStr(themeInfo.GetColor(i))); sb.Append(content); first = false; } } } if (isScatter) { return(TrimAndReplaceLine(sb)); } else if (string.IsNullOrEmpty(title)) { if (needCategory) { return(category + PH_NN + TrimAndReplaceLine(sb)); } else { return(TrimAndReplaceLine(sb)); } } else { title = s_RegexNewLine.Replace(title, PH_NN); return(title + PH_NN + TrimAndReplaceLine(sb)); } } else { string content = tooltip.formatter; ReplaceContent(ref content, dataIndex, tooltip, null, series, themeInfo, category, dataZoom, isCartesian); return(content); } }