mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 13:28:47 +00:00
优化DataZoom的Marquee框选功能
This commit is contained in:
@@ -869,21 +869,36 @@ namespace XCharts.Runtime
|
||||
private static void UpdateFilterData_Category(Serie serie, DataZoom dataZoom)
|
||||
{
|
||||
var data = serie.data;
|
||||
var range = Mathf.RoundToInt(data.Count * (dataZoom.end - dataZoom.start) / 100);
|
||||
if (range <= 0) range = 1;
|
||||
int start = 0, end = 0;
|
||||
if (dataZoom.context.invert)
|
||||
// Use (N-1) intervals so that data point i maps to exactly i/(N-1)*100% of the
|
||||
// DataZoom width — matching how the shadow draws data via scaleWid = width/(N-1).
|
||||
// CeilToInt for start ensures we never include a point that lies before the filler.
|
||||
// FloorToInt for end ensures we never include a point that lies after the filler.
|
||||
int n = data.Count - 1;
|
||||
int startIndex, endIndex;
|
||||
if (n > 0)
|
||||
{
|
||||
end = Mathf.RoundToInt(data.Count * dataZoom.end / 100);
|
||||
start = end - range;
|
||||
if (start < 0) start = 0;
|
||||
if (dataZoom.context.invert)
|
||||
{
|
||||
startIndex = Mathf.CeilToInt((float)n * (100 - dataZoom.end) / 100);
|
||||
endIndex = Mathf.FloorToInt((float)n * (100 - dataZoom.start) / 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
startIndex = Mathf.CeilToInt((float)n * dataZoom.start / 100);
|
||||
endIndex = Mathf.FloorToInt((float)n * dataZoom.end / 100);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
start = Mathf.RoundToInt(data.Count * dataZoom.start / 100);
|
||||
end = start + range;
|
||||
if (end > data.Count) end = data.Count;
|
||||
startIndex = 0;
|
||||
endIndex = 0;
|
||||
}
|
||||
var range = endIndex - startIndex + 1;
|
||||
if (range <= 0) range = 1;
|
||||
int start = startIndex;
|
||||
if (start < 0) start = 0;
|
||||
int end = start + range;
|
||||
if (end > data.Count) end = data.Count;
|
||||
var minZoomRatio = (int)(data.Count * dataZoom.minZoomRatio);
|
||||
if (start != serie.m_FilterStart || end != serie.m_FilterEnd ||
|
||||
minZoomRatio != serie.m_FilterMinShow || serie.m_NeedUpdateFilterData)
|
||||
|
||||
Reference in New Issue
Block a user