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