mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 14:00:12 +00:00
Fixed dynamically creating chart at runtime would be abnormal
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
|
||||
## Latest
|
||||
|
||||
* (2021.04.26) Fixed dynamically creating chart at runtime would be abnormal #137
|
||||
* (2021.04.26) Added support for `Barchart` to draw gradient borders
|
||||
* (2021.04.23) Added support for custom charts
|
||||
* (2021.04.22) Fixed bug where `Gauge` `axisLabel`'s text color could not be adjusted
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
## Latest
|
||||
|
||||
* (2021.04.26) 修复运行时动态创建图表会异常的问题 #137
|
||||
* (2021.04.26) 增加`BarChart`绘制渐变边框的支持
|
||||
* (2021.04.23) 增加自定义图表支持
|
||||
* (2021.04.22) 修复`Gauge`的`AxisLabel`和文字颜色无法调整的问题
|
||||
|
||||
@@ -107,6 +107,11 @@ namespace XCharts
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
if (m_Settings == null) m_Settings = Settings.DefaultSettings;
|
||||
if (m_Series == null) m_Series = Series.defaultSeries; ;
|
||||
if (m_Titles.Count == 0) m_Titles = new List<Title>() { Title.defaultTitle };
|
||||
if (m_Legends.Count == 0) m_Legends = new List<Legend>() { Legend.defaultLegend };
|
||||
if (m_Tooltips.Count == 0) m_Tooltips = new List<Tooltip>() { Tooltip.defaultTooltip };
|
||||
CheckTheme();
|
||||
base.Awake();
|
||||
m_Series.AnimationReset();
|
||||
@@ -118,23 +123,18 @@ namespace XCharts
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
m_Theme = ChartTheme.Default;
|
||||
m_Settings = Settings.DefaultSettings;
|
||||
m_Titles = new List<Title>() { Title.defaultTitle };
|
||||
m_Legends = new List<Legend>() { Legend.defaultLegend };
|
||||
m_Tooltips = new List<Tooltip>() { Tooltip.defaultTooltip };
|
||||
|
||||
m_Theme = null;
|
||||
m_Settings = null;
|
||||
m_Series = null;
|
||||
m_Titles.Clear();
|
||||
m_Legends.Clear();
|
||||
m_Tooltips.Clear();
|
||||
var sizeDelta = rectTransform.sizeDelta;
|
||||
if (sizeDelta.x < 580 && sizeDelta.y < 300)
|
||||
{
|
||||
rectTransform.sizeDelta = new Vector2(580, 300);
|
||||
}
|
||||
ChartHelper.HideAllObject(transform);
|
||||
m_Theme = ChartTheme.Default;
|
||||
m_Titles = new List<Title>() { Title.defaultTitle };
|
||||
m_Legends = new List<Legend>() { Legend.defaultLegend };
|
||||
m_Tooltips = new List<Tooltip>() { Tooltip.defaultTooltip };
|
||||
m_Series = Series.defaultSeries;
|
||||
Awake();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -30,6 +30,9 @@ namespace XCharts
|
||||
protected override void InitComponent()
|
||||
{
|
||||
base.InitComponent();
|
||||
if (m_Grids.Count == 0) m_Grids = new List<Grid>() { Grid.defaultGrid };
|
||||
if (m_DataZooms.Count == 0) m_DataZooms = new List<DataZoom>() { DataZoom.defaultDataZoom };
|
||||
if (m_VisualMaps.Count == 0) m_VisualMaps = new List<VisualMap> { new VisualMap() };
|
||||
InitDefaultAxes();
|
||||
CheckMinMaxValue();
|
||||
InitGrid();
|
||||
@@ -52,9 +55,9 @@ namespace XCharts
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
m_Grids = new List<Grid>() { Grid.defaultGrid };
|
||||
m_DataZooms = new List<DataZoom>() { DataZoom.defaultDataZoom };
|
||||
m_VisualMaps = new List<VisualMap> { new VisualMap() };
|
||||
m_Grids.Clear();
|
||||
m_DataZooms.Clear();
|
||||
m_VisualMaps.Clear();
|
||||
m_XAxes.Clear();
|
||||
m_YAxes.Clear();
|
||||
Awake();
|
||||
@@ -887,13 +890,13 @@ namespace XCharts
|
||||
if (tempMinValue != 0 || tempMaxValue != 0)
|
||||
{
|
||||
var grid = GetAxisGridOrDefault(axis);
|
||||
if (axis is XAxis && axis.IsValue())
|
||||
if (grid != null && axis is XAxis && axis.IsValue())
|
||||
{
|
||||
axis.runtimeZeroXOffset = axis.runtimeMinValue > 0 ? 0 :
|
||||
axis.runtimeMaxValue < 0 ? grid.runtimeWidth :
|
||||
Mathf.Abs(axis.runtimeMinValue) * (grid.runtimeWidth / (Mathf.Abs(axis.runtimeMinValue) + Mathf.Abs(axis.runtimeMaxValue)));
|
||||
}
|
||||
if (axis is YAxis && axis.IsValue())
|
||||
if (grid != null && axis is YAxis && axis.IsValue())
|
||||
{
|
||||
axis.runtimeZeroYOffset = axis.runtimeMinValue > 0 ? 0 :
|
||||
axis.runtimeMaxValue < 0 ? grid.runtimeHeight :
|
||||
@@ -941,6 +944,7 @@ namespace XCharts
|
||||
protected void UpdateAxisLabelText(Axis axis)
|
||||
{
|
||||
var grid = GetAxisGridOrDefault(axis);
|
||||
if (grid == null || axis == null) return;
|
||||
float runtimeWidth = axis is XAxis ? grid.runtimeWidth : grid.runtimeHeight;
|
||||
var isPercentStack = SeriesHelper.IsPercentStack(m_Series, SerieType.Bar);
|
||||
axis.UpdateLabelText(runtimeWidth, dataZoom, isPercentStack, 500);
|
||||
@@ -1020,6 +1024,7 @@ namespace XCharts
|
||||
if (AxisHelper.NeedShowSplit(yAxis))
|
||||
{
|
||||
var grid = GetAxisGridOrDefault(yAxis);
|
||||
if (grid == null) return;
|
||||
var size = AxisHelper.GetScaleNumber(yAxis, grid.runtimeWidth, dataZoom);
|
||||
var totalWidth = grid.runtimeY;
|
||||
var xAxis = GetRelatedXAxis(yAxis);
|
||||
@@ -1135,6 +1140,7 @@ namespace XCharts
|
||||
if (AxisHelper.NeedShowSplit(xAxis))
|
||||
{
|
||||
var grid = GetAxisGridOrDefault(xAxis);
|
||||
if (grid == null) return;
|
||||
var size = AxisHelper.GetScaleNumber(xAxis, grid.runtimeWidth, dataZoom);
|
||||
var totalWidth = grid.runtimeX;
|
||||
var yAxis = m_YAxes[xAxisIndex];
|
||||
@@ -2078,7 +2084,7 @@ namespace XCharts
|
||||
else return grid;
|
||||
}
|
||||
|
||||
protected Grid GetSerieGridOrDefault(Serie serie)
|
||||
public Grid GetSerieGridOrDefault(Serie serie)
|
||||
{
|
||||
var xAxis = GetSerieXAxisOrDefault(serie);
|
||||
var yAxis = GetSerieYAxisOrDefault(serie);
|
||||
|
||||
@@ -27,6 +27,9 @@ namespace XCharts
|
||||
protected override void InitComponent()
|
||||
{
|
||||
base.InitComponent();
|
||||
if (m_Polars.Count == 0) m_Polars = new List<Polar>() { Polar.defaultPolar };
|
||||
if (m_RadiusAxes.Count == 0) m_RadiusAxes = new List<RadiusAxis>() { RadiusAxis.defaultRadiusAxis };
|
||||
if (m_AngleAxes.Count == 0) m_AngleAxes = new List<AngleAxis>() { AngleAxis.defaultAngleAxis };
|
||||
CheckMinMaxValue();
|
||||
UpdateRuntimeValue();
|
||||
InitPolars();
|
||||
@@ -40,9 +43,9 @@ namespace XCharts
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
m_Polars = new List<Polar>() { Polar.defaultPolar };
|
||||
m_RadiusAxes = new List<RadiusAxis>() { RadiusAxis.defaultRadiusAxis };
|
||||
m_AngleAxes = new List<AngleAxis>() { AngleAxis.defaultAngleAxis };
|
||||
m_Polars.Clear();
|
||||
m_RadiusAxes.Clear();
|
||||
m_AngleAxes.Clear();
|
||||
title.text = "PolarChart";
|
||||
tooltip.type = Tooltip.Type.Corss;
|
||||
RemoveData();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
@@ -15,12 +16,18 @@ namespace XCharts
|
||||
[DisallowMultipleComponent]
|
||||
public class RadarChart : BaseChart
|
||||
{
|
||||
protected override void InitComponent()
|
||||
{
|
||||
base.InitComponent();
|
||||
if (m_Radars.Count == 0) m_Radars = new List<Radar>() { Radar.defaultRadar };
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
RemoveData();
|
||||
m_Radars.Add(Radar.defaultRadar);
|
||||
m_Radars.Clear();
|
||||
title.text = "RadarChart";
|
||||
SerieTemplate.AddDefaultRadarSerie(this, "serie1");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user