diff --git a/Runtime/Internal/BaseChart.API.cs b/Runtime/Internal/BaseChart.API.cs index 84847cca..f51f8a5b 100644 --- a/Runtime/Internal/BaseChart.API.cs +++ b/Runtime/Internal/BaseChart.API.cs @@ -631,15 +631,5 @@ namespace XCharts.Runtime SerieHelper.GetItemColor(out color, out toColor, serie, null, m_Theme); return color; } - - /// - /// 保存图表为图片。 - /// - /// type of image: png, jpg, exr - /// save path - public void SaveAsImage(string imageType = "png", string savePath = "") - { - StartCoroutine(SaveAsImageSync(imageType, savePath)); - } } } \ No newline at end of file diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index 0815e8dc..10499ebb 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -746,11 +746,5 @@ namespace XCharts.Runtime InitComponentHandlers(); InitSerieHandlers(); } - - private IEnumerator SaveAsImageSync(string imageType, string path) - { - yield return new WaitForEndOfFrame(); - ChartHelper.SaveAsImage(rectTransform, canvas, imageType, path); - } } } \ No newline at end of file diff --git a/Runtime/Internal/BaseGraph.API.cs b/Runtime/Internal/BaseGraph.API.cs index dae4f8da..d15276ff 100644 --- a/Runtime/Internal/BaseGraph.API.cs +++ b/Runtime/Internal/BaseGraph.API.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using UnityEngine; using UnityEngine.EventSystems; @@ -170,5 +171,21 @@ namespace XCharts.Runtime } return true; } + + /// + /// 保存图表为图片。 + /// + /// type of image: png, jpg, exr + /// save path + public void SaveAsImage(string imageType = "png", string savePath = "") + { + StartCoroutine(SaveAsImageSync(imageType, savePath)); + } + + private IEnumerator SaveAsImageSync(string imageType, string path) + { + yield return new WaitForEndOfFrame(); + ChartHelper.SaveAsImage(rectTransform, canvas, imageType, path); + } } } \ No newline at end of file diff --git a/Runtime/Internal/Object/ChartLabel.cs b/Runtime/Internal/Object/ChartLabel.cs index 746e17fb..bf609c64 100644 --- a/Runtime/Internal/Object/ChartLabel.cs +++ b/Runtime/Internal/Object/ChartLabel.cs @@ -40,6 +40,7 @@ namespace XCharts.Runtime public bool hideIconIfTextEmpty { set { m_HideIconIfTextEmpty = value; } } public bool isIconActive { get; private set; } public bool isAnimationEnd { get; internal set; } + public Rect rect { get; set; } internal RectTransform objectRect { diff --git a/Runtime/Internal/Painter.cs b/Runtime/Internal/Painter.cs index c60041a9..b1ac47b4 100644 --- a/Runtime/Internal/Painter.cs +++ b/Runtime/Internal/Painter.cs @@ -51,7 +51,7 @@ namespace XCharts.Runtime Init(); } - internal void CheckRefresh() + public void CheckRefresh() { if (m_Refresh && gameObject.activeSelf) { diff --git a/Runtime/Internal/Utilities/ChartHelper.cs b/Runtime/Internal/Utilities/ChartHelper.cs index 2b8a88f8..8f3b7d6f 100644 --- a/Runtime/Internal/Utilities/ChartHelper.cs +++ b/Runtime/Internal/Utilities/ChartHelper.cs @@ -324,14 +324,20 @@ namespace XCharts.Runtime if (background == null) return; if (imageStyle.show) { + background.gameObject.SetActive(true); background.sprite = imageStyle.sprite; background.color = imageStyle.color; background.type = imageStyle.type; + if (imageStyle.width > 0 && imageStyle.height > 0) + { + background.rectTransform.sizeDelta = new Vector2(imageStyle.width, imageStyle.height); + } } else { background.sprite = null; background.color = Color.clear; + background.gameObject.SetActive(false); } }