海拔图和小地图
This commit is contained in:
1 parent
45801dff22
commit
c5bd9daba2
521 files changed
+1985033
-439
No files matched your search
@@ -0,0 +1,172 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public static class ChartCached
|
||||
{
|
||||
private const string NUMERIC_FORMATTER_D = "D";
|
||||
private const string NUMERIC_FORMATTER_d = "d";
|
||||
private const string NUMERIC_FORMATTER_X = "X";
|
||||
private const string NUMERIC_FORMATTER_x = "x";
|
||||
private static readonly string s_DefaultAxisY = "axis_y";
|
||||
private static readonly string s_DefaultAxisX = "axis_x";
|
||||
private static CultureInfo ci = new CultureInfo("en-us");// "en-us", "zh-cn", "ar-iq", "de-de"
|
||||
private static Dictionary<Color, string> s_ColorToStr = new Dictionary<Color, string>(100);
|
||||
private static Dictionary<int, string> s_SerieLabelName = new Dictionary<int, string>(1000);
|
||||
private static Dictionary<Color, string> s_ColorDotStr = new Dictionary<Color, string>(100);
|
||||
private static Dictionary<int, string> s_XAxisName = new Dictionary<int, string>();
|
||||
private static Dictionary<int, string> s_YAxisName = new Dictionary<int, string>();
|
||||
private static Dictionary<string, string> s_AxisLabel = new Dictionary<string, string>();
|
||||
|
||||
|
||||
private static Dictionary<float, Dictionary<string, string>> s_NumberToStr = new Dictionary<float, Dictionary<string, string>>();
|
||||
private static Dictionary<int, Dictionary<string, string>> s_PrecisionToStr = new Dictionary<int, Dictionary<string, string>>();
|
||||
|
||||
public static string FloatToStr(float value, string numericFormatter = "F", int precision = 0)
|
||||
{
|
||||
if (precision > 0 && numericFormatter.Length == 1)
|
||||
{
|
||||
if (!s_PrecisionToStr.ContainsKey(precision))
|
||||
{
|
||||
s_PrecisionToStr[precision] = new Dictionary<string, string>();
|
||||
}
|
||||
if (!s_PrecisionToStr[precision].ContainsKey(numericFormatter))
|
||||
{
|
||||
s_PrecisionToStr[precision][numericFormatter] = numericFormatter + precision;
|
||||
}
|
||||
return NumberToStr(value, s_PrecisionToStr[precision][numericFormatter]);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NumberToStr(value, numericFormatter);
|
||||
}
|
||||
}
|
||||
|
||||
public static string NumberToStr(float value, string formatter)
|
||||
{
|
||||
if (!s_NumberToStr.ContainsKey(value))
|
||||
{
|
||||
s_NumberToStr[value] = new Dictionary<string, string>();
|
||||
}
|
||||
if (!s_NumberToStr[value].ContainsKey(formatter))
|
||||
{
|
||||
if (string.IsNullOrEmpty(formatter))
|
||||
{
|
||||
if (value - (int)value == 0)
|
||||
s_NumberToStr[value][formatter] = ((int)value).ToString();
|
||||
else
|
||||
s_NumberToStr[value][formatter] = value.ToString();
|
||||
}
|
||||
else if (formatter.StartsWith(NUMERIC_FORMATTER_D)
|
||||
|| formatter.StartsWith(NUMERIC_FORMATTER_d)
|
||||
|| formatter.StartsWith(NUMERIC_FORMATTER_X)
|
||||
|| formatter.StartsWith(NUMERIC_FORMATTER_x)
|
||||
)
|
||||
{
|
||||
s_NumberToStr[value][formatter] = ((int)value).ToString(formatter, ci);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_NumberToStr[value][formatter] = value.ToString(formatter, ci);
|
||||
}
|
||||
}
|
||||
return s_NumberToStr[value][formatter];
|
||||
}
|
||||
|
||||
public static string IntToStr(int value, string numericFormatter = "")
|
||||
{
|
||||
return NumberToStr(value, numericFormatter);
|
||||
}
|
||||
|
||||
public static string ColorToStr(Color color)
|
||||
{
|
||||
if (s_ColorToStr.ContainsKey(color))
|
||||
{
|
||||
return s_ColorToStr[color];
|
||||
}
|
||||
else
|
||||
{
|
||||
s_ColorToStr[color] = ColorUtility.ToHtmlStringRGBA(color);
|
||||
return s_ColorToStr[color];
|
||||
}
|
||||
}
|
||||
|
||||
public static string ColorToDotStr(Color color)
|
||||
{
|
||||
if (!s_ColorDotStr.ContainsKey(color))
|
||||
{
|
||||
s_ColorDotStr[color] = "<color=#" + ColorToStr(color) + ">● </color>";
|
||||
}
|
||||
return s_ColorDotStr[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 GetXAxisName(int axisIndex, int index = -1)
|
||||
{
|
||||
if (index >= 0)
|
||||
{
|
||||
int key = (axisIndex + 1) * 10000 + index;
|
||||
if (!s_XAxisName.ContainsKey(key))
|
||||
{
|
||||
s_XAxisName[key] = axisIndex > 0 ? s_DefaultAxisX + axisIndex + index : s_DefaultAxisX + index;
|
||||
}
|
||||
return s_XAxisName[key];
|
||||
}
|
||||
else if (!s_XAxisName.ContainsKey(axisIndex))
|
||||
{
|
||||
s_XAxisName[axisIndex] = axisIndex > 0 ? s_DefaultAxisX + axisIndex : s_DefaultAxisX;
|
||||
}
|
||||
return s_XAxisName[axisIndex];
|
||||
}
|
||||
|
||||
internal static string GetYAxisName(int axisIndex, int index = -1)
|
||||
{
|
||||
if (index >= 0)
|
||||
{
|
||||
int key = (axisIndex + 1) * 10000 + index;
|
||||
if (!s_YAxisName.ContainsKey(key))
|
||||
{
|
||||
s_YAxisName[key] = axisIndex > 0 ? s_DefaultAxisY + axisIndex + index : s_DefaultAxisY + index;
|
||||
}
|
||||
return s_YAxisName[key];
|
||||
}
|
||||
else if (!s_YAxisName.ContainsKey(axisIndex))
|
||||
{
|
||||
s_YAxisName[axisIndex] = axisIndex > 0 ? s_DefaultAxisY + axisIndex : s_DefaultAxisY;
|
||||
}
|
||||
return s_YAxisName[axisIndex];
|
||||
}
|
||||
|
||||
internal static string GetAxisTooltipLabel(string axisName)
|
||||
{
|
||||
if (!s_AxisLabel.ContainsKey(axisName))
|
||||
{
|
||||
s_AxisLabel[axisName] = axisName + "_label";
|
||||
}
|
||||
return s_AxisLabel[axisName];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 403191b8caeb44430b89d9f3260c4a76
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public static class ChartConst
|
||||
{
|
||||
public static readonly Color32 clearColor32 = new Color32(0, 0, 0, 0);
|
||||
public static readonly Color32 greyColor32 = new Color32(128, 128, 128, 255);
|
||||
public static readonly Color clearColor = Color.clear;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e19d8fc0680be46b5ac9babf7dd9fe27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,122 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public static class ChartDrawer
|
||||
{
|
||||
public static void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
|
||||
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
|
||||
Color32 backgroundColor, float smoothness)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SerieSymbolType.None:
|
||||
break;
|
||||
case SerieSymbolType.Circle:
|
||||
if (gap > 0)
|
||||
{
|
||||
UGL.DrawDoughnut(vh, pos, symbolSize, symbolSize + gap, backgroundColor, backgroundColor, color, smoothness);
|
||||
}
|
||||
else
|
||||
{
|
||||
UGL.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness);
|
||||
}
|
||||
break;
|
||||
case SerieSymbolType.EmptyCircle:
|
||||
if (gap > 0)
|
||||
{
|
||||
UGL.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness);
|
||||
UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, backgroundColor, smoothness);
|
||||
}
|
||||
else
|
||||
{
|
||||
UGL.DrawEmptyCricle(vh, pos, symbolSize, tickness, color, color, backgroundColor, smoothness);
|
||||
}
|
||||
break;
|
||||
case SerieSymbolType.Rect:
|
||||
if (gap > 0)
|
||||
{
|
||||
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
|
||||
UGL.DrawSquare(vh, pos, symbolSize, color, toColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
UGL.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
|
||||
}
|
||||
break;
|
||||
case SerieSymbolType.Triangle:
|
||||
if (gap > 0)
|
||||
{
|
||||
UGL.DrawTriangle(vh, pos, symbolSize + gap, backgroundColor);
|
||||
UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
UGL.DrawTriangle(vh, pos, symbolSize, color, toColor);
|
||||
}
|
||||
break;
|
||||
case SerieSymbolType.Diamond:
|
||||
if (gap > 0)
|
||||
{
|
||||
UGL.DrawDiamond(vh, pos, symbolSize + gap, backgroundColor);
|
||||
UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
UGL.DrawDiamond(vh, pos, symbolSize, color, toColor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle,
|
||||
// Vector3 startPos, Vector3 endPos, Color32 color, float themeWidth)
|
||||
// {
|
||||
// var type = lineStyle.type;
|
||||
// var width = lineStyle.GetWidth(themeWidth);
|
||||
// DrawLineStyle(vh, type, width, startPos, endPos, color);
|
||||
// }
|
||||
|
||||
public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle,
|
||||
Vector3 startPos, Vector3 endPos, Color32 color, float themeWidth, LineStyle.Type themeType)
|
||||
{
|
||||
var type = lineStyle.GetType(themeType);
|
||||
var width = lineStyle.GetWidth(themeWidth);
|
||||
DrawLineStyle(vh, type, width, startPos, endPos, color);
|
||||
}
|
||||
|
||||
public static void DrawLineStyle(VertexHelper vh, LineStyle.Type lineType, float lineWidth,
|
||||
Vector3 startPos, Vector3 endPos, Color32 color)
|
||||
{
|
||||
switch (lineType)
|
||||
{
|
||||
case LineStyle.Type.Dashed:
|
||||
UGL.DrawDashLine(vh, startPos, endPos, lineWidth, color);
|
||||
break;
|
||||
case LineStyle.Type.Dotted:
|
||||
UGL.DrawDotLine(vh, startPos, endPos, lineWidth, color);
|
||||
break;
|
||||
case LineStyle.Type.Solid:
|
||||
UGL.DrawLine(vh, startPos, endPos, lineWidth, color);
|
||||
break;
|
||||
case LineStyle.Type.DashDot:
|
||||
UGL.DrawDashDotLine(vh, startPos, endPos, lineWidth, color);
|
||||
break;
|
||||
case LineStyle.Type.DashDotDot:
|
||||
UGL.DrawDashDotDotLine(vh, startPos, endPos, lineWidth, color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 712f08d71f1bf4ab6a1785526bcd5c30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47cfa7bd879be4069bd187e46346d73d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user