mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 06:50:18 +00:00
[feature][axis] support AxisName.onZero (#207)
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
|
||||
## master
|
||||
|
||||
* (2022.07.05) 增加`AxisName`的`onZero`参数支持设置坐标轴名称位置是否和Y轴0刻度一致 (#207)
|
||||
* (2022.07.02) 修复`PieChart`用代码动态创建时`Legend`不正常的问题 (#206)
|
||||
* (2022.07.02) 修复`YAxis`的`AxisLabel`设置`onZero`不生效的问题
|
||||
* (2022.07.02) 修复`AxisLabel`代码设置`distance`属性后一直刷新的问题
|
||||
|
||||
@@ -181,6 +181,7 @@ namespace XCharts.Editor
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_Name");
|
||||
PropertyField(prop, "m_OnZero");
|
||||
PropertyField(prop, "m_LabelStyle");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
|
||||
@@ -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