mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 14:00:12 +00:00
优化SerieLabel引起的性能问题
This commit is contained in:
@@ -23,6 +23,10 @@ namespace XCharts
|
||||
private static Dictionary<int, string> s_IntToStr = new Dictionary<int, string>(1000);
|
||||
private static Dictionary<int, string> s_IntToFn = new Dictionary<int, string>(20);
|
||||
private static Dictionary<Color, string> s_ColorToStr = new Dictionary<Color, string>(1000);
|
||||
private static Dictionary<int, string> s_SerieLabelName = new Dictionary<int, string>(1000);
|
||||
private static Dictionary<int, string> s_AxisLabelName = new Dictionary<int, string>(1000);
|
||||
|
||||
|
||||
|
||||
public static string FloatToStr(float value, int f = 0, bool forceE = false)
|
||||
{
|
||||
@@ -83,5 +87,35 @@ namespace XCharts
|
||||
return s_ColorToStr[color];
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetSerieLabelName(string prefix, int i, int j)
|
||||
{
|
||||
int key = i * 10000000 + j;
|
||||
if (s_SerieLabelName.ContainsKey(key))
|
||||
{
|
||||
return s_SerieLabelName[key];
|
||||
}
|
||||
else
|
||||
{
|
||||
string name = prefix + "_" + i + "_" + j;
|
||||
s_SerieLabelName[key] = name;
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetAxisLabelName(string prefix, bool isYAxis,int axisIndex, int i)
|
||||
{
|
||||
int key = (isYAxis?2:1) * 1000000 + (axisIndex+1) * 100000 + i;
|
||||
if (s_AxisLabelName.ContainsKey(key))
|
||||
{
|
||||
return s_AxisLabelName[key];
|
||||
}
|
||||
else
|
||||
{
|
||||
string name = prefix + "_" + axisIndex + "_" + i;
|
||||
s_AxisLabelName[key] = name;
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user