mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-18 14:30:10 +00:00
修复Axis的更新数据时效果不顺畅的问题
This commit is contained in:
@@ -22,6 +22,7 @@ slug: /api
|
||||
- [AreaStyle](#areastyle)
|
||||
- [ArrowStyle](#arrowstyle)
|
||||
- [Axis](#axis)
|
||||
- [AxisAnimation](#axisanimation)
|
||||
- [AxisContext](#axiscontext)
|
||||
- [AxisHandler<T>](#axishandlert)
|
||||
- [AxisHelper](#axishelper)
|
||||
@@ -451,6 +452,19 @@ The axis in rectangular coordinate.
|
||||
|UpdateIcon()||public void UpdateIcon(int index, Sprite icon)<br/>更新图标 |
|
||||
|UpdateZeroOffset()||public void UpdateZeroOffset(float axisLength)|
|
||||
|
||||
## AxisAnimation
|
||||
|
||||
> class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
|
||||
|
||||
> Since `v3.9.0`
|
||||
|
||||
animation style of axis.
|
||||
|
||||
|public method|since|description|
|
||||
|--|--|--|
|
||||
|Clone()||public AxisAnimation Clone()|
|
||||
|Copy()||public void Copy(AxisAnimation animation)|
|
||||
|
||||
## AxisContext
|
||||
|
||||
> class in XCharts.Runtime / Inherits from: [MainComponentContext](#maincomponentcontext)
|
||||
@@ -1114,7 +1128,7 @@ Configurations of blur state.
|
||||
|
||||
## ChildComponent
|
||||
|
||||
> class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle),[AxisName](#axisname),[AxisSplitArea](#axissplitarea),[AreaStyle](#areastyle),[ArrowStyle](#arrowstyle),[BaseLine](#baseline),[IconStyle](#iconstyle),[ImageStyle](#imagestyle),[ItemStyle](#itemstyle),[Level](#level),[LevelStyle](#levelstyle),[LineArrow](#linearrow),[LineStyle](#linestyle),[Location](#location),[MLValue](#mlvalue),[MarqueeStyle](#marqueestyle),[Padding](#padding),[StageColor](#stagecolor),[SymbolStyle](#symbolstyle),[TextLimit](#textlimit),[TextStyle](#textstyle),[CommentItem](#commentitem),[CommentMarkStyle](#commentmarkstyle),[LabelLine](#labelline),[LabelStyle](#labelstyle),[MarkAreaData](#markareadata),[MarkLineData](#marklinedata),[StateStyle](#statestyle),[VisualMapRange](#visualmaprange),[UIComponentTheme](#uicomponenttheme),[SerieData](#seriedata),[ComponentTheme](#componenttheme),[SerieTheme](#serietheme),[ThemeStyle](#themestyle)
|
||||
> class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle),[AxisAnimation](#axisanimation),[AxisName](#axisname),[AxisSplitArea](#axissplitarea),[AreaStyle](#areastyle),[ArrowStyle](#arrowstyle),[BaseLine](#baseline),[IconStyle](#iconstyle),[ImageStyle](#imagestyle),[ItemStyle](#itemstyle),[Level](#level),[LevelStyle](#levelstyle),[LineArrow](#linearrow),[LineStyle](#linestyle),[Location](#location),[MLValue](#mlvalue),[MarqueeStyle](#marqueestyle),[Padding](#padding),[StageColor](#stagecolor),[SymbolStyle](#symbolstyle),[TextLimit](#textlimit),[TextStyle](#textstyle),[CommentItem](#commentitem),[CommentMarkStyle](#commentmarkstyle),[LabelLine](#labelline),[LabelStyle](#labelstyle),[MarkAreaData](#markareadata),[MarkLineData](#marklinedata),[StateStyle](#statestyle),[VisualMapRange](#visualmaprange),[UIComponentTheme](#uicomponenttheme),[SerieData](#seriedata),[ComponentTheme](#componenttheme),[SerieTheme](#serietheme),[ThemeStyle](#themestyle)
|
||||
|
||||
|
||||
|public method|since|description|
|
||||
@@ -2599,6 +2613,7 @@ the data of serie event.
|
||||
|GetLastStackSerie()||public static Serie GetLastStackSerie(List<Serie> series, Serie serie)<br/>获得上一个同堆叠且显示的serie。 |
|
||||
|GetLegalSerieNameList()||public static List<string> GetLegalSerieNameList(List<Serie> series)|
|
||||
|GetMaxSerieDataCount()||public static int GetMaxSerieDataCount(List<Serie> series)|
|
||||
|GetMinAnimationDuration()||public static float GetMinAnimationDuration(List<Serie> series)|
|
||||
|GetNameColor()||public static Color GetNameColor(BaseChart chart, int index, string name)|
|
||||
|GetStackSeries()||public static void GetStackSeries(List<Serie> series, ref Dictionary<int, List<Serie>> stackSeries)<br/>获得堆叠系列列表 |
|
||||
|IsAnyClipSerie()||public static bool IsAnyClipSerie(List<Serie> series)<br/>是否有需裁剪的serie。 |
|
||||
|
||||
@@ -81,6 +81,7 @@ import APITable from '@site/src/components/APITable';
|
||||
- [AnimationStyle](#animationstyle)
|
||||
- [AreaStyle](#areastyle)
|
||||
- [ArrowStyle](#arrowstyle)
|
||||
- [AxisAnimation](#axisanimation)
|
||||
- [AxisLabel](#axislabel)
|
||||
- [AxisLine](#axisline)
|
||||
- [AxisMinorSplitLine](#axisminorsplitline)
|
||||
@@ -421,6 +422,7 @@ The axis in rectangular coordinate.
|
||||
|axisLabel|||axis label. [AxisLabel](#axislabel)|
|
||||
|splitLine|||axis split line. [AxisSplitLine](#axissplitline)|
|
||||
|splitArea|||axis split area. [AxisSplitArea](#axissplitarea)|
|
||||
|animation|||animation of axis. [AxisAnimation](#axisanimation)|
|
||||
|minorTick||v3.2.0|axis minor tick. [AxisMinorTick](#axisminortick)|
|
||||
|minorSplitLine||v3.2.0|axis minor split line. [AxisMinorSplitLine](#axisminorsplitline)|
|
||||
|indicatorLabel||v3.4.0|Style of axis tooltip indicator label. [LabelStyle](#labelstyle)|
|
||||
@@ -429,6 +431,29 @@ The axis in rectangular coordinate.
|
||||
</APITable>
|
||||
```
|
||||
|
||||
## AxisAnimation
|
||||
|
||||
> class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
|
||||
|
||||
> Since `v3.9.0`
|
||||
|
||||
animation style of axis.
|
||||
|
||||
```mdx-code-block
|
||||
<APITable name="AxisAnimation">
|
||||
```
|
||||
|
||||
|
||||
|field|default|since|comment|
|
||||
|--|--|--|--|
|
||||
|show|true||whether to enable animation.
|
||||
|duration|||the duration of animation (ms). When it is set to 0, the animation duration will be automatically calculated according to the serie.
|
||||
|unscaledTime|||Animation updates independently of Time.timeScale.
|
||||
|
||||
```mdx-code-block
|
||||
</APITable>
|
||||
```
|
||||
|
||||
## AxisLabel
|
||||
|
||||
> class in XCharts.Runtime / Inherits from: [LabelStyle](#labelstyle)
|
||||
@@ -719,7 +744,7 @@ Configurations of blur state.
|
||||
|
||||
## ChildComponent
|
||||
|
||||
> class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [IconStyle](#iconstyle), [ImageStyle](#imagestyle), [ItemStyle](#itemstyle), [Level](#level), [LevelStyle](#levelstyle), [LineArrow](#linearrow), [LineStyle](#linestyle), [Location](#location), [MLValue](#mlvalue), [MarqueeStyle](#marqueestyle), [Padding](#padding), [StageColor](#stagecolor), [SymbolStyle](#symbolstyle), [TextLimit](#textlimit), [TextStyle](#textstyle), [CommentItem](#commentitem), [CommentMarkStyle](#commentmarkstyle), [LabelLine](#labelline), [LabelStyle](#labelstyle), [MarkAreaData](#markareadata), [MarkLineData](#marklinedata), [StateStyle](#statestyle), [VisualMapRange](#visualmaprange), [UIComponentTheme](#uicomponenttheme), [SerieData](#seriedata), [ComponentTheme](#componenttheme), [SerieTheme](#serietheme), [ThemeStyle](#themestyle)
|
||||
> class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle), [AxisAnimation](#axisanimation), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [IconStyle](#iconstyle), [ImageStyle](#imagestyle), [ItemStyle](#itemstyle), [Level](#level), [LevelStyle](#levelstyle), [LineArrow](#linearrow), [LineStyle](#linestyle), [Location](#location), [MLValue](#mlvalue), [MarqueeStyle](#marqueestyle), [Padding](#padding), [StageColor](#stagecolor), [SymbolStyle](#symbolstyle), [TextLimit](#textlimit), [TextStyle](#textstyle), [CommentItem](#commentitem), [CommentMarkStyle](#commentmarkstyle), [LabelLine](#labelline), [LabelStyle](#labelstyle), [MarkAreaData](#markareadata), [MarkLineData](#marklinedata), [StateStyle](#statestyle), [VisualMapRange](#visualmaprange), [UIComponentTheme](#uicomponenttheme), [SerieData](#seriedata), [ComponentTheme](#componenttheme), [SerieTheme](#serietheme), [ThemeStyle](#themestyle)
|
||||
|
||||
## Comment
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -74,6 +74,7 @@ slug: /changelog
|
||||
|
||||
版本要点:
|
||||
|
||||
* 增加`Axis`的`Animation`,完善数据变更动画效果
|
||||
* 增加`Axis`的对数轴子刻度的支持
|
||||
* 增加`MarkLine`的`onTop`设置是否显示在最上层
|
||||
* 增加`UITable`表格组件的轮播功能,重构`UITable`
|
||||
@@ -82,6 +83,8 @@ slug: /changelog
|
||||
|
||||
日志详情:
|
||||
|
||||
* (2023.11.24) 修复`Axis`的更新数据时效果不顺畅的问题
|
||||
* (2023.11.23) 增加`Axis`的`Animation`支持动画效果
|
||||
* (2023.11.16) 取消`Legend`的`formatter`,用`LabelStyle`的代替
|
||||
* (2023.11.14) 完善`LabelStyle`的`formatter`的注释和文档(#291)
|
||||
* (2023.11.11) 修复`Documentation`部分注释生成文档不完整的问题 (#290)
|
||||
|
||||
@@ -81,6 +81,7 @@ import APITable from '@site/src/components/APITable';
|
||||
- [AnimationStyle](#animationstyle)
|
||||
- [AreaStyle](#areastyle)
|
||||
- [ArrowStyle](#arrowstyle)
|
||||
- [AxisAnimation](#axisanimation)
|
||||
- [AxisLabel](#axislabel)
|
||||
- [AxisLine](#axisline)
|
||||
- [AxisMinorSplitLine](#axisminorsplitline)
|
||||
@@ -414,6 +415,7 @@ import APITable from '@site/src/components/APITable';
|
||||
|axisLabel|||坐标轴刻度标签。 [AxisLabel](#axislabel)|
|
||||
|splitLine|||坐标轴分割线。 [AxisSplitLine](#axissplitline)|
|
||||
|splitArea|||坐标轴分割区域。 [AxisSplitArea](#axissplitarea)|
|
||||
|animation|||坐标轴动画。 [AxisAnimation](#axisanimation)|
|
||||
|minorTick||v3.2.0|坐标轴次刻度。 [AxisMinorTick](#axisminortick)|
|
||||
|minorSplitLine||v3.2.0|坐标轴次分割线。 [AxisMinorSplitLine](#axisminorsplitline)|
|
||||
|indicatorLabel||v3.4.0|指示器文本的样式。Tooltip为Cross时使用。 [LabelStyle](#labelstyle)|
|
||||
@@ -422,6 +424,28 @@ import APITable from '@site/src/components/APITable';
|
||||
</APITable>
|
||||
```
|
||||
|
||||
## AxisAnimation
|
||||
|
||||
> class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
|
||||
|
||||
> 从 `v3.9.0` 开始支持
|
||||
|
||||
坐标轴动画配置。
|
||||
|
||||
```mdx-code-block
|
||||
<APITable name="AxisAnimation">
|
||||
```
|
||||
|
||||
|参数|默认|版本|描述|
|
||||
|--|--|--|--|
|
||||
|show|true||是否开启动画。
|
||||
|duration|||动画时长(ms)。 默认设置为0时,会自动获取serie的动画时长。
|
||||
|unscaledTime|||动画是否受TimeScaled的影响。默认为 false 受TimeScaled的影响。
|
||||
|
||||
```mdx-code-block
|
||||
</APITable>
|
||||
```
|
||||
|
||||
## AxisLabel
|
||||
|
||||
> class in XCharts.Runtime / 继承自: [LabelStyle](#labelstyle)
|
||||
@@ -701,7 +725,7 @@ import APITable from '@site/src/components/APITable';
|
||||
|
||||
## ChildComponent
|
||||
|
||||
> class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [IconStyle](#iconstyle), [ImageStyle](#imagestyle), [ItemStyle](#itemstyle), [Level](#level), [LevelStyle](#levelstyle), [LineArrow](#linearrow), [LineStyle](#linestyle), [Location](#location), [MLValue](#mlvalue), [MarqueeStyle](#marqueestyle), [Padding](#padding), [StageColor](#stagecolor), [SymbolStyle](#symbolstyle), [TextLimit](#textlimit), [TextStyle](#textstyle), [CommentItem](#commentitem), [CommentMarkStyle](#commentmarkstyle), [LabelLine](#labelline), [LabelStyle](#labelstyle), [MarkAreaData](#markareadata), [MarkLineData](#marklinedata), [StateStyle](#statestyle), [VisualMapRange](#visualmaprange), [UIComponentTheme](#uicomponenttheme), [SerieData](#seriedata), [ComponentTheme](#componenttheme), [SerieTheme](#serietheme), [ThemeStyle](#themestyle)
|
||||
> class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle), [AxisAnimation](#axisanimation), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [IconStyle](#iconstyle), [ImageStyle](#imagestyle), [ItemStyle](#itemstyle), [Level](#level), [LevelStyle](#levelstyle), [LineArrow](#linearrow), [LineStyle](#linestyle), [Location](#location), [MLValue](#mlvalue), [MarqueeStyle](#marqueestyle), [Padding](#padding), [StageColor](#stagecolor), [SymbolStyle](#symbolstyle), [TextLimit](#textlimit), [TextStyle](#textstyle), [CommentItem](#commentitem), [CommentMarkStyle](#commentmarkstyle), [LabelLine](#labelline), [LabelStyle](#labelstyle), [MarkAreaData](#markareadata), [MarkLineData](#marklinedata), [StateStyle](#statestyle), [VisualMapRange](#visualmaprange), [UIComponentTheme](#uicomponenttheme), [SerieData](#seriedata), [ComponentTheme](#componenttheme), [SerieTheme](#serietheme), [ThemeStyle](#themestyle)
|
||||
|
||||
## Comment
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace XCharts.Editor
|
||||
var m_Type = baseProperty.FindPropertyRelative("m_Type");
|
||||
var m_LogBase = baseProperty.FindPropertyRelative("m_LogBase");
|
||||
var m_MinMaxType = baseProperty.FindPropertyRelative("m_MinMaxType");
|
||||
var type = (Axis.AxisType) m_Type.enumValueIndex;
|
||||
var type = (Axis.AxisType)m_Type.enumValueIndex;
|
||||
EditorGUI.indentLevel++;
|
||||
if (component is ParallelAxis)
|
||||
{
|
||||
@@ -40,7 +40,7 @@ namespace XCharts.Editor
|
||||
if (type == Axis.AxisType.Value || type == Axis.AxisType.Time)
|
||||
{
|
||||
PropertyField("m_MinMaxType");
|
||||
Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType) m_MinMaxType.enumValueIndex;
|
||||
Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType)m_MinMaxType.enumValueIndex;
|
||||
switch (minMaxType)
|
||||
{
|
||||
case Axis.AxisMinMaxType.Default:
|
||||
@@ -63,7 +63,6 @@ namespace XCharts.Editor
|
||||
PropertyField("m_SplitNumber");
|
||||
if (type == Axis.AxisType.Category)
|
||||
{
|
||||
//PropertyField("m_InsertDataToHead");
|
||||
PropertyField("m_MaxCache");
|
||||
PropertyField("m_BoundaryGap");
|
||||
}
|
||||
@@ -72,6 +71,10 @@ namespace XCharts.Editor
|
||||
PropertyField("m_Interval");
|
||||
}
|
||||
DrawExtendeds();
|
||||
if (type != Axis.AxisType.Category)
|
||||
{
|
||||
PropertyField("m_Animation");
|
||||
}
|
||||
PropertyField("m_AxisLine");
|
||||
PropertyField("m_AxisName");
|
||||
PropertyField("m_AxisTick");
|
||||
@@ -204,4 +207,21 @@ namespace XCharts.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(AxisAnimation), true)]
|
||||
public class AxisAnimationDrawer : BasePropertyDrawer
|
||||
{
|
||||
public override string ClassName { get { return "Animation"; } }
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
base.OnGUI(pos, prop, label);
|
||||
if (MakeComponentFoldout(prop, "m_Show", true))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_UnscaledTime");
|
||||
PropertyField(prop, "m_Duration");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,19 @@ namespace XCharts.Example
|
||||
{
|
||||
AddData();
|
||||
}
|
||||
else if(Input.GetKeyDown(KeyCode.R))
|
||||
else if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
chart.AnimationReset();
|
||||
chart.AnimationFadeIn();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.U))
|
||||
{
|
||||
chart.UpdateData(0, 2, 99);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.C))
|
||||
{
|
||||
chart.UpdateData(0, 2, 22);
|
||||
}
|
||||
}
|
||||
|
||||
void AddData()
|
||||
|
||||
@@ -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