mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 12:08:46 +00:00
[bug][axis] fix showStartLabel and showEndLabel not work
This commit is contained in:
@@ -57,6 +57,7 @@
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2022.07.20) 修复`Axis`在`Value`轴时,`AxisLabel`的`showStartLabel`和`showEndLabel`参数设置不生效的问题
|
||||||
* (2022.07.19) 增加`Axis`的`MinorSplitLine`设置坐标轴次分割线
|
* (2022.07.19) 增加`Axis`的`MinorSplitLine`设置坐标轴次分割线
|
||||||
* (2022.07.19) 增加`Axis`的`MinorTick`设置坐标轴次刻度
|
* (2022.07.19) 增加`Axis`的`MinorTick`设置坐标轴次刻度
|
||||||
* (2022.07.17) 增加`Radar`的`smooth`参数设置平滑曲线
|
* (2022.07.17) 增加`Radar`的`smooth`参数设置平滑曲线
|
||||||
|
|||||||
@@ -555,6 +555,21 @@ namespace XCharts.Runtime
|
|||||||
return m_Position == AxisPosition.Bottom;
|
return m_Position == AxisPosition.Bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsNeedShowLabel(int index, int total = 0)
|
||||||
|
{
|
||||||
|
if (total == 0)
|
||||||
|
{
|
||||||
|
total = context.labelValueList.Count;
|
||||||
|
}
|
||||||
|
var labelShow = axisLabel.show && (axisLabel.interval == 0 || index % (axisLabel.interval + 1) == 0);
|
||||||
|
if (labelShow)
|
||||||
|
{
|
||||||
|
if (!axisLabel.showStartLabel && index == 0) labelShow = false;
|
||||||
|
else if (!axisLabel.showEndLabel && index == total - 1) labelShow = false;
|
||||||
|
}
|
||||||
|
return labelShow;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetNeedUpdateFilterData()
|
public void SetNeedUpdateFilterData()
|
||||||
{
|
{
|
||||||
context.isNeedUpdateFilterData = true;
|
context.isNeedUpdateFilterData = true;
|
||||||
@@ -831,7 +846,7 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public void UpdateZeroOffset(float axisLength)
|
public void UpdateZeroOffset(float axisLength)
|
||||||
{
|
{
|
||||||
context.offset = context.minValue > 0 || context.minMaxRange == 0?
|
context.offset = context.minValue > 0 || context.minMaxRange == 0 ?
|
||||||
0 :
|
0 :
|
||||||
(context.maxValue < 0 ?
|
(context.maxValue < 0 ?
|
||||||
axisLength :
|
axisLength :
|
||||||
|
|||||||
@@ -296,12 +296,12 @@ namespace XCharts
|
|||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
var dist = GetLabelPosition(0, 1).x - pos.x;
|
var dist = GetLabelPosition(0, 1).x - pos.x;
|
||||||
label.SetTextActive(dist > label.text.GetPreferredWidth());
|
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredWidth());
|
||||||
}
|
}
|
||||||
else if (i == axis.context.labelValueList.Count - 1)
|
else if (i == axis.context.labelValueList.Count - 1)
|
||||||
{
|
{
|
||||||
var dist = pos.x - GetLabelPosition(0, i - 1).x;
|
var dist = pos.x - GetLabelPosition(0, i - 1).x;
|
||||||
label.SetTextActive(dist > label.text.GetPreferredWidth());
|
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredWidth());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -309,12 +309,12 @@ namespace XCharts
|
|||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
var dist = GetLabelPosition(0, 1).y - pos.y;
|
var dist = GetLabelPosition(0, 1).y - pos.y;
|
||||||
label.SetTextActive(dist > label.text.GetPreferredHeight());
|
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredHeight());
|
||||||
}
|
}
|
||||||
else if (i == axis.context.labelValueList.Count - 1)
|
else if (i == axis.context.labelValueList.Count - 1)
|
||||||
{
|
{
|
||||||
var dist = pos.y - GetLabelPosition(0, i - 1).y;
|
var dist = pos.y - GetLabelPosition(0, i - 1).y;
|
||||||
label.SetTextActive(dist > label.text.GetPreferredHeight());
|
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
|
||||||
UpdateAxisMinMaxValue(component.index, component);
|
UpdateAxisMinMaxValue(component.index, component);
|
||||||
UpdatePointerValue(component);
|
UpdatePointerValue(component);
|
||||||
}
|
}
|
||||||
@@ -31,7 +30,7 @@ namespace XCharts.Runtime
|
|||||||
private void UpdatePosition(XAxis axis)
|
private void UpdatePosition(XAxis axis)
|
||||||
{
|
{
|
||||||
var grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
|
var grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
|
||||||
if (grid != null && axis is XAxis && axis.IsValue())
|
if (grid != null)
|
||||||
{
|
{
|
||||||
var relativedAxis = chart.GetChartComponent<YAxis>(axis.gridIndex);
|
var relativedAxis = chart.GetChartComponent<YAxis>(axis.gridIndex);
|
||||||
axis.context.x = grid.context.x;
|
axis.context.x = grid.context.x;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace XCharts.Runtime
|
|||||||
private void UpdatePosition(YAxis axis)
|
private void UpdatePosition(YAxis axis)
|
||||||
{
|
{
|
||||||
var grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
|
var grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
|
||||||
if (grid != null && axis.IsValue())
|
if (grid != null)
|
||||||
{
|
{
|
||||||
var relativedAxis = chart.GetChartComponent<XAxis>(axis.gridIndex);
|
var relativedAxis = chart.GetChartComponent<XAxis>(axis.gridIndex);
|
||||||
axis.context.x = AxisHelper.GetYAxisXOrY(grid, axis, relativedAxis);
|
axis.context.x = AxisHelper.GetYAxisXOrY(grid, axis, relativedAxis);
|
||||||
|
|||||||
@@ -336,12 +336,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
var textStyle = axis.axisLabel.textStyle;
|
var textStyle = axis.axisLabel.textStyle;
|
||||||
var label = AddChartLabel(name, parent, axis.axisLabel, theme, content, autoColor, autoAlignment);
|
var label = AddChartLabel(name, parent, axis.axisLabel, theme, content, autoColor, autoAlignment);
|
||||||
var labelShow = axis.axisLabel.show && (axis.axisLabel.interval == 0 || index % (axis.axisLabel.interval + 1) == 0);
|
var labelShow = axis.IsNeedShowLabel(index, total);
|
||||||
if (labelShow)
|
|
||||||
{
|
|
||||||
if (!axis.axisLabel.showStartLabel && index == 0) labelShow = false;
|
|
||||||
else if (!axis.axisLabel.showEndLabel && index == total - 1) labelShow = false;
|
|
||||||
}
|
|
||||||
label.UpdateIcon(axis.axisLabel.icon, axis.GetIcon(index));
|
label.UpdateIcon(axis.axisLabel.icon, axis.GetIcon(index));
|
||||||
label.text.SetActive(labelShow);
|
label.text.SetActive(labelShow);
|
||||||
return label;
|
return label;
|
||||||
|
|||||||
Reference in New Issue
Block a user