mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 10:20:10 +00:00
[bug][axis] fix showStartLabel and showEndLabel not work
This commit is contained in:
@@ -555,6 +555,21 @@ namespace XCharts.Runtime
|
||||
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()
|
||||
{
|
||||
context.isNeedUpdateFilterData = true;
|
||||
@@ -831,7 +846,7 @@ namespace XCharts.Runtime
|
||||
|
||||
public void UpdateZeroOffset(float axisLength)
|
||||
{
|
||||
context.offset = context.minValue > 0 || context.minMaxRange == 0?
|
||||
context.offset = context.minValue > 0 || context.minMaxRange == 0 ?
|
||||
0 :
|
||||
(context.maxValue < 0 ?
|
||||
axisLength :
|
||||
|
||||
@@ -296,12 +296,12 @@ namespace XCharts
|
||||
if (i == 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
@@ -309,12 +309,12 @@ namespace XCharts
|
||||
if (i == 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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()
|
||||
{
|
||||
|
||||
UpdateAxisMinMaxValue(component.index, component);
|
||||
UpdatePointerValue(component);
|
||||
}
|
||||
@@ -31,7 +30,7 @@ namespace XCharts.Runtime
|
||||
private void UpdatePosition(XAxis axis)
|
||||
{
|
||||
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);
|
||||
axis.context.x = grid.context.x;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace XCharts.Runtime
|
||||
private void UpdatePosition(YAxis axis)
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
|
||||
if (grid != null && axis.IsValue())
|
||||
if (grid != null)
|
||||
{
|
||||
var relativedAxis = chart.GetChartComponent<XAxis>(axis.gridIndex);
|
||||
axis.context.x = AxisHelper.GetYAxisXOrY(grid, axis, relativedAxis);
|
||||
|
||||
Reference in New Issue
Block a user