mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 18:30:14 +00:00
增加南丁格尔玫瑰图
This commit is contained in:
@@ -16,6 +16,7 @@ namespace xcharts
|
|||||||
{
|
{
|
||||||
public float insideRadius = 0f;
|
public float insideRadius = 0f;
|
||||||
public float outsideRadius = 80f;
|
public float outsideRadius = 80f;
|
||||||
|
public bool outsideRadiusDynamic = false;
|
||||||
public float space;
|
public float space;
|
||||||
public float left;
|
public float left;
|
||||||
public float right;
|
public float right;
|
||||||
@@ -60,14 +61,19 @@ namespace xcharts
|
|||||||
float totalDegree = 360;
|
float totalDegree = 360;
|
||||||
float startDegree = 0;
|
float startDegree = 0;
|
||||||
float dataTotal = GetDataTotal();
|
float dataTotal = GetDataTotal();
|
||||||
|
float dataMax = GetDataMax();
|
||||||
for (int i = 0; i < pieInfo.dataList.Count; i++)
|
for (int i = 0; i < pieInfo.dataList.Count; i++)
|
||||||
{
|
{
|
||||||
if (!legend.IsShowSeries(i)) continue;
|
if (!legend.IsShowSeries(i)) continue;
|
||||||
float value = pieInfo.dataList[i].value;
|
float value = pieInfo.dataList[i].value;
|
||||||
float degree = totalDegree * value / dataTotal;
|
float degree = totalDegree * value / dataTotal;
|
||||||
float toDegree = startDegree + degree;
|
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;
|
startDegree = toDegree;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,6 +97,19 @@ namespace xcharts
|
|||||||
return total;
|
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()
|
private void UpdatePieCenter()
|
||||||
{
|
{
|
||||||
float diffX = chartWid - pieInfo.left - pieInfo.right;
|
float diffX = chartWid - pieInfo.left - pieInfo.right;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,10 @@
|
|||||||
# XChart
|
# XChart
|
||||||
A Simple UGUI Charting Library for Unity
|
A Simple UGUI Charting Library for Unity
|
||||||
|
|
||||||

|
# 效果图
|
||||||
|
1.折线图
|
||||||
|

|
||||||
|
2.柱形图
|
||||||
|

|
||||||
|
3.饼图
|
||||||
|

|
||||||
BIN
demo_bar.png
Normal file
BIN
demo_bar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
BIN
demo_line.png
Normal file
BIN
demo_line.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
BIN
demo_pie.png
Normal file
BIN
demo_pie.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Reference in New Issue
Block a user