mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-18 22:40:10 +00:00
增加AxisLabel配置坐标轴刻度标签
This commit is contained in:
@@ -76,6 +76,7 @@ namespace XCharts
|
||||
[SerializeField] private float m_Rotate;
|
||||
[SerializeField] private Color m_Color;
|
||||
[SerializeField] private int m_FontSize;
|
||||
[SerializeField] private FontStyle m_FontStyle;
|
||||
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
public string name { get { return m_Name; } set { m_Name = value; } }
|
||||
@@ -84,6 +85,7 @@ namespace XCharts
|
||||
public float rotate { get { return m_Rotate; } set { m_Rotate = value; } }
|
||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
||||
|
||||
public static AxisName defaultAxisName
|
||||
{
|
||||
@@ -97,7 +99,8 @@ namespace XCharts
|
||||
m_Gap = 5,
|
||||
m_Rotate = 0,
|
||||
m_Color = Color.clear,
|
||||
m_FontSize = 18
|
||||
m_FontSize = 18,
|
||||
m_FontStyle = FontStyle.Normal
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -111,6 +114,7 @@ namespace XCharts
|
||||
m_Rotate = other.rotate;
|
||||
m_Color = other.color;
|
||||
m_FontSize = other.fontSize;
|
||||
m_FontStyle = other.fontStyle;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
@@ -126,7 +130,8 @@ namespace XCharts
|
||||
m_Gap == other.gap &&
|
||||
m_Rotate == other.rotate &&
|
||||
m_Color == other.color &&
|
||||
m_FontSize == other.fontSize;
|
||||
m_FontSize == other.fontSize &&
|
||||
m_FontStyle == other.fontStyle;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
@@ -172,25 +177,99 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public Color getColor(int index){
|
||||
public Color getColor(int index)
|
||||
{
|
||||
var i = index % color.Count;
|
||||
return color[i];
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class AxisLabel
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private int m_Interval;
|
||||
[SerializeField] private bool m_Inside;
|
||||
[SerializeField] private float m_Rotate;
|
||||
[SerializeField] private float m_Margin;
|
||||
[SerializeField] private Color m_Color;
|
||||
[SerializeField] private int m_FontSize;
|
||||
[SerializeField] private FontStyle m_FontStyle;
|
||||
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
public int interval { get { return m_Interval; } set { m_Interval = value; } }
|
||||
public bool inside { get { return m_Inside; } set { m_Inside = value; } }
|
||||
public float rotate { get { return m_Rotate; } set { m_Rotate = value; } }
|
||||
public float margin { get { return m_Margin; } set { m_Margin = value; } }
|
||||
public Color color { get { return m_Color; } set { m_Color = value; } }
|
||||
public int fontSize { get { return m_FontSize; } set { m_FontSize = value; } }
|
||||
public FontStyle fontStyle { get { return m_FontStyle; } set { m_FontStyle = value; } }
|
||||
|
||||
public static AxisLabel defaultAxisLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return new AxisLabel()
|
||||
{
|
||||
m_Show = true,
|
||||
m_Interval = 0,
|
||||
m_Inside = false,
|
||||
m_Rotate = 0,
|
||||
m_Margin = 8,
|
||||
m_Color = Color.clear,
|
||||
m_FontSize = 18,
|
||||
m_FontStyle = FontStyle.Normal
|
||||
};
|
||||
}
|
||||
}
|
||||
public void Copy(AxisLabel other)
|
||||
{
|
||||
m_Show = other.show;
|
||||
m_Interval = other.interval;
|
||||
m_Inside = other.inside;
|
||||
m_Rotate = other.rotate;
|
||||
m_Margin = other.margin;
|
||||
m_Color = other.color;
|
||||
m_FontSize = other.fontSize;
|
||||
m_FontStyle = other.fontStyle;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var other = (AxisLabel)obj;
|
||||
return m_Show == other.show &&
|
||||
m_Interval.Equals(other.interval) &&
|
||||
m_Inside == other.inside &&
|
||||
m_Rotate == other.rotate &&
|
||||
m_Margin == other.margin &&
|
||||
m_Color == other.color &&
|
||||
m_FontSize == other.fontSize &&
|
||||
m_FontStyle == other.fontStyle;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] protected bool m_Show = true;
|
||||
[SerializeField] protected AxisType m_Type;
|
||||
[SerializeField] protected AxisMinMaxType m_MinMaxType;
|
||||
[SerializeField] protected int m_Min;
|
||||
[SerializeField] protected int m_Max;
|
||||
[SerializeField] protected int m_SplitNumber = 5;
|
||||
[SerializeField] protected int m_TextRotation = 0;
|
||||
[SerializeField] protected bool m_ShowSplitLine = false;
|
||||
[SerializeField] protected SplitLineType m_SplitLineType = SplitLineType.Dashed;
|
||||
[SerializeField] protected bool m_BoundaryGap = true;
|
||||
[SerializeField] protected List<string> m_Data = new List<string>();
|
||||
[SerializeField] protected AxisName m_AxisName = AxisName.defaultAxisName;
|
||||
[SerializeField] protected AxisTick m_AxisTick = AxisTick.defaultTick;
|
||||
[SerializeField] protected AxisLabel m_AxisLabel = AxisLabel.defaultAxisLabel;
|
||||
[SerializeField] protected SplitArea m_SplitArea = SplitArea.defaultSplitArea;
|
||||
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
@@ -199,7 +278,6 @@ namespace XCharts
|
||||
public int min { get { return m_Min; } set { m_Min = value; } }
|
||||
public int max { get { return m_Max; } set { m_Max = value; } }
|
||||
public int splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
|
||||
public int textRotation { get { return m_TextRotation; } set { m_TextRotation = value; } }
|
||||
public bool showSplitLine { get { return m_ShowSplitLine; } set { m_ShowSplitLine = value; } }
|
||||
public SplitLineType splitLineType { get { return m_SplitLineType; } set { m_SplitLineType = value; } }
|
||||
public bool boundaryGap { get { return m_BoundaryGap; } set { m_BoundaryGap = value; } }
|
||||
@@ -207,6 +285,7 @@ namespace XCharts
|
||||
|
||||
public AxisName axisName { get { return m_AxisName; } set { m_AxisName = value; } }
|
||||
public AxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
|
||||
public AxisLabel axisLabel { get { return m_AxisLabel; } set { m_AxisLabel = value; } }
|
||||
public SplitArea splitArea { get { return m_SplitArea; } set { m_SplitArea = value; } }
|
||||
|
||||
public int filterStart { get; set; }
|
||||
@@ -220,11 +299,12 @@ namespace XCharts
|
||||
m_Min = other.min;
|
||||
m_Max = other.max;
|
||||
m_SplitNumber = other.splitNumber;
|
||||
m_TextRotation = other.textRotation;
|
||||
|
||||
m_ShowSplitLine = other.showSplitLine;
|
||||
m_SplitLineType = other.splitLineType;
|
||||
m_BoundaryGap = other.boundaryGap;
|
||||
m_AxisName.Copy(other.axisName);
|
||||
m_AxisLabel.Copy(other.axisLabel);
|
||||
m_Data.Clear();
|
||||
foreach (var d in other.data) m_Data.Add(d);
|
||||
}
|
||||
@@ -405,7 +485,7 @@ namespace XCharts
|
||||
max == other.max &&
|
||||
splitNumber == other.splitNumber &&
|
||||
showSplitLine == other.showSplitLine &&
|
||||
textRotation == other.textRotation &&
|
||||
m_AxisLabel.Equals(other.axisLabel) &&
|
||||
splitLineType == other.splitLineType &&
|
||||
boundaryGap == other.boundaryGap &&
|
||||
axisName.Equals(other.axisName) &&
|
||||
@@ -456,7 +536,6 @@ namespace XCharts
|
||||
m_Min = 0,
|
||||
m_Max = 0,
|
||||
m_SplitNumber = 5,
|
||||
m_TextRotation = 0,
|
||||
m_ShowSplitLine = false,
|
||||
m_SplitLineType = SplitLineType.Dashed,
|
||||
m_BoundaryGap = true,
|
||||
@@ -484,7 +563,6 @@ namespace XCharts
|
||||
m_Min = 0,
|
||||
m_Max = 0,
|
||||
m_SplitNumber = 5,
|
||||
m_TextRotation = 0,
|
||||
m_ShowSplitLine = false,
|
||||
m_SplitLineType = SplitLineType.Dashed,
|
||||
m_BoundaryGap = false,
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace XCharts
|
||||
private XAxis m_CheckXAxis = XAxis.defaultXAxis;
|
||||
private YAxis m_CheckYAxis = YAxis.defaultYAxis;
|
||||
private Coordinate m_CheckCoordinate = Coordinate.defaultCoordinate;
|
||||
private List<Text> m_SplitYTextList = new List<Text>();
|
||||
private List<Text> m_AxisLabelYTextList = new List<Text>();
|
||||
private List<Text> m_SplitXTextList = new List<Text>();
|
||||
|
||||
public int minValue { get; private set; }
|
||||
@@ -47,8 +47,8 @@ namespace XCharts
|
||||
base.Awake();
|
||||
CheckMinMaxValue();
|
||||
InitDataZoom();
|
||||
InitSplitX();
|
||||
InitSplitY();
|
||||
InitAxisX();
|
||||
InitAxisY();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@@ -68,8 +68,8 @@ namespace XCharts
|
||||
m_Coordinate = Coordinate.defaultCoordinate;
|
||||
m_XAxis = XAxis.defaultXAxis;
|
||||
m_YAxis = YAxis.defaultYAxis;
|
||||
InitSplitX();
|
||||
InitSplitY();
|
||||
InitAxisX();
|
||||
InitAxisY();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -226,8 +226,8 @@ namespace XCharts
|
||||
{
|
||||
base.OnThemeChanged();
|
||||
InitDataZoom();
|
||||
InitSplitX();
|
||||
InitSplitY();
|
||||
InitAxisX();
|
||||
InitAxisY();
|
||||
}
|
||||
|
||||
public void AddXAxisData(string category)
|
||||
@@ -242,27 +242,44 @@ namespace XCharts
|
||||
OnYAxisChanged();
|
||||
}
|
||||
|
||||
private void InitSplitY()
|
||||
private void InitAxisY()
|
||||
{
|
||||
m_SplitYTextList.Clear();
|
||||
m_AxisLabelYTextList.Clear();
|
||||
ChartHelper.HideAllObject(gameObject, "split_y");//old name
|
||||
float splitWidth = m_YAxis.GetScaleWidth(coordinateHig, m_DataZoom);
|
||||
float labelWidth = m_YAxis.GetScaleWidth(coordinateHig, m_DataZoom);
|
||||
|
||||
var axisObj = ChartHelper.AddObject(s_DefaultAxisY, transform, chartAnchorMin,
|
||||
chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
||||
axisObj.transform.localPosition = Vector3.zero;
|
||||
axisObj.SetActive(m_YAxis.axisLabel.show);
|
||||
ChartHelper.HideAllObject(axisObj, s_DefaultAxisY);
|
||||
|
||||
var labelColor = m_YAxis.axisLabel.color == Color.clear ?
|
||||
(Color)m_ThemeInfo.axisTextColor :
|
||||
m_YAxis.axisLabel.color;
|
||||
for (int i = 0; i < m_YAxis.GetSplitNumber(m_DataZoom); i++)
|
||||
{
|
||||
Text txt = ChartHelper.AddTextObject(s_DefaultAxisY + i, axisObj.transform,
|
||||
m_ThemeInfo.font, m_ThemeInfo.axisTextColor, TextAnchor.MiddleRight, Vector2.zero,
|
||||
Vector2.zero, new Vector2(1, 0.5f), new Vector2(m_Coordinate.left, 20),
|
||||
m_Coordinate.fontSize, m_XAxis.textRotation);
|
||||
txt.transform.localPosition = GetSplitYPosition(splitWidth, i);
|
||||
Text txt;
|
||||
if (m_YAxis.axisLabel.inside)
|
||||
{
|
||||
txt = ChartHelper.AddTextObject(s_DefaultAxisY + i, axisObj.transform,
|
||||
m_ThemeInfo.font, labelColor, TextAnchor.MiddleLeft, Vector2.zero,
|
||||
Vector2.zero, new Vector2(0, 0.5f), new Vector2(m_Coordinate.left, 20),
|
||||
m_YAxis.axisLabel.fontSize, m_YAxis.axisLabel.rotate, m_YAxis.axisLabel.fontStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
txt = ChartHelper.AddTextObject(s_DefaultAxisY + i, axisObj.transform,
|
||||
m_ThemeInfo.font, labelColor, TextAnchor.MiddleRight, Vector2.zero,
|
||||
Vector2.zero, new Vector2(1, 0.5f), new Vector2(m_Coordinate.left, 20),
|
||||
m_YAxis.axisLabel.fontSize, m_YAxis.axisLabel.rotate, m_YAxis.axisLabel.fontStyle);
|
||||
}
|
||||
|
||||
txt.transform.localPosition = GetLabelYPosition(labelWidth, i, m_YAxis.axisLabel.inside);
|
||||
txt.text = m_YAxis.GetScaleName(i, minValue, maxValue, m_DataZoom);
|
||||
txt.gameObject.SetActive(m_YAxis.show);
|
||||
m_SplitYTextList.Add(txt);
|
||||
txt.gameObject.SetActive(m_YAxis.show &&
|
||||
(m_YAxis.axisLabel.interval == 0 || i % (m_YAxis.axisLabel.interval + 1) == 0));
|
||||
m_AxisLabelYTextList.Add(txt);
|
||||
}
|
||||
if (m_YAxis.axisName.show)
|
||||
{
|
||||
@@ -277,14 +294,14 @@ namespace XCharts
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisX + "_name", axisObj.transform,
|
||||
m_ThemeInfo.font, color, TextAnchor.MiddleCenter, new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), fontSize,
|
||||
m_YAxis.axisName.rotate);
|
||||
m_YAxis.axisName.rotate, m_YAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = new Vector2(coordinateX, coordinateY - gap);
|
||||
break;
|
||||
case Axis.AxisName.Location.Middle:
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisX + "_name", axisObj.transform,
|
||||
m_ThemeInfo.font, color, TextAnchor.MiddleRight, new Vector2(1, 0.5f),
|
||||
new Vector2(1, 0.5f), new Vector2(1, 0.5f), new Vector2(100, 20), fontSize,
|
||||
m_YAxis.axisName.rotate);
|
||||
m_YAxis.axisName.rotate, m_YAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = new Vector2(coordinateX - gap,
|
||||
coordinateY + coordinateHig / 2);
|
||||
break;
|
||||
@@ -292,7 +309,7 @@ namespace XCharts
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisX + "_name", axisObj.transform,
|
||||
m_ThemeInfo.font, color, TextAnchor.MiddleCenter, new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), fontSize,
|
||||
m_YAxis.axisName.rotate);
|
||||
m_YAxis.axisName.rotate, m_YAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = new Vector2(coordinateX,
|
||||
coordinateY + coordinateHig + gap);
|
||||
break;
|
||||
@@ -300,26 +317,31 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private void InitSplitX()
|
||||
private void InitAxisX()
|
||||
{
|
||||
m_SplitXTextList.Clear();
|
||||
ChartHelper.HideAllObject(gameObject, "split_x");//old name
|
||||
float splitWidth = m_XAxis.GetScaleWidth(coordinateWid, m_DataZoom);
|
||||
float labelWidth = m_XAxis.GetScaleWidth(coordinateWid, m_DataZoom);
|
||||
|
||||
var axisObj = ChartHelper.AddObject(s_DefaultAxisX, transform, chartAnchorMin,
|
||||
chartAnchorMax, chartPivot, new Vector2(chartWidth, chartHeight));
|
||||
axisObj.transform.localPosition = Vector3.zero;
|
||||
axisObj.SetActive(m_XAxis.axisLabel.show);
|
||||
ChartHelper.HideAllObject(axisObj, s_DefaultAxisX);
|
||||
var labelColor = m_XAxis.axisLabel.color == Color.clear ?
|
||||
(Color)m_ThemeInfo.axisTextColor :
|
||||
m_XAxis.axisLabel.color;
|
||||
for (int i = 0; i < m_XAxis.GetSplitNumber(m_DataZoom); i++)
|
||||
{
|
||||
Text txt = ChartHelper.AddTextObject(s_DefaultAxisX + i, axisObj.transform,
|
||||
m_ThemeInfo.font, m_ThemeInfo.axisTextColor, TextAnchor.MiddleCenter, Vector2.zero,
|
||||
Vector2.zero, new Vector2(1, 0.5f), new Vector2(splitWidth, 20),
|
||||
m_Coordinate.fontSize, m_XAxis.textRotation);
|
||||
m_ThemeInfo.font, labelColor, TextAnchor.MiddleCenter, new Vector2(0, 1),
|
||||
new Vector2(0, 1), new Vector2(1, 0.5f), new Vector2(labelWidth, 20),
|
||||
m_XAxis.axisLabel.fontSize, m_XAxis.axisLabel.rotate, m_XAxis.axisLabel.fontStyle);
|
||||
|
||||
txt.transform.localPosition = GetSplitXPosition(splitWidth, i);
|
||||
txt.transform.localPosition = GetLabelXPosition(labelWidth, i, m_XAxis.axisLabel.inside);
|
||||
txt.text = m_XAxis.GetScaleName(i, minValue, maxValue, m_DataZoom);
|
||||
txt.gameObject.SetActive(m_XAxis.show);
|
||||
txt.gameObject.SetActive(m_XAxis.show &&
|
||||
(m_XAxis.axisLabel.interval == 0 || i % (m_XAxis.axisLabel.interval + 1) == 0));
|
||||
m_SplitXTextList.Add(txt);
|
||||
}
|
||||
if (m_XAxis.axisName.show)
|
||||
@@ -335,14 +357,14 @@ namespace XCharts
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisX + "_name", axisObj.transform,
|
||||
m_ThemeInfo.font, color, TextAnchor.MiddleRight, new Vector2(1, 0.5f),
|
||||
new Vector2(1, 0.5f), new Vector2(1, 0.5f), new Vector2(100, 20), fontSize,
|
||||
m_XAxis.axisName.rotate);
|
||||
m_XAxis.axisName.rotate, m_XAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = new Vector2(coordinateX - gap, coordinateY);
|
||||
break;
|
||||
case Axis.AxisName.Location.Middle:
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisX + "_name", axisObj.transform,
|
||||
m_ThemeInfo.font, color, TextAnchor.MiddleCenter, new Vector2(0.5f, 0.5f),
|
||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(100, 20), fontSize,
|
||||
m_XAxis.axisName.rotate);
|
||||
m_XAxis.axisName.rotate, m_XAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = new Vector2(coordinateX + coordinateWid / 2,
|
||||
coordinateY - gap);
|
||||
break;
|
||||
@@ -350,7 +372,7 @@ namespace XCharts
|
||||
axisName = ChartHelper.AddTextObject(s_DefaultAxisX + "_name", axisObj.transform,
|
||||
m_ThemeInfo.font, color, TextAnchor.MiddleLeft, new Vector2(0, 0.5f),
|
||||
new Vector2(0, 0.5f), new Vector2(0, 0.5f), new Vector2(100, 20), fontSize,
|
||||
m_XAxis.axisName.rotate);
|
||||
m_XAxis.axisName.rotate, m_XAxis.axisName.fontStyle);
|
||||
axisName.transform.localPosition = new Vector2(coordinateX + coordinateWid + gap,
|
||||
coordinateY);
|
||||
break;
|
||||
@@ -382,31 +404,33 @@ namespace XCharts
|
||||
raycastTarget = m_DataZoom.show;
|
||||
}
|
||||
|
||||
private Vector3 GetSplitYPosition(float scaleWid, int i)
|
||||
private Vector3 GetLabelYPosition(float scaleWid, int i, bool inside)
|
||||
{
|
||||
var posX = inside ?
|
||||
coordinateX + m_YAxis.axisLabel.margin :
|
||||
coordinateX - m_YAxis.axisLabel.margin;
|
||||
if (m_YAxis.boundaryGap)
|
||||
{
|
||||
return new Vector3(coordinateX - m_YAxis.axisTick.length - 2f,
|
||||
coordinateY + (i + 0.5f) * scaleWid, 0);
|
||||
return new Vector3(posX, coordinateY + (i + 0.5f) * scaleWid, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Vector3(coordinateX - m_YAxis.axisTick.length - 2f,
|
||||
coordinateY + i * scaleWid, 0);
|
||||
return new Vector3(posX, coordinateY + i * scaleWid, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 GetSplitXPosition(float scaleWid, int i)
|
||||
private Vector3 GetLabelXPosition(float scaleWid, int i, bool inside)
|
||||
{
|
||||
var posY = inside ?
|
||||
coordinateY + m_XAxis.axisLabel.margin + m_XAxis.axisLabel.fontSize / 2 :
|
||||
coordinateY - m_XAxis.axisLabel.margin - m_XAxis.axisLabel.fontSize / 2;
|
||||
if (m_XAxis.boundaryGap)
|
||||
{
|
||||
return new Vector3(coordinateX + (i + 1) * scaleWid,
|
||||
coordinateY - m_XAxis.axisTick.length - 12, 0);
|
||||
return new Vector3(coordinateX + (i + 1) * scaleWid, posY);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Vector3(coordinateX + (i + 1 - 0.5f) * scaleWid,
|
||||
coordinateY - m_XAxis.axisTick.length - 12, 0);
|
||||
return new Vector3(coordinateX + (i + 1 - 0.5f) * scaleWid, posY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,18 +527,18 @@ namespace XCharts
|
||||
|
||||
protected virtual void OnCoordinateChanged()
|
||||
{
|
||||
InitSplitX();
|
||||
InitSplitY();
|
||||
InitAxisX();
|
||||
InitAxisY();
|
||||
}
|
||||
|
||||
protected virtual void OnYAxisChanged()
|
||||
{
|
||||
InitSplitY();
|
||||
InitAxisY();
|
||||
}
|
||||
|
||||
protected virtual void OnXAxisChanged()
|
||||
{
|
||||
InitSplitX();
|
||||
InitAxisX();
|
||||
}
|
||||
|
||||
protected override void OnSizeChanged()
|
||||
@@ -522,15 +546,15 @@ namespace XCharts
|
||||
base.OnSizeChanged();
|
||||
minValue = 0;
|
||||
maxValue = 100;
|
||||
InitSplitX();
|
||||
InitSplitY();
|
||||
InitAxisX();
|
||||
InitAxisY();
|
||||
}
|
||||
|
||||
protected override void OnYMaxValueChanged()
|
||||
{
|
||||
for (int i = 0; i < m_SplitYTextList.Count; i++)
|
||||
for (int i = 0; i < m_AxisLabelYTextList.Count; i++)
|
||||
{
|
||||
m_SplitYTextList[i].text = m_YAxis.GetScaleName(i, minValue, maxValue, m_DataZoom);
|
||||
m_AxisLabelYTextList[i].text = m_YAxis.GetScaleName(i, minValue, maxValue, m_DataZoom);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,7 +591,8 @@ namespace XCharts
|
||||
}
|
||||
if (m_YAxis.axisTick.show)
|
||||
{
|
||||
pX += zeroX - m_YAxis.axisTick.length - 2;
|
||||
pX += zeroX - (m_YAxis.axisTick.inside ? -m_YAxis.axisTick.length :
|
||||
m_YAxis.axisTick.length);
|
||||
ChartHelper.DrawLine(vh, new Vector3(zeroX, pY), new Vector3(pX, pY),
|
||||
m_Coordinate.tickness, m_ThemeInfo.axisLineColor);
|
||||
}
|
||||
@@ -600,7 +625,8 @@ namespace XCharts
|
||||
}
|
||||
if (m_XAxis.axisTick.show)
|
||||
{
|
||||
pY += zeroY - m_XAxis.axisTick.length - 2;
|
||||
pY += zeroY + (m_XAxis.axisTick.inside ? m_XAxis.axisTick.length :
|
||||
-m_XAxis.axisTick.length);
|
||||
ChartHelper.DrawLine(vh, new Vector3(pX, zeroY), new Vector3(pX, pY),
|
||||
m_Coordinate.tickness, m_ThemeInfo.axisLineColor);
|
||||
}
|
||||
@@ -861,7 +887,7 @@ namespace XCharts
|
||||
m_DataZoom.SetStartLabelText(xAxis.data[startIndex]);
|
||||
m_DataZoom.SetEndLabelText(xAxis.data[endIndex]);
|
||||
}
|
||||
InitSplitX();
|
||||
InitAxisX();
|
||||
}
|
||||
|
||||
var start = coordinateX + coordinateWid * m_DataZoom.start / 100;
|
||||
|
||||
Reference in New Issue
Block a user