mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 23:10:06 +00:00
完善多坐标轴的支持 #132
This commit is contained in:
@@ -34,6 +34,9 @@
|
||||
|
||||
## Latest
|
||||
|
||||
* (2021.04.13) Add the `ShowStarttick` and '`ShowEndTick` parameters of 'AxisTick' to control whether the first and last ticks are displayed
|
||||
* (2021.04.13) Improved multi-axis support #132
|
||||
|
||||
## v2.1.1
|
||||
|
||||
* (2021.04.13) Define the code and clear `Warning`
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
|
||||
## Latest
|
||||
|
||||
* (2021.04.13) 增加`AxisTick`的`ShowStartTick`和`ShowEndTick`参数控制第一个和最后一个刻度是否显示
|
||||
* (2021.04.13) 完善多坐标轴的支持 #132
|
||||
|
||||
## v2.1.1
|
||||
|
||||
* (2021.04.13) 整理代码,清除`Warning`
|
||||
|
||||
@@ -879,6 +879,8 @@ K线图系列。
|
||||
* `inside`:坐标轴刻度是否朝内,默认朝外。
|
||||
* `length`:坐标轴刻度的长度。
|
||||
* `width`:坐标轴刻度的宽度。默认为0时宽度和坐标轴一致。
|
||||
* `showStartTick`:是否显示第一个刻度。
|
||||
* `showEndTick`:是否显示最后一个刻度。
|
||||
|
||||
## `Emphasis`
|
||||
|
||||
|
||||
@@ -772,6 +772,8 @@ K线图系列。
|
||||
* `inside`: 坐标轴刻度是否朝内,默认朝外。
|
||||
* `length`: 坐标轴刻度的长度。
|
||||
* `width`: 坐标轴刻度的宽度。默认为0时宽度和坐标轴一致。
|
||||
* `showStartTick`:是否显示第一个刻度。
|
||||
* `showEndTick`:是否显示最后一个刻度。
|
||||
|
||||
## `Emphasis`
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ namespace XCharts
|
||||
base.DrawExtendeds(prop);
|
||||
PropertyField(prop, "m_AlignWithLabel");
|
||||
PropertyField(prop, "m_Inside");
|
||||
PropertyField(prop, "m_ShowStartTick");
|
||||
PropertyField(prop, "m_ShowEndTick");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace XCharts
|
||||
{
|
||||
[SerializeField] private bool m_AlignWithLabel;
|
||||
[SerializeField] private bool m_Inside;
|
||||
[SerializeField] private bool m_ShowStartTick;
|
||||
[SerializeField] private bool m_ShowEndTick;
|
||||
|
||||
/// <summary>
|
||||
/// Align axis tick with label, which is available only when boundaryGap is set to be true in category axis.
|
||||
@@ -38,6 +40,24 @@ namespace XCharts
|
||||
get { return m_Inside; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Inside, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to display the first tick.
|
||||
/// 是否显示第一个刻度。
|
||||
/// </summary>
|
||||
public bool showStartTick
|
||||
{
|
||||
get { return m_ShowStartTick; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowStartTick, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to display the last tick.
|
||||
/// 是否显示最后一个刻度。
|
||||
/// </summary>
|
||||
public bool showEndTick
|
||||
{
|
||||
get { return m_ShowEndTick; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowEndTick, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public static AxisTick defaultTick
|
||||
{
|
||||
@@ -48,6 +68,8 @@ namespace XCharts
|
||||
m_Show = true,
|
||||
m_AlignWithLabel = false,
|
||||
m_Inside = false,
|
||||
m_ShowStartTick = false,
|
||||
m_ShowEndTick = true
|
||||
};
|
||||
return tick;
|
||||
}
|
||||
@@ -59,6 +81,8 @@ namespace XCharts
|
||||
axisTick.show = show;
|
||||
axisTick.alignWithLabel = alignWithLabel;
|
||||
axisTick.inside = inside;
|
||||
axisTick.showStartTick = showStartTick;
|
||||
axisTick.showEndTick = showEndTick;
|
||||
axisTick.lineStyle = lineStyle.Clone();
|
||||
return axisTick;
|
||||
}
|
||||
@@ -68,6 +92,8 @@ namespace XCharts
|
||||
show = axisTick.show;
|
||||
alignWithLabel = axisTick.alignWithLabel;
|
||||
inside = axisTick.inside;
|
||||
showStartTick = axisTick.showStartTick;
|
||||
showEndTick = axisTick.showEndTick;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -826,13 +826,14 @@ namespace XCharts
|
||||
{
|
||||
posX = startX - yAxis.axisLabel.margin;
|
||||
}
|
||||
posX += yAxis.offset;
|
||||
return new Vector3(posX, grid.runtimeY + scaleWid, 0);
|
||||
}
|
||||
|
||||
private Vector3 GetLabelXPosition(float scaleWid, int i, int xAxisIndex, XAxis xAxis)
|
||||
{
|
||||
var grid = GetAxisGridOrDefault(xAxis);
|
||||
var startY = grid.runtimeY + xAxis.offset + (xAxis.axisLabel.onZero ? m_YAxes[xAxisIndex].runtimeZeroYOffset : 0);
|
||||
var startY = grid.runtimeY + (xAxis.axisLabel.onZero ? m_YAxes[xAxisIndex].runtimeZeroYOffset : 0);
|
||||
if (xAxis.IsTop()) startY += grid.runtimeHeight;
|
||||
var posY = 0f;
|
||||
var inside = xAxis.axisLabel.inside;
|
||||
@@ -845,6 +846,7 @@ namespace XCharts
|
||||
{
|
||||
posY = startY - xAxis.axisLabel.margin - fontSize / 2;
|
||||
}
|
||||
posY += xAxis.offset;
|
||||
return new Vector3(grid.runtimeX + scaleWid, posY);
|
||||
}
|
||||
|
||||
@@ -1067,15 +1069,22 @@ namespace XCharts
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var scaleWidth = AxisHelper.GetScaleWidth(yAxis, grid.runtimeHeight, i + 1, dataZoom);
|
||||
float pX = 0;
|
||||
float pY = totalWidth;
|
||||
if (yAxis.boundaryGap && yAxis.axisTick.alignWithLabel)
|
||||
if (i == 0 && !yAxis.axisTick.showStartTick)
|
||||
{
|
||||
pY -= scaleWidth / 2;
|
||||
totalWidth += scaleWidth;
|
||||
continue;
|
||||
}
|
||||
if (yAxis.axisTick.show && i > 0)
|
||||
if (i == size - 1 && !yAxis.axisTick.showEndTick)
|
||||
{
|
||||
var startX = grid.runtimeX + GetYAxisOnZeroOffset(yAxis);
|
||||
totalWidth += scaleWidth;
|
||||
continue;
|
||||
}
|
||||
if (yAxis.axisTick.show)
|
||||
{
|
||||
float pX = 0;
|
||||
float pY = totalWidth;
|
||||
if (yAxis.boundaryGap && yAxis.axisTick.alignWithLabel) pY -= scaleWidth / 2;
|
||||
var startX = grid.runtimeX + GetYAxisOnZeroOffset(yAxis) + yAxis.offset;
|
||||
startX -= yAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
if (yAxis.IsValue() && yAxis.IsRight()) startX += grid.runtimeWidth;
|
||||
bool inside = yAxis.axisTick.inside;
|
||||
@@ -1176,14 +1185,21 @@ namespace XCharts
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var scaleWidth = AxisHelper.GetScaleWidth(xAxis, grid.runtimeWidth, i + 1, dataZoom);
|
||||
float pX = totalWidth;
|
||||
float pY = 0;
|
||||
if (xAxis.boundaryGap && xAxis.axisTick.alignWithLabel)
|
||||
if (i == 0 && !xAxis.axisTick.showStartTick)
|
||||
{
|
||||
pX -= scaleWidth / 2;
|
||||
totalWidth += scaleWidth;
|
||||
continue;
|
||||
}
|
||||
if (xAxis.axisTick.show && i > 0)
|
||||
if (i == size - 1 && !xAxis.axisTick.showEndTick)
|
||||
{
|
||||
totalWidth += scaleWidth;
|
||||
continue;
|
||||
}
|
||||
if (xAxis.axisTick.show)
|
||||
{
|
||||
float pX = totalWidth;
|
||||
float pY = 0;
|
||||
if (xAxis.boundaryGap && xAxis.axisTick.alignWithLabel) pX -= scaleWidth / 2;
|
||||
var startY = grid.runtimeY + xAxis.offset - xAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
if (xAxis.IsTop()) startY += grid.runtimeHeight;
|
||||
else startY += GetXAxisOnZeroOffset(xAxis);
|
||||
|
||||
Reference in New Issue
Block a user