private static void InitScatterTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index, ThemeInfo themeInfo) { if (!tooltip.runtimeSerieIndex.ContainsKey(serie.index)) { return; } var dataIndexList = tooltip.runtimeSerieIndex[serie.index]; if (!string.IsNullOrEmpty(serie.name)) { sb.Append(serie.name).Append(FormatterHelper.PH_NN); } for (int i = 0; i < dataIndexList.Count; i++) { var dataIndex = dataIndexList[i]; var serieData = serie.GetSerieData(dataIndex); var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData); float xValue, yValue; serie.GetXYData(dataIndex, null, out xValue, out yValue); sb.Append("<color=#").Append(themeInfo.GetColorStr(serie.index)).Append(">● </color>"); if (!string.IsNullOrEmpty(serieData.name)) { sb.Append(serieData.name).Append(": "); } sb.AppendFormat("({0},{1})", ChartCached.FloatToStr(xValue, numericFormatter), ChartCached.FloatToStr(yValue, numericFormatter)); if (i != dataIndexList.Count - 1) { sb.Append("\n"); } } }
private static void InitCoordinateTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index, ThemeInfo themeInfo, bool isCartesian, DataZoom dataZoom = null) { string key = serie.name; float xValue, yValue; serie.GetXYData(index, dataZoom, out xValue, out yValue); var isIngore = serie.IsIgnorePoint(index); var serieData = serie.GetSerieData(index, dataZoom); var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData); if (isCartesian) { if (serieData != null && serieData.highlighted) { sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : ""); sb.Append("[").Append(ChartCached.FloatToStr(xValue, numericFormatter)).Append(",") .Append(ChartCached.FloatToStr(yValue, numericFormatter)).Append("]"); } } else { var valueTxt = isIngore ? tooltip.ignoreDataDefaultContent : ChartCached.FloatToStr(yValue, numericFormatter); sb.Append("<color=#").Append(themeInfo.GetColorStr(serie.index)).Append(">● </color>") .Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "") .Append(valueTxt); } }
public static void CheckLabel(Serie serie, ref bool m_ReinitLabel, ref bool m_UpdateLabelText) { switch (serie.type) { case SerieType.Gauge: case SerieType.Ring: var serieData = serie.GetSerieData(0); if (serieData != null) { if (serie.label.show && serie.show) { if (serieData.labelObject != null) { serieData.SetLabelActive(true); m_UpdateLabelText = true; } else { m_ReinitLabel = true; } } else if (serieData.labelObject != null) { serieData.SetLabelActive(false); } } break; } }
public static void SetLiquidLabelText(Serie serie, ChartTheme theme, int colorIndex) { var serieData = serie.GetSerieData(0); if (serieData == null) { return; } var serieLabel = SerieHelper.GetSerieLabel(serie, serieData, serieData.highlighted); if (serieLabel.show && serieData.labelObject != null) { if (!serie.show || !serieData.show) { serieData.SetLabelActive(false); return; } var value = serieData.GetData(1); var total = serie.max - serie.min; var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total); serieData.SetLabelActive(true); serieData.labelObject.SetText(content); serieData.labelObject.SetLabelColor(GetLabelColor(serie, theme, colorIndex)); serieData.labelObject.SetLabelPosition(serieData.labelPosition + serieLabel.offset); } }
private void UpdateAxisLabel(Serie serie) { var show = serie.gaugeAxis.show && serie.gaugeAxis.axisLabel.show; serie.gaugeAxis.SetLabelObjectActive(show); if (!show) { return; } var count = serie.splitNumber > 36 ? 36 : serie.splitNumber; var startAngle = serie.startAngle; var totalAngle = serie.endAngle - serie.startAngle; var totalValue = serie.max - serie.min; var diffAngle = totalAngle / count; var diffValue = totalValue / count; var radius = serie.runtimeInsideRadius - serie.gaugeAxis.axisLabel.margin; var serieData = serie.GetSerieData(0); var customLabelText = serie.gaugeAxis.axisLabelText; for (int j = 0; j <= count; j++) { var angle = serie.startAngle + j * diffAngle; var value = serie.min + j * diffValue; var pos = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, radius); var text = customLabelText != null && j < customLabelText.Count ? customLabelText[j] : SerieLabelHelper.GetFormatterContent(serie, serieData, value, totalValue, serie.gaugeAxis.axisLabel, Color.clear); serie.gaugeAxis.SetLabelObjectText(j, text); serie.gaugeAxis.SetLabelObjectPosition(j, pos + serie.gaugeAxis.axisLabel.offset); } }
private void UpdateLabel(Serie serie) { var serieData = serie.GetSerieData(0); if (serieData != null) { if (serie.label.show) { if (serieData.IsInitLabel()) { serieData.SetLabelActive(true); serieData.SetLabelPosition(serie.runtimeCenterPos + serie.label.offset); m_UpdateLabelText = true; } else { m_ReinitLabel = true; } } else { serieData.SetLabelActive(false); } } }
private static void InitGaugeTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index, ChartTheme theme) { if (tooltip.runtimeGridIndex >= 0) { return; } if (serie.index != index || serie.type != SerieType.Gauge) { return; } var serieData = serie.GetSerieData(0); var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData); float value = serieData.data[1]; sb.Length = 0; if (!string.IsNullOrEmpty(serie.name)) { sb.Append(serie.name).Append("\n"); } if (!string.IsNullOrEmpty(serieData.name)) { //sb.Append("<color=#").Append(theme.GetColorStr(index)).Append(">● </color>") sb.Append(serieData.name).Append(": ").Append(ChartCached.FloatToStr(value, numericFormatter)); } else { sb.Append(ChartCached.FloatToStr(value, numericFormatter)); } }
public static void InitRadarTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, Radar radar, ThemeInfo themeInfo) { var dataIndex = tooltip.runtimeDataIndex[1]; var serieData = serie.GetSerieData(dataIndex); switch (serie.radarType) { case RadarType.Multiple: 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("\n"); } sb.AppendFormat("{0}: {1}", key, ChartCached.FloatToStr(value, 0, tooltip.forceENotation)); } break; case RadarType.Single: string key2 = serieData.name; float value2 = serieData.GetData(1); if (string.IsNullOrEmpty(key2)) { key2 = radar.indicatorList[dataIndex].name; } sb.AppendFormat("{0}: {1}", key2, ChartCached.FloatToStr(value2, 0, tooltip.forceENotation)); break; } }
private static void InitPieTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index, ThemeInfo themeInfo) { if (tooltip.runtimeDataIndex[serie.index] < 0) { return; } string key = serie.data[index].name; var serieData = serie.GetSerieData(index); var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData); float value = serieData.GetData(1); sb.Length = 0; if (!string.IsNullOrEmpty(serie.name)) { sb.Append(serie.name).Append(FormatterHelper.PH_NN); } sb.Append("<color=#").Append(themeInfo.GetColorStr(index)).Append(">● </color>"); if (!string.IsNullOrEmpty(key)) { sb.Append(key).Append(": "); } sb.Append(ChartCached.FloatToStr(value, numericFormatter)); }
private void CheckAnimation(Serie serie) { var serieData = serie.GetSerieData(0); if (serieData != null) { var value = serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration()); var data = serieData.GetData(1); if (value != data) { chart.RefreshPainter(serie); } } }
public static void InitCoordinateTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index, ChartTheme theme, bool isCartesian, DataZoom dataZoom = null) { string key = serie.name; double xValue, yValue; serie.GetXYData(index, dataZoom, out xValue, out yValue); var isIngore = serie.IsIgnorePoint(index); if (isIngore) { return; } var serieData = serie.GetSerieData(index, dataZoom); var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData); if (isCartesian) { if (serieData != null && serieData.highlighted) { sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : ""); sb.Append("[").Append(ChartCached.FloatToStr(xValue, numericFormatter)).Append(",") .Append(ChartCached.FloatToStr(yValue, numericFormatter)).Append("]"); } } else if (!isIngore || (isIngore && tooltip.ignoreDataShow)) { var valueTxt = isIngore ? tooltip.ignoreDataDefaultContent : ChartCached.FloatToStr(yValue, numericFormatter); sb.Append("<color=#").Append(theme.GetColorStr(serie.index)).Append(">● </color>"); if (serie.type == SerieType.Candlestick) { sb.Append(key).Append(FormatterHelper.PH_NN); var data = serieData.data; var open = ChartCached.FloatToStr(data[0], numericFormatter); var close = ChartCached.FloatToStr(data[1], numericFormatter); var lowest = ChartCached.FloatToStr(data[2], numericFormatter); var heighest = ChartCached.FloatToStr(data[3], numericFormatter); sb.Append(" open: ").Append(open).Append(FormatterHelper.PH_NN); sb.Append(" close: ").Append(close).Append(FormatterHelper.PH_NN); sb.Append(" lowest: ").Append(lowest).Append(FormatterHelper.PH_NN); sb.Append(" heighest: ").Append(heighest); } else { sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : ""); sb.Append(valueTxt); } } }
private bool NeedRefresh(Serie serie) { if (serie.type == SerieType.Gauge) { var serieData = serie.GetSerieData(0); if (serieData != null) { var destValue = serieData.GetData(1); var currValue = serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration()); return(destValue != currValue); } } return(false); }
private static void InitRingTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index, ThemeInfo themeInfo) { var serieData = serie.GetSerieData(index); float value = serieData.GetFirstData(); sb.Length = 0; if (!string.IsNullOrEmpty(serieData.name)) { sb.Append("<color=#").Append(themeInfo.GetColorStr(index)).Append(">● </color>") .Append(serieData.name).Append(": ").Append(ChartCached.FloatToStr(value, 0, tooltip.forceENotation)); } else { sb.Append(ChartCached.FloatToStr(value, 0, tooltip.forceENotation)); } }
private static void InitRingTooltip(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index, ChartTheme theme) { var serieData = serie.GetSerieData(index); var numericFormatter = GetItemNumericFormatter(tooltip, serie, serieData); float value = serieData.GetFirstData(); sb.Length = 0; if (!string.IsNullOrEmpty(serieData.name)) { sb.Append("<color=#").Append(theme.GetColorStr(index)).Append(">● </color>") .Append(serieData.name).Append(": ").Append(ChartCached.FloatToStr(value, numericFormatter)); } else { sb.Append(ChartCached.FloatToStr(value, numericFormatter)); } }
private static void SetGaugeLabelText(Serie serie) { var serieData = serie.GetSerieData(0); if (serieData != null) { if (serieData.IsInitLabel()) { var value = serieData.GetData(1); var total = serie.max; var content = serie.label.GetFormatterContent(serie.name, serieData.name, value, total); serieData.SetLabelText(content); serieData.SetLabelPosition(serie.runtimeCenterPos + serie.label.offset); if (serie.label.color != Color.clear) { serieData.SetLabelColor(serie.label.color); } } } }
public static void SetGaugeLabelText(Serie serie) { var serieData = serie.GetSerieData(0); if (serieData == null) { return; } if (serieData.labelObject == null) { return; } var value = serieData.GetData(1); var total = serie.max; var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total); serieData.labelObject.SetText(content); serieData.labelObject.SetLabelPosition(serie.runtimeCenterPos + serie.label.offset); if (!ChartHelper.IsClearColor(serie.label.textStyle.color)) { serieData.labelObject.label.SetColor(serie.label.textStyle.color); } }
private void DrawRectLiquid(VertexHelper vh, Serie serie, Vessel vessel) { var cenPos = vessel.runtimeCenterPos; var serieData = serie.GetSerieData(0); if (serieData == null) { return; } var dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); var value = serieData.GetCurrData(1, dataChangeDuration); if (serie.runtimeCheckValue != value) { serie.runtimeCheckValue = value; m_UpdateLabelText = true; } if (serieData.labelPosition != cenPos) { serieData.labelPosition = cenPos; m_UpdateLabelText = true; } if (value <= 0) { return; } var colorIndex = chart.m_LegendRealShowName.IndexOf(serie.name); var realHig = (value - serie.min) / (serie.max - serie.min) * vessel.runtimeHeight; serie.animation.InitProgress(1, 0, (float)realHig); var hig = serie.animation.IsFinish() ? realHig : serie.animation.GetCurrDetail(); var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false); var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, false); var isNeedGradient = !ChartHelper.IsValueEqualsColor(color, toColor); var isFull = hig >= vessel.runtimeHeight; if (hig >= vessel.runtimeHeight) { hig = vessel.runtimeHeight; } if (isFull && !isNeedGradient) { UGL.DrawRectangle(vh, cenPos, vessel.runtimeWidth / 2, vessel.runtimeHeight / 2, toColor); } else { var startY = (float)(cenPos.y - vessel.runtimeHeight / 2 + hig); var waveStartPos = new Vector3(cenPos.x - vessel.runtimeWidth / 2, startY); var waveEndPos = new Vector3(cenPos.x + vessel.runtimeWidth / 2, startY); var startX = waveStartPos.x; var endX = waveEndPos.x; var step = vessel.smoothness; if (step < 0.5f) { step = 0.5f; } var lup = waveStartPos; var ldp = new Vector3(startX, vessel.runtimeCenterPos.y - vessel.runtimeHeight / 2); var nup = Vector3.zero; var ndp = Vector3.zero; var angle = 0f; var isStarted = false; var isEnded = false; var waveHeight = isFull ? 0 : serie.waveHeight; serie.runtimeWaveSpeed += serie.waveSpeed * Time.deltaTime; while (startX < endX) { startX += step; if (startX > endX) { startX = endX; } if (startX > waveStartPos.x && !isStarted) { startX = waveStartPos.x; isStarted = true; } if (startX > waveEndPos.x && !isEnded) { startX = waveEndPos.x; isEnded = true; } var py = Mathf.Sqrt(Mathf.Pow(vessel.runtimeHeight, 2) - Mathf.Pow(Mathf.Abs(cenPos.x - startX), 2)); if (startX < waveStartPos.x || startX > waveEndPos.x) { nup = new Vector3(startX, cenPos.y + py); } else { var py2 = waveHeight * Mathf.Sin(1 / serie.waveLength * angle + serie.runtimeWaveSpeed + serie.waveOffset); var nupY = waveStartPos.y + py2; nup = new Vector3(startX, nupY); angle += step; } ndp = new Vector3(startX, cenPos.y - vessel.runtimeHeight / 2); if (nup.y > cenPos.y + vessel.runtimeHeight / 2) { nup.y = cenPos.y + vessel.runtimeHeight / 2; } if (nup.y < cenPos.y - vessel.runtimeHeight / 2) { nup.y = cenPos.y - vessel.runtimeHeight / 2; } if (!ChartHelper.IsValueEqualsColor(color, toColor)) { var colorMin = cenPos.y - vessel.runtimeHeight; var colorMax = startY + serie.waveHeight; var tcolor1 = Color32.Lerp(color, toColor, 1 - (lup.y - colorMin) / (colorMax - colorMin)); var tcolor2 = Color32.Lerp(color, toColor, 1 - (ldp.y - colorMin) / (colorMax - colorMin)); UGL.DrawQuadrilateral(vh, lup, nup, ndp, ldp, tcolor1, tcolor2); } else { UGL.DrawQuadrilateral(vh, lup, nup, ndp, ldp, color); } lup = nup; ldp = ndp; } } if (serie.waveSpeed != 0 && Application.isPlaying && !isFull) { chart.RefreshPainter(serie); } if (!serie.animation.IsFinish()) { serie.animation.CheckProgress(realHig); chart.m_IsPlayingAnimation = true; chart.RefreshPainter(serie); } }
private void DrawSerie(VertexHelper vh, Serie serie) { var vessel = GetVessel(serie.vesselIndex); if (vessel == null) { return; } var cenPos = vessel.runtimeCenterPos; var radius = vessel.runtimeInnerRadius; var serieData = serie.GetSerieData(0); if (serieData == null) { return; } var value = serieData.GetData(1); if (serie.runtimeCheckValue != value) { serie.runtimeCheckValue = value; m_UpdateLabelText = true; } if (serieData.labelPosition != cenPos) { serieData.labelPosition = cenPos; m_UpdateLabelText = true; } if (value == 0) { return; } var colorIndex = m_LegendRealShowName.IndexOf(serie.name); var realHig = (value - serie.min) / (serie.max - serie.min) * radius * 2; serie.animation.InitProgress(1, 0, realHig); var hig = serie.animation.IsFinish() ? realHig : serie.animation.GetCurrDetail(); var a = Mathf.Abs(radius - hig + (hig > radius ? serie.waveHeight : -serie.waveHeight)); var diff = Mathf.Sqrt(radius * radius - Mathf.Pow(a, 2)); var color = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, colorIndex, false); var toColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, false); if (hig >= 2 * radius) { ChartDrawer.DrawCricle(vh, cenPos, radius, toColor, m_Settings.cicleSmoothness); } else { var startY = cenPos.y - radius + hig; var waveStartPos = new Vector3(cenPos.x - diff, startY); var waveEndPos = new Vector3(cenPos.x + diff, startY); var startX = hig > radius ? cenPos.x - radius : waveStartPos.x; var endX = hig > radius ? cenPos.x + radius : waveEndPos.x; var step = vessel.smoothness; if (step < 0.5f) { step = 0.5f; } var lup = hig > radius ? new Vector3(cenPos.x - radius, cenPos.y) : waveStartPos; var ldp = lup; var nup = Vector3.zero; var ndp = Vector3.zero; var angle = 0f; serie.runtimeWaveSpeed += serie.waveSpeed * Time.deltaTime; var isStarted = false; var isEnded = false; while (startX < endX) { startX += step; if (startX > endX) { startX = endX; } if (startX > waveStartPos.x && !isStarted) { startX = waveStartPos.x; isStarted = true; } if (startX > waveEndPos.x && !isEnded) { startX = waveEndPos.x; isEnded = true; } var py = Mathf.Sqrt(Mathf.Pow(radius, 2) - Mathf.Pow(Mathf.Abs(cenPos.x - startX), 2)); if (startX < waveStartPos.x || startX > waveEndPos.x) { nup = new Vector3(startX, cenPos.y + py); } else { var py2 = serie.waveHeight * Mathf.Sin(1 / serie.waveLength * angle + serie.runtimeWaveSpeed + serie.waveOffset); var nupY = waveStartPos.y + py2; if (nupY > cenPos.y + py) { nupY = cenPos.y + py; } else if (nupY < cenPos.y - py) { nupY = cenPos.y - py; } nup = new Vector3(startX, nupY); angle += step; } ndp = new Vector3(startX, cenPos.y - py); if (!ChartHelper.IsValueEqualsColor(color, toColor)) { var colorMin = cenPos.y - radius; var colorMax = startY + serie.waveHeight; var tcolor1 = Color.Lerp(color, toColor, 1 - (lup.y - colorMin) / (colorMax - colorMin)); var tcolor2 = Color.Lerp(color, toColor, 1 - (ldp.y - colorMin) / (colorMax - colorMin)); ChartDrawer.DrawPolygon(vh, lup, nup, ndp, ldp, tcolor1, tcolor2); } else { ChartDrawer.DrawPolygon(vh, lup, nup, ndp, ldp, color); } lup = nup; ldp = ndp; } } if (serie.waveSpeed != 0 && Application.isPlaying) { RefreshChart(); } if (!serie.animation.IsFinish()) { serie.animation.CheckProgress(realHig); m_IsPlayingAnimation = true; RefreshChart(); } }
/// <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); }
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; } }