mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-22 08:50:10 +00:00
修复Axis的更新数据时效果不顺畅的问题
This commit is contained in:
@@ -29,7 +29,7 @@ namespace XCharts.Runtime
|
||||
if (axis.IsCategory() || !axis.show) return;
|
||||
double tempMinValue = 0;
|
||||
double tempMaxValue = 0;
|
||||
SeriesHelper.GetYMinMaxValue(chart, axis.polarIndex, true, axis.inverse, out tempMinValue,
|
||||
SeriesHelper.GetYMinMaxValue(chart, axis.polarIndex, axis.inverse, out tempMinValue,
|
||||
out tempMaxValue, true);
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
|
||||
if (tempMinValue != axis.context.minValue || tempMaxValue != axis.context.maxValue)
|
||||
|
||||
@@ -106,6 +106,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] protected AxisLabel m_AxisLabel = AxisLabel.defaultAxisLabel;
|
||||
[SerializeField] protected AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
|
||||
[SerializeField] protected AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
||||
[SerializeField] protected AxisAnimation m_Animation = new AxisAnimation();
|
||||
[SerializeField][Since("v3.2.0")] protected AxisMinorTick m_MinorTick = AxisMinorTick.defaultMinorTick;
|
||||
[SerializeField][Since("v3.2.0")] protected AxisMinorSplitLine m_MinorSplitLine = AxisMinorSplitLine.defaultMinorSplitLine;
|
||||
[SerializeField][Since("v3.4.0")] protected LabelStyle m_IndicatorLabel = new LabelStyle() { numericFormatter = "f2" };
|
||||
@@ -387,6 +388,15 @@ namespace XCharts.Runtime
|
||||
set { if (value != null) { m_IndicatorLabel = value; SetComponentDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// animation of axis.
|
||||
/// ||坐标轴动画。
|
||||
/// </summary>
|
||||
public AxisAnimation animation
|
||||
{
|
||||
get { return m_Animation; }
|
||||
set { if (value != null) { m_Animation = value; SetComponentDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to add new data at the head or at the end of the list.
|
||||
/// ||添加新数据时是在列表的头部还是尾部加入。
|
||||
/// </summary>
|
||||
@@ -439,7 +449,7 @@ namespace XCharts.Runtime
|
||||
splitArea.ClearVerticesDirty();
|
||||
minorTick.ClearVerticesDirty();
|
||||
minorSplitLine.ClearVerticesDirty();
|
||||
indicatorLabel.ClearComponentDirty();
|
||||
indicatorLabel.ClearVerticesDirty();
|
||||
}
|
||||
|
||||
public override void SetComponentDirty()
|
||||
@@ -474,6 +484,7 @@ namespace XCharts.Runtime
|
||||
axis.minorTick = minorTick.Clone();
|
||||
axis.minorSplitLine = minorSplitLine.Clone();
|
||||
axis.indicatorLabel = indicatorLabel.Clone();
|
||||
axis.animation = animation.Clone();
|
||||
axis.icons = new List<Sprite>();
|
||||
axis.data = new List<string>();
|
||||
ChartHelper.CopyList(axis.data, data);
|
||||
@@ -505,6 +516,7 @@ namespace XCharts.Runtime
|
||||
minorTick.Copy(axis.minorTick);
|
||||
minorSplitLine.Copy(axis.minorSplitLine);
|
||||
indicatorLabel.Copy(axis.indicatorLabel);
|
||||
animation.Copy(axis.animation);
|
||||
ChartHelper.CopyList(data, axis.data);
|
||||
ChartHelper.CopyList<Sprite>(icons, axis.icons);
|
||||
}
|
||||
@@ -713,11 +725,11 @@ namespace XCharts.Runtime
|
||||
if (IsCategory() && boundaryGap)
|
||||
{
|
||||
var each = axisLength / data.Count;
|
||||
return (float) (each * (value + 0.5f));
|
||||
return (float)(each * (value + 0.5f));
|
||||
}
|
||||
else
|
||||
{
|
||||
return axisLength * (float) ((value - context.minValue) / context.minMaxRange);
|
||||
return axisLength * (float)((value - context.minValue) / context.minMaxRange);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,7 +737,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (context.minMaxRange > 0)
|
||||
{
|
||||
return axisLength * ((float) (value / context.minMaxRange));
|
||||
return axisLength * ((float)(value / context.minMaxRange));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -789,7 +801,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (context.labelObjectList[i] != null)
|
||||
{
|
||||
var text = AxisHelper.GetLabelName(this, coordinateWidth, i, context.minValue, context.maxValue, dataZoom, forcePercent);
|
||||
var text = AxisHelper.GetLabelName(this, coordinateWidth, i, context.destMinValue, context.destMaxValue, dataZoom, forcePercent);
|
||||
context.labelObjectList[i].SetText(text);
|
||||
}
|
||||
}
|
||||
@@ -803,10 +815,27 @@ namespace XCharts.Runtime
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
internal void UpdateMinMaxValue(double minValue, double maxValue)
|
||||
internal void UpdateMinMaxValue(double minValue, double maxValue, bool needAnimation = false)
|
||||
{
|
||||
context.minValue = minValue;
|
||||
context.maxValue = maxValue;
|
||||
if (needAnimation)
|
||||
{
|
||||
if (context.lastMinValue == 0 && context.lastMaxValue == 0)
|
||||
{
|
||||
context.minValue = minValue;
|
||||
context.maxValue = maxValue;
|
||||
}
|
||||
context.lastMinValue = context.minValue;
|
||||
context.lastMaxValue = context.maxValue;
|
||||
context.destMinValue = minValue;
|
||||
context.destMaxValue = maxValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.minValue = minValue;
|
||||
context.maxValue = maxValue;
|
||||
context.destMinValue = minValue;
|
||||
context.destMaxValue = maxValue;
|
||||
}
|
||||
double tempRange = maxValue - minValue;
|
||||
if (context.minMaxRange != tempRange)
|
||||
{
|
||||
@@ -823,7 +852,7 @@ namespace XCharts.Runtime
|
||||
if (value <= 0 || value == 1)
|
||||
return 0;
|
||||
else
|
||||
return logBaseE ? (float) Math.Log(value) : (float) Math.Log(value, logBase);
|
||||
return logBaseE ? (float)Math.Log(value) : (float)Math.Log(value, logBase);
|
||||
}
|
||||
|
||||
public double GetLogMinIndex()
|
||||
@@ -868,8 +897,7 @@ namespace XCharts.Runtime
|
||||
0 :
|
||||
(context.maxValue < 0 ?
|
||||
axisLength :
|
||||
(float) (Math.Abs(context.minValue) * (axisLength /
|
||||
(Math.Abs(context.minValue) + Math.Abs(context.maxValue))))
|
||||
(float)(Math.Abs(context.minValue) * (axisLength / (Math.Abs(context.minValue) + Math.Abs(context.maxValue))))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,16 @@ namespace XCharts.Runtime
|
||||
/// ||当前最小值。
|
||||
/// </summary>
|
||||
public double minValue;
|
||||
public double lastMinValue { get; internal set; }
|
||||
public double destMinValue { get; internal set; }
|
||||
/// <summary>
|
||||
/// the current maximum value.
|
||||
/// ||当前最大值。
|
||||
/// </summary>
|
||||
public double maxValue;
|
||||
public double lastMaxValue { get; internal set; }
|
||||
public double destMaxValue { get; internal set; }
|
||||
public bool needAnimation { get; internal set; }
|
||||
/// <summary>
|
||||
/// the offset of zero position.
|
||||
/// ||坐标轴原点在坐标轴的偏移。
|
||||
|
||||
@@ -140,8 +140,9 @@ namespace XCharts
|
||||
return;
|
||||
}
|
||||
|
||||
double tempMinValue = 0;
|
||||
double tempMaxValue = 0;
|
||||
double tempMinValue;
|
||||
double tempMaxValue;
|
||||
axis.context.needAnimation = Application.isPlaying && axis.animation.show;
|
||||
chart.GetSeriesMinMaxValue(axis, axisIndex, out tempMinValue, out tempMaxValue);
|
||||
|
||||
var dataZoom = chart.GetDataZoomOfAxis(axis);
|
||||
@@ -152,14 +153,15 @@ namespace XCharts
|
||||
else
|
||||
dataZoom.SetYAxisIndexValueInfo(axisIndex, ref tempMinValue, ref tempMaxValue);
|
||||
}
|
||||
if (tempMinValue != axis.context.minValue ||
|
||||
tempMaxValue != axis.context.maxValue ||
|
||||
|
||||
if (tempMinValue != axis.context.destMinValue ||
|
||||
tempMaxValue != axis.context.destMaxValue ||
|
||||
m_LastInterval != axis.interval ||
|
||||
m_LastSplitNumber != axis.splitNumber)
|
||||
{
|
||||
m_LastSplitNumber = axis.splitNumber;
|
||||
m_LastInterval = axis.interval;
|
||||
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
|
||||
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue, axis.context.needAnimation);
|
||||
axis.context.offset = 0;
|
||||
axis.context.lastCheckInverse = axis.inverse;
|
||||
UpdateAxisTickValueList(axis);
|
||||
@@ -183,6 +185,36 @@ namespace XCharts
|
||||
chart.RefreshChart();
|
||||
}
|
||||
}
|
||||
|
||||
if (axis.context.needAnimation && (axis.context.minValue != axis.context.destMinValue || axis.context.maxValue != axis.context.destMaxValue))
|
||||
{
|
||||
var duration = axis.animation.duration == 0
|
||||
? SeriesHelper.GetMinAnimationDuration(chart.series) / 1000f
|
||||
: axis.animation.duration / 1000f;
|
||||
var deltaTime = axis.animation.unscaledTime ? Time.unscaledDeltaTime : Time.deltaTime;
|
||||
var minDiff = axis.context.destMinValue - axis.context.lastMinValue;
|
||||
var maxDiff = axis.context.destMaxValue - axis.context.lastMaxValue;
|
||||
var minDelta = minDiff / duration * deltaTime;
|
||||
var maxDelta = maxDiff / duration * deltaTime;
|
||||
axis.context.minValue += minDelta;
|
||||
axis.context.maxValue += maxDelta;
|
||||
if ((minDiff > 0 && axis.context.minValue > axis.context.destMinValue)
|
||||
|| (minDiff < 0 && axis.context.minValue < axis.context.destMinValue))
|
||||
{
|
||||
axis.context.minValue = axis.context.destMinValue;
|
||||
axis.context.lastMinValue = axis.context.destMinValue;
|
||||
}
|
||||
if ((maxDiff > 0 && axis.context.maxValue > axis.context.destMaxValue)
|
||||
|| (maxDiff < 0 && axis.context.maxValue < axis.context.destMaxValue))
|
||||
{
|
||||
axis.context.maxValue = axis.context.destMaxValue;
|
||||
axis.context.lastMaxValue = axis.context.destMaxValue;
|
||||
}
|
||||
axis.context.minMaxRange = axis.context.maxValue - axis.context.minValue;
|
||||
UpdateAxisTickValueList(axis);
|
||||
UpdateAxisLabelText(axis);
|
||||
chart.RefreshChart();
|
||||
}
|
||||
}
|
||||
|
||||
internal virtual void UpdateAxisLabelText(Axis axis)
|
||||
@@ -376,8 +408,8 @@ namespace XCharts
|
||||
{
|
||||
var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
|
||||
var labelName = AxisHelper.GetLabelName(axis, axisLength, i,
|
||||
axis.context.minValue,
|
||||
axis.context.maxValue,
|
||||
axis.context.destMinValue,
|
||||
axis.context.destMaxValue,
|
||||
dataZoom, isPercentStack);
|
||||
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i,
|
||||
@@ -631,7 +663,8 @@ namespace XCharts
|
||||
minorTickDistance = scaleWidth * axis.GetLogValue(1 + (count + 1) * logRange / minorTickSplitNumber);
|
||||
tickTotal = lastTickX + minorTickDistance;
|
||||
}
|
||||
}else if (lastTickX <= axis.context.zeroX || (i == minorStartIndex && pX > axis.context.zeroX))
|
||||
}
|
||||
else if (lastTickX <= axis.context.zeroX || (i == minorStartIndex && pX > axis.context.zeroX))
|
||||
{
|
||||
var tickTotal = pX - minorTickDistance;
|
||||
while (tickTotal > lastTickX)
|
||||
|
||||
@@ -106,18 +106,20 @@ namespace XCharts.Runtime
|
||||
|
||||
public new AxisLabel Clone()
|
||||
{
|
||||
var axisLabel = new AxisLabel();
|
||||
axisLabel.show = show;
|
||||
axisLabel.formatter = formatter;
|
||||
axisLabel.interval = interval;
|
||||
axisLabel.inside = inside;
|
||||
axisLabel.distance = distance;
|
||||
axisLabel.numericFormatter = numericFormatter;
|
||||
axisLabel.width = width;
|
||||
axisLabel.height = height;
|
||||
axisLabel.showStartLabel = showStartLabel;
|
||||
axisLabel.showEndLabel = showEndLabel;
|
||||
axisLabel.textLimit = textLimit.Clone();
|
||||
var axisLabel = new AxisLabel
|
||||
{
|
||||
show = show,
|
||||
formatter = formatter,
|
||||
interval = interval,
|
||||
inside = inside,
|
||||
distance = distance,
|
||||
numericFormatter = numericFormatter,
|
||||
width = width,
|
||||
height = height,
|
||||
showStartLabel = showStartLabel,
|
||||
showEndLabel = showEndLabel,
|
||||
textLimit = textLimit.Clone()
|
||||
};
|
||||
axisLabel.textStyle.Copy(textStyle);
|
||||
return axisLabel;
|
||||
}
|
||||
|
||||
@@ -51,9 +51,9 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (axis == null) return;
|
||||
if (axis.IsCategory() || !axis.show) return;
|
||||
double tempMinValue = 0;
|
||||
double tempMaxValue = 0;
|
||||
SeriesHelper.GetXMinMaxValue(chart, axis.polarIndex, true, axis.inverse, out tempMinValue,
|
||||
double tempMinValue;
|
||||
double tempMaxValue;
|
||||
SeriesHelper.GetXMinMaxValue(chart, axis.polarIndex, axis.inverse, out tempMinValue,
|
||||
out tempMaxValue, true);
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
|
||||
if (tempMinValue != axis.context.minValue || tempMaxValue != axis.context.maxValue)
|
||||
|
||||
@@ -529,7 +529,7 @@ namespace XCharts.Runtime
|
||||
Vector3 np = Vector3.zero;
|
||||
double minValue = 0;
|
||||
double maxValue = 0;
|
||||
SeriesHelper.GetYMinMaxValue(chart, 0, chart.IsAllAxisValue(), axis.inverse, out minValue, out maxValue, false, false);
|
||||
SeriesHelper.GetYMinMaxValue(chart, 0, axis.inverse, out minValue, out maxValue, false, false);
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref minValue, ref maxValue, true);
|
||||
|
||||
int rate = 1;
|
||||
@@ -621,7 +621,7 @@ namespace XCharts.Runtime
|
||||
Vector3 np = Vector3.zero;
|
||||
double minValue = 0;
|
||||
double maxValue = 0;
|
||||
SeriesHelper.GetYMinMaxValue(chart, 0, chart.IsAllAxisValue(), axis.inverse, out minValue, out maxValue);
|
||||
SeriesHelper.GetYMinMaxValue(chart, 0, axis.inverse, out minValue, out maxValue);
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref minValue, ref maxValue, true);
|
||||
|
||||
int rate = 1;
|
||||
|
||||
@@ -10,20 +10,21 @@ namespace XCharts.Runtime
|
||||
|
||||
public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double tempMinValue, out double tempMaxValue)
|
||||
{
|
||||
var needAnimationData = !axis.context.needAnimation;
|
||||
if (IsAllAxisValue())
|
||||
{
|
||||
if (axis is XAxis)
|
||||
{
|
||||
SeriesHelper.GetXMinMaxValue(this, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue, false, false);
|
||||
SeriesHelper.GetXMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
|
||||
}
|
||||
else
|
||||
{
|
||||
SeriesHelper.GetYMinMaxValue(this, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||
SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SeriesHelper.GetYMinMaxValue(this, axisIndex, false, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||
SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
|
||||
}
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace XCharts.Runtime
|
||||
ref bool dataChanging, Axis axis, bool unscaledTime)
|
||||
{
|
||||
var inverse = axis.inverse;
|
||||
var minValue = axis.context.minValue;
|
||||
var maxValue = axis.context.maxValue;
|
||||
var minValue = 0;
|
||||
var maxValue = 0;
|
||||
if (rate <= 1 || index == minCount)
|
||||
{
|
||||
if (showData[index].IsDataChanged())
|
||||
|
||||
@@ -192,8 +192,6 @@ namespace XCharts.Runtime
|
||||
var dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var interactDuration = serie.animation.GetInteractionDuration();
|
||||
var yMinValue = relativedAxis.context.minValue;
|
||||
var yMaxValue = relativedAxis.context.maxValue;
|
||||
|
||||
var areaColor = ColorUtil.clearColor32;
|
||||
var areaToColor = ColorUtil.clearColor32;
|
||||
@@ -219,7 +217,7 @@ namespace XCharts.Runtime
|
||||
var state = SerieHelper.GetSerieState(serie, serieData);
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, state);
|
||||
var value = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse);
|
||||
var relativedValue = serieData.GetCurrData(1, dataAddDuration, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue, serie.animation.unscaledTime);
|
||||
var relativedValue = serieData.GetCurrData(1, dataAddDuration, dataChangeDuration, relativedAxis.inverse, 0, 0, serie.animation.unscaledTime);
|
||||
var borderWidth = relativedValue == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
var borderGap = relativedValue == 0 ? 0 : itemStyle.borderGap;
|
||||
var borderGapAndWidth = borderWidth + borderGap;
|
||||
|
||||
@@ -137,8 +137,6 @@ namespace XCharts.Runtime
|
||||
var dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var interactDuration = serie.animation.GetInteractionDuration();
|
||||
double yMinValue = relativedAxis.context.minValue;
|
||||
double yMaxValue = relativedAxis.context.maxValue;
|
||||
|
||||
var areaColor = ColorUtil.clearColor32;
|
||||
var areaToColor = ColorUtil.clearColor32;
|
||||
@@ -163,7 +161,7 @@ namespace XCharts.Runtime
|
||||
var highlight = serieData.context.highlight || serie.highlight;
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
|
||||
var value = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse);
|
||||
var relativedValue = serieData.GetCurrData(1, dataAddDuration, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue, serie.animation.unscaledTime);
|
||||
var relativedValue = serieData.GetCurrData(1, dataAddDuration, dataChangeDuration, relativedAxis.inverse, 0, 0, serie.animation.unscaledTime);
|
||||
var borderWidth = relativedValue == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
|
||||
if (!serieData.interact.TryGetColor(ref areaColor, ref areaToColor, ref interacting, interactDuration))
|
||||
|
||||
@@ -249,7 +249,7 @@ namespace XCharts.Runtime
|
||||
var isRectSymbol = symbol.type == SymbolType.Rect;
|
||||
SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, serieData, chart.theme, state);
|
||||
var value = serieData.GetCurrData(dimension, dataAddDuration, dataChangeDuration, yAxis.inverse,
|
||||
yAxis.context.minValue, yAxis.context.maxValue, unscaledTime);
|
||||
0, 0, unscaledTime);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
var pos = new Vector3(zeroX + (i + 0.5f) * xWidth,
|
||||
zeroY + (j + 0.5f) * yWidth);
|
||||
|
||||
@@ -308,10 +308,10 @@ namespace XCharts.Runtime
|
||||
/// <param name="axisIndex"></param>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public static void GetXMinMaxValue(BaseChart chart, int axisIndex, bool isValueAxis,
|
||||
bool inverse, out double minValue, out double maxValue, bool isPolar = false, bool filterByDataZoom = true)
|
||||
public static void GetXMinMaxValue(BaseChart chart, int axisIndex, bool inverse, out double minValue,
|
||||
out double maxValue, bool isPolar = false, bool filterByDataZoom = true, bool needAnimation = false)
|
||||
{
|
||||
GetMinMaxValue(chart, axisIndex, isValueAxis, inverse, false, out minValue, out maxValue, isPolar, filterByDataZoom);
|
||||
GetMinMaxValue(chart, axisIndex, inverse, false, out minValue, out maxValue, isPolar, filterByDataZoom, needAnimation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -321,18 +321,17 @@ namespace XCharts.Runtime
|
||||
/// <param name="axisIndex"></param>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
public static void GetYMinMaxValue(BaseChart chart, int axisIndex, bool isValueAxis,
|
||||
bool inverse, out double minValue, out double maxValue, bool isPolar = false, bool filterByDataZoom = true)
|
||||
public static void GetYMinMaxValue(BaseChart chart, int axisIndex, bool inverse, out double minValue,
|
||||
out double maxValue, bool isPolar = false, bool filterByDataZoom = true, bool needAnimation = false)
|
||||
{
|
||||
GetMinMaxValue(chart, axisIndex, isValueAxis, inverse, true, out minValue, out maxValue, isPolar, filterByDataZoom);
|
||||
GetMinMaxValue(chart, axisIndex, inverse, true, out minValue, out maxValue, isPolar, filterByDataZoom, needAnimation);
|
||||
}
|
||||
|
||||
private static Dictionary<int, List<Serie>> _stackSeriesForMinMax = new Dictionary<int, List<Serie>>();
|
||||
private static Dictionary<int, double> _serieTotalValueForMinMax = new Dictionary<int, double>();
|
||||
private static DataZoom xDataZoom, yDataZoom;
|
||||
public static void GetMinMaxValue(BaseChart chart, int axisIndex, bool isValueAxis,
|
||||
public static void GetMinMaxValue(BaseChart chart, int axisIndex,
|
||||
bool inverse, bool yValue, out double minValue, out double maxValue, bool isPolar = false,
|
||||
bool filterByDataZoom = true)
|
||||
bool filterByDataZoom = true, bool needAnimation = false)
|
||||
{
|
||||
double min = double.MaxValue;
|
||||
double max = double.MinValue;
|
||||
@@ -346,8 +345,8 @@ namespace XCharts.Runtime
|
||||
if ((isPolar && serie.polarIndex != axisIndex) ||
|
||||
(!isPolar && serie.yAxisIndex != axisIndex) ||
|
||||
!serie.show) continue;
|
||||
var updateDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var updateDuration = needAnimation ? serie.animation.GetChangeDuration() : 0;
|
||||
var dataAddDuration = needAnimation ? serie.animation.GetAdditionDuration() : 0;
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
if (isPercentStack && SeriesHelper.IsPercentStack<Bar>(series, serie.serieName))
|
||||
{
|
||||
@@ -406,8 +405,8 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
var updateDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var updateDuration = needAnimation ? serie.animation.GetChangeDuration() : 0;
|
||||
var dataAddDuration = needAnimation ? serie.animation.GetAdditionDuration() : 0;
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
for (int j = 0; j < showData.Count; j++)
|
||||
{
|
||||
@@ -420,10 +419,8 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
//currData = yValue ? showData[j].GetData(1) : showData[j].GetData(0);
|
||||
currData = showData[j].GetCurrData(yValue ? 1 : 0, dataAddDuration, updateDuration, unscaledTime, inverse);
|
||||
}
|
||||
//if (inverse) currData = -currData;
|
||||
if (!serie.IsIgnoreValue(showData[j], currData))
|
||||
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] + currData;
|
||||
}
|
||||
@@ -466,5 +463,18 @@ namespace XCharts.Runtime
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public static float GetMinAnimationDuration(List<Serie> series)
|
||||
{
|
||||
float min = float.MaxValue;
|
||||
foreach (var serie in series)
|
||||
{
|
||||
var changeAnimation = serie.animation.change.duration;
|
||||
var additionAnimation = serie.animation.addition.duration;
|
||||
if (changeAnimation != 0 && changeAnimation < min) min = changeAnimation;
|
||||
if (additionAnimation != 0 && additionAnimation < min) min = additionAnimation;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user