增加南丁格尔玫瑰图

This commit is contained in:
monitor1394
2018-09-23 13:32:46 +08:00
parent a1aa6269c8
commit 6828722efe
2 changed files with 1544 additions and 3 deletions

View File

@@ -16,6 +16,7 @@ namespace xcharts
{
public float insideRadius = 0f;
public float outsideRadius = 80f;
public bool outsideRadiusDynamic = false;
public float space;
public float left;
public float right;
@@ -60,14 +61,19 @@ namespace xcharts
float totalDegree = 360;
float startDegree = 0;
float dataTotal = GetDataTotal();
float dataMax = GetDataMax();
for (int i = 0; i < pieInfo.dataList.Count; i++)
{
if (!legend.IsShowSeries(i)) continue;
float value = pieInfo.dataList[i].value;
float degree = totalDegree * value / dataTotal;
float toDegree = startDegree + degree;
ChartUtils.DrawDoughnut(vh, new Vector3(pieCenterX, pieCenterY), pieInfo.insideRadius, pieRadius,
startDegree, toDegree, legend.GetColor(i));
float outSideRadius = pieInfo.outsideRadiusDynamic ?
pieInfo.insideRadius + (pieRadius - pieInfo.insideRadius) * value / dataMax :
pieRadius;
ChartUtils.DrawDoughnut(vh, new Vector3(pieCenterX, pieCenterY), pieInfo.insideRadius,
outSideRadius,startDegree, toDegree, legend.GetColor(i));
startDegree = toDegree;
}
}
@@ -91,6 +97,19 @@ namespace xcharts
return total;
}
private float GetDataMax()
{
float max = 0;
for(int i = 0; i < pieInfo.dataList.Count; i++)
{
if(legend.IsShowSeries(i) && pieInfo.dataList[i].value > max)
{
max = pieInfo.dataList[i].value;
}
}
return max;
}
private void UpdatePieCenter()
{
float diffX = chartWid - pieInfo.left - pieInfo.right;