增加Formatter配置Axis的AxisLabel的格式化输出

This commit is contained in:
monitor1394
2019-09-23 19:09:56 +08:00
parent d23aaa359e
commit 32b7dd7516
5 changed files with 63 additions and 17 deletions

View File

@@ -440,15 +440,7 @@ namespace XCharts
{
value = (minValue + (maxValue - minValue) * index / (split - 1));
}
if (_cacheValue2str.ContainsKey(value)) return _cacheValue2str[value];
else
{
if (value - (int)value == 0)
_cacheValue2str[value] = (value).ToString();
else
_cacheValue2str[value] = (value).ToString("f1");
return _cacheValue2str[value];
}
return m_AxisLabel.GetFormatterContent(value);
}
var showData = GetDataList(dataZoom);
int dataCount = showData.Count;
@@ -456,7 +448,7 @@ namespace XCharts
if (index == split - 1 && !m_BoundaryGap)
{
return showData[dataCount - 1];
return m_AxisLabel.GetFormatterContent(showData[dataCount - 1]);
}
else
{
@@ -465,7 +457,7 @@ namespace XCharts
int offset = m_BoundaryGap ? (int)(rate / 2) : 0;
int newIndex = (int)(index * rate >= dataCount - 1 ?
dataCount - 1 : offset + index * rate);
return showData[newIndex];
return m_AxisLabel.GetFormatterContent(showData[newIndex]);
}
}

View File

@@ -90,7 +90,7 @@ namespace XCharts
/// <summary>
/// 图例内容字符串模版格式器。支持用 \n 换行。
/// 模板变量为图例名称 {name}
/// </example>
/// </summary>
public string formatter { get { return m_Formatter; } set { m_Formatter = value; } }
/// <summary>
/// Data array of legend. An array item is usually a name representing string. (If it is a pie chart,