Compare commits

..

40 Commits

Author SHA1 Message Date
monitor1394
e4e1a69e76 3.14.0 2025-03-16 10:45:38 +08:00
monitor1394
a1c7e1a64b update doc 2025-03-13 23:33:09 +08:00
monitor1394
1c3afc0255 update doc 2025-03-13 23:00:52 +08:00
monitor1394
42059d9ab9 update readme 2025-03-12 23:25:43 +08:00
monitor1394
24d13a36d3 update readme 2025-03-12 23:14:20 +08:00
monitor1394
247abb2e3f update readme 2025-03-12 23:05:41 +08:00
monitor1394
e8ea30a9fb 更新订阅服务 2025-03-12 08:49:04 +08:00
monitor1394
a1ba6b095d 增加BarrealtimeSort支持实时排序 2025-03-10 08:40:22 +08:00
monitor1394
e4923ea598 修复Bar在同一个Chart不同Grid里时绘制有些异常的问题 2025-03-09 23:14:26 +08:00
monitor1394
ffd2521360 增加Animationspeed可指定动画速度 2025-03-07 22:59:32 +08:00
monitor1394
e7aae593bf 优化Animation的新增动画表现 2025-03-07 22:32:27 +08:00
monitor1394
aea4aa7c8d 修复Treemaplabel显示异常的问题 2025-03-04 08:33:07 +08:00
monitor1394
f9f2428142 增加TooltipcolumnGapWidths参数设置列文本间隙距离 2025-03-02 20:57:58 +08:00
monitor1394
ffed67d8ee 增加BarrealtimeSort支持实时排序 2025-03-01 22:30:51 +08:00
monitor1394
063b5529d7 增加BarrealtimeSort支持实时排序 2025-02-23 21:47:15 +08:00
monitor1394
a54c50d947 增加TooltipitemFormatter\n换行的支持 2025-02-19 22:52:38 +08:00
monitor1394
9ddc543ed7 优化Tooltip的对齐方式 2025-02-18 23:30:56 +08:00
monitor1394
214b84c71d 修复SaveAsImage保存图片时不支持透明度的问题 (#337) 2025-02-09 20:21:42 +08:00
monitor1394
9fc75c78d7 增加GraphChart可单独设置data样式的支持 2025-02-06 22:11:13 +08:00
monitor1394
ec3d012f08 重构SerieSymbolsizeFunction参数 2025-02-06 21:23:58 +08:00
monitor1394
c6896677b8 修复TreemapLabel不显示的问题 2025-01-23 08:37:41 +08:00
monitor1394
29b1f8a8c2 修复Chart在运行时动态添加Component异常的问题 (#339) 2025-01-15 08:30:50 +08:00
monitor1394
ddbfd9b7ef 修复TextMeshPro关闭时残留组件影响Text初始化的问题 2025-01-08 22:28:47 +08:00
monitor1394
3db02b86b4 3.13.0 2025-01-01 22:52:48 +08:00
monitor1394
151ed168b5 3.13.0 2025-01-01 20:15:29 +08:00
monitor1394
be6a91b4c2 3.13.0 2024-12-31 08:44:57 +08:00
monitor1394
43de03951c 增加SymbolStylesize2参数支持长方形标记 2024-12-28 21:03:17 +08:00
monitor1394
21cd72b995 优化DrawBackground接口 2024-12-27 22:13:35 +08:00
monitor1394
d466ac2bc1 优化TextTextMeshPro下的居中对齐方式 2024-12-26 10:05:20 +08:00
monitor1394
6e9d9bfd3d 增加TooltipitemFormatter设置{f0}支持 2024-12-25 21:39:13 +08:00
monitor1394
d1438dd76f 修复YAxis在范围变更刷新时部分label可能不显示的问题 2024-12-25 16:30:25 +08:00
monitor1394
074c1a3992 增加UISlider扩展组件 2024-12-25 10:06:53 +08:00
monitor1394
5d24580725 增加SymbolStyleborderWidthemptyColor配置 2024-12-23 21:31:27 +08:00
monitor1394
301c66eccf 增加拖拽点击判断 2024-12-23 21:29:39 +08:00
monitor1394
2fc87d03cd 增加UISlider扩展组件 2024-12-17 22:19:22 +08:00
monitor1394
33b71dc711 增加UIToggle扩展组件 2024-12-10 08:49:41 +08:00
monitor1394
f5ec47c105 修复Chart节点下不能放自定义节点的问题 2024-12-07 22:21:55 +08:00
monitor1394
2e604529ee 处理Unity版本兼容问题 2024-12-04 09:18:38 +08:00
monitor1394
333dfb8e37 增加UIText扩展组件 2024-12-04 08:19:40 +08:00
monitor1394
7eddebd660 删除TextStyle的无用配置项tmpAlignment 2024-12-04 08:19:08 +08:00
92 changed files with 1570 additions and 652 deletions

View File

@@ -405,7 +405,7 @@ the delegate function of animation delay.
### AnimationInfo.duration ### AnimationInfo.duration
public float duration public float duration
the duration of animation. the duration of animation. Default is used to calculate the speed of animation. It can also be specified by speed.
### AnimationInfo.durationFunction ### AnimationInfo.durationFunction
@@ -432,6 +432,11 @@ the callback function of animation start.
public bool reverse public bool reverse
whether enable reverse animation. whether enable reverse animation.
### AnimationInfo.speed
public float speed
the speed of animation. When speed is specified, duration will be invalid. Default is 0, which means no speed specified.
### AnimationInfo.End ### AnimationInfo.End
public void End() public void End()
@@ -1042,6 +1047,10 @@ public bool needAnimation
public List<string> runtimeData public List<string> runtimeData
the tick value of value axis. the tick value of value axis.
### AxisContext.sortedDataIndices
public List<int> sortedDataIndices
## AxisHandler<T> ## AxisHandler<T>
class in XCharts / Inherits from: [MainComponentHandler](#maincomponenthandler) class in XCharts / Inherits from: [MainComponentHandler](#maincomponenthandler)
@@ -1170,7 +1179,7 @@ public void Copy(AxisLabel axisLabel)
### AxisLabel.GetFormatterContent ### AxisLabel.GetFormatterContent
public override string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false) public override string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
### AxisLabel.IsNeedShowLabel ### AxisLabel.IsNeedShowLabel
@@ -1362,6 +1371,11 @@ class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent)
Background component. Background component.
### Background.rect
public Rect rect
the rect of background.
### Background.SetDefaultValue ### Background.SetDefaultValue
public override void SetDefaultValue() public override void SetDefaultValue()
@@ -1378,6 +1392,10 @@ public int containerIndex
public int containterInstanceId public int containterInstanceId
### Bar.useSortData
public override bool useSortData
### Bar.AddDefaultSerie ### Bar.AddDefaultSerie
public static Serie AddDefaultSerie(BaseChart chart, string serieName) public static Serie AddDefaultSerie(BaseChart chart, string serieName)
@@ -1936,6 +1954,10 @@ public T GetOrAddChartComponent<T>() where T : MainComponent
public Painter GetPainter(int index) public Painter GetPainter(int index)
### BaseChart.GetRealtimeSortSerie
public Serie GetRealtimeSortSerie(int gridIndex)
### BaseChart.GetSerie ### BaseChart.GetSerie
public Serie GetSerie(int serieIndex) public Serie GetSerie(int serieIndex)
@@ -1948,19 +1970,19 @@ public T GetSerie<T>(int serieIndex) where T : Serie
### BaseChart.GetSerieBarGap<T> ### BaseChart.GetSerieBarGap<T>
public float GetSerieBarGap<T>() where T : Serie public float GetSerieBarGap<T>(int gridIndex) where T : Serie
### BaseChart.GetSerieBarRealCount<T> ### BaseChart.GetSerieBarRealCount<T>
public int GetSerieBarRealCount<T>() where T : Serie public int GetSerieBarRealCount<T>(int gridIndex) where T : Serie
### BaseChart.GetSerieIndexIfStack<T> ### BaseChart.GetSerieIndexIfStack<T>
public int GetSerieIndexIfStack<T>(Serie currSerie) where T : Serie public int GetSerieIndexIfStack<T>(Serie currSerie, int gridIndex) where T : Serie
### BaseChart.GetSerieSameStackTotalValue<T> ### BaseChart.GetSerieSameStackTotalValue<T>
public double GetSerieSameStackTotalValue<T>(string stack, int dataIndex) where T : Serie public double GetSerieSameStackTotalValue<T>(string stack, int dataIndex, int gridIndex) where T : Serie
### BaseChart.GetSeriesMinMaxValue ### BaseChart.GetSeriesMinMaxValue
@@ -1968,11 +1990,11 @@ public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double te
### BaseChart.GetSerieTotalGap<T> ### BaseChart.GetSerieTotalGap<T>
public float GetSerieTotalGap<T>(float categoryWidth, float gap, int index) where T : Serie public float GetSerieTotalGap<T>(float categoryWidth, float gap, int index, int gridIndex) where T : Serie
### BaseChart.GetSerieTotalWidth<T> ### BaseChart.GetSerieTotalWidth<T>
public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount) where T : Serie public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount, int gridIndex) where T : Serie
### BaseChart.GetTitlePosition ### BaseChart.GetTitlePosition
@@ -2002,6 +2024,10 @@ public bool HasChartComponent(Type type)
public bool HasChartComponent<T>() public bool HasChartComponent<T>()
### BaseChart.HasRealtimeSortSerie
public bool HasRealtimeSortSerie(int gridIndex)
### BaseChart.HasSerie ### BaseChart.HasSerie
public bool HasSerie(Type type) public bool HasSerie(Type type)
@@ -2353,6 +2379,10 @@ class in XCharts.Runtime / Inherits from: [MaskableGraphic](https://docs.unity3d
public virtual HideFlags chartHideFlags public virtual HideFlags chartHideFlags
### BaseGraph.childrenNodeNames
public List<string> childrenNodeNames
### BaseGraph.clickPos ### BaseGraph.clickPos
public Vector2 clickPos public Vector2 clickPos
@@ -2411,6 +2441,10 @@ The x of graph.
public float graphY public float graphY
The y of graph. The y of graph.
### BaseGraph.isDragingClick
public bool isDragingClick
### BaseGraph.isPointerClick ### BaseGraph.isPointerClick
public bool isPointerClick public bool isPointerClick
@@ -2759,6 +2793,10 @@ public float GetRuntimeBorderWidth()
public float[] GetRuntimeCornerRadius() public float[] GetRuntimeCornerRadius()
### BorderStyle.IsCricle
public bool IsCricle()
## CalendarCoord ## CalendarCoord
class in XCharts.Runtime / Inherits from: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer) class in XCharts.Runtime / Inherits from: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer)
@@ -2893,7 +2931,8 @@ public static void DestoryGameObject(GameObject go)
### ChartHelper.DestoryGameObjectByMatch ### ChartHelper.DestoryGameObjectByMatch
public static void DestoryGameObjectByMatch(Transform parent, string containString) public static void DestoryGameObjectByMatch(Transform parent, List<string> children)
### ChartHelper.DestroyAllChildren ### ChartHelper.DestroyAllChildren
@@ -2940,7 +2979,8 @@ public static Vector3 GetLastValue(List<Vector3> list)
### ChartHelper.GetMaxCeilRate ### ChartHelper.GetMaxCeilRate
public static double GetMaxCeilRate(double value, double ceilRate) public static float GetMaxCeilRate(float value, float ceilRate)
### ChartHelper.GetMaxDivisibleValue ### ChartHelper.GetMaxDivisibleValue
@@ -2952,7 +2992,8 @@ public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE
### ChartHelper.GetMinCeilRate ### ChartHelper.GetMinCeilRate
public static double GetMinCeilRate(double value, double ceilRate) public static float GetMinCeilRate(float value, float ceilRate)
### ChartHelper.GetMinDivisibleValue ### ChartHelper.GetMinDivisibleValue
@@ -3062,6 +3103,10 @@ public static List<string> ParseStringFromString(string jsonData)
public static void RemoveComponent<T>(GameObject gameObject) public static void RemoveComponent<T>(GameObject gameObject)
### ChartHelper.RemoveTMPComponents
public static void RemoveTMPComponents(GameObject gameObject)
### ChartHelper.RotateRound ### ChartHelper.RotateRound
public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle) public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle)
@@ -3414,10 +3459,9 @@ class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
comment of chart. comment of chart.
### CommentItem.content ### CommentItem.labelObject
public string content public ChartLabel labelObject
content of comment.
### CommentItem.markRect ### CommentItem.markRect
@@ -3866,9 +3910,13 @@ public static bool NeedFormat(string content)
### FormatterHelper.ReplaceAxisLabelContent ### FormatterHelper.ReplaceAxisLabelContent
public static void ReplaceAxisLabelContent(ref string content, string value) public static void ReplaceAxisLabelContent(ref string content, string value, int index, int totalIndex)
### FormatterHelper.ReplaceIndexContent
public static void ReplaceIndexContent(ref string content, int currIndex, int totalIndex)
### FormatterHelper.TrimAndReplaceLine ### FormatterHelper.TrimAndReplaceLine
public static string TrimAndReplaceLine(string content) public static string TrimAndReplaceLine(string content)
@@ -4379,7 +4427,7 @@ public override void ClearData()
### Indicator.GetFormatterIndicatorContent ### Indicator.GetFormatterIndicatorContent
public string GetFormatterIndicatorContent(string indicatorName) public string GetFormatterIndicatorContent(string indicatorName, int index, int totalIndex)
### Indicator.GetIndicator ### Indicator.GetIndicator
@@ -4630,12 +4678,12 @@ public Color GetColor(Color defaultColor)
### LabelStyle.GetFormatterContent ### LabelStyle.GetFormatterContent
public virtual string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false) public virtual string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
### LabelStyle.GetFormatterDateTime ### LabelStyle.GetFormatterDateTime
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue) public string GetFormatterDateTime(int labelIndex, int totalIndex, double value, double minValue, double maxValue)
### LabelStyle.GetOffset ### LabelStyle.GetOffset
@@ -5317,6 +5365,10 @@ public float runtimeTop
public Vector3 GetPosition(float chartWidth, float chartHeight) public Vector3 GetPosition(float chartWidth, float chartHeight)
返回在坐标系中的具体位置 返回在坐标系中的具体位置
### Location.GetRect
public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight)
### Location.IsBottom ### Location.IsBottom
public bool IsBottom() public bool IsBottom()
@@ -6695,7 +6747,7 @@ public double GetData(int index, int dimension, DataZoom dataZoom = null)
### Serie.GetDataList ### Serie.GetDataList
public List<SerieData> GetDataList(DataZoom dataZoom = null) public List<SerieData> GetDataList(DataZoom dataZoom = null, bool sorted = false)
获得系列的数据列表 获得系列的数据列表
### Serie.GetDataTotal ### Serie.GetDataTotal
@@ -7002,6 +7054,10 @@ public SelectStyle selectStyle
public bool show public bool show
[default:true] Whether the data item is showed. [default:true] Whether the data item is showed.
### SerieData.sortIndex
public int sortIndex
### SerieData.state ### SerieData.state
public SerieState state public SerieState state
@@ -7148,7 +7204,7 @@ public void SetIconActive(bool flag)
### SerieData.SetLabelActive ### SerieData.SetLabelActive
public void SetLabelActive(bool flag) public void SetLabelActive(bool flag, bool force = false)
### SerieData.SetPolygon ### SerieData.SetPolygon
@@ -7925,7 +7981,7 @@ class in XCharts.Runtime / Inherits from: [SymbolStyle](#symbolstyle),[ISerieDat
### SerieSymbol.GetSize ### SerieSymbol.GetSize
public float GetSize(List<double> data, float themeSize) public float GetSize(SerieData serieData, float themeSize)
根据指定的sizeType获得标记的大小 根据指定的sizeType获得标记的大小
### SerieSymbol.Reset ### SerieSymbol.Reset
@@ -9087,6 +9143,11 @@ class in XCharts.Runtime
UI帮助类。 UI帮助类。
### UIHelper.DrawBackground
public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2)
## ViewControl ## ViewControl
class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent) class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)

View File

@@ -6,6 +6,8 @@ slug: /changelog
# Changelog # Changelog
[master](#master) [master](#master)
[v3.14.0](#v3140)
[v3.13.0](#v3130)
[v3.12.1](#v3121) [v3.12.1](#v3121)
[v3.12.0](#v3120) [v3.12.0](#v3120)
[v3.11.2](#v3112) [v3.11.2](#v3112)
@@ -77,6 +79,63 @@ slug: /changelog
## master ## master
## v3.14.0
**Key Highlights:**
* Added real-time sorting functionality for `Bar`
* Added support for `\n` line breaks in `itemFormatter` for `Tooltip`
* Added support for `{index}` formatting in `AxisLabel`
* Added `speed` to `Animation` to specify animation speed
* Optimized column alignment in `Tooltip`
**Detailed Changelog:**
* (2025.03.15) Released version `v3.14.0`
* (2025.03.09) Fixed an issue where `Bar` displayed abnormally when placed in different `Grids` within the same `Chart`
* (2025.03.07) Added `speed` to `Animation` to specify animation speed
* (2025.03.06) Optimized the performance of newly added animations in `Animation`
* (2025.03.04) Fixed an issue where `label` in `Treemap` displayed abnormally
* (2025.03.02) Added `columnGapWidths` parameter to `Tooltip` to set the gap distance between column texts
* (2025.03.01) Optimized the refresh of `Comment` component
* (2025.02.23) Added support for `{index}`, `{index-1}`, `{-index}`, and `{-index-1}` wildcards in `formatter` for `Label` in `Axis`
* (2025.02.23) Added `realtimeSort` to `Bar` to support real-time sorting
* (2025.02.19) Added support for `\n` line breaks in `itemFormatter` for `Tooltip`
* (2025.02.18) Optimized the alignment of `Tooltip`
* (2025.02.09) Fixed an issue where `SaveAsImage` did not support transparency when saving images (#337)
* (2025.02.05) Added support for setting `data` styles separately in `GraphChart`
* (2025.02.05) Refactored the `sizeFunction` parameter in `SerieSymbol`
* (2025.01.23) Fixed an issue where `Label` in `Treemap` was not displayed
* (2025.01.15) Fixed an issue where dynamically adding `Component` to `Chart` at runtime caused exceptions (#339)
* (2025.01.08) Fixed an issue where residual components affected `Text` initialization when `TextMeshPro` was turned off
## v3.13.0
Key Features:
* Added the `UIText` extension component
* Added the `UIToggle` extension component
* Added the `UISlider` extension component
* Refactored the `UIProgress` extension component
* Added `borderWidth` and `emptyColor` configurations to `SymbolStyle`
* Added the `size2` parameter to `SymbolStyle` to support rectangular markers
* Other optimizations and bug fixes
Detailed Changelog:
* (2025.01.01) Released `v3.13.0`
* (2024.12.27) Added the `size2` parameter to `SymbolStyle` to support rectangular markers
* (2024.12.26) Optimized `Text` alignment in `TextMeshPro` for proper centering
* (2024.12.25) Added support for `{f0}` in the `Tooltip`'s `itemFormatter` setting
* (2024.12.25) Fixed an issue where some labels on the `YAxis` might not display during range refresh
* (2024.12.23) Added `borderWidth` and `emptyColor` configurations to `SymbolStyle`
* (2024.12.17) Added the `UISlider` extension component
* (2024.12.10) Added the `UIToggle` extension component
* (2024.12.09) Fixed an issue where the `UITable`'s `scrollbar` could not be dragged
* (2024.12.07) Fixed an issue where custom nodes could not be placed under the `Chart` node
* (2024.12.05) Added the `UIText` extension component
* (2024.12.04) Removed the unused `tmpAlignment` option from `TextStyle`
## v3.12.1 ## v3.12.1
Version Highlights: Version Highlights:
@@ -120,7 +179,6 @@ Log Details:
* (2024.09.01) Added `radiusGradient` parameter for `Ring` to set the gradient direction * (2024.09.01) Added `radiusGradient` parameter for `Ring` to set the gradient direction
* (2024.09.01) Optimized the position of the first Label when `Axis` is used as a time axis * (2024.09.01) Optimized the position of the first Label when `Axis` is used as a time axis
## v3.11.2 ## v3.11.2
* (2024.08.01) Release `v3.11.2` * (2024.08.01) Release `v3.11.2`

View File

@@ -276,7 +276,7 @@ the delay time before animation start.
`float` `1000` `v3.8.0` `float` `1000` `v3.8.0`
the duration of animation. the duration of animation. Default is used to calculate the speed of animation. It can also be specified by speed.
### AnimationInfo.enable ### AnimationInfo.enable
@@ -290,6 +290,12 @@ whether enable animation.
whether enable reverse animation. whether enable reverse animation.
### AnimationInfo.speed
`float` `0` `v3.14.0`
the speed of animation. When speed is specified, duration will be invalid. Default is 0, which means no speed specified.
## AnimationInteraction ## AnimationInteraction
class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo) class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
@@ -2462,7 +2468,7 @@ the distance of label to axis line.
`string` `string`
label content string template formatter. \n line wrapping is supported. Formatters for some components will not take effect. <br /> Template placeholder have the following, some of which apply only to fixed components: <br /> `\{.\}` : indicates the dot mark. <br /> `\{a\}` : indicates the series name. <br /> `\{b\}` : category value of x axis or data name. <br /> `\{c\}` : data value. <br /> `\{d\}` : percentage. <br /> `\{e\}` : indicates the data name. <br /> `\{f\}` : data sum. <br /> `\{g\}` : indicates the total number of data. <br /> `\{h\}` : hexadecimal color value. <br /> `\{y\}` : category value of y axis. <br /> `\{value\}` : The value of the axis or legend. <br /> The following placeholder apply to `UITable` components: <br /> `\{name\}` : indicates the row name of the table. <br /> `\{index\}` : indicates the row number of the table. <br /> The following placeholder apply to `UIStatistc` components: <br /> `\{title\}` : title text. <br /> `\{dd\}` : day. <br /> `\{hh\}` : hours. <br /> `\{mm\}` : minutes. <br /> `\{ss\}` : second. <br /> `\{fff\}` : milliseconds. <br /> `\{d\}` : day. <br /> `\{h\}` : hours. <br /> `\{m\}` : minutes. <br /> `\{s\}` : second. <br /> `\{f\}` : milliseconds. <br /> Example :\{b\}:\{c\}<br /> label content string template formatter. \n line wrapping is supported. Formatters for some components will not take effect. <br /> Template placeholder have the following, some of which apply only to fixed components: <br /> `\{.\}` : indicates the dot mark. <br /> `\{a\}` : indicates the series name. <br /> `\{b\}` : category value of x axis or data name. <br /> `\{c\}` : data value. <br /> `\{d\}` : percentage. <br /> `\{e\}` : indicates the data name. <br /> `\{f\}` : data sum. <br /> `\{g\}` : indicates the total number of data. <br /> `\{h\}` : hexadecimal color value. <br /> `\{y\}` : category value of y axis. <br /> `\{value\}` : the value of the axis or legend. <br /> `\{index\}` : the index of the axis. <br /> The following placeholder apply to `UITable` components: <br /> `\{name\}` : indicates the row name of the table. <br /> `\{index\}` : indicates the row number of the table. <br /> The following placeholder apply to `UIStatistc` components: <br /> `\{title\}` : title text. <br /> `\{dd\}` : day. <br /> `\{hh\}` : hours. <br /> `\{mm\}` : minutes. <br /> `\{ss\}` : second. <br /> `\{fff\}` : milliseconds. <br /> `\{d\}` : day. <br /> `\{h\}` : hours. <br /> `\{m\}` : minutes. <br /> `\{s\}` : second. <br /> `\{f\}` : milliseconds. <br /> Example :\{b\}:\{c\}<br />
### LabelStyle.height ### LabelStyle.height
@@ -3755,6 +3761,12 @@ Options:
the radius of chart. the radius of chart.
### Serie.realtimeSort
`bool` `false` `v3.14.0`
Whether to enable realtime sorting, which is used for bar-racing effect. Currently only available in Bar.
### Serie.right ### Serie.right
`float` `float`
@@ -4366,12 +4378,24 @@ class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent) / Su
系列数据项的标记的图形 系列数据项的标记的图形
### SymbolStyle.borderWidth
`float` `0f` `v3.13.0`
the border width of symbol.
### SymbolStyle.color ### SymbolStyle.color
`Color32` `Color32`
图形的颜色。 图形的颜色。
### SymbolStyle.emptyColor
`Color32` `v3.13.0`
the color of empty symbol.
### SymbolStyle.gap ### SymbolStyle.gap
`float` `0` `float` `0`
@@ -4414,6 +4438,12 @@ Whether the symbol is showed.
the size of symbol. the size of symbol.
### SymbolStyle.size2
`float` `0f` `v3.13.0`
the size of symbol.
### SymbolStyle.type ### SymbolStyle.type
[SymbolType](#symboltype) [SymbolType](#symboltype)
@@ -4551,10 +4581,6 @@ Rotation of text.
Settings related to text. Settings related to text.
### TextStyle.tMPAlignment
`TextAlignmentOptions`
### TextStyle.tMPFont ### TextStyle.tMPFont
`TMP_FontAsset` `TMP_FontAsset`
@@ -4802,11 +4828,17 @@ the color of tooltip border.
the width of tooltip border. the width of tooltip border.
### Tooltip.columnGapWidths
`List<float>` `v3.14.0`
the column gap width of content. When there is only one column, it only represents the gap width of the second column.
### Tooltip.contentLabelStyles ### Tooltip.contentLabelStyles
`List<LabelStyle>` `List<LabelStyle>`
the textstyle list of content. the column text style list of content. The first represents the text style of the first column, and so on.
### Tooltip.fixedHeight ### Tooltip.fixedHeight

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 KiB

After

Width:  |  Height:  |  Size: 704 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 660 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 86 KiB

View File

@@ -405,7 +405,7 @@ public AnimationDelayFunction delayFunction
### AnimationInfo.duration ### AnimationInfo.duration
public float duration public float duration
动画的时长。 动画的时长。默认用于计算动画的速度。也可以通过speed指定速度。
### AnimationInfo.durationFunction ### AnimationInfo.durationFunction
@@ -432,6 +432,11 @@ public Action OnAnimationStart
public bool reverse public bool reverse
是否开启反向动画效果。 是否开启反向动画效果。
### AnimationInfo.speed
public float speed
动画的速度。当指定speed时duration将失效。默认为0表示不指定速度。
### AnimationInfo.End ### AnimationInfo.End
public void End() public void End()
@@ -1042,6 +1047,10 @@ public bool needAnimation
public List&lt;string&gt; runtimeData public List&lt;string&gt; runtimeData
数值轴时每个tick的数值。 数值轴时每个tick的数值。
### AxisContext.sortedDataIndices
public List&lt;int&gt; sortedDataIndices
## AxisHandler&lt;T&gt; ## AxisHandler&lt;T&gt;
class in XCharts / 继承自: [MainComponentHandler](#maincomponenthandler) class in XCharts / 继承自: [MainComponentHandler](#maincomponenthandler)
@@ -1170,7 +1179,7 @@ public void Copy(AxisLabel axisLabel)
### AxisLabel.GetFormatterContent ### AxisLabel.GetFormatterContent
public override string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false) public override string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
### AxisLabel.IsNeedShowLabel ### AxisLabel.IsNeedShowLabel
@@ -1362,6 +1371,11 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent)
背景组件。 背景组件。
### Background.rect
public Rect rect
背景的矩形区域。
### Background.SetDefaultValue ### Background.SetDefaultValue
public override void SetDefaultValue() public override void SetDefaultValue()
@@ -1378,6 +1392,10 @@ public int containerIndex
public int containterInstanceId public int containterInstanceId
### Bar.useSortData
public override bool useSortData
### Bar.AddDefaultSerie ### Bar.AddDefaultSerie
public static Serie AddDefaultSerie(BaseChart chart, string serieName) public static Serie AddDefaultSerie(BaseChart chart, string serieName)
@@ -1936,6 +1954,10 @@ public T GetOrAddChartComponent&lt;T&gt;() where T : MainComponent
public Painter GetPainter(int index) public Painter GetPainter(int index)
### BaseChart.GetRealtimeSortSerie
public Serie GetRealtimeSortSerie(int gridIndex)
### BaseChart.GetSerie ### BaseChart.GetSerie
public Serie GetSerie(int serieIndex) public Serie GetSerie(int serieIndex)
@@ -1948,19 +1970,19 @@ public T GetSerie&lt;T&gt;(int serieIndex) where T : Serie
### BaseChart.GetSerieBarGap&lt;T&gt; ### BaseChart.GetSerieBarGap&lt;T&gt;
public float GetSerieBarGap&lt;T&gt;() where T : Serie public float GetSerieBarGap&lt;T&gt;(int gridIndex) where T : Serie
### BaseChart.GetSerieBarRealCount&lt;T&gt; ### BaseChart.GetSerieBarRealCount&lt;T&gt;
public int GetSerieBarRealCount&lt;T&gt;() where T : Serie public int GetSerieBarRealCount&lt;T&gt;(int gridIndex) where T : Serie
### BaseChart.GetSerieIndexIfStack&lt;T&gt; ### BaseChart.GetSerieIndexIfStack&lt;T&gt;
public int GetSerieIndexIfStack&lt;T&gt;(Serie currSerie) where T : Serie public int GetSerieIndexIfStack&lt;T&gt;(Serie currSerie, int gridIndex) where T : Serie
### BaseChart.GetSerieSameStackTotalValue&lt;T&gt; ### BaseChart.GetSerieSameStackTotalValue&lt;T&gt;
public double GetSerieSameStackTotalValue&lt;T&gt;(string stack, int dataIndex) where T : Serie public double GetSerieSameStackTotalValue&lt;T&gt;(string stack, int dataIndex, int gridIndex) where T : Serie
### BaseChart.GetSeriesMinMaxValue ### BaseChart.GetSeriesMinMaxValue
@@ -1968,11 +1990,11 @@ public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double te
### BaseChart.GetSerieTotalGap&lt;T&gt; ### BaseChart.GetSerieTotalGap&lt;T&gt;
public float GetSerieTotalGap&lt;T&gt;(float categoryWidth, float gap, int index) where T : Serie public float GetSerieTotalGap&lt;T&gt;(float categoryWidth, float gap, int index, int gridIndex) where T : Serie
### BaseChart.GetSerieTotalWidth&lt;T&gt; ### BaseChart.GetSerieTotalWidth&lt;T&gt;
public float GetSerieTotalWidth&lt;T&gt;(float categoryWidth, float gap, int realBarCount) where T : Serie public float GetSerieTotalWidth&lt;T&gt;(float categoryWidth, float gap, int realBarCount, int gridIndex) where T : Serie
### BaseChart.GetTitlePosition ### BaseChart.GetTitlePosition
@@ -2002,6 +2024,10 @@ public bool HasChartComponent(Type type)
public bool HasChartComponent&lt;T&gt;() public bool HasChartComponent&lt;T&gt;()
### BaseChart.HasRealtimeSortSerie
public bool HasRealtimeSortSerie(int gridIndex)
### BaseChart.HasSerie ### BaseChart.HasSerie
public bool HasSerie(Type type) public bool HasSerie(Type type)
@@ -2353,6 +2379,10 @@ class in XCharts.Runtime / 继承自: [MaskableGraphic](https://docs.unity3d.com
public virtual HideFlags chartHideFlags public virtual HideFlags chartHideFlags
### BaseGraph.childrenNodeNames
public List&lt;string&gt; childrenNodeNames
### BaseGraph.clickPos ### BaseGraph.clickPos
public Vector2 clickPos public Vector2 clickPos
@@ -2411,6 +2441,10 @@ public float graphX
public float graphY public float graphY
图形的Y 图形的Y
### BaseGraph.isDragingClick
public bool isDragingClick
### BaseGraph.isPointerClick ### BaseGraph.isPointerClick
public bool isPointerClick public bool isPointerClick
@@ -2759,6 +2793,10 @@ public float GetRuntimeBorderWidth()
public float[] GetRuntimeCornerRadius() public float[] GetRuntimeCornerRadius()
### BorderStyle.IsCricle
public bool IsCricle()
## CalendarCoord ## CalendarCoord
class in XCharts.Runtime / 继承自: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer) class in XCharts.Runtime / 继承自: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer)
@@ -2893,7 +2931,8 @@ public static void DestoryGameObject(GameObject go)
### ChartHelper.DestoryGameObjectByMatch ### ChartHelper.DestoryGameObjectByMatch
public static void DestoryGameObjectByMatch(Transform parent, string containString) public static void DestoryGameObjectByMatch(Transform parent, List&lt;string&gt; children)
### ChartHelper.DestroyAllChildren ### ChartHelper.DestroyAllChildren
@@ -2940,7 +2979,8 @@ public static Vector3 GetLastValue(List&lt;Vector3&gt; list)
### ChartHelper.GetMaxCeilRate ### ChartHelper.GetMaxCeilRate
public static double GetMaxCeilRate(double value, double ceilRate) public static float GetMaxCeilRate(float value, float ceilRate)
### ChartHelper.GetMaxDivisibleValue ### ChartHelper.GetMaxDivisibleValue
@@ -2952,7 +2992,8 @@ public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE
### ChartHelper.GetMinCeilRate ### ChartHelper.GetMinCeilRate
public static double GetMinCeilRate(double value, double ceilRate) public static float GetMinCeilRate(float value, float ceilRate)
### ChartHelper.GetMinDivisibleValue ### ChartHelper.GetMinDivisibleValue
@@ -3062,6 +3103,10 @@ public static List&lt;string&gt; ParseStringFromString(string jsonData)
public static void RemoveComponent&lt;T&gt;(GameObject gameObject) public static void RemoveComponent&lt;T&gt;(GameObject gameObject)
### ChartHelper.RemoveTMPComponents
public static void RemoveTMPComponents(GameObject gameObject)
### ChartHelper.RotateRound ### ChartHelper.RotateRound
public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle) public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle)
@@ -3414,10 +3459,9 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
注解项。 注解项。
### CommentItem.content ### CommentItem.labelObject
public string content public ChartLabel labelObject
注解的文本内容。支持模板参数可以参考Tooltip的itemFormatter。
### CommentItem.markRect ### CommentItem.markRect
@@ -3866,9 +3910,13 @@ public static bool NeedFormat(string content)
### FormatterHelper.ReplaceAxisLabelContent ### FormatterHelper.ReplaceAxisLabelContent
public static void ReplaceAxisLabelContent(ref string content, string value) public static void ReplaceAxisLabelContent(ref string content, string value, int index, int totalIndex)
### FormatterHelper.ReplaceIndexContent
public static void ReplaceIndexContent(ref string content, int currIndex, int totalIndex)
### FormatterHelper.TrimAndReplaceLine ### FormatterHelper.TrimAndReplaceLine
public static string TrimAndReplaceLine(string content) public static string TrimAndReplaceLine(string content)
@@ -4379,7 +4427,7 @@ public override void ClearData()
### Indicator.GetFormatterIndicatorContent ### Indicator.GetFormatterIndicatorContent
public string GetFormatterIndicatorContent(string indicatorName) public string GetFormatterIndicatorContent(string indicatorName, int index, int totalIndex)
### Indicator.GetIndicator ### Indicator.GetIndicator
@@ -4630,12 +4678,12 @@ public Color GetColor(Color defaultColor)
### LabelStyle.GetFormatterContent ### LabelStyle.GetFormatterContent
public virtual string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false) public virtual string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
### LabelStyle.GetFormatterDateTime ### LabelStyle.GetFormatterDateTime
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue) public string GetFormatterDateTime(int labelIndex, int totalIndex, double value, double minValue, double maxValue)
### LabelStyle.GetOffset ### LabelStyle.GetOffset
@@ -5317,6 +5365,10 @@ public float runtimeTop
public Vector3 GetPosition(float chartWidth, float chartHeight) public Vector3 GetPosition(float chartWidth, float chartHeight)
返回在坐标系中的具体位置 返回在坐标系中的具体位置
### Location.GetRect
public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight)
### Location.IsBottom ### Location.IsBottom
public bool IsBottom() public bool IsBottom()
@@ -6695,7 +6747,7 @@ public double GetData(int index, int dimension, DataZoom dataZoom = null)
### Serie.GetDataList ### Serie.GetDataList
public List&lt;SerieData&gt; GetDataList(DataZoom dataZoom = null) public List&lt;SerieData&gt; GetDataList(DataZoom dataZoom = null, bool sorted = false)
获得系列的数据列表 获得系列的数据列表
### Serie.GetDataTotal ### Serie.GetDataTotal
@@ -7002,6 +7054,10 @@ public SelectStyle selectStyle
public bool show public bool show
该数据项是否要显示。 该数据项是否要显示。
### SerieData.sortIndex
public int sortIndex
### SerieData.state ### SerieData.state
public SerieState state public SerieState state
@@ -7148,7 +7204,7 @@ public void SetIconActive(bool flag)
### SerieData.SetLabelActive ### SerieData.SetLabelActive
public void SetLabelActive(bool flag) public void SetLabelActive(bool flag, bool force = false)
### SerieData.SetPolygon ### SerieData.SetPolygon
@@ -7925,7 +7981,7 @@ class in XCharts.Runtime / 继承自: [SymbolStyle](#symbolstyle),[ISerieDataCom
### SerieSymbol.GetSize ### SerieSymbol.GetSize
public float GetSize(List&lt;double&gt; data, float themeSize) public float GetSize(SerieData serieData, float themeSize)
根据指定的sizeType获得标记的大小 根据指定的sizeType获得标记的大小
### SerieSymbol.Reset ### SerieSymbol.Reset
@@ -9087,6 +9143,11 @@ class in XCharts.Runtime
UI帮助类。 UI帮助类。
### UIHelper.DrawBackground
public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2)
## ViewControl ## ViewControl
class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)

View File

@@ -6,6 +6,8 @@ slug: /changelog
# 更新日志 # 更新日志
[master](#master) [master](#master)
[v3.14.0](#v3140)
[v3.13.0](#v3130)
[v3.12.1](#v3121) [v3.12.1](#v3121)
[v3.12.0](#v3120) [v3.12.0](#v3120)
[v3.11.2](#v3112) [v3.11.2](#v3112)
@@ -78,6 +80,63 @@ slug: /changelog
## master ## master
## v3.14.0
版本要点:
* 新增`Bar`的实时排序功能
* 新增`Tooltip``itemFormatter`支持`\n`换行
* 新增`AxisLabel`的格式化支持`{index}`
* 新增`Animation``speed`可指定动画速度
* 优化`Tooltip`的列对齐方式
日志详情:
* (2025.03.15) 发布`v3.14.0`版本
* (2025.03.09) 修复`Bar`在同一个`Chart`不同`Grid`里时绘制有些异常的问题
* (2025.03.07) 增加`Animation``speed`可指定动画速度
* (2025.03.06) 优化`Animation`的新增动画表现
* (2025.03.04) 修复`Treemap``label`显示异常的问题
* (2025.03.02) 增加`Tooltip``columnGapWidths`参数设置列文本间隙距离
* (2025.03.01) 优化`Comment`的组件刷新
* (2025.02.23) 增加`Axis``Label``formatter`支持`{index}``{index-1}``{-index}``{-index-1}`通配符
* (2025.02.23) 增加`Bar``realtimeSort`支持实时排序
* (2025.02.19) 增加`Tooltip``itemFormatter``\n`换行的支持
* (2025.02.18) 优化`Tooltip`的对齐方式
* (2025.02.09) 修复`SaveAsImage`保存图片时不支持透明度的问题 (#337)
* (2025.02.05) 增加`GraphChart`可单独设置`data`样式的支持
* (2025.02.05) 重构`SerieSymbol``sizeFunction`参数
* (2025.01.23) 修复`Treemap``Label`不显示的问题
* (2025.01.15) 修复`Chart`在运行时动态添加`Component`异常的问题 (#339)
* (2025.01.08) 修复`TextMeshPro`关闭时残留组件影响`Text`初始化的问题
## v3.13.0
版本要点:
* 新增`UIText`扩展组件
* 新增`UIToggle`扩展组件
* 新增`UISlider`扩展组件
* 重构`UIProgress`扩展组件
* 增加`SymbolStyle``borderWidth``emptyColor`配置
* 增加`SymbolStyle``size2`参数支持长方形标记
* 其他优化和问题修复
日志详情:
* (2025.01.01) 发布`v3.13.0`版本
* (2024.12.27) 增加`SymbolStyle``size2`参数支持长方形标记
* (2024.12.26) 优化`Text``TextMeshPro`下的居中对齐方式
* (2024.12.25) 增加`Tooltip``itemFormatter`设置`{f0}`支持
* (2024.12.25) 修复`YAxis`在范围变更刷新时部分label可能不显示的问题
* (2024.12.23) 增加`SymbolStyle``borderWidth``emptyColor`配置
* (2024.12.17) 增加`UISlider`扩展组件
* (2024.12.10) 增加`UIToggle`扩展组件
* (2024.12.09) 修复`UITable``scrollbar`无法拖动的问题
* (2024.12.07) 修复`Chart`节点下不能放自定义节点的问题
* (2024.12.05) 增加`UIText`扩展组件
* (2024.12.04) 删除`TextStyle`的无用配置项`tmpAlignment`
## v3.12.1 ## v3.12.1
版本要点: 版本要点:
@@ -153,8 +212,6 @@ slug: /changelog
日志详情: 日志详情:
* (2024.06.16) 发布`v3.11.0`版本 * (2024.06.16) 发布`v3.11.0`版本
* (2024.06.15) 增加`Editor``Data`的添加、删除、上下移动操作按钮 * (2024.06.15) 增加`Editor``Data`的添加、删除、上下移动操作按钮
* (2024.06.11) 修复`Axis``IndicatorLabel`可能会遮挡住`Tooltip`的问题 * (2024.06.11) 修复`Axis``IndicatorLabel`可能会遮挡住`Tooltip`的问题

View File

@@ -276,7 +276,7 @@ class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein), [Animati
`float` `1000` `v3.8.0` `float` `1000` `v3.8.0`
动画的时长。 动画的时长。默认用于计算动画的速度。也可以通过speed指定速度。
### AnimationInfo.enable ### AnimationInfo.enable
@@ -290,6 +290,12 @@ class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein), [Animati
是否开启反向动画效果。 是否开启反向动画效果。
### AnimationInfo.speed
`float` `0` `v3.14.0`
动画的速度。当指定speed时duration将失效。默认为0表示不指定速度。
## AnimationInteraction ## AnimationInteraction
class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo) class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
@@ -2462,7 +2468,7 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent), [ISerie
`string` `string`
标签内容字符串模版格式器。支持用 \n 换行。部分组件的格式器会不生效。<br/> 模板通配符有以下这些,部分只适用于固定的组件:<br/> `\{.\}`:圆点标记。<br/> `\{a\}`:系列名。<br/> `\{b\}`X轴类目名或数据名。<br/> `\{c\}`:数据值。<br/> `\{d\}`:百分比。<br/> `\{e\}`:数据名。<br/> `\{f\}`:数据和。<br/> `\{g\}`:数据总个数。<br/> `\{h\}`:十六进制颜色值。<br/> `\{y\}`Y轴的类目名。<br/> `\{value\}`:坐标轴或图例的值。<br/> 以下通配符适用UITable组件<br/> `\{name\}` 表格的行名。<br/> `\{index\}`:表格的行号。<br/> 以下通配符适用UIStatistc组件<br/> `\{title\}`:标题文本。<br/> `\{dd\}`:天。<br/> `\{hh\}`:小时。<br/> `\{mm\}`:分钟。<br/> `\{ss\}`:秒。<br/> `\{fff\}`:毫秒。<br/> `\{d\}`:天。<br/> `\{h\}`:小时。<br/> `\{m\}`:分钟。<br/> `\{s\}`:秒。<br/> `\{f\}`:毫秒。<br/> 示例:“\{b\}:\{c\}” 标签内容字符串模版格式器。支持用 \n 换行。部分组件的格式器会不生效。<br/> 模板通配符有以下这些,部分只适用于固定的组件:<br/> `\{.\}`:圆点标记。<br/> `\{a\}`:系列名。<br/> `\{b\}`X轴类目名或数据名。<br/> `\{c\}`:数据值。<br/> `\{d\}`:百分比。<br/> `\{e\}`:数据名。<br/> `\{f\}`:数据和。<br/> `\{g\}`:数据总个数。<br/> `\{h\}`:十六进制颜色值。<br/> `\{y\}`Y轴的类目名。<br/> `\{value\}`:坐标轴或图例的值。<br/> `\{index\}`:坐标轴编号。<br/> 以下通配符适用UITable组件<br/> `\{name\}` 表格的行名。<br/> `\{index\}`:表格的行号。<br/> 以下通配符适用UIStatistc组件<br/> `\{title\}`:标题文本。<br/> `\{dd\}`:天。<br/> `\{hh\}`:小时。<br/> `\{mm\}`:分钟。<br/> `\{ss\}`:秒。<br/> `\{fff\}`:毫秒。<br/> `\{d\}`:天。<br/> `\{h\}`:小时。<br/> `\{m\}`:分钟。<br/> `\{s\}`:秒。<br/> `\{f\}`:毫秒。<br/> 示例:“\{b\}:\{c\}”
### LabelStyle.height ### LabelStyle.height
@@ -3755,6 +3761,12 @@ class in XCharts.Runtime / 继承自: [BaseSerie](#baseserie), [IComparable](htt
半径。radius[0]表示内径radius[1]表示外径。 半径。radius[0]表示内径radius[1]表示外径。
### Serie.realtimeSort
`bool` `false` `v3.14.0`
是否开启实时排序用来实现动态排序图效果。目前仅在Bar中生效。
### Serie.right ### Serie.right
`float` `float`
@@ -4366,12 +4378,24 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) / 子类
系列数据项的标记的图形 系列数据项的标记的图形
### SymbolStyle.borderWidth
`float` `0f` `v3.13.0`
图形的边框宽度。
### SymbolStyle.color ### SymbolStyle.color
`Color32` `Color32`
图形的颜色。 图形的颜色。
### SymbolStyle.emptyColor
`Color32` `v3.13.0`
空心图形的颜色。
### SymbolStyle.gap ### SymbolStyle.gap
`float` `0` `float` `0`
@@ -4414,6 +4438,12 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) / 子类
标记的大小。 标记的大小。
### SymbolStyle.size2
`float` `0f` `v3.13.0`
标记的大小。当为Rect时size2表示高度。
### SymbolStyle.type ### SymbolStyle.type
[SymbolType](#symboltype) [SymbolType](#symboltype)
@@ -4551,10 +4581,6 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
文本的相关设置。 文本的相关设置。
### TextStyle.tMPAlignment
`TextAlignmentOptions`
### TextStyle.tMPFont ### TextStyle.tMPFont
`TMP_FontAsset` `TMP_FontAsset`
@@ -4802,11 +4828,17 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent)
边框线宽。 边框线宽。
### Tooltip.columnGapWidths
`List<float>` `v3.14.0`
内容部分的列间距。当只有一列时,只表示第二列的间距。
### Tooltip.contentLabelStyles ### Tooltip.contentLabelStyles
`List<LabelStyle>` `List<LabelStyle>`
内容部分的文本样式列表。和列一一对应 内容部分的文本样式列表。第一个表示第一列的文本样式,以此类推
### Tooltip.fixedHeight ### Tooltip.fixedHeight

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 KiB

After

Width:  |  Height:  |  Size: 704 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 660 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 86 KiB

View File

@@ -6,74 +6,64 @@ slug: /support
# 订阅服务 # 订阅服务
如需技术支持和购买扩展图表,可订阅`VIP`服务。详情可查看以下内容,也可以加QQ`3525422251XCharts技术支持`或发邮件到`monitor1394@gmail.com`进行咨询 如需技术支持和扩展图表购买,可通过订阅 VIP 服务获取专属权益。企业商务合作请联系 QQ `3525422251` 或邮件至 `monitor1394@gmail.com`
企业商务合作可QQ和邮件咨询。 ## 订阅计划
## 订阅VIP服务 ### 订阅类型
订阅服务分`个人订阅``企业订阅` - **个人订阅**
- 归属个人,不可转让,服务仅限订阅者本人使用。
- **企业订阅**
- 归属企业,席位可分配给指定员工,支持席位变更(如员工离职后重新分配)。
- 通过企业专属群组提供技术支持。
- __个人订阅__`个人VIP`属于个人,不可转让,`XCharts`团队只服务于订阅当事人。 ### 订阅优势
- __企业订阅__`企业VIP`属于企业,席位内可安排固定职员,职员离职后席位可重新安排,`XCharts`团队通过专属企业群为企业服务。
订阅服务有哪些优势? - **高效支持**:快速定位技术问题,节省开发时间。
- **深度交流**:与 XCharts 核心团队及开发者社区直接互动,获取行业经验。
- **扩展功能**:解锁高级图表和 UI 组件,持续获得更新支持。
- **社区共建**:加入 GitHub 组织,访问私有仓库,参与项目生态建设。
- **专属标识**:在交流群中享有 VIP 身份标识,优先响应需求。
- __提高工作效率节省时间成本__。`XCharts`功能强大,配置项众多,`VIP`服务可快速帮您定位,节省查找和核对的时间;`VIP`的即时回答服务可快速为您答疑解惑,快速上手,提高工作效率。 ## 服务详情
- __更多技术交流更多经验交流__。`XCharts`团队成员从业多年,有丰富的技术和工作经验。`VIP`服务不仅可以交流`XCharts`相关的内容,也可以咨询其他方面内容。`VIP`群也有更多的交流碰撞。
- __订阅扩展图表获得更新支持__。扩展图表需要订阅`VIP`服务后才能购买扩展图表超过1年后的更新支持也需要持续订阅`VIP`服务。
- __加入团队组织参与社区建设__。订阅`VIP`后可加入`GitHub`组织,参与社区建设,访问专有仓库,扩展图表仓库等其他私有仓库。
- __专属高级功能专属身份标识__。订阅`VIP`后可以享有扩展UI组件扩展图表等其他高级功能XCharts后续也会陆续推出更多高级功能。在`XCharts交流群`里拥有`专属头衔`方便快速识别优先响应第一时间回复VIP用户的各种问题。
| |免费用户|付费咨询|个人`VIP` | 个人`SVIP` | 企业`VIP` | 企业`SVIP` | | 权益/服务 | 免费用户 | 个人 VIP | 个人 SVIP | 企业 VIP | 企业 SVIP |
| ----- |--|--|--|--|--|--| |-------------------|----------|----------|-----------------|-----------------|----------------|
| 订阅费用 | -- | `98`¥ | `298`¥ | 首年`1298`¥<br/>后续`298¥`* | 首年`1698`¥<br/>后续`298¥`* | `联系我们` | | **订阅费用** | — | 298¥/年 | 首年 1298¥<br/>续费 298¥/年 | 首年 1698¥<br/>续费 298¥/年 | 定制报价 |
| 订阅时长 | -- | `7`天* | `1`年 | `1`年 | `1`年 | `1` | | **服务时长** | — | 1 年 | 1 年 | 1 年 | 1 年 |
| 拥有席位 | -- | `1`个席位 | `1`个席位 |`1`个席位|`1`个席位|`5`个以上席位| | **服务席位** | — | 1 个 | 1 个 | 1 个 | ≥5 个 |
| 增加席位 | -- | -- | -- | -- |支持|支持| | **增加席位** | — | — | — | 支持298¥/席位/年) | 支持(定制报价)|
| __`服务方式:`__| | **支持方式** | | | | | |
| 官方QQ群交流 | √ | √ | √ | √ | √ | √ | | - Github Issues | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| QQ一对一交流 | | √ | √ | √ | √ | √ | | - 官方 QQ 群 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| 专属VIP群交流 | | | √ | √ | √ | √ | | - QQ 一对一支持 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| 微信交流 | | | | | √ | √(企业专属群) | | - 专属 VIP 群 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| 电话交流 | | | | | | √ | | - 微信支持 | | — | — | ✔️ | ✔️ |
| __`服务内容:`__| | - 电话支持 | — | — | — | — | ✔️ |
| 可商用可二次开发 | √ | √ | √ | √ | √ | √ | | - 专属企业群 | — | — | — | — | ✔️ |
| 有问即答 | | √ | √ | √ | √ | √ | | **核心权益** | | | | | |
| 新手入门指导 | | √ | √ | √ | √ | √ | | - 商用与二次开发 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| 开发优化指导 | | √ | √ | √ | √ | √ | | - 即时技术支持 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| 其他技术支持 | | | √ | √ | √ | √ | | - 开发优化指导 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| 问题及时处理 | | | √ | √ | √ | √ | | - 需求优先处理 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| 需求优先考虑 | | | √ | √ | √ | √ | | - 付费定制 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| 可另付费定制 | | | √ | √ | √ | √ | | - 扩展 UI 组件 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| 可另付费加急 | | | √ | √ | √ | √ | | - 扩展图表免费使用 | — | 按需购买 | ✔️(全量) | ✔️(全量) | ✔️(全量) |
| 扩展UI组件 | | | √ | √ | √ | √ | | **企业专属权益** | | | | | |
| 首页赞助展示 | | | | | | √ | | - 电子发票 | | ✔️ | ✔️ | ✔️ | ✔️ |
| 付费方式 | | | 二维码 | 二维码 | __公对公转账__* | __公对公转账__* | | - 专用发票 | — | — | — | ✔️ | ✔️ |
| 支持开发票 | | | 普票 | 普票 | __可开专票__ | __可开专票__ | | - 首页赞助展示 | — | — | — | — | ✔️ |
| 扩展图表购买 | | | 按需购买 | __全部免费__* | __全部免费__* | __全部免费__* | | **源码与更新** | | | | | |
| 扩展图表源码 | | | 永久持有 | 永久持有 | 永久持有 | 永久持有 | | - 永久持有源码 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| 扩展图表更新 | | | 1年更新支持 | 1年更新支持 | 1年更新支持 | 1年更新支持 | | - 1 年更新支持 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| Github仓库 | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)<br/>[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI) | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)<br/>[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)<br/>[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)<br/>[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo) | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)<br/>[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)<br/>[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)<br/>[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo) | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)<br/>[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)<br/>[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)<br/>[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo) | | **GitHub 仓库权限**| 公开仓库 | +UI 扩展组件 | +Pro 扩展图表 | +Pro 扩展图表 | +Pro 扩展图表 |
>备注: ## 扩展图表
>*__`付费定制`__ 用户可根据自己的需求可付费定制不同的图表或新功能,只有`VIP`用户才享有`付费定制`权利。
>*__`付费加急`__ 用户可对已在开发计划中或正在开发中的功能进行付费加急,将开发优先级提到最高,并可要求在指定`截止日期`内交付,只有`VIP`用户才享有`付费加急`权利。
>*__`付费咨询`__ 付费咨询有效期`7`天,且总咨询时长不超过`7`个小时。
>*__`扩展图表`__ 购买后代码可永久持有和商用1年的更新和技术支持。可继续订阅VIP延长服务时间。
>*__`全部免费`__ 是指在订阅期间的`个人SVIP``企业VIP`的订阅用户,可免费使用全部的扩展图表。
>*__`次年付费`__ 个人SVIP和企业VIP的首年和次年付费不一样次年付费都是`298¥`
>*__`增加席位`__ 企业VIP支持增加席位每个席位`298¥`一年。
>*__`对公转账`__ 有开专票需求时,可用企业银行帐号进行公对公转账支付。二维码支付不支持开专票,只能开普票。发票默认都是电子发票。
>*__`登记资料`__ 订阅成功后需提供手机号和Github帐号进行登记手机号用于确认归属Github帐号用于加入Github的Team组织下载源码。
## 购买扩展图表 以下扩展图表需订阅 VIP 后购买个人SVIP 及企业 VIP 用户可免费使用全量图表):
扩展图表为另付费购买图表,只对订阅了`VIP`服务的用户开放购买。对于`个人SVIP``企业VIP`的订阅用户,所有扩展图表仓库在订阅期间可全部免费使用,不用再单独购买。 |编号|扩展图表|图表类名|价格|
对所有已购买的扩展图表,源码可永久持有但不能传播,并获得持续一年的更新支持和技术服务,一年后如需更新支持等服务,可再继续订阅`VIP`服务。
|编号|扩展图表|扩展图表|价格|
|--|--|--|--| |--|--|--|--|
| 101 | [象形柱图](https://xcharts-team.github.io/docs/pictorialbar) |PictorialBarChart | 98¥ | | 101 | [象形柱图](https://xcharts-team.github.io/docs/pictorialbar) |PictorialBarChart | 98¥ |
| 102 | [漏斗图](https://xcharts-team.github.io/docs/funnel) |FunnelChart | 98¥ | | 102 | [漏斗图](https://xcharts-team.github.io/docs/funnel) |FunnelChart | 98¥ |
@@ -88,15 +78,15 @@ slug: /support
| 206 | [3D折线图](https://xcharts-team.github.io/docs/line3d) |Line3DChart | 198¥ | | 206 | [3D折线图](https://xcharts-team.github.io/docs/line3d) |Line3DChart | 198¥ |
| 207 | [关系图](https://xcharts-team.github.io/docs/graph) |GraphChart | 198¥ | | 207 | [关系图](https://xcharts-team.github.io/docs/graph) |GraphChart | 198¥ |
扩展图表的在线效果图也可以查看[WebGL在线Demo](https://xcharts-team.github.io/examples/) ## 附注说明
## 捐助支持 1. **扩展图表更新**:购买后享 1 年免费更新,续订 VIP 可延长服务周期。
2. **企业订阅**:支持公对公转账与专用发票,席位可灵活调整。
3. **定制服务**VIP 用户可额外付费定制功能或加急需求开发。
如果这个项目对您有帮助,请右上方点 `Star` 予以支持也欢迎扫后面的二维码进行任意金额的捐助XCharts需要您的支持和帮助。 ## 支持我们
## 二维码 - **社区支持**:欢迎在 GitHub 为 XCharts 点 ⭐️ [Star 支持](https://github.com/XCharts-Team/XCharts)
- **扫码捐助**
如果看不到二维码图片可以加Q联系`XCharts技术支持:3525422251`或邮件`monitor1394@gmail.com`咨询。 ![微信支付](img/support_wechat.png)
![支付宝](img/support_alipay.png)
![alipay-qrcode](img/support_alipay.png)
![wechat-qrcode](img/support_wechat.png)

View File

@@ -15,6 +15,7 @@ namespace XCharts.Editor
++EditorGUI.indentLevel; ++EditorGUI.indentLevel;
PropertyField(prop, "m_Delay"); PropertyField(prop, "m_Delay");
PropertyField(prop, "m_Duration"); PropertyField(prop, "m_Duration");
PropertyField(prop, "m_Speed");
--EditorGUI.indentLevel; --EditorGUI.indentLevel;
} }
} }
@@ -30,6 +31,7 @@ namespace XCharts.Editor
{ {
++EditorGUI.indentLevel; ++EditorGUI.indentLevel;
PropertyField(prop, "m_Duration"); PropertyField(prop, "m_Duration");
PropertyField(prop, "m_Speed");
--EditorGUI.indentLevel; --EditorGUI.indentLevel;
} }
} }
@@ -45,6 +47,7 @@ namespace XCharts.Editor
{ {
++EditorGUI.indentLevel; ++EditorGUI.indentLevel;
PropertyField(prop, "m_Duration"); PropertyField(prop, "m_Duration");
PropertyField(prop, "m_Speed");
--EditorGUI.indentLevel; --EditorGUI.indentLevel;
} }
} }

View File

@@ -27,7 +27,10 @@ namespace XCharts.Editor
} }
PropertyField(prop, "m_Color"); PropertyField(prop, "m_Color");
PropertyField(prop, "m_Size"); PropertyField(prop, "m_Size");
PropertyField(prop, "m_Size2");
PropertyField(prop, "m_Gap"); PropertyField(prop, "m_Gap");
PropertyField(prop, "m_BorderWidth");
PropertyField(prop, "m_EmptyColor");
PropertyField(prop, "m_Offset"); PropertyField(prop, "m_Offset");
--EditorGUI.indentLevel; --EditorGUI.indentLevel;
} }

View File

@@ -27,14 +27,13 @@ namespace XCharts.Editor
PropertyField(prop, "m_Color"); PropertyField(prop, "m_Color");
PropertyField(prop, "m_FontSize"); PropertyField(prop, "m_FontSize");
PropertyField(prop, "m_LineSpacing"); PropertyField(prop, "m_LineSpacing");
PropertyField(prop, "m_Alignment");
PropertyField(prop, "m_AutoAlign");
#if dUI_TextMeshPro #if dUI_TextMeshPro
PropertyField(prop, "m_TMPFontStyle"); PropertyField(prop, "m_TMPFontStyle");
PropertyField(prop, "m_TMPSpriteAsset"); PropertyField(prop, "m_TMPSpriteAsset");
PropertyField(prop, "m_TMPAlignment");
#else #else
PropertyField(prop, "m_FontStyle"); PropertyField(prop, "m_FontStyle");
PropertyField(prop, "m_Alignment");
PropertyField(prop, "m_AutoAlign");
PropertyField(prop, "m_AutoWrap"); PropertyField(prop, "m_AutoWrap");
#endif #endif
--EditorGUI.indentLevel; --EditorGUI.indentLevel;

View File

@@ -41,6 +41,7 @@ namespace XCharts.Editor
}); });
PropertyField("m_LineStyle"); PropertyField("m_LineStyle");
PropertyField("m_TitleLabelStyle"); PropertyField("m_TitleLabelStyle");
PropertyListField("m_ColumnGapWidths");
PropertyListField("m_ContentLabelStyles"); PropertyListField("m_ContentLabelStyles");
--EditorGUI.indentLevel; --EditorGUI.indentLevel;
} }

View File

@@ -22,6 +22,11 @@ namespace XCharts.Editor
PropertyField("m_BarWidth"); PropertyField("m_BarWidth");
PropertyField("m_BarGap"); PropertyField("m_BarGap");
PropertyField("m_BarMaxWidth"); PropertyField("m_BarMaxWidth");
PropertyField("m_RealtimeSort");
if(serie.useSortData)
{
PropertyField("m_DataSortType");
}
if (serie.IsUseCoord<PolarCoord>()) if (serie.IsUseCoord<PolarCoord>())
{ {
PropertyField("m_RoundCap"); PropertyField("m_RoundCap");

View File

@@ -108,11 +108,11 @@ namespace XCharts.Editor
{ {
EditorGUI.LabelField(drawRect, name); EditorGUI.LabelField(drawRect, name);
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH; var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
var diff = 13 + EditorGUI.indentLevel * 14; var diff = 12 + EditorGUI.indentLevel * 14;
var offset = diff - INDENT_WIDTH; var offset = diff - INDENT_WIDTH;
var tempWidth = (rectWidth - startX + diff) / 2; var tempWidth = (rectWidth - startX + diff) / 2;
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1); var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1);
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1); var centerYRect = new Rect(centerXRect.x + tempWidth - offset + 3.4f, drawRect.y, tempWidth - 1, drawRect.height - 1);
EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none); EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none); EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -326,7 +326,13 @@ namespace XCharts.Editor
var foldoutRect = drawRect; var foldoutRect = drawRect;
foldoutRect.xMax -= 10; foldoutRect.xMax -= 10;
bool flag = EditorGUI.Foldout(foldoutRect, foldout, listProp.displayName, true); bool flag = EditorGUI.Foldout(foldoutRect, foldout, listProp.displayName, true);
ChartEditorHelper.DrawMenu(drawRect, menus); if (!flag)
{
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
var sizeRect = new Rect(startX, drawRect.y + 1f, (EditorGUI.indentLevel + 1) * 15, drawRect.height - 1);
EditorGUI.IntField(sizeRect, GUIContent.none, listProp.arraySize);
DrawMenu(drawRect, menus);
}
height += headerHeight; height += headerHeight;
drawRect.y += headerHeight; drawRect.y += headerHeight;
drawRect.width = rawWidth; drawRect.width = rawWidth;

View File

@@ -21,9 +21,9 @@ namespace XCharts.Example
} }
} }
float SymbolSize(List<double> data) float SymbolSize(float defaultSize, SerieData serieData)
{ {
return (float) (Math.Sqrt(data[2]) / 6e2); return defaultSize;
} }
} }
} }

137
README.md
View File

@@ -38,7 +38,7 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
![XCharts](Documentation~/zh/img/xcharts.png) ![XCharts](Documentation~/zh/img/xcharts.png)
一款基于`UGUI`的功能强大简单易用的`Unity`数据可视化图表插件。支持`折线图``柱状图``饼图``雷达图``散点图``热力图``环形图``K线图``极坐标``平行坐标`等十几种内置图表,以及`3D饼图``3D柱图``3D金字塔``漏斗图``仪表盘``水位图``象形柱图``甘特图``矩形树图``桑基图``3D折线图``关系图`等十几种扩展图表。 XCharts 是一款基于 UGUI 的功能强大简单易用的 Unity 数据可视化图表插件。它提供了丰富的图表类型和灵活的配置选项帮助开发者快速实现专业级的数据可视化效果。支持折线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等十多种常用的内置图表。提供3D饼图、3D柱图、3D金字塔、漏斗图、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图、3D折线图、关系图等十多种高级扩展图表。
[XCharts 官方主页](https://xcharts-team.github.io) [XCharts 官方主页](https://xcharts-team.github.io)
[XCharts 在线示例](https://xcharts-team.github.io/examples) [XCharts 在线示例](https://xcharts-team.github.io/examples)
@@ -52,25 +52,24 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
## 特性 ## 特性
- __纯代码绘制__图表纯代码绘制,无需额外贴图Shader资源。 - __纯代码绘制__图表完全通过代码生成,无需额外贴图Shader 资源,轻量高效
- __可视化配置__参数可视化配置,效果实时预览,支持运行时代码动态修改配置和数据。 - __可视化配置__提供直观的参数配置界面,支持实时预览效果,并可在运行时动态修改配置和数据。
- __高自由定制__支持从主题和配置参数上任意调整;支持代码自定义绘制,自定义回调以及自定义实现图表 - __高定制__支持从主题、组件到数据项的全面参数设置,同时允许通过代码自定义绘制逻辑、回调函数及图表实现
- __多内置图表__支持线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等多种内置图表。 - __多内置图表__支持线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等多种常用的内置图表。
- __多扩展图表__支持3D柱图、3D饼图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图、3D折线图、关系图等多种扩展图表。 - __多扩展图表__支持3D柱图、3D饼图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图、3D折线图、关系图等多种高级扩展图表,满足复杂数据可视化需求
- __多扩展组件__支持表格、统计数值等多种扩展UI组件 - __多扩展组件__支持多种实用 UI 组件,如表格、统计数值、滑动条、进度条等,增强图表交互性
- __多图表组合__支持内置图表的任意组合,同一图中可同时显示多个相同或不同类型的图表。 - __多图表组合__支持在同一图表中组合显示多个相同或不同类型的图表,满足复杂场景需求
- __多种坐标系__支持直角坐标系、极坐标系、单轴等多种坐标系。 - __多种坐标系__支持直角坐标系、极坐标系、单轴等多种坐标系,适应不同数据展示需求
- __丰富的组件__支持标题、图例、提示框、标线、标域、数据区域缩放、视觉映射等常用组件。 - __丰富的组件__提供标题、图例、提示框、标线、标域、数据区域缩放、视觉映射等常用组件,提升图表可读性
- __多样式线图__支持直线、曲线、虚线、面积图、阶梯线图等多种线图。 - __多样式线图__支持直线、曲线、虚线、面积图、阶梯线图等多种线图样式,满足不同数据趋势展示需求
- __多样式柱图__支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图、胶囊柱图等多种柱状图。 - __多样式柱图__支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图、胶囊柱图等多种柱状图样式
- __多样式饼图__支持环形图、玫瑰图、环形玫瑰图等多种饼图。 - __多样式饼图__支持环形图、玫瑰图、环形玫瑰图等多种饼图样式,直观展示数据占比
- __丰富的线条__支持实线、曲线、阶梯线、虚线、点线、点划线、双点划线等线条 - __自定义绘制__提供强大的绘图 API支持自定义绘制点、线、面等图形满足个性化需求
- __自定义绘制__支持自定义图表内容绘制提供绘制点、线、面等其他图形的强大的绘图API - __大数据绘制__支持万级数据量绘制,优化性能表现;支持采样绘制,进一步提升大数据场景下的性能
- __大数据绘制__支持万级大数据量绘制支持采样绘制特殊的简化图表支持更优的性能 - __自定义主题__支持主题定制、导入和导出内置明暗两种默认主题轻松适配不同应用场景
- __自定义主题__支持主题定制、导入和导出内置明暗两种默认主题 - __动画和交互__支持渐入、渐出、变更、新增等多种动画效果以及数据筛选、视图缩放、细节展示等交互操作提升用户体验
- __动画和交互__支持渐入动画、渐出动画、变更动画、新增动画、交互动画等多种动画支持多平台的数据筛选、视图缩放、细节展示等交互操作 - __第三方扩展__无缝集成TexMeshPro和New Input System扩展功能兼容性
- __第三方扩展__支持无缝接入`TexMeshPro``New Input System` - __版本和兼容__支持 Unity 5.6 及以上版本,兼容全平台运行
- __版本和兼容__支持所有`5.6`以上的`Unity`版本;支持全平台运行。
## 截图 ## 截图
@@ -78,36 +77,6 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
![扩展图表](Documentation~/zh/img/readme_extendchart.png) ![扩展图表](Documentation~/zh/img/readme_extendchart.png)
## 仓库
- __[XCharts](https://github.com/XCharts-Team/XCharts)__ XCharts核心功能完全免费。
- __[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)__ XCharts守护程序用于确保XCharts更新时的编译正常。非必须但建议使用。
- __[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)__ XCharts官方示例不包含扩展图表部分。订阅购买扩展图表后可导入示例。
- __[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)__ XCharts专业版包含所有扩展图表和扩展组件。订阅SVIP后可访问使用。
- __[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo)__ XCharts专业版官方示例包含所有扩展图表和扩展组件的示例。订阅SVIP后可访问使用。
- __[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)__ XCharts的扩展UI组件。订阅VIP后可访问使用。
- __[XCharts-Bar3DChart](https://github.com/XCharts-Team/XCharts-Bar3DChart)__ XCharts扩展图表3D柱图。订阅购买后可访问使用。
- __[XCharts-FunnelChart](https://github.com/XCharts-Team/XCharts-FunnelChart)__ XCharts扩展图表漏斗图。订阅购买后可访问使用。
- __[XCharts-GanttChart](https://github.com/XCharts-Team/XCharts-GanttChart)__ XCharts扩展图表甘特图。订阅购买后可访问使用。
- __[XCharts-GaugeChart](https://github.com/XCharts-Team/XCharts-GaugeChart)__ XCharts扩展图表仪表盘。订阅购买后可访问使用。
- __[XCharts-LiquidChart](https://github.com/XCharts-Team/XCharts-LiquidChart)__ XCharts扩展图表水位图。订阅购买后可访问使用。
- __[XCharts-PictorialBarChart](https://github.com/XCharts-Team/XCharts-PictorialBarChart)__ XCharts扩展图表象形住图。订阅购买后可访问使用。
- __[XCharts-Pie3DChart](https://github.com/XCharts-Team/XCharts-Pie3DChart)__ XCharts扩展图表3D饼图。订阅购买后可访问使用。
- __[XCharts-PyramidChart](https://github.com/XCharts-Team/XCharts-PyramidChart)__ XCharts扩展图表3D金字塔。订阅购买后可访问使用。
- __[XCharts-TreemapChart](https://github.com/XCharts-Team/XCharts-TreemapChart)__ XCharts扩展图表矩形树图。订阅购买后可访问使用。
- __[XCharts-SankeyChart](https://github.com/XCharts-Team/XCharts-SankeyChart)__ XCharts扩展图表桑基图。订阅购买后可访问使用。
- __[XCharts-Line3DChart](https://github.com/XCharts-Team/XCharts-Line3DChart)__ XCharts扩展图表3D折线图。订阅购买后可访问使用。
- __[XCharts-GraphChart](https://github.com/XCharts-Team/XCharts-GraphChart)__ XCharts扩展图表关系图。订阅购买后可访问使用。
## 分支
- __[master](https://github.com/XCharts-Team/XCharts/tree/master)__ XCharts3.0的开发分支。最新的修改和功能都先提交到`master`分支,稳定后再发布`release`版本。
- __[3.0](https://github.com/XCharts-Team/XCharts/tree/3.0)__ XCharts3.0的稳定分支。一般一个月一发布,`master`分支稳定后,`merge``3.0`分支,并发布`release`版本。
- __[2.0](https://github.com/XCharts-Team/XCharts/tree/2.0)__ XCharts2.0的稳定分支。带Demo目前基本不再维护仅修改严重bug。
- __[2.0-upm](https://github.com/XCharts-Team/XCharts/tree/2.0-upm)__ XCharts2.0的稳定UMP分支。不带Demo只包含Package部分不再维护。
- __[1.0](https://github.com/XCharts-Team/XCharts/tree/1.0)__ XCharts1.0的稳定分支。带Demo不再维护。
- __[1.0-upm](https://github.com/XCharts-Team/XCharts/tree/1.0-upm)__ XCharts1.0的稳定UMP分支。不带Demo不再维护。
## 使用 ## 使用
- 导入`XCharts``unitypackage`或者源码到项目。建议也导入`XCharts`守护程序 [XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)。 - 导入`XCharts``unitypackage`或者源码到项目。建议也导入`XCharts`守护程序 [XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)。
@@ -117,47 +86,67 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
- 更多细节,请看[【XCharts教程5分钟上手教程】](Documentation~/zh/tutorial01.md)。 - 更多细节,请看[【XCharts教程5分钟上手教程】](Documentation~/zh/tutorial01.md)。
- 首次使用,建议先认真看一遍教程。 - 首次使用,建议先认真看一遍教程。
## 注意 ## 常见问题 (FAQ)
- __XCharts3.0不完全兼容XCharts2.0版本。__ 升级`3.0`时,部分代码和配置可能需要重新调整。建议旧项目可以继续使用`XCharts2.0`,新项目推荐使用`XCharts3.0`
- __XCharts2.0只维护不加新功能。__ `2.0`只修复严重`bug`,原则上不再加新功能。
- __XCharts支持Unity 5.6及以上版本。__ 但由于版本测试有限难免疏漏,发现问题可提`Issue`
- __本仓库只包含XCharts源码不包含Demo示例部分。__ 需要查看`Demo`示例源码请到[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)仓库。也可以在浏览器查看运行效果 [在线Demo](https://xcharts-team.github.io/examples/) 。
## FAQ
- __XCharts 可以免费使用吗__ - __XCharts 可以免费使用吗__
`XCharts`使用`MIT`协议,可以免费使用。也可以订阅`VIP`享受更多增值服务 XCharts 基于 MIT 协议,核心功能完全免费。您也可以订阅 VIP 服务,享受更多高级功能和专属技术支持
- __XCharts支持代码动态添加和修改数据吗支持从`Excel`或数据库中获取数据吗?__ - __XCharts 支持代码动态添加和修改数据吗__
`XCharts`提供了各种数据操作接口,支持代码动态修改配置,添加和修改数据但数据来源需要自己解析和获取,再调用`XCharts`接口添加到图表。 是的,XCharts 提供了丰富的数据操作接口,支持代码动态修改配置数据但数据来源(如 Excel 或数据库)需要您自行解析后调用 XCharts 接口添加到图表
- __XCharts除了用在Unity平台还能用在Winform或WPF等平台__ - __XCharts 支持哪些平台__
`XCharts`只支持在`Unity`平台使用。理论上任何支持`UGUI``Unity`版本都能运行`XCharts` XCharts 专为 Unity 平台设计,支持 Unity 5.6 及以上版本。理论上任何支持 UGUI 的 Unity 版本均可运行 XCharts。目前不支持 Winform 或 WPF 等其他平台
- __锯齿怎么解决?支持多大量级的数据__ - __如何解决锯齿问题XCharts 支持多大的数据__
`XCharts`是基于`UGUI`实现的,所以`UGUI`中碰到的问题,在`XCharts`中也会存在。比如锯齿问题,比如`Mesh`顶点数`65535`的问题。这两个问题的解决可参考[问答16](Documentation~/zh/faq.md)和[问答27](Documentation~/zh/faq.md) XCharts 基于 UGUI 实现,因此 UGUI 的常见问题(如锯齿、Mesh 顶点数限制)在 XCharts 中也会存在
由于`Mesh``65535`顶点数的限制,目前`XCharts`的单条`Line`支持约`2万`的数据量当然开启采样可以支持更多数据的绘制但同时也会更消耗CPU。 - __锯齿问题__可通过调整抗锯齿设置或使用更高分辨率解决。
- __数据量限制__单条折线图Line支持约 2 万数据点,开启采样后可支持更多数据,但会消耗更多 CPU 资源。
更多解决方案请参考 [问答 16](Documentation~/zh/faq.md) 和 [问答 27](Documentation~/zh/faq.md)。
- __哪里可以查看 Demo__
本仓库仅包含 XCharts 源码Demo 示例请访问 [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) 仓库。您也可以在浏览器中查看 [在线 Demo](https://xcharts-team.github.io/examples/)。
## 日志 ## 日志
- 各版本的详细更新日志请查看 [更新日志](Documentation~/zh/changelog.md) - 各版本的详细更新日志请查看 [更新日志](Documentation~/zh/changelog.md)
## Licenses ## 扩展
- [MIT License](https://github.com/XCharts-Team/XCharts/blob/master/LICENSE.md) - __[XCharts](https://github.com/XCharts-Team/XCharts)__ 核心功能,完全开源免费
- 可免费商用,可二次开发。 - __[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)__ 守护程序确保XCharts更新时的编译正常
- 扩展图表和高级功能部分需购买使用授权。 - __[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)__ 官方示例(不包含扩展图表的示例)
- __[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)__ 专业版,包含所有扩展图表和扩展组件(需订阅 SVIP
- __[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo)__ 专业版官方示例(需订阅 SVIP
- __[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)__ 扩展UI组件需订阅 VIP
- __[XCharts-Bar3DChart](https://github.com/XCharts-Team/XCharts-Bar3DChart)__ 3D柱图需订阅 VIP
- __[XCharts-FunnelChart](https://github.com/XCharts-Team/XCharts-FunnelChart)__ 漏斗图(需订阅 VIP
- __[XCharts-GanttChart](https://github.com/XCharts-Team/XCharts-GanttChart)__ 甘特图(需订阅 VIP
- __[XCharts-GaugeChart](https://github.com/XCharts-Team/XCharts-GaugeChart)__ 仪表盘(需订阅 VIP
- __[XCharts-LiquidChart](https://github.com/XCharts-Team/XCharts-LiquidChart)__ 水位图(需订阅 VIP
- __[XCharts-PictorialBarChart](https://github.com/XCharts-Team/XCharts-PictorialBarChart)__ 象形住图(需订阅 VIP
- __[XCharts-Pie3DChart](https://github.com/XCharts-Team/XCharts-Pie3DChart)__ 3D饼图需订阅 VIP
- __[XCharts-PyramidChart](https://github.com/XCharts-Team/XCharts-PyramidChart)__ 3D金字塔需订阅 VIP
- __[XCharts-TreemapChart](https://github.com/XCharts-Team/XCharts-TreemapChart)__ 矩形树图(需订阅 VIP
- __[XCharts-SankeyChart](https://github.com/XCharts-Team/XCharts-SankeyChart)__ 桑基图(需订阅 VIP
- __[XCharts-Line3DChart](https://github.com/XCharts-Team/XCharts-Line3DChart)__ 3D折线图需订阅 VIP
- __[XCharts-GraphChart](https://github.com/XCharts-Team/XCharts-GraphChart)__ 关系图(需订阅 VIP
## 许可
- __[MIT License](https://github.com/XCharts-Team/XCharts/blob/master/LICENSE.md)__XCharts 核心库基于 MIT 协议,允许免费商用和二次开发。
- __扩展功能授权__扩展图表和高级功能需订阅 VIP 或 SVIP 服务获得使用许可。
## 订阅 ## 订阅
- `XCharts`核心库开源,可免费使用的。在此基础上,我们也提供多种订阅服务以满足不同用户的需求,订阅详情[☞ 请看这里](Documentation~/zh/support.md) - __核心功能免费__XCharts 核心库基于 MIT 协议完全开源,可免费使用。
- 订阅不是必须的,不影响`XCharts`的核心功能使用 - __增值服务__为满足多样化需求我们提供多种订阅服务详情请查看 [订阅详情](Documentation~/zh/support.md)
- 订阅是按年付费,订阅到期后,不要求必须续订,但中断订阅期间无法享受技术更新和支持等服务 - __灵活选择__订阅非强制不影响核心功能使用
- __按年付费__订阅服务按年计费到期后可选择续订。中断订阅后将无法享受更新和技术支持服务。
## 其他 ## 其他
- 邮箱:`monitor1394@gmail.com` - 邮箱:`monitor1394@gmail.com`
- QQ群XCharts交流群`202030963` - QQ群XCharts交流群`202030963`
- VIP群XCharts VIP群`867291970` - VIP群XCharts VIP群`867291970`
- 捐助、合作、订阅和技术支持:[☞ 请看这里](Documentation~/zh/support.md) - 支持与合作:[订阅与支持](Documentation~/zh/support.md)

View File

@@ -16,6 +16,7 @@ namespace XCharts.Runtime
[SerializeField][Since("v3.8.0")] private bool m_Reverse = false; [SerializeField][Since("v3.8.0")] private bool m_Reverse = false;
[SerializeField][Since("v3.8.0")] private float m_Delay = 0; [SerializeField][Since("v3.8.0")] private float m_Delay = 0;
[SerializeField][Since("v3.8.0")] private float m_Duration = 1000; [SerializeField][Since("v3.8.0")] private float m_Duration = 1000;
[SerializeField][Since("v3.14.0")] private float m_Speed = 0;
public AnimationInfoContext context = new AnimationInfoContext(); public AnimationInfoContext context = new AnimationInfoContext();
/// <summary> /// <summary>
@@ -34,11 +35,15 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public float delay { get { return m_Delay; } set { m_Delay = value; } } public float delay { get { return m_Delay; } set { m_Delay = value; } }
/// <summary> /// <summary>
/// the duration of animation. /// the duration of animation. Default is used to calculate the speed of animation. It can also be specified by speed.
/// ||动画的时长。 /// ||动画的时长。默认用于计算动画的速度。也可以通过speed指定速度。
/// </summary> /// </summary>
public float duration { get { return m_Duration; } set { m_Duration = value; } } public float duration { get { return m_Duration; } set { m_Duration = value; } }
/// <summary>
/// the speed of animation. When speed is specified, duration will be invalid. Default is 0, which means no speed specified.
/// ||动画的速度。当指定speed时duration将失效。默认为0表示不指定速度。
/// </summary>
public float speed { get { return m_Speed; } set { m_Speed = value; } }
/// <summary> /// <summary>
/// the callback function of animation start. /// the callback function of animation start.
/// ||动画开始的回调。 /// ||动画开始的回调。
@@ -147,6 +152,7 @@ namespace XCharts.Runtime
{ {
if (!enable) return; if (!enable) return;
if (!context.start || context.end) return; if (!context.start || context.end) return;
context.init = false;
context.start = false; context.start = false;
context.end = true; context.end = true;
context.currPointIndex = context.destPointIndex; context.currPointIndex = context.destPointIndex;
@@ -168,20 +174,19 @@ namespace XCharts.Runtime
public bool Init(float curr, float dest, int totalPointIndex) public bool Init(float curr, float dest, int totalPointIndex)
{ {
if (!enable || !context.start) return false; if (!enable || !context.start) return false;
if (context.init || context.end) return false;
context.init = true;
context.totalProgress = dest - curr; context.totalProgress = dest - curr;
context.destPointIndex = totalPointIndex; context.destPointIndex = totalPointIndex;
if (reverse) if (reverse)
{ {
context.currProgress = dest; if (!context.init) context.currProgress = dest;
context.destProgress = curr; context.destProgress = curr;
} }
else else
{ {
context.currProgress = curr; if (!context.init) context.currProgress = curr;
context.destProgress = dest; context.destProgress = dest;
} }
context.init = true;
return true; return true;
} }
@@ -208,7 +213,7 @@ namespace XCharts.Runtime
if (!context.start) if (!context.start)
return false; return false;
else else
return (m_Delay > 0 && Time.time - context.startTime < m_Delay / 1000); return m_Delay > 0 && Time.time - context.startTime < m_Delay / 1000;
} }
/// <summary> /// <summary>
@@ -285,8 +290,7 @@ namespace XCharts.Runtime
{ {
if (!context.start || !context.init || context.pause) return; if (!context.start || !context.init || context.pause) return;
if (IsInDelay()) return; if (IsInDelay()) return;
var duration = GetCurrAnimationDuration(); var delta = GetDelta(total, m_UnscaledTime);
var delta = (float)(total / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
if (reverse) if (reverse)
{ {
context.currProgress -= delta; context.currProgress -= delta;
@@ -330,8 +334,7 @@ namespace XCharts.Runtime
} }
else else
{ {
var duration = GetCurrAnimationDuration(dataIndex); var delta = GetDelta(destProgress - startProgress, m_UnscaledTime);
var delta = (destProgress - startProgress) / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
currHig += delta; currHig += delta;
if (reverse) if (reverse)
{ {
@@ -362,8 +365,7 @@ namespace XCharts.Runtime
if (IsInDelay()) if (IsInDelay())
return; return;
var duration = GetCurrAnimationDuration(); var delta = GetDelta(dest, m_UnscaledTime);
var delta = dest / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
if (reverse) if (reverse)
{ {
context.sizeProgress -= delta; context.sizeProgress -= delta;
@@ -377,6 +379,20 @@ namespace XCharts.Runtime
context.sizeProgress = dest; context.sizeProgress = dest;
} }
} }
private float GetDelta(double total, bool unscaledTime)
{
if (m_Speed > 0)
{
context.currDuration = (float)total / m_Speed;
return (float)(m_Speed * (unscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
}
else
{
context.currDuration = 0;
return (float)(total / GetCurrAnimationDuration() * (unscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
}
}
} }
/// <summary> /// <summary>

View File

@@ -17,6 +17,7 @@ namespace XCharts.Runtime
public float sizeProgress; public float sizeProgress;
public int currPointIndex; public int currPointIndex;
public int destPointIndex; public int destPointIndex;
public float currDuration;
public Vector3 currPoint; public Vector3 currPoint;
public Vector3 destPoint; public Vector3 destPoint;
public Dictionary<int, float> dataCurrProgress = new Dictionary<int, float>(); public Dictionary<int, float> dataCurrProgress = new Dictionary<int, float>();

View File

@@ -306,7 +306,7 @@ namespace XCharts.Runtime
startIndex = anim.context.currPointIndex == paths.Count - 1 ? startIndex = anim.context.currPointIndex == paths.Count - 1 ?
paths.Count - 2 : paths.Count - 2 :
anim.context.currPointIndex; anim.context.currPointIndex;
if (startIndex < 0 || startIndex > paths.Count - 2) startIndex = 0; if (startIndex < 0 || startIndex >= paths.Count - 1) return;
} }
else else
{ {
@@ -336,9 +336,12 @@ namespace XCharts.Runtime
{ {
return; return;
} }
if (anim.Init(currDetailProgress, totalDetailProgress, paths.Count - 1))
{
anim.context.currPoint = sp; anim.context.currPoint = sp;
anim.context.destPoint = ep; anim.context.destPoint = ep;
anim.Init(currDetailProgress, totalDetailProgress, paths.Count - 1); }
} }
public bool IsEnd() public bool IsEnd()
@@ -362,12 +365,23 @@ namespace XCharts.Runtime
return true; return true;
var animation = activedAnimation; var animation = activedAnimation;
if (animation != null && animation.context.end) if (animation != null && animation.context.end)
{
return true; return true;
}
if (IsSerieAnimation()) if (IsSerieAnimation())
{ {
if (m_FadeOut.context.start) return m_FadeOut.context.currProgress <= m_FadeOut.context.destProgress; if (m_FadeOut.context.start)
else if (m_Addition.context.start) return m_Addition.context.currProgress >= m_Addition.context.destProgress; {
else return m_FadeIn.context.currProgress >= m_FadeIn.context.destProgress; return m_FadeOut.context.currProgress <= m_FadeOut.context.destProgress;
}
else if (m_Addition.context.start)
{
return m_Addition.context.currProgress >= m_Addition.context.destProgress;
}
else
{
return m_FadeIn.context.currProgress >= m_FadeIn.context.destProgress;
}
} }
else if (IsDataAnimation()) else if (IsDataAnimation())
{ {
@@ -546,7 +560,7 @@ namespace XCharts.Runtime
public float GetChangeDuration() public float GetChangeDuration()
{ {
if (m_Enable && m_Change.enable) if (m_Enable && m_Change.enable)
return m_Change.duration; return m_Change.context.currDuration > 0 ? m_Change.context.currDuration : m_Change.duration;
else else
return 0; return 0;
} }
@@ -554,7 +568,7 @@ namespace XCharts.Runtime
public float GetAdditionDuration() public float GetAdditionDuration()
{ {
if (m_Enable && m_Addition.enable) if (m_Enable && m_Addition.enable)
return m_Addition.duration; return m_Addition.context.currDuration > 0 ? m_Addition.context.currDuration : m_Addition.duration;
else else
return 0; return 0;
} }
@@ -562,7 +576,7 @@ namespace XCharts.Runtime
public float GetInteractionDuration() public float GetInteractionDuration()
{ {
if (m_Enable && m_Interaction.enable) if (m_Enable && m_Interaction.enable)
return m_Interaction.duration; return m_Interaction.context.currDuration > 0 ? m_Interaction.context.currDuration : m_Interaction.duration;
else else
return 0; return 0;
} }

View File

@@ -53,7 +53,7 @@ namespace XCharts.Runtime
if (axis.context.labelObjectList.Count <= 0) if (axis.context.labelObjectList.Count <= 0)
InitAngleAxis(axis); InitAngleAxis(axis);
else else
axis.UpdateLabelText(runtimeWidth, null, false); UpdateLabelText(axis, runtimeWidth, null, false);
} }
private void InitAngleAxis(AngleAxis axis) private void InitAngleAxis(AngleAxis axis)
@@ -67,7 +67,7 @@ namespace XCharts.Runtime
string objName = component.GetType().Name + axis.index; string objName = component.GetType().Name + axis.index;
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.transform.localPosition = Vector3.zero; axisObj.transform.localPosition = Vector3.zero;
axisObj.SetActive(axis.show); axisObj.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags; axisObj.hideFlags = chart.chartHideFlags;

View File

@@ -836,22 +836,6 @@ namespace XCharts.Runtime
return IsCategory() ? GetDataList(dataZoom).Count : 0; return IsCategory() ? GetDataList(dataZoom).Count : 0;
} }
/// <summary>
/// 更新刻度标签文字
/// </summary>
/// <param name="dataZoom"></param>
internal void UpdateLabelText(float coordinateWidth, DataZoom dataZoom, bool forcePercent)
{
for (int i = 0; i < context.labelObjectList.Count; i++)
{
if (context.labelObjectList[i] != null)
{
var text = AxisHelper.GetLabelName(this, coordinateWidth, i, context.destMinValue, context.destMaxValue, dataZoom, forcePercent);
context.labelObjectList[i].SetText(text);
}
}
}
internal Vector3 GetLabelObjectPosition(int index) internal Vector3 GetLabelObjectPosition(int index)
{ {
if (context.labelObjectList != null && index < context.labelObjectList.Count) if (context.labelObjectList != null && index < context.labelObjectList.Count)

View File

@@ -69,6 +69,7 @@ namespace XCharts.Runtime
public List<string> runtimeData { get { return m_RuntimeData; } } public List<string> runtimeData { get { return m_RuntimeData; } }
public List<double> labelValueList { get { return m_LabelValueList; } } public List<double> labelValueList { get { return m_LabelValueList; } }
public List<ChartLabel> labelObjectList { get { return m_AxisLabelList; } } public List<ChartLabel> labelObjectList { get { return m_AxisLabelList; } }
public List<int> sortedDataIndices { get { return m_SortedDataIndices; } }
public int dataZoomStartIndex; public int dataZoomStartIndex;
/// <summary> /// <summary>
/// 添加过的历史数据总数 /// 添加过的历史数据总数
@@ -86,6 +87,7 @@ namespace XCharts.Runtime
private List<ChartLabel> m_AxisLabelList = new List<ChartLabel>(); private List<ChartLabel> m_AxisLabelList = new List<ChartLabel>();
private List<double> m_LabelValueList = new List<double>(); private List<double> m_LabelValueList = new List<double>();
private List<string> m_RuntimeData = new List<string>(); private List<string> m_RuntimeData = new List<string>();
private List<int> m_SortedDataIndices = new List<int>();
internal void Clear() internal void Clear()
{ {

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using XCharts.Runtime; using XCharts.Runtime;
@@ -149,6 +150,10 @@ namespace XCharts
axis.context.minValue = 0; axis.context.minValue = 0;
axis.context.maxValue = axis.data.Count > 0 ? axis.data.Count - 1 : SeriesHelper.GetMaxSerieDataCount(chart.series) - 1; axis.context.maxValue = axis.data.Count > 0 ? axis.data.Count - 1 : SeriesHelper.GetMaxSerieDataCount(chart.series) - 1;
axis.context.minMaxRange = axis.context.maxValue; axis.context.minMaxRange = axis.context.maxValue;
if (chart.HasRealtimeSortSerie(axis.gridIndex))
{
UpdateAxisLabelText(axis);
}
return; return;
} }
@@ -236,7 +241,64 @@ namespace XCharts
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series); var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
var dataZoom = chart.GetDataZoomOfAxis(axis); var dataZoom = chart.GetDataZoomOfAxis(axis);
axis.UpdateLabelText(runtimeWidth, dataZoom, isPercentStack); UpdateLabelText(axis, runtimeWidth, dataZoom, isPercentStack);
}
internal void UpdateLabelText(Axis axis, float coordinateWidth, DataZoom dataZoom, bool forcePercent)
{
var context = axis.context;
var destMaxValue = context.destMaxValue;
var destMinValue = context.destMinValue;
var isCategory = axis.IsCategory();
var serie = chart.GetSerie(0);
if (isCategory && serie != null && serie.useSortData)
{
var showData = serie.GetDataList(dataZoom, true);
var isChanged = CheckSortedDataChanged(axis, showData);
if (isChanged)
{
for (int i = 0; i < context.labelObjectList.Count; i++)
{
if (context.labelObjectList[i] != null)
{
var index = i < showData.Count ? showData[i].index : i;
var text = AxisHelper.GetLabelName(axis, coordinateWidth, index, destMinValue, destMaxValue, dataZoom, forcePercent, i);
context.labelObjectList[i].SetText(text);
}
}
SaveSortedDataIndex(axis, showData);
}
}
else
{
for (int i = 0; i < context.labelObjectList.Count; i++)
{
if (context.labelObjectList[i] != null)
{
var text = AxisHelper.GetLabelName(axis, coordinateWidth, i, destMinValue, destMaxValue, dataZoom, forcePercent);
context.labelObjectList[i].SetText(text);
}
}
}
}
private bool CheckSortedDataChanged(Axis axis, List<SerieData> dataList)
{
if (dataList.Count != axis.context.sortedDataIndices.Count) return true;
for (int i = 0; i < dataList.Count; i++)
{
if (dataList[i].index != axis.context.sortedDataIndices[i]) return true;
}
return false;
}
private void SaveSortedDataIndex(Axis axis, List<SerieData> dataList)
{
axis.context.sortedDataIndices.Clear();
for (int i = 0; i < dataList.Count; i++)
{
axis.context.sortedDataIndices.Add(dataList[i].index);
}
} }
internal void UpdateAxisTickValueList(Axis axis) internal void UpdateAxisTickValueList(Axis axis)
@@ -372,6 +434,7 @@ namespace XCharts
var axisLength = (axis.context.end - axis.context.start).magnitude; var axisLength = (axis.context.end - axis.context.start).magnitude;
if (axisLength == 0) return; if (axisLength == 0) return;
chart.InitAxisRuntimeData(axis); chart.InitAxisRuntimeData(axis);
UpdateAxisMinMaxValue(axis.index, axis, true);
var objName = ChartCached.GetComponentObjectName(axis); var objName = ChartCached.GetComponentObjectName(axis);
var axisObj = ChartHelper.AddObject(objName, var axisObj = ChartHelper.AddObject(objName,
@@ -379,7 +442,7 @@ namespace XCharts
chart.chartMinAnchor, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartMaxAnchor,
chart.chartPivot, chart.chartPivot,
chart.chartSizeDelta); chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.SetActive(axis.show); axisObj.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags; axisObj.hideFlags = chart.chartHideFlags;
@@ -415,13 +478,21 @@ namespace XCharts
if (axis.IsCategory() && axis.boundaryGap) if (axis.IsCategory() && axis.boundaryGap)
splitNumber -= 1; splitNumber -= 1;
axis.context.aligment = defaultAlignment; axis.context.aligment = defaultAlignment;
var sortSerie = chart.GetRealtimeSortSerie(axis.gridIndex);
if (sortSerie != null)
{
SerieHelper.UpdateSerieRuntimeFilterData(sortSerie);
}
var showData = sortSerie != null ? sortSerie.GetDataList(dataZoom, true) : null;
for (int i = 0; i < splitNumber; i++) for (int i = 0; i < splitNumber; i++)
{ {
var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom); var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
var labelName = AxisHelper.GetLabelName(axis, axisLength, i, var sortIndex = sortSerie != null ? (i < showData.Count ? showData[i].index : i) : i;
var labelName = AxisHelper.GetLabelName(axis, axisLength, sortIndex,
axis.context.destMinValue, axis.context.destMinValue,
axis.context.destMaxValue, axis.context.destMaxValue,
dataZoom, isPercentStack); dataZoom, isPercentStack, i);
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, var label = ChartHelper.AddAxisLabelObject(splitNumber, i,
ChartCached.GetAxisLabelName(i), ChartCached.GetAxisLabelName(i),
@@ -473,7 +544,6 @@ namespace XCharts
break; break;
} }
} }
UpdateAxisMinMaxValue(axis.index, axis, true);
} }
protected void InitAxis(Axis relativedAxis, Orient orient, protected void InitAxis(Axis relativedAxis, Orient orient,
@@ -481,6 +551,7 @@ namespace XCharts
{ {
Axis axis = component; Axis axis = component;
chart.InitAxisRuntimeData(axis); chart.InitAxisRuntimeData(axis);
UpdateAxisMinMaxValue(axis.index, axis, true);
var objName = ChartCached.GetComponentObjectName(axis); var objName = ChartCached.GetComponentObjectName(axis);
var axisObj = ChartHelper.AddObject(objName, var axisObj = ChartHelper.AddObject(objName,
@@ -488,7 +559,7 @@ namespace XCharts
chart.chartMinAnchor, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartMaxAnchor,
chart.chartPivot, chart.chartPivot,
chart.chartSizeDelta); chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.SetActive(axis.show); axisObj.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags; axisObj.hideFlags = chart.chartHideFlags;
@@ -527,13 +598,20 @@ namespace XCharts
if (axis.IsCategory() && axis.boundaryGap) if (axis.IsCategory() && axis.boundaryGap)
splitNumber -= 1; splitNumber -= 1;
axis.context.aligment = defaultAlignment; axis.context.aligment = defaultAlignment;
var sortSerie = chart.GetRealtimeSortSerie(axis.gridIndex);
if (sortSerie != null)
{
SerieHelper.UpdateSerieRuntimeFilterData(sortSerie);
}
var showData = sortSerie != null ? sortSerie.GetDataList(dataZoom, true) : null;
for (int i = 0; i < splitNumber; i++) for (int i = 0; i < splitNumber; i++)
{ {
var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom); var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
var labelName = AxisHelper.GetLabelName(axis, axisLength, i, var sortIndex = sortSerie != null ? (i < showData.Count ? showData[i].index : i) : i;
var labelName = AxisHelper.GetLabelName(axis, axisLength, sortIndex,
axis.context.destMinValue, axis.context.destMinValue,
axis.context.destMaxValue, axis.context.destMaxValue,
dataZoom, isPercentStack); dataZoom, isPercentStack, i);
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, var label = ChartHelper.AddAxisLabelObject(splitNumber, i,
ChartCached.GetAxisLabelName(i), ChartCached.GetAxisLabelName(i),
@@ -557,8 +635,8 @@ namespace XCharts
} }
if (axis.axisName.show) if (axis.axisName.show)
{ {
ChartLabel label = null; ChartLabel label;
var relativedDist = (relativedAxis == null ? 0 : relativedAxis.context.offset); var relativedDist = relativedAxis == null ? 0 : relativedAxis.context.offset;
var zeroPos = new Vector3(axisStartX, axisStartY + relativedDist); var zeroPos = new Vector3(axisStartX, axisStartY + relativedDist);
var offset = axis.axisName.labelStyle.offset; var offset = axis.axisName.labelStyle.offset;
var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor); var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor);
@@ -637,7 +715,6 @@ namespace XCharts
} }
} }
} }
UpdateAxisMinMaxValue(axis.index, axis, true);
} }
internal static Vector3 GetLabelPosition(int i, Orient orient, Axis axis, Axis relativedAxis, AxisTheme theme, internal static Vector3 GetLabelPosition(int i, Orient orient, Axis axis, Axis relativedAxis, AxisTheme theme,

View File

@@ -116,9 +116,10 @@ namespace XCharts.Runtime
/// <param name="dataZoom"></param> /// <param name="dataZoom"></param>
/// <returns></returns> /// <returns></returns>
public static string GetLabelName(Axis axis, float coordinateWidth, int index, double minValue, double maxValue, public static string GetLabelName(Axis axis, float coordinateWidth, int index, double minValue, double maxValue,
DataZoom dataZoom, bool forcePercent) DataZoom dataZoom, bool forcePercent, int sortIndex = -1)
{ {
int split = GetSplitNumber(axis, coordinateWidth, dataZoom); int split = GetSplitNumber(axis, coordinateWidth, dataZoom);
if (sortIndex == -1) sortIndex = index;
if (axis.type == Axis.AxisType.Value) if (axis.type == Axis.AxisType.Value)
{ {
if (minValue == 0 && maxValue == 0) if (minValue == 0 && maxValue == 0)
@@ -137,7 +138,7 @@ namespace XCharts.Runtime
if (forcePercent) if (forcePercent)
return string.Format("{0}%", (int)value); return string.Format("{0}%", (int)value);
else else
return axis.axisLabel.GetFormatterContent(index, value, minValue, maxValue); return axis.axisLabel.GetFormatterContent(sortIndex, axis.context.labelValueList.Count, value, minValue, maxValue);
} }
else if (axis.type == Axis.AxisType.Log) else if (axis.type == Axis.AxisType.Log)
{ {
@@ -150,7 +151,7 @@ namespace XCharts.Runtime
minValue = -minValue; minValue = -minValue;
maxValue = -maxValue; maxValue = -maxValue;
} }
return axis.axisLabel.GetFormatterContent(index, value, minValue, maxValue, true); return axis.axisLabel.GetFormatterContent(sortIndex, 0, value, minValue, maxValue, true);
} }
else if (axis.type == Axis.AxisType.Time) else if (axis.type == Axis.AxisType.Time)
{ {
@@ -160,7 +161,7 @@ namespace XCharts.Runtime
return string.Empty; return string.Empty;
var value = axis.GetLabelValue(index); var value = axis.GetLabelValue(index);
return axis.axisLabel.GetFormatterDateTime(index, value, minValue, maxValue); return axis.axisLabel.GetFormatterDateTime(sortIndex, axis.context.labelValueList.Count, value, minValue, maxValue);
} }
var showData = axis.GetDataList(dataZoom); var showData = axis.GetDataList(dataZoom);
int dataCount = showData.Count; int dataCount = showData.Count;
@@ -172,18 +173,18 @@ namespace XCharts.Runtime
{ {
if (index > 0) if (index > 0)
{ {
var residue = (dataCount - 1) - split * rate; var residue = dataCount - 1 - split * rate;
var newIndex = residue + (index - 1) * rate; var newIndex = residue + (index - 1) * rate;
if (newIndex < 0) if (newIndex < 0)
newIndex = 0; newIndex = 0;
return axis.axisLabel.GetFormatterContent(newIndex, showData[newIndex]); return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[newIndex]);
} }
else else
{ {
if (axis.boundaryGap && coordinateWidth / dataCount > 5) if (axis.boundaryGap && coordinateWidth / dataCount > 5)
return string.Empty; return string.Empty;
else else
return axis.axisLabel.GetFormatterContent(0, showData[0]); return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[0]);
} }
} }
else else
@@ -191,7 +192,7 @@ namespace XCharts.Runtime
int newIndex = index * rate; int newIndex = index * rate;
if (newIndex < dataCount) if (newIndex < dataCount)
{ {
return axis.axisLabel.GetFormatterContent(newIndex, showData[newIndex]); return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[newIndex]);
} }
else else
{ {
@@ -199,7 +200,7 @@ namespace XCharts.Runtime
if (axis.boundaryGap && ((diff > 0 && diff / rate < 0.4f) || dataCount >= axis.data.Count)) if (axis.boundaryGap && ((diff > 0 && diff / rate < 0.4f) || dataCount >= axis.data.Count))
return string.Empty; return string.Empty;
else else
return axis.axisLabel.GetFormatterContent(dataCount - 1, showData[dataCount - 1]); return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[dataCount - 1]);
} }
} }
} }

View File

@@ -145,7 +145,7 @@ namespace XCharts.Runtime
m_TextLimit.SetRelatedText(txt, labelWidth); m_TextLimit.SetRelatedText(txt, labelWidth);
} }
public override string GetFormatterContent(int labelIndex, string category) public override string GetFormatterContent(int labelIndex, int totalIndex, string category)
{ {
if (string.IsNullOrEmpty(category)) if (string.IsNullOrEmpty(category))
return GetFormatterFunctionContent(labelIndex, category, category); return GetFormatterFunctionContent(labelIndex, category, category);
@@ -157,18 +157,18 @@ namespace XCharts.Runtime
else else
{ {
var content = m_Formatter; var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, category); FormatterHelper.ReplaceAxisLabelContent(ref content, category, labelIndex, totalIndex);
return GetFormatterFunctionContent(labelIndex, category, m_TextLimit.GetLimitContent(content)); return GetFormatterFunctionContent(labelIndex, category, m_TextLimit.GetLimitContent(content));
} }
} }
public override string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false) public override string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
{ {
if (showAsPositiveNumber && value < 0) if (showAsPositiveNumber && value < 0)
{ {
value = Math.Abs(value); value = Math.Abs(value);
} }
return base.GetFormatterContent(labelIndex, value, minValue, maxValue, isLog); return base.GetFormatterContent(labelIndex, totalIndex, value, minValue, maxValue, isLog);
} }
public bool IsNeedShowLabel(int index, int total) public bool IsNeedShowLabel(int index, int total)

View File

@@ -80,7 +80,7 @@ namespace XCharts.Runtime
InitRadiusAxis(axis); InitRadiusAxis(axis);
else else
{ {
axis.UpdateLabelText(polar.context.radius, null, false); UpdateLabelText(axis, polar.context.radius, null, false);
} }
} }
@@ -99,7 +99,7 @@ namespace XCharts.Runtime
var radius = polar.context.outsideRadius - polar.context.insideRadius; var radius = polar.context.outsideRadius - polar.context.insideRadius;
var objName = component.GetType().Name + axis.index; var objName = component.GetType().Name + axis.index;
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.transform.localPosition = Vector3.zero; axisObj.transform.localPosition = Vector3.zero;
axisObj.SetActive(axis.show && axis.axisLabel.show); axisObj.SetActive(axis.show && axis.axisLabel.show);
axisObj.hideFlags = chart.chartHideFlags; axisObj.hideFlags = chart.chartHideFlags;

View File

@@ -100,6 +100,12 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetClass(ref m_BorderStyle, value)) SetComponentDirty(); } set { if (PropertyUtil.SetClass(ref m_BorderStyle, value)) SetComponentDirty(); }
} }
/// <summary>
/// the rect of background.
/// ||背景的矩形区域。
/// </summary>
public Rect rect { get; set; }
public override void SetDefaultValue() public override void SetDefaultValue()
{ {
m_Show = true; m_Show = true;

View File

@@ -15,7 +15,7 @@ namespace XCharts.Runtime
component.refreshComponent = delegate () component.refreshComponent = delegate ()
{ {
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor, var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
component.gameObject = backgroundObj; component.gameObject = backgroundObj;
backgroundObj.hideFlags = chart.chartHideFlags; backgroundObj.hideFlags = chart.chartHideFlags;

View File

@@ -82,5 +82,11 @@ namespace XCharts.Runtime
{ {
return m_Show && roundedCorner ? m_CornerRadius : null; return m_Show && roundedCorner ? m_CornerRadius : null;
} }
public bool IsCricle()
{
return roundedCorner && m_CornerRadius[0] == 1 && m_CornerRadius[1] == 1 &&
m_CornerRadius[2] == 1 && m_CornerRadius[3] == 1;
}
} }
} }

View File

@@ -349,6 +349,69 @@ namespace XCharts.Runtime
} }
} }
public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight)
{
UpdateRuntimeData(graphWidth, graphWidth);
float x, y, width, height;
width = rectWidth == 0 ? graphWidth - runtimeLeft - runtimeRight : rectWidth;
height = rectHeight == 0 ? graphHeight - runtimeBottom - runtimeTop : rectHeight;
switch (align)
{
case Align.BottomCenter:
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
y = graphY + runtimeBottom;
break;
case Align.BottomLeft:
x = graphX + runtimeLeft;
y = graphY + runtimeBottom;
break;
case Align.BottomRight:
x = graphX + graphWidth - runtimeRight - width;
y = graphY + runtimeBottom;
break;
case Align.Center:
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
break;
case Align.CenterLeft:
x = graphX + runtimeLeft;
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
break;
case Align.CenterRight:
x = graphX + graphWidth - runtimeRight - width;
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
break;
case Align.TopCenter:
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
y = graphY + graphHeight - runtimeTop - height;
break;
case Align.TopLeft:
x = graphX + runtimeLeft;
y = graphY + graphHeight - runtimeTop - height;
break;
case Align.TopRight:
x = graphX + graphWidth - runtimeRight - width;
y = graphY + graphHeight - runtimeTop - height;
break;
default:
return new Rect(0, 0, 0, 0);
}
return new Rect(x, y, width, height);
}
/// <summary> /// <summary>
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot /// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
/// </summary> /// </summary>

View File

@@ -152,18 +152,16 @@ namespace XCharts.Runtime
/// <summary> /// <summary>
/// 根据指定的sizeType获得标记的大小 /// 根据指定的sizeType获得标记的大小
/// </summary> /// </summary>
/// <param name="data"></param> public float GetSize(SerieData serieData, float themeSize)
/// <returns></returns>
public float GetSize(List<double> data, float themeSize)
{ {
switch (m_SizeType) switch (m_SizeType)
{ {
case SymbolSizeType.Custom: case SymbolSizeType.Custom:
return size == 0 ? themeSize : size; return size == 0 ? themeSize : size;
case SymbolSizeType.FromData: case SymbolSizeType.FromData:
if (data != null && dataIndex >= 0 && dataIndex < data.Count) if (serieData != null && dataIndex >= 0 && dataIndex < serieData.data.Count)
{ {
var value = (float) data[dataIndex] * m_DataScale; var value = (float) serieData.data[dataIndex] * m_DataScale;
if (m_MinSize != 0 && value < m_MinSize) value = m_MinSize; if (m_MinSize != 0 && value < m_MinSize) value = m_MinSize;
if (m_MaxSize != 0 && value > m_MaxSize) value = m_MaxSize; if (m_MaxSize != 0 && value > m_MaxSize) value = m_MaxSize;
return value; return value;
@@ -173,7 +171,7 @@ namespace XCharts.Runtime
return size == 0 ? themeSize : size; return size == 0 ? themeSize : size;
} }
case SymbolSizeType.Function: case SymbolSizeType.Function:
if (data != null && sizeFunction != null) return sizeFunction(data); if (sizeFunction != null) return sizeFunction(themeSize, serieData);
else return size == 0 ? themeSize : size; else return size == 0 ? themeSize : size;
default: default:
return size == 0 ? themeSize : size; return size == 0 ? themeSize : size;

View File

@@ -84,12 +84,16 @@ namespace XCharts.Runtime
[SerializeField] protected Sprite m_Image; [SerializeField] protected Sprite m_Image;
[SerializeField] protected Image.Type m_ImageType; [SerializeField] protected Image.Type m_ImageType;
[SerializeField] protected Color32 m_Color; [SerializeField] protected Color32 m_Color;
[SerializeField][Since("v3.13.0")] protected float m_BorderWidth = 0f;
[SerializeField][Since("v3.13.0")] protected Color32 m_EmptyColor;
[SerializeField][Since("v3.13.0")] protected float m_Size2 = 0f;
public virtual void Reset() public virtual void Reset()
{ {
m_Show = false; m_Show = false;
m_Type = SymbolType.EmptyCircle; m_Type = SymbolType.EmptyCircle;
m_Size = 0f; m_Size = 0f;
m_Size2 = 0f;
m_Gap = 0; m_Gap = 0;
m_Width = 0f; m_Width = 0f;
m_Height = 0f; m_Height = 0f;
@@ -126,6 +130,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); } set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
} }
/// <summary> /// <summary>
/// the size of symbol.
/// ||标记的大小。当为Rect时size2表示高度。
/// </summary>
public float size2
{
get { return m_Size2; }
set { if (PropertyUtil.SetStruct(ref m_Size2, value)) SetVerticesDirty(); }
}
/// <summary>
/// the gap of symbol and line segment. /// the gap of symbol and line segment.
/// ||图形标记和线条的间隙距离。 /// ||图形标记和线条的间隙距离。
/// </summary> /// </summary>
@@ -183,6 +196,24 @@ namespace XCharts.Runtime
get { return m_Color; } get { return m_Color; }
set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); } set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); }
} }
/// <summary>
/// the border width of symbol.
/// ||图形的边框宽度。
/// </summary>
public float borderWidth
{
get { return m_BorderWidth; }
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetAllDirty(); }
}
/// <summary>
/// the color of empty symbol.
/// ||空心图形的颜色。
/// </summary>
public Color32 emptyColor
{
get { return m_EmptyColor; }
set { if (PropertyUtil.SetStruct(ref m_EmptyColor, value)) SetAllDirty(); }
}
public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } } public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 }; private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
/// <summary> /// <summary>

View File

@@ -27,7 +27,6 @@ namespace XCharts.Runtime
#if dUI_TextMeshPro #if dUI_TextMeshPro
[SerializeField] private TMP_FontAsset m_TMPFont; [SerializeField] private TMP_FontAsset m_TMPFont;
[SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal; [SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal;
[SerializeField] private TextAlignmentOptions m_TMPAlignment = TextAlignmentOptions.Left;
[SerializeField][Since("v3.1.0")] private TMP_SpriteAsset m_TMPSpriteAsset; [SerializeField][Since("v3.1.0")] private TMP_SpriteAsset m_TMPSpriteAsset;
#endif #endif
public bool show public bool show
@@ -147,15 +146,6 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); } set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); }
} }
/// <summary> /// <summary>
/// the text alignment of TextMeshPro.
/// ||TextMeshPro字体对齐方式。
/// </summary>
public TextAlignmentOptions tmpAlignment
{
get { return m_TMPAlignment; }
set { if (PropertyUtil.SetStruct(ref m_TMPAlignment, value)) SetComponentDirty(); }
}
/// <summary>
/// the sprite asset of TextMeshPro. /// the sprite asset of TextMeshPro.
/// ||TextMeshPro的Sprite Asset。 /// ||TextMeshPro的Sprite Asset。
/// </summary> /// </summary>
@@ -214,11 +204,7 @@ namespace XCharts.Runtime
public void UpdateAlignmentByLocation(Location location) public void UpdateAlignmentByLocation(Location location)
{ {
#if dUI_TextMeshPro
m_TMPAlignment = location.runtimeTMPTextAlignment;
#else
m_Alignment = location.runtimeTextAlignment; m_Alignment = location.runtimeTextAlignment;
#endif
} }
public Color GetColor(Color defaultColor) public Color GetColor(Color defaultColor)

View File

@@ -22,7 +22,7 @@ namespace XCharts.Runtime
chart.chartMinAnchor, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartMaxAnchor,
chart.chartPivot, chart.chartPivot,
chart.chartSizeDelta); chart.chartSizeDelta, -1, chart.childrenNodeNames);
commentObj.SetActive(comment.show); commentObj.SetActive(comment.show);
commentObj.hideFlags = chart.chartHideFlags; commentObj.hideFlags = chart.chartHideFlags;
@@ -37,6 +37,7 @@ namespace XCharts.Runtime
label.SetActive(comment.show && item.show, true); label.SetActive(comment.show && item.show, true);
label.SetPosition(labelPos); label.SetPosition(labelPos);
label.text.SetLocalPosition(labelStyle.offset); label.text.SetLocalPosition(labelStyle.offset);
item.labelObject = label;
} }
}; };
comment.refreshComponent(); comment.refreshComponent();

View File

@@ -17,6 +17,8 @@ namespace XCharts.Runtime
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle() { show = false }; [SerializeField] private LabelStyle m_LabelStyle = new LabelStyle() { show = false };
[SerializeField][Since("v3.5.0")] private Location m_Location = new Location() { align = Location.Align.TopLeft, top = 0.125f }; [SerializeField][Since("v3.5.0")] private Location m_Location = new Location() { align = Location.Align.TopLeft, top = 0.125f };
public ChartLabel labelObject { get; set; }
/// <summary> /// <summary>
/// Set this to false to prevent this comment item from showing. /// Set this to false to prevent this comment item from showing.
@@ -27,7 +29,18 @@ namespace XCharts.Runtime
/// content of comment. /// content of comment.
/// ||注解的文本内容。支持模板参数可以参考Tooltip的itemFormatter。 /// ||注解的文本内容。支持模板参数可以参考Tooltip的itemFormatter。
/// </summary> /// </summary>
public string content { get { return m_Content; } set { if (PropertyUtil.SetClass(ref m_Content, value)) SetComponentDirty(); } } public string content
{
get { return m_Content; }
set
{
if (PropertyUtil.SetClass(ref m_Content, value))
{
if (labelObject != null) labelObject.SetText(value);
else SetComponentDirty();
}
}
}
/// <summary> /// <summary>
/// the mark rect of comment. /// the mark rect of comment.
/// ||注解区域。 /// ||注解区域。

View File

@@ -27,7 +27,7 @@ namespace XCharts.Runtime
dataZoom.refreshComponent = delegate () dataZoom.refreshComponent = delegate ()
{ {
var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + dataZoom.index, chart.transform, var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + dataZoom.index, chart.transform,
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
dataZoom.gameObject = dataZoomObject; dataZoom.gameObject = dataZoomObject;
dataZoomObject.hideFlags = chart.chartHideFlags; dataZoomObject.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(dataZoomObject); ChartHelper.HideAllObject(dataZoomObject);

View File

@@ -75,7 +75,7 @@ namespace XCharts.Runtime
public void Init(BaseChart chart) public void Init(BaseChart chart)
{ {
m_Chart = chart; m_Chart = chart;
m_Label = AddDebugInfoObject("debug", chart.transform, m_LabelStyle, chart.theme); m_Label = AddDebugInfoObject("debug", chart.transform, m_LabelStyle, chart.theme, chart.childrenNodeNames);
} }
public void Update() public void Update()
@@ -155,14 +155,14 @@ namespace XCharts.Runtime
} }
private ChartLabel AddDebugInfoObject(string name, Transform parent, LabelStyle labelStyle, private ChartLabel AddDebugInfoObject(string name, Transform parent, LabelStyle labelStyle,
ThemeStyle theme) ThemeStyle theme, List<string> childrenNodeNames)
{ {
var anchorMax = new Vector2(0, 1); var anchorMax = new Vector2(0, 1);
var anchorMin = new Vector2(0, 1); var anchorMin = new Vector2(0, 1);
var pivot = new Vector2(0, 1); var pivot = new Vector2(0, 1);
var sizeDelta = new Vector2(100, 100); var sizeDelta = new Vector2(100, 100);
var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta, -1, childrenNodeNames);
labelGameObject.transform.SetAsLastSibling(); labelGameObject.transform.SetAsLastSibling();
labelGameObject.hideFlags = m_Chart.chartHideFlags; labelGameObject.hideFlags = m_Chart.chartHideFlags;
ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo); ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);

View File

@@ -131,7 +131,8 @@ namespace XCharts.Runtime
/// `{g}` : indicates the total number of data. <br /> /// `{g}` : indicates the total number of data. <br />
/// `{h}` : hexadecimal color value. <br /> /// `{h}` : hexadecimal color value. <br />
/// `{y}` : category value of y axis. <br /> /// `{y}` : category value of y axis. <br />
/// `{value}` : The value of the axis or legend. <br /> /// `{value}` : the value of the axis or legend. <br />
/// `{index}` : the index of the axis. <br />
/// The following placeholder apply to `UITable` components: <br /> /// The following placeholder apply to `UITable` components: <br />
/// `{name}` : indicates the row name of the table. <br /> /// `{name}` : indicates the row name of the table. <br />
/// `{index}` : indicates the row number of the table. <br /> /// `{index}` : indicates the row number of the table. <br />
@@ -161,6 +162,7 @@ namespace XCharts.Runtime
/// `{h}`:十六进制颜色值。<br/> /// `{h}`:十六进制颜色值。<br/>
/// `{y}`Y轴的类目名。<br/> /// `{y}`Y轴的类目名。<br/>
/// `{value}`:坐标轴或图例的值。<br/> /// `{value}`:坐标轴或图例的值。<br/>
/// `{index}`:坐标轴编号。<br/>
/// 以下通配符适用UITable组件<br/> /// 以下通配符适用UITable组件<br/>
/// `{name}` 表格的行名。<br/> /// `{name}` 表格的行名。<br/>
/// `{index}`:表格的行号。<br/> /// `{index}`:表格的行号。<br/>
@@ -398,7 +400,7 @@ namespace XCharts.Runtime
m_TextStyle.Copy(label.m_TextStyle); m_TextStyle.Copy(label.m_TextStyle);
} }
public virtual string GetFormatterContent(int labelIndex, string category) public virtual string GetFormatterContent(int labelIndex, int totalIndex, string category)
{ {
if (string.IsNullOrEmpty(category)) if (string.IsNullOrEmpty(category))
return GetFormatterFunctionContent(labelIndex, category, category); return GetFormatterFunctionContent(labelIndex, category, category);
@@ -410,12 +412,12 @@ namespace XCharts.Runtime
else else
{ {
var content = m_Formatter; var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, category); FormatterHelper.ReplaceAxisLabelContent(ref content, category, labelIndex, totalIndex);
return GetFormatterFunctionContent(labelIndex, category, category); return GetFormatterFunctionContent(labelIndex, category, category);
} }
} }
public virtual string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false) public virtual string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
{ {
var newNumericFormatter = numericFormatter; var newNumericFormatter = numericFormatter;
if (value == 0 && !DateTimeUtil.IsDateOrTimeRegex(newNumericFormatter)) if (value == 0 && !DateTimeUtil.IsDateOrTimeRegex(newNumericFormatter))
@@ -452,14 +454,14 @@ namespace XCharts.Runtime
else else
{ {
var content = m_Formatter; var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, newNumericFormatter, value); FormatterHelper.ReplaceAxisLabelContent(ref content, newNumericFormatter, value, labelIndex, totalIndex);
return GetFormatterFunctionContent(labelIndex, value, content); return GetFormatterFunctionContent(labelIndex, value, content);
} }
} }
private static bool isDateFormatter = false; private static bool isDateFormatter = false;
private static string newFormatter = null; private static string newFormatter = null;
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue) public string GetFormatterDateTime(int labelIndex, int totalIndex, double value, double minValue, double maxValue)
{ {
var timestamp = (int)value; var timestamp = (int)value;
var dateTime = DateTimeUtil.GetDateTime(timestamp); var dateTime = DateTimeUtil.GetDateTime(timestamp);
@@ -492,7 +494,7 @@ namespace XCharts.Runtime
if (!string.IsNullOrEmpty(m_Formatter)) if (!string.IsNullOrEmpty(m_Formatter))
{ {
var content = m_Formatter; var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, dateString); FormatterHelper.ReplaceAxisLabelContent(ref content, dateString, labelIndex, totalIndex);
return GetFormatterFunctionContent(labelIndex, value, content); return GetFormatterFunctionContent(labelIndex, value, content);
} }
else else

View File

@@ -45,7 +45,7 @@ namespace XCharts.Runtime
{ {
var content = serieLabel.formatter; var content = serieLabel.formatter;
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue, FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue,
dataTotal, serieName, dataName, dataName, color, serieData, chart); dataTotal, serieName, dataName, dataName, color, serieData, chart, serie.index);
if (serieLabel.formatterFunction == null) if (serieLabel.formatterFunction == null)
return content; return content;
else else

View File

@@ -55,7 +55,7 @@ namespace XCharts.Runtime
{ {
legend.OnChanged(); legend.OnChanged();
var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, chart.transform, chart.chartMinAnchor, var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
legend.gameObject = legendObject; legend.gameObject = legendObject;
legendObject.hideFlags = chart.chartHideFlags; legendObject.hideFlags = chart.chartHideFlags;
//ChartHelper.DestoryGameObjectByMatch(legendObject.transform, "_"); //ChartHelper.DestoryGameObjectByMatch(legendObject.transform, "_");

View File

@@ -48,7 +48,7 @@ namespace XCharts.Runtime
var objAnchorMin = new Vector2(0, 1); var objAnchorMin = new Vector2(0, 1);
var objAnchorMax = new Vector2(0, 1); var objAnchorMax = new Vector2(0, 1);
var objPivot = new Vector2(0, 1); var objPivot = new Vector2(0, 1);
var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta); var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta, -1, chart.childrenNodeNames);
var iconObj = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta); var iconObj = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta);
var img = ChartHelper.EnsureComponent<Image>(btnObj); var img = ChartHelper.EnsureComponent<Image>(btnObj);
img.color = Color.clear; img.color = Color.clear;

View File

@@ -14,7 +14,7 @@ namespace XCharts.Runtime
public override void InitComponent() public override void InitComponent()
{ {
m_MarkLineLabelRoot = ChartHelper.AddObject("markarea" + component.index, chart.transform, chart.chartMinAnchor, m_MarkLineLabelRoot = ChartHelper.AddObject("markarea" + component.index, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags; m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(m_MarkLineLabelRoot); ChartHelper.HideAllObject(m_MarkLineLabelRoot);
InitMarkArea(component); InitMarkArea(component);

View File

@@ -13,7 +13,7 @@ namespace XCharts.Runtime
public override void InitComponent() public override void InitComponent()
{ {
m_MarkLineLabelRoot = ChartHelper.AddObject("markline", chart.transform, chart.chartMinAnchor, m_MarkLineLabelRoot = ChartHelper.AddObject("markline", chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags; m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(m_MarkLineLabelRoot); ChartHelper.HideAllObject(m_MarkLineLabelRoot);
InitMarkLine(component); InitMarkLine(component);

View File

@@ -464,16 +464,16 @@ namespace XCharts.Runtime
indicatorList.Clear(); indicatorList.Clear();
} }
public string GetFormatterIndicatorContent(int indicatorIndex) public string GetFormatterIndicatorContent(int indicatorIndex, int totalIndex)
{ {
var indicator = GetIndicator(indicatorIndex); var indicator = GetIndicator(indicatorIndex);
if (indicator == null) if (indicator == null)
return string.Empty; return string.Empty;
else else
return GetFormatterIndicatorContent(indicator.name); return GetFormatterIndicatorContent(indicator.name, indicatorIndex, totalIndex);
} }
public string GetFormatterIndicatorContent(string indicatorName) public string GetFormatterIndicatorContent(string indicatorName, int index, int totalIndex)
{ {
if (string.IsNullOrEmpty(indicatorName)) if (string.IsNullOrEmpty(indicatorName))
return indicatorName; return indicatorName;
@@ -485,7 +485,7 @@ namespace XCharts.Runtime
else else
{ {
var content = m_AxisName.labelStyle.formatter; var content = m_AxisName.labelStyle.formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, indicatorName); FormatterHelper.ReplaceAxisLabelContent(ref content, indicatorName, index, totalIndex);
return content; return content;
} }
} }

View File

@@ -41,7 +41,7 @@ namespace XCharts.Runtime
{ {
radar.UpdateRadarCenter(chart); radar.UpdateRadarCenter(chart);
var radarObject = ChartHelper.AddObject("Radar" + radar.index, chart.transform, chart.chartMinAnchor, var radarObject = ChartHelper.AddObject("Radar" + radar.index, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
radar.gameObject = radarObject; radar.gameObject = radarObject;
radar.gameObject.hideFlags = chart.chartHideFlags; radar.gameObject.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(radarObject.transform, INDICATOR_TEXT); ChartHelper.HideAllObject(radarObject.transform, INDICATOR_TEXT);
@@ -50,9 +50,9 @@ namespace XCharts.Runtime
var indicator = radar.indicatorList[i]; var indicator = radar.indicatorList[i];
var pos = radar.GetIndicatorPosition(i); var pos = radar.GetIndicatorPosition(i);
var objName = INDICATOR_TEXT + "_" + i; var objName = INDICATOR_TEXT + "_" + i;
var content = radar.GetFormatterIndicatorContent(i, radar.indicatorList.Count);
var label = ChartHelper.AddChartLabel(objName, radarObject.transform, radar.axisName.labelStyle, var label = ChartHelper.AddChartLabel(objName, radarObject.transform, radar.axisName.labelStyle,
chart.theme.common, radar.GetFormatterIndicatorContent(i), Color.clear, TextAnchor.MiddleCenter); chart.theme.common, content, Color.clear, TextAnchor.MiddleCenter);
label.SetActive(radar.axisName.show && radar.indicator && radar.axisName.labelStyle.show, true); label.SetActive(radar.axisName.show && radar.indicator && radar.axisName.labelStyle.show, true);
AxisHelper.AdjustCircleLabelPos(label, pos, radar.context.center, txtHig, radar.axisName.labelStyle.offset); AxisHelper.AdjustCircleLabelPos(label, pos, radar.context.center, txtHig, radar.axisName.labelStyle.offset);
} }

View File

@@ -22,7 +22,7 @@ namespace XCharts.Runtime
var pivot = title.location.runtimePivot; var pivot = title.location.runtimePivot;
var objName = ChartCached.GetComponentObjectName(title); var objName = ChartCached.GetComponentObjectName(title);
var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax, var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax,
pivot, chart.chartSizeDelta); pivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
title.gameObject = titleObject; title.gameObject = titleObject;
title.gameObject.transform.SetSiblingIndex(chart.m_PainterUpper.transform.GetSiblingIndex() + 1); title.gameObject.transform.SetSiblingIndex(chart.m_PainterUpper.transform.GetSiblingIndex() + 1);
anchorMin = title.location.runtimeAnchorMin; anchorMin = title.location.runtimeAnchorMin;

View File

@@ -145,6 +145,7 @@ namespace XCharts.Runtime
[SerializeField] private float m_TitleHeight = 25f; [SerializeField] private float m_TitleHeight = 25f;
[SerializeField] private float m_ItemHeight = 25f; [SerializeField] private float m_ItemHeight = 25f;
[SerializeField] private Color32 m_BorderColor = new Color32(230, 230, 230, 255); [SerializeField] private Color32 m_BorderColor = new Color32(230, 230, 230, 255);
[SerializeField][Since("v3.14.0")] private List<float> m_ColumnGapWidths = new List<float>{15};
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None); [SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None);
[SerializeField] [SerializeField]
private LabelStyle m_TitleLabelStyle = new LabelStyle() private LabelStyle m_TitleLabelStyle = new LabelStyle()
@@ -154,7 +155,7 @@ namespace XCharts.Runtime
[SerializeField] [SerializeField]
private List<LabelStyle> m_ContentLabelStyles = new List<LabelStyle>() private List<LabelStyle> m_ContentLabelStyles = new List<LabelStyle>()
{ {
new LabelStyle() { textPadding = new TextPadding(0, 5, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft } }, new LabelStyle() { textPadding = new TextPadding(0, 5, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleCenter } },
new LabelStyle() { textPadding = new TextPadding(0, 20, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft } }, new LabelStyle() { textPadding = new TextPadding(0, 20, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft } },
new LabelStyle() { textPadding = new TextPadding(0, 0, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleRight } } new LabelStyle() { textPadding = new TextPadding(0, 0, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleRight } }
}; };
@@ -453,6 +454,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); } set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
} }
/// <summary> /// <summary>
/// the column gap width of content. When there is only one column, it only represents the gap width of the second column.
/// ||内容部分的列间距。当只有一列时,只表示第二列的间距。
/// </summary>
public List<float> columnGapWidths
{
get { return m_ColumnGapWidths; }
set { if (value != null) { m_ColumnGapWidths = value; SetComponentDirty(); } }
}
/// <summary>
/// the textstyle of title. /// the textstyle of title.
/// ||标题的文本样式。 /// ||标题的文本样式。
/// </summary> /// </summary>
@@ -462,8 +472,8 @@ namespace XCharts.Runtime
set { if (value != null) { m_TitleLabelStyle = value; SetComponentDirty(); } } set { if (value != null) { m_TitleLabelStyle = value; SetComponentDirty(); } }
} }
/// <summary> /// <summary>
/// the textstyle list of content. /// the column text style list of content. The first represents the text style of the first column, and so on.
/// ||内容部分的文本样式列表。和列一一对应 /// ||内容部分的文本样式列表。第一个表示第一列的文本样式,以此类推
/// </summary> /// </summary>
public List<LabelStyle> contentLabelStyles public List<LabelStyle> contentLabelStyles
{ {

View File

@@ -53,7 +53,7 @@ namespace XCharts.Runtime
{ {
var objName = ChartCached.GetComponentObjectName(tooltip); var objName = ChartCached.GetComponentObjectName(tooltip);
tooltip.gameObject = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, tooltip.gameObject = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
var tooltipObject = tooltip.gameObject; var tooltipObject = tooltip.gameObject;
tooltipObject.transform.localPosition = Vector3.zero; tooltipObject.transform.localPosition = Vector3.zero;
tooltipObject.hideFlags = chart.chartHideFlags; tooltipObject.hideFlags = chart.chartHideFlags;
@@ -264,15 +264,15 @@ namespace XCharts.Runtime
var index = (int)axis.context.pointerValue; var index = (int)axis.context.pointerValue;
var dataZoom = chart.GetDataZoomOfAxis(axis); var dataZoom = chart.GetDataZoomOfAxis(axis);
var category = axis.GetData(index, dataZoom); var category = axis.GetData(index, dataZoom);
label.SetText(axis.indicatorLabel.GetFormatterContent(index, category)); label.SetText(axis.indicatorLabel.GetFormatterContent(index, 0, category));
} }
else if (axis.IsTime()) else if (axis.IsTime())
{ {
label.SetText(axis.indicatorLabel.GetFormatterDateTime(0, axis.context.pointerValue, axis.context.minValue, axis.context.maxValue)); label.SetText(axis.indicatorLabel.GetFormatterDateTime(0, 0, axis.context.pointerValue, axis.context.minValue, axis.context.maxValue));
} }
else else
{ {
label.SetText(axis.indicatorLabel.GetFormatterContent(0, axis.context.pointerValue, axis.context.minValue, axis.context.maxValue, axis.IsLog())); label.SetText(axis.indicatorLabel.GetFormatterContent(0, 0, axis.context.pointerValue, axis.context.minValue, axis.context.maxValue, axis.IsLog()));
} }
var textColor = axis.axisLabel.textStyle.GetColor(chart.theme.axis.textColor); var textColor = axis.axisLabel.textStyle.GetColor(chart.theme.axis.textColor);
if (ChartHelper.IsClearColor(axis.indicatorLabel.background.color)) if (ChartHelper.IsClearColor(axis.indicatorLabel.background.color))
@@ -356,6 +356,7 @@ namespace XCharts.Runtime
if (isTriggerAxis) if (isTriggerAxis)
{ {
var index = serie.context.dataZoomStartIndex + (int)yAxis.context.pointerValue; var index = serie.context.dataZoomStartIndex + (int)yAxis.context.pointerValue;
if(serie.useSortData) index = yAxis.context.sortedDataIndices[index];
serie.context.pointerEnter = true; serie.context.pointerEnter = true;
serie.context.pointerAxisDataIndexs.Add(index); serie.context.pointerAxisDataIndexs.Add(index);
serie.context.pointerItemDataIndex = index; serie.context.pointerItemDataIndex = index;
@@ -375,6 +376,7 @@ namespace XCharts.Runtime
if (isTriggerAxis) if (isTriggerAxis)
{ {
var index = serie.context.dataZoomStartIndex + (int)xAxis.context.pointerValue; var index = serie.context.dataZoomStartIndex + (int)xAxis.context.pointerValue;
if(serie.useSortData) index = xAxis.context.sortedDataIndices[index];
if (chart.isTriggerOnClick) if (chart.isTriggerOnClick)
{ {
if (serie.insertDataToHead) if (serie.insertDataToHead)
@@ -452,7 +454,7 @@ namespace XCharts.Runtime
var dataCount = serie.dataCount; var dataCount = serie.dataCount;
var themeSymbolSize = chart.theme.serie.scatterSymbolSize; var themeSymbolSize = chart.theme.serie.scatterSymbolSize;
var data = serie.data; var data = serie.data;
if (!isTimeAxis) if (!isTimeAxis)// || serie.useSortData)
{ {
serie.context.sortedData.Clear(); serie.context.sortedData.Clear();
for (int i = 0; i < dataCount; i++) for (int i = 0; i < dataCount; i++)

View File

@@ -44,7 +44,8 @@ namespace XCharts.Runtime
param.serieData.name, param.serieData.name,
param.color, param.color,
param.serieData, param.serieData,
chart); chart,
param.serieIndex);
foreach (var item in content.Split('|')) foreach (var item in content.Split('|'))
{ {
param.columns.Add(item); param.columns.Add(item);

View File

@@ -60,6 +60,7 @@ namespace XCharts.Runtime
ChartHelper.SetActive(gameObject, m_Active); ChartHelper.SetActive(gameObject, m_Active);
if (!flag) if (!flag)
{ {
m_ColumnMaxWidth.Clear();
foreach (var item in m_Items) foreach (var item in m_Items)
item.gameObject.SetActive(false); item.gameObject.SetActive(false);
} }
@@ -75,8 +76,6 @@ namespace XCharts.Runtime
ChartHelper.SetActive(title, titleActive); ChartHelper.SetActive(title, titleActive);
title.SetText(data.title); title.SetText(data.title);
m_ColumnMaxWidth.Clear();
var contentLabelStyle0 = tooltip.GetContentLabelStyle(0);
for (int i = 0; i < data.param.Count; i++) for (int i = 0; i < data.param.Count; i++)
{ {
var item = GetItem(i); var item = GetItem(i);
@@ -89,17 +88,21 @@ namespace XCharts.Runtime
item.gameObject.SetActive(true); item.gameObject.SetActive(true);
for (int j = 0; j < param.columns.Count; j++) for (int j = 0; j < param.columns.Count; j++)
{ {
var column = GetItemColumn(item, j); var column = GetItemColumn(item, j, j == 0 && IsSecondaryMark(param, param.columns[j]));
column.SetActive(true); column.SetActive(true);
column.SetText(param.columns[j]); column.SetText(param.columns[j]);
if (j == 0 && contentLabelStyle0 != null && ChartHelper.IsClearColor(contentLabelStyle0.textStyle.color)) if (j == 0)
{
var labelStyle = tooltip.GetContentLabelStyle(j);
if (labelStyle != null && ChartHelper.IsClearColor(labelStyle.textStyle.color))
column.text.SetColor(param.color); column.text.SetColor(param.color);
}
if (j >= m_ColumnMaxWidth.Count) if (j >= m_ColumnMaxWidth.Count)
m_ColumnMaxWidth.Add(0); m_ColumnMaxWidth.Add(0);
var columnWidth = column.GetWidth(); var columnWidth = column.text.GetPreferredWidth() + GetTooltipColumnGapWidth(tooltip, j);
if (m_ColumnMaxWidth[j] < columnWidth) if (m_ColumnMaxWidth[j] < columnWidth)
m_ColumnMaxWidth[j] = columnWidth; m_ColumnMaxWidth[j] = columnWidth;
} }
@@ -117,6 +120,22 @@ namespace XCharts.Runtime
tooltip.gameObject.transform.SetAsLastSibling(); tooltip.gameObject.transform.SetAsLastSibling();
} }
private static float GetTooltipColumnGapWidth(Tooltip tooltip, int index)
{
if (tooltip == null || tooltip.columnGapWidths.Count == 0) return 0;
if (tooltip.columnGapWidths.Count == 1) return index == 1 ? tooltip.columnGapWidths[0] : 0;
if (index < tooltip.columnGapWidths.Count)
{
return tooltip.columnGapWidths[index];
}
return 0;
}
private static bool IsSecondaryMark(SerieParams sp, string mark)
{
return sp.isSecondaryMark && mark == sp.marker;
}
private void ResetSize() private void ResetSize()
{ {
var maxHig = 0f; var maxHig = 0f;
@@ -158,8 +177,10 @@ namespace XCharts.Runtime
var xPos = 0f; var xPos = 0f;
for (int j = 0; j < m_ColumnMaxWidth.Count; j++) for (int j = 0; j < m_ColumnMaxWidth.Count; j++)
{ {
if (j >= item.columns.Count) break;
var deltaX = j == m_ColumnMaxWidth.Count - 1 ? maxWid - xPos : m_ColumnMaxWidth[j]; var deltaX = j == m_ColumnMaxWidth.Count - 1 ? maxWid - xPos : m_ColumnMaxWidth[j];
item.columns[j].text.SetSizeDelta(new Vector2(deltaX, tooltip.itemHeight)); item.columns[j].text.SetSizeDelta(new Vector2(deltaX, tooltip.itemHeight));
item.columns[j].SetSize(deltaX, tooltip.itemHeight);
item.columns[j].SetRectPosition(new Vector3(xPos, 0)); item.columns[j].SetRectPosition(new Vector3(xPos, 0));
xPos += m_ColumnMaxWidth[j]; xPos += m_ColumnMaxWidth[j];
} }
@@ -192,19 +213,24 @@ namespace XCharts.Runtime
} }
} }
private ChartLabel GetItemColumn(TooltipViewItem item, int i) private ChartLabel GetItemColumn(TooltipViewItem item, int i, bool isSecondaryMark = false)
{ {
if (i < 0) i = 0; if (i < 0) i = 0;
ChartLabel column;
if (i < item.columns.Count) if (i < item.columns.Count)
{ {
return item.columns[i]; column = item.columns[i];
} }
else else
{ {
var column = CreateViewItemColumn(i, item.gameObject.transform, tooltip, theme); column = CreateViewItemColumn(i, item.gameObject.transform, tooltip, theme);
item.columns.Add(column); item.columns.Add(column);
return column;
} }
if (isSecondaryMark)
{
column.text.text.fontSize = (int)(tooltip.GetContentLabelStyle(i).textStyle.fontSize * 0.6f);
}
return column;
} }
public static TooltipView CreateView(Tooltip tooltip, ThemeStyle theme, Transform parent) public static TooltipView CreateView(Tooltip tooltip, ThemeStyle theme, Transform parent)
@@ -266,8 +292,9 @@ namespace XCharts.Runtime
private static ChartLabel CreateViewItemColumn(int i, Transform parent, Tooltip tooltip, ComponentTheme theme) private static ChartLabel CreateViewItemColumn(int i, Transform parent, Tooltip tooltip, ComponentTheme theme)
{ {
var labelStyle = tooltip.GetContentLabelStyle(i); var labelStyle = tooltip.GetContentLabelStyle(i);
labelStyle.textStyle.autoAlign = false;
var label = ChartHelper.AddChartLabel("column" + i, parent, labelStyle, theme, var label = ChartHelper.AddChartLabel("column" + i, parent, labelStyle, theme,
"", Color.clear, TextAnchor.MiddleLeft); "", Color.clear, TextAnchor.MiddleLeft, true);
return label; return label;
} }
} }

View File

@@ -18,6 +18,7 @@ namespace XCharts.Runtime
private static Regex s_RegexSubForAxisLabel = new Regex(@"(value)|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase); private static Regex s_RegexSubForAxisLabel = new Regex(@"(value)|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
private static Regex s_RegexForSerieLabel = new Regex(@"{[a-h|\.|y]\d*(:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase); private static Regex s_RegexForSerieLabel = new Regex(@"{[a-h|\.|y]\d*(:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase);
private static Regex s_RegexSubForSerieLabel = new Regex(@"(\.)|([a-h|y]\d*)|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase); private static Regex s_RegexSubForSerieLabel = new Regex(@"(\.)|([a-h|y]\d*)|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
private static Regex s_RegexForAxisIndex = new Regex(@"\{(-?)index([+-]\d+)?\}", RegexOptions.IgnoreCase);
public static bool NeedFormat(string content) public static bool NeedFormat(string content)
{ {
@@ -149,7 +150,7 @@ namespace XCharts.Runtime
else if (p == 'c' || p == 'C' || p == 'd' || p == 'D' || p == 'f' || p == 'f') else if (p == 'c' || p == 'C' || p == 'd' || p == 'D' || p == 'f' || p == 'f')
{ {
var isPercent = p == 'd' || p == 'D'; var isPercent = p == 'd' || p == 'D';
var isTotal = p == 'f' || p == 'f'; var isTotal = p == 'f' || p == 'F';
var bIndex = dataIndex; var bIndex = dataIndex;
var dimensionIndex = -1; var dimensionIndex = -1;
if (argsCount >= 2) if (argsCount >= 2)
@@ -211,7 +212,7 @@ namespace XCharts.Runtime
} }
public static void ReplaceSerieLabelContent(ref string content, string numericFormatter, int dataCount, double value, double total, public static void ReplaceSerieLabelContent(ref string content, string numericFormatter, int dataCount, double value, double total,
string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null) string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null, int serieIndex = 0)
{ {
var mc = s_RegexForSerieLabel.Matches(content); var mc = s_RegexForSerieLabel.Matches(content);
foreach (var m in mc) foreach (var m in mc)
@@ -270,6 +271,14 @@ namespace XCharts.Runtime
} }
else if (p == 'f' || p == 'f') else if (p == 'f' || p == 'f')
{ {
if (pIndex != 1 && chart != null)
{
var serie = chart.GetSerie(serieIndex);
if (serie != null)
{
total = serie.GetDataTotal(pIndex, serieData);
}
}
content = content.Replace(old, ChartCached.NumberToStr(total, numericFormatter)); content = content.Replace(old, ChartCached.NumberToStr(total, numericFormatter));
} }
else if (p == 'g' || p == 'G') else if (p == 'g' || p == 'G')
@@ -326,7 +335,7 @@ namespace XCharts.Runtime
return s_RegexNewLine.Replace(content.Trim(), PH_NN); return s_RegexNewLine.Replace(content.Trim(), PH_NN);
} }
public static void ReplaceAxisLabelContent(ref string content, string numericFormatter, double value) public static void ReplaceAxisLabelContent(ref string content, string numericFormatter, double value, int index, int totalIndex)
{ {
var mc = s_RegexForAxisLabel.Matches(content); var mc = s_RegexForAxisLabel.Matches(content);
foreach (var m in mc) foreach (var m in mc)
@@ -341,10 +350,11 @@ namespace XCharts.Runtime
} }
content = content.Replace(old, ChartCached.FloatToStr(value, numericFormatter)); content = content.Replace(old, ChartCached.FloatToStr(value, numericFormatter));
} }
ReplaceIndexContent(ref content, index, totalIndex);
content = TrimAndReplaceLine(content); content = TrimAndReplaceLine(content);
} }
public static void ReplaceAxisLabelContent(ref string content, string value) public static void ReplaceAxisLabelContent(ref string content, string value, int index, int totalIndex)
{ {
var mc = s_RegexForAxisLabel.Matches(content); var mc = s_RegexForAxisLabel.Matches(content);
foreach (var m in mc) foreach (var m in mc)
@@ -355,8 +365,26 @@ namespace XCharts.Runtime
if (argsCount <= 0) continue; if (argsCount <= 0) continue;
content = content.Replace(old, value); content = content.Replace(old, value);
} }
ReplaceIndexContent(ref content, index, totalIndex);
content = TrimAndReplaceLine(content); content = TrimAndReplaceLine(content);
} }
public static void ReplaceIndexContent(ref string content, int currIndex, int totalIndex)
{
if (totalIndex <= 0) return;
content = s_RegexForAxisIndex.Replace(content, (match) =>
{
bool isNegative = match.Groups[1].Value == "-";
int offset = 0;
int parsedOffset = 0;
if (match.Groups[2].Success &&
int.TryParse(match.Groups[2].Value, out parsedOffset))
{
offset = parsedOffset;
}
int baseValue = isNegative ? totalIndex - currIndex : currIndex + 1;
return (baseValue + offset).ToString();
});
}
} }
} }

View File

@@ -52,6 +52,7 @@ namespace XCharts.Runtime
public MainComponent AddChartComponent(Type type) public MainComponent AddChartComponent(Type type)
{ {
InitListForFieldInfos();
if (!CanAddChartComponent(type)) if (!CanAddChartComponent(type))
{ {
Debug.LogError("XCharts ERROR: CanAddChartComponent:" + type.Name); Debug.LogError("XCharts ERROR: CanAddChartComponent:" + type.Name);

View File

@@ -54,8 +54,8 @@ namespace XCharts.Runtime
p4 = ClampInGrid(grid, p4); p4 = ClampInGrid(grid, p4);
} }
if (!clip || if (!clip ||
(clip && (grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) && (clip && grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) &&
grid.Contains(p4)))) grid.Contains(p4)))
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, startColor, toColor); UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, startColor, toColor);
} }
@@ -83,12 +83,12 @@ namespace XCharts.Runtime
public void DrawClipSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness, public void DrawClipSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, float gap, Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, float gap,
bool clip, float[] cornerRadius, GridCoord grid, Vector3 startPos) bool clip, float[] cornerRadius, GridCoord grid, Vector3 startPos, float symbolSize2 = 0)
{ {
if (!IsInChart(pos)) return; if (!IsInChart(pos)) return;
if (!clip || (clip && (grid.Contains(pos)))) if (!clip || (clip && (grid.Contains(pos))))
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor, DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor,
gap, cornerRadius, startPos); gap, cornerRadius, startPos, symbolSize2);
} }
public void DrawClipZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth, public void DrawClipZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,
@@ -101,22 +101,22 @@ namespace XCharts.Runtime
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness, public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor,
float gap, float[] cornerRadius) float gap, float[] cornerRadius, float symbolSize2 = 0)
{ {
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor, DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor,
gap, cornerRadius, Vector3.zero); gap, cornerRadius, Vector3.zero, symbolSize2);
} }
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness, public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor,
float gap, float[] cornerRadius, Vector3 startPos) float gap, float[] cornerRadius, Vector3 startPos, float symbolSize2 = 0)
{ {
var backgroundColor = GetChartBackgroundColor(); var backgroundColor = GetChartBackgroundColor();
if (ChartHelper.IsClearColor(emptyColor)) if (ChartHelper.IsClearColor(emptyColor))
emptyColor = backgroundColor; emptyColor = backgroundColor;
var smoothness = settings.cicleSmoothness; var smoothness = settings.cicleSmoothness;
ChartDrawer.DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap, ChartDrawer.DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap,
cornerRadius, emptyColor, backgroundColor, borderColor, smoothness, startPos); cornerRadius, emptyColor, backgroundColor, borderColor, smoothness, startPos, symbolSize2);
} }
public Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, GridCoord grid) public Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, GridCoord grid)

View File

@@ -101,6 +101,28 @@ namespace XCharts.Runtime
return false; return false;
} }
public bool HasRealtimeSortSerie(int gridIndex)
{
foreach (var serie in m_Series)
{
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (serie.useSortData)
return true;
}
return false;
}
public Serie GetRealtimeSortSerie(int gridIndex)
{
foreach (var serie in m_Series)
{
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (serie.useSortData)
return serie;
}
return null;
}
public T GetSerie<T>() where T : Serie public T GetSerie<T>() where T : Serie
{ {
foreach (var serie in m_Series) foreach (var serie in m_Series)
@@ -831,7 +853,7 @@ namespace XCharts.Runtime
} }
} }
public float GetSerieBarGap<T>() where T : Serie public float GetSerieBarGap<T>(int gridIndex) where T : Serie
{ {
float gap = 0f; float gap = 0f;
for (int i = 0; i < m_Series.Count; i++) for (int i = 0; i < m_Series.Count; i++)
@@ -839,6 +861,7 @@ namespace XCharts.Runtime
var serie = m_Series[i]; var serie = m_Series[i];
if (serie.show && serie is T) if (serie.show && serie is T)
{ {
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (serie.barGap != 0) if (serie.barGap != 0)
{ {
gap = serie.barGap; gap = serie.barGap;
@@ -848,7 +871,7 @@ namespace XCharts.Runtime
return gap; return gap;
} }
public double GetSerieSameStackTotalValue<T>(string stack, int dataIndex) where T : Serie public double GetSerieSameStackTotalValue<T>(string stack, int dataIndex, int gridIndex) where T : Serie
{ {
if (string.IsNullOrEmpty(stack)) return 0; if (string.IsNullOrEmpty(stack)) return 0;
double total = 0; double total = 0;
@@ -856,6 +879,7 @@ namespace XCharts.Runtime
{ {
if (serie is T) if (serie is T)
{ {
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (stack.Equals(serie.stack)) if (stack.Equals(serie.stack))
{ {
total += serie.data[dataIndex].data[1]; total += serie.data[dataIndex].data[1];
@@ -865,7 +889,7 @@ namespace XCharts.Runtime
return total; return total;
} }
public int GetSerieBarRealCount<T>() where T : Serie public int GetSerieBarRealCount<T>(int gridIndex) where T : Serie
{ {
var count = 0; var count = 0;
barStackSet.Clear(); barStackSet.Clear();
@@ -875,6 +899,7 @@ namespace XCharts.Runtime
if (!serie.show) continue; if (!serie.show) continue;
if (serie is T) if (serie is T)
{ {
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (!string.IsNullOrEmpty(serie.stack)) if (!string.IsNullOrEmpty(serie.stack))
{ {
if (barStackSet.Contains(serie.stack)) continue; if (barStackSet.Contains(serie.stack)) continue;
@@ -887,8 +912,26 @@ namespace XCharts.Runtime
return count; return count;
} }
private bool CheckSerieGridIndex(Serie serie, int gridIndex)
{
if (gridIndex >= 0)
{
if (serie.xAxisIndex >= 0 && serie.xAxisIndex < m_XAxes.Count)
{
var xAxis = m_XAxes[serie.xAxisIndex];
if (xAxis.gridIndex != gridIndex) return false;
}
if (serie.yAxisIndex >= 0 && serie.yAxisIndex < m_YAxes.Count)
{
var yAxis = m_YAxes[serie.yAxisIndex];
if (yAxis.gridIndex != gridIndex) return false;
}
}
return true;
}
private HashSet<string> barStackSet = new HashSet<string>(); private HashSet<string> barStackSet = new HashSet<string>();
public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount) where T : Serie public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount, int gridIndex) where T : Serie
{ {
float total = 0; float total = 0;
float lastGap = 0; float lastGap = 0;
@@ -899,6 +942,7 @@ namespace XCharts.Runtime
if (!serie.show) continue; if (!serie.show) continue;
if (serie is T) if (serie is T)
{ {
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (!string.IsNullOrEmpty(serie.stack)) if (!string.IsNullOrEmpty(serie.stack))
{ {
if (barStackSet.Contains(serie.stack)) continue; if (barStackSet.Contains(serie.stack)) continue;
@@ -921,12 +965,12 @@ namespace XCharts.Runtime
return total; return total;
} }
public float GetSerieTotalGap<T>(float categoryWidth, float gap, int index) where T : Serie public float GetSerieTotalGap<T>(float categoryWidth, float gap, int index, int gridIndex) where T : Serie
{ {
if (index <= 0) return 0; if (index <= 0) return 0;
var total = 0f; var total = 0f;
var count = 0; var count = 0;
var totalRealBarCount = GetSerieBarRealCount<T>(); var totalRealBarCount = GetSerieBarRealCount<T>(gridIndex);
barStackSet.Clear(); barStackSet.Clear();
for (int i = 0; i < m_Series.Count; i++) for (int i = 0; i < m_Series.Count; i++)
{ {
@@ -934,6 +978,7 @@ namespace XCharts.Runtime
if (!serie.show) continue; if (!serie.show) continue;
if (serie is T) if (serie is T)
{ {
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (!string.IsNullOrEmpty(serie.stack)) if (!string.IsNullOrEmpty(serie.stack))
{ {
if (barStackSet.Contains(serie.stack)) continue; if (barStackSet.Contains(serie.stack)) continue;
@@ -983,7 +1028,7 @@ namespace XCharts.Runtime
} }
private List<string> tempList = new List<string>(); private List<string> tempList = new List<string>();
public int GetSerieIndexIfStack<T>(Serie currSerie) where T : Serie public int GetSerieIndexIfStack<T>(Serie currSerie, int gridIndex) where T : Serie
{ {
tempList.Clear(); tempList.Clear();
int index = 0; int index = 0;
@@ -992,6 +1037,7 @@ namespace XCharts.Runtime
var serie = m_Series[i]; var serie = m_Series[i];
if (!serie.show) continue; if (!serie.show) continue;
if (!(serie is T)) continue; if (!(serie is T)) continue;
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (string.IsNullOrEmpty(serie.stack)) if (string.IsNullOrEmpty(serie.stack))
{ {
if (serie.index == currSerie.index) return index; if (serie.index == currSerie.index) return index;

View File

@@ -377,7 +377,7 @@ namespace XCharts.Runtime
serie.index = i; serie.index = i;
SetPainterActive(i, true); SetPainterActive(i, true);
} }
if (transform.childCount - 3 != m_PainterTop.transform.GetSiblingIndex()) if (m_PainterTop != null && transform.childCount - 3 != m_PainterTop.transform.GetSiblingIndex())
{ {
m_PainterTop.transform.SetSiblingIndex(transform.childCount - 3); m_PainterTop.transform.SetSiblingIndex(transform.childCount - 3);
} }
@@ -394,7 +394,7 @@ namespace XCharts.Runtime
{ {
var index = settings.reversePainter ? settings.maxPainter - 1 - i : i; var index = settings.reversePainter ? settings.maxPainter - 1 - i : i;
var painter = ChartHelper.AddPainterObject("painter_" + index, transform, m_GraphMinAnchor, var painter = ChartHelper.AddPainterObject("painter_" + index, transform, m_GraphMinAnchor,
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + index); m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + index, m_ChildNodeNames);
painter.index = m_PainterList.Count; painter.index = m_PainterList.Count;
painter.type = Painter.Type.Serie; painter.type = Painter.Type.Serie;
painter.onPopulateMesh = OnDrawPainterSerie; painter.onPopulateMesh = OnDrawPainterSerie;
@@ -404,7 +404,7 @@ namespace XCharts.Runtime
m_PainterList.Add(painter); m_PainterList.Add(painter);
} }
m_PainterUpper = ChartHelper.AddPainterObject("painter_u", transform, m_GraphMinAnchor, m_PainterUpper = ChartHelper.AddPainterObject("painter_u", transform, m_GraphMinAnchor,
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter); m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter, m_ChildNodeNames);
m_PainterUpper.type = Painter.Type.Top; m_PainterUpper.type = Painter.Type.Top;
m_PainterUpper.onPopulateMesh = OnDrawPainterUpper; m_PainterUpper.onPopulateMesh = OnDrawPainterUpper;
m_PainterUpper.SetActive(true, m_DebugInfo.showAllChartObject); m_PainterUpper.SetActive(true, m_DebugInfo.showAllChartObject);
@@ -412,7 +412,7 @@ namespace XCharts.Runtime
m_PainterUpper.transform.SetSiblingIndex(settings.maxPainter + 1); m_PainterUpper.transform.SetSiblingIndex(settings.maxPainter + 1);
m_PainterTop = ChartHelper.AddPainterObject("painter_t", transform, m_GraphMinAnchor, m_PainterTop = ChartHelper.AddPainterObject("painter_t", transform, m_GraphMinAnchor,
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter); m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter, m_ChildNodeNames);
m_PainterTop.type = Painter.Type.Top; m_PainterTop.type = Painter.Type.Top;
m_PainterTop.onPopulateMesh = OnDrawPainterTop; m_PainterTop.onPopulateMesh = OnDrawPainterTop;
m_PainterTop.SetActive(true, m_DebugInfo.showAllChartObject); m_PainterTop.SetActive(true, m_DebugInfo.showAllChartObject);
@@ -724,7 +724,7 @@ namespace XCharts.Runtime
private void InitListForFieldInfos() private void InitListForFieldInfos()
{ {
if (m_TypeListForSerie.Count != 0) return; if (m_TypeListForSerie.Count != 0 || m_TypeListForComponent.Count != 0) return;
m_TypeListForComponent.Clear(); m_TypeListForComponent.Clear();
m_TypeListForSerie.Clear(); m_TypeListForSerie.Clear();
var fileds1 = GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance); var fileds1 = GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

View File

@@ -158,8 +158,8 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void RebuildChartObject() public void RebuildChartObject()
{ {
ChartHelper.DestroyAllChildren(transform); ChartHelper.DestoryGameObjectByMatch(transform, m_ChildNodeNames);
SetAllComponentDirty(); //SetAllComponentDirty();
} }
public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint) public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint)

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using UnityEngine.UI; using UnityEngine.UI;
@@ -14,6 +15,7 @@ namespace XCharts.Runtime
IDragHandler, IEndDragHandler, IScrollHandler IDragHandler, IEndDragHandler, IScrollHandler
{ {
[SerializeField] protected bool m_EnableTextMeshPro = false; [SerializeField] protected bool m_EnableTextMeshPro = false;
[SerializeField] protected List<string> m_ChildNodeNames = new List<string>();
protected Painter m_Painter; protected Painter m_Painter;
protected int m_SiblingIndex; protected int m_SiblingIndex;
@@ -52,8 +54,11 @@ namespace XCharts.Runtime
public virtual HideFlags chartHideFlags { get { return HideFlags.None; } } public virtual HideFlags chartHideFlags { get { return HideFlags.None; } }
private ScrollRect m_ScrollRect; private ScrollRect m_ScrollRect;
private Vector2 m_PointerDownPos;
public Painter painter { get { return m_Painter; } } public Painter painter { get { return m_Painter; } }
public List<string> childrenNodeNames { get { return m_ChildNodeNames; } }
public bool isDragingClick { get; set; }
protected virtual void InitComponent() protected virtual void InitComponent()
{ {
@@ -158,7 +163,7 @@ namespace XCharts.Runtime
protected virtual void InitPainter() protected virtual void InitPainter()
{ {
m_Painter = ChartHelper.AddPainterObject("painter_b", transform, m_GraphMinAnchor, m_Painter = ChartHelper.AddPainterObject("painter_b", transform, m_GraphMinAnchor,
m_GraphMaxAnchor, m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight), chartHideFlags, 1); m_GraphMaxAnchor, m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight), chartHideFlags, 1, m_ChildNodeNames);
m_Painter.type = Painter.Type.Base; m_Painter.type = Painter.Type.Base;
m_Painter.onPopulateMesh = OnDrawPainterBase; m_Painter.onPopulateMesh = OnDrawPainterBase;
m_Painter.transform.SetSiblingIndex(0); m_Painter.transform.SetSiblingIndex(0);
@@ -284,11 +289,13 @@ namespace XCharts.Runtime
public virtual void OnPointerDown(PointerEventData eventData) public virtual void OnPointerDown(PointerEventData eventData)
{ {
m_PointerDownPos = eventData.position;
if (m_OnPointerDown != null) m_OnPointerDown(eventData, this); if (m_OnPointerDown != null) m_OnPointerDown(eventData, this);
} }
public virtual void OnPointerUp(PointerEventData eventData) public virtual void OnPointerUp(PointerEventData eventData)
{ {
isDragingClick = Vector2.Distance(eventData.position, m_PointerDownPos) > 6;
if (m_OnPointerUp != null) m_OnPointerUp(eventData, this); if (m_OnPointerUp != null) m_OnPointerUp(eventData, this);
} }

View File

@@ -18,9 +18,7 @@ namespace XCharts.Runtime
/// <summary> /// <summary>
/// 获取标记大小的回调。 /// 获取标记大小的回调。
/// </summary> /// </summary>
/// <param name="data"></param> public delegate float SymbolSizeFunction(float defaultSize, SerieData serieData);
/// <returns></returns>
public delegate float SymbolSizeFunction(List<double> data);
public delegate void CustomDrawGaugePointerFunction(VertexHelper vh, int serieIndex, int dataIndex, float currentAngle); public delegate void CustomDrawGaugePointerFunction(VertexHelper vh, int serieIndex, int dataIndex, float currentAngle);
/// <summary> /// <summary>
/// DataZoom的start和end变更时的委托方法。 /// DataZoom的start和end变更时的委托方法。

View File

@@ -187,13 +187,13 @@ namespace XCharts.Runtime
m_TMPText.alignment = TextAlignmentOptions.BottomRight; m_TMPText.alignment = TextAlignmentOptions.BottomRight;
break; break;
case TextAnchor.MiddleCenter: case TextAnchor.MiddleCenter:
m_TMPText.alignment = TextAlignmentOptions.Center; m_TMPText.alignment = TextAlignmentOptions.Midline;
break; break;
case TextAnchor.MiddleLeft: case TextAnchor.MiddleLeft:
m_TMPText.alignment = TextAlignmentOptions.Left; m_TMPText.alignment = TextAlignmentOptions.MidlineLeft;
break; break;
case TextAnchor.MiddleRight: case TextAnchor.MiddleRight:
m_TMPText.alignment = TextAlignmentOptions.Right; m_TMPText.alignment = TextAlignmentOptions.MidlineRight;
break; break;
case TextAnchor.UpperCenter: case TextAnchor.UpperCenter:
m_TMPText.alignment = TextAlignmentOptions.Top; m_TMPText.alignment = TextAlignmentOptions.Top;
@@ -205,8 +205,7 @@ namespace XCharts.Runtime
m_TMPText.alignment = TextAlignmentOptions.TopRight; m_TMPText.alignment = TextAlignmentOptions.TopRight;
break; break;
default: default:
m_TMPText.alignment = TextAlignmentOptions.Center; m_TMPText.alignment = TextAlignmentOptions.Midline;
m_TextAlignment = TextAnchor.MiddleCenter;
break; break;
} }
#else #else

View File

@@ -14,7 +14,7 @@ namespace XCharts.Runtime
{ {
[SerializeField] private bool m_DebugModel = false; [SerializeField] private bool m_DebugModel = false;
[SerializeField] protected UIComponentTheme m_Theme = new UIComponentTheme(); [SerializeField] protected UIComponentTheme m_Theme = new UIComponentTheme();
[SerializeField] private Background m_Background = new Background() { show = true }; [SerializeField] protected Background m_Background = new Background() { show = true };
protected bool m_DataDirty; protected bool m_DataDirty;
private ThemeType m_CheckTheme = 0; private ThemeType m_CheckTheme = 0;

View File

@@ -9,7 +9,8 @@ namespace XCharts.Runtime
{ {
public static void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness, public static void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
Color32 emptyColor, Color32 backgroundColor, Color32 borderColor, float smoothness, Vector3 startPos) Color32 emptyColor, Color32 backgroundColor, Color32 borderColor, float smoothness,
Vector3 startPos, float symbolSize2 = 0f)
{ {
switch (type) switch (type)
{ {
@@ -22,13 +23,14 @@ namespace XCharts.Runtime
} }
else else
{ {
if (tickness > 0) if (tickness > 0 && !ChartHelper.IsClearColor(borderColor))
UGL.DrawDoughnut(vh, pos, symbolSize, symbolSize + tickness, borderColor, borderColor, color, smoothness); UGL.DrawDoughnut(vh, pos, symbolSize, symbolSize + tickness, borderColor, borderColor, color, smoothness);
else else
UGL.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness); UGL.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness);
} }
break; break;
case SymbolType.EmptyCircle: case SymbolType.EmptyCircle:
if (tickness == 0) tickness = 4f;
if (gap > 0) if (gap > 0)
{ {
UGL.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness); UGL.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness);
@@ -40,6 +42,12 @@ namespace XCharts.Runtime
} }
break; break;
case SymbolType.Rect: case SymbolType.Rect:
if (symbolSize2 > 0 && symbolSize2 != symbolSize)
{
UGL.DrawRectangle(vh, pos, symbolSize, symbolSize2, color, toColor);
}
else
{
if (gap > 0) if (gap > 0)
{ {
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor); UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
@@ -55,8 +63,10 @@ namespace XCharts.Runtime
else else
UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true); UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true);
} }
}
break; break;
case SymbolType.EmptyRect: case SymbolType.EmptyRect:
if (tickness == 0) tickness = 4f;
if (gap > 0) if (gap > 0)
{ {
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor); UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
@@ -75,6 +85,7 @@ namespace XCharts.Runtime
} }
if (type == SymbolType.EmptyTriangle) if (type == SymbolType.EmptyTriangle)
{ {
if (tickness == 0) tickness = 4f;
UGL.DrawEmptyTriangle(vh, pos, symbolSize * 1.4f, tickness * 2f, color, emptyColor); UGL.DrawEmptyTriangle(vh, pos, symbolSize * 1.4f, tickness * 2f, color, emptyColor);
} }
else else
@@ -92,6 +103,7 @@ namespace XCharts.Runtime
} }
if (type == SymbolType.EmptyDiamond) if (type == SymbolType.EmptyDiamond)
{ {
if (tickness == 0) tickness = 4f;
UGL.DrawEmptyDiamond(vh, pos, xRadius, yRadius, tickness, color, emptyColor); UGL.DrawEmptyDiamond(vh, pos, xRadius, yRadius, tickness, color, emptyColor);
} }
else else
@@ -124,6 +136,7 @@ namespace XCharts.Runtime
arrowOffset, arrowDent, color); arrowOffset, arrowDent, color);
if (type == SymbolType.EmptyArrow) if (type == SymbolType.EmptyArrow)
{ {
if (tickness == 0) tickness = 4f;
arrowWidth = (symbolSize - tickness) * 2; arrowWidth = (symbolSize - tickness) * 2;
arrowHeight = arrowWidth * 1.5f; arrowHeight = arrowWidth * 1.5f;
arrowOffset = 0; arrowOffset = 0;

View File

@@ -156,6 +156,21 @@ namespace XCharts.Runtime
} }
} }
public static void DestoryGameObjectByMatch(Transform parent, List<string> children)
{
if (parent == null) return;
if (children == null || children.Count == 0) return;
var childCount = parent.childCount;
for (int i = childCount - 1; i >= 0; i--)
{
var go = parent.GetChild(i);
if (go != null && children.Contains(go.name))
{
GameObject.DestroyImmediate(go.gameObject, true);
}
}
}
public static void DestoryGameObject(GameObject go) public static void DestoryGameObject(GameObject go)
{ {
if (go != null) GameObject.DestroyImmediate(go, true); if (go != null) GameObject.DestroyImmediate(go, true);
@@ -189,6 +204,25 @@ namespace XCharts.Runtime
} }
} }
public static void RemoveTMPComponents(GameObject gameObject)
{
var coms = gameObject.GetComponents<Component>();
foreach (var com in coms)
{
if (com.GetType().FullName.Contains("TMPro"))
{
#if UNITY_EDITOR
if (!Application.isPlaying)
GameObject.DestroyImmediate(com as UnityEngine.Object);
else
GameObject.Destroy(com as UnityEngine.Object);
#else
GameObject.Destroy(com as UnityEngine.Object);
#endif
}
}
}
[System.Obsolete("Use EnsureComponent instead")] [System.Obsolete("Use EnsureComponent instead")]
public static T GetOrAddComponent<T>(Transform transform) where T : Component public static T GetOrAddComponent<T>(Transform transform) where T : Component
{ {
@@ -224,8 +258,14 @@ namespace XCharts.Runtime
{ {
if (gameObject.GetComponent<T>() == null) if (gameObject.GetComponent<T>() == null)
{ {
var com = gameObject.AddComponent<T>();
if (com == null)
{
RemoveTMPComponents(gameObject);
return gameObject.AddComponent<T>(); return gameObject.AddComponent<T>();
} }
return com;
}
else else
{ {
return gameObject.GetComponent<T>(); return gameObject.GetComponent<T>();
@@ -233,7 +273,7 @@ namespace XCharts.Runtime
} }
public static GameObject AddObject(string name, Transform parent, Vector2 anchorMin, public static GameObject AddObject(string name, Transform parent, Vector2 anchorMin,
Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, int replaceIndex = -1) Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, int replaceIndex = -1, List<string> cacheNames = null)
{ {
GameObject obj; GameObject obj;
if (parent.Find(name)) if (parent.Find(name))
@@ -267,6 +307,8 @@ namespace XCharts.Runtime
rect.anchorMax = anchorMax; rect.anchorMax = anchorMax;
rect.pivot = pivot; rect.pivot = pivot;
rect.anchoredPosition3D = Vector3.zero; rect.anchoredPosition3D = Vector3.zero;
if (cacheNames != null && !cacheNames.Contains(name)) cacheNames.Add(name);
return obj; return obj;
} }
@@ -297,7 +339,11 @@ namespace XCharts.Runtime
chartText.tmpText.fontStyle = textStyle.tmpFontStyle; chartText.tmpText.fontStyle = textStyle.tmpFontStyle;
chartText.tmpText.richText = true; chartText.tmpText.richText = true;
chartText.tmpText.raycastTarget = false; chartText.tmpText.raycastTarget = false;
#if UNITY_2023_2_OR_NEWER
chartText.tmpText.textWrappingMode = textStyle.autoWrap ? TextWrappingModes.Normal : TextWrappingModes.NoWrap;
#else
chartText.tmpText.enableWordWrapping = textStyle.autoWrap; chartText.tmpText.enableWordWrapping = textStyle.autoWrap;
#endif
#else #else
chartText.text = EnsureComponent<Text>(txtObj); chartText.text = EnsureComponent<Text>(txtObj);
chartText.text.font = textStyle.font == null ? theme.font : textStyle.font; chartText.text.font = textStyle.font == null ? theme.font : textStyle.font;
@@ -319,7 +365,7 @@ namespace XCharts.Runtime
chartText.SetActive(textStyle.show); chartText.SetActive(textStyle.show);
RectTransform rect = EnsureComponent<RectTransform>(txtObj); RectTransform rect = EnsureComponent<RectTransform>(txtObj);
rect.localPosition = Vector3.zero; rect.anchoredPosition3D = Vector3.zero;
rect.sizeDelta = sizeDelta; rect.sizeDelta = sizeDelta;
rect.anchorMin = anchorMin; rect.anchorMin = anchorMin;
rect.anchorMax = anchorMax; rect.anchorMax = anchorMax;
@@ -328,9 +374,9 @@ namespace XCharts.Runtime
} }
public static Painter AddPainterObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, public static Painter AddPainterObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax,
Vector2 pivot, Vector2 sizeDelta, HideFlags hideFlags, int siblingIndex) Vector2 pivot, Vector2 sizeDelta, HideFlags hideFlags, int siblingIndex, List<string> childNodeNames)
{ {
var painterObj = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); var painterObj = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta, -1, childNodeNames);
painterObj.hideFlags = hideFlags; painterObj.hideFlags = hideFlags;
painterObj.transform.SetSiblingIndex(siblingIndex); painterObj.transform.SetSiblingIndex(siblingIndex);
return ChartHelper.EnsureComponent<Painter>(painterObj); return ChartHelper.EnsureComponent<Painter>(painterObj);
@@ -422,16 +468,21 @@ namespace XCharts.Runtime
} }
public static ChartLabel AddChartLabel(string name, Transform parent, LabelStyle labelStyle, public static ChartLabel AddChartLabel(string name, Transform parent, LabelStyle labelStyle,
ComponentTheme theme, string content, Color autoColor, TextAnchor autoAlignment = TextAnchor.MiddleCenter) ComponentTheme theme, string content, Color autoColor, TextAnchor autoAlignment = TextAnchor.MiddleCenter,
bool isObjectAnchor = false)
{ {
Vector2 anchorMin, anchorMax, pivot; Vector2 anchorMin, anchorMax, pivot;
var sizeDelta = new Vector2(labelStyle.width, labelStyle.height); var sizeDelta = new Vector2(labelStyle.width, labelStyle.height);
var textStyle = labelStyle.textStyle; var textStyle = labelStyle.textStyle;
var alignment = textStyle.GetAlignment(autoAlignment); var alignment = isObjectAnchor ? autoAlignment : textStyle.GetAlignment(autoAlignment);
UpdateAnchorAndPivotByTextAlignment(alignment, out anchorMin, out anchorMax, out pivot); UpdateAnchorAndPivotByTextAlignment(alignment, out anchorMin, out anchorMax, out pivot);
var labelObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); var labelObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
//ChartHelper.RemoveComponent<Text>(labelObj); //ChartHelper.RemoveComponent<Text>(labelObj);
var label = EnsureComponent<ChartLabel>(labelObj); var label = EnsureComponent<ChartLabel>(labelObj);
if(isObjectAnchor)
{
UpdateAnchorAndPivotByTextAlignment(textStyle.GetAlignment(autoAlignment), out anchorMin, out anchorMax, out pivot);
}
label.text = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot, label.text = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot,
sizeDelta, textStyle, theme, autoColor, autoAlignment, label.text); sizeDelta, textStyle, theme, autoColor, autoAlignment, label.text);
label.icon = ChartHelper.AddIcon("Icon", label.gameObject.transform, labelStyle.icon); label.icon = ChartHelper.AddIcon("Icon", label.gameObject.transform, labelStyle.icon);
@@ -492,7 +543,7 @@ namespace XCharts.Runtime
return label; return label;
} }
private static void UpdateAnchorAndPivotByTextAlignment(TextAnchor alignment, out Vector2 anchorMin, out Vector2 anchorMax, public static void UpdateAnchorAndPivotByTextAlignment(TextAnchor alignment, out Vector2 anchorMin, out Vector2 anchorMax,
out Vector2 pivot) out Vector2 pivot)
{ {
switch (alignment) switch (alignment)
@@ -770,6 +821,14 @@ namespace XCharts.Runtime
return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate; return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate;
} }
public static float GetMaxCeilRate(float value, float ceilRate)
{
if (ceilRate == 0) return value;
var mod = value % ceilRate;
int rate = (int)(value / ceilRate);
return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate;
}
public static double GetMinCeilRate(double value, double ceilRate) public static double GetMinCeilRate(double value, double ceilRate)
{ {
if (ceilRate == 0) return value; if (ceilRate == 0) return value;
@@ -778,6 +837,14 @@ namespace XCharts.Runtime
return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate; return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate;
} }
public static float GetMinCeilRate(float value, float ceilRate)
{
if (ceilRate == 0) return value;
var mod = value % ceilRate;
int rate = (int)(value / ceilRate);
return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate;
}
public static double GetMinDivisibleValue(double min, double ceilRate) public static double GetMinDivisibleValue(double min, double ceilRate)
{ {
if (min == 0) return 0; if (min == 0) return 0;
@@ -997,12 +1064,12 @@ namespace XCharts.Runtime
{ {
var cam = canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : canvas.worldCamera; var cam = canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : canvas.worldCamera;
var pos = RectTransformUtility.WorldToScreenPoint(cam, rectTransform.position); var pos = RectTransformUtility.WorldToScreenPoint(cam, rectTransform.position);
var width = rectTransform.rect.width * canvas.scaleFactor; var width = (int)(rectTransform.rect.width * canvas.scaleFactor);
var height = rectTransform.rect.height * canvas.scaleFactor; var height = (int)(rectTransform.rect.height * canvas.scaleFactor);
var posX = pos.x + rectTransform.rect.xMin * canvas.scaleFactor; var posX = pos.x + rectTransform.rect.xMin * canvas.scaleFactor;
var posY = pos.y + rectTransform.rect.yMin * canvas.scaleFactor; var posY = pos.y + rectTransform.rect.yMin * canvas.scaleFactor;
var rect = new Rect(posX, posY, width, height); var rect = new Rect(posX, posY, width, height);
var tex = new Texture2D((int)width, (int)height, TextureFormat.RGBA32, false); var tex = new Texture2D(width, height, TextureFormat.ARGB32, false);
tex.ReadPixels(rect, 0, 0); tex.ReadPixels(rect, 0, 0);
tex.Apply(); tex.Apply();
byte[] bytes; byte[] bytes;

View File

@@ -11,43 +11,66 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public static class UIHelper public static class UIHelper
{ {
internal static void DrawBackground(VertexHelper vh, UIComponent component) public static void DrawBackground(VertexHelper vh, UIComponent component)
{ {
var background = component.background; var background = component.background;
var rect = component.graphRect;
if (background.imageWidth > 0 || background.imageHeight > 0)
{
if (background.imageWidth > 0)
{
rect.width = background.imageWidth;
rect.x = component.graphX + (component.graphWidth - background.imageWidth) / 2;
}
if (background.imageHeight > 0)
{
rect.height = background.imageHeight;
rect.y = component.graphY + (component.graphHeight - background.imageHeight) / 2;
}
}
background.rect = rect;
if (!background.show) if (!background.show)
return; return;
if (background.image != null) if (background.image != null)
return; return;
var backgroundColor = component.theme.GetBackgroundColor(background); var backgroundColor = component.theme.GetBackgroundColor(background);
DrawBackground(vh, background, backgroundColor);
}
public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2)
{
if (!background.show)
return;
if (background.image != null)
return;
var borderWidth = background.borderStyle.GetRuntimeBorderWidth(); var borderWidth = background.borderStyle.GetRuntimeBorderWidth();
var borderColor = background.borderStyle.GetRuntimeBorderColor(); var borderColor = background.borderStyle.GetRuntimeBorderColor();
var cornerRadius = background.borderStyle.GetRuntimeCornerRadius(); var cornerRadius = background.borderStyle.GetRuntimeCornerRadius();
UGL.DrawRoundRectangleWithBorder(vh, component.graphRect, backgroundColor, backgroundColor, cornerRadius, UGL.DrawRoundRectangleWithBorder(vh, background.rect, color, color, cornerRadius,
borderWidth, borderColor); borderWidth, borderColor, 0, smoothness);
} }
internal static void InitBackground(UIComponent table) internal static void InitBackground(UIComponent component)
{ {
if (table.background.show == false || if (component.background.show == false ||
(table.background.image == null && ChartHelper.IsClearColor(table.background.imageColor))) (component.background.image == null && ChartHelper.IsClearColor(component.background.imageColor)))
{ {
ChartHelper.DestoryGameObject(table.transform, "Background"); ChartHelper.DestoryGameObject(component.transform, "Background");
return; return;
} }
var sizeDelta = table.background.imageWidth > 0 && table.background.imageHeight > 0 ? var sizeDelta = component.background.imageWidth > 0 && component.background.imageHeight > 0 ?
new Vector2(table.background.imageWidth, table.background.imageHeight) : new Vector2(component.background.imageWidth, component.background.imageHeight) :
table.graphSizeDelta; component.graphSizeDelta;
var backgroundObj = ChartHelper.AddObject("Background", table.transform, table.graphMinAnchor, var backgroundObj = ChartHelper.AddObject("Background", component.transform, component.graphMinAnchor,
table.graphMaxAnchor, table.graphPivot, sizeDelta); component.graphMaxAnchor, component.graphPivot, sizeDelta);
backgroundObj.hideFlags = table.chartHideFlags; backgroundObj.hideFlags = component.chartHideFlags;
var backgroundImage = ChartHelper.EnsureComponent<Image>(backgroundObj); var backgroundImage = ChartHelper.EnsureComponent<Image>(backgroundObj);
ChartHelper.UpdateRectTransform(backgroundObj, table.graphMinAnchor, ChartHelper.UpdateRectTransform(backgroundObj, component.graphMinAnchor,
table.graphMaxAnchor, table.graphPivot, sizeDelta); component.graphMaxAnchor, component.graphPivot, sizeDelta);
ChartHelper.SetBackground(backgroundImage, table.background); ChartHelper.SetBackground(backgroundImage, component.background);
backgroundObj.transform.SetSiblingIndex(0); backgroundObj.transform.SetSiblingIndex(0);
backgroundObj.SetActive(table.background.show && table.background.image != null); backgroundObj.SetActive(component.background.show && component.background.image != null);
} }
} }
} }

View File

@@ -21,8 +21,8 @@ namespace XCharts.Runtime
[ExecuteInEditMode] [ExecuteInEditMode]
public static class XChartsMgr public static class XChartsMgr
{ {
public static readonly string version = "3.12.1"; public static readonly string version = "3.14.0";
public static readonly int versionDate = 20241201; public static readonly int versionDate = 20250315;
public static string fullVersion { get { return version + "-" + versionDate; } } public static string fullVersion { get { return version + "-" + versionDate; } }
internal static List<BaseChart> chartList = new List<BaseChart>(); internal static List<BaseChart> chartList = new List<BaseChart>();

View File

@@ -1,3 +1,5 @@
using UnityEngine;
namespace XCharts.Runtime namespace XCharts.Runtime
{ {
[System.Serializable] [System.Serializable]
@@ -11,6 +13,8 @@ namespace XCharts.Runtime
[SerieDataExtraField("m_Ignore")] [SerieDataExtraField("m_Ignore")]
public class Bar : Serie, INeedSerieContainer public class Bar : Serie, INeedSerieContainer
{ {
public override bool useSortData { get { return realtimeSort; } }
public int containerIndex { get; internal set; } public int containerIndex { get; internal set; }
public int containterInstanceId { get; internal set; } public int containterInstanceId { get; internal set; }

View File

@@ -31,7 +31,7 @@ namespace XCharts.Runtime
foreach (var serieData in serie.data) foreach (var serieData in serie.data)
{ {
var symbol = SerieHelper.GetSerieSymbol(serie, serieData); var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize); var symbolSize = symbol.GetSize(serieData, chart.theme.serie.lineSymbolSize);
serieData.context.highlight = false; serieData.context.highlight = false;
serieData.interact.SetValue(ref needAnimation1, symbolSize); serieData.interact.SetValue(ref needAnimation1, symbolSize);
} }
@@ -125,16 +125,17 @@ namespace XCharts.Runtime
if (isStack) if (isStack)
SeriesHelper.UpdateStackDataList(chart.series, serie, null, m_StackSerieData); SeriesHelper.UpdateStackDataList(chart.series, serie, null, m_StackSerieData);
var barCount = chart.GetSerieBarRealCount<Bar>(); var barCount = chart.GetSerieBarRealCount<Bar>(-1);
var categoryWidth = m_AngleAxis.IsCategory() ? var categoryWidth = m_AngleAxis.IsCategory() ?
AxisHelper.GetDataWidth(m_AngleAxis, 360, datas.Count, null) : AxisHelper.GetDataWidth(m_AngleAxis, 360, datas.Count, null) :
AxisHelper.GetDataWidth(m_RadiusAxis, m_SeriePolar.context.radius, datas.Count, null); AxisHelper.GetDataWidth(m_RadiusAxis, m_SeriePolar.context.radius, datas.Count, null);
var barGap = chart.GetSerieBarGap<Bar>(); var barGap = chart.GetSerieBarGap<Bar>(-1);
var totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap, barCount); var totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap, barCount, -1);
var barWidth = serie.GetBarWidth(categoryWidth, barCount); var barWidth = serie.GetBarWidth(categoryWidth, barCount);
var offset = (categoryWidth - totalBarWidth) * 0.5f; var offset = (categoryWidth - totalBarWidth) * 0.5f;
var serieReadIndex = chart.GetSerieIndexIfStack<Bar>(serie); var serieReadIndex = chart.GetSerieIndexIfStack<Bar>(serie, -1);
float gap = serie.barGap == -1 ? offset : offset + chart.GetSerieTotalGap<Bar>(categoryWidth, barGap, serieReadIndex); float gap = serie.barGap == -1 ? offset :
offset + chart.GetSerieTotalGap<Bar>(categoryWidth, barGap, serieReadIndex, -1);
var areaColor = ColorUtil.clearColor32; var areaColor = ColorUtil.clearColor32;
var areaToColor = ColorUtil.clearColor32; var areaToColor = ColorUtil.clearColor32;

View File

@@ -161,9 +161,13 @@ namespace XCharts.Runtime
m_SerieGrid = chart.GetChartComponent<GridCoord>(axis.gridIndex); m_SerieGrid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
if (m_SerieGrid == null) if (m_SerieGrid == null)
return; return;
if (serie.useSortData)
{
SerieHelper.UpdateSerieRuntimeFilterData(serie);
}
var dataZoom = chart.GetDataZoomOfAxis(axis); var dataZoom = chart.GetDataZoomOfAxis(axis);
var showData = serie.GetDataList(dataZoom); var showData = serie.GetDataList(dataZoom, true);
if (showData.Count <= 0) if (showData.Count <= 0)
return; return;
@@ -176,15 +180,16 @@ namespace XCharts.Runtime
if (isStack) if (isStack)
SeriesHelper.UpdateStackDataList(chart.series, serie, dataZoom, m_StackSerieData); SeriesHelper.UpdateStackDataList(chart.series, serie, dataZoom, m_StackSerieData);
var barCount = chart.GetSerieBarRealCount<Bar>(); var barCount = chart.GetSerieBarRealCount<Bar>(m_SerieGrid.index);
float categoryWidth = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom); float categoryWidth = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
float relativedCategoryWidth = AxisHelper.GetDataWidth(relativedAxis, relativedAxisLength, showData.Count, dataZoom); float relativedCategoryWidth = AxisHelper.GetDataWidth(relativedAxis, relativedAxisLength, showData.Count, dataZoom);
float barGap = chart.GetSerieBarGap<Bar>(); float barGap = chart.GetSerieBarGap<Bar>(m_SerieGrid.index);
float totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap, barCount); float totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap, barCount, m_SerieGrid.index);
float barWidth = serie.GetBarWidth(categoryWidth, barCount); float barWidth = serie.GetBarWidth(categoryWidth, barCount);
float offset = (categoryWidth - totalBarWidth) * 0.5f; float offset = (categoryWidth - totalBarWidth) * 0.5f;
var serieReadIndex = chart.GetSerieIndexIfStack<Bar>(serie); var serieReadIndex = chart.GetSerieIndexIfStack<Bar>(serie, m_SerieGrid.index);
float gap = serie.barGap == -1 ? offset : offset + chart.GetSerieTotalGap<Bar>(categoryWidth, barGap, serieReadIndex); float gap = serie.barGap == -1 ? offset :
offset + chart.GetSerieTotalGap<Bar>(categoryWidth, barGap, serieReadIndex, m_SerieGrid.index);
int maxCount = serie.maxShow > 0 ? int maxCount = serie.maxShow > 0 ?
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow) : (serie.maxShow > showData.Count ? showData.Count : serie.maxShow) :
showData.Count; showData.Count;
@@ -236,7 +241,7 @@ namespace XCharts.Runtime
var barHig = 0f; var barHig = 0f;
if (isPercentStack) if (isPercentStack)
{ {
var valueTotal = chart.GetSerieSameStackTotalValue<Bar>(serie.stack, i); var valueTotal = chart.GetSerieSameStackTotalValue<Bar>(serie.stack, i, m_SerieGrid.index);
barHig = valueTotal != 0 ? (float)(relativedValue / valueTotal * relativedAxisLength) : 0; barHig = valueTotal != 0 ? (float)(relativedValue / valueTotal * relativedAxisLength) : 0;
} }
else else

View File

@@ -122,11 +122,11 @@ namespace XCharts.Runtime
var relativedAxisLength = isY ? m_SerieGrid.context.width : m_SerieGrid.context.height; var relativedAxisLength = isY ? m_SerieGrid.context.width : m_SerieGrid.context.height;
var axisXY = isY ? m_SerieGrid.context.y : m_SerieGrid.context.x; var axisXY = isY ? m_SerieGrid.context.y : m_SerieGrid.context.x;
var barCount = chart.GetSerieBarRealCount<SimplifiedBar>(); var barCount = chart.GetSerieBarRealCount<SimplifiedBar>(m_SerieGrid.index);
float categoryWidth = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom); float categoryWidth = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
float relativedCategoryWidth = AxisHelper.GetDataWidth(relativedAxis, relativedAxisLength, showData.Count, dataZoom); float relativedCategoryWidth = AxisHelper.GetDataWidth(relativedAxis, relativedAxisLength, showData.Count, dataZoom);
float barGap = chart.GetSerieBarGap<SimplifiedBar>(); float barGap = chart.GetSerieBarGap<SimplifiedBar>(m_SerieGrid.index);
float totalBarWidth = chart.GetSerieTotalWidth<SimplifiedBar>(categoryWidth, barGap, barCount); float totalBarWidth = chart.GetSerieTotalWidth<SimplifiedBar>(categoryWidth, barGap, barCount,m_SerieGrid.index);
float barWidth = serie.GetBarWidth(categoryWidth, barCount); float barWidth = serie.GetBarWidth(categoryWidth, barCount);
float offset = (categoryWidth - totalBarWidth) * 0.5f; float offset = (categoryWidth - totalBarWidth) * 0.5f;
float barGapWidth = barWidth + barWidth * barGap; float barGapWidth = barWidth + barWidth * barGap;

View File

@@ -33,7 +33,10 @@ namespace XCharts.Runtime
var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker); var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker);
var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
var isEmptyItemFormatter = string.IsNullOrEmpty(newItemFormatter);
if (isEmptyItemFormatter)
{
var param = serie.context.param; var param = serie.context.param;
param.serieName = serie.serieName; param.serieName = serie.serieName;
param.serieIndex = serie.index; param.serieIndex = serie.index;
@@ -68,6 +71,7 @@ namespace XCharts.Runtime
param.marker = newMarker; param.marker = newMarker;
param.itemFormatter = newItemFormatter; param.itemFormatter = newItemFormatter;
param.numericFormatter = newNumericFormatter; param.numericFormatter = newNumericFormatter;
param.isSecondaryMark = true;
param.columns.Clear(); param.columns.Clear();
param.columns.Add(param.marker); param.columns.Add(param.marker);
@@ -77,6 +81,30 @@ namespace XCharts.Runtime
paramList.Add(param); paramList.Add(param);
} }
} }
else
{
newItemFormatter = newItemFormatter.Replace("\\n", "\n");
var temp = newItemFormatter.Split('\n');
foreach (var str in temp)
{
var param = new SerieParams();
param.serieName = serie.serieName;
param.serieIndex = serie.index;
param.category = category;
param.serieData = serieData;
param.dataCount = serie.dataCount;
param.value = 0;
param.total = 0;
param.color = color;
param.marker = newMarker;
param.itemFormatter = str;
param.numericFormatter = newNumericFormatter;
param.isSecondaryMark = false;
param.columns.Clear();
paramList.Add(param);
}
}
}
private void DrawCandlestickSerie(VertexHelper vh, Candlestick serie) private void DrawCandlestickSerie(VertexHelper vh, Candlestick serie)
{ {

View File

@@ -33,7 +33,10 @@ namespace XCharts.Runtime
var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker); var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker);
var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
var isEmptyItemFormatter = string.IsNullOrEmpty(newItemFormatter);
if (isEmptyItemFormatter)
{
var param = serie.context.param; var param = serie.context.param;
param.serieName = serie.serieName; param.serieName = serie.serieName;
param.serieIndex = serie.index; param.serieIndex = serie.index;
@@ -68,6 +71,7 @@ namespace XCharts.Runtime
param.marker = newMarker; param.marker = newMarker;
param.itemFormatter = newItemFormatter; param.itemFormatter = newItemFormatter;
param.numericFormatter = newNumericFormatter; param.numericFormatter = newNumericFormatter;
param.isSecondaryMark = true;
param.columns.Clear(); param.columns.Clear();
param.columns.Add(param.marker); param.columns.Add(param.marker);
@@ -77,6 +81,30 @@ namespace XCharts.Runtime
paramList.Add(param); paramList.Add(param);
} }
} }
else
{
newItemFormatter = newItemFormatter.Replace("\\n", "\n");
var temp = newItemFormatter.Split('\n');
foreach (var str in temp)
{
var param = new SerieParams();
param.serieName = serie.serieName;
param.serieIndex = serie.index;
param.category = category;
param.serieData = serieData;
param.dataCount = serie.dataCount;
param.value = 0;
param.total = 0;
param.color = color;
param.marker = newMarker;
param.itemFormatter = str;
param.numericFormatter = newNumericFormatter;
param.isSecondaryMark = false;
param.columns.Clear();
paramList.Add(param);
}
}
}
private void DrawCandlestickSerie(VertexHelper vh, SimplifiedCandlestick serie) private void DrawCandlestickSerie(VertexHelper vh, SimplifiedCandlestick serie)
{ {

View File

@@ -31,7 +31,7 @@ namespace XCharts.Runtime
foreach (var serieData in serie.data) foreach (var serieData in serie.data)
{ {
var symbol = SerieHelper.GetSerieSymbol(serie, serieData); var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize); var symbolSize = symbol.GetSize(serieData, chart.theme.serie.lineSymbolSize);
serieData.context.highlight = false; serieData.context.highlight = false;
serieData.interact.SetValue(ref needAnimation1, symbolSize); serieData.interact.SetValue(ref needAnimation1, symbolSize);
} }

View File

@@ -59,17 +59,28 @@ namespace XCharts.Runtime
var dimension = VisualMapHelper.GetDimension(visualMap, defaultDimension); var dimension = VisualMapHelper.GetDimension(visualMap, defaultDimension);
title = serie.serieName; title = serie.serieName;
itemFormatter = SerieHelper.GetItemFormatter(serie, null, itemFormatter);
numericFormatter = SerieHelper.GetNumericFormatter(serie, null, numericFormatter);
marker = SerieHelper.GetItemMarker(serie, null, marker);
var color = visualMap.GetColor(value);
if (itemFormatter == null) itemFormatter = "";
itemFormatter = itemFormatter.Replace("\\n", "\n");
var temp = itemFormatter.Split('\n');
for (int i = 0; i < temp.Length; i++)
{
var formatter = temp[i];
var param = i == 0 ? serie.context.param : new SerieParams();
var param = serie.context.param;
param.serieName = serie.serieName; param.serieName = serie.serieName;
param.serieIndex = serie.index; param.serieIndex = serie.index;
param.dimension = dimension; param.dimension = dimension;
param.dataCount = serie.dataCount; param.dataCount = serie.dataCount;
param.serieData = null; param.serieData = null;
param.color = visualMap.GetColor(value); param.color = color;
param.marker = SerieHelper.GetItemMarker(serie, null, marker); param.marker = marker;
param.itemFormatter = SerieHelper.GetItemFormatter(serie, null, itemFormatter); param.itemFormatter = formatter;
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, null, numericFormatter); param.numericFormatter = numericFormatter;
param.columns.Clear(); param.columns.Clear();
param.columns.Add(param.marker); param.columns.Add(param.marker);
@@ -78,6 +89,7 @@ namespace XCharts.Runtime
paramList.Add(param); paramList.Add(param);
} }
}
else else
{ {
if (dataIndex < 0) if (dataIndex < 0)
@@ -96,17 +108,27 @@ namespace XCharts.Runtime
category = xAxis.GetData((int)serieData.GetData(0)); category = xAxis.GetData((int)serieData.GetData(0));
} }
title = serie.serieName; title = serie.serieName;
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
marker = SerieHelper.GetItemMarker(serie, serieData, marker);
if (itemFormatter == null) itemFormatter = "";
itemFormatter = itemFormatter.Replace("\\n", "\n");
var temp = itemFormatter.Split('\n');
for (int i = 0; i < temp.Length; i++)
{
var formatter = temp[i];
var param = i == 0 ? serie.context.param : new SerieParams();
var param = serie.context.param;
param.serieName = serie.serieName; param.serieName = serie.serieName;
param.serieIndex = serie.index; param.serieIndex = serie.index;
param.dimension = dimension; param.dimension = dimension;
param.dataCount = serie.dataCount; param.dataCount = serie.dataCount;
param.serieData = serieData; param.serieData = serieData;
param.color = serieData.context.color; param.color = serieData.context.color;
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.marker = marker;
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); param.itemFormatter = formatter;
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); param.numericFormatter = numericFormatter;
param.columns.Clear(); param.columns.Clear();
param.columns.Add(param.marker); param.columns.Add(param.marker);
@@ -116,6 +138,7 @@ namespace XCharts.Runtime
paramList.Add(param); paramList.Add(param);
} }
} }
}
public override void UpdateSerieContext() public override void UpdateSerieContext()
{ {
@@ -303,7 +326,7 @@ namespace XCharts.Runtime
var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serie.context.colorIndex, state); var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serie.context.colorIndex, state);
serieData.context.rect = new Rect(pos.x - symbolSize / 2, pos.y - symbolSize / 2, symbolSize, symbolSize); serieData.context.rect = new Rect(pos.x - symbolSize / 2, pos.y - symbolSize / 2, symbolSize, symbolSize);
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
color, color, emptyColor, borderColor, symbol.gap, cornerRadius); color, color, emptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
} }
if (visualMap.hoverLink && highlight && emphasisStyle != null && if (visualMap.hoverLink && highlight && emphasisStyle != null &&
@@ -461,7 +484,7 @@ namespace XCharts.Runtime
else else
{ {
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
color, color, emptyColor, borderColor, symbol.gap, cornerRadius); color, color, emptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
} }
if (visualMap.hoverLink && highlight && emphasisStyle != null && if (visualMap.hoverLink && highlight && emphasisStyle != null &&

View File

@@ -31,7 +31,7 @@ namespace XCharts.Runtime
foreach (var serieData in serie.data) foreach (var serieData in serie.data)
{ {
var symbol = SerieHelper.GetSerieSymbol(serie, serieData); var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize); var symbolSize = symbol.GetSize(serieData, chart.theme.serie.lineSymbolSize);
serieData.context.highlight = false; serieData.context.highlight = false;
serieData.interact.SetValue(ref needAnimation1, symbolSize); serieData.interact.SetValue(ref needAnimation1, symbolSize);
} }
@@ -275,7 +275,7 @@ namespace XCharts.Runtime
symbolSize = serie.animation.GetSysmbolSize(symbolSize); symbolSize = serie.animation.GetSysmbolSize(symbolSize);
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.context.position, chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.context.position,
symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius); symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
} }
} }
} }

View File

@@ -50,7 +50,7 @@ namespace XCharts.Runtime
foreach (var serieData in serie.data) foreach (var serieData in serie.data)
{ {
var symbol = SerieHelper.GetSerieSymbol(serie, serieData); var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize); var symbolSize = symbol.GetSize(serieData, chart.theme.serie.lineSymbolSize);
serieData.context.highlight = false; serieData.context.highlight = false;
serieData.interact.SetValue(ref needAnimation1, symbolSize); serieData.interact.SetValue(ref needAnimation1, symbolSize);
} }

View File

@@ -59,6 +59,12 @@ namespace XCharts.Runtime
var colorIndex = serie.colorByData ? chart.GetLegendRealShowNameIndex(serieData.legendName) : serie.context.colorIndex; var colorIndex = serie.colorByData ? chart.GetLegendRealShowNameIndex(serieData.legendName) : serie.context.colorIndex;
SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal); SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal);
title = serieData.name; title = serieData.name;
itemFormatter = SerieHelper.GetItemFormatter(serie, null, itemFormatter);
numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
marker = SerieHelper.GetItemMarker(serie, serieData, marker);
if (string.IsNullOrEmpty(itemFormatter))
{
for (int i = 0; i < serieData.data.Count; i++) for (int i = 0; i < serieData.data.Count; i++)
{ {
var indicator = radar.GetIndicator(i); var indicator = radar.GetIndicator(i);
@@ -74,9 +80,9 @@ namespace XCharts.Runtime
param.total = indicator.max; param.total = indicator.max;
param.color = color; param.color = color;
param.category = radar.GetIndicatorName(i); param.category = radar.GetIndicatorName(i);
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.marker = marker;
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); param.itemFormatter = itemFormatter;
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); param.numericFormatter = numericFormatter;
param.columns.Clear(); param.columns.Clear();
param.columns.Add(param.marker); param.columns.Add(param.marker);
@@ -86,6 +92,32 @@ namespace XCharts.Runtime
paramList.Add(param); paramList.Add(param);
} }
} }
else
{
itemFormatter = itemFormatter.Replace("\\n", "\n");
var temp = itemFormatter.Split('\n');
for (int i = 0; i < temp.Length; i++)
{
var formatter = temp[i];
var param = i == 0 ? serie.context.param : new SerieParams();
param.serieName = serie.serieName;
param.serieIndex = serie.index;
param.dimension = i;
param.serieData = serieData;
param.dataCount = serie.dataCount;
param.value = serieData.GetData(i);
param.total = serie.yTotal;
param.color = color;
param.category = radar.GetIndicatorName(i);
param.marker = marker;
param.itemFormatter = formatter;
param.numericFormatter = numericFormatter;
param.columns.Clear();
paramList.Add(param);
}
}
}
public override void UpdateSerieContext() public override void UpdateSerieContext()
{ {
@@ -123,7 +155,7 @@ namespace XCharts.Runtime
{ {
var serieData = serie.data[i]; var serieData = serie.data[i];
var symbol = SerieHelper.GetSerieSymbol(serie, serieData); var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize); var symbolSize = symbol.GetSize(serieData, chart.theme.serie.lineSymbolSize);
if (m_LegendEnter) if (m_LegendEnter)
{ {
serieData.context.highlight = true; serieData.context.highlight = true;
@@ -345,7 +377,7 @@ namespace XCharts.Runtime
SerieHelper.GetItemColor(out symbolColor, out symbolToColor, out symbolEmptyColor, serie, serieData, chart.theme, colorIndex, serieState); SerieHelper.GetItemColor(out symbolColor, out symbolToColor, out symbolEmptyColor, serie, serieData, chart.theme, colorIndex, serieState);
SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, serieData, chart.theme, serieState); SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, serieData, chart.theme, serieState);
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, point, symbolColor, chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, point, symbolColor,
symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius); symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
} }
} }
} }
@@ -495,7 +527,7 @@ namespace XCharts.Runtime
symbolToColor = m_RadarCoord.outRangeColor; symbolToColor = m_RadarCoord.outRangeColor;
} }
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor, chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor,
symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius); symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius, serie.symbol.size2);
} }
} }
if (!serie.animation.IsFinish()) if (!serie.animation.IsFinish())

View File

@@ -86,8 +86,17 @@ namespace XCharts.Runtime
return; return;
Color32 color, toColor; Color32 color, toColor;
SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, dataIndex); SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, dataIndex);
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
marker = SerieHelper.GetItemMarker(serie, serieData, marker);
var param = serie.context.param; if (itemFormatter == null) itemFormatter = "";
itemFormatter = itemFormatter.Replace("\\n", "\n");
var temp = itemFormatter.Split('\n');
for (int i = 0; i < temp.Length; i++)
{
var formatter = temp[i];
var param = i == 0 ? serie.context.param : new SerieParams();
param.serieName = serie.serieName; param.serieName = serie.serieName;
param.serieIndex = serie.index; param.serieIndex = serie.index;
param.category = category; param.category = category;
@@ -97,9 +106,9 @@ namespace XCharts.Runtime
param.value = serieData.GetData(0); param.value = serieData.GetData(0);
param.total = serieData.GetData(1); param.total = serieData.GetData(1);
param.color = color; param.color = color;
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.marker = marker;
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); param.itemFormatter = formatter;
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); param.numericFormatter = numericFormatter;
param.columns.Clear(); param.columns.Clear();
param.columns.Add(param.marker); param.columns.Add(param.marker);
@@ -108,6 +117,7 @@ namespace XCharts.Runtime
paramList.Add(param); paramList.Add(param);
} }
}
private Vector3 GetLabelLineEndPosition(Serie serie, SerieData serieData, LabelLine labelLine) private Vector3 GetLabelLineEndPosition(Serie serie, SerieData serieData, LabelLine labelLine)
{ {

View File

@@ -29,17 +29,29 @@ namespace XCharts.Runtime
title = serie.serieName; title = serie.serieName;
var param = serie.context.param; itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
marker = SerieHelper.GetItemMarker(serie, serieData, marker);
var color = chart.GetMarkColor(serie, serieData);
if (itemFormatter == null) itemFormatter = "";
itemFormatter = itemFormatter.Replace("\\n", "\n");
var temp = itemFormatter.Split('\n');
for (int i = 0; i < temp.Length; i++)
{
var formatter = temp[i];
var param = i == 0 ? serie.context.param : new SerieParams();
param.serieName = serie.serieName; param.serieName = serie.serieName;
param.serieIndex = serie.index; param.serieIndex = serie.index;
param.category = category; param.category = category;
param.dimension = 1; param.dimension = 1;
param.dataCount = serie.dataCount; param.dataCount = serie.dataCount;
param.serieData = serieData; param.serieData = serieData;
param.color = chart.GetMarkColor(serie, serieData); param.color = color;
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.marker = marker;
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); param.itemFormatter = formatter;
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); param.numericFormatter = numericFormatter;
param.columns.Clear(); param.columns.Clear();
param.columns.Add(param.marker); param.columns.Add(param.marker);
@@ -49,6 +61,7 @@ namespace XCharts.Runtime
paramList.Add(param); paramList.Add(param);
} }
}
public override void DrawSerie(VertexHelper vh) public override void DrawSerie(VertexHelper vh)
{ {

View File

@@ -305,6 +305,7 @@ namespace XCharts.Runtime
[SerializeField] private float m_Top; [SerializeField] private float m_Top;
[SerializeField] private float m_Bottom; [SerializeField] private float m_Bottom;
[SerializeField] private bool m_InsertDataToHead; [SerializeField] private bool m_InsertDataToHead;
[SerializeField][Since("v3.14.0")] private bool m_RealtimeSort = false;
[SerializeField] private LineStyle m_LineStyle = new LineStyle(); [SerializeField] private LineStyle m_LineStyle = new LineStyle();
[SerializeField] private SerieSymbol m_Symbol = new SerieSymbol(); [SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
@@ -983,6 +984,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_MinShowLabelValue, value)) { SetVerticesDirty(); } } set { if (PropertyUtil.SetStruct(ref m_MinShowLabelValue, value)) { SetVerticesDirty(); } }
} }
/// <summary> /// <summary>
/// Whether to enable realtime sorting, which is used for bar-racing effect. Currently only available in Bar.
/// ||是否开启实时排序用来实现动态排序图效果。目前仅在Bar中生效。
/// </summary>
public bool realtimeSort
{
get { return m_RealtimeSort; }
set { if (PropertyUtil.SetStruct(ref m_RealtimeSort, value)) SetVerticesDirty(); }
}
/// <summary>
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。 /// 系列中的数据内容数组。SerieData可以设置1到n维数据。
/// </summary> /// </summary>
public List<SerieData> data { get { return m_Data; } } public List<SerieData> data { get { return m_Data; } }
@@ -1740,7 +1750,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
/// <param name="dataZoom"></param> /// <param name="dataZoom"></param>
/// <returns></returns> /// <returns></returns>
public List<SerieData> GetDataList(DataZoom dataZoom = null) public List<SerieData> GetDataList(DataZoom dataZoom = null, bool sorted = false)
{ {
if (dataZoom != null && dataZoom.enable && if (dataZoom != null && dataZoom.enable &&
(dataZoom.IsContainsXAxis(xAxisIndex) || dataZoom.IsContainsYAxis(yAxisIndex))) (dataZoom.IsContainsXAxis(xAxisIndex) || dataZoom.IsContainsYAxis(yAxisIndex)))
@@ -1750,7 +1760,7 @@ namespace XCharts.Runtime
} }
else else
{ {
return useSortData && context.sortedData.Count > 0 ? context.sortedData : m_Data; return useSortData && sorted && context.sortedData.Count > 0 ? context.sortedData : m_Data;
} }
} }
@@ -2019,6 +2029,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationFadeIn() public void AnimationFadeIn()
{ {
if (dataCount <= 0) return;
ResetInteract(); ResetInteract();
if (animation.enable) animation.FadeIn(); if (animation.enable) animation.FadeIn();
SetVerticesDirty(); SetVerticesDirty();
@@ -2029,6 +2040,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationFadeOut() public void AnimationFadeOut()
{ {
if (dataCount <= 0) return;
ResetInteract(); ResetInteract();
if (animation.enable) animation.FadeOut(); if (animation.enable) animation.FadeOut();
SetVerticesDirty(); SetVerticesDirty();
@@ -2039,6 +2051,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationPause() public void AnimationPause()
{ {
if (dataCount <= 0) return;
if (animation.enable) animation.Pause(); if (animation.enable) animation.Pause();
SetVerticesDirty(); SetVerticesDirty();
} }
@@ -2048,6 +2061,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationResume() public void AnimationResume()
{ {
if (dataCount <= 0) return;
if (animation.enable) animation.Resume(); if (animation.enable) animation.Resume();
SetVerticesDirty(); SetVerticesDirty();
} }
@@ -2057,6 +2071,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationReset() public void AnimationReset()
{ {
if (dataCount <= 0) return;
if (animation.enable) animation.Reset(); if (animation.enable) animation.Reset();
SetVerticesDirty(); SetVerticesDirty();
} }
@@ -2066,6 +2081,7 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public void AnimationRestart() public void AnimationRestart()
{ {
if (dataCount <= 0) return;
if (animation.enable) animation.Restart(); if (animation.enable) animation.Restart();
SetVerticesDirty(); SetVerticesDirty();
} }

View File

@@ -59,6 +59,7 @@ namespace XCharts.Runtime
public ChartLabel labelObject { get; set; } public ChartLabel labelObject { get; set; }
public ChartLabel titleObject { get; set; } public ChartLabel titleObject { get; set; }
public int sortIndex { get; set; }
private bool m_Show = true; private bool m_Show = true;
/// <summary> /// <summary>
@@ -758,17 +759,18 @@ namespace XCharts.Runtime
return 0; return 0;
} }
public void SetLabelActive(bool flag) public void SetLabelActive(bool flag, bool force = false)
{ {
if (labelObject != null) labelObject.SetActive(flag); if (labelObject != null) labelObject.SetActive(flag, force);
foreach (var labelObject in context.dataLabels) foreach (var labelObject in context.dataLabels)
{ {
labelObject.SetActive(false); labelObject.SetActive(flag, force);
} }
} }
public void SetIconActive(bool flag) public void SetIconActive(bool flag)
{ {
if (labelObject != null) labelObject.SetActive(flag); if (labelObject != null) labelObject.SetIconActive(flag);
} }
public void SetPolygon(params Vector2[] points) public void SetPolygon(params Vector2[] points)

View File

@@ -314,7 +314,7 @@ namespace XCharts.Runtime
} }
var objName = s_SerieRootObjectName + "_" + serie.index; var objName = s_SerieRootObjectName + "_" + serie.index;
m_SerieRoot = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor, m_SerieRoot = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
m_SerieRoot.hideFlags = chart.chartHideFlags; m_SerieRoot.hideFlags = chart.chartHideFlags;
ChartHelper.SetActive(m_SerieRoot, true); ChartHelper.SetActive(m_SerieRoot, true);
ChartHelper.HideAllObject(m_SerieRoot); ChartHelper.HideAllObject(m_SerieRoot);
@@ -497,7 +497,7 @@ namespace XCharts.Runtime
{ {
serieData.SetLabelActive(false); serieData.SetLabelActive(false);
continue; continue;
}; }
var currLabel = SerieHelper.GetSerieLabel(serie, serieData); var currLabel = SerieHelper.GetSerieLabel(serie, serieData);
var isIgnore = serie.IsIgnoreIndex(serieData.index, defaultDimension); var isIgnore = serie.IsIgnoreIndex(serieData.index, defaultDimension);
if (serie.show && if (serie.show &&
@@ -669,8 +669,14 @@ namespace XCharts.Runtime
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter); itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
if (serie.placeHolder || TooltipHelper.IsIgnoreFormatter(itemFormatter)) if (serie.placeHolder || TooltipHelper.IsIgnoreFormatter(itemFormatter))
return; return;
if (itemFormatter == null) itemFormatter = "";
var param = serie.context.param; var newItemFormatter = itemFormatter.Replace("\\n", "\n");
var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
var temp = newItemFormatter.Split('\n');
for (int i = 0; i < temp.Length; i++)
{
var formatter = temp[i];
var param = i == 0 ? serie.context.param : new SerieParams();
param.serieName = serie.serieName; param.serieName = serie.serieName;
param.serieIndex = serie.index; param.serieIndex = serie.index;
param.category = category; param.category = category;
@@ -682,8 +688,8 @@ namespace XCharts.Runtime
param.total = serie.yTotal; param.total = serie.yTotal;
param.color = chart.GetMarkColor(serie, serieData); param.color = chart.GetMarkColor(serie, serieData);
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
param.itemFormatter = itemFormatter; param.itemFormatter = formatter;
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); param.numericFormatter = newNumericFormatter;
param.columns.Clear(); param.columns.Clear();
param.columns.Add(param.marker); param.columns.Add(param.marker);
@@ -692,6 +698,7 @@ namespace XCharts.Runtime
paramList.Add(param); paramList.Add(param);
} }
}
protected void UpdateItemSerieParams(ref List<SerieParams> paramList, ref string title, protected void UpdateItemSerieParams(ref List<SerieParams> paramList, ref string title,
int dataIndex, string category, string marker, int dataIndex, string category, string marker,
@@ -721,7 +728,17 @@ namespace XCharts.Runtime
Color32 color, toColor; Color32 color, toColor;
SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal); SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal);
var param = serie.context.param;
if (itemFormatter == null) itemFormatter = "";
var newItemFormatter = itemFormatter.Replace("\\n", "\n");
var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
var temp = newItemFormatter.Split('\n');
var mark = SerieHelper.GetItemMarker(serie, serieData, marker);
var total = serie.multiDimensionLabel ? serieData.GetTotalData() : serie.GetDataTotal(defaultDimension);
for (int i = 0; i < temp.Length; i++)
{
var formatter = temp[i];
var param = i == 0 ? serie.context.param : new SerieParams();
param.serieName = serie.serieName; param.serieName = serie.serieName;
param.serieIndex = serie.index; param.serieIndex = serie.index;
@@ -731,11 +748,11 @@ namespace XCharts.Runtime
param.dataCount = serie.dataCount; param.dataCount = serie.dataCount;
param.value = serieData.GetData(param.dimension); param.value = serieData.GetData(param.dimension);
param.ignore = ignore; param.ignore = ignore;
param.total = serie.multiDimensionLabel ? serieData.GetTotalData() : serie.GetDataTotal(defaultDimension); param.total = total;
param.color = color; param.color = color;
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker); param.marker = mark;
param.itemFormatter = itemFormatter; param.itemFormatter = formatter;
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); param.numericFormatter = newNumericFormatter;
param.columns.Clear(); param.columns.Clear();
param.columns.Add(param.marker); param.columns.Add(param.marker);
@@ -745,6 +762,7 @@ namespace XCharts.Runtime
paramList.Add(param); paramList.Add(param);
} }
}
public void DrawLabelLineSymbol(VertexHelper vh, LabelLine labelLine, Vector3 startPos, Vector3 endPos, Color32 defaultColor) public void DrawLabelLineSymbol(VertexHelper vh, LabelLine labelLine, Vector3 startPos, Vector3 endPos, Color32 defaultColor)
{ {
@@ -762,7 +780,7 @@ namespace XCharts.Runtime
{ {
var color = symbol.GetColor(defaultColor); var color = symbol.GetColor(defaultColor);
chart.DrawSymbol(vh, symbol.type, symbol.size, 1, pos, chart.DrawSymbol(vh, symbol.type, symbol.size, 1, pos,
color, color, ColorUtil.clearColor32, color, symbol.gap, null); color, color, ColorUtil.clearColor32, color, symbol.gap, null, symbol.size2);
} }
public override void OnPointerDown(PointerEventData eventData) public override void OnPointerDown(PointerEventData eventData)

View File

@@ -705,7 +705,7 @@ namespace XCharts.Runtime
if (stateStyle == null) if (stateStyle == null)
{ {
var symbol = GetSerieSymbol(serie, serieData, SerieState.Normal); var symbol = GetSerieSymbol(serie, serieData, SerieState.Normal);
size = symbol.GetSize(serieData == null ? null : serieData.data, defaultSize); size = symbol.GetSize(serieData, defaultSize);
switch (state) switch (state)
{ {
case SerieState.Emphasis: case SerieState.Emphasis:
@@ -719,7 +719,7 @@ namespace XCharts.Runtime
else else
{ {
var symbol = stateStyle.symbol; var symbol = stateStyle.symbol;
size = symbol.GetSize(serieData == null ? null : serieData.data, defaultSize); size = symbol.GetSize(serieData, defaultSize);
} }
if (serieData != null && checkAnimation) if (serieData != null && checkAnimation)
{ {
@@ -955,6 +955,10 @@ namespace XCharts.Runtime
public static void UpdateSerieRuntimeFilterData(Serie serie, bool filterInvisible = true) public static void UpdateSerieRuntimeFilterData(Serie serie, bool filterInvisible = true)
{ {
var realtimeData = true;
var dataChangeDuration = serie.animation.GetChangeDuration();
var dataAddDuration = serie.animation.GetAdditionDuration();
var unscaledTime = serie.animation.unscaledTime;
serie.context.sortedData.Clear(); serie.context.sortedData.Clear();
foreach (var serieData in serie.data) foreach (var serieData in serie.data)
{ {
@@ -966,8 +970,12 @@ namespace XCharts.Runtime
case SerieDataSortType.Ascending: case SerieDataSortType.Ascending:
serie.context.sortedData.Sort(delegate (SerieData data1, SerieData data2) serie.context.sortedData.Sort(delegate (SerieData data1, SerieData data2)
{ {
var value1 = data1.GetData(1); var value1 = realtimeData ?
var value2 = data2.GetData(1); data1.GetCurrData(1, dataAddDuration, dataChangeDuration, false, 0, 0, unscaledTime) :
data1.GetData(1);
var value2 = realtimeData ?
data2.GetCurrData(1, dataAddDuration, dataChangeDuration, false, 0, 0, unscaledTime) :
data2.GetData(1);
if (value1 == value2) return 0; if (value1 == value2) return 0;
else if (value1 > value2) return 1; else if (value1 > value2) return 1;
else return -1; else return -1;
@@ -976,8 +984,12 @@ namespace XCharts.Runtime
case SerieDataSortType.Descending: case SerieDataSortType.Descending:
serie.context.sortedData.Sort(delegate (SerieData data1, SerieData data2) serie.context.sortedData.Sort(delegate (SerieData data1, SerieData data2)
{ {
var value1 = data1.GetData(1); var value1 = realtimeData ?
var value2 = data2.GetData(1); data1.GetCurrData(1, dataAddDuration, dataChangeDuration, false, 0, 0, unscaledTime) :
data1.GetData(1);
var value2 = realtimeData ?
data2.GetCurrData(1, dataAddDuration, dataChangeDuration, false, 0, 0, unscaledTime) :
data2.GetData(1);
if (value1 == value2) return 0; if (value1 == value2) return 0;
else if (value1 > value2) return -1; else if (value1 > value2) return -1;
else return 1; else return 1;
@@ -986,6 +998,10 @@ namespace XCharts.Runtime
case SerieDataSortType.None: case SerieDataSortType.None:
break; break;
} }
for (int i = 0; i < serie.context.sortedData.Count; i++)
{
serie.context.sortedData[i].sortIndex = i;
}
} }
public static T CloneSerie<T>(Serie serie) where T : Serie public static T CloneSerie<T>(Serie serie) where T : Serie

View File

@@ -10,6 +10,7 @@ namespace XCharts.Runtime
public int serieIndex; public int serieIndex;
public string serieName; public string serieName;
public string marker = "●"; public string marker = "●";
public bool isSecondaryMark;
public string category; public string category;
public int dimension; public int dimension;
public SerieData serieData; public SerieData serieData;

View File

@@ -7,6 +7,7 @@ namespace XCharts.Runtime
{ {
private static Dictionary<string, Color32> s_ColorCached = new Dictionary<string, Color32>(); private static Dictionary<string, Color32> s_ColorCached = new Dictionary<string, Color32>();
public static readonly Color32 clearColor32 = new Color32(0, 0, 0, 0); public static readonly Color32 clearColor32 = new Color32(0, 0, 0, 0);
public static readonly Color32 white = new Color32(255, 255, 255, 255);
public static readonly Vector2 zeroVector2 = Vector2.zero; public static readonly Vector2 zeroVector2 = Vector2.zero;
/// <summary> /// <summary>

View File

@@ -3,9 +3,9 @@
"displayName": "XCharts", "displayName": "XCharts",
"author": "monitor1394", "author": "monitor1394",
"license": "MIT", "license": "MIT",
"version": "3.12.1", "version": "3.14.0",
"date": "20241201", "date": "20250315",
"checkdate": "20241201", "checkdate": "20250315",
"unity": "2018.3", "unity": "2018.3",
"description": "A charting and data visualization library for Unity. Support line chart, bar chart, pie chart, radar chart, scatter chart, heatmap chart, ring chart, candlestick chart, polar chart and parallel coordinates.", "description": "A charting and data visualization library for Unity. Support line chart, bar chart, pie chart, radar chart, scatter chart, heatmap chart, ring chart, candlestick chart, polar chart and parallel coordinates.",
"keywords": [ "keywords": [