3.0 - guage chart

This commit is contained in:
monitor1394
2022-02-19 17:35:22 +08:00
parent a19b796a02
commit ce5aeb2d98
41 changed files with 266 additions and 337 deletions

View File

@@ -25,7 +25,6 @@ namespace XCharts.Editor
#endif
PropertyField(prop, "m_FontSize");
PropertyField(prop, "m_TextColor");
//PropertyField(prop, "m_TextBackgroundColor");
DrawExtendeds(prop);
--EditorGUI.indentLevel;
}
@@ -75,27 +74,6 @@ namespace XCharts.Editor
}
}
}
[CustomPropertyDrawer(typeof(GaugeAxisTheme), true)]
public class GaugeAxisThemeDrawer : AxisThemeDrawer
{
public override string ClassName { get { return "Gauge Axis"; } }
public override List<string> IngorePropertys
{
get
{
return new List<string> {
"m_TextBackgroundColor" ,
"m_LineLength",
};
}
}
protected override void DrawExtendeds(SerializedProperty prop)
{
base.DrawExtendeds(prop);
PropertyField(prop, "m_BarBackgroundColor");
PropertyField(prop, "m_StageColor");
}
}
[CustomPropertyDrawer(typeof(DataZoomTheme), true)]
public class DataZoomThemeDrawer : ComponentThemeDrawer
@@ -133,8 +111,6 @@ namespace XCharts.Editor
protected override void DrawExtendeds(SerializedProperty prop)
{
base.DrawExtendeds(prop);
PropertyField(prop, "m_BorderWidth");
PropertyField(prop, "m_BorderColor");
PropertyField(prop, "m_LineType");
PropertyField(prop, "m_LineWidth");
PropertyField(prop, "m_LineColor");

View File

@@ -17,16 +17,14 @@ namespace XCharts.Editor
PropertyField(prop, "m_Position");
PropertyField(prop, "m_Offset");
PropertyField(prop, "m_AutoOffset");
PropertyField(prop, "m_Margin");
PropertyField(prop, "m_AutoColor");
PropertyField(prop, "m_Distance");
PropertyField(prop, "m_Formatter");
PropertyField(prop, "m_NumericFormatter");
PropertyField(prop, "m_BackgroundWidth");
PropertyField(prop, "m_BackgroundHeight");
PropertyField(prop, "m_PaddingLeftRight");
PropertyField(prop, "m_PaddingTopBottom");
PropertyField(prop, "m_Border");
PropertyField(prop, "m_BorderWidth");
PropertyField(prop, "m_BorderColor");
PropertyField(prop, "m_TextStyle");
--EditorGUI.indentLevel;
}

View File

@@ -42,6 +42,8 @@ namespace XCharts.Editor
{
base.DrawExtendeds(prop);
PropertyField(prop, "m_Interval");
PropertyField(prop, "m_Distance");
PropertyField(prop, "m_AutoColor");
}
}
[CustomPropertyDrawer(typeof(AxisTick), true)]
@@ -55,6 +57,9 @@ namespace XCharts.Editor
PropertyField(prop, "m_Inside");
PropertyField(prop, "m_ShowStartTick");
PropertyField(prop, "m_ShowEndTick");
PropertyField(prop, "m_SplitNumber");
PropertyField(prop, "m_Distance");
PropertyField(prop, "m_AutoColor");
}
}
}

View File

@@ -26,6 +26,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_Offset");
PropertyField(prop, "m_ExtraWidth");
PropertyField(prop, "m_Color");
PropertyField(prop, "m_AutoBackgroundColor");
PropertyField(prop, "m_BackgroundColor");
PropertyField(prop, "m_FontSize");
PropertyField(prop, "m_LineSpacing");

View File

@@ -13,6 +13,7 @@ namespace XCharts.Editor
if (MakeComponentFoldout(prop, "m_Show"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_OffsetCenter");
PropertyField(prop, "m_TextStyle");
--EditorGUI.indentLevel;
}

View File

@@ -152,7 +152,7 @@ namespace XCharts.Editor
++EditorGUI.indentLevel;
PropertyField(prop, "m_Inside");
PropertyField(prop, "m_Interval");
PropertyField(prop, "m_Margin");
PropertyField(prop, "m_Distance");
PropertyField(prop, "m_Width");
PropertyField(prop, "m_Height");
PropertyField(prop, "m_Formatter");

View File

@@ -14,7 +14,6 @@ namespace XCharts.Editor
PropertyField("m_RoundCap");
PropertyField("m_Clockwise");
PropertyField("m_TitleStyle");
PropertyField("m_ItemStyle");
PropertyField("m_Animation");
}

View File

@@ -181,7 +181,7 @@ namespace XCharts.Editor
});
if (m_DataElementFoldout[index])
{
if(!(serie is ISimplifiedSerie))
if (!(serie is ISimplifiedSerie))
DrawSerieDataDetail(m_Datas, index);
}
}
@@ -201,6 +201,7 @@ namespace XCharts.Editor
var m_Symbol = serieData.FindPropertyRelative("m_Symbols");
var m_LineStyle = serieData.FindPropertyRelative("m_LineStyles");
var m_AreaStyle = serieData.FindPropertyRelative("m_AreaStyles");
var m_TitleStyle = serieData.FindPropertyRelative("m_TitleStyles");
PropertyField(sereName);
PropertyField(selected);
@@ -239,6 +240,10 @@ namespace XCharts.Editor
{
serie.GetSerieData(index).GetOrAddComponent<AreaStyle>();
}, m_AreaStyle.arraySize == 0),
new HeaderMenuInfo("Add TitleStyle", () =>
{
serie.GetSerieData(index).GetOrAddComponent<TitleStyle>();
}, m_TitleStyle.arraySize == 0),
new HeaderMenuInfo("Remove ItemStyle", () =>
{
serie.GetSerieData(index).RemoveComponent<ItemStyle>();
@@ -267,6 +272,10 @@ namespace XCharts.Editor
{
serie.GetSerieData(index).RemoveComponent<AreaStyle>();
}, m_AreaStyle.arraySize > 0),
new HeaderMenuInfo("Remove TitleStyle", () =>
{
serie.GetSerieData(index).RemoveComponent<TitleStyle>();
}, m_TitleStyle.arraySize > 0),
new HeaderMenuInfo("Remove All", () =>
{
serie.GetSerieData(index).RemoveAllComponent();
@@ -287,6 +296,8 @@ namespace XCharts.Editor
PropertyField(m_LineStyle.GetArrayElementAtIndex(0));
if (m_AreaStyle.arraySize > 0)
PropertyField(m_AreaStyle.GetArrayElementAtIndex(0));
if (m_TitleStyle.arraySize > 0)
PropertyField(m_TitleStyle.GetArrayElementAtIndex(0));
}
EditorGUI.indentLevel--;
}

View File

@@ -208,8 +208,6 @@ namespace XCharts.Example
{
chart.GetChartComponent<Title>().subText = "SerieLabel 文本标签";
serie.AddExtraComponent<LabelStyle>();
serie.label.show = true;
serie.label.border = false;
chart.RefreshChart();
while (serie.label.offset[1] < 20)
{
@@ -219,7 +217,6 @@ namespace XCharts.Example
}
yield return new WaitForSeconds(1);
serie.label.border = true;
chart.RefreshChart();
yield return new WaitForSeconds(1);

View File

@@ -143,13 +143,11 @@ namespace XCharts.Example
serie.AddExtraComponent<LabelStyle>();
serie.label.show = true;
serie.label.position = LabelStyle.Position.Center;
serie.label.border = false;
serie.label.textStyle.color = Color.white;
serie.label.formatter = "{d:f0}%";
serie2.label.show = true;
serie2.label.position = LabelStyle.Position.Center;
serie2.label.border = false;
serie2.label.textStyle.color = Color.white;
serie2.label.formatter = "{d:f0}%";
serie2.labelDirty = true;

View File

@@ -151,7 +151,6 @@ namespace XCharts.Example
serie1.label.position = LabelStyle.Position.Inside;
serie1.label.textStyle.color = Color.white;
serie1.label.textStyle.fontSize = 14;
serie1.label.border = false;
chart.RefreshChart();
yield return new WaitForSeconds(1);

View File

@@ -87,49 +87,6 @@ MonoBehaviour:
rgba: 1308293882
- serializedVersion: 2
rgba: 1305004232
m_Gauge:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_TextColor: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_TextBackgroundColor: {r: 0, g: 0, b: 0, a: 0}
m_FontSize: 18
m_LineType: 0
m_LineWidth: 15
m_LineLength: 0
m_LineColor:
serializedVersion: 2
rgba: 4283256145
m_SplitLineType: 0
m_SplitLineWidth: 0.8
m_SplitLineLength: 15
m_SplitLineColor:
serializedVersion: 2
rgba: 4294967295
m_TickWidth: 0.8
m_TickLength: 5
m_TickColor:
serializedVersion: 2
rgba: 4294967295
m_SplitAreaColors:
- serializedVersion: 2
rgba: 1308293882
- serializedVersion: 2
rgba: 1305004232
m_BarBackgroundColor:
serializedVersion: 2
rgba: 4291348680
m_StageColor:
- m_Percent: 0.2
m_Color:
serializedVersion: 2
rgba: 4289644433
- m_Percent: 0.8
m_Color:
serializedVersion: 2
rgba: 4288579171
- m_Percent: 1
m_Color:
serializedVersion: 2
rgba: 4281415106
m_Tooltip:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_TextColor: {r: 0, g: 0, b: 0, a: 1}

View File

@@ -504,19 +504,19 @@ namespace XCharts
return m_FadeInDuration > 0 ? m_FadeInDuration / 1000 : 1f;
}
internal float CheckItemProgress(int dataIndex, float barHig, ref bool isEnd)
internal float CheckItemProgress(int dataIndex, float destProgress, ref bool isEnd, float startProgress = 0)
{
isEnd = false;
var initHig = m_FadeOut ? barHig : 0;
var destHig = m_FadeOut ? 0 : barHig;
var initHig = m_FadeOut ? destProgress : startProgress;
var destHig = m_FadeOut ? startProgress : destProgress;
var currHig = GetDataCurrProgress(dataIndex, initHig, destHig, ref isEnd);
if (isEnd || IsFinish())
{
return m_FadeOuted ? 0 : barHig;
return m_FadeOuted ? startProgress : destProgress;
}
else if (IsInDelay() || IsInIndexDelay(dataIndex))
{
return m_FadeOut ? barHig : 0;
return m_FadeOut ? destProgress : startProgress;
}
else if (m_IsPause)
{
@@ -525,7 +525,7 @@ namespace XCharts
else
{
var duration = GetCurrAnimationDuration(dataIndex);
var delta = barHig / duration * Time.deltaTime;
var delta = (destProgress - startProgress) / duration * Time.deltaTime;
currHig = currHig + (m_FadeOut ? -delta : delta);
if (m_FadeOut)
{
@@ -535,11 +535,12 @@ namespace XCharts
isEnd = true;
}
}
else if (Mathf.Abs(currHig) >= Mathf.Abs(barHig))
else if (currHig - destProgress > 0)
{
currHig = barHig;
currHig = destProgress;
isEnd = true;
}
SetDataCurrProgress(dataIndex, currHig);
return currHig;
}

View File

@@ -8,7 +8,7 @@ namespace XCharts
public struct AnimationStyleContext
{
public AnimationType type;
internal float currentPathDistance;
internal bool isAllItemAnimationEnd;
public float currentPathDistance;
public bool isAllItemAnimationEnd;
}
}

View File

@@ -5,7 +5,7 @@ namespace XCharts
{
public static class AnimationStyleHelper
{
public static float CheckDataAnimation(BaseChart chart, Serie serie, int dataIndex, float destProgress)
public static float CheckDataAnimation(BaseChart chart, Serie serie, int dataIndex, float destProgress, float startPorgress = 0)
{
if (!serie.animation.IsItemAnimation())
{
@@ -18,7 +18,7 @@ namespace XCharts
return destProgress;
}
var isDataAnimationEnd = true;
float currHig = serie.animation.CheckItemProgress(dataIndex, destProgress, ref isDataAnimationEnd);
float currHig = serie.animation.CheckItemProgress(dataIndex, destProgress, ref isDataAnimationEnd, startPorgress);
if (!isDataAnimationEnd)
{
serie.animation.context.isAllItemAnimationEnd = false;

View File

@@ -77,7 +77,7 @@ namespace XCharts
var total = 360;
var cenPos = polar.context.center;
var txtHig = axis.axisLabel.textStyle.GetFontSize(chart.theme.axis) + 2;
var margin = axis.axisLabel.margin + axis.axisTick.GetLength(chart.theme.axis.tickLength);
var margin = axis.axisLabel.distance + axis.axisTick.GetLength(chart.theme.axis.tickLength);
var isCategory = axis.IsCategory();
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
for (int i = 0; i < splitNumber; i++)

View File

@@ -567,9 +567,9 @@ namespace XCharts
axisStartY += relativedLength;
if ((inside && axis.IsBottom()) || (!inside && axis.IsTop()))
current += axisStartY + axis.axisLabel.margin + fontSize / 2;
current += axisStartY + axis.axisLabel.distance + fontSize / 2;
else
current += axisStartY - axis.axisLabel.margin - fontSize / 2;
current += axisStartY - axis.axisLabel.distance - fontSize / 2;
return new Vector3(axisStartX + scaleWid, current) + axis.axisLabel.textStyle.offsetv3;
}
@@ -582,9 +582,9 @@ namespace XCharts
axisStartX += relativedLength;
if ((inside && axis.IsLeft()) || (!inside && axis.IsRight()))
current += axisStartX + axis.axisLabel.margin;
current += axisStartX + axis.axisLabel.distance;
else
current += axisStartX - axis.axisLabel.margin;
current += axisStartX - axis.axisLabel.distance;
return new Vector3(current, axisStartY + scaleWid) + axis.axisLabel.textStyle.offsetv3;
}

View File

@@ -16,7 +16,7 @@ namespace XCharts
[SerializeField] private string m_Formatter;
[SerializeField] private int m_Interval = 0;
[SerializeField] private bool m_Inside = false;
[SerializeField] private float m_Margin;
[SerializeField] private float m_Distance;
[SerializeField] private string m_NumericFormatter = "";
[SerializeField] private bool m_ShowAsPositiveNumber = false;
[SerializeField] private bool m_OnZero = false;
@@ -56,13 +56,13 @@ namespace XCharts
set { if (PropertyUtil.SetStruct(ref m_Inside, value)) SetComponentDirty(); }
}
/// <summary>
/// The margin between the axis label and the axis line.
/// The distance between the axis label and the axis line.
/// 刻度标签与轴线之间的距离。
/// </summary>
public float margin
public float distance
{
get { return m_Margin; }
set { if (PropertyUtil.SetStruct(ref m_Margin, value)) SetComponentDirty(); }
get { return m_Distance; }
set { if (PropertyUtil.SetStruct(ref m_Distance, value)) SetComponentDirty(); }
}
/// <summary>
/// 图例内容字符串模版格式器。支持用 \n 换行。
@@ -179,7 +179,7 @@ namespace XCharts
m_Show = true,
m_Interval = 0,
m_Inside = false,
m_Margin = 8,
m_Distance = 8,
m_TextStyle = new TextStyle(),
};
}
@@ -192,7 +192,7 @@ namespace XCharts
axisLabel.formatter = formatter;
axisLabel.interval = interval;
axisLabel.inside = inside;
axisLabel.margin = margin;
axisLabel.distance = distance;
axisLabel.numericFormatter = numericFormatter;
axisLabel.width = width;
axisLabel.height = height;
@@ -209,7 +209,7 @@ namespace XCharts
formatter = axisLabel.formatter;
interval = axisLabel.interval;
inside = axisLabel.inside;
margin = axisLabel.margin;
distance = axisLabel.distance;
numericFormatter = axisLabel.numericFormatter;
width = axisLabel.width;
height = axisLabel.height;

View File

@@ -12,6 +12,15 @@ namespace XCharts
public class AxisSplitLine : BaseLine
{
[SerializeField] private int m_Interval;
[SerializeField] private float m_Distance;
[SerializeField] private bool m_AutoColor;
/// <summary>
/// The distance between the split line and axis line.
/// 刻度线与轴线的距离。
/// </summary>
public float distance { get { return m_Distance; } set { m_Distance = value; } }
public bool autoColor { get { return m_AutoColor; } set { m_AutoColor = value; } }
public int interval
{

View File

@@ -15,6 +15,15 @@ namespace XCharts
[SerializeField] private bool m_Inside;
[SerializeField] private bool m_ShowStartTick;
[SerializeField] private bool m_ShowEndTick;
[SerializeField] private float m_Distance;
[SerializeField] protected int m_SplitNumber = 0;
[SerializeField] private bool m_AutoColor;
/// <summary>
/// The distance between the tick line and axis line.
/// 刻度线与轴线的距离。
/// </summary>
public float distance { get { return m_Distance; } set { m_Distance = value; } }
/// <summary>
/// Align axis tick with label, which is available only when boundaryGap is set to be true in category axis.
@@ -52,6 +61,16 @@ namespace XCharts
get { return m_ShowEndTick; }
set { if (PropertyUtil.SetStruct(ref m_ShowEndTick, value)) SetVerticesDirty(); }
}
/// <summary>
/// Number of segments that the axis is split into.
/// 分隔线之间分割的刻度数。
/// </summary>
public int splitNumber
{
get { return m_SplitNumber; }
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
}
public bool autoColor { get { return m_AutoColor; } set { m_AutoColor = value; } }
public static AxisTick defaultTick
{

View File

@@ -135,7 +135,7 @@ namespace XCharts
var dire = ChartHelper.GetDire(startAngle, true).normalized;
var tickLength = axis.axisTick.GetLength(chart.theme.axis.tickLength);
var tickVector = ChartHelper.GetVertialDire(dire)
* (tickLength + axis.axisLabel.margin);
* (tickLength + axis.axisLabel.distance);
return ChartHelper.GetPos(cenPos, totalWidth, startAngle, true) + tickVector;
}

View File

@@ -73,17 +73,15 @@ namespace XCharts
[SerializeField] private bool m_Show = true;
[SerializeField] Position m_Position = Position.Outside;
[SerializeField] private Vector3 m_Offset;
[SerializeField] private float m_Margin;
[SerializeField] private float m_Distance;
[SerializeField] private string m_Formatter;
[SerializeField] private float m_PaddingLeftRight = 2f;
[SerializeField] private float m_PaddingTopBottom = 2f;
[SerializeField] private float m_BackgroundWidth = 0;
[SerializeField] private float m_BackgroundHeight = 0;
[SerializeField] private bool m_Border = false;
[SerializeField] private float m_BorderWidth = 0.5f;
[SerializeField] private Color32 m_BorderColor = ChartConst.greyColor32;
[SerializeField] private string m_NumericFormatter = "";
[SerializeField] private bool m_AutoOffset = false;
[SerializeField] private bool m_AutoColor = false;
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
private DelegateSerieLabelFormatter m_FormatterFunction;
@@ -92,16 +90,14 @@ namespace XCharts
m_Show = false;
m_Position = Position.Outside;
m_Offset = Vector3.zero;
m_Margin = 0;
m_Distance = 0;
m_PaddingLeftRight = 2f;
m_PaddingTopBottom = 2f;
m_BackgroundWidth = 0;
m_BackgroundHeight = 0;
m_Border = false;
m_BorderWidth = 0.5f;
m_BorderColor = Color.grey;
m_NumericFormatter = "";
m_AutoOffset = false;
m_AutoColor = false;
}
/// <summary>
@@ -152,10 +148,10 @@ namespace XCharts
/// <summary>
/// 距离轴线的距离。
/// </summary>
public float margin
public float distance
{
get { return m_Margin; }
set { if (PropertyUtil.SetStruct(ref m_Margin, value)) SetVerticesDirty(); }
get { return m_Distance; }
set { if (PropertyUtil.SetStruct(ref m_Distance, value)) SetVerticesDirty(); }
}
/// <summary>
/// the width of background. If set as default value 0, it means than the background width auto set as the text width.
@@ -196,33 +192,6 @@ namespace XCharts
set { if (PropertyUtil.SetStruct(ref m_PaddingTopBottom, value)) SetComponentDirty(); }
}
/// <summary>
/// Whether to show border.
/// 是否显示边框。
/// </summary>
public bool border
{
get { return m_Border; }
set { if (PropertyUtil.SetStruct(ref m_Border, value)) SetVerticesDirty(); }
}
/// <summary>
/// the width of border.
/// 边框宽度。
/// </summary>
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// the color of border.
/// 边框颜色。
/// </summary>
public Color32 borderColor
{
get { return m_BorderColor; }
set { if (PropertyUtil.SetStruct(ref m_BorderColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// Standard numeric format strings.
/// 标准数字格式字符串。用于将数值格式化显示为字符串。
/// 使用Axx的形式A是格式说明符的单字符支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明从0-99。
@@ -242,6 +211,14 @@ namespace XCharts
get { return m_AutoOffset; }
set { if (PropertyUtil.SetStruct(ref m_AutoOffset, value)) SetAllDirty(); }
}
/// <summary>
/// 是否开启自动颜色。当开启时会根据已支持的serie自动设置颜色。
/// </summary>
public bool autoColor
{
get { return m_AutoColor; }
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetAllDirty(); }
}
/// <summary>
/// the sytle of text.
@@ -264,6 +241,14 @@ namespace XCharts
return position == Position.Inside || position == Position.Center;
}
public Vector3 GetOffset(float radius)
{
var x = ChartHelper.GetActualValue(m_Offset.x, radius);
var y = ChartHelper.GetActualValue(m_Offset.y, radius);
var z = ChartHelper.GetActualValue(m_Offset.z, radius);
return new Vector3(x, y, z);
}
public Color GetColor(Color defaultColor)
{
if (ChartHelper.IsClearColor(textStyle.color))

View File

@@ -21,6 +21,7 @@ namespace XCharts
[SerializeField] private float m_ExtraWidth = 0;
[SerializeField] private Vector2 m_Offset = Vector2.zero;
[SerializeField] private Color m_Color = Color.clear;
[SerializeField] private bool m_AutoBackgroundColor = false;
[SerializeField] private Color m_BackgroundColor = Color.clear;
[SerializeField] private int m_FontSize = 0;
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
@@ -73,6 +74,11 @@ namespace XCharts
get { return m_Color; }
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetComponentDirty(); }
}
public bool autoBackgroundColor
{
get { return m_AutoBackgroundColor; }
set { if (PropertyUtil.SetStruct(ref m_AutoBackgroundColor, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of text.
/// 文本的背景颜色。

View File

@@ -1,7 +1,6 @@
using System;
using UnityEngine;
using UnityEngine.Serialization;
namespace XCharts
{
@@ -10,9 +9,10 @@ namespace XCharts
/// 标题相关设置。
/// </summary>
[Serializable]
public class TitleStyle : ChildComponent
public class TitleStyle : ChildComponent, ISerieDataComponent, ISerieExtraComponent
{
[SerializeField] private bool m_Show;
[SerializeField] private bool m_Show = true;
[SerializeField] private Vector2 m_OffsetCenter = new Vector2(0, -0.2f);
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
/// <summary>
@@ -24,6 +24,15 @@ namespace XCharts
get { return m_Show; }
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
}
/// <summary>
/// The offset position relative to the center.
/// 相对于中心的偏移位置。
/// </summary>
public Vector2 offsetCenter
{
get { return m_OffsetCenter; }
set { if (PropertyUtil.SetStruct(ref m_OffsetCenter, value)) SetComponentDirty(); }
}
/// <summary>
/// the color of text.
@@ -43,46 +52,11 @@ namespace XCharts
textStyle.ClearComponentDirty();
}
public ChartText runtimeText { get; set; }
public bool IsInited()
public Vector3 GetOffset(float radius)
{
return runtimeText != null;
}
public void SetActive(bool active)
{
if (runtimeText != null)
{
runtimeText.SetActive(active);
}
}
public void UpdatePosition(Vector3 pos)
{
if (runtimeText != null)
{
runtimeText.SetLocalPosition(pos + new Vector3(m_TextStyle.offset.x, m_TextStyle.offset.y));
}
}
public void SetText(string text)
{
if (runtimeText == null) return;
var oldText = runtimeText.GetText();
if (oldText != null && !oldText.Equals(text))
{
if (!ChartHelper.IsClearColor(textStyle.color)) runtimeText.SetColor(textStyle.color);
runtimeText.SetText(text);
}
}
public void SetColor(Color color)
{
if (runtimeText != null)
{
runtimeText.SetColor(color);
}
var x = ChartHelper.GetActualValue(m_OffsetCenter.x, radius);
var y = ChartHelper.GetActualValue(m_OffsetCenter.y, radius);
return new Vector3(x, y, 0);
}
}
}

View File

@@ -474,6 +474,12 @@ namespace XCharts
else return serie.areaStyle;
}
public static TitleStyle GetTitleStyle(Serie serie, SerieData serieData)
{
if (serieData != null && serieData.titleStyle != null) return serieData.titleStyle;
else return serie.titleStyle;
}
public static Color32 GetAreaColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight)
{
Color32 color = ChartConst.clearColor32;

View File

@@ -150,7 +150,7 @@ namespace XCharts
serieData.context.labelPosition = serie.context.center;
break;
case LabelStyle.Position.Inside:
var labelRadius = offsetRadius + insideRadius + (outsideRadius - insideRadius) / 2 + serieLabel.margin;
var labelRadius = offsetRadius + insideRadius + (outsideRadius - insideRadius) / 2 + serieLabel.distance;
var labelCenter = new Vector2(serie.context.center.x + labelRadius * Mathf.Sin(currRad),
serie.context.center.y + labelRadius * Mathf.Cos(currRad));
serieData.context.labelPosition = labelCenter;

View File

@@ -86,6 +86,10 @@ namespace XCharts
/// </summary>
public Action<VertexHelper> onCustomDrawTop { set { m_OnCustomDrawTopCallback = value; } }
/// <summary>
/// 自定义仪表盘指针绘制回调。参数SerieIndexSerieDataIndexcurrAngle
/// </summary>
public Action<VertexHelper, int, int, float> onCustomDrawGagugePointer { set { m_OnCustomDrawGagugePointerCallback = value; } get { return m_OnCustomDrawGagugePointerCallback; } }
/// <summary>
/// the callback function of click pie area.
/// 点击饼图区域回调。参数PointerEventDataSerieIndexSerieDataIndex
/// </summary>

View File

@@ -85,6 +85,7 @@ namespace XCharts
protected Action<VertexHelper> m_OnCustomDrawTopCallback;
protected Action<VertexHelper, Serie> m_OnCustomDrawSerieBeforeCallback;
protected Action<VertexHelper, Serie> m_OnCustomDrawSerieAfterCallback;
protected Action<VertexHelper, int, int, float> m_OnCustomDrawGagugePointerCallback;
protected Action<PointerEventData, int, int> m_OnPointerClickPie;
protected Action<PointerEventData, int> m_OnPointerClickBar;
protected Action<Axis, double> m_OnUpdateAxisPointer;

View File

@@ -188,8 +188,10 @@ namespace XCharts
m_LabelRect.sizeDelta = newSize;
if (m_LabelBackgroundRect != null)
m_LabelBackgroundRect.sizeDelta = newSize;
if (!isIconActive && m_ObjectRect != null)
m_ObjectRect.sizeDelta = newSize;
AdjustIconPos();
}
return sizeChange;
}

View File

@@ -415,6 +415,21 @@ namespace XCharts
return label;
}
public static ChartLabel AddDefaultChartLabel(string name, Transform parent,
Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, TextStyle textStyle, ComponentTheme theme,
string content)
{
var labelObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
var label = GetOrAddComponent<ChartLabel>(labelObj);
label.label = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot, sizeDelta, textStyle, theme);
label.icon = ChartHelper.AddIcon("Icon", label.gameObject.transform, 0, 0);
label.SetAutoSize(true);
label.label.SetActive(true);
label.SetText(content);
label.color = textStyle.color;
return label;
}
internal static GameObject AddSerieLabel(string name, Transform parent, float width, float height,
Color color, TextStyle textStyle, ThemeStyle theme)
{
@@ -906,5 +921,11 @@ namespace XCharts
{
return !ChartHelper.IsClearColor(color) && color.a == 0;
}
public static float GetActualValue(float valueOrRate, float total)
{
if (valueOrRate >= -1.5f && valueOrRate <= 1.5f) return valueOrRate * total;
else return valueOrRate;
}
}
}

View File

@@ -5,7 +5,7 @@ namespace XCharts
{
[System.Serializable]
[SerieHandler(typeof(RingHandler), true)]
[SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
[SerieExtraComponent(typeof(LabelStyle), typeof(TitleStyle), typeof(Emphasis))]
public class Ring : Serie
{
public override bool useDataNameForColor { get { return true; } }
@@ -14,13 +14,17 @@ namespace XCharts
var serie = chart.AddSerie<Ring>(serieName);
serie.roundCap = true;
serie.radius = new float[] { 0.3f, 0.35f };
serie.titleStyle.show = false;
serie.titleStyle.textStyle.offset = new Vector2(0, 30);
serie.AddExtraComponent<LabelStyle>();
serie.label.show = true;
serie.label.position = LabelStyle.Position.Center;
serie.label.formatter = "{d:f0}%";
serie.label.textStyle.fontSize = 28;
serie.AddExtraComponent<TitleStyle>();
serie.titleStyle.show = false;
serie.titleStyle.textStyle.offset = new Vector2(0, 30);
var value = Random.Range(30, 90);
var max = 100;
chart.AddData(serie.index, value, max, "data1");

View File

@@ -247,12 +247,12 @@ namespace XCharts
case LabelStyle.Position.Bottom:
var px1 = Mathf.Sin(startAngle * Mathf.Deg2Rad) * centerRadius;
var py1 = Mathf.Cos(startAngle * Mathf.Deg2Rad) * centerRadius;
var xDiff = serie.clockwise ? -label.margin : label.margin;
var xDiff = serie.clockwise ? -label.distance : label.distance;
serieData.context.labelPosition = serie.context.center + new Vector3(px1 + xDiff, py1);
break;
case LabelStyle.Position.Top:
startAngle += serie.clockwise ? -label.margin : label.margin;
toAngle += serie.clockwise ? label.margin : -label.margin;
startAngle += serie.clockwise ? -label.distance : label.distance;
toAngle += serie.clockwise ? label.distance : -label.distance;
var px2 = Mathf.Sin(toAngle * Mathf.Deg2Rad) * centerRadius;
var py2 = Mathf.Cos(toAngle * Mathf.Deg2Rad) * centerRadius;
serieData.context.labelPosition = serie.context.center + new Vector3(px2, py2);

View File

@@ -16,6 +16,7 @@ namespace XCharts
{typeof(AreaStyle), "m_AreaStyles"},
{typeof(IconStyle), "m_IconStyles"},
{typeof(Emphasis), "m_Emphases"},
{typeof(TitleStyle), "m_TitleStyles"},
};
[SerializeField] private List<LabelStyle> m_Labels = new List<LabelStyle>();
@@ -24,6 +25,7 @@ namespace XCharts
[SerializeField] private List<LineArrow> m_LineArrows = new List<LineArrow>();
[SerializeField] private List<AreaStyle> m_AreaStyles = new List<AreaStyle>();
[SerializeField] private List<IconStyle> m_IconStyles = new List<IconStyle>();
[SerializeField] private List<TitleStyle> m_TitleStyles = new List<TitleStyle>();
[SerializeField] private List<Emphasis> m_Emphases = new List<Emphasis>();
/// <summary>
@@ -56,6 +58,11 @@ namespace XCharts
/// 数据项图标样式。
/// </summary>
public IconStyle iconStyle { get { return m_IconStyles.Count > 0 ? m_IconStyles[0] : null; } }
/// <summary>
/// the icon of data.
/// 数据项标题样式。
/// </summary>
public TitleStyle titleStyle { get { return m_TitleStyles.Count > 0 ? m_TitleStyles[0] : null; } }
public void RemoveAllExtraComponent()
{

View File

@@ -235,7 +235,6 @@ namespace XCharts
[SerializeField] private SymbolStyle m_Symbol = new SymbolStyle();
[SerializeField] private AnimationStyle m_Animation = new AnimationStyle();
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
[SerializeField] private TitleStyle m_TitleStyle = new TitleStyle();
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
[NonSerialized] internal int m_FilterStart;
@@ -710,14 +709,6 @@ namespace XCharts
set { if (PropertyUtil.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
}
/// <summary>
/// 标题样式。
/// </summary>
public TitleStyle titleStyle
{
get { return m_TitleStyle; }
set { if (PropertyUtil.SetClass(ref m_TitleStyle, value, true)) SetAllDirty(); }
}
/// <summary>
/// 数据项里的数据维数。
/// </summary>
public int showDataDimension { get { return m_ShowDataDimension; } set { m_ShowDataDimension = value; } }
@@ -879,18 +870,25 @@ namespace XCharts
itemStyle.vertsDirty ||
(areaStyle != null && areaStyle.vertsDirty) ||
(label != null && label.vertsDirty) ||
(emphasis != null && emphasis.vertsDirty);
(emphasis != null && emphasis.vertsDirty) ||
(titleStyle != null && titleStyle.vertsDirty);
}
}
public override bool componentDirty { get { return m_ComponentDirty || titleStyle.componentDirty; } }
public override bool componentDirty
{
get
{
return m_ComponentDirty
|| (titleStyle != null && titleStyle.componentDirty);
}
}
public override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
symbol.ClearVerticesDirty();
lineStyle.ClearVerticesDirty();
itemStyle.ClearVerticesDirty();
titleStyle.ClearVerticesDirty();
if (iconStyle != null)
iconStyle.ClearVerticesDirty();
if (areaStyle != null)
@@ -901,6 +899,8 @@ namespace XCharts
emphasis.ClearVerticesDirty();
if (lineArrow != null)
lineArrow.ClearVerticesDirty();
if (titleStyle != null)
titleStyle.ClearVerticesDirty();
}
public override void ClearComponentDirty()
@@ -909,8 +909,6 @@ namespace XCharts
symbol.ClearComponentDirty();
lineStyle.ClearComponentDirty();
itemStyle.ClearComponentDirty();
emphasis.ClearComponentDirty();
titleStyle.ClearComponentDirty();
if (iconStyle != null)
iconStyle.ClearComponentDirty();
if (areaStyle != null)
@@ -921,6 +919,8 @@ namespace XCharts
emphasis.ClearComponentDirty();
if (lineArrow != null)
lineArrow.ClearComponentDirty();
if (titleStyle != null)
titleStyle.ClearComponentDirty();
}
public override void SetAllDirty()

View File

@@ -39,11 +39,11 @@ namespace XCharts
/// <summary>
/// 内半径
/// </summary>
public float insideRadius { get; internal set; }
public float insideRadius { get; set; }
/// <summary>
/// 外半径
/// </summary>
public float outsideRadius { get; internal set; }
public float outsideRadius { get; set; }
/// <summary>
/// 最大值
/// </summary>

View File

@@ -25,12 +25,14 @@ namespace XCharts
[SerializeField] private List<IconStyle> m_IconStyles = new List<IconStyle>();
[SerializeField] private List<LineStyle> m_LineStyles = new List<LineStyle>();
[SerializeField] private List<AreaStyle> m_AreaStyles = new List<AreaStyle>();
[SerializeField] private List<TitleStyle> m_TitleStyles = new List<TitleStyle>();
[SerializeField] private List<double> m_Data = new List<double>();
[SerializeField] private List<int> m_Children = new List<int>();
[NonSerialized] public SerieDataContext context = new SerieDataContext();
[NonSerialized] public InteractData interact = new InteractData();
public ChartLabel labelObject { get; set; }
public ChartLabel titleObject { get; set; }
private bool m_Show = true;
@@ -81,6 +83,7 @@ namespace XCharts
public SymbolStyle symbol { get { return m_Symbols.Count > 0 ? m_Symbols[0] : null; } }
public LineStyle lineStyle { get { return m_LineStyles.Count > 0 ? m_LineStyles[0] : null; } }
public AreaStyle areaStyle { get { return m_AreaStyles.Count > 0 ? m_AreaStyles[0] : null; } }
public TitleStyle titleStyle { get { return m_TitleStyles.Count > 0 ? m_TitleStyles[0] : null; } }
/// <summary>
/// 是否忽略数据。当为 true 时,数据不进行绘制。
/// </summary>
@@ -130,6 +133,7 @@ namespace XCharts
m_Symbols.Clear();
m_LineStyles.Clear();
m_AreaStyles.Clear();
m_TitleStyles.Clear();
}
public T GetOrAddComponent<T>() where T : ChildComponent
@@ -183,6 +187,12 @@ namespace XCharts
m_AreaStyles.Add(new AreaStyle() { show = true });
return m_AreaStyles[0] as T;
}
else if (type == typeof(TitleStyle))
{
if (m_TitleStyles.Count == 0)
m_TitleStyles.Add(new TitleStyle() { show = true });
return m_TitleStyles[0] as T;
}
else
{
throw new System.Exception("SerieData not support component:" + type);
@@ -199,6 +209,7 @@ namespace XCharts
m_Emphases.Clear();
m_LineStyles.Clear();
m_AreaStyles.Clear();
m_TitleStyles.Clear();
}
public void RemoveComponent<T>() where T : ISerieDataComponent
@@ -220,6 +231,8 @@ namespace XCharts
m_LineStyles.Clear();
else if (type == typeof(AreaStyle))
m_AreaStyles.Clear();
else if (type == typeof(TitleStyle))
m_TitleStyles.Clear();
else
throw new System.Exception("SerieData not support component:" + type);
}
@@ -427,6 +440,11 @@ namespace XCharts
m_PolygonPoints.Add(p3);
m_PolygonPoints.Add(p4);
}
public void SetPolygon(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5)
{
SetPolygon(p1, p2, p3, p4);
m_PolygonPoints.Add(p5);
}
public bool IsInPolygon(Vector2 p)
{

View File

@@ -45,7 +45,8 @@ namespace XCharts
public abstract class SerieHandler<T> : SerieHandler where T : Serie
{
private static readonly string s_SerieLabelObjectName = "label";
private static readonly string s_SerieTitleObjectName = "serie";
private static readonly string s_SerieTitleObjectName = "title";
private static readonly string s_SerieRootObjectName = "serie";
protected GameObject m_SerieRoot;
protected bool m_InitedLabel;
protected bool m_NeedInitComponent;
@@ -82,7 +83,7 @@ namespace XCharts
serie.label.ClearComponentDirty();
InitSerieLabel();
}
if (serie.titleDirty || serie.titleStyle.componentDirty)
if (serie.titleStyle != null && (serie.titleDirty || serie.titleStyle.componentDirty))
{
serie.titleDirty = false;
serie.titleStyle.ClearComponentDirty();
@@ -169,7 +170,7 @@ namespace XCharts
private void InitRoot()
{
if (m_SerieRoot != null) return;
var objName = s_SerieTitleObjectName + "_" + serie.index;
var objName = s_SerieRootObjectName + "_" + serie.index;
m_SerieRoot = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
m_SerieRoot.hideFlags = chart.chartHideFlags;
@@ -198,6 +199,7 @@ namespace XCharts
count++;
}
}
RefreshLabelInternal();
}
protected bool AddSerieLabel(GameObject serieLabelRoot, Serie serie, SerieData serieData, ref int count)
@@ -231,7 +233,10 @@ namespace XCharts
item.SetLabel(labelObj, isAutoSize, serieLabel.paddingLeftRight, serieLabel.paddingTopBottom);
item.SetIcon(iconImage);
item.SetIconActive(iconStyle != null && iconStyle.show);
item.color = serieLabel.textStyle.backgroundColor;
if (serieLabel.textStyle.autoBackgroundColor)
item.color = chart.theme.GetColor(serieData.index);
else
item.color = serieLabel.textStyle.backgroundColor;
serieData.labelObject = item;
foreach (var data in serieData.children)
@@ -247,28 +252,35 @@ namespace XCharts
{
if (m_SerieRoot == null)
InitRoot();
var textStyle = serie.titleStyle.textStyle;
var titleColor = ChartHelper.IsClearColor(textStyle.color)
? chart.theme.GetColor(serie.index)
: (Color32)textStyle.color;
var serieTitleRoot = ChartHelper.AddObject(s_SerieTitleObjectName, m_SerieRoot.transform,
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
serieTitleRoot.hideFlags = chart.chartHideFlags;
SerieLabelPool.ReleaseAll(serieTitleRoot.transform);
ChartHelper.RemoveComponent<Text>(serieTitleRoot);
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
var anchorMin = new Vector2(0.5f, 0.5f);
var anchorMax = new Vector2(0.5f, 0.5f);
var pivot = new Vector2(0.5f, 0.5f);
var fontSize = 10;
var sizeDelta = new Vector2(50, fontSize + 2);
var txt = ChartHelper.AddTextObject("title", m_SerieRoot.transform, anchorMin, anchorMax,
pivot, sizeDelta, textStyle, chart.theme.common);
txt.SetText("");
txt.SetColor(titleColor);
txt.SetLocalPosition(Vector2.zero);
txt.SetLocalEulerAngles(Vector2.zero);
txt.SetActive(serie.titleStyle.show);
serie.titleStyle.runtimeText = txt;
serie.titleStyle.UpdatePosition(serie.context.center);
var serieData = serie.GetSerieData(0);
if (serieData != null)
for (int i = 0; i < serie.dataCount; i++)
{
txt.SetText(serieData.name);
var serieData = serie.data[i];
var titleStyle = SerieHelper.GetTitleStyle(serie, serieData);
if (titleStyle == null) continue;
var color = chart.GetLegendRealShowNameColor(serieData.name);
var label = ChartHelper.AddDefaultChartLabel("title_" + i, serieTitleRoot.transform, anchorMin, anchorMax,
pivot, sizeDelta, titleStyle.textStyle, chart.theme.common, serieData.name);
serieData.titleObject = label;
label.SetActive(titleStyle.show);
var labelPosition = GetSerieDataTitlePosition(serieData, titleStyle);
var offset = titleStyle.GetOffset(serie.context.insideRadius);
label.SetPosition(labelPosition + offset);
if (titleStyle.textStyle.autoBackgroundColor)
label.color = color;
else
label.color = titleStyle.textStyle.backgroundColor;
}
}
@@ -279,7 +291,7 @@ namespace XCharts
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
var total = serie.GetDataTotal(defaultDimension);
var isNeedInvertPositionSerie = serie is Line;
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
foreach (var serieData in serie.data)
{
@@ -292,7 +304,6 @@ namespace XCharts
var isIgnore = serie.IsIgnoreIndex(serieData.index, defaultDimension);
var currLabel = isHighlight && emphasisLabel != null ? emphasisLabel : serieLabel;
serieData.labelObject.SetPosition(serieData.context.position);
serieData.labelObject.UpdateIcon(iconStyle);
if (serie.show
&& currLabel != null
@@ -300,17 +311,12 @@ namespace XCharts
&& serieData.context.canShowLabel
&& !isIgnore)
{
var value = serieData.GetData(defaultDimension);
var content = serie.useDataNameForColor && string.IsNullOrEmpty(currLabel.formatter)
? serieData.name
//var value = serieData.GetData(defaultDimension);
var value = serieData.GetCurrData(defaultDimension, dataChangeDuration);
var content = string.IsNullOrEmpty(currLabel.formatter)
? ChartCached.NumberToStr(value, serieLabel.numericFormatter)
: SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
currLabel, chart.theme.GetColor(colorIndex));
var invert = currLabel.autoOffset
&& isNeedInvertPositionSerie
&& SerieHelper.IsDownPoint(serie, serieData.index)
&& (serie.areaStyle == null || !serie.areaStyle.show);
var labelPosition = GetSerieDataLabelPosition(serieData, currLabel);
var isInsidePosition = currLabel.position == LabelStyle.Position.Inside;
//text color
@@ -332,9 +338,9 @@ namespace XCharts
}
SerieLabelHelper.ResetLabel(serieData.labelObject.label, currLabel, chart.theme, textColor, rotate);
serieData.SetLabelActive(!isIgnore);
serieData.labelObject.SetPosition(labelPosition
+ (invert ? -currLabel.offset : currLabel.offset));
serieData.labelObject.SetText(content);
UpdateLabelPosition(serieData, currLabel);
}
else
{
@@ -343,11 +349,29 @@ namespace XCharts
}
}
private void UpdateLabelPosition(SerieData serieData, LabelStyle currLabel)
{
var isNeedInvertPositionSerie = serie is Line;
var invert = currLabel.autoOffset
&& isNeedInvertPositionSerie
&& SerieHelper.IsDownPoint(serie, serieData.index)
&& (serie.areaStyle == null || !serie.areaStyle.show);
var labelPosition = GetSerieDataLabelPosition(serieData, currLabel);
var offset = currLabel.GetOffset(serie.context.insideRadius);
serieData.labelObject.SetPosition(labelPosition
+ (invert ? -offset : offset));
}
public virtual Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label)
{
return serieData.context.position;
}
public virtual Vector3 GetSerieDataTitlePosition(SerieData serieData, TitleStyle titleStyle)
{
return serieData.context.position;
}
protected void UpdateCoordSerieParams(ref List<SerieParams> paramList, ref string title,
int dataIndex, bool showCategory, string category, string marker,
string itemFormatter, string numericFormatter)

View File

@@ -1,77 +0,0 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
[Serializable]
public class GaugeAxisTheme : BaseAxisTheme
{
[SerializeField] private Color32 m_BarBackgroundColor;
[SerializeField]
private List<StageColor> m_StageColor = new List<StageColor>()
{
new StageColor(0.2f,new Color32(145,199,174,255)),
new StageColor(0.8f,new Color32(99,134,158,255)),
new StageColor(1.0f,new Color32(194,53,49,255)),
};
/// <summary>
/// 进度条背景颜色。
/// </summary>
public Color32 barBackgroundColor { get { return m_BarBackgroundColor; } set { m_BarBackgroundColor = value; } }
/// <summary>
/// 阶段颜色。
/// </summary>
public List<StageColor> stageColor { get { return m_StageColor; } set { m_StageColor = value; } }
public GaugeAxisTheme(ThemeType theme) : base(theme)
{
m_LineWidth = XCSettings.gaugeAxisLineWidth;
m_LineLength = 0;
m_SplitLineWidth = XCSettings.gaugeAxisSplitLineWidth;
m_SplitLineLength = XCSettings.gaugeAxisSplitLineLength;
m_TickWidth = XCSettings.gaugeAxisTickWidth;
m_TickLength = XCSettings.gaugeAxisTickLength;
m_SplitLineColor = Color.white;
m_TickColor = Color.white;
switch (theme)
{
case ThemeType.Default:
m_BarBackgroundColor = new Color32(200, 200, 200, 255);
m_StageColor = new List<StageColor>()
{
new StageColor(0.2f,new Color32(145,199,174,255)),
new StageColor(0.8f,new Color32(99,134,158,255)),
new StageColor(1.0f,new Color32(194,53,49,255)),
};
break;
case ThemeType.Light:
m_BarBackgroundColor = new Color32(200, 200, 200, 255);
m_StageColor = new List<StageColor>()
{
new StageColor(0.2f,new Color32(145,199,174,255)),
new StageColor(0.8f,new Color32(99,134,158,255)),
new StageColor(1.0f,new Color32(194,53,49,255)),
};
break;
case ThemeType.Dark:
m_BarBackgroundColor = new Color32(200, 200, 200, 255);
m_StageColor = new List<StageColor>()
{
new StageColor(0.2f,new Color32(145,199,174,255)),
new StageColor(0.8f,new Color32(99,134,158,255)),
new StageColor(1.0f,new Color32(194,53,49,255)),
};
break;
}
}
public void Copy(GaugeAxisTheme theme)
{
base.Copy(theme);
m_BarBackgroundColor = theme.barBackgroundColor;
ChartHelper.CopyList(m_StageColor, theme.stageColor);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b38e4b45ec20b4c65a6dc82891c5c39a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -37,7 +37,6 @@ namespace XCharts
[SerializeField] private SubTitleTheme m_SubTitle;
[SerializeField] private LegendTheme m_Legend;
[SerializeField] private AxisTheme m_Axis;
[SerializeField] private GaugeAxisTheme m_Gauge;
[SerializeField] private TooltipTheme m_Tooltip;
[SerializeField] private DataZoomTheme m_DataZoom;
[SerializeField] private VisualMapTheme m_VisualMap;
@@ -88,7 +87,6 @@ namespace XCharts
public SubTitleTheme subTitle { get { return m_SubTitle; } set { m_SubTitle = value; } }
public LegendTheme legend { get { return m_Legend; } set { m_Legend = value; } }
public AxisTheme axis { get { return m_Axis; } set { m_Axis = value; } }
public GaugeAxisTheme gauge { get { return m_Gauge; } set { m_Gauge = value; } }
public TooltipTheme tooltip { get { return m_Tooltip; } set { m_Tooltip = value; } }
public DataZoomTheme dataZoom { get { return m_DataZoom; } set { m_DataZoom = value; } }
public VisualMapTheme visualMap { get { return m_VisualMap; } set { m_VisualMap = value; } }
@@ -235,7 +233,6 @@ namespace XCharts
m_Title.Copy(theme.title);
m_SubTitle.Copy(theme.subTitle);
m_Axis.Copy(theme.axis);
m_Gauge.Copy(theme.gauge);
m_Tooltip.Copy(theme.tooltip);
m_DataZoom.Copy(theme.dataZoom);
m_VisualMap.Copy(theme.visualMap);
@@ -344,7 +341,6 @@ namespace XCharts
subTitle.font = font;
legend.font = font;
axis.font = font;
gauge.font = font;
tooltip.font = font;
dataZoom.font = font;
visualMap.font = font;
@@ -372,7 +368,6 @@ namespace XCharts
theme.subTitle = new SubTitleTheme(theme.themeType);
theme.legend = new LegendTheme(theme.themeType);
theme.axis = new AxisTheme(theme.themeType);
theme.gauge = new GaugeAxisTheme(theme.themeType);
theme.tooltip = new TooltipTheme(theme.themeType);
theme.dataZoom = new DataZoomTheme(theme.themeType);
theme.visualMap = new VisualMapTheme(theme.themeType);

View File

@@ -112,7 +112,6 @@ namespace XCharts
public SubTitleTheme subTitle { get { return sharedTheme.subTitle; } }
public LegendTheme legend { get { return sharedTheme.legend; } }
public AxisTheme axis { get { return sharedTheme.axis; } }
public GaugeAxisTheme gauge { get { return sharedTheme.gauge; } }
public TooltipTheme tooltip { get { return sharedTheme.tooltip; } }
public DataZoomTheme dataZoom { get { return sharedTheme.dataZoom; } }
public VisualMapTheme visualMap { get { return sharedTheme.visualMap; } }