mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 18:00:26 +00:00
v3.0.0-preivew8
This commit is contained in:
@@ -86,14 +86,14 @@ namespace XCharts.Runtime
|
||||
bool inside = axis.axisLabel.inside;
|
||||
var labelName = AxisHelper.GetLabelName(axis, total, i, axis.context.minValue, axis.context.maxValue,
|
||||
null, isPercentStack);
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform, new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(scaleAngle, txtHig), axis,
|
||||
chart.theme.axis, labelName);
|
||||
label.label.SetAlignment(axis.axisLabel.textStyle.GetAlignment(TextAnchor.MiddleCenter));
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
|
||||
new Vector2(scaleAngle, txtHig), axis,
|
||||
chart.theme.axis, labelName, Color.clear);
|
||||
label.text.SetAlignment(axis.axisLabel.textStyle.GetAlignment(TextAnchor.MiddleCenter));
|
||||
var pos = ChartHelper.GetPos(cenPos, radius + margin,
|
||||
isCategory ? (totalAngle + scaleAngle / 2) : totalAngle, true);
|
||||
AxisHelper.AdjustCircleLabelPos(label, pos, cenPos, txtHig, Vector3.zero);
|
||||
if (i == 0) axis.axisLabel.SetRelatedText(label.label, scaleAngle);
|
||||
if (i == 0) axis.axisLabel.SetRelatedText(label.text, scaleAngle);
|
||||
axis.context.labelObjectList.Add(label);
|
||||
|
||||
totalAngle += scaleAngle;
|
||||
|
||||
@@ -94,7 +94,6 @@ namespace XCharts.Runtime
|
||||
[SerializeField] protected bool m_Inverse = false;
|
||||
[SerializeField] private bool m_Clockwise = true;
|
||||
[SerializeField] private bool m_InsertDataToHead;
|
||||
[SerializeField] private IconStyle m_IconStyle = new IconStyle();
|
||||
[SerializeField] protected List<Sprite> m_Icons = new List<Sprite>();
|
||||
[SerializeField] protected List<string> m_Data = new List<string>();
|
||||
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
||||
@@ -362,14 +361,6 @@ namespace XCharts.Runtime
|
||||
get { return m_InsertDataToHead; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_InsertDataToHead, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图标样式。
|
||||
/// </summary>
|
||||
public IconStyle iconStyle
|
||||
{
|
||||
get { return m_IconStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_IconStyle, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
public override bool vertsDirty
|
||||
{
|
||||
@@ -432,7 +423,6 @@ namespace XCharts.Runtime
|
||||
axis.logBaseE = logBaseE;
|
||||
axis.ceilRate = ceilRate;
|
||||
axis.insertDataToHead = insertDataToHead;
|
||||
axis.iconStyle = iconStyle.Clone();
|
||||
axis.axisLine = axisLine.Clone();
|
||||
axis.axisName = axisName.Clone();
|
||||
axis.axisTick = axisTick.Clone();
|
||||
@@ -461,7 +451,6 @@ namespace XCharts.Runtime
|
||||
logBaseE = axis.logBaseE;
|
||||
ceilRate = axis.ceilRate;
|
||||
insertDataToHead = axis.insertDataToHead;
|
||||
iconStyle.Copy(axis.iconStyle);
|
||||
axisLine.Copy(axis.axisLine);
|
||||
axisName.Copy(axis.axisName);
|
||||
axisTick.Copy(axis.axisTick);
|
||||
|
||||
@@ -104,7 +104,12 @@ namespace XCharts.Runtime
|
||||
else
|
||||
range = dataZoom.minShowNum;
|
||||
}
|
||||
filterData = data.GetRange(start, range);
|
||||
if (range > data.Count - start - 1)
|
||||
start = data.Count - range - 1;
|
||||
if (start >= 0)
|
||||
filterData = data.GetRange(start, range);
|
||||
else
|
||||
filterData = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -296,12 +296,12 @@ namespace XCharts
|
||||
if (i == 0)
|
||||
{
|
||||
var dist = GetLabelPosition(0, 1).x - pos.x;
|
||||
label.SetLabelActive(dist > label.label.GetPreferredWidth());
|
||||
label.SetTextActive(dist > label.text.GetPreferredWidth());
|
||||
}
|
||||
else if (i == axis.context.labelValueList.Count - 1)
|
||||
{
|
||||
var dist = pos.x - GetLabelPosition(0, i - 1).x;
|
||||
label.SetLabelActive(dist > label.label.GetPreferredWidth());
|
||||
label.SetTextActive(dist > label.text.GetPreferredWidth());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -309,12 +309,12 @@ namespace XCharts
|
||||
if (i == 0)
|
||||
{
|
||||
var dist = GetLabelPosition(0, 1).y - pos.y;
|
||||
label.SetLabelActive(dist > label.label.GetPreferredHeight());
|
||||
label.SetTextActive(dist > label.text.GetPreferredHeight());
|
||||
}
|
||||
else if (i == axis.context.labelValueList.Count - 1)
|
||||
{
|
||||
var dist = pos.y - GetLabelPosition(0, i - 1).y;
|
||||
label.SetLabelActive(dist > label.label.GetPreferredHeight());
|
||||
label.SetTextActive(dist > label.text.GetPreferredHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,82 +361,36 @@ namespace XCharts
|
||||
? axis.axisLabel.height
|
||||
: 20f;
|
||||
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
|
||||
var inside = axis.axisLabel.inside;
|
||||
var defaultAlignment = orient == Orient.Horizonal ? TextAnchor.MiddleCenter :
|
||||
((inside && axis.IsLeft()) || (!inside && axis.IsRight())
|
||||
? TextAnchor.MiddleLeft
|
||||
: TextAnchor.MiddleRight);
|
||||
|
||||
if (axis.IsCategory() && axis.boundaryGap)
|
||||
{
|
||||
splitNumber -= 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < splitNumber; i++)
|
||||
{
|
||||
ChartLabel label;
|
||||
|
||||
var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
|
||||
var inside = axis.axisLabel.inside;
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
|
||||
|
||||
var labelName = AxisHelper.GetLabelName(axis, axisLength, i,
|
||||
axis.context.minValue,
|
||||
axis.context.maxValue,
|
||||
dataZoom, isPercentStack);
|
||||
|
||||
if (orient == Orient.Horizonal)
|
||||
{
|
||||
label = ChartHelper.AddAxisLabelObject(splitNumber, i,
|
||||
ChartCached.GetAxisLabelName(i),
|
||||
axisObj.transform,
|
||||
new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f),
|
||||
new Vector2(textWidth, textHeight),
|
||||
axis, chart.theme.axis, labelName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((inside && axis.IsLeft()) || (!inside && axis.IsRight()))
|
||||
{
|
||||
label = ChartHelper.AddAxisLabelObject(splitNumber, i,
|
||||
ChartCached.GetAxisLabelName(i),
|
||||
axisObj.transform,
|
||||
Vector2.zero,
|
||||
Vector2.zero,
|
||||
new Vector2(0, 0.5f),
|
||||
new Vector2(textWidth, textHeight),
|
||||
axis, chart.theme.axis, labelName);
|
||||
|
||||
label.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleLeft));
|
||||
}
|
||||
else
|
||||
{
|
||||
label = ChartHelper.AddAxisLabelObject(splitNumber, i,
|
||||
ChartCached.GetAxisLabelName(i),
|
||||
axisObj.transform,
|
||||
Vector2.zero,
|
||||
Vector2.zero,
|
||||
new Vector2(1, 0.5f),
|
||||
new Vector2(textWidth, textHeight),
|
||||
axis, chart.theme.axis, labelName);
|
||||
|
||||
label.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleRight));
|
||||
}
|
||||
}
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i,
|
||||
ChartCached.GetAxisLabelName(i),
|
||||
axisObj.transform,
|
||||
new Vector2(textWidth, textHeight),
|
||||
axis, chart.theme.axis, labelName,
|
||||
Color.clear,
|
||||
defaultAlignment);
|
||||
|
||||
if (i == 0)
|
||||
axis.axisLabel.SetRelatedText(label.label, labelWidth);
|
||||
axis.axisLabel.SetRelatedText(label.text, labelWidth);
|
||||
|
||||
var pos = handler.GetLabelPosition(totalWidth + gapWidth, i);
|
||||
|
||||
if (orient == Orient.Horizonal)
|
||||
{
|
||||
label.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleCenter));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (axis.IsRight())
|
||||
label.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleLeft));
|
||||
else
|
||||
label.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleRight));
|
||||
}
|
||||
|
||||
label.SetPosition(pos);
|
||||
handler.CheckValueLabelActive(axis, i, label, pos);
|
||||
|
||||
@@ -446,59 +400,41 @@ namespace XCharts
|
||||
}
|
||||
if (axis.axisName.show)
|
||||
{
|
||||
ChartText axisName = null;
|
||||
|
||||
var axisNameTextStyle = axis.axisName.textStyle;
|
||||
var offset = axisNameTextStyle.offset;
|
||||
|
||||
ChartLabel label = null;
|
||||
var relativedDist = (relativedAxis == null ? 0 : relativedAxis.context.offset);
|
||||
var zeroPos = new Vector3(axisStartX, axisStartY + relativedDist);
|
||||
|
||||
var offset = axis.axisName.labelStyle.offset;
|
||||
var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor);
|
||||
if (orient == Orient.Horizonal)
|
||||
{
|
||||
switch (axis.axisName.location)
|
||||
switch (axis.axisName.labelStyle.position)
|
||||
{
|
||||
case AxisName.Location.Start:
|
||||
case LabelStyle.Position.Start:
|
||||
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisName, axisObj.transform,
|
||||
new Vector2(1, 0.5f),
|
||||
new Vector2(1, 0.5f),
|
||||
new Vector2(1, 0.5f),
|
||||
new Vector2(100, 20),
|
||||
axisNameTextStyle, chart.theme.axis);
|
||||
|
||||
axisName.SetAlignment(axisNameTextStyle.GetAlignment(TextAnchor.MiddleRight));
|
||||
axisName.SetLocalPosition(axis.position == Axis.AxisPosition.Top
|
||||
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
|
||||
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleRight);
|
||||
label.SetActive(axis.axisName.labelStyle.show);
|
||||
label.SetPosition(axis.position == Axis.AxisPosition.Top
|
||||
? new Vector2(zeroPos.x - offset.x, axisStartY + relativedLength + offset.y + axis.offset)
|
||||
: new Vector2(zeroPos.x - offset.x, zeroPos.y + offset.y + axis.offset));
|
||||
break;
|
||||
|
||||
case AxisName.Location.Middle:
|
||||
case LabelStyle.Position.Middle:
|
||||
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisName, axisObj.transform,
|
||||
new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f),
|
||||
new Vector2(100, 20),
|
||||
axisNameTextStyle, chart.theme.axis);
|
||||
|
||||
axisName.SetAlignment(axisNameTextStyle.GetAlignment(TextAnchor.MiddleCenter));
|
||||
axisName.SetLocalPosition(axis.position == Axis.AxisPosition.Top
|
||||
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
|
||||
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
|
||||
label.SetActive(axis.axisName.labelStyle.show);
|
||||
label.SetPosition(axis.position == Axis.AxisPosition.Top
|
||||
? new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY + relativedLength - offset.y + axis.offset)
|
||||
: new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY - offset.y + axis.offset));
|
||||
break;
|
||||
|
||||
case AxisName.Location.End:
|
||||
default:
|
||||
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisName, axisObj.transform,
|
||||
new Vector2(0, 0.5f),
|
||||
new Vector2(0, 0.5f),
|
||||
new Vector2(0, 0.5f),
|
||||
new Vector2(100, 20),
|
||||
axisNameTextStyle, chart.theme.axis);
|
||||
|
||||
axisName.SetAlignment(axisNameTextStyle.GetAlignment(TextAnchor.MiddleLeft));
|
||||
axisName.SetLocalPosition(axis.position == Axis.AxisPosition.Top
|
||||
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
|
||||
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleLeft);
|
||||
label.SetActive(axis.axisName.labelStyle.show);
|
||||
label.SetPosition(axis.position == Axis.AxisPosition.Top
|
||||
? new Vector2(axisStartX + axisLength + offset.x, axisStartY + relativedLength + offset.y + axis.offset)
|
||||
: new Vector2(axisStartX + axisLength + offset.x, zeroPos.y + offset.y + axis.offset));
|
||||
break;
|
||||
@@ -506,43 +442,39 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (axis.axisName.location)
|
||||
switch (axis.axisName.labelStyle.position)
|
||||
{
|
||||
case AxisName.Location.Start:
|
||||
case LabelStyle.Position.Start:
|
||||
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisName, axisObj.transform, new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), axisNameTextStyle,
|
||||
chart.theme.axis);
|
||||
axisName.SetAlignment(axisNameTextStyle.GetAlignment(TextAnchor.MiddleCenter));
|
||||
axisName.SetLocalPosition(axis.position == Axis.AxisPosition.Right ?
|
||||
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
|
||||
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
|
||||
label.SetActive(axis.axisName.labelStyle.show);
|
||||
label.SetPosition(axis.position == Axis.AxisPosition.Right ?
|
||||
new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY - offset.y) :
|
||||
new Vector2(zeroPos.x + offset.x + axis.offset, axisStartY - offset.y));
|
||||
break;
|
||||
|
||||
case AxisName.Location.Middle:
|
||||
case LabelStyle.Position.Middle:
|
||||
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisName, axisObj.transform, new Vector2(1, 0.5f),
|
||||
new Vector2(1, 0.5f), new Vector2(1, 0.5f), new Vector2(100, 20), axisNameTextStyle,
|
||||
chart.theme.axis);
|
||||
axisName.SetAlignment(axisNameTextStyle.GetAlignment(TextAnchor.MiddleRight));
|
||||
axisName.SetLocalPosition(axis.position == Axis.AxisPosition.Right ?
|
||||
new Vector2(axisStartX + relativedLength - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y) :
|
||||
new Vector2(axisStartX - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y));
|
||||
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
|
||||
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
|
||||
label.SetActive(axis.axisName.labelStyle.show);
|
||||
label.SetPosition(axis.position == Axis.AxisPosition.Right ?
|
||||
new Vector2(axisStartX + relativedLength - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y) :
|
||||
new Vector2(axisStartX - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y));
|
||||
break;
|
||||
|
||||
case AxisName.Location.End:
|
||||
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisName, axisObj.transform, new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), axisNameTextStyle,
|
||||
chart.theme.axis);
|
||||
axisName.SetAlignment(axisNameTextStyle.GetAlignment(TextAnchor.MiddleCenter));
|
||||
axisName.SetLocalPosition(axis.position == Axis.AxisPosition.Right ?
|
||||
default:
|
||||
//LabelStyle.Position
|
||||
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
|
||||
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
|
||||
label.SetActive(axis.axisName.labelStyle.show);
|
||||
label.SetPosition(axis.position == Axis.AxisPosition.Right ?
|
||||
new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY + axisLength + offset.y) :
|
||||
new Vector2(zeroPos.x + offset.x + axis.offset, axisStartY + axisLength + offset.y));
|
||||
break;
|
||||
}
|
||||
}
|
||||
axisName.SetText(axis.axisName.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,7 +505,7 @@ namespace XCharts
|
||||
else
|
||||
current += axisStartY - axis.axisLabel.distance - fontSize / 2;
|
||||
|
||||
return new Vector3(axisStartX + scaleWid, current) + axis.axisLabel.textStyle.offsetv3;
|
||||
return new Vector3(axisStartX + scaleWid, current);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -588,7 +520,7 @@ namespace XCharts
|
||||
else
|
||||
current += axisStartX - axis.axisLabel.distance;
|
||||
|
||||
return new Vector3(current, axisStartY + scaleWid) + axis.axisLabel.textStyle.offsetv3;
|
||||
return new Vector3(current, axisStartY + scaleWid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -403,33 +403,11 @@ namespace XCharts.Runtime
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void AdjustCircleLabelPos(ChartText txt, Vector3 pos, Vector3 cenPos, float txtHig, Vector3 offset)
|
||||
{
|
||||
var txtWidth = txt.GetPreferredWidth();
|
||||
var sizeDelta = new Vector2(txtWidth, txt.GetPreferredHeight());
|
||||
txt.SetSizeDelta(sizeDelta);
|
||||
var diff = pos.x - cenPos.x;
|
||||
if (diff < -1f) //left
|
||||
{
|
||||
pos = new Vector3(pos.x - txtWidth / 2, pos.y);
|
||||
}
|
||||
else if (diff > 1f) //right
|
||||
{
|
||||
pos = new Vector3(pos.x + txtWidth / 2, pos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
float y = pos.y > cenPos.y ? pos.y + txtHig / 2 : pos.y - txtHig / 2;
|
||||
pos = new Vector3(pos.x, y);
|
||||
}
|
||||
txt.SetLocalPosition(pos + offset);
|
||||
}
|
||||
|
||||
public static void AdjustCircleLabelPos(ChartLabel txt, Vector3 pos, Vector3 cenPos, float txtHig, Vector3 offset)
|
||||
{
|
||||
var txtWidth = txt.label.GetPreferredWidth();
|
||||
var sizeDelta = new Vector2(txtWidth, txt.label.GetPreferredHeight());
|
||||
txt.label.SetSizeDelta(sizeDelta);
|
||||
var txtWidth = txt.text.GetPreferredWidth();
|
||||
var sizeDelta = new Vector2(txtWidth, txt.text.GetPreferredHeight());
|
||||
txt.text.SetSizeDelta(sizeDelta);
|
||||
var diff = pos.x - cenPos.x;
|
||||
if (diff < -1f) //left
|
||||
{
|
||||
@@ -447,11 +425,11 @@ namespace XCharts.Runtime
|
||||
txt.SetPosition(pos + offset);
|
||||
}
|
||||
|
||||
public static void AdjustRadiusAxisLabelPos(ChartText txt, Vector3 pos, Vector3 cenPos, float txtHig, Vector3 offset)
|
||||
public static void AdjustRadiusAxisLabelPos(ChartLabel txt, Vector3 pos, Vector3 cenPos, float txtHig, Vector3 offset)
|
||||
{
|
||||
var txtWidth = txt.GetPreferredWidth();
|
||||
var sizeDelta = new Vector2(txtWidth, txt.GetPreferredHeight());
|
||||
txt.SetSizeDelta(sizeDelta);
|
||||
var txtWidth = txt.text.GetPreferredWidth();
|
||||
var sizeDelta = new Vector2(txtWidth, txt.text.GetPreferredHeight());
|
||||
txt.text.SetSizeDelta(sizeDelta);
|
||||
var diff = pos.y - cenPos.y;
|
||||
if (diff > 20f) //left
|
||||
{
|
||||
@@ -466,7 +444,7 @@ namespace XCharts.Runtime
|
||||
float y = pos.y > cenPos.y ? pos.y + txtHig / 2 : pos.y - txtHig / 2;
|
||||
pos = new Vector3(pos.x, y);
|
||||
}
|
||||
txt.SetLocalPosition(pos);
|
||||
txt.SetPosition(pos);
|
||||
}
|
||||
|
||||
public static float GetAxisPosition(GridCoord grid, Axis axis, double value, int dataCount = 0, DataZoom dataZoom = null)
|
||||
|
||||
@@ -10,33 +10,16 @@ namespace XCharts.Runtime
|
||||
/// |坐标轴刻度标签的相关设置。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AxisLabel : ChildComponent
|
||||
public class AxisLabel : LabelStyle
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private string m_Formatter;
|
||||
[SerializeField] private int m_Interval = 0;
|
||||
[SerializeField] private bool m_Inside = false;
|
||||
[SerializeField] private float m_Distance;
|
||||
[SerializeField] private string m_NumericFormatter = "";
|
||||
[SerializeField] private bool m_ShowAsPositiveNumber = false;
|
||||
[SerializeField] private bool m_OnZero = false;
|
||||
[SerializeField] private float m_Width = 0f;
|
||||
[SerializeField] private float m_Height = 0f;
|
||||
[SerializeField] private bool m_ShowStartLabel = true;
|
||||
[SerializeField] private bool m_ShowEndLabel = true;
|
||||
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
private AxisLabelFormatterFunction m_FormatterFunction;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis label from appearing.
|
||||
/// |是否显示刻度标签。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The display interval of the axis label.
|
||||
/// |坐标轴刻度标签的显示间隔,在类目轴中有效。0表示显示所有标签,1表示隔一个隔显示一个标签,以此类推。
|
||||
@@ -55,38 +38,6 @@ namespace XCharts.Runtime
|
||||
get { return m_Inside; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Inside, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The distance between the axis label and the axis line.
|
||||
/// |刻度标签与轴线之间的距离。
|
||||
/// </summary>
|
||||
public float distance
|
||||
{
|
||||
get { return m_Distance; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Distance, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图例内容字符串模版格式器。支持用 \n 换行。
|
||||
/// 模板变量为图例名称 {value}。
|
||||
/// </summary>
|
||||
public string formatter
|
||||
{
|
||||
get { return m_Formatter; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Standard numeric format strings.
|
||||
/// |标准数字格式字符串。用于将数值格式化显示为字符串。
|
||||
/// 使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。
|
||||
/// 参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string numericFormatter
|
||||
{
|
||||
get { return m_NumericFormatter; }
|
||||
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show negative number as positive number.
|
||||
/// |将负数数值显示为正数。一般和`Serie`的`showAsPositiveNumber`配合使用。
|
||||
@@ -106,22 +57,6 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_OnZero, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 文本的宽。为0时会自动匹配。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 文本的高。为0时会自动匹配。
|
||||
/// </summary>
|
||||
public float height
|
||||
{
|
||||
get { return m_Height; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to display the first label.
|
||||
/// |是否显示第一个文本。
|
||||
/// </summary>
|
||||
@@ -148,21 +83,6 @@ namespace XCharts.Runtime
|
||||
set { if (value != null) { m_TextLimit = value; SetComponentDirty(); } }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The text style of axis name.
|
||||
/// |文本样式。
|
||||
/// </summary>
|
||||
public TextStyle textStyle
|
||||
{
|
||||
get { return m_TextStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public AxisLabelFormatterFunction formatterFunction
|
||||
{
|
||||
set { m_FormatterFunction = value; }
|
||||
}
|
||||
|
||||
public override bool componentDirty { get { return m_ComponentDirty || m_TextLimit.componentDirty; } }
|
||||
public override void ClearComponentDirty()
|
||||
{
|
||||
@@ -185,7 +105,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public AxisLabel Clone()
|
||||
public new AxisLabel Clone()
|
||||
{
|
||||
var axisLabel = new AxisLabel();
|
||||
axisLabel.show = show;
|
||||
|
||||
@@ -11,21 +11,9 @@ namespace XCharts.Runtime
|
||||
[Serializable]
|
||||
public class AxisName : ChildComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// the location of axis name.
|
||||
/// |坐标轴名称显示位置。
|
||||
/// </summary>
|
||||
public enum Location
|
||||
{
|
||||
Start,
|
||||
Middle,
|
||||
End
|
||||
}
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private string m_Name;
|
||||
[SerializeField] private string m_Formatter;
|
||||
[SerializeField] private Location m_Location;
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show axis name.
|
||||
@@ -45,46 +33,28 @@ namespace XCharts.Runtime
|
||||
get { return m_Name; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Name, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The formatter of indicator's name.
|
||||
/// |指示器名称显示的格式器。可用在雷达图。
|
||||
/// </summary>
|
||||
public string formatter
|
||||
{
|
||||
get { return m_Formatter; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Location of axis name.
|
||||
/// |坐标轴名称显示位置。
|
||||
/// </summary>
|
||||
public Location location
|
||||
{
|
||||
get { return m_Location; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Location, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The text style of axis name.
|
||||
/// |文本样式。
|
||||
/// </summary>
|
||||
public TextStyle textStyle
|
||||
public LabelStyle labelStyle
|
||||
{
|
||||
get { return m_TextStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||
get { return m_LabelStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_LabelStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public static AxisName defaultAxisName
|
||||
{
|
||||
get
|
||||
{
|
||||
return new AxisName()
|
||||
var axisName = new AxisName()
|
||||
{
|
||||
m_Show = false,
|
||||
m_Name = "axisName",
|
||||
m_Location = Location.End,
|
||||
m_TextStyle = new TextStyle(),
|
||||
m_LabelStyle = new LabelStyle()
|
||||
};
|
||||
axisName.labelStyle.position = LabelStyle.Position.End;
|
||||
return axisName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,8 +63,7 @@ namespace XCharts.Runtime
|
||||
var axisName = new AxisName();
|
||||
axisName.show = show;
|
||||
axisName.name = name;
|
||||
axisName.location = location;
|
||||
axisName.textStyle.Copy(textStyle);
|
||||
axisName.m_LabelStyle.Copy(m_LabelStyle);
|
||||
return axisName;
|
||||
}
|
||||
|
||||
@@ -102,8 +71,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
show = axisName.show;
|
||||
name = axisName.name;
|
||||
location = axisName.location;
|
||||
textStyle.Copy(axisName.textStyle);
|
||||
m_LabelStyle.Copy(axisName.labelStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ namespace XCharts.Runtime
|
||||
splitLine.show = false;
|
||||
splitLine.lineStyle.type = LineStyle.Type.None;
|
||||
axisLabel.textLimit.enable = true;
|
||||
iconStyle.show = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -109,18 +109,17 @@ namespace XCharts.Runtime
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
|
||||
var labelName = AxisHelper.GetLabelName(axis, radius, i, axis.context.minValue, axis.context.maxValue,
|
||||
null, isPercentStack);
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform, new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(labelWidth, txtHig), axis, chart.theme.axis,
|
||||
labelName);
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
|
||||
new Vector2(labelWidth, txtHig), axis, chart.theme.axis, labelName, Color.clear);
|
||||
|
||||
if (i == 0)
|
||||
axis.axisLabel.SetRelatedText(label.label, labelWidth);
|
||||
axis.axisLabel.SetRelatedText(label.text, labelWidth);
|
||||
|
||||
label.label.SetAlignment(textStyle.GetAlignment(TextAnchor.MiddleCenter));
|
||||
label.text.SetAlignment(textStyle.GetAlignment(TextAnchor.MiddleCenter));
|
||||
label.SetText(labelName);
|
||||
label.SetPosition(GetLabelPosition(polar, axis, angleAxis.context.startAngle, totalWidth));
|
||||
label.SetActive(true);
|
||||
label.SetLabelActive(true);
|
||||
label.SetTextActive(true);
|
||||
|
||||
axis.context.labelObjectList.Add(label);
|
||||
|
||||
|
||||
@@ -140,7 +140,6 @@ namespace XCharts.Runtime
|
||||
axisLabel.textLimit.enable = true;
|
||||
axisTick.showStartTick = true;
|
||||
axisTick.showEndTick = true;
|
||||
iconStyle.show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ namespace XCharts.Runtime
|
||||
splitLine.show = false;
|
||||
splitLine.lineStyle.type = LineStyle.Type.None;
|
||||
axisLabel.textLimit.enable = true;
|
||||
iconStyle.show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ namespace XCharts.Runtime
|
||||
splitLine.lineStyle.type = LineStyle.Type.None;
|
||||
axisLabel.textLimit.enable = false;
|
||||
axisTick.showStartTick = true;
|
||||
iconStyle.show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user