public override void OnSerieDataUpdate(int serieIndex) { if (FormatterHelper.NeedFormat(component.formatter)) { component.refreshComponent(); } }
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue) { var timestamp = (int)value; var dateTime = DateTimeUtil.GetDateTime(timestamp); var dateString = string.Empty; if (string.IsNullOrEmpty(numericFormatter)) { dateString = DateTimeUtil.GetDateTimeFormatString(dateTime, maxValue - minValue); } else { dateString = dateTime.ToString(numericFormatter); } if (!string.IsNullOrEmpty(m_Formatter)) { var content = m_Formatter; FormatterHelper.ReplaceAxisLabelContent(ref content, dateString); return(GetFormatterFunctionContent(labelIndex, value, m_TextLimit.GetLimitContent(content))); } else { return(GetFormatterFunctionContent(labelIndex, value, m_TextLimit.GetLimitContent(dateString))); } }
public string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false) { if (showAsPositiveNumber && value < 0) { value = Math.Abs(value); } if (string.IsNullOrEmpty(m_Formatter)) { if (isLog) { return(GetFormatterFunctionContent(labelIndex, value, 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(GetFormatterFunctionContent(labelIndex, value, ChartCached.FloatToStr(value, numericFormatter, acc))); } return(GetFormatterFunctionContent(labelIndex, value, ChartCached.NumberToStr(value, numericFormatter))); } else { var content = m_Formatter; FormatterHelper.ReplaceAxisLabelContent(ref content, numericFormatter, value); return(GetFormatterFunctionContent(labelIndex, value, content)); } }
public override void OnSerieDataUpdate(int serieIndex) { if (m_LabelObject != null && FormatterHelper.NeedFormat(component.text)) { m_LabelObject.SetText(GetTitleText(component)); } if (m_SubLabelObject != null && FormatterHelper.NeedFormat(component.subText)) { m_SubLabelObject.SetText(GetSubTitleText(component)); } }
private string GetSubTitleText(Title title) { if (FormatterHelper.NeedFormat(title.subText)) { var content = title.subText; FormatterHelper.ReplaceContent(ref content, 0, title.subLabelStyle.numericFormatter, null, chart); return(content); } else { return(title.subText); } }
private string GetContent(CommentItem item) { if (item.content.IndexOf("{") >= 0) { var content = item.content; FormatterHelper.ReplaceContent(ref content, 0, item.labelStyle.numericFormatter, null, chart); return(content); } else { return(item.content); } }
private string GetFormatterContent(Legend legend, int dataIndex, string category) { if (string.IsNullOrEmpty(legend.formatter)) { return(category); } else { var content = legend.formatter.Replace("{name}", category); content = content.Replace("{value}", category); var serie = chart.GetSerie(0); FormatterHelper.ReplaceContent(ref content, dataIndex, legend.numericFormatter, serie, chart); return(content); } }
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); } } } }
public string GetFormatterContent(int labelIndex, string category) { if (string.IsNullOrEmpty(category)) { return(GetFormatterFunctionContent(labelIndex, category, category)); } if (string.IsNullOrEmpty(m_Formatter)) { return(GetFormatterFunctionContent(labelIndex, category, m_TextLimit.GetLimitContent(category))); } else { var content = m_Formatter; FormatterHelper.ReplaceAxisLabelContent(ref content, category); return(GetFormatterFunctionContent(labelIndex, category, m_TextLimit.GetLimitContent(content))); } }
public string GetFormatterIndicatorContent(string indicatorName) { if (string.IsNullOrEmpty(indicatorName)) { return(indicatorName); } if (string.IsNullOrEmpty(m_AxisName.labelStyle.formatter)) { return(indicatorName); } else { var content = m_AxisName.labelStyle.formatter; FormatterHelper.ReplaceAxisLabelContent(ref content, indicatorName); return(content); } }
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)); } }
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)); } } }