mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-29 20:58:47 +00:00
优化DataZoom的Marquee框选功能
This commit is contained in:
@@ -81,6 +81,7 @@ slug: /changelog
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2026.05.23) 优化`DataZoom`的`Marquee`框选功能
|
||||||
* (2026.05.23) 修复`DataZoom`内绘制的折线图可能会超出范围的问题
|
* (2026.05.23) 修复`DataZoom`内绘制的折线图可能会超出范围的问题
|
||||||
* (2026.05.23) 修复`Axis`的`inverse`没能正确反转的问题
|
* (2026.05.23) 修复`Axis`的`inverse`没能正确反转的问题
|
||||||
* (2026.05.23) 增加`LabelStyle`的`showCondition`,`showFilter`,`showThreshold`可控制`label`显示和隐藏
|
* (2026.05.23) 增加`LabelStyle`的`showCondition`,`showFilter`,`showThreshold`可控制`label`显示和隐藏
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace XCharts.Runtime
|
|||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class MarqueeStyle : ChildComponent
|
public class MarqueeStyle : ChildComponent
|
||||||
{
|
{
|
||||||
[SerializeField][Since("v3.5.0")] private bool m_Apply = false;
|
[SerializeField][Since("v3.5.0")] private bool m_Apply = true;
|
||||||
[SerializeField][Since("v3.5.0")] private bool m_RealRect = false;
|
[SerializeField][Since("v3.5.0")] private bool m_RealRect = false;
|
||||||
[SerializeField][Since("v3.5.0")] private AreaStyle m_AreaStyle = new AreaStyle();
|
[SerializeField][Since("v3.5.0")] private AreaStyle m_AreaStyle = new AreaStyle();
|
||||||
[SerializeField][Since("v3.5.0")] private LineStyle m_LineStyle = new LineStyle();
|
[SerializeField][Since("v3.5.0")] private LineStyle m_LineStyle = new LineStyle();
|
||||||
@@ -52,7 +52,7 @@ namespace XCharts.Runtime
|
|||||||
/// Custom checkboxes select ongoing callbacks.
|
/// Custom checkboxes select ongoing callbacks.
|
||||||
/// ||自定义选取框选取进行时的回调。
|
/// ||自定义选取框选取进行时的回调。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<DataZoom> onGoing { set { m_OnStart = value; } get { return m_OnStart; } }
|
public Action<DataZoom> onGoing { set { m_OnGoing = value; } get { return m_OnGoing; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Customize the callback at the end of the selection.
|
/// Customize the callback at the end of the selection.
|
||||||
/// ||自定义选取框结束选取时的回调。
|
/// ||自定义选取框结束选取时的回调。
|
||||||
|
|||||||
@@ -217,10 +217,23 @@ namespace XCharts.Runtime
|
|||||||
if (dataZoom.marqueeStyle.apply)
|
if (dataZoom.marqueeStyle.apply)
|
||||||
{
|
{
|
||||||
var grid = chart.GetGridOfDataZoom(dataZoom);
|
var grid = chart.GetGridOfDataZoom(dataZoom);
|
||||||
var start = (dataZoom.context.marqueeRect.x - grid.context.x) / grid.context.width * 100;
|
var currentRange = dataZoom.end - dataZoom.start;
|
||||||
var end = (dataZoom.context.marqueeRect.x - grid.context.x + dataZoom.context.marqueeRect.width) / grid.context.width * 100;
|
var startRatio = (dataZoom.context.marqueeRect.x - grid.context.x) / grid.context.width;
|
||||||
|
var endRatio = (dataZoom.context.marqueeRect.x - grid.context.x + dataZoom.context.marqueeRect.width) / grid.context.width;
|
||||||
|
var start = dataZoom.start + startRatio * currentRange;
|
||||||
|
var end = dataZoom.start + endRatio * currentRange;
|
||||||
|
if (start > end)
|
||||||
|
{
|
||||||
|
var temp = start;
|
||||||
|
start = end;
|
||||||
|
end = temp;
|
||||||
|
}
|
||||||
UpdateDataZoomRange(dataZoom, start, end, grid);
|
UpdateDataZoomRange(dataZoom, start, end, grid);
|
||||||
|
chart.OnDataZoomRangeChanged(dataZoom);
|
||||||
|
chart.RefreshChart();
|
||||||
}
|
}
|
||||||
|
dataZoom.context.marqueeRect = Rect.zero;
|
||||||
|
dataZoom.SetVerticesDirty();
|
||||||
if (dataZoom.marqueeStyle.onEnd != null)
|
if (dataZoom.marqueeStyle.onEnd != null)
|
||||||
{
|
{
|
||||||
dataZoom.marqueeStyle.onEnd(dataZoom);
|
dataZoom.marqueeStyle.onEnd(dataZoom);
|
||||||
@@ -793,7 +806,7 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
private void DrawMarquee(VertexHelper vh, DataZoom dataZoom)
|
private void DrawMarquee(VertexHelper vh, DataZoom dataZoom)
|
||||||
{
|
{
|
||||||
if (!dataZoom.enable || !dataZoom.supportMarquee)
|
if (!dataZoom.enable || !dataZoom.supportMarquee || !dataZoom.context.isMarqueeDrag)
|
||||||
return;
|
return;
|
||||||
var areaColor = dataZoom.marqueeStyle.areaStyle.GetColor(chart.theme.dataZoom.dataAreaColor);
|
var areaColor = dataZoom.marqueeStyle.areaStyle.GetColor(chart.theme.dataZoom.dataAreaColor);
|
||||||
UGL.DrawRectangle(vh, dataZoom.context.marqueeRect, areaColor);
|
UGL.DrawRectangle(vh, dataZoom.context.marqueeRect, areaColor);
|
||||||
|
|||||||
Reference in New Issue
Block a user