mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-27 19:50:10 +00:00
Fixed an issue where the Radar could not refresh itself after parameter changing #122
This commit is contained in:
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
## Latest
|
## Latest
|
||||||
|
|
||||||
|
* (2021.02.18) Fixed an issue where the `Radar` could not refresh itself after parameter changing #122
|
||||||
|
|
||||||
## v2.0.0
|
## v2.0.0
|
||||||
|
|
||||||
* (2021.02.05) Release `v2.0.0` version
|
* (2021.02.05) Release `v2.0.0` version
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
## Latest
|
## Latest
|
||||||
|
|
||||||
|
* (2021.02.18) 修复`Radar`参数变更后无法自刷新的问题
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
* (2021.02.05) 发布`v2.0.0`版本
|
* (2021.02.05) 发布`v2.0.0`版本
|
||||||
|
|||||||
@@ -26,6 +26,17 @@ namespace XCharts
|
|||||||
m_Radars.Clear();
|
m_Radars.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除指定Radar的所有Indicator。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="radarIndex"></param>
|
||||||
|
public void RemoveIndicator(int radarIndex)
|
||||||
|
{
|
||||||
|
var radar = GetRadar(radarIndex);
|
||||||
|
if (radar == null) return;
|
||||||
|
radar.indicatorList.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加雷达坐标系组件。
|
/// 添加雷达坐标系组件。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -61,6 +72,14 @@ namespace XCharts
|
|||||||
return radar;
|
return radar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AddIndicator(int radarIndex, Radar.Indicator indicator)
|
||||||
|
{
|
||||||
|
var radar = GetRadar(radarIndex);
|
||||||
|
if (radar == null) return false;
|
||||||
|
radar.AddIndicator(indicator);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加指示器。
|
/// 添加指示器。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -340,6 +340,12 @@ namespace XCharts
|
|||||||
return new Vector3(x, y);
|
return new Vector3(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddIndicator(Radar.Indicator indicator)
|
||||||
|
{
|
||||||
|
indicatorList.Add(indicator);
|
||||||
|
SetAllDirty();
|
||||||
|
}
|
||||||
|
|
||||||
public Radar.Indicator AddIndicator(string name, float min, float max)
|
public Radar.Indicator AddIndicator(string name, float min, float max)
|
||||||
{
|
{
|
||||||
var indicator = new Radar.Indicator();
|
var indicator = new Radar.Indicator();
|
||||||
|
|||||||
@@ -249,16 +249,19 @@ namespace XCharts
|
|||||||
m_Theme.ClearDirty();
|
m_Theme.ClearDirty();
|
||||||
}
|
}
|
||||||
CheckComponentDirty(tooltip);
|
CheckComponentDirty(tooltip);
|
||||||
foreach (var title in m_Titles) CheckComponentDirty(title);
|
foreach (var component in m_Titles) CheckComponentDirty(component);
|
||||||
foreach (var legend in m_Legends) CheckComponentDirty(legend);
|
foreach (var component in m_Legends) CheckComponentDirty(component);
|
||||||
foreach (var dataZoom in m_DataZooms) CheckComponentDirty(dataZoom);
|
foreach (var component in m_Tooltips) CheckComponentDirty(component);
|
||||||
foreach (var visualMap in m_VisualMaps) CheckComponentDirty(visualMap);
|
foreach (var component in m_DataZooms) CheckComponentDirty(component);
|
||||||
foreach (var grid in m_Grids) CheckComponentDirty(grid);
|
foreach (var component in m_VisualMaps) CheckComponentDirty(component);
|
||||||
foreach (var axis in m_XAxes) CheckComponentDirty(axis);
|
foreach (var component in m_Grids) CheckComponentDirty(component);
|
||||||
foreach (var axis in m_YAxes) CheckComponentDirty(axis);
|
foreach (var component in m_XAxes) CheckComponentDirty(component);
|
||||||
foreach (var polar in m_Polars) CheckComponentDirty(polar);
|
foreach (var component in m_YAxes) CheckComponentDirty(component);
|
||||||
foreach (var axis in m_AngleAxes) CheckComponentDirty(axis);
|
foreach (var component in m_Vessels) CheckComponentDirty(component);
|
||||||
foreach (var axis in m_RadiusAxes) CheckComponentDirty(axis);
|
foreach (var component in m_Polars) CheckComponentDirty(component);
|
||||||
|
foreach (var component in m_AngleAxes) CheckComponentDirty(component);
|
||||||
|
foreach (var component in m_RadiusAxes) CheckComponentDirty(component);
|
||||||
|
foreach (var component in m_Radars) CheckComponentDirty(component);
|
||||||
foreach (var drawSerie in m_DrawSeries) drawSerie.CheckComponent();
|
foreach (var drawSerie in m_DrawSeries) drawSerie.CheckComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,9 +281,19 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
base.SetAllComponentDirty();
|
base.SetAllComponentDirty();
|
||||||
m_Theme.SetAllDirty();
|
m_Theme.SetAllDirty();
|
||||||
foreach (var title in m_Titles) title.SetAllDirty();
|
foreach (var component in m_Titles) component.SetAllDirty();
|
||||||
foreach (var legend in m_Legends) legend.SetAllDirty();
|
foreach (var component in m_Legends) component.SetAllDirty();
|
||||||
tooltip.SetAllDirty();
|
foreach (var component in m_Tooltips) component.SetAllDirty();
|
||||||
|
foreach (var component in m_Grids) component.SetAllDirty();
|
||||||
|
foreach (var component in m_XAxes) component.SetAllDirty();
|
||||||
|
foreach (var component in m_YAxes) component.SetAllDirty();
|
||||||
|
foreach (var component in m_DataZooms) component.SetAllDirty();
|
||||||
|
foreach (var component in m_VisualMaps) component.SetAllDirty();
|
||||||
|
foreach (var component in m_Vessels) component.SetAllDirty();
|
||||||
|
foreach (var component in m_Polars) component.SetAllDirty();
|
||||||
|
foreach (var component in m_RadiusAxes) component.SetAllDirty();
|
||||||
|
foreach (var component in m_AngleAxes) component.SetAllDirty();
|
||||||
|
foreach (var component in m_Radars) component.SetAllDirty();
|
||||||
m_ReinitLabel = true;
|
m_ReinitLabel = true;
|
||||||
m_ReinitTitle = true;
|
m_ReinitTitle = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ namespace XCharts
|
|||||||
public BaseChart chart;
|
public BaseChart chart;
|
||||||
private const string INDICATOR_TEXT = "indicator";
|
private const string INDICATOR_TEXT = "indicator";
|
||||||
private bool m_IsEnterLegendButtom;
|
private bool m_IsEnterLegendButtom;
|
||||||
private bool m_RadarsDirty;
|
|
||||||
Dictionary<string, int> serieNameSet = new Dictionary<string, int>();
|
Dictionary<string, int> serieNameSet = new Dictionary<string, int>();
|
||||||
|
|
||||||
public DrawSerieRadar(BaseChart chart)
|
public DrawSerieRadar(BaseChart chart)
|
||||||
@@ -28,26 +27,11 @@ namespace XCharts
|
|||||||
|
|
||||||
public void InitComponent()
|
public void InitComponent()
|
||||||
{
|
{
|
||||||
InitIndicator();
|
InitRadars();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckComponent()
|
public void CheckComponent()
|
||||||
{
|
{
|
||||||
var anyDirty = IsAnyRadarDirty();
|
|
||||||
if (m_RadarsDirty || anyDirty)
|
|
||||||
{
|
|
||||||
InitIndicator();
|
|
||||||
chart.RefreshBasePainter();
|
|
||||||
chart.tooltip.UpdateToTop();
|
|
||||||
if (anyDirty)
|
|
||||||
{
|
|
||||||
foreach (var radar in chart.radars)
|
|
||||||
{
|
|
||||||
radar.ClearDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_RadarsDirty = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
@@ -244,22 +228,31 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitIndicator()
|
private void InitRadars()
|
||||||
{
|
{
|
||||||
ChartHelper.HideAllObject(chart.transform, INDICATOR_TEXT);
|
|
||||||
for (int n = 0; n < chart.radars.Count; n++)
|
for (int n = 0; n < chart.radars.Count; n++)
|
||||||
{
|
{
|
||||||
Radar radar = chart.radars[n];
|
Radar radar = chart.radars[n];
|
||||||
|
radar.index = n;
|
||||||
|
InitRadar(radar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitRadar(Radar radar)
|
||||||
|
{
|
||||||
|
float txtWid = 100;
|
||||||
|
float txtHig = 20;
|
||||||
|
radar.painter = chart.GetPainter(radar.index);
|
||||||
|
radar.refreshComponent = delegate ()
|
||||||
|
{
|
||||||
|
ChartHelper.HideAllObject(chart.transform, INDICATOR_TEXT + "_" + radar.index);
|
||||||
radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||||
int indicatorNum = radar.indicatorList.Count;
|
for (int i = 0; i < radar.indicatorList.Count; i++)
|
||||||
float txtWid = 100;
|
|
||||||
float txtHig = 20;
|
|
||||||
for (int i = 0; i < indicatorNum; i++)
|
|
||||||
{
|
{
|
||||||
var indicator = radar.indicatorList[i];
|
var indicator = radar.indicatorList[i];
|
||||||
var pos = radar.GetIndicatorPosition(i);
|
var pos = radar.GetIndicatorPosition(i);
|
||||||
var textStyle = indicator.textStyle;
|
var textStyle = indicator.textStyle;
|
||||||
var objName = INDICATOR_TEXT + "_" + n + "_" + i;
|
var objName = INDICATOR_TEXT + "_" + radar.index + "_" + i;
|
||||||
var txt = ChartHelper.AddTextObject(objName, chart.transform, new Vector2(0.5f, 0.5f),
|
var txt = ChartHelper.AddTextObject(objName, chart.transform, new Vector2(0.5f, 0.5f),
|
||||||
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(txtWid, txtHig),
|
new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(txtWid, txtHig),
|
||||||
textStyle, chart.theme.radar);
|
textStyle, chart.theme.radar);
|
||||||
@@ -270,7 +263,8 @@ namespace XCharts
|
|||||||
var offset = new Vector3(textStyle.offset.x, textStyle.offset.y);
|
var offset = new Vector3(textStyle.offset.x, textStyle.offset.y);
|
||||||
AxisHelper.AdjustCircleLabelPos(txt, pos, radar.runtimeCenterPos, txtHig, offset);
|
AxisHelper.AdjustCircleLabelPos(txt, pos, radar.runtimeCenterPos, txtHig, offset);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
radar.refreshComponent?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawMutipleRadar(VertexHelper vh, Serie serie, int i)
|
private void DrawMutipleRadar(VertexHelper vh, Serie serie, int i)
|
||||||
|
|||||||
Reference in New Issue
Block a user