增加单条堆叠柱状图

This commit is contained in:
monitor1394
2019-09-18 19:10:43 +08:00
parent b090d5d874
commit aa7eeab49b
5 changed files with 11084 additions and 5767 deletions

View File

@@ -72,7 +72,7 @@ namespace XCharts
/ (xAxis.maxValue - xAxis.minValue) * coordinateWid;
seriesHig[i] += barHig;
float currHig = CheckAnimation(serie,i,barHig);
float currHig = CheckAnimation(serie, i, barHig);
Vector3 p1 = new Vector3(pX, pY + space + barWidth);
Vector3 p2 = new Vector3(pX + currHig, pY + space + barWidth);
@@ -158,7 +158,7 @@ namespace XCharts
/ (yAxis.maxValue - yAxis.minValue) * coordinateHig;
seriesHig[i] += barHig;
float currHig = CheckAnimation(serie,i,barHig);
float currHig = CheckAnimation(serie, i, barHig);
Vector3 p1 = new Vector3(pX + space, pY);
Vector3 p2 = new Vector3(pX + space, pY + currHig);

View File

@@ -387,7 +387,9 @@ namespace XCharts
public float GetSplitWidth(float coordinateWidth, DataZoom dataZoom)
{
int split = GetSplitNumber(coordinateWidth, dataZoom);
return coordinateWidth / (m_BoundaryGap ? split : split - 1);
int segment = (m_BoundaryGap ? split : split - 1);
segment = segment <= 0 ? 1 : segment;
return coordinateWidth / segment;
}
/// <summary>
@@ -409,7 +411,9 @@ namespace XCharts
public float GetDataWidth(float coordinateWidth, DataZoom dataZoom)
{
var dataCount = GetDataNumber(dataZoom);
return coordinateWidth / (m_BoundaryGap ? dataCount : dataCount - 1);
int segment = (m_BoundaryGap ? dataCount : dataCount - 1);
segment = segment <= 0 ? 1 : segment;
return coordinateWidth / segment;
}
private Dictionary<float, string> _cacheValue2str = new Dictionary<float, string>();

View File

@@ -1100,6 +1100,7 @@ namespace XCharts
var serie = m_Series.GetSerie(n);
if (!serie.show || serie.symbol.type == SerieSymbolType.None) continue;
var zeroPos = Vector3.zero;
var lastStackSerie = m_Series.GetLastStackSerie(n);
if (serie.type == SerieType.Bar)
{
if (serie.label.position == SerieLabel.Position.Bottom || serie.label.position == SerieLabel.Position.Center)
@@ -1128,14 +1129,16 @@ namespace XCharts
case SerieType.Line:
break;
case SerieType.Bar:
var bottomPos = lastStackSerie == null ? zeroPos : lastStackSerie.dataPoints[j];
switch (serie.label.position)
{
case SerieLabel.Position.Center:
pos = isYAxis ? new Vector3(zeroPos.x + (pos.x - zeroPos.x) / 2, pos.y) :
new Vector3(pos.x, zeroPos.y + (pos.y - zeroPos.y) / 2);
pos = isYAxis ? new Vector3(bottomPos.x + (pos.x - bottomPos.x) / 2, pos.y) :
new Vector3(pos.x, bottomPos.y + (pos.y - bottomPos.y) / 2);
break;
case SerieLabel.Position.Bottom:
pos = isYAxis ? new Vector3(zeroPos.x, pos.y) : new Vector3(pos.x, zeroPos.y);
pos = isYAxis ? new Vector3(bottomPos.x, pos.y) : new Vector3(pos.x, bottomPos.y);
break;
}
break;