mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 17:30:10 +00:00
[improve][serie] improve min-max data range
This commit is contained in:
@@ -58,6 +58,8 @@
|
||||
|
||||
## master
|
||||
|
||||
* (2022.08.29) 优化`BarChart`在数据过密时的默认表现
|
||||
* (2022.08.29) 优化`DataZoom`下Y轴的最大最小值计算
|
||||
* (2022.08.29) 优化`CandlestickChart`大量数据绘制
|
||||
* (2022.08.28) 修复`LineChart`在堆叠和自定义Y轴范围的情况下显示不正常的问题
|
||||
* (2022.08.26) 增加`Legend`新图标类型`Candlestick`
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace XCharts.Runtime
|
||||
if (axis.IsCategory() || !axis.show) return;
|
||||
double tempMinValue = 0;
|
||||
double tempMaxValue = 0;
|
||||
SeriesHelper.GetYMinMaxValue(chart.series, null, axis.polarIndex, true, axis.inverse, out tempMinValue,
|
||||
SeriesHelper.GetYMinMaxValue(chart, axis.polarIndex, true, axis.inverse, out tempMinValue,
|
||||
out tempMaxValue, true);
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
|
||||
if (tempMinValue != axis.context.minValue || tempMaxValue != axis.context.maxValue)
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace XCharts.Runtime
|
||||
if (axis.IsCategory() || !axis.show) return;
|
||||
double tempMinValue = 0;
|
||||
double tempMaxValue = 0;
|
||||
SeriesHelper.GetXMinMaxValue(chart.series, null, axis.polarIndex, true, axis.inverse, out tempMinValue,
|
||||
SeriesHelper.GetXMinMaxValue(chart, axis.polarIndex, true, axis.inverse, out tempMinValue,
|
||||
out tempMaxValue, true);
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
|
||||
if (tempMinValue != axis.context.minValue || tempMaxValue != axis.context.maxValue)
|
||||
|
||||
@@ -464,7 +464,7 @@ namespace XCharts.Runtime
|
||||
Vector3 np = Vector3.zero;
|
||||
double minValue = 0;
|
||||
double maxValue = 0;
|
||||
SeriesHelper.GetYMinMaxValue(chart.series, null, 0, chart.IsAllAxisValue(), axis.inverse, out minValue, out maxValue);
|
||||
SeriesHelper.GetYMinMaxValue(chart, 0, chart.IsAllAxisValue(), axis.inverse, out minValue, out maxValue, false, false);
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref minValue, ref maxValue, true);
|
||||
|
||||
int rate = 1;
|
||||
@@ -553,7 +553,7 @@ namespace XCharts.Runtime
|
||||
Vector3 np = Vector3.zero;
|
||||
double minValue = 0;
|
||||
double maxValue = 0;
|
||||
SeriesHelper.GetYMinMaxValue(chart.series, null, 0, chart.IsAllAxisValue(), axis.inverse, out minValue, out maxValue);
|
||||
SeriesHelper.GetYMinMaxValue(chart, 0, chart.IsAllAxisValue(), axis.inverse, out minValue, out maxValue);
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref minValue, ref maxValue, true);
|
||||
|
||||
int rate = 1;
|
||||
|
||||
@@ -349,6 +349,22 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public DataZoom GetXDataZoomOfSerie(Serie serie)
|
||||
{
|
||||
if (serie == null) return null;
|
||||
foreach (var component in m_Components)
|
||||
{
|
||||
if (component is DataZoom)
|
||||
{
|
||||
var dataZoom = component as DataZoom;
|
||||
if (!dataZoom.enable) continue;
|
||||
if (dataZoom.IsContainsXAxis(serie.xAxisIndex))
|
||||
return dataZoom;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// reutrn true when all the show axis is `Value` type.
|
||||
/// |纯数值坐标轴(数值轴或对数轴)。
|
||||
|
||||
@@ -6,8 +6,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
public partial class BaseChart
|
||||
{
|
||||
public virtual void InitAxisRuntimeData(Axis axis)
|
||||
{ }
|
||||
public virtual void InitAxisRuntimeData(Axis axis) { }
|
||||
|
||||
public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double tempMinValue, out double tempMaxValue)
|
||||
{
|
||||
@@ -15,16 +14,16 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (axis is XAxis)
|
||||
{
|
||||
SeriesHelper.GetXMinMaxValue(m_Series, null, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||
SeriesHelper.GetXMinMaxValue(this, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
SeriesHelper.GetYMinMaxValue(m_Series, null, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||
SeriesHelper.GetYMinMaxValue(this, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SeriesHelper.GetYMinMaxValue(m_Series, null, axisIndex, false, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||
SeriesHelper.GetYMinMaxValue(this, axisIndex, false, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||
}
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
|
||||
}
|
||||
|
||||
@@ -300,10 +300,10 @@ namespace XCharts.Runtime
|
||||
/// <param name="axisIndex"></param>
|
||||
/// <param name="minVaule"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public static void GetXMinMaxValue(List<Serie> series, DataZoom dataZoom, int axisIndex, bool isValueAxis,
|
||||
bool inverse, out double minVaule, out double maxValue, bool isPolar = false)
|
||||
public static void GetXMinMaxValue(BaseChart chart, int axisIndex, bool isValueAxis,
|
||||
bool inverse, out double minVaule, out double maxValue, bool isPolar = false, bool filterByDataZoom = true)
|
||||
{
|
||||
GetMinMaxValue(series, dataZoom, axisIndex, isValueAxis, inverse, false, out minVaule, out maxValue, isPolar);
|
||||
GetMinMaxValue(chart, axisIndex, isValueAxis, inverse, false, out minVaule, out maxValue, isPolar, filterByDataZoom);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -313,19 +313,22 @@ namespace XCharts.Runtime
|
||||
/// <param name="axisIndex"></param>
|
||||
/// <param name="minVaule"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public static void GetYMinMaxValue(List<Serie> series, DataZoom dataZoom, int axisIndex, bool isValueAxis,
|
||||
bool inverse, out double minVaule, out double maxValue, bool isPolar = false)
|
||||
public static void GetYMinMaxValue(BaseChart chart, int axisIndex, bool isValueAxis,
|
||||
bool inverse, out double minVaule, out double maxValue, bool isPolar = false, bool filterByDataZoom = true)
|
||||
{
|
||||
GetMinMaxValue(series, dataZoom, axisIndex, isValueAxis, inverse, true, out minVaule, out maxValue, isPolar);
|
||||
GetMinMaxValue(chart, axisIndex, isValueAxis, inverse, true, out minVaule, out maxValue, isPolar, filterByDataZoom);
|
||||
}
|
||||
|
||||
private static Dictionary<int, List<Serie>> _stackSeriesForMinMax = new Dictionary<int, List<Serie>>();
|
||||
private static Dictionary<int, double> _serieTotalValueForMinMax = new Dictionary<int, double>();
|
||||
public static void GetMinMaxValue(List<Serie> series, DataZoom dataZoom, int axisIndex, bool isValueAxis,
|
||||
bool inverse, bool yValue, out double minVaule, out double maxValue, bool isPolar = false)
|
||||
private static DataZoom xDataZoom, yDataZoom;
|
||||
public static void GetMinMaxValue(BaseChart chart, int axisIndex, bool isValueAxis,
|
||||
bool inverse, bool yValue, out double minVaule, out double maxValue, bool isPolar = false,
|
||||
bool filterByDataZoom = true)
|
||||
{
|
||||
double min = double.MaxValue;
|
||||
double max = double.MinValue;
|
||||
var series = chart.series;
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(series);
|
||||
if (!SeriesHelper.IsStack(series) || (isValueAxis && !yValue))
|
||||
{
|
||||
@@ -343,7 +346,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
var showData = serie.GetDataList(dataZoom);
|
||||
var showData = serie.GetDataList(filterByDataZoom?chart.GetXDataZoomOfSerie(serie) : null);
|
||||
if (serie is Candlestick || serie is SimplifiedCandlestick)
|
||||
{
|
||||
foreach (var data in showData)
|
||||
@@ -381,7 +384,7 @@ namespace XCharts.Runtime
|
||||
if ((isPolar && serie.polarIndex != axisIndex) ||
|
||||
(!isPolar && serie.yAxisIndex != axisIndex) ||
|
||||
!serie.show) continue;
|
||||
var showData = serie.GetDataList(dataZoom);
|
||||
var showData = serie.GetDataList(filterByDataZoom?chart.GetXDataZoomOfSerie(serie) : null);
|
||||
if (SeriesHelper.IsPercentStack<Bar>(series, serie.stack))
|
||||
{
|
||||
for (int j = 0; j < showData.Count; j++)
|
||||
|
||||
Reference in New Issue
Block a user