This commit is contained in:
monitor1394
2024-01-21 22:33:45 +08:00
parent e68e41a939
commit 653b81cc48
17 changed files with 41 additions and 11 deletions

View File

@@ -779,7 +779,7 @@ Bar chart shows different data through the height of a bar, which is used in rec
|HasChartComponent<T>()||public bool HasChartComponent<T>()|
|HasSerie()||public bool HasSerie(Type type)|
|HasSerie<T>()||public bool HasSerie<T>() where T : Serie|
|Init()||public void Init(bool defaultChart = true) { }|
|Init()||public void Init(bool defaultChart = true)|
|InitAxisRuntimeData()||public virtual void InitAxisRuntimeData(Axis axis) { }|
|InsertSerie()||public void InsertSerie(Serie serie, int index = -1, bool addToHead = false)|
|InsertSerie<T>()||public T InsertSerie<T>(int index, string serieName = null, bool show = true) where T : Serie|

View File

@@ -779,7 +779,7 @@ slug: /api
|HasChartComponent<T>()||public bool HasChartComponent<T>()|
|HasSerie()||public bool HasSerie(Type type)|
|HasSerie<T>()||public bool HasSerie<T>() where T : Serie|
|Init()||public void Init(bool defaultChart = true) { }|
|Init()||public void Init(bool defaultChart = true)|
|InitAxisRuntimeData()||public virtual void InitAxisRuntimeData(Axis axis) { }|
|InsertSerie()||public void InsertSerie(Serie serie, int index = -1, bool addToHead = false)|
|InsertSerie<T>()||public T InsertSerie<T>(int index, string serieName = null, bool show = true) where T : Serie|

View File

@@ -72,7 +72,6 @@ slug: /changelog
* (2024.01.18) 修复`Animation``type`代码动态修改无效的问题
* (2024.01.13) 增加`Chart`的更多快捷创建图表菜单
* (2024.01.12) 屏蔽`Chart``Init()`接口,动态创建图表不再需要调用
* (2024.01.09) 增加`Background``borderStyle`,给图表默认设置圆角
* (2024.01.07) 修复`Tooltop`的第一个`ContentLabelStyle`设置`color`无效的问题
* (2024.01.01) 增加`BorderStyle`边框样式

View File

@@ -15,6 +15,7 @@ namespace XCharts.Example
if (chart == null)
{
chart = gameObject.AddComponent<BarChart>();
chart.Init();
}
var serie = chart.GetSerie(0);
serie.animation.enable = true;

View File

@@ -40,7 +40,10 @@ namespace XCharts.Example
IEnumerator AddSimpleLine()
{
chart = gameObject.GetComponent<LineChart>();
if (chart == null) chart = gameObject.AddComponent<LineChart>();
if (chart == null){
chart = gameObject.AddComponent<LineChart>();
chart.Init();
}
chart.GetChartComponent<Title>().text = "LineChart - 折线图";
chart.GetChartComponent<Title>().subText = "普通折线图";

View File

@@ -16,6 +16,7 @@ namespace XCharts.Example
if (chart == null)
{
chart = gameObject.AddComponent<LineChart>();
chart.Init();
}
chart.EnsureChartComponent<Title>().show = true;
chart.EnsureChartComponent<Title>().text = "Sin Curve";

View File

@@ -29,7 +29,7 @@ namespace XCharts.Example
if (chart == null)
{
chart = gameObject.AddComponent<LineChart>();
chart.SetSize(580, 300);
chart.Init();
}
chart.EnsureChartComponent<Title>().show = true;
chart.EnsureChartComponent<Title>().text = "Line Simple";

View File

@@ -38,7 +38,11 @@ namespace XCharts.Example
IEnumerator AddSimpleBar()
{
chart = gameObject.GetComponent<BarChart>();
if (chart == null) chart = gameObject.AddComponent<BarChart>();
if (chart == null)
{
chart = gameObject.AddComponent<BarChart>();
chart.Init();
}
chart.EnsureChartComponent<Title>().text = "BarChart - 柱状图";
chart.EnsureChartComponent<Title>().subText = "普通柱状图";

View File

@@ -38,7 +38,11 @@ namespace XCharts.Example
IEnumerator PieAdd()
{
chart = gameObject.GetComponent<PieChart>();
if (chart == null) chart = gameObject.AddComponent<PieChart>();
if (chart == null)
{
chart = gameObject.AddComponent<PieChart>();
chart.Init();
}
yield return null;
chart.GetChartComponent<Title>().text = "PieChart - 饼图";
chart.GetChartComponent<Title>().subText = "基础饼图";

View File

@@ -17,6 +17,7 @@ namespace XCharts.Example
if (chart == null)
{
chart = gameObject.AddComponent<PieChart>();
chart.Init();
}
var serieIndex = 0;
var serie = chart.GetSerie(serieIndex);

View File

@@ -40,7 +40,11 @@ namespace XCharts.Example
IEnumerator RadarAdd()
{
chart = gameObject.GetComponent<RadarChart>();
if (chart == null) chart = gameObject.AddComponent<RadarChart>();
if (chart == null)
{
chart = gameObject.AddComponent<RadarChart>();
chart.Init();
}
chart.RemoveChartComponents<RadarCoord>();
chart.RemoveData();

View File

@@ -19,6 +19,7 @@ namespace XCharts.Example
if (chart == null)
{
chart = gameObject.AddComponent<RadarChart>();
chart.Init();
}
}

View File

@@ -16,6 +16,7 @@ namespace XCharts.Example
if (chart == null)
{
chart = gameObject.AddComponent<HeatmapChart>();
chart.Init();
}
chart.GetChartComponent<Title>().text = "HeatmapChart";
chart.GetChartComponent<Tooltip>().type = Tooltip.Type.None;

View File

@@ -18,6 +18,7 @@ namespace XCharts.Example
if (chart == null)
{
chart = gameObject.AddComponent<BaseChart>();
chart.Init();
}
chart.EnsureChartComponent<PolarCoord>();
}

View File

@@ -19,6 +19,7 @@ namespace XCharts.Example
if (chart == null)
{
chart = gameObject.AddComponent<CandlestickChart>();
chart.Init();
}
AddData();
}

View File

@@ -166,8 +166,18 @@ namespace XCharts.Runtime
/// </summary>
public Action<Legend, int, string> onLegendExit { set { m_OnLegendExit = value; } internal get { return m_OnLegendExit; } }
[Obsolete("No need to call Init() anymore.", true)]
public void Init(bool defaultChart = true) { }
public void Init(bool defaultChart = true)
{
if (defaultChart)
{
OnInit();
DefaultChart();
}
else
{
OnBeforeSerialize();
}
}
/// <summary>
/// Redraw chart in next frame.

View File

@@ -136,7 +136,6 @@ namespace XCharts.Runtime
m_Settings = Settings.DefaultSettings;
CheckTheme(true);
base.Awake();
CheckChartInit();
InitComponentHandlers();
InitSerieHandlers();
AnimationReset();