mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 01:40:06 +00:00
增加Axis的图标、自动换行、自定义长宽的支持
This commit is contained in:
@@ -424,6 +424,28 @@ namespace XCharts
|
||||
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 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.SetPosition(pos + offset);
|
||||
}
|
||||
|
||||
public static void AdjustRadiusAxisLabelPos(ChartText txt, Vector3 pos, Vector3 cenPos, float txtHig, Vector3 offset)
|
||||
{
|
||||
var txtWidth = txt.GetPreferredWidth();
|
||||
|
||||
Reference in New Issue
Block a user