mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 08:50:10 +00:00
增加AxisLabel的showStartLabel和showEndLabel参数设置首尾的Label是否显示
This commit is contained in:
@@ -599,14 +599,14 @@ namespace XCharts
|
||||
yAxis.runtimeMaxValue, dataZoom, isPercentStack);
|
||||
if ((inside && yAxis.IsLeft()) || (!inside && yAxis.IsRight()))
|
||||
{
|
||||
txt = ChartHelper.AddAxisLabelObject(i, objName + i, axisObj.transform, Vector2.zero,
|
||||
txt = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform, Vector2.zero,
|
||||
Vector2.zero, new Vector2(0, 0.5f), new Vector2(textWidth, textHeight), yAxis, theme.axis,
|
||||
labelName);
|
||||
txt.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleLeft));
|
||||
}
|
||||
else
|
||||
{
|
||||
txt = ChartHelper.AddAxisLabelObject(i, objName + i, axisObj.transform, Vector2.zero,
|
||||
txt = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform, Vector2.zero,
|
||||
Vector2.zero, new Vector2(1, 0.5f), new Vector2(textWidth, textHeight), yAxis, theme.axis,
|
||||
labelName);
|
||||
txt.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleRight));
|
||||
@@ -722,9 +722,9 @@ namespace XCharts
|
||||
var isPercentStack = SeriesHelper.IsPercentStack(m_Series, SerieType.Bar);
|
||||
var labelName = AxisHelper.GetLabelName(xAxis, grid.runtimeWidth, i, xAxis.runtimeMinValue,
|
||||
xAxis.runtimeMaxValue, dataZoom, isPercentStack);
|
||||
var label = ChartHelper.AddAxisLabelObject(i, ChartCached.GetXAxisName(xAxisIndex, i), axisObj.transform,
|
||||
new Vector2(0, 1), new Vector2(0, 1), new Vector2(1, 0.5f), new Vector2(textWidth, textHeight),
|
||||
xAxis, theme.axis, labelName);
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, ChartCached.GetXAxisName(xAxisIndex, i),
|
||||
axisObj.transform, new Vector2(0, 1), new Vector2(0, 1), new Vector2(1, 0.5f),
|
||||
new Vector2(textWidth, textHeight), xAxis, theme.axis, labelName);
|
||||
|
||||
if (i == 0) xAxis.axisLabel.SetRelatedText(label.label, labelWidth);
|
||||
label.label.SetAlignment(axisLabelTextStyle.GetAlignment(TextAnchor.MiddleCenter));
|
||||
|
||||
@@ -399,8 +399,9 @@ namespace XCharts
|
||||
return img;
|
||||
}
|
||||
|
||||
public static ChartLabel AddAxisLabelObject(int index, string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax,
|
||||
Vector2 pivot, Vector2 sizeDelta, Axis axis, ComponentTheme theme, string content)
|
||||
public static ChartLabel AddAxisLabelObject(int total, int index, string name, Transform parent,
|
||||
Vector2 anchorMin, Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, Axis axis, ComponentTheme theme,
|
||||
string content)
|
||||
{
|
||||
var textStyle = axis.axisLabel.textStyle;
|
||||
var iconStyle = axis.iconStyle;
|
||||
@@ -414,6 +415,11 @@ namespace XCharts
|
||||
GameObject.DestroyImmediate(oldText);
|
||||
}
|
||||
var labelShow = axis.axisLabel.show && (axis.axisLabel.interval == 0 || index % (axis.axisLabel.interval + 1) == 0);
|
||||
if (labelShow)
|
||||
{
|
||||
if (!axis.axisLabel.showStartLabel && index == 0) labelShow = false;
|
||||
else if (!axis.axisLabel.showEndLabel && index == total - 1) labelShow = false;
|
||||
}
|
||||
label.label = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot, sizeDelta, textStyle, theme);
|
||||
label.icon = ChartHelper.AddIcon("Icon", label.gameObject.transform, iconStyle.width, iconStyle.height);
|
||||
label.SetAutoSize(false);
|
||||
|
||||
Reference in New Issue
Block a user