From 89b5bcd94c875777b898102ce94efa96952ac6f4 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 14 Mar 2021 05:23:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Tooltip`=E7=9A=84=E6=8C=87?= =?UTF-8?q?=E7=A4=BA=E5=99=A8=E5=9C=A8=E6=9F=90=E4=BA=9B=E6=83=85=E5=86=B5?= =?UTF-8?q?=E4=B8=8B=E6=8C=87=E7=A4=BA=E4=BD=8D=E7=BD=AE=E4=B8=8D=E5=87=86?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG-EN.md | 69 ++++++++++++----------- CHANGELOG.md | 1 + Examples/Runtime/Example90_Candlestick.cs | 3 +- Runtime/Internal/CoordinateChart.cs | 12 ++-- Runtime/Internal/Helper/AxisHelper.cs | 1 + 5 files changed, 45 insertions(+), 41 deletions(-) diff --git a/CHANGELOG-EN.md b/CHANGELOG-EN.md index 9372c3e6..cb73c420 100644 --- a/CHANGELOG-EN.md +++ b/CHANGELOG-EN.md @@ -32,7 +32,8 @@ ## Latest -* (2021.03.13) Optimize the editing experience and component refresh after `MulticomponentMode` is enabled #128 +* (2021.03.14) Fixed `Tooltip` indicator was not indicating the correct location in some cases +* (2021.03.13) Optimized the editing experience and component refresh after `MulticomponentMode` is enabled #128 * (2021.03.10) Added `CandlestickChart` #124 * (2021.03.06) Added `PieChart`'s `minAngle` parameter to support setting minimum sector angle #117 * (2021.03.05) Added support for `Legend` for several built-in ICONS #90 @@ -53,7 +54,7 @@ * (2021.02.05) Release `v2.0.0` version * (2021.02.03) Fixed an issue where `Axisline` `OnZero` did not work on `YAxis` #116 * (2021.01.29) Fixed incorrect display of `Tick` on `Category` axis when `BoundaryGap` and `alignWithLabel` are `True` #115 -* (2021.01.25) Optimize some details +* (2021.01.25) Optimized some details * (2021.01.22) Fixed a `Inpsector` displayed error ## v2.0.0-preview.2 @@ -81,14 +82,14 @@ * (2020.11.21) Fixed `Unity5` compatibility error reporting problem * (2020.11.13) Improved `RadarChart` `Indicator` support for `\n` line feed * (2020.11.12) Fixed `LineChart` reporting errors when the type was `Smooth` when the data was too secure #100 -* (2020.10.22) Improve the support of `VisualMap` for `Piecewise` in `HeatmapChart` +* (2020.10.22) Optimized 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 -* (2020.09.18) Optimize coordinate axis calibration and text display #93 -* (2020.09.17) fixed `Package` import missing `meta` file causing failure #92 -* (2020.09.08) Optimize the color of `Legend` to automatically match the custom color of `ItemStyle` -* (2020.09.05) Optimize `LineChart` to display `XAxis1` without using `XAxis1`. +* (2020.09.18) Optimized coordinate axis calibration and text display #93 +* (2020.09.17) Fixed `Package` import missing `meta` file causing failure #92 +* (2020.09.08) Optimized the color of `Legend` to automatically match the custom color of `ItemStyle` +* (2020.09.05) Optimized `LineChart` to display `XAxis1` without using `XAxis1`. * (2020.08.29) Added `toColor` and `toColor2` of `LineStyle` to set the horizontal gradient of `LineChart`. Cancel `ItemStyle` to set the horizontal gradient of `LineChart`. * (2020.08.29) Added the `onPointerClickPie` of `PieChart`, a callback function of click pie area. * (2020.08.29) Added the `onPointerClickBar` of `BarChart`, a callback function of click bar. @@ -97,10 +98,10 @@ * (2020.08.24) Release `v1.6.0` version * (2020.08.23) Refactor code, replace `Color` with `Color32` for reduce implicit conversion (Can cause custom colors to lose, reference [Q&A 29](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/xcharts-questions-and-answers-EN.md) to upgrade) -* (2020.08.15) Optimize `PieChart` drawing performance effect #85 +* (2020.08.15) Optimized `PieChart` drawing performance effect #85 * (2020.08.11) Added `LiquidChart` data change animation#83 -* (2020.08.11) Optimize `PieChart` text stack and lead line effects#85 -* (2020.08.08) Optimize `LineChart` the rendering performance of dense data +* (2020.08.11) Optimized `PieChart` text stack and lead line effects#85 +* (2020.08.08) Optimized `LineChart` the rendering performance of dense data * (2020.07.30) Added `LineChart` to configure gradient through `VisualMap` or `ItemStyle`#78 * (2020.07.25) Fixed a problem with `LineChart` emerging abnormal in animation drawing#79 * (2020.07.25) Fixed a problem with gradual discoloration on `LiquidChart` at `100%`#80 @@ -108,34 +109,32 @@ * (2020.07.23) Added `RingChart` ring gradient support#75 * (2020.07.21) Added `formatter` of `AxisLabel` and `SerieLabel` to configure numeric formatting separately. * (2020.07.17) Added animation completion callback interface for `SerieAnimation`. -* (2020.07.17) Optimize `Chart` under `ScrollView` without affecting the scrolling and dragging of `ScrollView`. +* (2020.07.17) Optimized `Chart` under `ScrollView` without affecting the scrolling and dragging of `ScrollView`. * (2020.07.16) Fixed a problem with `Tooltip` that would also show up if it was blocked on top. #74 -* (2020.07.08) 优化`Scatter`类型`Serie`支持`Log`轴#70 -* (2020.07.07) 修复`SerieLabel`位置错乱的问题 -* (2020.07.07) 增加`Tooltip`的`offset`参数配置偏移 -* (2020.07.06) 增加`LiquidChart`水位图 -* (2020.07.01) 增加`PolarChart`极坐标图表 +* (2020.07.07) Fixed issue where `SerieLabel` position was out of order +* (2020.07.07) Added `Tooltip` to the `offset` parameter +* (2020.07.06) Added `Liquidchart` +* (2020.07.01) Added `PolarChart` ## v1.5.2 -* (2020.06.25) 发布`v1.5.2`版本 -* (2020.06.25) 修复`BarChart`在数值为`0`时还会绘制一小部分柱条的问题 -* (2020.06.24) 修复`PieChart`在设置`clockwise`后绘制异常的问题#65 -* (2020.06.23) 优化`LineChart`在峰谷差异过大时的绘制效果#64 -* (2020.06.18) 修复`SerieLabel`在重新添加数据时可能不显示的问题 -* (2020.06.17) 增加`SerieData`可单独设置`SerieSymbol`#66 -* (2020.06.17) 修复`Check For Update`在`Unity 2018`部分版本报错的问题#63 -* (2020.06.16) 增加`Serie`的`avoidLabelOverlap`参数避免饼图标签堆叠的情况#56 -* (2020.06.15) 修复`SerieLabel`单独控制显示时可能错乱的问题 -* (2020.06.11) 修复`Check warning`不生效的问题 -* (2020.06.11) 修复`PieChart`和`RingChart`在数据占比很小时不显示的问题 -* (2020.06.11) 增加`Tooltip`的`titleFormatter`支持配置占位符`{i}`表示忽略不显示标题 -* (2020.06.07) 增加`Animation`的`customFadeInDelay`等自定义数据项延时和时长回调函数#58 -* (2020.06.07) 优化`PieChart`在数据全为`0`时的显示为等份的效果#59 -* (2020.06.04) 增加`SerieLabel`的`autoOffset`参数设置是否自动判断上下偏移 -* (2020.06.04) 增加`Tooltip`的`alwayShow`参数设置触发后一直显示 -* (2020.06.04) 优化`Tooltip`的`formatter`支持`{.1}`通配符 -* (2020.06.04) 优化`Legend`数量过多时自动换行显示#53 +* (2020.06.25) Fixed an issue where `BarChart` would draw a small number of bars when the value was `0` +* (2020.06.24) Fixed an issue where `PieChart` was drawing abnormally after setting `Clockwise` #65 +* (2020.06.23) Optimized the drawing effect of `LineChart` when the difference between peak and valley is too large #64 +* (2020.06.18) Fixed an issue where `SerieLabel` might not be displayed when adding data again +* (2020.06.17) Added `SerieData` to `serieSymbol` #66 +* (2020.06.17) Fixed `Check For Update` bug in `Unity 2018` version #63 +* (2020.06.16) Added `Serie` `avoidLabelOverlap` parameter to avoid pie chart TAB stacking #56 +* (2020.06.15) Fixed an issue where the `SerieLabel` control display could be deranged +* (2020.06.11) Fixed `Check warning` not working +* (2020.06.11) Fixed issue where `Piechart` and `Ringchart` were not displayed when data fraction was very small +* (2020.06.11) Added `Tooltip` to `titleFormatter` to support configuration placeholder `{i}` to ignore not showing titles +* (2020.06.07) Added `customFadeInDelay` and other custom data item delay and duration callback function #58 +* (2020.06.07) Optimized `Piechart` to display equal parts when all the data are `0` #59 +* (2020.06.04) Added `autoOffset` parameter setting for `SerieLabel` to determine whether the up and down offset is automatically determined +* (2020.06.04) Added `Tooltip` to `AlwayShow` parameter setting to always show after triggering +* (2020.06.04) Tooltip's `formatter` supports `{.1}` wildcards +* (2020.06.04) Optimizes the number of `Legend` to automatically wrap to display #53 ## v1.5.1 @@ -151,6 +150,8 @@ * (2020.05.27) 优化`柱状图`的渐变色效果 * (2020.05.24) 修复`Axis`同时设置`boundaryGap`和`alignWithLabel`时`Tick`绘制异常的问题 * (2020.05.24) 优化版本更新检测 +* (2020.06.25) release `v1.5.2` + ## v1.5.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 04ee2c0a..5842f1f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ ## Latest +* (2021.03.14) 修复`Tooltip`的指示器在某些情况下指示位置不准的问题 * (2021.03.13) 优化`MultiComponentMode`开启后的编辑体验和组件刷新 #128 * (2021.03.10) 增加`CandlestickChart`K线图 #124 * (2021.03.06) 增加`PieChart`的`minAngle`参数支持设置最小扇区角度 #117 diff --git a/Examples/Runtime/Example90_Candlestick.cs b/Examples/Runtime/Example90_Candlestick.cs index ed58a618..5da1af93 100644 --- a/Examples/Runtime/Example90_Candlestick.cs +++ b/Examples/Runtime/Example90_Candlestick.cs @@ -16,6 +16,7 @@ namespace XCharts.Examples { private CandlestickChart chart; private float updateTime; + public int dataCount = 100; void Awake() { @@ -24,7 +25,7 @@ namespace XCharts.Examples { chart = gameObject.AddComponent(); } - GenerateOHLC(1000); + GenerateOHLC(dataCount); } void Update() diff --git a/Runtime/Internal/CoordinateChart.cs b/Runtime/Internal/CoordinateChart.cs index a051b28d..d6f47e15 100644 --- a/Runtime/Internal/CoordinateChart.cs +++ b/Runtime/Internal/CoordinateChart.cs @@ -424,9 +424,9 @@ namespace XCharts else { labelText = axis.GetData((int)tooltip.runtimeXValues[axisIndex], dataZoom); - float splitWidth = AxisHelper.GetSplitWidth(axis, grid.runtimeWidth, dataZoom); - int index = (int)tooltip.runtimeXValues[axisIndex]; - float px = grid.runtimeX + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0) + 0.5f; + var splitWidth = AxisHelper.GetDataWidth(axis, grid.runtimeWidth, 0, dataZoom); + var index = (int)tooltip.runtimeXValues[axisIndex]; + var px = grid.runtimeX + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0); labelPos = new Vector2(px, posY - diff); } } @@ -442,9 +442,9 @@ namespace XCharts else { labelText = axis.GetData((int)tooltip.runtimeYValues[axisIndex], dataZoom); - float splitWidth = AxisHelper.GetSplitWidth(axis, grid.runtimeHeight, dataZoom); - int index = (int)tooltip.runtimeYValues[axisIndex]; - float py = grid.runtimeY + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0); + var splitWidth = AxisHelper.GetDataWidth(axis, grid.runtimeHeight, 0, dataZoom); + var index = (int)tooltip.runtimeYValues[axisIndex]; + var py = grid.runtimeY + index * splitWidth + (axis.boundaryGap ? splitWidth / 2 : 0); labelPos = new Vector2(posX - diff, py); } } diff --git a/Runtime/Internal/Helper/AxisHelper.cs b/Runtime/Internal/Helper/AxisHelper.cs index 5a233396..9544fc64 100644 --- a/Runtime/Internal/Helper/AxisHelper.cs +++ b/Runtime/Internal/Helper/AxisHelper.cs @@ -93,6 +93,7 @@ namespace XCharts var categoryCount = axis.GetDataNumber(dataZoom); int segment = (axis.boundaryGap ? categoryCount : categoryCount - 1); segment = segment <= 0 ? dataCount : segment; + if (segment <= 0) segment = 1; return coordinateWidth / segment; }