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

@@ -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;
}