mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 15:00:08 +00:00
增加DataZoom的orient参数设置水平或垂直样式
This commit is contained in:
@@ -5,25 +5,40 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public static class DataZoomHelper
|
||||
{
|
||||
public static DataZoom GetDataZoom(Serie serie, List<DataZoom> dataZooms)
|
||||
public static DataZoom GetAxisRelatedDataZoom(Axis axis, 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;
|
||||
}
|
||||
if (dataZoom.IsContainsAxis(axis)) return dataZoom;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static void GetSerieRelatedDataZoom(Serie serie, List<DataZoom> dataZooms,
|
||||
out DataZoom xDataZoom, out DataZoom yDataZoom)
|
||||
{
|
||||
xDataZoom = null;
|
||||
yDataZoom = null;
|
||||
if (serie == null) return;
|
||||
foreach (var dataZoom in dataZooms)
|
||||
{
|
||||
if (!dataZoom.enable) continue;
|
||||
if (dataZoom.IsContainsXAxis(serie.xAxisIndex))
|
||||
{
|
||||
xDataZoom = dataZoom;
|
||||
}
|
||||
if (dataZoom.IsContainsYAxis(serie.yAxisIndex))
|
||||
{
|
||||
yDataZoom = dataZoom;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateDataZoomRuntimeStartEndValue(DataZoom dataZoom, Serie serie)
|
||||
{
|
||||
@@ -35,22 +50,32 @@ namespace XCharts
|
||||
dataZoom.runtimeEndValue = min + (max - min) * dataZoom.end / 100;
|
||||
}
|
||||
|
||||
public static void UpdateDataZoomRuntimeStartEndValue(List<DataZoom> dataZooms, Series series, SerieType serieType)
|
||||
public static void UpdateDataZoomRuntimeStartEndValue(CoordinateChart chart, SerieType serieType)
|
||||
{
|
||||
foreach (var dataZoom in dataZooms)
|
||||
foreach (var dataZoom in chart.dataZooms)
|
||||
{
|
||||
if (!dataZoom.enable) continue;
|
||||
float min = float.MaxValue;
|
||||
float max = float.MinValue;
|
||||
foreach (var serie in series.list)
|
||||
foreach (var serie in chart.series.list)
|
||||
{
|
||||
if (!serie.show || serie.type != serieType) continue;
|
||||
if (!dataZoom.IsXAxisIndexValue(serie.xAxisIndex)) continue;
|
||||
var serieMinValue = 0f;
|
||||
var serieMaxValue = 0f;
|
||||
SerieHelper.GetMinMaxData(serie, out serieMinValue, out serieMaxValue, null, 2);
|
||||
if (serieMinValue < min) min = serieMinValue;
|
||||
if (serieMaxValue > max) max = serieMaxValue;
|
||||
if (!dataZoom.IsContainsXAxis(serie.xAxisIndex)) continue;
|
||||
var axis = chart.GetXAxis(serie.xAxisIndex);
|
||||
|
||||
if (axis.minMaxType == Axis.AxisMinMaxType.Custom)
|
||||
{
|
||||
if (axis.min < min) min = axis.min;
|
||||
if (axis.max > max) max = axis.max;
|
||||
}
|
||||
else
|
||||
{
|
||||
var serieMinValue = 0f;
|
||||
var serieMaxValue = 0f;
|
||||
SerieHelper.GetMinMaxData(serie, out serieMinValue, out serieMaxValue, null, 2);
|
||||
if (serieMinValue < min) min = serieMinValue;
|
||||
if (serieMaxValue > max) max = serieMaxValue;
|
||||
}
|
||||
}
|
||||
dataZoom.runtimeStartValue = min + (max - min) * dataZoom.start / 100;
|
||||
dataZoom.runtimeEndValue = min + (max - min) * dataZoom.end / 100;
|
||||
|
||||
Reference in New Issue
Block a user