mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 16:00:24 +00:00
[feature][axis] support AxisName.onZero (#207)
This commit is contained in:
@@ -424,7 +424,8 @@ namespace XCharts
|
||||
var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor);
|
||||
if (orient == Orient.Horizonal)
|
||||
{
|
||||
var posY = GetAxisLineXOrY() + offset.y;
|
||||
var grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
|
||||
var posY = !axis.axisName.onZero && grid != null? grid.context.y : GetAxisLineXOrY() + offset.y;
|
||||
switch (axis.axisName.labelStyle.position)
|
||||
{
|
||||
case LabelStyle.Position.Start:
|
||||
@@ -460,7 +461,8 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
var posX = GetAxisLineXOrY() + offset.x;
|
||||
var grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
|
||||
var posX = !axis.axisName.onZero && grid != null? grid.context.x : GetAxisLineXOrY() + offset.x;
|
||||
switch (axis.axisName.labelStyle.position)
|
||||
{
|
||||
case LabelStyle.Position.Start:
|
||||
|
||||
@@ -12,11 +12,12 @@ namespace XCharts.Runtime
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private string m_Name;
|
||||
[SerializeField][Since("v3.1.0")] private bool m_OnZero;
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show axis name.
|
||||
/// |是否显示坐标名称。
|
||||
/// |是否显示坐标轴名称。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
@@ -33,6 +34,15 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetClass(ref m_Name, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the axis name position are the same with 0 position of YAxis.
|
||||
/// |坐标轴名称的位置是否保持和Y轴0刻度一致。
|
||||
/// </summary>
|
||||
public bool onZero
|
||||
{
|
||||
get { return m_OnZero; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_OnZero, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The text style of axis name.
|
||||
/// |文本样式。
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user