mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 17:00:08 +00:00
优化DataZoom
This commit is contained in:
37
Runtime/Helper/DataZoomHelper.cs
Normal file
37
Runtime/Helper/DataZoomHelper.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public static class DataZoomHelper
|
||||
{
|
||||
public static DataZoom GetDataZoom(Serie serie, List<DataZoom> dataZooms)
|
||||
{
|
||||
if(serie == null) return null;
|
||||
foreach (var dataZoom in dataZooms)
|
||||
{
|
||||
if (!dataZoom.enable) continue;
|
||||
if (dataZoom.IsContainsXAxis(serie.xAxisIndex)
|
||||
|| dataZoom.IsContainsYAxis(serie.yAxisIndex))
|
||||
{
|
||||
return dataZoom;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void UpdateDataZoomRuntimeStartEndValue(DataZoom dataZoom, Serie serie){
|
||||
if(dataZoom == null || serie == null) return;
|
||||
float min = 0;
|
||||
float max = 0;
|
||||
SerieHelper.GetMinMaxData(serie, out min, out max, null);
|
||||
dataZoom.runtimeStartValue = min + (max-min) * dataZoom.start / 100;
|
||||
dataZoom.runtimeEndValue = min +(max-min) * dataZoom.end / 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Helper/DataZoomHelper.cs.meta
Normal file
11
Runtime/Helper/DataZoomHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 629319d47e0ca4e4dad76864d4e7226b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -442,7 +442,7 @@ namespace XCharts
|
||||
public static void UpdateFilterData(Serie serie, DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom == null || !dataZoom.enable) return;
|
||||
if (dataZoom.xAxisIndexs.Contains(serie.xAxisIndex))
|
||||
if (dataZoom.IsContainsXAxis(serie.xAxisIndex))
|
||||
{
|
||||
if (dataZoom.IsXAxisIndexValue(serie.xAxisIndex))
|
||||
{
|
||||
@@ -455,7 +455,7 @@ namespace XCharts
|
||||
UpdateFilterData_Category(serie, dataZoom);
|
||||
}
|
||||
}
|
||||
else if (dataZoom.yAxisIndexs.Contains(serie.yAxisIndex))
|
||||
else if (dataZoom.IsContainsYAxis(serie.yAxisIndex))
|
||||
{
|
||||
if (dataZoom.IsYAxisIndexValue(serie.yAxisIndex))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user