mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 15:00:08 +00:00
3.0
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
@@ -13,7 +12,7 @@ namespace XCharts.Runtime
|
||||
private const string NUMERIC_FORMATTER_X = "X";
|
||||
private const string NUMERIC_FORMATTER_x = "x";
|
||||
private static readonly string s_DefaultAxis = "axis_";
|
||||
private static CultureInfo ci = new CultureInfo("en-us");// "en-us", "zh-cn", "ar-iq", "de-de"
|
||||
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);
|
||||
@@ -21,7 +20,6 @@ namespace XCharts.Runtime
|
||||
private static Dictionary<int, string> s_AxisLabelName = new Dictionary<int, string>();
|
||||
private static Dictionary<Type, string> s_TypeName = new Dictionary<Type, string>();
|
||||
|
||||
|
||||
private static Dictionary<double, Dictionary<string, string>> s_NumberToStr = new Dictionary<double, Dictionary<string, string>>();
|
||||
private static Dictionary<int, Dictionary<string, string>> s_PrecisionToStr = new Dictionary<int, Dictionary<string, string>>();
|
||||
|
||||
@@ -55,18 +53,18 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (string.IsNullOrEmpty(formatter))
|
||||
{
|
||||
if (value - (int)value == 0)
|
||||
s_NumberToStr[value][formatter] = ((int)value).ToString();
|
||||
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)
|
||||
)
|
||||
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);
|
||||
s_NumberToStr[value][formatter] = ((int) value).ToString(formatter, ci);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -97,13 +95,13 @@ namespace XCharts.Runtime
|
||||
var arrowOffset = 0;
|
||||
var arrowDent = arrowWidth / 3.3f;
|
||||
UGL.DrawArrow(vh, startPos, pos, arrowWidth, arrowHeight,
|
||||
arrowOffset, arrowDent, color);
|
||||
arrowOffset, arrowDent, color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle, Vector3 startPos, Vector3 endPos,
|
||||
Color32 defaultColor, float themeWidth, LineStyle.Type themeType)
|
||||
Color32 defaultColor, float themeWidth, LineStyle.Type themeType)
|
||||
{
|
||||
var type = lineStyle.GetType(themeType);
|
||||
var width = lineStyle.GetWidth(themeWidth);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
@@ -365,8 +364,8 @@ namespace XCharts.Runtime
|
||||
label.UpdateIcon(labelStyle.icon);
|
||||
if (labelStyle.background.show)
|
||||
{
|
||||
label.color = (!labelStyle.background.autoColor || autoColor == Color.clear)
|
||||
? labelStyle.background.color : autoColor;
|
||||
label.color = (!labelStyle.background.autoColor || autoColor == Color.clear) ?
|
||||
labelStyle.background.color : autoColor;
|
||||
label.sprite = labelStyle.background.sprite;
|
||||
label.type = labelStyle.background.type;
|
||||
}
|
||||
@@ -442,7 +441,7 @@ namespace XCharts.Runtime
|
||||
ThemeStyle theme, TextAnchor alignment)
|
||||
{
|
||||
var label = ChartHelper.AddChartLabel(name, parent, tooltip.indicatorLabelStyle, theme.tooltip,
|
||||
"", Color.clear, alignment);
|
||||
"", Color.clear, alignment);
|
||||
label.SetActive(tooltip.show && tooltip.indicatorLabelStyle.show);
|
||||
return label;
|
||||
}
|
||||
@@ -451,7 +450,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
Vector3 dir = (ep - sp).normalized;
|
||||
float dist = Vector3.Distance(sp, ep);
|
||||
int segment = (int)(dist / k);
|
||||
int segment = (int) (dist / k);
|
||||
posList.Clear();
|
||||
posList.Add(sp);
|
||||
for (int i = 1; i < segment; i++)
|
||||
@@ -606,7 +605,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
Color color;
|
||||
ColorUtility.TryParseHtmlString(hexColorStr, out color);
|
||||
return (Color32)color;
|
||||
return (Color32) color;
|
||||
}
|
||||
|
||||
public static double GetMaxDivisibleValue(double max, int ceilRate)
|
||||
@@ -615,15 +614,15 @@ namespace XCharts.Runtime
|
||||
if (max > -1 && max < 1)
|
||||
{
|
||||
int count = 1;
|
||||
int intvalue = (int)(max * Mathf.Pow(10, count));
|
||||
int intvalue = (int) (max * Mathf.Pow(10, count));
|
||||
while (intvalue == 0 && count < 12)
|
||||
{
|
||||
count++;
|
||||
intvalue = (int)(max * Mathf.Pow(10, count));
|
||||
intvalue = (int) (max * Mathf.Pow(10, count));
|
||||
}
|
||||
var pow = Mathf.Pow(10, count);
|
||||
if (max > 0) return (int)((max * pow + 1)) / pow;
|
||||
else return (int)((max * pow - 1)) / pow;
|
||||
if (max > 0) return (int) ((max * pow + 1)) / pow;
|
||||
else return (int) ((max * pow - 1)) / pow;
|
||||
}
|
||||
if (ceilRate == 0)
|
||||
{
|
||||
@@ -646,7 +645,7 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
var mod = max % ceilRate;
|
||||
int rate = (int)(max / ceilRate);
|
||||
int rate = (int) (max / ceilRate);
|
||||
return mod == 0 ? max : (max < 0 ? rate : rate + 1) * ceilRate;
|
||||
}
|
||||
}
|
||||
@@ -657,15 +656,15 @@ namespace XCharts.Runtime
|
||||
if (min > -1 && min < 1)
|
||||
{
|
||||
int count = 1;
|
||||
int intvalue = (int)(min * Mathf.Pow(10, count));
|
||||
int intvalue = (int) (min * Mathf.Pow(10, count));
|
||||
while (intvalue == 0 && count < 12)
|
||||
{
|
||||
count++;
|
||||
intvalue = (int)(min * Mathf.Pow(10, count));
|
||||
intvalue = (int) (min * Mathf.Pow(10, count));
|
||||
}
|
||||
var pow = Mathf.Pow(10, count);
|
||||
if (min > 0) return (int)((min * pow + 1)) / pow;
|
||||
else return (int)((min * pow - 1)) / pow;
|
||||
if (min > 0) return (int) ((min * pow + 1)) / pow;
|
||||
else return (int) ((min * pow - 1)) / pow;
|
||||
}
|
||||
if (ceilRate == 0)
|
||||
{
|
||||
@@ -687,7 +686,7 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
var mod = min % ceilRate;
|
||||
int rate = (int)(min / ceilRate);
|
||||
int rate = (int) (min / ceilRate);
|
||||
return mod == 0 ? min : (min < 0 ? rate - 1 : rate) * ceilRate;
|
||||
}
|
||||
}
|
||||
@@ -701,31 +700,31 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (isLogBaseE)
|
||||
{
|
||||
max = Mathf.Exp(splitNumber);
|
||||
max = Math.Exp(splitNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
max = Mathf.Pow(logBase, splitNumber);
|
||||
max = Math.Pow(logBase, splitNumber);
|
||||
}
|
||||
splitNumber++;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public static float GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)
|
||||
public static double GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)
|
||||
{
|
||||
splitNumber = 0;
|
||||
if (value > 1) return 1;
|
||||
float min = 1;
|
||||
double min = 1;
|
||||
while (min > value)
|
||||
{
|
||||
if (isLogBaseE)
|
||||
{
|
||||
min = Mathf.Exp(-splitNumber);
|
||||
min = Math.Exp(-splitNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
min = Mathf.Pow(logBase, -splitNumber);
|
||||
min = Math.Pow(logBase, -splitNumber);
|
||||
}
|
||||
splitNumber++;
|
||||
}
|
||||
@@ -736,11 +735,11 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (value > 1 || value < -1) return 0;
|
||||
int count = 1;
|
||||
int intvalue = (int)(value * Mathf.Pow(10, count));
|
||||
int intvalue = (int) (value * Mathf.Pow(10, count));
|
||||
while (intvalue == 0 && count < 38)
|
||||
{
|
||||
count++;
|
||||
intvalue = (int)(value * Mathf.Pow(10, count));
|
||||
intvalue = (int) (value * Mathf.Pow(10, count));
|
||||
}
|
||||
if (count == 38 && (value == 0 || value == 1)) return 1;
|
||||
else return count;
|
||||
@@ -836,16 +835,16 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (color.a != 0 && opacity != 1)
|
||||
{
|
||||
color.a = (byte)(color.a * opacity);
|
||||
color.a = (byte) (color.a * opacity);
|
||||
}
|
||||
}
|
||||
|
||||
public static Color32 GetHighlightColor(Color32 color, float rate = 0.8f)
|
||||
{
|
||||
var newColor = color;
|
||||
newColor.r = (byte)(color.r * rate);
|
||||
newColor.g = (byte)(color.g * rate);
|
||||
newColor.b = (byte)(color.b * rate);
|
||||
newColor.r = (byte) (color.r * rate);
|
||||
newColor.g = (byte) (color.g * rate);
|
||||
newColor.b = (byte) (color.b * rate);
|
||||
return newColor;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -18,7 +16,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static RadiusAxis GetRadiusAxis(List<MainComponent> components, int polarIndex)
|
||||
{
|
||||
foreach (var component in components)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
@@ -213,14 +212,14 @@ namespace XCharts.Runtime
|
||||
public static bool IsFixedWidthHeight(RectTransform rt)
|
||||
{
|
||||
return IsLeftTop(rt.anchorMin, rt.anchorMax) ||
|
||||
IsLeftCenter(rt.anchorMin, rt.anchorMax) ||
|
||||
IsLeftBottom(rt.anchorMin, rt.anchorMax) ||
|
||||
IsCenterTop(rt.anchorMin, rt.anchorMax) ||
|
||||
IsCenterCenter(rt.anchorMin, rt.anchorMax) ||
|
||||
IsCenterBottom(rt.anchorMin, rt.anchorMax) ||
|
||||
IsRightTop(rt.anchorMin, rt.anchorMax) ||
|
||||
IsRightCenter(rt.anchorMin, rt.anchorMax) ||
|
||||
IsRightBottom(rt.anchorMin, rt.anchorMax);
|
||||
IsLeftCenter(rt.anchorMin, rt.anchorMax) ||
|
||||
IsLeftBottom(rt.anchorMin, rt.anchorMax) ||
|
||||
IsCenterTop(rt.anchorMin, rt.anchorMax) ||
|
||||
IsCenterCenter(rt.anchorMin, rt.anchorMax) ||
|
||||
IsCenterBottom(rt.anchorMin, rt.anchorMax) ||
|
||||
IsRightTop(rt.anchorMin, rt.anchorMax) ||
|
||||
IsRightCenter(rt.anchorMin, rt.anchorMax) ||
|
||||
IsRightBottom(rt.anchorMin, rt.anchorMax);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
Reference in New Issue
Block a user