From 95cf5ed30340a821e31f27bbc6d9bb80c0b7f791 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 22 Oct 2020 09:39:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84`HeatmapChart`=E4=B8=AD`Visua?= =?UTF-8?q?lMap`=E5=AF=B9`Piecewise`=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/XCharts/CHANGELOG-EN.md | 1 + Assets/XCharts/CHANGELOG.md | 1 + Assets/XCharts/Runtime/Component/Main/VisualMap.cs | 2 +- .../Runtime/Internal/CoordinateChart_DrawHeatmap.cs | 8 ++++---- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Assets/XCharts/CHANGELOG-EN.md b/Assets/XCharts/CHANGELOG-EN.md index 055bdc75..b66dd70a 100644 --- a/Assets/XCharts/CHANGELOG-EN.md +++ b/Assets/XCharts/CHANGELOG-EN.md @@ -1,6 +1,7 @@ # 更新日志 +* (2020.10.22) Improve the support of `VisualMap` for `Piecewise` in `HeatmapChart` * (2020.09.22) Fixed `PieChart` inconsistent border size * (2020.09.18) Added `Remove All Chart Object` to Remove All child nodes under the Chart (automatically reinitialized) * (2020.09.18) Fixed `SerieLabel` also displayed after hided `Serie` by clicked the legend #94 diff --git a/Assets/XCharts/CHANGELOG.md b/Assets/XCharts/CHANGELOG.md index 3bc182bd..0e9f02e9 100644 --- a/Assets/XCharts/CHANGELOG.md +++ b/Assets/XCharts/CHANGELOG.md @@ -1,6 +1,7 @@ # 更新日志 +* (2020.10.22) 完善`HeatmapChart`中`VisualMap`对`Piecewise`的支持 * (2020.09.22) 修复`PieChart`边框大小不一致的问题 * (2020.09.19) 发布`v1.6.1`版本 * (2020.09.19) 增加`Remove All Chart Object`移除图表下的所有子节点(会自动重新初始化) diff --git a/Assets/XCharts/Runtime/Component/Main/VisualMap.cs b/Assets/XCharts/Runtime/Component/Main/VisualMap.cs index ebbdaa3a..ab08cafa 100644 --- a/Assets/XCharts/Runtime/Component/Main/VisualMap.cs +++ b/Assets/XCharts/Runtime/Component/Main/VisualMap.cs @@ -454,7 +454,7 @@ namespace XCharts if (splitNumber <= 0) return -1; value = Mathf.Clamp(value, m_Min, m_Max); - var diff = (m_Max - m_Min) / (splitNumber - (IsPiecewise() ? 0 : 1)); + var diff = (m_Max - m_Min) / (splitNumber - 1); var index = -1; for (int i = 0; i < splitNumber; i++) { diff --git a/Assets/XCharts/Runtime/Internal/CoordinateChart_DrawHeatmap.cs b/Assets/XCharts/Runtime/Internal/CoordinateChart_DrawHeatmap.cs index 2bfe3caa..72b17023 100644 --- a/Assets/XCharts/Runtime/Internal/CoordinateChart_DrawHeatmap.cs +++ b/Assets/XCharts/Runtime/Internal/CoordinateChart_DrawHeatmap.cs @@ -282,7 +282,7 @@ namespace XCharts { var splitPos = pos1 + dir * (i - 1 + 0.5f) * splitWid; var startColor = colors[i - 1]; - var toColor = colors[i]; + var toColor = m_VisualMap.IsPiecewise() ? startColor : colors[i]; ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical); } else if (rangeMin > splitMin && rangeMax >= splitMax) @@ -291,7 +291,7 @@ namespace XCharts var splitMaxPos = pos1 + dir * i * splitWid; var splitPos = p0 + (splitMaxPos - p0) / 2; var startColor = m_VisualMap.GetColor(m_VisualMap.rangeMin); - var toColor = colors[i]; + var toColor = m_VisualMap.IsPiecewise() ? startColor : colors[i]; var yRadius1 = Vector3.Distance(p0, splitMaxPos) / 2; if (m_VisualMap.orient == Orient.Vertical) ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical); @@ -304,7 +304,7 @@ namespace XCharts var splitMinPos = pos1 + dir * (i - 1) * splitWid; var splitPos = splitMinPos + (p0 - splitMinPos) / 2; var startColor = colors[i - 1]; - var toColor = m_VisualMap.GetColor(m_VisualMap.rangeMax); + var toColor = m_VisualMap.IsPiecewise() ? startColor : m_VisualMap.GetColor(m_VisualMap.rangeMax); var yRadius1 = Vector3.Distance(p0, splitMinPos) / 2; if (m_VisualMap.orient == Orient.Vertical) ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical); @@ -332,7 +332,7 @@ namespace XCharts { var splitPos = pos1 + dir * (i - 1 + 0.5f) * splitWid; var startColor = colors[i - 1]; - var toColor = colors[i]; + var toColor = m_VisualMap.IsPiecewise() ? startColor : colors[i]; ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical); } }