mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 21:38:49 +00:00
增加SerieData的radius自定义数据项的半径
This commit is contained in:
20
Assets/XCharts/Demo/Scripts/Demo30_Pie.cs
Normal file
20
Assets/XCharts/Demo/Scripts/Demo30_Pie.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using XCharts;
|
||||||
|
|
||||||
|
[DisallowMultipleComponent]
|
||||||
|
[ExecuteInEditMode]
|
||||||
|
public class Demo30_Pie : MonoBehaviour
|
||||||
|
{
|
||||||
|
private PieChart chart;
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
chart = gameObject.GetComponent<PieChart>();
|
||||||
|
if (chart == null) return;
|
||||||
|
|
||||||
|
var serie = chart.series.GetSerie(0);
|
||||||
|
var serieData = serie.GetSerieData(0);
|
||||||
|
serieData.radius = 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/XCharts/Demo/Scripts/Demo30_Pie.cs.meta
Normal file
11
Assets/XCharts/Demo/Scripts/Demo30_Pie.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 00a8daeea9dce492c8c1ed93c90ae409
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -14,6 +14,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
[SerializeField] private string m_Name;
|
[SerializeField] private string m_Name;
|
||||||
[SerializeField] private bool m_Selected;
|
[SerializeField] private bool m_Selected;
|
||||||
|
[SerializeField] private float m_Radius;
|
||||||
[SerializeField] private bool m_ShowIcon;
|
[SerializeField] private bool m_ShowIcon;
|
||||||
[SerializeField] private Sprite m_IconImage;
|
[SerializeField] private Sprite m_IconImage;
|
||||||
[SerializeField] private Color m_IconColor = Color.white;
|
[SerializeField] private Color m_IconColor = Color.white;
|
||||||
@@ -27,6 +28,7 @@ namespace XCharts
|
|||||||
private bool m_LabelAutoSize;
|
private bool m_LabelAutoSize;
|
||||||
private float m_LabelPaddingLeftRight;
|
private float m_LabelPaddingLeftRight;
|
||||||
private float m_LabelPaddingTopBottom;
|
private float m_LabelPaddingTopBottom;
|
||||||
|
private float m_RtPieOutsideRadius;
|
||||||
|
|
||||||
public int index { get; set; }
|
public int index { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -40,6 +42,10 @@ namespace XCharts
|
|||||||
/// <value></value>
|
/// <value></value>
|
||||||
public string legendName { get { return string.IsNullOrEmpty(name) ? ChartCached.IntToStr(index) : name; } }
|
public string legendName { get { return string.IsNullOrEmpty(name) ? ChartCached.IntToStr(index) : name; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 自定义半径。可用在饼图中自定义某个数据项的半径。
|
||||||
|
/// </summary>
|
||||||
|
public float radius { get { return m_Radius; } set { m_Radius = value; } }
|
||||||
|
/// <summary>
|
||||||
/// Whether the data item is selected.
|
/// Whether the data item is selected.
|
||||||
/// 该数据项是否被选中。
|
/// 该数据项是否被选中。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -135,11 +141,22 @@ namespace XCharts
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图数据项的内半径
|
/// 饼图数据项的内半径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieInsideRadius{get;set;}
|
public float pieInsideRadius { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图数据项的外半径
|
/// 饼图数据项的外半径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float pieOutsideRadius { get; set; }
|
public float pieOutsideRadius
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (radius > 0) return radius;
|
||||||
|
else return m_RtPieOutsideRadius;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
m_RtPieOutsideRadius = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图数据项的偏移半径
|
/// 饼图数据项的偏移半径
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -452,6 +452,7 @@
|
|||||||
* `data`:系列中的数据项 `SerieData` 数组。`SerieData` 可以设置`1`到`n`维数据。`SerieData`的相关参数如下:
|
* `data`:系列中的数据项 `SerieData` 数组。`SerieData` 可以设置`1`到`n`维数据。`SerieData`的相关参数如下:
|
||||||
* `name`:数据项名称。
|
* `name`:数据项名称。
|
||||||
* `selected`:该数据项是否被选中。
|
* `selected`:该数据项是否被选中。
|
||||||
|
* `radius`:自定义半径。可用在饼图中自定义某个数据项的半径。
|
||||||
* `showIcon`:是否显示图标。
|
* `showIcon`:是否显示图标。
|
||||||
* `iconImage`:图标的图片。
|
* `iconImage`:图标的图片。
|
||||||
* `iconColor`:图标颜色。
|
* `iconColor`:图标颜色。
|
||||||
|
|||||||
Reference in New Issue
Block a user