mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 09:50:15 +00:00
增加单条堆叠柱状图
This commit is contained in:
@@ -80,6 +80,7 @@ public class Demo : MonoBehaviour
|
|||||||
{
|
{
|
||||||
InitModuleButton();
|
InitModuleButton();
|
||||||
}
|
}
|
||||||
|
if (!Application.isPlaying) m_Mark.enabled = false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16829
Demo/demo_xchart.unity
16829
Demo/demo_xchart.unity
File diff suppressed because it is too large
Load Diff
@@ -72,7 +72,7 @@ namespace XCharts
|
|||||||
/ (xAxis.maxValue - xAxis.minValue) * coordinateWid;
|
/ (xAxis.maxValue - xAxis.minValue) * coordinateWid;
|
||||||
seriesHig[i] += barHig;
|
seriesHig[i] += barHig;
|
||||||
|
|
||||||
float currHig = CheckAnimation(serie,i,barHig);
|
float currHig = CheckAnimation(serie, i, barHig);
|
||||||
|
|
||||||
Vector3 p1 = new Vector3(pX, pY + space + barWidth);
|
Vector3 p1 = new Vector3(pX, pY + space + barWidth);
|
||||||
Vector3 p2 = new Vector3(pX + currHig, pY + space + barWidth);
|
Vector3 p2 = new Vector3(pX + currHig, pY + space + barWidth);
|
||||||
@@ -158,7 +158,7 @@ namespace XCharts
|
|||||||
/ (yAxis.maxValue - yAxis.minValue) * coordinateHig;
|
/ (yAxis.maxValue - yAxis.minValue) * coordinateHig;
|
||||||
seriesHig[i] += barHig;
|
seriesHig[i] += barHig;
|
||||||
|
|
||||||
float currHig = CheckAnimation(serie,i,barHig);
|
float currHig = CheckAnimation(serie, i, barHig);
|
||||||
|
|
||||||
Vector3 p1 = new Vector3(pX + space, pY);
|
Vector3 p1 = new Vector3(pX + space, pY);
|
||||||
Vector3 p2 = new Vector3(pX + space, pY + currHig);
|
Vector3 p2 = new Vector3(pX + space, pY + currHig);
|
||||||
|
|||||||
@@ -387,7 +387,9 @@ namespace XCharts
|
|||||||
public float GetSplitWidth(float coordinateWidth, DataZoom dataZoom)
|
public float GetSplitWidth(float coordinateWidth, DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
int split = GetSplitNumber(coordinateWidth, 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>
|
/// <summary>
|
||||||
@@ -409,7 +411,9 @@ namespace XCharts
|
|||||||
public float GetDataWidth(float coordinateWidth, DataZoom dataZoom)
|
public float GetDataWidth(float coordinateWidth, DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
var dataCount = GetDataNumber(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>();
|
private Dictionary<float, string> _cacheValue2str = new Dictionary<float, string>();
|
||||||
|
|||||||
@@ -1100,6 +1100,7 @@ namespace XCharts
|
|||||||
var serie = m_Series.GetSerie(n);
|
var serie = m_Series.GetSerie(n);
|
||||||
if (!serie.show || serie.symbol.type == SerieSymbolType.None) continue;
|
if (!serie.show || serie.symbol.type == SerieSymbolType.None) continue;
|
||||||
var zeroPos = Vector3.zero;
|
var zeroPos = Vector3.zero;
|
||||||
|
var lastStackSerie = m_Series.GetLastStackSerie(n);
|
||||||
if (serie.type == SerieType.Bar)
|
if (serie.type == SerieType.Bar)
|
||||||
{
|
{
|
||||||
if (serie.label.position == SerieLabel.Position.Bottom || serie.label.position == SerieLabel.Position.Center)
|
if (serie.label.position == SerieLabel.Position.Bottom || serie.label.position == SerieLabel.Position.Center)
|
||||||
@@ -1128,14 +1129,16 @@ namespace XCharts
|
|||||||
case SerieType.Line:
|
case SerieType.Line:
|
||||||
break;
|
break;
|
||||||
case SerieType.Bar:
|
case SerieType.Bar:
|
||||||
|
var bottomPos = lastStackSerie == null ? zeroPos : lastStackSerie.dataPoints[j];
|
||||||
switch (serie.label.position)
|
switch (serie.label.position)
|
||||||
{
|
{
|
||||||
case SerieLabel.Position.Center:
|
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;
|
break;
|
||||||
case SerieLabel.Position.Bottom:
|
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;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user