Compare commits

...

124 Commits

Author SHA1 Message Date
monitor1394
fdcefb48f6 优化DataZoom的缩放功能 2026-06-09 22:32:39 +08:00
monitor1394
986fe7e575 增加Tooltip通过TitleLabelStyleTextStyleAlignment设置标题的对齐方式 (#363) 2026-06-03 22:03:06 +08:00
monitor1394
12be0ef93b 优化图表性能 2026-05-28 23:24:42 +08:00
monitor1394
2688d93f17 优化DataZoomMarquee框选功能 2026-05-28 09:14:53 +08:00
monitor1394
b040f27b2c 增加DataZoomfilterAxisRange设置坐标轴的范围计算是否受DataZoom的影响 2026-05-26 08:46:49 +08:00
monitor1394
584ef9a834 优化DataZoomMarquee框选功能 2026-05-25 22:19:22 +08:00
monitor1394
b14a574ad6 优化DataZoomMarquee框选功能 2026-05-24 21:15:29 +08:00
monitor1394
9d982019dd 修复DataZoom内绘制的折线图可能会超出范围的问题 2026-05-23 22:51:15 +08:00
monitor1394
be07afeb69 修复Axisinverse没能正确反转的问题 2026-05-23 22:16:28 +08:00
monitor1394
4ad2b3268f 增加LabelStyleshowCondition,showFilter,showThreshold可控制label显示和隐藏 2026-05-23 17:07:00 +08:00
monitor1394
f7ccec87d9 增加LabelStyleminGap可避免label过于密集 2026-05-22 21:52:22 +08:00
monitor1394
9bca52fbfb 修复DataZoom点击时指示区域不准的问题 2026-05-20 23:09:51 +08:00
monitor1394
2ee94acd30 优化图表性能 2026-05-20 22:13:04 +08:00
monitor1394
10d67cff41 修复DataZoom点击时指示区域不准的问题 2026-05-17 22:52:05 +08:00
monitor1394
4120b61f2a 增加LegendWidthHeight可设置固定宽高 2026-05-17 18:47:47 +08:00
monitor1394
0174453b05 修复SerieEndLabelY轴是MinMax类型时显示的数值不对的问题 2026-05-17 18:37:47 +08:00
monitor1394
68cb18305d 修复Candlestick按昨收判断涨跌颜色,一字涨停/跌停显示不对的问题 (#362) 2026-05-17 18:28:03 +08:00
monitor1394
39514f82b3 修复Candlestick的涨停颜色不对的问题 (#362) 2026-05-16 22:33:40 +08:00
monitor1394
5f66391428 修复LegendBackground区域在Horizonal模式下不对的问题 2026-03-29 21:48:25 +08:00
monitor1394
99e56d238a 增加ChartJson导出导入 2026-03-25 22:46:26 +08:00
monitor1394
dcac0f9655 默认设置圆角 2026-03-10 09:27:13 +08:00
monitor1394
2bb56fcd28 修复SaveAsImage保存的图片在PC和手机上不一致的问题 2026-03-03 22:23:07 +08:00
monitor1394
7d4ba652ec 修复SaveAsImage保存的图片尺寸变大的问题 2026-02-28 21:56:35 +08:00
monitor1394
619246bee2 3.15.0 2026-02-27 21:14:53 +08:00
monitor1394
52b9b0a03a 增加SerieignoreZeroOccupy可设置0数据的Bar是否占位 (#286) 2026-02-26 22:31:50 +08:00
monitor1394
3301d5fd36 修复SaveAsImage被其他组件遮挡时无法正常保存的问题 (#337) 2026-02-26 21:53:29 +08:00
monitor1394
92abee1a6c 增加AxismainAxis参数设置主轴可控制柱图的朝向 (#331) 2026-02-26 08:47:51 +08:00
monitor1394
90e9187808 修复Pie的点击有时候不响应的问题 (#357) 2026-01-15 08:53:42 +08:00
monitor1394
b311d17d94 增加DataZoomminZoomRatio替换旧的minShowNum (#350) 2026-01-08 08:58:12 +08:00
monitor1394
880a6b1885 优化Candlestick对时间轴的支持 2025-11-05 23:05:15 +08:00
monitor1394
fb841a3498 修复AxisindicatorLabel无法隐藏的问题 2025-11-05 22:49:23 +08:00
monitor1394
ac41dd1d07 优化Candlestick对时间轴的支持 2025-11-05 08:55:02 +08:00
monitor1394
39cee1bd52 增加TooltipTitle可通过TitleLabelStylenumericFormatter格式化时间显示 (#353) 2025-11-03 07:41:41 +08:00
monitor1394
f1c9a3ac4b 增加ChartuseUtc参数设置显示时间是否用UTC时间 2025-10-31 08:39:29 +08:00
monitor1394
2cb82526bc 优化Candlestick对时间轴的支持 2025-10-30 22:48:36 +08:00
monitor1394
0499126e55 增加Scatterignore支持设置忽略数据 2025-10-30 22:46:53 +08:00
monitor1394
c2bafb8aa8 增加PiepieType支持实心饼图和线框柄图 (#349) 2025-10-22 09:06:28 +08:00
monitor1394
c83fe89a31 优化MarkLine的表现 2025-09-05 22:09:11 +08:00
monitor1394
dd473b7d29 增加AxisLinestartExtendLengthendExtendLength设置轴线的延长线 2025-09-01 23:05:49 +08:00
monitor1394
d1f424f3a1 修复SerieTitleStyle在数据变更时不及时刷新的问题 2025-08-27 09:10:58 +08:00
monitor1394
efbe16b804 修复TMP开启时Axis运行报错 2025-05-19 21:57:11 +08:00
monitor1394
2d2e45da80 修复TMP开启时Axis运行报错 2025-05-19 21:55:52 +08:00
monitor1394
06bd26dc5f 修复MarkArea指定yValuexValue时绘制区域不准确的问题 2025-04-25 22:42:11 +08:00
monitor1394
a0dba26318 重构Title相关代码 2025-04-17 22:10:47 +08:00
monitor1394
e124d38d3e 增加Bar支持通过VisualMap设置颜色 2025-04-15 23:11:05 +08:00
monitor1394
21ffcba0c0 增加AxisLabelshowZeroLabel设置是否显示0刻度 2025-04-15 22:51:59 +08:00
monitor1394
ccf815c853 优化AxisTime时间轴支持设置Custom和ceilRate 2025-04-07 22:30:17 +08:00
monitor1394
fc0451e535 update doc 2025-04-07 20:59:12 +08:00
monitor1394
b23c581b63 修复GridCoord在设置背景色且Serie开启Clip时会覆盖图表的问题 2025-04-07 11:16:33 +08:00
monitor1394
eafd7276c0 修复AxisTime时间轴无法显示大于2038的年份的问题 2025-04-07 10:03:19 +08:00
monitor1394
3818d1213e 修复AxisTime时间轴在有DataZoom缩放时文本显示异常的问题 2025-04-06 22:24:05 +08:00
monitor1394
85b92ca2cc 增加LegenditemInactiveOpacity可设置非激活状态时的颜色透明度 (#343) 2025-03-27 22:35:02 +08:00
monitor1394
546ff1f61a 增加AxisonLabelClick回调事件 2025-03-27 08:39:30 +08:00
monitor1394
da360693e6 增加AxisonLabelClick回调事件 2025-03-27 08:31:21 +08:00
monitor1394
ad3bc75d7c 重命名MarkLineType的None为Custom 2025-03-26 22:24:41 +08:00
monitor1394
0b218f6dfe 增加AnimationExchange排序交换动画 2025-03-26 08:28:27 +08:00
monitor1394
9e07617cc4 增加Commentlayer设置层级 2025-03-22 09:24:46 +08:00
monitor1394
8bc66ca30a 优化Comment坐标刷新 2025-03-21 21:39:12 +08:00
monitor1394
20da9dbe94 增加SerieLabelformatter支持{index}通配符 2025-03-21 08:44:33 +08:00
monitor1394
62f071e5a9 增加SerieLabelformatter支持{index}通配符 2025-03-19 23:03:11 +08:00
monitor1394
4c001c8130 增加Bar可添加TitleStyle组件支持 2025-03-18 23:10:52 +08:00
monitor1394
4ad4505720 增加Bar可添加TitleStyle组件支持 2025-03-18 08:18:22 +08:00
monitor1394
47caaa2113 增加LabelStylefixedXfixedY可固定label的坐标 2025-03-18 07:41:58 +08:00
monitor1394
2f8a1300d3 增加ItemStylebackgroundGap可设置数据项背景间隙 2025-03-18 07:37:15 +08:00
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
monitor1394
19744ec124 3.12.1 2024-12-01 10:22:23 +08:00
monitor1394
1bdb756ad1 修复Tooltip在图表设置其他锚点时手机上显示位置异常的问题 2024-11-30 23:48:53 +08:00
monitor1394
bc1a11c4e3 修复Tooltip在图表设置其他锚点时手机上显示位置异常的问题 2024-11-30 23:45:28 +08:00
monitor1394
6c42fe6399 优化性能 2024-11-27 23:24:09 +08:00
monitor1394
ad77a79308 修复Unity6的一些代码警告问题 2024-11-27 22:28:47 +08:00
monitor1394
d5647a448d 修复Tooltip在特殊情况下可能会超出屏幕显示不完整的问题 2024-11-26 23:18:49 +08:00
monitor1394
756df47fe3 修复UITable在拖拽时也会点选的问题 2024-11-25 08:39:48 +08:00
monitor1394
1dd31f747e 修复Time时间轴在开启Animation时动态变更效果异常的问题 2024-11-22 22:10:12 +08:00
monitor1394
6568595abb 优化Line在数据点过密时有更好的绘制效果 2024-11-18 23:14:51 +08:00
monitor1394
61fb717d20 修复Animation无法通过代码开启的问题 (#334) 2024-11-16 17:22:40 +08:00
monitor1394
0a923400b2 修复Animation无法通过代码开启的问题 2024-11-16 17:18:06 +08:00
monitor1394
7fb0765c6c 修复DataZoom的start和end在代码动态修改时图表不刷新的问题 2024-11-13 08:40:56 +08:00
monitor1394
e6c68be728 更新文档 2024-11-05 22:17:23 +08:00
monitor1394
fdc7b41e8e 修复Title设置隐藏后运行还显示的问题 2024-11-05 08:28:57 +08:00
monitor1394
45972a4cd9 更新文档 2024-11-01 08:22:36 +08:00
monitor1394
d0d25b0221 更新文档 2024-10-31 23:28:46 +08:00
monitor1394
143a037761 更新文档 2024-10-28 22:25:14 +08:00
monitor1394
dc254fb722 更新文档 2024-10-21 08:44:16 +08:00
monitor1394
b0d6bea256 更新文档 2024-10-19 23:23:38 +08:00
monitor1394
4f38b59288 3.12.0 2024-10-01 22:59:59 +08:00
149 changed files with 8469 additions and 1680 deletions

View File

@@ -3,7 +3,7 @@ sidebar_position: 41
slug: /api
---
# Chart API
# API
## All Class
@@ -13,6 +13,7 @@ slug: /api
- [AnimationAddition](#animationaddition)
- [AnimationChange](#animationchange)
- [AnimationEasing](#animationeasing)
- [AnimationExchange](#animationexchange)
- [AnimationFadeIn](#animationfadein)
- [AnimationFadeOut](#animationfadeout)
- [AnimationHiding](#animationhiding)
@@ -70,6 +71,7 @@ slug: /api
- [ColorUtil](#colorutil)
- [Comment](#comment)
- [CommentItem](#commentitem)
- [CommentLayer](#commentlayer)
- [CommentMarkStyle](#commentmarkstyle)
- [ComponentHandlerAttribute](#componenthandlerattribute)
- [ComponentHelper](#componenthelper)
@@ -157,6 +159,7 @@ slug: /api
- [MainComponentContext](#maincomponentcontext)
- [MainComponentHandler](#maincomponenthandler)
- [MainComponentHandler<T>](#maincomponenthandlert)
- [MainComponentHandler<Title>](#maincomponenthandlertitle)
- [MarkArea](#markarea)
- [MarkAreaData](#markareadata)
- [MarkAreaType](#markareatype)
@@ -179,6 +182,7 @@ slug: /api
- [ParallelCoordContext](#parallelcoordcontext)
- [Pie](#pie)
- [PieChart](#piechart)
- [PieType](#pietype)
- [PolarAxisTheme](#polaraxistheme)
- [PolarChart](#polarchart)
- [PolarCoord](#polarcoord)
@@ -255,6 +259,7 @@ slug: /api
- [ThemeStyle](#themestyle)
- [ThemeType](#themetype)
- [Title](#title)
- [TitleHandler](#titlehandler)
- [TitleStyle](#titlestyle)
- [TitleTheme](#titletheme)
- [Tooltip](#tooltip)
@@ -360,6 +365,14 @@ Options:
- `Linear`:
## AnimationExchange
class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
> Since `v3.15.0`
Data exchange animation. Generally used for animation of data sorting.
## AnimationFadeIn
class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
@@ -386,7 +399,7 @@ Data hiding animation.
## AnimationInfo
class in XCharts.Runtime / Subclasses: [AnimationFadeIn](#animationfadein),[AnimationFadeOut](#animationfadeout),[AnimationChange](#animationchange),[AnimationAddition](#animationaddition),[AnimationHiding](#animationhiding),[AnimationInteraction](#animationinteraction)
class in XCharts.Runtime / Subclasses: [AnimationFadeIn](#animationfadein),[AnimationFadeOut](#animationfadeout),[AnimationChange](#animationchange),[AnimationAddition](#animationaddition),[AnimationHiding](#animationhiding),[AnimationInteraction](#animationinteraction),[AnimationExchange](#animationexchange)
> Since `v3.8.0`
@@ -405,7 +418,7 @@ the delegate function of animation delay.
### AnimationInfo.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
@@ -432,6 +445,11 @@ the callback function of animation start.
public bool reverse
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
public void End()
@@ -526,7 +544,7 @@ public float GetWidth(float width)
class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
the animation of serie. support animation type: fadeIn, fadeOut, change, addition.
the animation of serie. support animation type: fadeIn, fadeOut, change, addition, exchange.
### AnimationStyle.addition
@@ -543,6 +561,11 @@ Update data animation configuration.
public bool enable
Whether to enable animation.
### AnimationStyle.exchange
public AnimationExchange exchange
Exchange animation configuration. Valid in sort bar chart.
### AnimationStyle.fadeIn
public AnimationFadeIn fadeIn
@@ -634,6 +657,10 @@ public int GetCurrIndex()
public float GetCurrRate()
### AnimationStyle.GetExchangeDuration
public float GetExchangeDuration()
### AnimationStyle.GetInteractionDuration
public float GetInteractionDuration()
@@ -784,6 +811,14 @@ class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) / Subc
The axis in rectangular coordinate.
### Axis.onLabelClick
public Action<int, string> onLabelClick
> Since `v3.15.0`
Callback function when click on the label. Parameters: labelIndex, labelName.
### Axis.AddData
public void AddData(string category)
@@ -883,7 +918,7 @@ public bool IsLog()
### Axis.IsNeedShowLabel
public bool IsNeedShowLabel(int index, int total = 0)
public bool IsNeedShowLabel(int index, int total = 0, string content = null)
### Axis.IsRight
@@ -1042,6 +1077,10 @@ public bool needAnimation
public List<string> runtimeData
the tick value of value axis.
### AxisContext.sortedDataIndices
public List<int> sortedDataIndices
## AxisHandler<T>
class in XCharts / Inherits from: [MainComponentHandler](#maincomponenthandler)
@@ -1050,6 +1089,14 @@ class in XCharts / Inherits from: [MainComponentHandler](#maincomponenthandler)
public T component
### AxisHandler<T>.DrawTop
// public override void DrawTop(VertexHelper vh)
### AxisHandler<T>.OnPointerClick
public override void OnPointerClick(PointerEventData eventData)
## AxisHelper
class in XCharts.Runtime
@@ -1088,7 +1135,7 @@ public static float GetAxisValueDistance(GridCoord grid, Axis axis, float scaleW
### AxisHelper.GetAxisValueLength
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value, float gap = 0)
获得数值value在坐标轴上对应的长度
### AxisHelper.GetAxisValuePosition
@@ -1170,12 +1217,12 @@ public void Copy(AxisLabel axisLabel)
### 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
public bool IsNeedShowLabel(int index, int total)
public bool IsNeedShowLabel(int index, int total, string content = null)
### AxisLabel.SetRelatedText
@@ -1362,6 +1409,11 @@ class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent)
Background component.
### Background.rect
public Rect rect
the rect of background.
### Background.SetDefaultValue
public override void SetDefaultValue()
@@ -1378,6 +1430,10 @@ public int containerIndex
public int containterInstanceId
### Bar.useSortData
public override bool useSortData
### Bar.AddDefaultSerie
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
@@ -1656,6 +1712,10 @@ Global parameter setting component.
public ThemeStyle theme
### BaseChart.topPainter
public Painter topPainter
### BaseChart.typeListForComponent
public Dictionary<Type, FieldInfo> typeListForComponent
@@ -1664,6 +1724,11 @@ public Dictionary<Type, FieldInfo> typeListForComponent
public Dictionary<Type, FieldInfo> typeListForSerie
### BaseChart.useUtc
public bool useUtc
Whether to use UTC time for the chart.
### BaseChart.AddChartComponent
public MainComponent AddChartComponent(Type type)
@@ -1920,6 +1985,10 @@ public Color32 GetLegendRealShowNameColor(string name)
public int GetLegendRealShowNameIndex(string name)
### BaseChart.GetMainAxis
public Axis GetMainAxis()
### BaseChart.GetMarkColor
public Color32 GetMarkColor(Serie serie, SerieData serieData)
@@ -1936,6 +2005,10 @@ public T GetOrAddChartComponent<T>() where T : MainComponent
public Painter GetPainter(int index)
### BaseChart.GetRealtimeSortSerie
public Serie GetRealtimeSortSerie(int gridIndex)
### BaseChart.GetSerie
public Serie GetSerie(int serieIndex)
@@ -1948,19 +2021,19 @@ public T GetSerie<T>(int serieIndex) where T : Serie
### BaseChart.GetSerieBarGap<T>
public float GetSerieBarGap<T>() where T : Serie
public float GetSerieBarGap<T>(int gridIndex) where T : Serie
### BaseChart.GetSerieBarRealCount<T>
public int GetSerieBarRealCount<T>() where T : Serie
public int GetSerieBarRealCount<T>(int gridIndex) where T : Serie
### 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>
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
@@ -1968,15 +2041,11 @@ public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double te
### 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>
public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount) where T : Serie
### BaseChart.GetTitlePosition
public Vector3 GetTitlePosition(Title title)
public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount, int gridIndex) where T : Serie
### BaseChart.GetVisualMapOfSerie
@@ -2002,6 +2071,10 @@ public bool HasChartComponent(Type type)
public bool HasChartComponent<T>()
### BaseChart.HasRealtimeSortSerie
public bool HasRealtimeSortSerie(int gridIndex)
### BaseChart.HasSerie
public bool HasSerie(Type type)
@@ -2347,12 +2420,16 @@ public void UpdateYAxisIcon(int index, Sprite icon, int yAxisIndex = 0)
## BaseGraph
class in XCharts.Runtime / Inherits from: [MaskableGraphic](https://docs.unity3d.com/ScriptReference/30_search.html?q=maskablegraphic),[IPointerDownHandler](https://docs.unity3d.com/ScriptReference/30_search.html?q=ipointerdownhandler),[IPointerUpHandler](https://docs.unity3d.com/ScriptReference/30_search.html?q=ipointeruphandler),[](#) / Subclasses: [BaseChart](#basechart),[UIComponent](#uicomponent)
class in XCharts.Runtime / Inherits from: [MaskableGraphic](https://docs.unity3d.com/ScriptReference/30_search.html?q=maskablegraphic),[IPointerDownHandler](https://docs.unity3d.com/ScriptReference/30_search.html?q=ipointerdownhandler),[IPointerUpHandler](https://docs.unity3d.com/ScriptReference/30_search.html?q=ipointeruphandler), / Subclasses: [BaseChart](#basechart),[UIComponent](#uicomponent)
### BaseGraph.chartHideFlags
public virtual HideFlags chartHideFlags
### BaseGraph.childrenNodeNames
public List<string> childrenNodeNames
### BaseGraph.clickPos
public Vector2 clickPos
@@ -2411,6 +2488,10 @@ The x of graph.
public float graphY
The y of graph.
### BaseGraph.isDragingClick
public bool isDragingClick
### BaseGraph.isPointerClick
public bool isPointerClick
@@ -2485,6 +2566,10 @@ public string warningInfo
public string CheckWarning()
检测警告信息。
### BaseGraph.GetTitlePosition
public Vector3 GetTitlePosition(Title title)
### BaseGraph.LocalPointToScreenPoint
public Vector2 LocalPointToScreenPoint(Vector2 localPoint)
@@ -2551,11 +2636,6 @@ public void RefreshAllComponent()
public virtual void RefreshGraph()
Redraw graph in next frame.
### BaseGraph.SaveAsImage
public void SaveAsImage(string imageType = "png", string savePath = "")
保存图表为图片。
### BaseGraph.ScreenPointToChartPoint
public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint)
@@ -2759,6 +2839,10 @@ public float GetRuntimeBorderWidth()
public float[] GetRuntimeCornerRadius()
### BorderStyle.IsCricle
public bool IsCricle()
## CalendarCoord
class in XCharts.Runtime / Inherits from: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer)
@@ -2809,6 +2893,14 @@ public static string ColorToStr(Color color)
public static string FloatToStr(double value, string numericFormatter = "F", int precision = 0)
### ChartCached.GetAxisLabelName
public static string GetAxisLabelName(int index)
### ChartCached.GetComponentObjectName
public static string GetComponentObjectName(MainComponent component)
### ChartCached.GetSerieLabelName
public static string GetSerieLabelName(string prefix, int i, int j)
@@ -2817,17 +2909,25 @@ public static string GetSerieLabelName(string prefix, int i, int j)
public static string GetString(string prefix, int suffix)
### ChartCached.GetTypeName
public static string GetTypeName(Type type)
### ChartCached.GetTypeName<T>
public static string GetTypeName<T>()
### ChartCached.IntToStr
public static string IntToStr(int value, string numericFormatter = "")
### ChartCached.NumberToDateStr
public static string NumberToDateStr(double timestamp, string formatter)
public static string NumberToDateStr(double timestamp, string formatter, bool local = false)
### ChartCached.NumberToDateTime
public static DateTime NumberToDateTime(double timestamp)
public static DateTime NumberToDateTime(double timestamp, bool local = false)
### ChartCached.NumberToStr
@@ -2893,7 +2993,8 @@ public static void DestoryGameObject(GameObject go)
### ChartHelper.DestoryGameObjectByMatch
public static void DestoryGameObjectByMatch(Transform parent, string containString)
public static void DestoryGameObjectByMatch(Transform parent, List<string> children)
### ChartHelper.DestroyAllChildren
@@ -2940,7 +3041,8 @@ public static Vector3 GetLastValue(List<Vector3> list)
### ChartHelper.GetMaxCeilRate
public static double GetMaxCeilRate(double value, double ceilRate)
public static float GetMaxCeilRate(float value, float ceilRate)
### ChartHelper.GetMaxDivisibleValue
@@ -2952,7 +3054,8 @@ public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE
### ChartHelper.GetMinCeilRate
public static double GetMinCeilRate(double value, double ceilRate)
public static float GetMinCeilRate(float value, float ceilRate)
### ChartHelper.GetMinDivisibleValue
@@ -3062,14 +3165,14 @@ public static List<string> ParseStringFromString(string jsonData)
public static void RemoveComponent<T>(GameObject gameObject)
### ChartHelper.RemoveTMPComponents
public static void RemoveTMPComponents(GameObject gameObject)
### ChartHelper.RotateRound
public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle)
### ChartHelper.SaveAsImage
public static Texture2D SaveAsImage(RectTransform rectTransform, Canvas canvas, string imageType = "png", string path = "")
### ChartHelper.SetActive
public static bool SetActive(Image image, bool active)
@@ -3129,6 +3232,10 @@ public float GetTextWidth()
public float GetWidth()
### ChartLabel.InRect
public bool InRect(Vector2 local)
### ChartLabel.IsActiveByScale
public bool IsActiveByScale()
@@ -3383,13 +3490,20 @@ Convert the html string to color.
class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent),[IPropertyChanged](#ipropertychanged)
comment of chart.
> Since `v3.15.0`
comment of chart. Used to annotate special information in the chart.
### Comment.items
public List<CommentItem> items
The items of comment.
### Comment.layer
public CommentLayer layer
The layer of comment.
### Comment.show
public bool show
@@ -3398,10 +3512,12 @@ Set this to false to prevent the comment from showing.
### Comment.GetLabelStyle
public LabelStyle GetLabelStyle(int index)
Get the label style of comment item.
### Comment.GetMarkStyle
public CommentMarkStyle GetMarkStyle(int index)
Get the mark style of comment item.
### Comment.OnChanged
@@ -3414,10 +3530,9 @@ class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
comment of chart.
### CommentItem.content
### CommentItem.labelObject
public string content
content of comment.
public ChartLabel labelObject
### CommentItem.markRect
@@ -3434,6 +3549,17 @@ the mark rect style.
public bool show
Set this to false to prevent this comment item from showing.
## CommentLayer
class in XCharts.Runtime
The layer of comment.
Options:
- `Lower`: The comment is display under the serie.
- `Upper`: The comment is display above the serie.
## CommentMarkStyle
class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
@@ -3719,17 +3845,17 @@ class in XCharts.Runtime
### DateTimeUtil.GetDateTime
public static DateTime GetDateTime(double timestamp, bool local = true)
public static DateTime GetDateTime(double timestamp, bool local = false)
### DateTimeUtil.GetDefaultDateTimeString
public static string GetDefaultDateTimeString(int timestamp, double range = 0)
public static string GetDefaultDateTimeString(double timestamp, double range = 0, bool local = false)
### DateTimeUtil.GetTimestamp
public static int GetTimestamp(DateTime time, bool local = false)
public static double GetTimestamp(DateTime time, bool local = false)
public static int GetTimestamp(string dateTime, bool local = false)
public static double GetTimestamp(string dateTime, bool local = false)
### DateTimeUtil.IsDateOrTimeRegex
@@ -3866,9 +3992,13 @@ public static bool NeedFormat(string content)
### 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
public static string TrimAndReplaceLine(string content)
@@ -4379,7 +4509,7 @@ public override void ClearData()
### Indicator.GetFormatterIndicatorContent
public string GetFormatterIndicatorContent(string indicatorName)
public string GetFormatterIndicatorContent(string indicatorName, int index, int totalIndex)
### Indicator.GetIndicator
@@ -4630,12 +4760,12 @@ public Color GetColor(Color defaultColor)
### 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
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue)
public string GetFormatterDateTime(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool local)
### LabelStyle.GetOffset
@@ -5317,6 +5447,10 @@ public float runtimeTop
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
public bool IsBottom()
@@ -5635,6 +5769,10 @@ class in XCharts.Runtime / Inherits from: [MainComponentHandler](#maincomponenth
public T component
## MainComponentHandler<Title>
class in / Subclasses: [TitleHandler](#titlehandler)
## MarkArea
class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent)
@@ -5729,15 +5867,15 @@ public double runtimeValue
class in XCharts.Runtime
标线类型
Mark line type.
Options:
- `None`: 标线类型
- `Min`: 最小值。
- `Max`: 最大值。
- `Average`: 平均值。
- `Median`: 中位数。
- `Custom`: Custom. You can customize the xy coordinates or values.
- `Min`: Minimum value.
- `Max`: Maximum value.
- `Average`: Average value.
- `Median`: Median.
## MarqueeStyle
@@ -5858,7 +5996,7 @@ class in / Subclasses: [XLog](#xlog)
## ObjectPool<T> where T
class in XCharts.Runtime / Inherits from: [new()](#new())
class in XCharts.Runtime / Inherits from: new()
### ObjectPool<T> where T.countActive
@@ -5930,10 +6068,6 @@ class in XCharts.Runtime / Inherits from: [MaskableGraphic](https://docs.unity3d
public int index
### Painter.onPopulateMesh
public Action<VertexHelper, Painter> onPopulateMesh
### Painter.type
public Type type
@@ -6068,6 +6202,15 @@ default label pie chart.
public void DefaultRadiusRosePieChart()
default rose pie chart.
## PieType
class in XCharts.Runtime
Options:
- `Solid`: solid pie chart - default fill style.
- `Wireframe`: wireframe pie chart - only show the outline wireframe.
## PolarAxisTheme
class in XCharts.Runtime / Inherits from: [BaseAxisTheme](#baseaxistheme)
@@ -6695,7 +6838,7 @@ public double GetData(int index, int dimension, DataZoom dataZoom = null)
### Serie.GetDataList
public List<SerieData> GetDataList(DataZoom dataZoom = null)
public List<SerieData> GetDataList(DataZoom dataZoom = null, bool sorted = false)
获得系列的数据列表
### Serie.GetDataTotal
@@ -7002,6 +7145,10 @@ public SelectStyle selectStyle
public bool show
[default:true] Whether the data item is showed.
### SerieData.sortIndex
public int sortIndex
### SerieData.state
public SerieState state
@@ -7085,12 +7232,12 @@ public double GetLastData()
### SerieData.GetMaxData
public double GetMaxData(bool inverse = false)
public double GetMaxData(bool inverse = false, int startDimensionIndex = 0)
the maxinum value.
### SerieData.GetMinData
public double GetMinData(bool inverse = false)
public double GetMinData(bool inverse = false, int startDimensionIndex = 0)
the mininum value.
### SerieData.GetMinMaxData
@@ -7148,7 +7295,7 @@ public void SetIconActive(bool flag)
### SerieData.SetLabelActive
public void SetLabelActive(bool flag)
public void SetLabelActive(bool flag, bool force = false)
### SerieData.SetPolygon
@@ -7201,6 +7348,10 @@ class in XCharts.Runtime
public void Reset()
### SerieDataContext.UpdateExchangePosition
public void UpdateExchangePosition(ref float x, ref float y, float totalTime)
## SerieDataExtraFieldAttribute
class in XCharts.Runtime / Inherits from: [Attribute](https://docs.unity3d.com/ScriptReference/30_search.html?q=attribute)
@@ -7629,6 +7780,10 @@ public override void RefreshLabelInternal()
public override void RefreshLabelNextFrame()
### SerieHandler<T>.RefreshTitleLabelInternal
public void RefreshTitleLabelInternal()
### SerieHandler<T>.RemoveComponent
public override void RemoveComponent()
@@ -7925,7 +8080,7 @@ class in XCharts.Runtime / Inherits from: [SymbolStyle](#symbolstyle),[ISerieDat
### SerieSymbol.GetSize
public float GetSize(List<double> data, float themeSize)
public float GetSize(SerieData serieData, float themeSize)
根据指定的sizeType获得标记的大小
### SerieSymbol.Reset
@@ -8549,6 +8704,30 @@ public override void ClearComponentDirty()
public void OnChanged()
## TitleHandler
class in XCharts.Runtime / Inherits from: [MainComponentHandler<Title>](#maincomponenthandlertitle)
### TitleHandler.AddSubTitleLabel
public static ChartLabel AddSubTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
### TitleHandler.AddTitleLabel
public static ChartLabel AddTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
### TitleHandler.AddTitleObject
public static GameObject AddTitleObject(BaseGraph graph, Title title, ComponentTheme componentTheme, int titleSiblingIndex, string objectName = null)
### TitleHandler.InitComponent
public override void InitComponent()
### TitleHandler.OnSerieDataUpdate
public override void OnSerieDataUpdate(int serieIndex)
## TitleStyle
class in XCharts.Runtime / Inherits from: [LabelStyle](#labelstyle),[ISerieDataComponent](#iseriedatacomponent),[ISerieComponent](#iseriecomponent)
@@ -8612,7 +8791,7 @@ Whether to show ignored data on tooltip.
### Tooltip.itemFormatter
public string itemFormatter
a string template formatter for a single Serie or data item content. Support for wrapping lines with \n. Template variables are {.}, {a}, {b}, {c}, {d}.<br/> {.} is the dot of the corresponding color of a Serie that is currently indicated or whose index is 0.<br/> {a} is the series name of the serie that is currently indicated or whose index is 0.<br/> {b} is the name of the data item serieData that is currently indicated or whose index is 0, or a category value (such as the X-axis of a line chart).<br/> {c} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0.<br/> {d} is the percentage value of Y-dimensions (dimesion is 1) from serie that is currently indicated or whose index is 0, with no % sign.<br/> {e} is the name of the data item serieData that is currently indicated or whose index is 0.<br/> {f} is sum of data.<br/> {y} is category value of y axis.<br/> {.1} represents a dot from serie corresponding color that specifies index as 1.<br/> 1 in {a1}, {b1}, {c1} represents a serie that specifies an index of 1.<br/> {c1:2} represents the third data from serie's current indication data item indexed to 1 (a data item has multiple data, index 2 represents the third data).<br/> {c1:2-2} represents the third data item from serie's third data item indexed to 1 (i.e., which data item must be specified to specify).<br/> {d1:2: F2} indicates that a formatted string with a value specified separately is F2 (numericFormatter is used when numericFormatter is not specified).<br/> {d:0.##} indicates that a formatted string with a value specified separately is 0.## (used for percentage, reserved 2 valid digits while avoiding the situation similar to "100.00%" when using f2 ).<br/> Example: "{a}, {c}", "{a1}, {c1: f1}", "{a1}, {c1:0: f1}", "{a1} : {c1:1-1: f1}"<br/>
a string template formatter for a single Serie or data item content. Support for wrapping lines with \n. Template variables are \{.\}, \{a\}, \{b\}, \{c\}, \{d\}.<br/> \{.\} is the dot of the corresponding color of a Serie that is currently indicated or whose index is 0.<br/> \{a\} is the series name of the serie that is currently indicated or whose index is 0.<br/> \{b\} is the name of the data item serieData that is currently indicated or whose index is 0, or a category value (such as the X-axis of a line chart).<br/> \{c\} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0.<br/> \{d\} is the percentage value of Y-dimensions (dimesion is 1) from serie that is currently indicated or whose index is 0, with no % sign.<br/> \{e\} is the name of the data item serieData that is currently indicated or whose index is 0.<br/> \{f\} is sum of data.<br/> \{y\} is category value of y axis.<br/> \{.1\} represents a dot from serie corresponding color that specifies index as 1.<br/> 1 in \{a1\}, \{b1\}, \{c1\} represents a serie that specifies an index of 1.<br/> \{c1:2\} represents the third data from serie's current indication data item indexed to 1 (a data item has multiple data, index 2 represents the third data).<br/> \{c1:2-2\} represents the third data item from serie's third data item indexed to 1 (i.e., which data item must be specified to specify).<br/> \{d1:2: F2\} indicates that a formatted string with a value specified separately is F2 (numericFormatter is used when numericFormatter is not specified).<br/> \{d:0.##\} indicates that a formatted string with a value specified separately is 0.## (used for percentage, reserved 2 valid digits while avoiding the situation similar to "100.00%" when using f2 ).<br/> Example: "\{a\}, \{c\}", "\{a1\}, \{c1: f1\}", "\{a1\}, \{c1:0: f1\}", "\{a1\} : \{c1:1-1: f1\}"<br/>
### Tooltip.marker
@@ -8662,7 +8841,7 @@ Whether to show the tooltip floating layer, whose default value is true. It shou
### Tooltip.titleFormatter
public string titleFormatter
String template formatter for tooltip title content. \n line wrapping is supported. The placeholder {i} can be set separately to indicate that title is ignored and not displayed. Template variables are {.}, {a}, {b}, {c}, {d}, {e}, {f}, and {g}. <br /> {.} is the dot of the corresponding color of serie currently indicated or index 0. <br /> {a} is the series name name of serie currently indicated or index 0. <br /> {b} is the name of the serie data item serieData currently indicated or index 0, or the category value (such as the X-axis of a line chart). <br /> {c} is the value of the serie y-dimension (dimesion is 1) currently indicated or index is 0. <br /> {d} is the serie y-dimensional (dimesion 1) percentage value of the currently indicated or index 0, note without the % sign. <br /> {e} is the name of the serie data item serieData currently indicated or whose index is 0. <br /> {h} is the hexadecimal color value of serieData for the serie data item currently indicated or index 0. <br /> {f} is the sum of data. <br /> {g} indicates the total number of data. <br /> {y} is category value of y axis. <br /> {.1} represents a dot of the corresponding color with serie specified as index 1. <br /> The 1 in {a1}, {b1}, {c1} represents serie where index is specified as 1. <br /> {c1:2} represents the third data of the current indicator data item in serie with index 1 (one data item has multiple data, index 2 represents the third data). <br /> {c1:2-2} represents the third data of serie third data item with index 1 (that is, the number of data items must be specified when specifying the number of data items). <br /> {d1:2:f2} indicates that a format string with a single value is f2 (numericFormatter is used if no value is specified). <br /> {d:0.##} indicates that the format string with a value specified alone is 0.## # (for percentages, preserving a 2-digit significant number while avoiding the "100.00%" situation with f2). <br /> example: "{a}, {c}", "{a1}, {c1: f1}", "{a1}, {c1:0: f1}", "{a1}, {c1:1-1: f1}"
String template formatter for tooltip title content. \n line wrapping is supported. The placeholder \{i\} can be set separately to indicate that title is ignored and not displayed. Template variables are \{.\}, \{a\}, \{b\}, \{c\}, \{d\}, \{e\}, \{f\}, and \{g\}. <br /> \{.\} is the dot of the corresponding color of serie currently indicated or index 0. <br /> \{a\} is the series name name of serie currently indicated or index 0. <br /> \{b\} is the name of the serie data item serieData currently indicated or index 0, or the category value (such as the X-axis of a line chart). <br /> \{c\} is the value of the serie y-dimension (dimesion is 1) currently indicated or index is 0. <br /> \{d\} is the serie y-dimensional (dimesion 1) percentage value of the currently indicated or index 0, note without the % sign. <br /> \{e\} is the name of the serie data item serieData currently indicated or whose index is 0. <br /> \{h\} is the hexadecimal color value of serieData for the serie data item currently indicated or index 0. <br /> \{f\} is the sum of data. <br /> \{g\} indicates the total number of data. <br /> \{y\} is category value of y axis. <br /> \{.1\} represents a dot of the corresponding color with serie specified as index 1. <br /> The 1 in \{a1\}, \{b1\}, \{c1\} represents serie where index is specified as 1. <br /> \{c1:2\} represents the third data of the current indicator data item in serie with index 1 (one data item has multiple data, index 2 represents the third data). <br /> \{c1:2-2\} represents the third data of serie third data item with index 1 (that is, the number of data items must be specified when specifying the number of data items). <br /> \{d1:2:f2\} indicates that a format string with a single value is f2 (numericFormatter is used if no value is specified). <br /> \{d:0.##\} indicates that the format string with a value specified alone is 0.## # (for percentages, preserving a 2-digit significant number while avoiding the "100.00%" situation with f2). <br /> example: "\{a\}, \{c\}", "\{a1\}, \{c1: f1\}", "\{a1\}, \{c1:0: f1\}", "\{a1\}, \{c1:1-1: f1\}"
### Tooltip.AddSerieDataIndex
@@ -8722,11 +8901,6 @@ public void SetActive(bool flag)
public void SetContentActive(bool flag)
设置文本框是否显示
### Tooltip.UpdateContentPos
public void UpdateContentPos(Vector2 pos, float width, float height)
更新文本框位置
## Tooltip.Position
class in XCharts.Runtime
@@ -8804,7 +8978,7 @@ public static bool IsIgnoreFormatter(string itemFormatter)
### TooltipHelper.LimitInRect
public static void LimitInRect(Tooltip tooltip, Rect chartRect)
public static void LimitInRect(BaseChart chart, Tooltip tooltip, Rect chartRect)
## TooltipTheme
@@ -9001,6 +9175,10 @@ public static bool IsPointInPolygon(Vector3 p, params Vector3[] polyons)
public static bool IsPointInTriangle(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 check)
### UGLHelper.IsUp
public static bool IsUp(Vector3 p1, Vector3 p2, Vector3 p3)
### UGLHelper.IsValueEqualsColor
public static bool IsValueEqualsColor(Color color1, Color color2)
@@ -9088,6 +9266,11 @@ class in XCharts.Runtime
UI帮助类。
### UIHelper.DrawBackground
public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2)
## ViewControl
class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)

View File

@@ -1,7 +1,15 @@
---
sidebar_position: 61
slug: /changelog
---
# 更新日志
# Changelog
[master](#master)
[v3.15.0](#v3150)
[v3.14.0](#v3140)
[v3.13.0](#v3130)
[v3.12.1](#v3121)
[v3.12.0](#v3120)
[v3.11.2](#v3112)
[v3.11.1](#v3111)
@@ -72,6 +80,138 @@
## master
## v3.15.0
Version Highlights:
* __Enhanced Timeline & Zoom Capabilities__: Added `DataZoom.minZoomRatio` (replacing `minShowNum`), `Chart.useUtc`, and continuous optimization of `Axis Time` performance during zooming and handling of large year ranges.
* __More Flexible Bar Charts & Axis Configuration__: Added `Axis.mainAxis` to control bar chart orientation, `Serie.ignoreZeroOccupy` to control whether zero-value bars occupy space, and `AxisLine` extension line configurations.
* __Improved Chart Styling & Interactivity__: Added `Pie.pieType`, `Legend.itemInactiveOpacity`, `Axis.onLabelClick`, `Animation.Exchange`, `LabelStyle.fixedX/fixedY`, and more.
* __Ongoing Enhancement of Extended UI Components__: Added `Title` and `Viewport` configurations for `UITable`, enhanced `UIStatistic.desc`, and optimized `Comment.layer` and coordinate refresh experience.
* __Focused Stability & Compatibility Fixes__: Resolved critical issues including `SaveAsImage` being blocked by other components, `Pie` click failures, `TMP` compatibility, `Gantt` time range and year 2038 problem, `MarkArea/GridCoord/Axis` and more.
Changelog Details:
* (2026.03.01) Released version `v3.15.0`
* (2026.02.26) Added `ignoreZeroOccupy` to `Serie` to set whether zero-value Bars occupy space (#286)
* (2026.02.26) Fixed `SaveAsImage` not saving correctly when blocked by other components (#337)
* (2026.02.26) Added `mainAxis` parameter to `Axis` to set the main axis for controlling bar chart orientation (#331)
* (2026.02.03) Fixed `UITable` `viewport` potentially drawing incorrectly under different anchor points
* (2026.01.15) Fixed `Pie` click sometimes not responding (#357)
* (2026.01.08) Added `minZoomRatio` to `DataZoom` to replace the old `minShowNum` (#350)
* (2025.11.05) Fixed `Axis` `indicatorLabel` not being hideable
* (2025.11.03) Added `Tooltip` `Title` time formatting via `TitleLabelStyle` `numericFormatter` (#353)
* (2025.10.30) Added `useUtc` parameter to `Chart` to set whether displayed time uses UTC
* (2025.10.30) Optimized `Candlestick` support for time axis
* (2025.10.30) Added support for `ignore` in `Scatter` to skip data points
* (2025.10.24) Optimized line drawing order for `Sankey`
* (2025.10.22) Added `pieType` to `Pie` supporting solid pie charts and wireframe handle charts (#349)
* (2025.09.05) Optimized `MarkLine` performance
* (2025.09.01) Added `startExtendLength` and `endExtendLength` to `AxisLine` for setting axis line extensions
* (2025.08.27) Fixed `Serie` `TitleStyle` not refreshing promptly when data changed
* (2025.05.19) Fixed `Axis` runtime error when `TMP` is enabled
* (2025.04.25) Fixed `MarkArea` drawing inaccurately when specifying `yValue` or `xValue`
* (2025.04.17) Added `Title` support for `UITable` to set headers
* (2025.04.17) Added `Viewport` support for `UITable` to set table viewport margins and borders
* (2025.04.15) Added `Bar` support for color settings via `VisualMap`
* (2025.04.14) Added `showZeroLabel` to `AxisLabel` to set whether to display zero tick
* (2025.04.08) Added `desc` description text setting support for `UIStatistic`
* (2025.04.07) Fixed `Gantt` chart calculating inaccurate time ranges with multi-dimensional data
* (2025.04.07) Optimized `Axis` `Time` axis support for Custom and ceilRate settings
* (2025.04.07) Fixed `GridCoord` covering charts when background color set and Serie Clip enabled
* (2025.04.07) Fixed `Gantt` chart display errors when year exceeds 2038
* (2025.04.07) Fixed `Axis` `Time` axis not displaying years beyond 2038
* (2025.04.06) Fixed `Axis` `Time` axis text display errors when zoomed with `DataZoom`
* (2025.03.28) Fixed `Pie3D` `avoidLabelOverlap` not working
* (2025.03.27) Added `itemInactiveOpacity` to `Legend` to set color transparency for inactive states (#343)
* (2025.03.27) Added `onLabelClick` callback event to `Axis`
* (2025.03.26) Added `Exchange` sort swap animation to `Animation`
* (2025.03.22) Added `layer` setting to `Comment`
* (2025.03.21) Optimized coordinate refresh for `Comment`
* (2025.03.19) Added `{index}` wildcard support for `Serie` `Label` `formatter`
* (2025.03.18) Added `TitleStyle` component support for `Bar`
* (2025.03.18) Added `fixedX` and `fixedY` to `LabelStyle` to fix label coordinates
* (2025.03.17) Added `backgroundGap` to `ItemStyle` to set data item background gap
## v3.14.0
Version 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`
Changelog Details:
* (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
Version Highlights:
* 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
Changelog Details:
* (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
Version Highlights:
* Enhanced Chinese and English support for the official website documentation.
* Optimized the rendering performance of line charts when data points are densely packed.
* Other issue fixes.
Log Details:
* (2024.12.01) Released `v3.12.1` version.
* (2024.11.30) Fixed an issue where the `Tooltip` displayed incorrectly on mobile devices when setting other anchors in charts.
* (2024.11.27) Resolved some code warning issues in `Unity6`.
* (2024.11.26) Fixed a problem where the `Tooltip` might exceed the screen and appear incomplete under specific circumstances.
* (2024.11.24) Fixed an issue where `UITable` would also select items during dragging.
* (2024.11.22) Fixed an abnormal effect issue when dynamically changing the `Time` timeline with `Animation` enabled.
* (2024.11.18) Optimized `Line` rendering for better performance when data points are densely packed.
* (2024.11.16) Fixed an issue where `Animation` could not be enabled through code (#334).
* (2024.11.13) Fixed a problem where dynamically modifying the `start` and `end` of `DataZoom` through code did not refresh the chart.
* (2024.11.05) Fixed an issue where the `Title` remained visible after being set to hidden.
* (2024.11.01) Improved `website` documentation in both English and Chinese.
## v3.12.0
Version Highlights:
@@ -82,7 +222,7 @@ Version Highlights:
* Adjusted and perfected the documentation
* Other optimizations and fixes
Log Details:
Changelog Details:
* (2024.09.30) Released version `v3.12.0`
* (2024.09.27) Improved the `5-minute tutorial`
@@ -93,7 +233,6 @@ Log Details:
* (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
## v3.11.2
* (2024.08.01) Release `v3.11.2`
@@ -116,7 +255,7 @@ Log Details:
## v3.11.0
Release Highlights:
Version Highlights:
* Added `Line3DChart` for 3D line charts
* Added `GraphChart` for relationship graphs
@@ -153,7 +292,7 @@ Changelog Details:
## v3.10.2
* (2024.03.11) Release `v3.10.2`
* (2024.03.11) Fix to `Legend`'s `formatter` showing possible mismatches when setting {d} (#304)
* (2024.03.11) Fix to `Legend`'s `formatter` showing possible mismatches when setting `{d}` (#304)
* (2024.03.11) Fix to `Tooltip` still showing after moving out of coordinate system
* (2024.03.08) Fixed an issue where `Tooltip`'s title might not appear after upgrading from an older version
@@ -171,7 +310,7 @@ Highlights:
* Added chart border Settings to support rounded corner charts
* Fixed several issues
Extended features:
Extension features:
* Added `SankeyChart` Sankey chart
* Added `border` Settings for `UITable`
@@ -212,7 +351,7 @@ Highlights:
* Perfect code comments and documentation
* Fixed several issues
Extended features:
Extension features:
* `UITable` adds the carousel function
* `UITable` adds data api and callback functions
@@ -377,7 +516,7 @@ Log details:
Highlights:
* Updated documentation structure, added [Official XCharts Homepage](https://xcharts-team.github.io)
* Updated documentation structure, added [Official XCharts Homepage](https://xcharts-team.github.io/en)
* Added support for the DataZoom box selected.
* Added support for maximum width Settings for bars.
* Other optimizations.
@@ -629,7 +768,7 @@ Details:
* (2022.03.20) Release `v2.7.0` version
* (2022.02.21) Fixed chart name repeat check error #183
* (2022.02.17) Fixed bug where axis split line might be displayed outside the coordinate system #181
* (2022.02.08) Fixed {d} formatter error when value is 0
* (2022.02.08) Fixed `{d}` formatter error when value is 0
* (2022.02.08) Fixed `YAxis` `AxisLabel`'s `onZero` does not work
* (2022.01.06) Improved `Zebra` bar chart

View File

@@ -2,9 +2,7 @@
sidebar_position: 31
slug: /configuration
---
import APITable from '@site/src/components/APITable';
# Chart Configuration
# Configuration
## Serie
@@ -178,6 +176,7 @@ import APITable from '@site/src/components/APITable';
- [AnimationAddition](#animationaddition)
- [AnimationChange](#animationchange)
- [AnimationExchange](#animationexchange)
- [AnimationFadeIn](#animationfadein)
- [AnimationFadeOut](#animationfadeout)
- [AnimationHiding](#animationhiding)
@@ -236,6 +235,14 @@ class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
Data change animation.
## AnimationExchange
class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
> Since `v3.15.0`
Data exchange animation. Generally used for animation of data sorting.
## AnimationFadeIn
class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
@@ -262,7 +269,7 @@ Data hiding animation.
## AnimationInfo
class in XCharts.Runtime / Subclasses: [AnimationFadeIn](#animationfadein), [AnimationFadeOut](#animationfadeout), [AnimationChange](#animationchange), [AnimationAddition](#animationaddition), [AnimationHiding](#animationhiding), [AnimationInteraction](#animationinteraction)
class in XCharts.Runtime / Subclasses: [AnimationFadeIn](#animationfadein), [AnimationFadeOut](#animationfadeout), [AnimationChange](#animationchange), [AnimationAddition](#animationaddition), [AnimationHiding](#animationhiding), [AnimationInteraction](#animationinteraction), [AnimationExchange](#animationexchange)
> Since `v3.8.0`
@@ -278,7 +285,7 @@ the delay time before animation start.
`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
@@ -292,6 +299,12 @@ whether enable 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
class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
@@ -322,7 +335,7 @@ the mlvalue of width.
class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
the animation of serie. support animation type: fadeIn, fadeOut, change, addition.
the animation of serie. support animation type: fadeIn, fadeOut, change, addition, exchange.
### AnimationStyle.addition
@@ -352,6 +365,12 @@ Options:
Whether to enable animation.
### AnimationStyle.exchange
[AnimationExchange](#animationexchange) `v3.15.0`
Exchange animation configuration. Valid in sort bar chart.
### AnimationStyle.fadeIn
[AnimationFadeIn](#animationfadein) `v3.8.0`
@@ -599,6 +618,12 @@ Base of logarithm, which is valid only for numeric axes with type: 'Log'.
On the log axis, if base e is the natural number, and is true, logBase fails.
### Axis.mainAxis
`bool` `false` `v3.15.0`
Whether it is the main axis. When both X and Y axes are of the same type, the axis set to main axis will determine the orientation, such as horizontal bar chart and vertical bar chart.
### Axis.max
`double`
@@ -785,6 +810,12 @@ Whether to display the last label.
Whether to display the first label.
### AxisLabel.showZeroLabel
`bool` `true` `v3.15.0`
Whether to display the zero label.
### AxisLabel.textLimit
[TextLimit](#textlimit)
@@ -803,6 +834,12 @@ Settings related to axis line.
the arrow of line.
### AxisLine.endExtendLength
`float`
Extend length of the axis line at the end.
### AxisLine.onZero
`bool`
@@ -815,6 +852,12 @@ When mutiple axes exists, this option can be used to specify which axis can be "
Whether to show the arrow symbol of axis.
### AxisLine.startExtendLength
`float`
Extend length of the axis line at the start.
## AxisMinorSplitLine
class in XCharts.Runtime / Inherits from: [BaseLine](#baseline)
@@ -1243,7 +1286,9 @@ class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle), [AxisA
class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent), [IPropertyChanged](#ipropertychanged)
comment of chart.
> Since `v3.15.0`
comment of chart. Used to annotate special information in the chart.
### Comment.items
@@ -1257,6 +1302,17 @@ The items of comment.
The text style of all comments.
### Comment.layer
[CommentLayer](#commentlayer) `v3.15.0`
The layer of comment.
Options:
- `Lower`: The comment is display under the serie.
- `Upper`: The comment is display above the serie.
### Comment.markStyle
[CommentMarkStyle](#commentmarkstyle)
@@ -1466,11 +1522,11 @@ Distance between dataZoom component and the left side of the container. left val
选取框样式。
### DataZoom.minShowNum
### DataZoom.minZoomRatio
`int` `2`
`float` `0.2f`
Minimum number of display data. Minimum number of data displayed when DataZoom is enlarged to maximum.
The minimum zoom ratio of dataZoom. Range 0f-1f.
### DataZoom.orient
@@ -2234,6 +2290,12 @@ class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent), [IS
数据项背景颜色。
### ItemStyle.backgroundGap
`float` `v3.15.0`
the gap between background and data item.
### ItemStyle.backgroundWidth
`float`
@@ -2460,11 +2522,23 @@ the sytle of background.
the distance of label to axis line.
### LabelStyle.fixedX
`float` `0` `v3.15.0`
the fixed x of label. When not 0, it will be fixed on the specified x value.
### LabelStyle.fixedY
`float` `0` `v3.15.0`
the fixed y of label. When not 0, it will be fixed on the specified y value.
### LabelStyle.formatter
`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
@@ -2611,6 +2685,12 @@ The distance between each legend, horizontal distance in horizontal layout, and
Image height of legend symbol.
### Legend.itemInactiveOpacity
`float` `1` `v3.15.0`
the opacity of item color when item is inactive.
### Legend.itemOpacity
`float` `1`
@@ -2686,11 +2766,11 @@ the limit of text.
class in XCharts.Runtime / Inherits from: [ComponentTheme](#componenttheme)
### LegendTheme.unableColor
### LegendTheme.inactiveColor
`Color`
the color of text.
the color when the component is inactive.
## Level
@@ -3106,11 +3186,11 @@ Special label types, are used to label maximum value, minimum value and so on.
Options:
- `None`: 标线类型
- `Min`: 最小值。
- `Max`: 最大值。
- `Average`: 平均值。
- `Median`: 中位数。
- `Custom`: Custom. You can customize the xy coordinates or values.
- `Min`: Minimum value.
- `Max`: Maximum value.
- `Average`: Average value.
- `Median`: Median.
### MarkLineData.xPosition
@@ -3299,6 +3379,17 @@ Distance between grid component and the top side of the container.
class in XCharts.Runtime / Inherits from: [Serie](#serie)
### Pie.pieType
[PieType](#pietype) `v3.15.0`
Pie chart type.
Options:
- `Solid`: solid pie chart - default fill style.
- `Wireframe`: wireframe pie chart - only show the outline wireframe.
### Pie.radiusGradient
`bool` `false` `v3.8.1`
@@ -3467,13 +3558,13 @@ The width of the bar. Adaptive when default 0.
`float` `2f`
斑马线的间距。
The gap of zebra bar. It is the distance between two zebra stripes. When the value is 0, there is no gap between stripes.
### Serie.barZebraWidth
`float` `4f`
斑马线的粗细。
The width of zebra bar. It is the width of each zebra stripe. When the value is 0, there is no zebra stripe.
### Serie.bottom
@@ -3577,6 +3668,12 @@ Index of layout component that serie uses. Default is -1 means not use layout, o
忽略数据的默认值。当ignore为true才有效。
### Serie.ignoreZeroOccupy
`bool` `false` `v3.15.0`
Whether to ignore the zero value bar occupy. When enabled, the bar with zero value will not occupy space, and the gap between bars will be automatically adjusted according to the actual displayed bars. Generally used in bar chart.
### Serie.index
`int`
@@ -3757,6 +3854,12 @@ Options:
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
`float`
@@ -4368,12 +4471,24 @@ class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent) / Su
系列数据项的标记的图形
### SymbolStyle.borderWidth
`float` `0f` `v3.13.0`
the border width of symbol.
### SymbolStyle.color
`Color32`
图形的颜色。
### SymbolStyle.emptyColor
`Color32` `v3.13.0`
the color of empty symbol.
### SymbolStyle.gap
`float` `0`
@@ -4416,6 +4531,12 @@ Whether the symbol is showed.
the size of symbol.
### SymbolStyle.size2
`float` `0f` `v3.13.0`
the size of symbol.
### SymbolStyle.type
[SymbolType](#symboltype)
@@ -4553,10 +4674,6 @@ Rotation of text.
Settings related to text.
### TextStyle.tMPAlignment
`TextAlignmentOptions`
### TextStyle.tMPFont
`TMP_FontAsset`
@@ -4804,11 +4921,17 @@ the color 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
`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
@@ -4850,7 +4973,7 @@ Whether to show ignored data on tooltip.
`string`
a string template formatter for a single Serie or data item content. Support for wrapping lines with \n. Template variables are {.}, {a}, {b}, {c}, {d}.<br/> {.} is the dot of the corresponding color of a Serie that is currently indicated or whose index is 0.<br/> {a} is the series name of the serie that is currently indicated or whose index is 0.<br/> {b} is the name of the data item serieData that is currently indicated or whose index is 0, or a category value (such as the X-axis of a line chart).<br/> {c} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0.<br/> {d} is the percentage value of Y-dimensions (dimesion is 1) from serie that is currently indicated or whose index is 0, with no % sign.<br/> {e} is the name of the data item serieData that is currently indicated or whose index is 0.<br/> {f} is sum of data.<br/> {y} is category value of y axis.<br/> {.1} represents a dot from serie corresponding color that specifies index as 1.<br/> 1 in {a1}, {b1}, {c1} represents a serie that specifies an index of 1.<br/> {c1:2} represents the third data from serie's current indication data item indexed to 1 (a data item has multiple data, index 2 represents the third data).<br/> {c1:2-2} represents the third data item from serie's third data item indexed to 1 (i.e., which data item must be specified to specify).<br/> {d1:2: F2} indicates that a formatted string with a value specified separately is F2 (numericFormatter is used when numericFormatter is not specified).<br/> {d:0.##} indicates that a formatted string with a value specified separately is 0.## (used for percentage, reserved 2 valid digits while avoiding the situation similar to "100.00%" when using f2 ).<br/> Example: "{a}, {c}", "{a1}, {c1: f1}", "{a1}, {c1:0: f1}", "{a1} : {c1:1-1: f1}"<br/>
a string template formatter for a single Serie or data item content. Support for wrapping lines with \n. Template variables are \{.\}, \{a\}, \{b\}, \{c\}, \{d\}.<br/> \{.\} is the dot of the corresponding color of a Serie that is currently indicated or whose index is 0.<br/> \{a\} is the series name of the serie that is currently indicated or whose index is 0.<br/> \{b\} is the name of the data item serieData that is currently indicated or whose index is 0, or a category value (such as the X-axis of a line chart).<br/> \{c\} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0.<br/> \{d\} is the percentage value of Y-dimensions (dimesion is 1) from serie that is currently indicated or whose index is 0, with no % sign.<br/> \{e\} is the name of the data item serieData that is currently indicated or whose index is 0.<br/> \{f\} is sum of data.<br/> \{y\} is category value of y axis.<br/> \{.1\} represents a dot from serie corresponding color that specifies index as 1.<br/> 1 in \{a1\}, \{b1\}, \{c1\} represents a serie that specifies an index of 1.<br/> \{c1:2\} represents the third data from serie's current indication data item indexed to 1 (a data item has multiple data, index 2 represents the third data).<br/> \{c1:2-2\} represents the third data item from serie's third data item indexed to 1 (i.e., which data item must be specified to specify).<br/> \{d1:2: F2\} indicates that a formatted string with a value specified separately is F2 (numericFormatter is used when numericFormatter is not specified).<br/> \{d:0.##\} indicates that a formatted string with a value specified separately is 0.## (used for percentage, reserved 2 valid digits while avoiding the situation similar to "100.00%" when using f2 ).<br/> Example: "\{a\}, \{c\}", "\{a1\}, \{c1: f1\}", "\{a1\}, \{c1:0: f1\}", "\{a1\} : \{c1:1-1: f1\}"<br/>
### Tooltip.itemHeight
@@ -4935,7 +5058,7 @@ Whether to show the tooltip floating layer, whose default value is true. It shou
`string`
String template formatter for tooltip title content. \n line wrapping is supported. The placeholder {i} can be set separately to indicate that title is ignored and not displayed. Template variables are {.}, {a}, {b}, {c}, {d}, {e}, {f}, and {g}. <br /> {.} is the dot of the corresponding color of serie currently indicated or index 0. <br /> {a} is the series name name of serie currently indicated or index 0. <br /> {b} is the name of the serie data item serieData currently indicated or index 0, or the category value (such as the X-axis of a line chart). <br /> {c} is the value of the serie y-dimension (dimesion is 1) currently indicated or index is 0. <br /> {d} is the serie y-dimensional (dimesion 1) percentage value of the currently indicated or index 0, note without the % sign. <br /> {e} is the name of the serie data item serieData currently indicated or whose index is 0. <br /> {h} is the hexadecimal color value of serieData for the serie data item currently indicated or index 0. <br /> {f} is the sum of data. <br /> {g} indicates the total number of data. <br /> {y} is category value of y axis. <br /> {.1} represents a dot of the corresponding color with serie specified as index 1. <br /> The 1 in {a1}, {b1}, {c1} represents serie where index is specified as 1. <br /> {c1:2} represents the third data of the current indicator data item in serie with index 1 (one data item has multiple data, index 2 represents the third data). <br /> {c1:2-2} represents the third data of serie third data item with index 1 (that is, the number of data items must be specified when specifying the number of data items). <br /> {d1:2:f2} indicates that a format string with a single value is f2 (numericFormatter is used if no value is specified). <br /> {d:0.##} indicates that the format string with a value specified alone is 0.## # (for percentages, preserving a 2-digit significant number while avoiding the "100.00%" situation with f2). <br /> example: "{a}, {c}", "{a1}, {c1: f1}", "{a1}, {c1:0: f1}", "{a1}, {c1:1-1: f1}"
String template formatter for tooltip title content. \n line wrapping is supported. The placeholder \{i\} can be set separately to indicate that title is ignored and not displayed. Template variables are \{.\}, \{a\}, \{b\}, \{c\}, \{d\}, \{e\}, \{f\}, and \{g\}. <br /> \{.\} is the dot of the corresponding color of serie currently indicated or index 0. <br /> \{a\} is the series name name of serie currently indicated or index 0. <br /> \{b\} is the name of the serie data item serieData currently indicated or index 0, or the category value (such as the X-axis of a line chart). <br /> \{c\} is the value of the serie y-dimension (dimesion is 1) currently indicated or index is 0. <br /> \{d\} is the serie y-dimensional (dimesion 1) percentage value of the currently indicated or index 0, note without the % sign. <br /> \{e\} is the name of the serie data item serieData currently indicated or whose index is 0. <br /> \{h\} is the hexadecimal color value of serieData for the serie data item currently indicated or index 0. <br /> \{f\} is the sum of data. <br /> \{g\} indicates the total number of data. <br /> \{y\} is category value of y axis. <br /> \{.1\} represents a dot of the corresponding color with serie specified as index 1. <br /> The 1 in \{a1\}, \{b1\}, \{c1\} represents serie where index is specified as 1. <br /> \{c1:2\} represents the third data of the current indicator data item in serie with index 1 (one data item has multiple data, index 2 represents the third data). <br /> \{c1:2-2\} represents the third data of serie third data item with index 1 (that is, the number of data items must be specified when specifying the number of data items). <br /> \{d1:2:f2\} indicates that a format string with a single value is f2 (numericFormatter is used if no value is specified). <br /> \{d:0.##\} indicates that the format string with a value specified alone is 0.## # (for percentages, preserving a 2-digit significant number while avoiding the "100.00%" situation with f2). <br /> example: "\{a\}, \{c\}", "\{a1\}, \{c1: f1\}", "\{a1\}, \{c1:0: f1\}", "\{a1\}, \{c1:1-1: f1\}"
### Tooltip.titleHeight

View File

@@ -1,155 +1,127 @@
# XCharts FAQ
---
sidebar_position: 41
slug: /faq
---
[FAQ 1: How to adjust the margin between the axis and the background?](#how-to-adjust-the-margin-between-the-axis-and-the-background)
[FAQ 2: How to play agian the fadeIn animation?](#how-to-play-agian-the-fadein-animation)
[FAQ 3: How to customize the color of data item in line chart and pie chart?](#how-to-customize-the-color-of-data-item-in-line-chart-and-pie-chart)
[FAQ 4: How to formatter the text of axis label, such as add a units text?](#how-to-formatter-the-text-of-axis-label-such-as-add-a-units-text)
[FAQ 5: How to stack the bar of bar chart](#how-to-stack-the-bar-of-bar-chart)
[FAQ 6: How to make the bar serie in the same bar but not stack?](#how-to-make-the-bar-serie-in-the-same-bar-but-not-stack)
[FAQ 7: How to adjust the bar width and gap of barchart?](#how-to-adjust-the-bar-width-and-gap-of-barchart)
[FAQ 8: How to adjust the color of bar?](#how-to-adjust-the-color-of-bar)
[FAQ 9: Can I adjust the anchor of chart?](#can-i-adjust-the-anchor-of-chart)
[FAQ 10: Can display more than 1000 data?](#can-display-more-than-1000-data)
[FAQ 11: Can line chart drawing be dash, dot and dash-dot?](#can-line-chart-drawing-be-dash-dot-and-dash-dot)
[FAQ 12: How to limit the value range of the Y-axis?](#how-to-limit-the-value-range-of-the-y-axis)
[FAQ 13: How to customize the tick value range of value axis?](#how-to-customize-the-tick-value-range-of-value-axis)
[FAQ 14: How to display text at the top of data items?](#how-to-display-text-at-the-top-of-data-items)
[FAQ 15: How do I customize icons for data items?](#how-do-i-customize-icons-for-data-items)
[FAQ 16: How to anti-aliasing and make the chart smoother?](#how-to-anti-aliasing-and-make-the-chart-smoother)
[FAQ 17: Why does mouse over chart Tooltip not show?](#why-does-mouse-over-chart-tooltip-not-show)
[FAQ 18: How not to display the bar line of Tooltip?](#how-not-to-display-the-bar-line-of-tooltip)
[FAQ 19: How do I customize the display of Tooltip?](#how-do-i-customize-the-display-of-tooltip)
[FAQ 20: How do I get the Y-axis to display multiple decimal places?](#how-do-i-get-the-y-axis-to-display-multiple-decimal-places)
[FAQ 21: How do I dynamically update data with code?](#how-do-i-dynamically-update-data-with-code)
[FAQ 22: How to display legend? Why are legends sometimes not displayed?](#how-to-display-legend-why-are-legends-sometimes-not-displayed)
[FAQ 23: How to make chart as prefab?](#how-to-make-chart-as-prefab)
[FAQ 24: How do I draw custom graphic in chart,such as line or dot?](#how-do-i-draw-custom-content-in-chart-such-as-line-or-dot)
[FAQ 25: How to achieve similar data movement effect of ELECTRO cardiogram?](#how-to-achieve-similar-data-movement-effect-of-electro-cardiogram)
[FAQ 26: How do I use the background component? What are the conditions?](#how-do-i-use-the-background-component-what-are-the-conditions)
[FAQ 27: Mesh can not have more than 65000 vertices?](#mesh-cannot-have-more-than-65000-vertices)
[FAQ 28: Why are the parameters set in Serie reset after they run?](#why-are-the-parameters-set-in-serie-reset-after-they-run)
[FAQ 29: How to change the color of serie symbol?](#how-to-change-the-color-of-serie-symbol)
[FAQ 30: How to deal with TMP errors when importing or updating XCharts?](#what-if-tmp-errors-occur-when-importing-or-updating-xcharts)
[FAQ 31: Support empty data? How to achieve the effect of line chart disconnection?](#support-empty-data-how-to-achieve-the-effect-of-line-chart-disconnection)
[FAQ 32: 2.x What are the common problems when upgrading version 3.x?](#what-are-the-common-problems-when-upgrading-xcharts2-to-xcharts3)
# FAQ
## how-to-adjust-the-margin-between-the-axis-and-the-background
## FAQ 1: How to adjust the margin between the axis and the background?
`Grid` conponentwhich can adjust the left, right, up, down margins of chart.
## how-to-play-agian-the-fadein-animation
## FAQ 2: How to play agian the fadeIn animation?
call the `chart.AnimationReset()` API.
## how-to-customize-the-color-of-data-item-in-line chart-and-pie-chart
## FAQ 3: How to customize the color of data item in line chart and pie chart?
`Theme`->`colorPalette`, or the sub component `LineStyle` and `ItemStyle` of `Serie`.
## how-to-formatter-the-text-of-axis-label-such-as-add-a-units-text
## FAQ 4: How to formatter the text of axis label, such as add a units text?
Adjust `formatter` and `numericFormatter` parameter of `Legend`, `AxisLabel`, `Tooltop`, `SerieLabel`.
## how-to-stack-the-bar-of-bar-chart
## FAQ 5: How to stack the bar of bar chart?
Set the `stack` parameter of `Serie`, the series will stack in a bar with the same `stack`.
## how-to-make-the-bar-serie-in-the-same-bar-but-not-stack
## FAQ 6: How to make the bar serie in the same bar but not stack?
Set the `barGap` of `Serie` to `-1``stack` to null.
## how-to-adjust-the-bar-width-and-gap-of-barchart
## FAQ 7: How to adjust the bar width and gap of barchart?
Adjust the `barWidth` and `barGap` parameter of `Serie`, the last `serie`'s `barWidth` and `barGap` are valid when multiple `serie`.
## how-to-adjust-the-color-of-bar
## FAQ 8: How to adjust the color of bar?
Adjust the `ItemStyle` of `Data` in `inspector`.
## can-i-adjust-the-anchor-of-chart
## FAQ 9: Can I adjust the anchor of chart?
Yes, you can set any one of 16 anchors but the value use default.
## can-display-more-than-1000-data
## FAQ 10: Can display more than 1000 data?
Yes. But `UGUI` limits `65000` vertices to a single `Graphic`, so too much data may not be displayed completely. The sampling simplification curve can be turned on by setting the sampling distance `sampleDist`. You can also set some parameters to reduce the number of vertices in the chart to help show more data. Such as reducing the size of the chart, close or reduce the axis of the client drawing, close `Symbol` and `Label` display. A `Normal` line chart occupies fewer vertices than a `Smooth` line chart. The `1.5.0` and above versions can set `large` and `largeThreshold` parameters to enable performance mode.
## can-line-chart-drawing-be-dash-dot-and-dash-dot
## FAQ 11: Can line chart drawing be dash, dot and dash-dot?
Yes. Adjust the `lineType` of `Serie`.
## how-to-limit-the-value-range-of-the-y-axis
## FAQ 12: How to limit the value range of the Y-axis?
Select the `minMaxType` of `Axis` as `Custom`, then set `min` and `max` to the values you want.
## how-to-customize-the-tick-value-range-of-value-axis
## FAQ 13: How to customize the tick value range of value axis?
By default, it is automatically split by the `splitNumber` of `Axis`. Also, you can customize the `interval` to the range you want.
## how-to-display-text-at-the-top-of-data-items
## FAQ 14: How to display text at the top of data items?
Adjust the `Label` of `Serie`.
## how-do-i-customize-icons-for-data-items
## FAQ 15: How do I customize icons for data items?
Set the `Icon` of `Data` in `Serie`.
## how-to-anti-aliasing-and-make-the-chart-smoother
## FAQ 16: How to anti-aliasing and make the chart smoother?
Open the `Anti-Aliasing` setting in `Unity`. Selected the UI Canvas `Render Mode` as `Screen Space-Camera`, selected `MSAA`, set `4` times or higher anti-aliasing. The sawtooth can only be reduced and unavoidable. The higher the pixel, the less obvious the sawtooth is.
## why-does-mouse-over-chart-tooltip-not-show
## FAQ 17: Why does mouse over chart Tooltip not show?
Verify `Toolip` is opened. Verify that the parent node of chart has turned off mouse events.
## how-not-to-display-the-bar-line-of-tooltip
## FAQ 18: How not to display the bar line of Tooltip?
Set the `type` of `Tooltup` as `None`. Or adjust the parameters of `lineStyle`.
## how-do-i-customize-the-display-of-tooltip
## FAQ 19: How do I customize the display of Tooltip?
See the `formatter`, `itemFormatter`, `titleFormatter` parameters of `Tooltip`.
## how-do-i-get-the-y-axis-to-display-multiple-decimal-places
## FAQ 20: How do I get the Y-axis to display multiple decimal places?
Set the `numericFormatter` parameter of `AxisLabel`.
## how-do-i-dynamically-update-data-with-code
## FAQ 21: How do I dynamically update data with code?
See example: `Example01_UpdateData.cs`
## how-to-display-legend-why-are-legends-sometimes-not-displayed
## FAQ 22: How to display legend? Why are legends sometimes not displayed?
First, the `name` in `Serie` must have a value that is not null. Then set `Legend` is `show`, where `data` can be empty by default, indicating that all legends are displayed. If you only want to display part of the `Serie` legend, fill in `data` with the `name` of the legend you want to display. If none of the values in `data` are `name` of the series, the legend will not be displayed.
## how-to-make-chart-as-prefab
## FAQ 23: How to make chart as prefab?
Before make prefab, please delete all sub gameObject under chart which auto-created by `XCharts`.
## how-do-i-draw-custom-content-in-chart-such-as-line-or-dot
## FAQ 24: How do I draw custom graphic in chart,such as line or dot?
Implement `onCustomDraw` of chart, see `Example12_CustomDrawing.cs`.
## how-to-achieve-similar-data-movement-effect-of-electro-cardiogram
## FAQ 25: How to achieve similar data movement effect of ELECTRO cardiogram?
See `Example_Dynamic.cs`.
## how-do-i-use-the-background-component-what-are-the-conditions
## FAQ 26: How do I use the background component? What are the conditions?
Setting `show` to `true` for the `background` component.
## mesh-cannot-have-more-than-65000-vertices
## FAQ 27: Mesh can not have more than 65000 vertices?
This is the limit of `UGUI` on the number of vertices for a single `Graphic`. `XCharts` is draw chart on a single `Graphic`, so there is also this limitation. The solution can be referred to: [FAQ 10: Can display more than 1000 data](#can-display-more-than-1000-data)
This is the limit of `UGUI` on the number of vertices for a single `Graphic`. `XCharts` is draw chart on a single `Graphic`, so there is also this limitation. The solution can be referred to: [FAQ 10: Can display more than 1000 data?](#FAQ-10-can-display-more-than-1000-data)
## why-are-the-parameters-set-in-serie-reset-after-they-run
## FAQ 28: Why are the parameters set in Serie reset after they run?
Check whether `RemoveData()` and add new `Serie` in the code. If you want to keep the configuration of `Serie`, you can only `ClearData()` which just clear data and then readd the data to the old serie.
## how-to-change-the-color-of-serie-symbol
## FAQ 29: How to change the color of serie symbol?
The color of 'Symbol' is the color of 'ItemStyle' used.
## what-if-tmp-errors-occur-when-importing-or-updating-xcharts
## FAQ 30: How to deal with TMP errors when importing or updating XCharts?
XCharts does not enable TMP by default, so there are no references to TMP on asmdef. This issue may occur when updating XCharts after TMP is enabled locally. It can be solved in the following two ways:
@@ -158,11 +130,23 @@ XCharts does not enable TMP by default, so there are no references to TMP on asm
Version ` 3.8.0 ` after adding Daemon [XCharts - Daemon](https://github.com/XCharts-Team/XCharts-Daemon), will be XCharts - Daemon import project, When updating XCharts, the daemon automatically refreshes the asmdef based on the locally enabled TMP to ensure proper compilation.
## support-empty-data-how-to-achieve-the-effect-of-line-chart-disconnection
## FAQ 31: Support empty data? How to achieve the effect of line chart disconnection?
`data` of `Serie` is of type `double`, so it cannot represent empty data. Empty data can be achieved by turning on Serie's ignore and specifying ignoreValue. You can also set the ignore parameter for each SerieData. The ignoreLineBreak parameter can be set to disconnect or connect after ignoring data.
## what-are-the-common-problems-when-upgrading-xcharts2-to-xcharts3
## FAQ 32: 2.x What are the common problems when upgrading version 3.x?
1. `XCharts.Runtime.XChartsMgr` is missing the class attribute `ExtensionOfNativeClass`!
3.x version does not need to mount XChartsMgr, directly delete the `_xcharts_` node on the scene.
## FAQ 33: How to display a line chart without white space on both sides and start from the 0 coordinate?
Set the `boundaryGap` parameter of the X-axis.
## FAQ 34: How to set some Series not to display Tooltips?
Setting the `itemFormatter` of `itemStyle` in `serie` to `'-'` can ignore `tooltip`.
## FAQ 35: Sometimes an overlapping line appears in the area line chart when using semi-transparent colors
This is a bug in the drawing of the area line chart. You can use light opaque colors instead of semi-transparent colors.

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

@@ -0,0 +1,9 @@
---
title: Support
sidebar_position: 51
slug: /support
---
# Support
For technical support and to purchase additional charts, you can subscribe to the `VIP` service. For details, please send an email to `monitor1394@gmail.com` for consultation.

View File

@@ -1,13 +1,16 @@
---
title: Tutorial: Getting Started with XCharts 3.0 in 5 Minutes
title: Getting Started
sidebar_position: 11
slug: /tutorial01
---
# Tutorial: Getting Started with XCharts 3.0 in 5 Minutes
# Getting Started with XCharts in 5 Minutes
:::warning
> Note: This tutorial is only applicable to the XCharts 3.x version. For the 2.x version, please refer to [Tutorial: Mastering XCharts 2.0](https://github.com/XCharts-Team/XCharts/blob/2.0/Doc/Tutorial%3A5-Minute-Start-to-XCharts.md)
Note: This tutorial is only applicable to the XCharts 3.x version. For the 2.x version, please refer to [Tutorial: Mastering XCharts 2.0](https://github.com/XCharts-Team/XCharts/blob/2.0/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md)
:::
## Prerequisites for XCharts
@@ -55,7 +58,11 @@ The import method of XCharts-Daemon can refer to the previous import method of X
After importing XCharts and compiling, the XCharts menu will appear in the Unity editor's menu bar, and you can start using XCharts.
>Note: The XCharts menu in the Unity menu bar indicates that XCharts is available.
:::tip
Note: The XCharts menu in the Unity menu bar indicates that XCharts is available.
:::
### Adding a Simple Chart
@@ -86,7 +93,11 @@ In the `Inspector` view, find the `LineChart` panel, and click the `Add Serie` b
![op_addserie](img/tutorial01_addserie.png)
![linechart2](img/tutorial01_linechart2.png)
>Note: Series are added through the `Add Serie` button. Different types of Series can be added. [What kinds of Series does XCharts have?](https://xcharts-team.github.io/docs/configuration#serie-系列)
:::tip
Series are added through the `Add Serie` button. Different types of Series can be added. [What kinds of Series does XCharts have?](https://xcharts-team.github.io/en/docs/configuration#serie-系列)
:::
### Adding Other Main Components
@@ -94,7 +105,11 @@ By default, the chart does not have a `Legend`. If you need a `Legend` component
![op_addcomponent](img/tutorial01_addcomponent.png)
>Note: Main components are added through the `Add Component` button. [What main components does XCharts have?](https://xcharts-team.github.io/docs/configuration/#maincomponent-主组件)
:::tip
Main components are added through the `Add Component` button. [What main components does XCharts have?](https://xcharts-team.github.io/en/docs/configuration/#maincomponent-主组件)
:::
### Adding Serie Components
@@ -103,7 +118,11 @@ Serie only comes with a few common components, and other components need to be a
![op_addseriecomponent](img/tutorial01_addseriecomponent.png)
![linechart3](img/tutorial01_linechart3.png)
>Note: Serie components are added through the button on the right side of Serie. [What components can be added to Serie in XCharts?](https://xcharts-team.github.io/docs/configuration/#iseriecomponent-可添加到serie的组件)
:::tip
Serie components are added through the button on the right side of Serie. [What components can be added to Serie in XCharts?](https://xcharts-team.github.io/en/docs/configuration/#iseriecomponent-可添加到serie的组件)
:::
### Adding SerieData Components
@@ -112,7 +131,11 @@ If you need to customize the configuration of each data item individually, you c
![op_addseriedatacomponent](img/tutorial01_addseriedatacomponent.png)
![linechart4](img/tutorial01_linechart4.png)
>Note: SerieData components are added through the button on the right side of SerieData after expanding. [What components can be added to SerieData in XCharts?](https://xcharts-team.github.io/docs/configuration/#iseriedatacomponent-可添加到seriedata的组件)
:::tip
SerieData components are added through the button on the right side of SerieData after expanding. [What components can be added to SerieData in XCharts?](https://xcharts-team.github.io/en/docs/configuration/#iseriedatacomponent-可添加到seriedata的组件)
:::
### More Components and Configuration Parameters
@@ -133,7 +156,11 @@ To quickly locate the component corresponding to the effect you want to change,
2. If the `ItemStyle` of `Serie` has a color value other than `0000`, this color value is used.
3. Otherwise, the color value is taken from the `Color Palette` of the theme `Theme`.
>Note: The color value is usually `0000` when using the default color of the theme; other parameters are `0` or null when using the default configuration of the theme; pay attention to transparency when setting colors.
:::tip
The color value is usually `0000` when using the default color of the theme; other parameters are `0` or null when using the default configuration of the theme; pay attention to transparency when setting colors.
:::
### Adding a Line Chart with Code
@@ -214,7 +241,11 @@ Now, a simple line chart is ready:
If there are multiple series in a Chart, the data of Axis only needs to be added once, and should not be repeated in multiple loops.
>Remember: The number of Axis data should be consistent with the number of Serie data.
:::tip
Remember: The number of Axis data should be consistent with the number of Serie data.
:::
For the complete code, please refer to `Examples`: `Example13_LineSimple.cs`
@@ -229,7 +260,11 @@ The default font used by XCharts is Unity's default font `Arial`, which may not
After the font is set, newly created charts will use the newly set font. For old charts, you can click the `Rebuild Chart Object` button to refresh.
>Note: It is recommended to set the font before using XCharts; when updating XCharts, pay attention to the potential restoration of the set font.
:::tip
It is recommended to set the font before using XCharts; when updating XCharts, pay attention to the potential restoration of the set font.
:::
### Using TextMeshPro
@@ -271,7 +306,11 @@ XCharts has an automatic refresh mechanism, but it is also triggered under certa
2. `chart.RefreshChart()`: Refresh chart rendering, which only refreshes the rendering part and will not refresh component text, position, etc.
3. Each component can also refresh itself by calling `SetAllDirty()`.
>Note: Use APIs to manipulate data and various lists, not directly access the list for processing.
:::tip
Use APIs to manipulate data and various lists, not directly access the list for processing.
:::
### Changing Parameters on Main Components
@@ -288,7 +327,11 @@ xAxis.boundaryGap = true;
xAxis.type = Axis.AxisType.Category;
```
> Note: In older versions without the `EnsureChartComponent()` interface, use `GetOrAddChartComponent()`
:::tip
In older versions without the `EnsureChartComponent()` interface, use `GetOrAddChartComponent()`
:::
### Changing Serie Parameters

View File

@@ -13,6 +13,7 @@ slug: /api
- [AnimationAddition](#animationaddition)
- [AnimationChange](#animationchange)
- [AnimationEasing](#animationeasing)
- [AnimationExchange](#animationexchange)
- [AnimationFadeIn](#animationfadein)
- [AnimationFadeOut](#animationfadeout)
- [AnimationHiding](#animationhiding)
@@ -70,6 +71,7 @@ slug: /api
- [ColorUtil](#colorutil)
- [Comment](#comment)
- [CommentItem](#commentitem)
- [CommentLayer](#commentlayer)
- [CommentMarkStyle](#commentmarkstyle)
- [ComponentHandlerAttribute](#componenthandlerattribute)
- [ComponentHelper](#componenthelper)
@@ -157,6 +159,7 @@ slug: /api
- [MainComponentContext](#maincomponentcontext)
- [MainComponentHandler](#maincomponenthandler)
- [MainComponentHandler&lt;T&gt;](#maincomponenthandlert)
- [MainComponentHandler&lt;Title&gt;](#maincomponenthandlertitle)
- [MarkArea](#markarea)
- [MarkAreaData](#markareadata)
- [MarkAreaType](#markareatype)
@@ -179,6 +182,7 @@ slug: /api
- [ParallelCoordContext](#parallelcoordcontext)
- [Pie](#pie)
- [PieChart](#piechart)
- [PieType](#pietype)
- [PolarAxisTheme](#polaraxistheme)
- [PolarChart](#polarchart)
- [PolarCoord](#polarcoord)
@@ -255,6 +259,7 @@ slug: /api
- [ThemeStyle](#themestyle)
- [ThemeType](#themetype)
- [Title](#title)
- [TitleHandler](#titlehandler)
- [TitleStyle](#titlestyle)
- [TitleTheme](#titletheme)
- [Tooltip](#tooltip)
@@ -360,6 +365,14 @@ class in XCharts.Runtime
- `Linear`:
## AnimationExchange
class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
> 从 `v3.15.0` 开始支持
数据交换动画。一般用于图表数据排序时顺序变化的动画。
## AnimationFadeIn
class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
@@ -386,7 +399,7 @@ class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
## AnimationInfo
class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein),[AnimationFadeOut](#animationfadeout),[AnimationChange](#animationchange),[AnimationAddition](#animationaddition),[AnimationHiding](#animationhiding),[AnimationInteraction](#animationinteraction)
class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein),[AnimationFadeOut](#animationfadeout),[AnimationChange](#animationchange),[AnimationAddition](#animationaddition),[AnimationHiding](#animationhiding),[AnimationInteraction](#animationinteraction),[AnimationExchange](#animationexchange)
> 从 `v3.8.0` 开始支持
@@ -405,7 +418,7 @@ public AnimationDelayFunction delayFunction
### AnimationInfo.duration
public float duration
动画的时长。
动画的时长。默认用于计算动画的速度。也可以通过speed指定速度。
### AnimationInfo.durationFunction
@@ -432,6 +445,11 @@ public Action OnAnimationStart
public bool reverse
是否开启反向动画效果。
### AnimationInfo.speed
public float speed
动画的速度。当指定speed时duration将失效。默认为0表示不指定速度。
### AnimationInfo.End
public void End()
@@ -526,7 +544,7 @@ public float GetWidth(float width)
class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
动画组件用于控制图表的动画播放。支持配置五种动画表现FadeIn渐入动画FadeOut渐出动画Change变更动画Addition新增动画Interaction交互动画。 按作用的对象可以分为两类SerieAnimation系列动画和DataAnimation数据动画
动画组件用于控制图表的动画播放。支持配置五种动画表现FadeIn渐入动画FadeOut渐出动画Change变更动画Addition新增动画Interaction交互动画Exchange交换动画。 按作用的对象可以分为两类SerieAnimation系列动画和DataAnimation数据动画
### AnimationStyle.addition
@@ -543,6 +561,11 @@ public AnimationChange change
public bool enable
是否开启动画效果。
### AnimationStyle.exchange
public AnimationExchange exchange
交换动画配置。如在排序柱图中有效。
### AnimationStyle.fadeIn
public AnimationFadeIn fadeIn
@@ -634,6 +657,10 @@ public int GetCurrIndex()
public float GetCurrRate()
### AnimationStyle.GetExchangeDuration
public float GetExchangeDuration()
### AnimationStyle.GetInteractionDuration
public float GetInteractionDuration()
@@ -784,6 +811,14 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类:
直角坐标系的坐标轴组件。
### Axis.onLabelClick
public Action&lt;int, string&gt; onLabelClick
> 从 `v3.15.0` 开始支持
点击文本标签回调函数。参数labelIndex, labelName。
### Axis.AddData
public void AddData(string category)
@@ -883,7 +918,7 @@ public bool IsLog()
### Axis.IsNeedShowLabel
public bool IsNeedShowLabel(int index, int total = 0)
public bool IsNeedShowLabel(int index, int total = 0, string content = null)
### Axis.IsRight
@@ -1042,6 +1077,10 @@ public bool needAnimation
public List&lt;string&gt; runtimeData
数值轴时每个tick的数值。
### AxisContext.sortedDataIndices
public List&lt;int&gt; sortedDataIndices
## AxisHandler&lt;T&gt;
class in XCharts / 继承自: [MainComponentHandler](#maincomponenthandler)
@@ -1050,6 +1089,14 @@ class in XCharts / 继承自: [MainComponentHandler](#maincomponenthandler)
public T component
### AxisHandler&lt;T&gt;.DrawTop
// public override void DrawTop(VertexHelper vh)
### AxisHandler&lt;T&gt;.OnPointerClick
public override void OnPointerClick(PointerEventData eventData)
## AxisHelper
class in XCharts.Runtime
@@ -1088,7 +1135,7 @@ public static float GetAxisValueDistance(GridCoord grid, Axis axis, float scaleW
### AxisHelper.GetAxisValueLength
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value, float gap = 0)
获得数值value在坐标轴上对应的长度
### AxisHelper.GetAxisValuePosition
@@ -1170,12 +1217,12 @@ public void Copy(AxisLabel axisLabel)
### 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
public bool IsNeedShowLabel(int index, int total)
public bool IsNeedShowLabel(int index, int total, string content = null)
### AxisLabel.SetRelatedText
@@ -1362,6 +1409,11 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent)
背景组件。
### Background.rect
public Rect rect
背景的矩形区域。
### Background.SetDefaultValue
public override void SetDefaultValue()
@@ -1378,6 +1430,10 @@ public int containerIndex
public int containterInstanceId
### Bar.useSortData
public override bool useSortData
### Bar.AddDefaultSerie
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
@@ -1656,6 +1712,10 @@ public Settings settings
public ThemeStyle theme
### BaseChart.topPainter
public Painter topPainter
### BaseChart.typeListForComponent
public Dictionary&lt;Type, FieldInfo&gt; typeListForComponent
@@ -1664,6 +1724,11 @@ public Dictionary&lt;Type, FieldInfo&gt; typeListForComponent
public Dictionary&lt;Type, FieldInfo&gt; typeListForSerie
### BaseChart.useUtc
public bool useUtc
图表的时间是否都显示为UTC时间。
### BaseChart.AddChartComponent
public MainComponent AddChartComponent(Type type)
@@ -1920,6 +1985,10 @@ public Color32 GetLegendRealShowNameColor(string name)
public int GetLegendRealShowNameIndex(string name)
### BaseChart.GetMainAxis
public Axis GetMainAxis()
### BaseChart.GetMarkColor
public Color32 GetMarkColor(Serie serie, SerieData serieData)
@@ -1936,6 +2005,10 @@ public T GetOrAddChartComponent&lt;T&gt;() where T : MainComponent
public Painter GetPainter(int index)
### BaseChart.GetRealtimeSortSerie
public Serie GetRealtimeSortSerie(int gridIndex)
### BaseChart.GetSerie
public Serie GetSerie(int serieIndex)
@@ -1948,19 +2021,19 @@ public T GetSerie&lt;T&gt;(int serieIndex) where T : Serie
### 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;
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;
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;
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
@@ -1968,15 +2041,11 @@ public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double te
### 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;
public float GetSerieTotalWidth&lt;T&gt;(float categoryWidth, float gap, int realBarCount) where T : Serie
### BaseChart.GetTitlePosition
public Vector3 GetTitlePosition(Title title)
public float GetSerieTotalWidth&lt;T&gt;(float categoryWidth, float gap, int realBarCount, int gridIndex) where T : Serie
### BaseChart.GetVisualMapOfSerie
@@ -2002,6 +2071,10 @@ public bool HasChartComponent(Type type)
public bool HasChartComponent&lt;T&gt;()
### BaseChart.HasRealtimeSortSerie
public bool HasRealtimeSortSerie(int gridIndex)
### BaseChart.HasSerie
public bool HasSerie(Type type)
@@ -2347,12 +2420,16 @@ public void UpdateYAxisIcon(int index, Sprite icon, int yAxisIndex = 0)
## BaseGraph
class in XCharts.Runtime / 继承自: [MaskableGraphic](https://docs.unity3d.com/ScriptReference/30_search.html?q=maskablegraphic),[IPointerDownHandler](https://docs.unity3d.com/ScriptReference/30_search.html?q=ipointerdownhandler),[IPointerUpHandler](https://docs.unity3d.com/ScriptReference/30_search.html?q=ipointeruphandler),[](#) / 子类: [BaseChart](#basechart),[UIComponent](#uicomponent)
class in XCharts.Runtime / 继承自: [MaskableGraphic](https://docs.unity3d.com/ScriptReference/30_search.html?q=maskablegraphic),[IPointerDownHandler](https://docs.unity3d.com/ScriptReference/30_search.html?q=ipointerdownhandler),[IPointerUpHandler](https://docs.unity3d.com/ScriptReference/30_search.html?q=ipointeruphandler), / 子类: [BaseChart](#basechart),[UIComponent](#uicomponent)
### BaseGraph.chartHideFlags
public virtual HideFlags chartHideFlags
### BaseGraph.childrenNodeNames
public List&lt;string&gt; childrenNodeNames
### BaseGraph.clickPos
public Vector2 clickPos
@@ -2411,6 +2488,10 @@ public float graphX
public float graphY
图形的Y
### BaseGraph.isDragingClick
public bool isDragingClick
### BaseGraph.isPointerClick
public bool isPointerClick
@@ -2485,6 +2566,10 @@ public string warningInfo
public string CheckWarning()
检测警告信息。
### BaseGraph.GetTitlePosition
public Vector3 GetTitlePosition(Title title)
### BaseGraph.LocalPointToScreenPoint
public Vector2 LocalPointToScreenPoint(Vector2 localPoint)
@@ -2551,11 +2636,6 @@ public void RefreshAllComponent()
public virtual void RefreshGraph()
在下一帧刷新图形。
### BaseGraph.SaveAsImage
public void SaveAsImage(string imageType = "png", string savePath = "")
保存图表为图片。
### BaseGraph.ScreenPointToChartPoint
public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint)
@@ -2759,6 +2839,10 @@ public float GetRuntimeBorderWidth()
public float[] GetRuntimeCornerRadius()
### BorderStyle.IsCricle
public bool IsCricle()
## CalendarCoord
class in XCharts.Runtime / 继承自: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer)
@@ -2809,6 +2893,14 @@ public static string ColorToStr(Color color)
public static string FloatToStr(double value, string numericFormatter = "F", int precision = 0)
### ChartCached.GetAxisLabelName
public static string GetAxisLabelName(int index)
### ChartCached.GetComponentObjectName
public static string GetComponentObjectName(MainComponent component)
### ChartCached.GetSerieLabelName
public static string GetSerieLabelName(string prefix, int i, int j)
@@ -2817,17 +2909,25 @@ public static string GetSerieLabelName(string prefix, int i, int j)
public static string GetString(string prefix, int suffix)
### ChartCached.GetTypeName
public static string GetTypeName(Type type)
### ChartCached.GetTypeName&lt;T&gt;
public static string GetTypeName&lt;T&gt;()
### ChartCached.IntToStr
public static string IntToStr(int value, string numericFormatter = "")
### ChartCached.NumberToDateStr
public static string NumberToDateStr(double timestamp, string formatter)
public static string NumberToDateStr(double timestamp, string formatter, bool local = false)
### ChartCached.NumberToDateTime
public static DateTime NumberToDateTime(double timestamp)
public static DateTime NumberToDateTime(double timestamp, bool local = false)
### ChartCached.NumberToStr
@@ -2893,7 +2993,8 @@ public static void DestoryGameObject(GameObject go)
### ChartHelper.DestoryGameObjectByMatch
public static void DestoryGameObjectByMatch(Transform parent, string containString)
public static void DestoryGameObjectByMatch(Transform parent, List&lt;string&gt; children)
### ChartHelper.DestroyAllChildren
@@ -2940,7 +3041,8 @@ public static Vector3 GetLastValue(List&lt;Vector3&gt; list)
### ChartHelper.GetMaxCeilRate
public static double GetMaxCeilRate(double value, double ceilRate)
public static float GetMaxCeilRate(float value, float ceilRate)
### ChartHelper.GetMaxDivisibleValue
@@ -2952,7 +3054,8 @@ public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE
### ChartHelper.GetMinCeilRate
public static double GetMinCeilRate(double value, double ceilRate)
public static float GetMinCeilRate(float value, float ceilRate)
### ChartHelper.GetMinDivisibleValue
@@ -3062,14 +3165,14 @@ public static List&lt;string&gt; ParseStringFromString(string jsonData)
public static void RemoveComponent&lt;T&gt;(GameObject gameObject)
### ChartHelper.RemoveTMPComponents
public static void RemoveTMPComponents(GameObject gameObject)
### ChartHelper.RotateRound
public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle)
### ChartHelper.SaveAsImage
public static Texture2D SaveAsImage(RectTransform rectTransform, Canvas canvas, string imageType = "png", string path = "")
### ChartHelper.SetActive
public static bool SetActive(Image image, bool active)
@@ -3129,6 +3232,10 @@ public float GetTextWidth()
public float GetWidth()
### ChartLabel.InRect
public bool InRect(Vector2 local)
### ChartLabel.IsActiveByScale
public bool IsActiveByScale()
@@ -3383,13 +3490,20 @@ public static Color32 GetColor(string hexColorStr)
class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent),[IPropertyChanged](#ipropertychanged)
图表注解组件。
> 从 `v3.15.0` 开始支持
图表注解组件。用于标注图表中的特殊信息。
### Comment.items
public List&lt;CommentItem&gt; items
注解项。每个注解组件可以设置多个注解项。
### Comment.layer
public CommentLayer layer
注解的显示层级。
### Comment.show
public bool show
@@ -3398,10 +3512,12 @@ public bool show
### Comment.GetLabelStyle
public LabelStyle GetLabelStyle(int index)
获取注解项的文本样式。
### Comment.GetMarkStyle
public CommentMarkStyle GetMarkStyle(int index)
获取注解项的标记样式。
### Comment.OnChanged
@@ -3414,10 +3530,9 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
注解项。
### CommentItem.content
### CommentItem.labelObject
public string content
注解的文本内容。支持模板参数可以参考Tooltip的itemFormatter。
public ChartLabel labelObject
### CommentItem.markRect
@@ -3434,6 +3549,17 @@ public CommentMarkStyle markStyle
public bool show
是否显示当前注解项。
## CommentLayer
class in XCharts.Runtime
注解的显示层级。
可选:
- `Lower`: 注解在系列下方。
- `Upper`: 注解在系列上方。
## CommentMarkStyle
class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
@@ -3719,17 +3845,17 @@ class in XCharts.Runtime
### DateTimeUtil.GetDateTime
public static DateTime GetDateTime(double timestamp, bool local = true)
public static DateTime GetDateTime(double timestamp, bool local = false)
### DateTimeUtil.GetDefaultDateTimeString
public static string GetDefaultDateTimeString(int timestamp, double range = 0)
public static string GetDefaultDateTimeString(double timestamp, double range = 0, bool local = false)
### DateTimeUtil.GetTimestamp
public static int GetTimestamp(DateTime time, bool local = false)
public static double GetTimestamp(DateTime time, bool local = false)
public static int GetTimestamp(string dateTime, bool local = false)
public static double GetTimestamp(string dateTime, bool local = false)
### DateTimeUtil.IsDateOrTimeRegex
@@ -3866,9 +3992,13 @@ public static bool NeedFormat(string content)
### 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
public static string TrimAndReplaceLine(string content)
@@ -4379,7 +4509,7 @@ public override void ClearData()
### Indicator.GetFormatterIndicatorContent
public string GetFormatterIndicatorContent(string indicatorName)
public string GetFormatterIndicatorContent(string indicatorName, int index, int totalIndex)
### Indicator.GetIndicator
@@ -4630,12 +4760,12 @@ public Color GetColor(Color defaultColor)
### 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
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue)
public string GetFormatterDateTime(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool local)
### LabelStyle.GetOffset
@@ -5317,6 +5447,10 @@ public float runtimeTop
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
public bool IsBottom()
@@ -5635,6 +5769,10 @@ class in XCharts.Runtime / 继承自: [MainComponentHandler](#maincomponenthandl
public T component
## MainComponentHandler&lt;Title&gt;
class in / 子类: [TitleHandler](#titlehandler)
## MarkArea
class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent)
@@ -5733,7 +5871,7 @@ class in XCharts.Runtime
可选:
- `None`: 标线类型
- `Custom`: 自定义。可自定义xy坐标或数值。
- `Min`: 最小值。
- `Max`: 最大值。
- `Average`: 平均值。
@@ -5858,7 +5996,7 @@ class in / 子类: [XLog](#xlog)
## ObjectPool&lt;T&gt; where T
class in XCharts.Runtime / 继承自: [new()](#new())
class in XCharts.Runtime / 继承自: new()
### ObjectPool&lt;T&gt; where T.countActive
@@ -5930,10 +6068,6 @@ class in XCharts.Runtime / 继承自: [MaskableGraphic](https://docs.unity3d.com
public int index
### Painter.onPopulateMesh
public Action&lt;VertexHelper, Painter&gt; onPopulateMesh
### Painter.type
public Type type
@@ -6068,6 +6202,15 @@ public void DefaultLabelPieChart()
public void DefaultRadiusRosePieChart()
默认玫瑰饼图。
## PieType
class in XCharts.Runtime
可选:
- `Solid`: 实心饼图 - 默认填充样式
- `Wireframe`: 线框饼图 - 仅显示轮廓线框
## PolarAxisTheme
class in XCharts.Runtime / 继承自: [BaseAxisTheme](#baseaxistheme)
@@ -6695,7 +6838,7 @@ public double GetData(int index, int dimension, DataZoom dataZoom = null)
### 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
@@ -7002,6 +7145,10 @@ public SelectStyle selectStyle
public bool show
该数据项是否要显示。
### SerieData.sortIndex
public int sortIndex
### SerieData.state
public SerieState state
@@ -7085,12 +7232,12 @@ public double GetLastData()
### SerieData.GetMaxData
public double GetMaxData(bool inverse = false)
public double GetMaxData(bool inverse = false, int startDimensionIndex = 0)
最大值。
### SerieData.GetMinData
public double GetMinData(bool inverse = false)
public double GetMinData(bool inverse = false, int startDimensionIndex = 0)
最小值。
### SerieData.GetMinMaxData
@@ -7148,7 +7295,7 @@ public void SetIconActive(bool flag)
### SerieData.SetLabelActive
public void SetLabelActive(bool flag)
public void SetLabelActive(bool flag, bool force = false)
### SerieData.SetPolygon
@@ -7201,6 +7348,10 @@ class in XCharts.Runtime
public void Reset()
### SerieDataContext.UpdateExchangePosition
public void UpdateExchangePosition(ref float x, ref float y, float totalTime)
## SerieDataExtraFieldAttribute
class in XCharts.Runtime / 继承自: [Attribute](https://docs.unity3d.com/ScriptReference/30_search.html?q=attribute)
@@ -7629,6 +7780,10 @@ public override void RefreshLabelInternal()
public override void RefreshLabelNextFrame()
### SerieHandler&lt;T&gt;.RefreshTitleLabelInternal
public void RefreshTitleLabelInternal()
### SerieHandler&lt;T&gt;.RemoveComponent
public override void RemoveComponent()
@@ -7925,7 +8080,7 @@ class in XCharts.Runtime / 继承自: [SymbolStyle](#symbolstyle),[ISerieDataCom
### SerieSymbol.GetSize
public float GetSize(List&lt;double&gt; data, float themeSize)
public float GetSize(SerieData serieData, float themeSize)
根据指定的sizeType获得标记的大小
### SerieSymbol.Reset
@@ -8549,6 +8704,30 @@ public override void ClearComponentDirty()
public void OnChanged()
## TitleHandler
class in XCharts.Runtime / 继承自: [MainComponentHandler&lt;Title&gt;](#maincomponenthandlertitle)
### TitleHandler.AddSubTitleLabel
public static ChartLabel AddSubTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
### TitleHandler.AddTitleLabel
public static ChartLabel AddTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
### TitleHandler.AddTitleObject
public static GameObject AddTitleObject(BaseGraph graph, Title title, ComponentTheme componentTheme, int titleSiblingIndex, string objectName = null)
### TitleHandler.InitComponent
public override void InitComponent()
### TitleHandler.OnSerieDataUpdate
public override void OnSerieDataUpdate(int serieIndex)
## TitleStyle
class in XCharts.Runtime / 继承自: [LabelStyle](#labelstyle),[ISerieDataComponent](#iseriedatacomponent),[ISerieComponent](#iseriecomponent)
@@ -8612,7 +8791,7 @@ public bool ignoreDataShow
### Tooltip.itemFormatter
public string itemFormatter
提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 换行。用|来表示多个列的分隔。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。<br/> {i}或-表示忽略当前项。 {.}为当前所指示的serie或数据项的对应颜色的圆点。<br/> {a}为当前所指示的serie或数据项的系列名name。<br/> {b}为当前所指示的serie或数据项的数据项serieData的name或者类目值如折线图的X轴。<br/> {c}为当前所指示的serie或数据项的y维dimesion为1的数值。<br/> {d}为当前所指示的serie或数据项的y维dimesion为1百分比值注意不带%号。<br/> {e}为当前所指示的serie或数据项的数据项serieData的name。<br/> {f}为当前所指示的serie的默认维度的数据总和。<br/> {g}为当前所指示的serie的数据总个数。<br/> {h}为当前所指示的serie的十六进制颜色值。<br/> {y}为当前所指示的serie的y轴的类目值。<br/> {c0}表示当前数据项维度为0的数据。<br/> {c1}表示当前数据项维度为1的数据。<br/> {d3}表示维度3的数据的百分比。它的分母是默认维度一般是1维度数据。<br/> |表示多个列的分隔。<br/> 示例:"{i}", "{.}|{a}|{c}", "{.}|{b}|{c2:f2}", "{.}|{b}|{y}"
提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 换行。用|来表示多个列的分隔。 模板变量有\{.\}、\{a\}、\{b\}、\{c\}、\{d\}、\{e\}、\{f\}、\{g\}。<br/> \{i\}或-表示忽略当前项。 \{.\}为当前所指示的serie或数据项的对应颜色的圆点。<br/> \{a\}为当前所指示的serie或数据项的系列名name。<br/> \{b\}为当前所指示的serie或数据项的数据项serieData的name或者类目值如折线图的X轴。<br/> \{c\}为当前所指示的serie或数据项的y维dimesion为1的数值。<br/> \{d\}为当前所指示的serie或数据项的y维dimesion为1百分比值注意不带%号。<br/> \{e\}为当前所指示的serie或数据项的数据项serieData的name。<br/> \{f\}为当前所指示的serie的默认维度的数据总和。<br/> \{g\}为当前所指示的serie的数据总个数。<br/> \{h\}为当前所指示的serie的十六进制颜色值。<br/> \{y\}为当前所指示的serie的y轴的类目值。<br/> \{c0\}表示当前数据项维度为0的数据。<br/> \{c1\}表示当前数据项维度为1的数据。<br/> \{d3\}表示维度3的数据的百分比。它的分母是默认维度一般是1维度数据。<br/> |表示多个列的分隔。<br/> 示例:"\{i\}", "\{.\}|\{a\}|\{c\}", "\{.\}|\{b\}|\{c2:f2\}", "\{.\}|\{b\}|\{y\}"
### Tooltip.marker
@@ -8662,7 +8841,7 @@ public bool showContent
### Tooltip.titleFormatter
public string titleFormatter
提示框标题内容的字符串模版格式器。支持用 \n 换行。可以单独设置占位符{i}表示忽略不显示title。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。<br/> {.}为当前所指示或index为0的serie的对应颜色的圆点。<br/> {a}为当前所指示或index为0的serie的系列名name。<br/> {b}为当前所指示或index为0的serie的数据项serieData的name或者类目值如折线图的X轴。<br/> {c}为当前所指示或index为0的serie的y维dimesion为1的数值。<br/> {d}为当前所指示或index为0的serie的y维dimesion为1百分比值注意不带%号。<br/> {e}为当前所指示或index为0的serie的数据项serieData的name。<br/> {h}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。<br/> {f}为数据总和。<br/> {g}为数据总个数。<br/> {y}为value所对应的y轴的类目值。<br/> {.1}表示指定index为1的serie对应颜色的圆点。<br/> {a1}、{b1}、{c1}中的1表示指定index为1的serie。<br/> {c1:2}表示索引为1的serie的当前指示数据项的第3个数据一个数据项有多个数据index为2表示第3个数据。<br/> {c1:2-2}表示索引为1的serie的第3个数据项的第3个数据也就是要指定第几个数据项时必须要指定第几个数据。<br/> {d1:2:f2}表示单独指定了数值的格式化字符串为f2不指定时用numericFormatter。<br/> {d:0.##} 表示单独指定了数值的格式化字符串为 0.## 用于百分比保留2位有效数同时又能避免使用 f2 而出现的类似于"100.00%"的情况 )。<br/> 示例:"{a}:{c}"、"{a1}:{c1:f1}"、"{a1}:{c1:0:f1}"、"{a1}:{c1:1-1:f1}"
提示框标题内容的字符串模版格式器。支持用 \n 换行。可以单独设置占位符\{i\}表示忽略不显示title。 模板变量有\{.\}、\{a\}、\{b\}、\{c\}、\{d\}、\{e\}、\{f\}、\{g\}。<br/> \{.\}为当前所指示或index为0的serie的对应颜色的圆点。<br/> \{a\}为当前所指示或index为0的serie的系列名name。<br/> \{b\}为当前所指示或index为0的serie的数据项serieData的name或者类目值如折线图的X轴。<br/> \{c\}为当前所指示或index为0的serie的y维dimesion为1的数值。<br/> \{d\}为当前所指示或index为0的serie的y维dimesion为1百分比值注意不带%号。<br/> \{e\}为当前所指示或index为0的serie的数据项serieData的name。<br/> \{h\}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。<br/> \{f\}为数据总和。<br/> \{g\}为数据总个数。<br/> \{y\}为value所对应的y轴的类目值。<br/> \{.1\}表示指定index为1的serie对应颜色的圆点。<br/> \{a1\}、\{b1\}、\{c1\}中的1表示指定index为1的serie。<br/> \{c1:2\}表示索引为1的serie的当前指示数据项的第3个数据一个数据项有多个数据index为2表示第3个数据。<br/> \{c1:2-2\}表示索引为1的serie的第3个数据项的第3个数据也就是要指定第几个数据项时必须要指定第几个数据。<br/> \{d1:2:f2\}表示单独指定了数值的格式化字符串为f2不指定时用numericFormatter。<br/> \{d:0.##\} 表示单独指定了数值的格式化字符串为 0.## 用于百分比保留2位有效数同时又能避免使用 f2 而出现的类似于"100.00%"的情况 )。<br/> 示例:"\{a\}:\{c\}"、"\{a1\}:\{c1:f1\}"、"\{a1\}:\{c1:0:f1\}"、"\{a1\}:\{c1:1-1:f1\}"
### Tooltip.AddSerieDataIndex
@@ -8722,11 +8901,6 @@ public void SetActive(bool flag)
public void SetContentActive(bool flag)
设置文本框是否显示
### Tooltip.UpdateContentPos
public void UpdateContentPos(Vector2 pos, float width, float height)
更新文本框位置
## Tooltip.Position
class in XCharts.Runtime
@@ -8804,7 +8978,7 @@ public static bool IsIgnoreFormatter(string itemFormatter)
### TooltipHelper.LimitInRect
public static void LimitInRect(Tooltip tooltip, Rect chartRect)
public static void LimitInRect(BaseChart chart, Tooltip tooltip, Rect chartRect)
## TooltipTheme
@@ -9001,6 +9175,10 @@ public static bool IsPointInPolygon(Vector3 p, params Vector3[] polyons)
public static bool IsPointInTriangle(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 check)
### UGLHelper.IsUp
public static bool IsUp(Vector3 p1, Vector3 p2, Vector3 p3)
### UGLHelper.IsValueEqualsColor
public static bool IsValueEqualsColor(Color color1, Color color2)
@@ -9088,6 +9266,11 @@ class in XCharts.Runtime
UI帮助类。
### UIHelper.DrawBackground
public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2)
## ViewControl
class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)

View File

@@ -6,6 +6,10 @@ slug: /changelog
# 更新日志
[master](#master)
[v3.15.0](#v3150)
[v3.14.0](#v3140)
[v3.13.0](#v3130)
[v3.12.1](#v3121)
[v3.12.0](#v3120)
[v3.11.2](#v3112)
[v3.11.1](#v3111)
@@ -77,6 +81,156 @@ slug: /changelog
## master
* (2026.06.03) 增加`Tooltip`通过`TitleLabelStyle``TextStyle``Alignment`设置标题的对齐方式 (#363)
* (2026.05.25) 增加`DataZoom``filterAxisRange`设置坐标轴的范围计算是否受`DataZoom`的影响
* (2026.05.23) 优化`DataZoom``Marquee`框选功能
* (2026.05.23) 修复`DataZoom`内绘制的折线图可能会超出范围的问题
* (2026.05.23) 修复`Axis``inverse`没能正确反转的问题
* (2026.05.23) 增加`LabelStyle``showCondition`,`showFilter`,`showThreshold`可控制`label`显示和隐藏
* (2026.05.22) 增加`LabelStyle``minGap`可避免`label`过于密集
* (2026.05.17) 修复`DataZoom`点击时指示区域不准的问题
* (2026.05.17) 增加`Legend``Width``Height`可设置固定宽高
* (2026.05.17) 修复`Serie``EndLabel``Y`轴是`MinMax`类型时显示的数值不对的问题
* (2026.05.16) 修复`Candlestick`按昨收判断涨跌颜色,一字涨停/跌停显示不对的问题 (#362)
* (2026.03.29) 修复`Legend``Background`区域在`Horizonal`模式下不对的问题
* (2026.03.25) 增加`Chart``Json`导出导入
* (2026.03.10) 增加`Sankey`的线条tooltip触发显示
* (2026.03.10) 增加`UITable`的排序功能支持
* (2026.03.07) 修复`UITable`在尺寸变化时背景没有实时刷新的问题
* (2026.03.06) 优化`UITable`支持万级以上数据量不卡顿
## v3.15.0
版本要点:
* __时间轴与缩放能力增强__新增 `DataZoom.minZoomRatio`(替代 `minShowNum`)、`Chart.useUtc`,并持续优化 `Axis Time` 在缩放与大年份场景下的表现。
* __柱图与坐标轴配置更灵活__新增 `Axis.mainAxis` 控制柱图朝向、`Serie.ignoreZeroOccupy` 控制 0 值柱是否占位、`AxisLine` 延长线配置等。
* __图表样式与交互能力提升__新增 `Pie.pieType``Legend.itemInactiveOpacity``Axis.onLabelClick``Animation.Exchange``LabelStyle.fixedX/fixedY` 等。
* __扩展 UI 组件持续完善__`UITable` 新增 `Title``Viewport` 配置,`UIStatistic.desc` 增强,`Comment.layer` 与坐标刷新体验优化。
* __稳定性与兼容性修复集中推进__修复 `SaveAsImage` 遮挡保存、`Pie` 点击失效、`TMP` 兼容、`Gantt` 时间区间与 2038 年问题、`MarkArea/GridCoord/Axis` 等多项关键问题。
日志详情:
* (2026.03.01) 发布`v3.15.0`版本
* (2026.02.26) 增加`Serie``ignoreZeroOccupy`可设置0数据的Bar是否占位 (#286)
* (2026.02.26) 修复`SaveAsImage`被其他组件遮挡时无法正常保存的问题 (#337)
* (2026.02.26) 增加`Axis``mainAxis`参数设置主轴可控制柱图的朝向 (#331)
* (2026.02.03) 修复`UITable``viewport`在不同的锚点下可能会绘制异常的问题
* (2026.01.15) 修复`Pie`的点击有时候不响应的问题 (#357)
* (2026.01.08) 增加`DataZoom``minZoomRatio`替换旧的`minShowNum` (#350)
* (2025.11.05) 修复`Axis``indicatorLabel`无法隐藏的问题
* (2025.11.03) 增加`Tooltip``Title`可通过`TitleLabelStyle``numericFormatter`格式化时间显示 (#353)
* (2025.10.30) 增加`Chart``useUtc`参数设置显示时间是否用UTC时间
* (2025.10.30) 优化`Candlestick`对时间轴的支持
* (2025.10.30) 增加`Scatter``ignore`支持设置忽略数据
* (2025.10.24) 优化`Sankey`的线条绘制排序
* (2025.10.22) 增加`Pie``pieType`支持实心饼图和线框柄图 (#349)
* (2025.09.05) 优化`MarkLine`的表现
* (2025.09.01) 增加`AxisLine``startExtendLength``endExtendLength`设置轴线的延长线
* (2025.08.27) 修复`Serie``TitleStyle`在数据变更时不及时刷新的问题
* (2025.05.19) 修复`TMP`开启时`Axis`运行报错
* (2025.04.25) 修复`MarkArea`指定`yValue``xValue`时绘制区域不准确的问题
* (2025.04.17) 增加`UITable``Title`支持设置标题
* (2025.04.17) 增加`UITable``Viewport`支持设置表格视口边距边框
* (2025.04.15) 增加`Bar`支持通过`VisualMap`设置颜色
* (2025.04.14) 增加`AxisLabel``showZeroLabel`设置是否显示0刻度
* (2025.04.08) 增加`UIStatistic``desc`描述文本设置支持
* (2025.04.07) 修复`Gantt`甘特图在有多维数据时计算的时间区间不准确的问题
* (2025.04.07) 优化`Axis``Time`时间轴支持设置Custom和ceilRate
* (2025.04.07) 修复`GridCoord`在设置背景色且Serie开启Clip时会覆盖图表的问题
* (2025.04.07) 修复`Gantt`甘特图年份大于2038时显示异常的问题
* (2025.04.07) 修复`Axis``Time`时间轴无法显示大于2038的年份的问题
* (2025.04.06) 修复`Axis``Time`时间轴在有`DataZoom`缩放时文本显示异常的问题
* (2025.03.28) 修复`Pie3D``avoidLabelOverlap`不生效的问题
* (2025.03.27) 增加`Legend``itemInactiveOpacity`可设置非激活状态时的颜色透明度 (#343)
* (2025.03.27) 增加`Axis``onLabelClick`回调事件
* (2025.03.26) 增加`Animation``Exchange`排序交换动画
* (2025.03.22) 增加`Comment``layer`设置层级
* (2025.03.21) 优化`Comment`的坐标刷新
* (2025.03.19) 增加`Serie``Label``formatter`支持`{index}`通配符
* (2025.03.18) 增加`Bar`可添加`TitleStyle`组件支持
* (2025.03.18) 增加`LabelStyle``fixedX``fixedY`可固定label的坐标
* (2025.03.17) 增加`ItemStyle``backgroundGap`可设置数据项背景间隙
## 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
版本要点:
* 完善官网文档的中英文支持
* 优化折线图数据密集时的绘制效果
* 其他问题修复
日志详情:
* (2024.12.01) 发布`v3.12.1`版本
* (2024.11.30) 修复`Tooltip`在图表设置其他锚点时手机上显示位置异常的问题
* (2024.11.27) 修复`Unity6`的一些代码警告问题
* (2024.11.26) 修复`Tooltip`在特殊情况下可能会超出屏幕显示不完整的问题
* (2024.11.24) 修复`UITable`在拖拽时也会点选的问题
* (2024.11.22) 修复`Time`时间轴在开启`Animation`时动态变更效果异常的问题
* (2024.11.18) 优化`Line`在数据点过密时有更好的绘制效果
* (2024.11.16) 修复`Animation`无法通过代码开启的问题 (#334)
* (2024.11.13) 修复`DataZoom`的start和end在代码动态修改时图表不刷新的问题
* (2024.11.05) 修复`Title`设置隐藏后运行还显示的问题
* (2024.11.01) 完善`website`中英文文档
## v3.12.0
版本要点:
@@ -189,12 +343,19 @@ slug: /changelog
* (2024.01.23) 增加`{y}`通配符用于获取Y轴的类目名
* (2024.01.23) 增加`Line`支持X轴和Y轴都为`Category`类目轴
* (2024.01.18) 修复`Animation``type`代码动态修改无效的问题
* (2024.01.16) 增加`UIImage`图片组件
* (2024.01.16) 优化`Background`组件,可设置圆角和边框
* (2024.01.13) 增加`Chart`的更多快捷创建图表菜单
* (2024.01.09) 增加`Background``borderStyle`,给图表默认设置圆角
* (2024.01.07) 修复`Tooltop`的第一个`ContentLabelStyle`设置`color`无效的问题
* (2024.01.03) 增加`UITable``carouselStyle``hoverPause`
* (2024.01.02) 增加`UITable``scrollStyle``borderStyle`
* (2024.01.02) 增加`UITable``columnHeadStyle``opaque`
* (2024.01.01) 调整`UITable``border`边框相关设置,用`BorderStyle`代替
* (2024.01.01) 增加`BorderStyle`边框样式
* (2023.12.26) 增加`Heatmap``maxCache`参数支持
* (2023.12.25) 优化`Line`开启`clip`时绘制的顶点数
* (2023.12.22) 增加`UITable`的行边框
* (2023.12.22) 修复`Scatter`散点图部分边界数据不显示的问题
* (2023.12.21) 修复`TriggerTooltip()`接口在指定0或最大index时可能无法触发的问题
* (2023.12.19) 修复`Legend``LabelStyle`设置`formatter`后不生效的问题
@@ -233,15 +394,27 @@ slug: /changelog
* (2023.11.23) 增加`Axis``Animation`支持动画效果
* (2023.11.16) 取消`Legend``formatter`,用`LabelStyle`的代替
* (2023.11.14) 完善`LabelStyle``formatter`的注释和文档(#291)
* (2023.11.14) 增加`UITable``GetData()``GetContent()`接口
* (2023.11.12) 增加`UITable``onTableClick`点击表格回调
* (2023.11.11) 重构`UITable``SeparatorStyle`,可分开设置行列的分割线
* (2023.11.11) 修复`Documentation`部分注释生成文档不完整的问题 (#290)
* (2023.11.11) 修复`Legend``formatter`在数据变更时没有自动刷新的问题
* (2023.11.05) 增加`UITable``ColumnStyle`重构Column相关参数
* (2023.11.05) 增加`UITable``RowStyle`重构Row相关参数
* (2023.11.05) 修复`SerieEventData``value`一直是0的问题 (#287)
* (2023.11.03) 修复`Bar`设置渐变色时鼠标移出效果异常的问题 (#285)
* (2023.11.02) 优化`SerieData`设置`ignore``formatter`的忽略问题
* (2023.11.01) 增加`UITable``CarouselStyle`轮播功能
* (2023.11.01) 增加`UITable``AddColumn()``UpdateColumn()`接口
* (2023.11.01) 增加`MarkLine``onTop`设置是否显示在最上层
* (2023.10.23) 修复`UITable`点击`Rebuild Object`异常的问题
* (2023.10.23) 修复`UITable`尺寸变化时不刷新的问题
* (2023.10.21) 修复`Pie`有0数据时`Label`的位置异常的问题
* (2023.10.21) 增加`Axis`的对数轴支持子刻度
* (2023.10.19) 修复`Pie`设置玫瑰图时引导线异常的问题
* (2023.10.17) 修复`UITable`首次初始化异常的问题
* (2023.10.17) 增加`UITable`的数据操作接口
* (2023.10.17) 增加`UITable``RefreshTable()`刷新接口
* (2023.10.15) 修复`Line`设置`Animation``AlongPath`时动画异常的问题 (#281)
* (2023.10.12) 修复`MarkLine`指定`yValue`时对数值轴无效的问题
* (2023.10.11) 修复`Serie``showDataDimension`设置无效的问题

View File

@@ -2,8 +2,6 @@
sidebar_position: 31
slug: /configuration
---
import APITable from '@site/src/components/APITable';
# 配置项手册
## Serie 系列
@@ -178,6 +176,7 @@ import APITable from '@site/src/components/APITable';
- [AnimationAddition](#animationaddition)
- [AnimationChange](#animationchange)
- [AnimationExchange](#animationexchange)
- [AnimationFadeIn](#animationfadein)
- [AnimationFadeOut](#animationfadeout)
- [AnimationHiding](#animationhiding)
@@ -236,6 +235,14 @@ class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
数据变更动画。
## AnimationExchange
class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
> 从 `v3.15.0` 开始支持
数据交换动画。一般用于图表数据排序时顺序变化的动画。
## AnimationFadeIn
class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
@@ -262,7 +269,7 @@ class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
## AnimationInfo
class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein), [AnimationFadeOut](#animationfadeout), [AnimationChange](#animationchange), [AnimationAddition](#animationaddition), [AnimationHiding](#animationhiding), [AnimationInteraction](#animationinteraction)
class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein), [AnimationFadeOut](#animationfadeout), [AnimationChange](#animationchange), [AnimationAddition](#animationaddition), [AnimationHiding](#animationhiding), [AnimationInteraction](#animationinteraction), [AnimationExchange](#animationexchange)
> 从 `v3.8.0` 开始支持
@@ -278,7 +285,7 @@ class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein), [Animati
`float` `1000` `v3.8.0`
动画的时长。
动画的时长。默认用于计算动画的速度。也可以通过speed指定速度。
### AnimationInfo.enable
@@ -292,6 +299,12 @@ class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein), [Animati
是否开启反向动画效果。
### AnimationInfo.speed
`float` `0` `v3.14.0`
动画的速度。当指定speed时duration将失效。默认为0表示不指定速度。
## AnimationInteraction
class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
@@ -322,7 +335,7 @@ class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
动画组件用于控制图表的动画播放。支持配置五种动画表现FadeIn渐入动画FadeOut渐出动画Change变更动画Addition新增动画Interaction交互动画。 按作用的对象可以分为两类SerieAnimation系列动画和DataAnimation数据动画
动画组件用于控制图表的动画播放。支持配置五种动画表现FadeIn渐入动画FadeOut渐出动画Change变更动画Addition新增动画Interaction交互动画Exchange交换动画。 按作用的对象可以分为两类SerieAnimation系列动画和DataAnimation数据动画
### AnimationStyle.addition
@@ -352,6 +365,12 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
是否开启动画效果。
### AnimationStyle.exchange
[AnimationExchange](#animationexchange) `v3.15.0`
交换动画配置。如在排序柱图中有效。
### AnimationStyle.fadeIn
[AnimationFadeIn](#animationfadein) `v3.8.0`
@@ -599,6 +618,12 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类:
对数轴是否以自然数 e 为底数,为 true 时 logBase 失效。
### Axis.mainAxis
`bool` `false` `v3.15.0`
是否为主轴。当XY轴类型都相同时设置为主轴的轴会决定朝向如横向柱图和纵向柱图。
### Axis.max
`double`
@@ -785,6 +810,12 @@ class in XCharts.Runtime / 继承自: [LabelStyle](#labelstyle)
是否显示第一个文本。
### AxisLabel.showZeroLabel
`bool` `true` `v3.15.0`
是否显示0刻度文本。
### AxisLabel.textLimit
[TextLimit](#textlimit)
@@ -803,6 +834,12 @@ class in XCharts.Runtime / 继承自: [BaseLine](#baseline)
轴线箭头。
### AxisLine.endExtendLength
`float`
轴线终点延长线长度。
### AxisLine.onZero
`bool`
@@ -815,6 +852,12 @@ X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一
是否显示箭头。
### AxisLine.startExtendLength
`float`
轴线起点延长线长度。
## AxisMinorSplitLine
class in XCharts.Runtime / 继承自: [BaseLine](#baseline)
@@ -1243,7 +1286,9 @@ class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle), [AxisAnima
class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent), [IPropertyChanged](#ipropertychanged)
图表注解组件。
> 从 `v3.15.0` 开始支持
图表注解组件。用于标注图表中的特殊信息。
### Comment.items
@@ -1257,6 +1302,17 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent), [IPropert
所有组件的文本样式。
### Comment.layer
[CommentLayer](#commentlayer) `v3.15.0`
注解的显示层级。
可选:
- `Lower`: 注解在系列下方。
- `Upper`: 注解在系列上方。
### Comment.markStyle
[CommentMarkStyle](#commentmarkstyle)
@@ -1466,11 +1522,11 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息
选取框样式。
### DataZoom.minShowNum
### DataZoom.minZoomRatio
`int` `2`
`float` `0.2f`
最小显示数据个数。当DataZoom放大到最大时最小显示的数据个数
缩放区域组件的最小缩放比例范围0f-1f
### DataZoom.orient
@@ -2234,6 +2290,12 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent), [ISerie
数据项背景颜色。
### ItemStyle.backgroundGap
`float` `v3.15.0`
数据项背景间隙。
### ItemStyle.backgroundWidth
`float`
@@ -2460,11 +2522,23 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent), [ISerie
距离轴线的距离。
### LabelStyle.fixedX
`float` `0` `v3.15.0`
固定的X值。不为0时会固定在指定的X值上。
### LabelStyle.fixedY
`float` `0` `v3.15.0`
固定的Y值。不为0时会固定在指定的Y值上。
### LabelStyle.formatter
`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
@@ -2611,6 +2685,12 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent), [IPropert
图例标记的图形高度。
### Legend.itemInactiveOpacity
`float` `1` `v3.15.0`
图例标记的图形在非激活状态下的颜色透明度。
### Legend.itemOpacity
`float` `1`
@@ -2686,11 +2766,11 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent), [IPropert
class in XCharts.Runtime / 继承自: [ComponentTheme](#componenttheme)
### LegendTheme.unableColor
### LegendTheme.inactiveColor
`Color`
文本颜色。
非激活状态时的颜色。
## Level
@@ -3090,7 +3170,7 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
`string`
标线名称将会作为文字显示。label的formatter可通过{b}显示名称,通过{c}显示数值。
标线名称将会作为文字显示。label的formatter可通过\{b\}显示名称,通过\{c\}显示数值。
### MarkLineData.startSymbol
@@ -3106,7 +3186,7 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
可选:
- `None`: 标线类型
- `Custom`: 自定义。可自定义xy坐标或数值。
- `Min`: 最小值。
- `Max`: 最大值。
- `Average`: 平均值。
@@ -3116,25 +3196,25 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
`float`
相对原点的 x 坐标单位像素。当type为None时有效。
相对原点的 x 坐标单位像素。当type为Custom时有效。
### MarkLineData.xValue
`double`
X轴上的指定值。当X轴为类目轴时指定值表示类目轴数据的索引否则为具体的值。当type为None时有效。
X轴上的指定值。当X轴为类目轴时指定值表示类目轴数据的索引否则为具体的值。当type为Custom时有效。
### MarkLineData.yPosition
`float`
相对原点的 y 坐标单位像素。当type为None时有效。
相对原点的 y 坐标单位像素。当type为Custom时有效。
### MarkLineData.yValue
`double`
Y轴上的指定值。当Y轴为类目轴时指定值表示类目轴数据的索引否则为具体的值。当type为None时有效。
Y轴上的指定值。当Y轴为类目轴时指定值表示类目轴数据的索引否则为具体的值。当type为Custom时有效。
### MarkLineData.zeroPosition
@@ -3299,6 +3379,17 @@ grid 组件离容器上侧的距离。
class in XCharts.Runtime / 继承自: [Serie](#serie)
### Pie.pieType
[PieType](#pietype) `v3.15.0`
饼图类型。
可选:
- `Solid`: 实心饼图 - 默认填充样式
- `Wireframe`: 线框饼图 - 仅显示轮廓线框
### Pie.radiusGradient
`bool` `false` `v3.8.1`
@@ -3577,6 +3668,12 @@ class in XCharts.Runtime / 继承自: [BaseSerie](#baseserie), [IComparable](htt
忽略数据的默认值。当ignore为true才有效。
### Serie.ignoreZeroOccupy
`bool` `false` `v3.15.0`
柱图是否忽略值为0的柱子占位。开启后值为0的柱子将不会占用空间柱子之间的间距会根据实际显示的柱子自动调整。一般用在柱状图中。
### Serie.index
`int`
@@ -3757,6 +3854,12 @@ class in XCharts.Runtime / 继承自: [BaseSerie](#baseserie), [IComparable](htt
半径。radius[0]表示内径radius[1]表示外径。
### Serie.realtimeSort
`bool` `false` `v3.14.0`
是否开启实时排序用来实现动态排序图效果。目前仅在Bar中生效。
### Serie.right
`float`
@@ -4368,12 +4471,24 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) / 子类
系列数据项的标记的图形
### SymbolStyle.borderWidth
`float` `0f` `v3.13.0`
图形的边框宽度。
### SymbolStyle.color
`Color32`
图形的颜色。
### SymbolStyle.emptyColor
`Color32` `v3.13.0`
空心图形的颜色。
### SymbolStyle.gap
`float` `0`
@@ -4416,6 +4531,12 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) / 子类
标记的大小。
### SymbolStyle.size2
`float` `0f` `v3.13.0`
标记的大小。当为Rect时size2表示高度。
### SymbolStyle.type
[SymbolType](#symboltype)
@@ -4553,10 +4674,6 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
文本的相关设置。
### TextStyle.tMPAlignment
`TextAlignmentOptions`
### TextStyle.tMPFont
`TMP_FontAsset`
@@ -4804,11 +4921,17 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent)
边框线宽。
### Tooltip.columnGapWidths
`List<float>` `v3.14.0`
内容部分的列间距。当只有一列时,只表示第二列的间距。
### Tooltip.contentLabelStyles
`List<LabelStyle>`
内容部分的文本样式列表。和列一一对应
内容部分的文本样式列表。第一个表示第一列的文本样式,以此类推
### Tooltip.fixedHeight
@@ -4850,7 +4973,7 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent)
`string`
提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 换行。用|来表示多个列的分隔。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。<br/> {i}或-表示忽略当前项。 {.}为当前所指示的serie或数据项的对应颜色的圆点。<br/> {a}为当前所指示的serie或数据项的系列名name。<br/> {b}为当前所指示的serie或数据项的数据项serieData的name或者类目值如折线图的X轴。<br/> {c}为当前所指示的serie或数据项的y维dimesion为1的数值。<br/> {d}为当前所指示的serie或数据项的y维dimesion为1百分比值注意不带%号。<br/> {e}为当前所指示的serie或数据项的数据项serieData的name。<br/> {f}为当前所指示的serie的默认维度的数据总和。<br/> {g}为当前所指示的serie的数据总个数。<br/> {h}为当前所指示的serie的十六进制颜色值。<br/> {y}为当前所指示的serie的y轴的类目值。<br/> {c0}表示当前数据项维度为0的数据。<br/> {c1}表示当前数据项维度为1的数据。<br/> {d3}表示维度3的数据的百分比。它的分母是默认维度一般是1维度数据。<br/> |表示多个列的分隔。<br/> 示例:"{i}", "{.}|{a}|{c}", "{.}|{b}|{c2:f2}", "{.}|{b}|{y}"
提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 换行。用|来表示多个列的分隔。 模板变量有\{.\}、\{a\}、\{b\}、\{c\}、\{d\}、\{e\}、\{f\}、\{g\}。<br/> \{i\}或-表示忽略当前项。 \{.\}为当前所指示的serie或数据项的对应颜色的圆点。<br/> \{a\}为当前所指示的serie或数据项的系列名name。<br/> \{b\}为当前所指示的serie或数据项的数据项serieData的name或者类目值如折线图的X轴。<br/> \{c\}为当前所指示的serie或数据项的y维dimesion为1的数值。<br/> \{d\}为当前所指示的serie或数据项的y维dimesion为1百分比值注意不带%号。<br/> \{e\}为当前所指示的serie或数据项的数据项serieData的name。<br/> \{f\}为当前所指示的serie的默认维度的数据总和。<br/> \{g\}为当前所指示的serie的数据总个数。<br/> \{h\}为当前所指示的serie的十六进制颜色值。<br/> \{y\}为当前所指示的serie的y轴的类目值。<br/> \{c0\}表示当前数据项维度为0的数据。<br/> \{c1\}表示当前数据项维度为1的数据。<br/> \{d3\}表示维度3的数据的百分比。它的分母是默认维度一般是1维度数据。<br/> |表示多个列的分隔。<br/> 示例:"\{i\}", "\{.\}|\{a\}|\{c\}", "\{.\}|\{b\}|\{c2:f2\}", "\{.\}|\{b\}|\{y\}"
### Tooltip.itemHeight
@@ -4935,7 +5058,7 @@ serie的符号标志。
`string`
提示框标题内容的字符串模版格式器。支持用 \n 换行。可以单独设置占位符{i}表示忽略不显示title。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。<br/> {.}为当前所指示或index为0的serie的对应颜色的圆点。<br/> {a}为当前所指示或index为0的serie的系列名name。<br/> {b}为当前所指示或index为0的serie的数据项serieData的name或者类目值如折线图的X轴。<br/> {c}为当前所指示或index为0的serie的y维dimesion为1的数值。<br/> {d}为当前所指示或index为0的serie的y维dimesion为1百分比值注意不带%号。<br/> {e}为当前所指示或index为0的serie的数据项serieData的name。<br/> {h}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。<br/> {f}为数据总和。<br/> {g}为数据总个数。<br/> {y}为value所对应的y轴的类目值。<br/> {.1}表示指定index为1的serie对应颜色的圆点。<br/> {a1}、{b1}、{c1}中的1表示指定index为1的serie。<br/> {c1:2}表示索引为1的serie的当前指示数据项的第3个数据一个数据项有多个数据index为2表示第3个数据。<br/> {c1:2-2}表示索引为1的serie的第3个数据项的第3个数据也就是要指定第几个数据项时必须要指定第几个数据。<br/> {d1:2:f2}表示单独指定了数值的格式化字符串为f2不指定时用numericFormatter。<br/> {d:0.##} 表示单独指定了数值的格式化字符串为 0.## 用于百分比保留2位有效数同时又能避免使用 f2 而出现的类似于"100.00%"的情况 )。<br/> 示例:"{a}:{c}"、"{a1}:{c1:f1}"、"{a1}:{c1:0:f1}"、"{a1}:{c1:1-1:f1}"
提示框标题内容的字符串模版格式器。支持用 \n 换行。可以单独设置占位符\{i\}表示忽略不显示title。 模板变量有\{.\}、\{a\}、\{b\}、\{c\}、\{d\}、\{e\}、\{f\}、\{g\}。<br/> \{.\}为当前所指示或index为0的serie的对应颜色的圆点。<br/> \{a\}为当前所指示或index为0的serie的系列名name。<br/> \{b\}为当前所指示或index为0的serie的数据项serieData的name或者类目值如折线图的X轴。<br/> \{c\}为当前所指示或index为0的serie的y维dimesion为1的数值。<br/> \{d\}为当前所指示或index为0的serie的y维dimesion为1百分比值注意不带%号。<br/> \{e\}为当前所指示或index为0的serie的数据项serieData的name。<br/> \{h\}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。<br/> \{f\}为数据总和。<br/> \{g\}为数据总个数。<br/> \{y\}为value所对应的y轴的类目值。<br/> \{.1\}表示指定index为1的serie对应颜色的圆点。<br/> \{a1\}、\{b1\}、\{c1\}中的1表示指定index为1的serie。<br/> \{c1:2\}表示索引为1的serie的当前指示数据项的第3个数据一个数据项有多个数据index为2表示第3个数据。<br/> \{c1:2-2\}表示索引为1的serie的第3个数据项的第3个数据也就是要指定第几个数据项时必须要指定第几个数据。<br/> \{d1:2:f2\}表示单独指定了数值的格式化字符串为f2不指定时用numericFormatter。<br/> \{d:0.##\} 表示单独指定了数值的格式化字符串为 0.## 用于百分比保留2位有效数同时又能避免使用 f2 而出现的类似于"100.00%"的情况 )。<br/> 示例:"\{a\}:\{c\}"、"\{a1\}:\{c1:f1\}"、"\{a1\}:\{c1:0:f1\}"、"\{a1\}:\{c1:1-1:f1\}"
### Tooltip.titleHeight

View File

@@ -5,183 +5,147 @@ slug: /faq
# 常见问题
[FAQ 1如何调整坐标轴与背景的边距](#如何调整坐标轴与背景的边距)
[FAQ 2如何让初始动画重新播放](#如何让初始动画重新播放)
[FAQ 3如何自定义折线图饼图的颜色](#如何自定义折线图饼图的颜色)
[FAQ 4如何给坐标轴上的文本加上单位](#如何给坐标轴上的文本加上单位)
[FAQ 5如何让柱形图的柱子堆叠显示](#如何让柱形图的柱子堆叠显示)
[FAQ 6如何让柱形图的柱子同柱但不重叠](#如何让柱形图的柱子同柱但不重叠)
[FAQ 7如何调整柱形图的柱子宽度和间距](#如何调整柱形图的柱子宽度和间距)
[FAQ 8如何调整柱形图单个柱子的颜色](#如何调整柱形图单个柱子的颜色)
[FAQ 9如何调整图表的对齐方式](#如何调整图表的对齐方式)
[FAQ 10可以显示超过1000以上的大数据吗](#可以显示超过1000以上的大数据吗)
[FAQ 11折线图可以画虚线、点线、点划线吗](#折线图可以画虚线点线点划线吗)
[FAQ 12如何限定Y轴的值范围](#如何限定y轴的值范围)
[FAQ 13如何自定义数值轴刻度大小](#如何自定义数值轴刻度大小)
[FAQ 14如何在数据项顶上显示文本](#如何在数据项顶上显示文本)
[FAQ 15如何给数据项自定义图标](#如何给数据项自定义图标)
[FAQ 16锯齿太严重如何让图表更顺滑](#锯齿太严重如何让图表更顺滑)
[FAQ 17为什么鼠标移上图表Tooltip不显示](#为什么鼠标移上图表tooltip不显示)
[FAQ 18如何取消Tooltip的竖线](#如何取消tooltip的竖线)
[FAQ 19如何自定义Tooltip的显示内容](#如何自定义tooltip的显示内容)
[FAQ 20如何让y轴显示多位小数](#如何让y轴显示多位小数)
[FAQ 21如何用代码动态更新数据](#如何用代码动态更新数据)
[FAQ 22如何显示图例为什么有时候图例无法显示](#如何显示图例为什么有时候图例无法显示)
[FAQ 23如何做成预设](#如何做成预设)
[FAQ 24如何在图表上画点画线等自定义内容](#如何在图表上画点画线等自定义内容)
[FAQ 25如何实现心电图类似的数据移动效果](#如何实现心电图类似的数据移动效果)
[FAQ 26如何使用背景组件有什么条件限制](#如何使用背景组件有什么条件限制)
[FAQ 27Mesh can not have more than 65000 vertices](#mesh_cannot_have_more_than_65000_vertices)
[FAQ 28为什么serie里设置的参数运行后又被重置了?](#为什么serie里设置的参数运行后又被重置了)
[FAQ 29如何修改serie的symbol的颜色?](#如何修改serie的symbol的颜色)
[FAQ 30导入或更新XCharts时TMP报错如何处理](#导入或更新xcharts时tmp报错怎么办)
[FAQ 31支持空数据吗如何实现折线图断开的效果?](#支持空数据吗如何实现折线图断开的效果)
[FAQ 322.x版本升级3.x版本时常见的问题有哪些](#xcharts2升级xcharts3时常见的问题有哪些)
[FAQ 33折线图如何两边不留空白而从0坐标开始显示](#折线图如何两边不留空白而从0坐标开始显示)
[FAQ 34如何设置部分Serie不显示Tooltip](#如何设置部分serie不显示tooltip)
## 如何调整坐标轴与背景的边距
## FAQ 1如何调整坐标轴与背景的边距
调整`Grid`组件,可调整上下左右边距。
## 如何让初始动画重新播放
## FAQ 2如何让初始动画重新播放
调用`chart.AnimationReset()`接口。
## 如何自定义折线图饼图的颜色
## FAQ 3如何自定义折线图饼图的颜色
通过`Theme``colorPalette`调整,或者部分`Serie`下的`LineStyle``ItemStyle`
## 如何给坐标轴上的文本加上单位
## FAQ 4如何给坐标轴上的文本加上单位
通过`formatter``numericFormatter`参数,在`Legend``Axis``AxisLabel``Tooltop``Serie``Label`都提供该参数的配置。
## 如何让柱形图的柱子堆叠显示
## FAQ 5如何让柱形图的柱子堆叠显示
设置`Serie`下的`stack``stack`相同的`serie`会堆叠显示在一个柱子上。
## 如何让柱形图的柱子同柱但不重叠
## FAQ 6如何让柱形图的柱子同柱但不重叠
设置`Serie`下的`barGap``-1``stack`为空。
## 如何调整柱形图的柱子宽度和间距
## FAQ 7如何调整柱形图的柱子宽度和间距
调整`Serie`下的`barWidth``barGap`,多个`serie`时最后一个`serie``barWidth``barGap`有效。
## 如何调整柱形图单个柱子的颜色
## FAQ 8如何调整柱形图单个柱子的颜色
可通过调整单个`Data`下的`ItemStyle`调整,也可以通过两个`serie`同柱不堆叠来实现,通过设置数据项为`0`来达到类似效果。
## 如何调整图表的对齐方式
## FAQ 9如何调整图表的对齐方式
调整RectTransform的锚点和UGUI的其他组件的用法一致。
## 可以显示超过1000以上的大数据吗
## FAQ 10可以显示超过1000以上的大数据吗
可以。但`UGUI`对单个`Graphic`限制`65000`个顶点,所以太多的数据不一定能显示完全。可通过设置采样距离`sampleDist`开启采样简化过密曲线。也可以通过设置一些参数来减少图表的顶点数有助于显示更多数据。如缩小图表的尺寸,关闭或减少坐标轴的客户端绘制,关闭`Serie``symbol``label`显示等。折线图的普通线图`Normal`比平滑线图`Smooth`占用顶点数更少。`1.5.0`以上版本可以设置`large``largeThreshold`参数来开启性能模式。
## 折线图可以画虚线点线点划线吗
## FAQ 11折线图可以画虚线点线点划线吗
可以。通过`Serie`下的`lineType`选择线条样式。当要显示的数据过多(成千以上)数据间过密时建议使用`Normal`或者`Step`样式。
## 如何限定y轴的值范围
## FAQ 12如何限定Y轴的值范围
设置`Axis`下的`minMaxType``Custom`,自定义`min``max`
## 如何自定义数值轴刻度大小
## FAQ 13如何自定义数值轴刻度大小
默认时通过`Axis`下的`splitNumer`进行自动划分。也可以设置`interval`自定义刻度大小。
## 如何在数据项顶上显示文本
## FAQ 14如何在数据项顶上显示文本
通过设置`Serie`下的`Label`。3.0版本需要先添加`LabelStyle`组件。
## 如何给数据项自定义图标
## FAQ 15如何给数据项自定义图标
通过设置`Serie``data`下的数据项可单独设置`icon`相关参数。
## 锯齿太严重如何让图表更顺滑
## FAQ 16锯齿太严重如何让图表更顺滑
开启抗锯齿设置(在`Unity`里设置。调整UI渲染模式为`Camera`模式,开启`MSAA`,设置`4`倍或更高抗锯齿。
## 为什么鼠标移上图表tooltip不显示
## FAQ 17为什么鼠标移上图表Tooltip不显示
确认`Tooltip`是否开启;确认父节点是否关闭了鼠标事件。
## 如何取消tooltip的竖线
## FAQ 18如何取消Tooltip的竖线
设置`Tooltip``type``None`。或者调整`lineStyle`的参数。
## 如何自定义tooltip的显示内容
## FAQ 19如何自定义Tooltip的显示内容
自定义总的内容可以通过`Tooltip``formatter`。如果只是想调整所有的`serie`的显示格式可以用`itemFormatter``titleFormatter`结合。如果想每个`serie`的显示格式不一样,可以定制`serie``itemStyle`里的`tooltipFormatter`。具体的用法请查阅[XCharts配置项手册](https://xcharts-team.github.io/docs/configuration#Tooltip-itemFormatter)。
## 如何让y轴显示多位小数
## FAQ 20如何让y轴显示多位小数
设置`Axis`下的`AxisLabel`中的`formatter``{value:f1}``{value:f2}``1.5.0`及以上版本通过`numericFormatter`设置。
## 如何用代码动态更新数据
## FAQ 21如何用代码动态更新数据
请查阅`Example`下的代码,`Example13_LineSimple.cs`就是一个简单添加数据构建折线图的例子,其他`Demo`也都是通过代码控制不同的组件实现不同的功能相关API请查看文档[XChartsAPI接口](api.md) 。
## 如何显示图例为什么有时候图例无法显示
## FAQ 22如何显示图例为什么有时候图例无法显示
首先,你的`serie`里的`name`需有值不为空。然后开启`Legend`显示,里面的`data`可以默认为空,表示显示所有的图例。如果你只想显示部分`serie`的图例,在`data`中填入要显示的图例的`name`即可。如果`data`中的值都不是系列的`name`,那图例就不会显示。
## 如何做成预设
## FAQ 23如何做成预设
做成prefab前执行一下`Rebuild Chart Object`重新刷新节点,避免有冗余的节点存在。
## 如何在图表上画点画线等自定义内容
## FAQ 24如何在图表上画点画线等自定义内容
`XCharts`有自定义绘制回调`onCustomDraw`,具体可参考`Example12_CustomDrawing.cs`
## 如何实现心电图类似的数据移动效果
## FAQ 25如何实现心电图类似的数据移动效果
参考`Example`目录下的`Example_Dynamic.cs`。主要通过设置`maxCache`参数实现。`axis``serie`都设置相同的`maxCache``maxCache`可固定数据个数,当数据超过设定时会先删除第一个在添加新数据,实现数据移动效果。
## 如何使用背景组件有什么条件限制
## FAQ 26如何使用背景组件有什么条件限制
设置`background`组件的`show``true`
## 区域折线图在用半透明颜色时有时候会一条叠加的线
这是区域折线图绘制的bug。可以用浅的不透的颜色替代半透明颜色。
## mesh_cannot_have_more_than_65000_vertices
## FAQ 27Mesh can not have more than 65000 vertices
这是`UGUI`对单个`Graphic`的顶点数限制。`XCharts`是将图形绘制在单个`Graphic`上,所以也会有这个限制。解决的办法可以参考:[FAQ 10可以显示超过1000以上的大数据吗](#可以显示超过1000以上的大数据吗)
## 为什么serie里设置的参数运行后又被重置了
## FAQ 28为什么serie里设置的参数运行后又被重置了
检测下代码里是否调用了`RemoveData()`并重新添加`Serie`了。如果想保留`Serie`的配置可以只`ClearData()`,然后重新添加数据。
## 如何修改serie的symbol的颜色
## FAQ 29如何修改serie的symbol的颜色
`Symbol` 的颜色是使用的 `ItemStyle``color`
## 导入或更新xcharts时tmp报错怎么办
## FAQ 30导入或更新XCharts时TMP报错如何处理
XCharts默认时不开启TMP所以asmdef上没有TMP的引用。当本地开启TMP后再更新XCharts可能会出现这个问题。可通过以下两种方式解决
XCharts默认时不开启TMP所以asmdef上没有TMP的引用。当本地开启TMP后再更新XCharts可能会出现这个问题。可通过以下两种方式的任意一种解决:
1. 找到`XCharts.Runtime.asmdef``XCharts.Editor.asmdef`,手动加上 `TextMeshPro`的引用
2. 移除`PlayerSetting``Scripting Define Symbols``dUI_TextMeshPro`
`3.8.0`版本后增加[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)守护程序将XCharts-Daemon导入项目后在更新XCharts时守护程序会自动根据本地开启的TMP情况刷新asmdef确保编译正常。
## 支持空数据吗如何实现折线图断开的效果
## FAQ 31支持空数据吗如何实现折线图断开的效果
`Serie``data``double`类型,所以无法表示空数据。可通过开启`Serie``ignore`和指定`ignoreValue`来达到空数据的效果。也可以每个`SerieData`设置`ignore`参数。忽略数据后断开还是连接可设置`ignoreLineBreak`参数。
## xcharts2升级xcharts3时常见的问题有哪些
## FAQ 322.x版本升级3.x版本时常见的问题有哪些
1. 'XCharts.Runtime.XChartsMgr' is missing the class attribute 'ExtensionOfNativeClass'!
3.x版本时不需要挂载XChartsMgr直接删掉场景上的`_xcharts_`节点即可。
1. 出现:`'XCharts.Runtime.XChartsMgr' is missing the class attribute 'ExtensionOfNativeClass'!`的问题时是因为3.x版本时不需要挂载XChartsMgr直接删掉场景上的`_xcharts_`节点即可。
## 折线图如何两边不留空白而从0坐标开始显示
## FAQ 33折线图如何两边不留空白而从0坐标开始显示
设置X轴的`boundaryGap`参数。
## 如何设置部分serie不显示tooltip
## FAQ 34如何设置部分Serie不显示Tooltip
`serie``itemStyle``itemFormatter`设置为`-`可以忽略`tooltip`
`serie``itemStyle``itemFormatter`设置为`-`可以忽略`serie``tooltip`
## FAQ 35区域折线图在用半透明颜色时有时候会一条叠加的线
这是区域折线图绘制的bug。可以用浅的不透的颜色替代半透明颜色。

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` |
| ----- |--|--|--|--|--|--|
| 订阅费用 | -- | `98`¥ | `298`¥ | 首年`1298`¥<br/>后续`298¥`* | 首年`1698`¥<br/>后续`298¥`* | `联系我们` |
| 订阅时长 | -- | `7`天* | `1`年 | `1`年 | `1`年 | `1` |
| 拥有席位 | -- | `1`个席位 | `1`个席位 |`1`个席位|`1`个席位|`5`个以上席位|
| 增加席位 | -- | -- | -- | -- |支持|支持|
| __`服务方式:`__|
| 官方QQ群交流 | √ | √ | √ | √ | √ | √ |
| QQ一对一交流 | | √ | √ | √ | √ | √ |
| 专属VIP群交流 | | | √ | √ | √ | √ |
| 微信交流 | | | | | √ | √(企业专属群) |
| 电话交流 | | | | | | √ |
| __`服务内容:`__|
| 可商用可二次开发 | √ | √ | √ | √ | √ | √ |
| 有问即答 | | √ | √ | √ | √ | √ |
| 新手入门指导 | | √ | √ | √ | √ | √ |
| 开发优化指导 | | √ | √ | √ | √ | √ |
| 其他技术支持 | | | √ | √ | √ | √ |
| 问题及时处理 | | | √ | √ | √ | √ |
| 需求优先考虑 | | | √ | √ | √ | √ |
| 可另付费定制 | | | √ | √ | √ | √ |
| 可另付费加急 | | | √ | √ | √ | √ |
| 扩展UI组件 | | | √ | √ | √ | √ |
| 首页赞助展示 | | | | | | √ |
| 付费方式 | | | 二维码 | 二维码 | __公对公转账__* | __公对公转账__* |
| 支持开发票 | | | 普票 | 普票 | __可开专票__ | __可开专票__ |
| 扩展图表购买 | | | 按需购买 | __全部免费__* | __全部免费__* | __全部免费__* |
| 扩展图表源码 | | | 永久持有 | 永久持有 | 永久持有 | 永久持有 |
| 扩展图表更新 | | | 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) |
| 权益/服务 | 免费用户 | 个人 VIP | 个人 SVIP | 企业 VIP | 企业 SVIP |
|-------------------|----------|----------|-----------------|-----------------|----------------|
| **订阅费用** | — | 298¥/年 | 首年 1298¥<br/>续费 298¥/年 | 首年 1698¥<br/>续费 298¥/年 | 定制报价 |
| **服务时长** | — | 1 年 | 1 年 | 1 年 | 1 年 |
| **服务席位** | — | 1 个 | 1 个 | 1 个 | ≥5 个 |
| **增加席位** | — | — | — | 支持298¥/席位/年) | 支持(定制报价)|
| **支持方式** | | | | | |
| - Github Issues | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| - 官方 QQ 群 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| - QQ 一对一支持 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| - 专属 VIP 群 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| - 微信支持 | | — | — | ✔️ | ✔️ |
| - 电话支持 | — | — | — | — | ✔️ |
| - 专属企业群 | — | — | — | — | ✔️ |
| **核心权益** | | | | | |
| - 商用与二次开发 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| - 即时技术支持 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| - 开发优化指导 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| - 需求优先处理 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| - 付费定制 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| - 扩展 UI 组件 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| - 扩展图表免费使用 | — | 按需购买 | ✔️(全量) | ✔️(全量) | ✔️(全量) |
| **企业专属权益** | | | | | |
| - 电子发票 | | ✔️ | ✔️ | ✔️ | ✔️ |
| - 专用发票 | — | — | — | ✔️ | ✔️ |
| - 首页赞助展示 | — | — | — | — | ✔️ |
| **源码与更新** | | | | | |
| - 永久持有源码 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| - 1 年更新支持 | — | ✔️ | ✔️ | ✔️ | ✔️ |
| **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¥ |
| 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¥ |
| 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需要您的支持和帮助。
## 支持我们
## 二维码
如果看不到二维码图片可以加Q联系`XCharts技术支持:3525422251`或邮件`monitor1394@gmail.com`咨询。
![alipay-qrcode](img/support_alipay.png)
![wechat-qrcode](img/support_wechat.png)
- **社区支持**:欢迎在 GitHub 为 XCharts 点 ⭐️ [Star 支持](https://github.com/XCharts-Team/XCharts)
- **扫码捐助**
![微信支付](img/support_wechat.png)
![支付宝](img/support_alipay.png)

View File

@@ -6,7 +6,11 @@ slug: /tutorial01
# 教程5分钟上手 XCharts 3.0
> Note本教程仅适用XCharts 3.x版本2.x版本请看 [教程5分钟上手XCharts 2.0](https://github.com/XCharts-Team/XCharts/blob/2.0/Doc/教程5分钟上手XCharts.md)
:::warning
Note本教程仅适用XCharts 3.x版本2.x版本请看 [教程5分钟上手XCharts 2.0](https://github.com/XCharts-Team/XCharts/blob/2.0/Doc/教程5分钟上手XCharts.md)
:::
## XCharts的前提条件
@@ -22,7 +26,7 @@ XCharts是一个Unity图表插件目前只能在Unity平台使用。
## XCharts的获取和导入
XCharts主要通过Github来维护更新和发布可以到【Github主页】(https://github.com/XCharts-Team)进行下载获取源码和Pacakge对于无Github访问条件的用户可以访问[【国内镜像】](https://gitee.com/monitor1394/unity-ugui-XCharts)进行下载。国内镜像的版本更新可能会相对滞后。
XCharts主要通过Github来维护更新和发布可以到[【Github主页】](https://github.com/XCharts-Team)进行下载获取源码和Pacakge对于无Github访问条件的用户可以访问[【国内镜像】](https://gitee.com/monitor1394/unity-ugui-XCharts)进行下载。国内镜像的版本更新可能会相对滞后。
XCharts可通过以下任意一种方式导入到你的项目
@@ -54,7 +58,11 @@ XCharts-Daemon的导入方式可参考刚才的XCharts导入方式。可以通
导入XCharts并编译通过后Unity编辑器的菜单栏会显示XCharts这时可以开始使用XCharts了。
>NoteUnity的菜单栏出现XCharts菜单时才表示XCharts可用。
:::tip
Unity的菜单栏出现XCharts菜单时才表示XCharts可用。
:::
### 添加一个简单图表
@@ -85,7 +93,11 @@ Serie支持多维数据一般折线图只用到二维数据第一维表示
![op_addserie](img/tutorial01_addserie.png)
![linechart2](img/tutorial01_linechart2.png)
>NoteSerie通过`Add Serie`按钮添加。可添加不同类型的Serie。[XCharts有哪些Serie](https://xcharts-team.github.io/docs/configuration#serie-系列)
:::tip
Serie通过`Add Serie`按钮添加。可添加不同类型的Serie。[XCharts有哪些Serie](https://xcharts-team.github.io/docs/configuration#serie-系列)
:::
### 添加其他主组件
@@ -93,7 +105,11 @@ Serie支持多维数据一般折线图只用到二维数据第一维表示
![op_addcomponent](img/tutorial01_addcomponent.png)
>Note主组件通过`Add Component`按钮添加。[XCharts有哪些主组件](https://xcharts-team.github.io/docs/configuration/#maincomponent-主组件)
:::tip
主组件通过`Add Component`按钮添加。[XCharts有哪些主组件](https://xcharts-team.github.io/docs/configuration/#maincomponent-主组件)
:::
### 添加Serie组件
@@ -102,7 +118,11 @@ Serie只自带了几个常见的组件其他组件用到时需额外添加。
![op_addseriecomponent](img/tutorial01_addseriecomponent.png)
![linechart3](img/tutorial01_linechart3.png)
>NoteSerie组件通过Serie右边的按钮添加。[XCharts有哪些Serie组件](https://xcharts-team.github.io/docs/configuration/#iseriecomponent-可添加到serie的组件)
:::tip
Serie组件通过Serie右边的按钮添加。[XCharts有哪些Serie组件](https://xcharts-team.github.io/docs/configuration/#iseriecomponent-可添加到serie的组件)
:::
### 添加SerieData组件
@@ -111,7 +131,11 @@ Serie只自带了几个常见的组件其他组件用到时需额外添加。
![op_addseriedatacomponent](img/tutorial01_addseriedatacomponent.png)
![linechart4](img/tutorial01_linechart4.png)
>NoteSerieData组件通过展开SerieData后Component右边的按钮添加。[XCharts有哪些SerieData组件](https://xcharts-team.github.io/docs/configuration/#iseriedatacomponent-可添加到seriedata的组件)
:::tip
SerieData组件通过展开SerieData后Component右边的按钮添加。[XCharts有哪些SerieData组件](https://xcharts-team.github.io/docs/configuration/#iseriedatacomponent-可添加到seriedata的组件)
:::
### 更多组件和配置参数
@@ -131,7 +155,11 @@ XCharts是数据和参数驱动的。想要什么效果只需要去调整对
2. 如果`Serie``ItemStyle`配置有非`0000`颜色值,则优先用这个颜色值。
3. 否则颜色值取自主题`Theme``Color Palette`
>Note通常颜色值为0000时表示用主题默认颜色其他参数为0或null时表示用主题默认配置设置颜色时注意透明度。
:::tip
通常颜色值为0000时表示用主题默认颜色其他参数为0或null时表示用主题默认配置设置颜色时注意透明度。
:::
### 用代码添加折线图
@@ -212,7 +240,11 @@ for (int i = 0; i < 10; i++)
如果一个Chart里面有多个系列时则Axis的data只需要加一次不要多个循环加重复了。
>记住Axis的数据个数要和Serie的数据个数一致。
:::danger
请确保Axis的数据个数和Serie的数据个数一致。
:::
完整代码请查阅`Examples``Example13_LineSimple.cs`
@@ -227,7 +259,11 @@ XCharts默认使用的是Unity默认字体`Arial`在WebGL平台上可能无
字体设置好后,新创建的图表就会用新设置的字体了。对于旧图表,可以点击`Rebuild Chart Object`进行刷新。
>Note使用XCharts前建议先设置好字体更新XCharts时注意设置的字体可能被还原的问题。
:::warning
使用XCharts前建议先设置好字体更新XCharts时注意设置的字体可能被还原的问题。
:::
### 使用TextMeshPro
@@ -269,7 +305,11 @@ XCharts内部有自动刷新机制但也是在一定条件才会触发。如
2. `chart.RefreshChart()`:刷新图表绘制,只刷新绘制部分,不会刷新组件文本,位置等部分。
3. 各个组件也可以通过`SetAllDirty()`只刷新自己。
>Note用API去操作数据和各种list而不是直接访问list进行处理
:::danger
用API去操作数据和各种list而不是直接访问list进行处理
:::
### 改主组件上的参数
@@ -286,7 +326,11 @@ xAxis.boundaryGap = true;
xAxis.type = Axis.AxisType.Category;
```
> 注:低版本没有`EnsureChartComponent()`接口时,用`GetOrAddChartComponent()`
:::note
低版本没有`EnsureChartComponent()`接口时,用`GetOrAddChartComponent()`
:::
### 改Serie的参数

View File

@@ -19,6 +19,8 @@ namespace XCharts.Editor
public static readonly GUIContent btnSaveAsImage = new GUIContent("Save As Image", "");
public static readonly GUIContent btnCheckWarning = new GUIContent("Check Warning", "");
public static readonly GUIContent btnHideWarning = new GUIContent("Hide Warning", "");
public static readonly GUIContent btnImportJsonData = new GUIContent("Import Json", "");
public static readonly GUIContent btnExportJsonData = new GUIContent("Export Json", "");
}
protected BaseChart m_Chart;
protected SerializedProperty m_Script;
@@ -26,6 +28,7 @@ namespace XCharts.Editor
protected SerializedProperty m_Settings;
protected SerializedProperty m_Theme;
protected SerializedProperty m_ChartName;
protected SerializedProperty m_UseUtc;
protected SerializedProperty m_DebugInfo;
protected SerializedProperty m_RaycastTarget;
@@ -35,6 +38,7 @@ namespace XCharts.Editor
private bool m_BaseFoldout;
private bool m_CheckWarning = false;
private bool m_ExportPending = false;
private int m_LastComponentCount = 0;
private int m_LastSerieCount = 0;
private string m_VersionString = "";
@@ -49,6 +53,7 @@ namespace XCharts.Editor
m_Script = serializedObject.FindProperty("m_Script");
m_EnableTextMeshPro = serializedObject.FindProperty("m_EnableTextMeshPro");
m_ChartName = serializedObject.FindProperty("m_ChartName");
m_UseUtc = serializedObject.FindProperty("m_UseUtc");
m_Theme = serializedObject.FindProperty("m_Theme");
m_Settings = serializedObject.FindProperty("m_Settings");
m_DebugInfo = serializedObject.FindProperty("m_DebugInfo");
@@ -124,6 +129,7 @@ namespace XCharts.Editor
{
EditorGUILayout.PropertyField(m_Script);
EditorGUILayout.PropertyField(m_ChartName);
EditorGUILayout.PropertyField(m_UseUtc);
EditorGUILayout.PropertyField(m_RaycastTarget);
if (XChartsMgr.IsRepeatChartName(m_Chart, m_ChartName.stringValue))
{
@@ -282,7 +288,7 @@ namespace XCharts.Editor
}
if (GUILayout.Button(Styles.btnSaveAsImage))
{
m_Chart.SaveAsImage();
m_Chart.SaveAsImage("png", "", 4f);
}
if (m_CheckWarning)
{
@@ -297,6 +303,14 @@ namespace XCharts.Editor
m_CheckWarning = false;
}
EditorGUILayout.EndHorizontal();
if (GUILayout.Button(Styles.btnImportJsonData))
{
ChartJsonImportWindow.ShowWindow(m_Chart);
}
if (GUILayout.Button(Styles.btnExportJsonData))
{
RequestExportJsonData();
}
sb.Length = 0;
sb.AppendFormat("v{0}", XChartsMgr.fullVersion);
if (!string.IsNullOrEmpty(m_Chart.warningInfo))
@@ -318,8 +332,47 @@ namespace XCharts.Editor
m_CheckWarning = true;
m_Chart.CheckWarning();
}
if (GUILayout.Button(Styles.btnImportJsonData))
{
ChartJsonImportWindow.ShowWindow(m_Chart);
}
if (GUILayout.Button(Styles.btnExportJsonData))
{
RequestExportJsonData();
}
}
}
private void RequestExportJsonData()
{
if (m_ExportPending) return;
m_ExportPending = true;
var chart = m_Chart;
EditorApplication.delayCall += delegate()
{
m_ExportPending = false;
ExportJsonData(chart);
};
GUIUtility.ExitGUI();
}
private static void ExportJsonData(BaseChart chart)
{
if (chart == null) return;
var json = chart.ExportToJson(true);
var defaultName = chart.gameObject.name + ".json";
var path = EditorUtility.SaveFilePanel("Save Chart JSON", "", defaultName, "json");
if (string.IsNullOrEmpty(path)) return;
try
{
System.IO.File.WriteAllText(path, json);
Debug.Log("[XCharts] JSON exported to: " + path);
}
catch (Exception ex)
{
Debug.LogError("[XCharts] Failed to save JSON: " + ex.Message);
}
}
}
}

View File

@@ -15,6 +15,7 @@ namespace XCharts.Editor
++EditorGUI.indentLevel;
PropertyField(prop, "m_Delay");
PropertyField(prop, "m_Duration");
PropertyField(prop, "m_Speed");
--EditorGUI.indentLevel;
}
}
@@ -30,6 +31,7 @@ namespace XCharts.Editor
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Duration");
PropertyField(prop, "m_Speed");
--EditorGUI.indentLevel;
}
}
@@ -45,6 +47,7 @@ namespace XCharts.Editor
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Duration");
PropertyField(prop, "m_Speed");
--EditorGUI.indentLevel;
}
}
@@ -68,6 +71,21 @@ namespace XCharts.Editor
}
}
[CustomPropertyDrawer(typeof(XCharts.Runtime.AnimationExchange), true)]
public class AnimationExchangeDrawer : BasePropertyDrawer
{
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeComponentFoldout(prop, "m_Enable", true))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Duration");
--EditorGUI.indentLevel;
}
}
}
[CustomPropertyDrawer(typeof(AnimationStyle), true)]
public class AnimationDrawer : BasePropertyDrawer
{
@@ -85,6 +103,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_Change");
PropertyField(prop, "m_Addition");
PropertyField(prop, "m_Interaction");
PropertyField(prop, "m_Exchange");
--EditorGUI.indentLevel;
}
}

View File

@@ -113,6 +113,15 @@ namespace XCharts.Editor
}
}
protected void PropertyFlagsField(SerializedProperty prop, string relativePropName, System.Type enumType)
{
if (IngorePropertys.Contains(relativePropName)) return;
if (!ChartEditorHelper.PropertyFlagsField(ref m_DrawRect, m_Heights, m_KeyName, prop, relativePropName, enumType))
{
Debug.LogError("PropertyFlagsField ERROR:" + prop.displayName + ", " + relativePropName);
}
}
protected void PropertyFieldLimitMin(SerializedProperty prop, string relativePropName, float minValue)
{
if (IngorePropertys.Contains(relativePropName)) return;

View File

@@ -102,7 +102,7 @@ namespace XCharts.Editor
protected override void DrawExtendeds(SerializedProperty prop)
{
base.DrawExtendeds(prop);
PropertyField(prop, "m_UnableColor");
PropertyField(prop, "m_InactiveColor");
}
}

View File

@@ -21,6 +21,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_MarkColor");
PropertyField(prop, "m_BackgroundColor");
PropertyField(prop, "m_BackgroundWidth");
PropertyField(prop, "m_BackgroundGap");
PropertyField(prop, "m_CenterColor");
PropertyField(prop, "m_CenterGap");
PropertyField(prop, "m_BorderWidth");

View File

@@ -24,6 +24,12 @@ namespace XCharts.Editor
PropertyField(prop, "m_Rotate");
PropertyField(prop, "m_Width");
PropertyField(prop, "m_Height");
PropertyField(prop, "m_FixedX");
PropertyField(prop, "m_FixedY");
PropertyField(prop, "m_ShowCondition");
PropertyField(prop, "m_ShowFilter");
PropertyField(prop, "m_ShowThreshold");
PropertyField(prop, "m_ShowMinGap");
PropertyField(prop, "m_Icon");
PropertyField(prop, "m_Background");
PropertyField(prop, "m_TextStyle");

View File

@@ -29,6 +29,8 @@ namespace XCharts.Editor
{
base.DrawExtendeds(prop);
PropertyField(prop, "m_OnZero");
PropertyField(prop, "m_StartExtendLength");
PropertyField(prop, "m_EndExtendLength");
PropertyField(prop, "m_ShowArrow");
PropertyField(prop, "m_Arrow");
}

View File

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

View File

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

View File

@@ -102,10 +102,24 @@ namespace XCharts.Editor
}
[ComponentEditor(typeof(XAxis))]
public class XAxisEditor : AxisEditor { }
public class XAxisEditor : AxisEditor
{
protected override void DrawExtendeds()
{
base.DrawExtendeds();
PropertyField("m_MainAxis");
}
}
[ComponentEditor(typeof(YAxis))]
public class YAxisEditor : AxisEditor { }
public class YAxisEditor : AxisEditor
{
protected override void DrawExtendeds()
{
base.DrawExtendeds();
PropertyField("m_MainAxis");
}
}
[ComponentEditor(typeof(XAxis3D))]
public class XAxis3DEditor : AxisEditor { }
@@ -164,6 +178,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_ShowAsPositiveNumber");
PropertyField(prop, "m_OnZero");
PropertyField(prop, "m_ShowZeroLabel");
PropertyField(prop, "m_ShowStartLabel");
PropertyField(prop, "m_ShowEndLabel");

View File

@@ -9,6 +9,7 @@ namespace XCharts.Editor
public override void OnInspectorGUI()
{
++EditorGUI.indentLevel;
PropertyField("m_Layer");
PropertyField("m_LabelStyle");
//PropertyField("m_MarkStyle");
PropertyListField("m_Items", true);

View File

@@ -13,7 +13,7 @@ namespace XCharts.Editor
var m_SupportMarquee = baseProperty.FindPropertyRelative("m_SupportMarquee");
var m_Start = baseProperty.FindPropertyRelative("m_Start");
var m_End = baseProperty.FindPropertyRelative("m_End");
var m_MinShowNum = baseProperty.FindPropertyRelative("m_MinShowNum");
var m_MinZoomRatio = baseProperty.FindPropertyRelative("m_MinZoomRatio");
++EditorGUI.indentLevel;
PropertyField("m_Orient");
PropertyField("m_SupportInside");
@@ -28,13 +28,15 @@ namespace XCharts.Editor
PropertyField("m_ScrollSensitivity");
PropertyField("m_RangeMode");
PropertyField(m_Start);
PropertyField(m_End);
PropertyField("m_StartLock");
PropertyField(m_End);
PropertyField("m_EndLock");
PropertyField(m_MinShowNum);
PropertyField(m_MinZoomRatio);
PropertyField("m_FilterAxisRange");
if (m_Start.floatValue < 0) m_Start.floatValue = 0;
if (m_End.floatValue > 100) m_End.floatValue = 100;
if (m_MinShowNum.intValue < 0) m_MinShowNum.intValue = 0;
if (m_MinZoomRatio.floatValue < 0) m_MinZoomRatio.floatValue = 0;
if (m_MinZoomRatio.floatValue > 1) m_MinZoomRatio.floatValue = 1;
if (m_SupportSlider.boolValue)
{
PropertyField("m_ShowDataShadow");

View File

@@ -10,11 +10,14 @@ namespace XCharts.Editor
{
++EditorGUI.indentLevel;
PropertyField("m_IconType");
PropertyField("m_Width");
PropertyField("m_Height");
PropertyField("m_ItemWidth");
PropertyField("m_ItemHeight");
PropertyField("m_ItemGap");
PropertyField("m_ItemAutoColor");
PropertyField("m_ItemOpacity");
PropertyField("m_ItemInactiveOpacity");
PropertyField("m_SelectedMode");
PropertyField("m_Orient");
PropertyField("m_Location");

View File

@@ -34,7 +34,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_Name");
switch (type)
{
case MarkLineType.None:
case MarkLineType.Custom:
PropertyField(prop, "m_XPosition");
PropertyField(prop, "m_YPosition");
PropertyField(prop, "m_XValue");
@@ -48,7 +48,7 @@ namespace XCharts.Editor
break;
}
PropertyField(prop, "m_Group");
if (group > 0 && type == MarkLineType.None) PropertyField(prop, "m_ZeroPosition");
if (group > 0 && type == MarkLineType.Custom) PropertyField(prop, "m_ZeroPosition");
PropertyField(prop, "m_LineStyle");
PropertyField(prop, "m_StartSymbol");
PropertyField(prop, "m_EndSymbol");

View File

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

View File

@@ -13,10 +13,13 @@ namespace XCharts.Editor
public static readonly GUIContent btnAddComponent = new GUIContent("Add Main Component", "");
public static readonly GUIContent btnRebuildChartObject = new GUIContent("Rebuild Object", "");
public static readonly GUIContent btnSaveAsImage = new GUIContent("Save As Image", "");
public static readonly GUIContent btnImportJsonData = new GUIContent("Import Json", "");
public static readonly GUIContent btnExportJsonData = new GUIContent("Export Json", "");
public static readonly GUIContent btnCheckWarning = new GUIContent("Check Warning", "");
public static readonly GUIContent btnHideWarning = new GUIContent("Hide Warning", "");
}
public UIComponent m_UIComponent;
private bool m_ExportPending;
public static T AddUIComponent<T>(string chartName) where T : UIComponent
{
@@ -54,7 +57,15 @@ namespace XCharts.Editor
}
if (GUILayout.Button(Styles.btnSaveAsImage))
{
m_UIComponent.SaveAsImage();
m_UIComponent.SaveAsImage("png", "", 4f);
}
if (GUILayout.Button(Styles.btnImportJsonData))
{
UIComponentJsonImportWindow.ShowWindow(m_UIComponent);
}
if (GUILayout.Button(Styles.btnExportJsonData))
{
RequestExportJsonData();
}
OnDebugEndInspectorGUI();
}
@@ -89,6 +100,37 @@ namespace XCharts.Editor
EditorGUILayout.PropertyField(property, title);
}
private void RequestExportJsonData()
{
if (m_ExportPending) return;
m_ExportPending = true;
var target = m_UIComponent;
EditorApplication.delayCall += delegate ()
{
m_ExportPending = false;
ExportJsonData(target);
};
GUIUtility.ExitGUI();
}
private static void ExportJsonData(UIComponent target)
{
if (target == null) return;
var json = target.ExportToJson(true);
var defaultName = target.gameObject.name + ".json";
var path = EditorUtility.SaveFilePanel("Save UI Component JSON", "", defaultName, "json");
if (string.IsNullOrEmpty(path)) return;
try
{
System.IO.File.WriteAllText(path, json);
Debug.Log("[XCharts] UI JSON exported to: " + path);
}
catch (System.Exception ex)
{
Debug.LogError("[XCharts] Failed to save UI JSON: " + ex.Message);
}
}
protected void PropertyListField(string relativePropName, bool showOrder = true, params HeaderMenuInfo[] menus)
{
var m_DrawRect = GUILayoutUtility.GetRect(1f, 17f);

View File

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

View File

@@ -8,6 +8,7 @@ namespace XCharts.Editor
public override void OnCustomInspectorGUI()
{
PropertyField("m_GridIndex");
PropertyField("m_PieType");
PropertyField("m_RoseType");
PropertyField("m_Gap");
PropertyTwoFiled("m_Center");

View File

@@ -18,6 +18,8 @@ namespace XCharts.Editor
}
PropertyField("m_MaxCache");
PropertyField("m_Clip");
PropertyField("m_Ignore");
PropertyField("m_IgnoreValue");
PropertyField("m_Symbol");
PropertyField("m_ItemStyle");

View File

@@ -108,11 +108,11 @@ namespace XCharts.Editor
{
EditorGUI.LabelField(drawRect, name);
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 tempWidth = (rectWidth - startX + diff) / 2;
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(centerYRect, prop2, GUIContent.none);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -326,7 +326,13 @@ namespace XCharts.Editor
var foldoutRect = drawRect;
foldoutRect.xMax -= 10;
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;
drawRect.y += headerHeight;
drawRect.width = rawWidth;
@@ -501,6 +507,28 @@ namespace XCharts.Editor
{
return PropertyField(ref drawRect, heights, key, parentProp.FindPropertyRelative(relativeName));
}
public static bool PropertyFlagsField(ref Rect drawRect, Dictionary<string, float> heights, string key,
SerializedProperty parentProp, string relativeName, System.Type enumType)
{
return PropertyFlagsField(ref drawRect, heights, key, parentProp.FindPropertyRelative(relativeName), enumType);
}
public static bool PropertyFlagsField(ref Rect drawRect, Dictionary<string, float> heights, string key,
SerializedProperty prop, System.Type enumType)
{
if (prop == null) return false;
var label = GetContent(prop.displayName);
var enumValue = (System.Enum)System.Enum.ToObject(enumType, prop.intValue);
EditorGUI.BeginChangeCheck();
var newValue = EditorGUI.EnumFlagsField(drawRect, label, enumValue);
if (EditorGUI.EndChangeCheck())
prop.intValue = (int)(object)newValue;
var hig = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
drawRect.y += hig;
heights[key] += hig;
return true;
}
public static bool PropertyFieldWithMinValue(ref Rect drawRect, Dictionary<string, float> heights, string key,
SerializedProperty parentProp, string relativeName, float minValue)
{

View File

@@ -0,0 +1,201 @@
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
namespace XCharts.Editor
{
public class ChartJsonImportWindow : EditorWindow
{
private const int TEXTAREA_SAFE_CHAR_LIMIT = 8000;
private const int LARGE_JSON_PREVIEW_CHAR_LIMIT = 4000;
private static BaseChart s_TargetChart;
private string m_JsonInput = "";
private Vector2 m_ScrollPos;
private bool m_ShowPreview = false;
private string m_PreviewText = "";
private bool m_OpenFilePending = false;
private bool m_PreviewPending = false;
private bool m_ImportPending = false;
public static void ShowWindow(BaseChart targetChart)
{
s_TargetChart = targetChart;
var window = GetWindow<ChartJsonImportWindow>("Import Chart JSON");
window.minSize = new Vector2(600, 400);
window.Show();
}
private void OnGUI()
{
if (s_TargetChart == null)
{
EditorGUILayout.HelpBox("Target chart is null. Please select a chart first.", MessageType.Error);
if (GUILayout.Button("Close")) Close();
return;
}
if (m_JsonInput == null) m_JsonInput = "";
EditorGUILayout.LabelField("Target Chart: " + s_TargetChart.gameObject.name, EditorStyles.boldLabel);
GUILayout.Space(10);
EditorGUILayout.LabelField("Paste JSON Data:", EditorStyles.boldLabel);
using (var scroll = new EditorGUILayout.ScrollViewScope(m_ScrollPos, GUILayout.Height(250)))
{
m_ScrollPos = scroll.scrollPosition;
if (m_JsonInput.Length <= TEXTAREA_SAFE_CHAR_LIMIT)
{
m_JsonInput = EditorGUILayout.TextArea(m_JsonInput, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
}
else
{
var preview = m_JsonInput.Substring(0, LARGE_JSON_PREVIEW_CHAR_LIMIT);
EditorGUILayout.HelpBox("JSON content is very large. To avoid editor text rendering limits, only a preview is shown below. Import uses full content.", MessageType.Info);
EditorGUILayout.TextArea(preview, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
}
}
EditorGUILayout.HelpBox("Paste JSON directly, or click Open Json File.", MessageType.Info);
GUILayout.Space(10);
using (new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Button("Open Json File", GUILayout.Width(120)))
{
RequestOpenJsonFile();
}
if (GUILayout.Button("Preview", GUILayout.Width(100)))
{
RequestPreviewJson();
}
}
if (m_ShowPreview && !string.IsNullOrEmpty(m_PreviewText))
{
EditorGUILayout.TextArea(m_PreviewText, GUILayout.Height(150));
}
GUILayout.Space(10);
using (new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Button("Import", GUILayout.Height(40), GUILayout.Width(150)))
{
RequestImportJson();
}
if (GUILayout.Button("Cancel", GUILayout.Height(40), GUILayout.Width(150))) Close();
}
}
private void RequestOpenJsonFile()
{
if (m_OpenFilePending) return;
m_OpenFilePending = true;
EditorApplication.delayCall += delegate ()
{
m_OpenFilePending = false;
if (this == null) return;
OpenJsonFile();
Repaint();
};
GUIUtility.ExitGUI();
}
private void RequestPreviewJson()
{
if (m_PreviewPending) return;
m_PreviewPending = true;
EditorApplication.delayCall += delegate ()
{
m_PreviewPending = false;
if (this == null) return;
PreviewJson();
Repaint();
};
GUIUtility.ExitGUI();
}
private void RequestImportJson()
{
if (m_ImportPending) return;
m_ImportPending = true;
EditorApplication.delayCall += delegate ()
{
m_ImportPending = false;
if (this == null) return;
ImportJson();
};
GUIUtility.ExitGUI();
}
private void PreviewJson()
{
if (string.IsNullOrEmpty(m_JsonInput))
{
EditorUtility.DisplayDialog("Error", "JSON input is empty.", "OK");
return;
}
try
{
var json = JsonUtility.FromJson<XCharts.Runtime.ChartJson>(m_JsonInput);
if (json == null)
{
m_PreviewText = "Invalid JSON or unsupported schema.";
}
else
{
var componentCount = json.components != null ? json.components.Count : 0;
var seriesCount = json.series != null ? json.series.Count : 0;
m_PreviewText = "Chart Type: " + json.chartType + "\nComponents: " + componentCount + "\nSeries: " + seriesCount + "\n(Full validation on import)";
}
m_ShowPreview = true;
}
catch (System.Exception ex)
{
EditorUtility.DisplayDialog("Preview Error", "Invalid JSON: " + ex.Message, "OK");
}
}
private void ImportJson()
{
if (string.IsNullOrEmpty(m_JsonInput))
{
EditorUtility.DisplayDialog("Error", "JSON input is empty. Please paste JSON data.", "OK");
return;
}
try
{
Undo.RecordObject(s_TargetChart, "Import Chart JSON");
s_TargetChart.ImportFromJson(m_JsonInput);
s_TargetChart.RebuildChartObject();
s_TargetChart.RefreshAllComponent();
s_TargetChart.RefreshChart();
EditorUtility.SetDirty(s_TargetChart);
UnityEditor.SceneView.RepaintAll();
var chart = s_TargetChart;
EditorApplication.delayCall += delegate ()
{
if (chart == null) return;
chart.RefreshAllComponent();
chart.RefreshChart();
UnityEditor.SceneView.RepaintAll();
};
EditorUtility.DisplayDialog("Success", "Chart '" + s_TargetChart.gameObject.name + "' imported successfully!", "OK");
Close();
}
catch (System.Exception ex)
{
EditorUtility.DisplayDialog("Import Error", "Failed to import JSON:\n" + ex.Message + "\n\n" + ex.StackTrace, "OK");
}
}
private void OpenJsonFile()
{
var path = EditorUtility.OpenFilePanel("Open Chart JSON", "", "json");
if (string.IsNullOrEmpty(path)) return;
try
{
m_JsonInput = System.IO.File.ReadAllText(path);
m_ShowPreview = false;
m_PreviewText = "";
}
catch (System.Exception ex)
{
EditorUtility.DisplayDialog("Open File Error", "Failed to read JSON file:\n" + ex.Message, "OK");
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 21f2eafb07ab34d4abf575784acc56a3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,193 @@
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
namespace XCharts.Editor
{
public class UIComponentJsonImportWindow : EditorWindow
{
private const int TEXTAREA_SAFE_CHAR_LIMIT = 8000;
private const int LARGE_JSON_PREVIEW_CHAR_LIMIT = 4000;
private static UIComponent s_TargetComponent;
private string m_JsonInput = "";
private Vector2 m_ScrollPos;
private bool m_ShowPreview = false;
private string m_PreviewText = "";
private bool m_OpenFilePending = false;
private bool m_PreviewPending = false;
private bool m_ImportPending = false;
public static void ShowWindow(UIComponent target)
{
s_TargetComponent = target;
var window = GetWindow<UIComponentJsonImportWindow>("Import UI JSON");
window.minSize = new Vector2(600, 400);
window.Show();
}
private void OnGUI()
{
if (s_TargetComponent == null)
{
EditorGUILayout.HelpBox("Target UI component is null. Please select a component first.", MessageType.Error);
if (GUILayout.Button("Close")) Close();
return;
}
if (m_JsonInput == null) m_JsonInput = "";
EditorGUILayout.LabelField("Target: " + s_TargetComponent.gameObject.name + " (" + s_TargetComponent.GetType().Name + ")", EditorStyles.boldLabel);
GUILayout.Space(10);
EditorGUILayout.LabelField("Paste JSON Data:", EditorStyles.boldLabel);
using (var scroll = new EditorGUILayout.ScrollViewScope(m_ScrollPos, GUILayout.Height(250)))
{
m_ScrollPos = scroll.scrollPosition;
if (m_JsonInput.Length <= TEXTAREA_SAFE_CHAR_LIMIT)
{
m_JsonInput = EditorGUILayout.TextArea(m_JsonInput, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
}
else
{
var preview = m_JsonInput.Substring(0, LARGE_JSON_PREVIEW_CHAR_LIMIT);
EditorGUILayout.HelpBox("JSON content is very large. Only a preview is shown below. Import uses full content.", MessageType.Info);
EditorGUILayout.TextArea(preview, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
}
}
EditorGUILayout.HelpBox("Paste JSON directly, or click Open Json File.", MessageType.Info);
GUILayout.Space(10);
using (new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Button("Open Json File", GUILayout.Width(120))) RequestOpenJsonFile();
if (GUILayout.Button("Preview", GUILayout.Width(100))) RequestPreviewJson();
}
if (m_ShowPreview && !string.IsNullOrEmpty(m_PreviewText))
{
EditorGUILayout.TextArea(m_PreviewText, GUILayout.Height(120));
}
GUILayout.Space(10);
using (new EditorGUILayout.HorizontalScope())
{
if (GUILayout.Button("Import", GUILayout.Height(40), GUILayout.Width(150))) RequestImportJson();
if (GUILayout.Button("Cancel", GUILayout.Height(40), GUILayout.Width(150))) Close();
}
}
private void RequestOpenJsonFile()
{
if (m_OpenFilePending) return;
m_OpenFilePending = true;
EditorApplication.delayCall += delegate ()
{
m_OpenFilePending = false;
if (this == null) return;
OpenJsonFile();
Repaint();
};
GUIUtility.ExitGUI();
}
private void RequestPreviewJson()
{
if (m_PreviewPending) return;
m_PreviewPending = true;
EditorApplication.delayCall += delegate ()
{
m_PreviewPending = false;
if (this == null) return;
PreviewJson();
Repaint();
};
GUIUtility.ExitGUI();
}
private void RequestImportJson()
{
if (m_ImportPending) return;
m_ImportPending = true;
EditorApplication.delayCall += delegate ()
{
m_ImportPending = false;
if (this == null) return;
ImportJson();
};
GUIUtility.ExitGUI();
}
private void PreviewJson()
{
if (string.IsNullOrEmpty(m_JsonInput))
{
EditorUtility.DisplayDialog("Error", "JSON input is empty.", "OK");
return;
}
try
{
var json = JsonUtility.FromJson<UIComponentJson>(m_JsonInput);
if (json == null)
m_PreviewText = "Invalid JSON or unsupported schema.";
else
m_PreviewText = "Component Type: " + json.componentType + "\nSchema: " + json.schemaVersion + "\nVersion: " + json.componentVersion;
m_ShowPreview = true;
}
catch (System.Exception ex)
{
EditorUtility.DisplayDialog("Preview Error", "Invalid JSON: " + ex.Message, "OK");
}
}
private void ImportJson()
{
if (string.IsNullOrEmpty(m_JsonInput))
{
EditorUtility.DisplayDialog("Error", "JSON input is empty. Please paste JSON data.", "OK");
return;
}
try
{
Undo.RecordObject(s_TargetComponent, "Import UI Component JSON");
s_TargetComponent.ImportFromJson(m_JsonInput);
s_TargetComponent.RebuildChartObject();
s_TargetComponent.RefreshAllComponent();
s_TargetComponent.RefreshGraph();
EditorUtility.SetDirty(s_TargetComponent);
SceneView.RepaintAll();
var target = s_TargetComponent;
EditorApplication.delayCall += delegate ()
{
if (target == null) return;
target.RefreshAllComponent();
target.RefreshGraph();
SceneView.RepaintAll();
};
EditorUtility.DisplayDialog("Success", "UI component imported successfully!", "OK");
Close();
}
catch (System.Exception ex)
{
EditorUtility.DisplayDialog("Import Error", "Failed to import JSON:\n" + ex.Message + "\n\n" + ex.StackTrace, "OK");
}
}
private void OpenJsonFile()
{
var path = EditorUtility.OpenFilePanel("Open UI Component JSON", "", "json");
if (string.IsNullOrEmpty(path)) return;
try
{
m_JsonInput = System.IO.File.ReadAllText(path);
m_ShowPreview = false;
m_PreviewText = "";
}
catch (System.Exception ex)
{
EditorUtility.DisplayDialog("Open File Error", "Failed to read JSON file:\n" + ex.Message, "OK");
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 68157a6f7d4e94ccc8ccbb4913d187f3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -19,7 +19,11 @@ namespace XCharts.Editor
GameObject selectObj = Selection.activeGameObject;
if (selectObj == null)
{
#if UNITY_2023_1_OR_NEWER
var canvas = UnityEngine.Object.FindFirstObjectByType<Canvas>();
#else
var canvas = GameObject.FindObjectOfType<Canvas>();
#endif
if (canvas != null) return canvas.transform;
else
{

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;
}
}
}

View File

@@ -1,45 +1,37 @@
<h2 align="center">XCharts</h2>
<p align="center">
<a href="">
<img src="" alt="" width="" height="">
</a>
</p>
<h2 align="center">XCharts</h3>
<p align="center">
A powerful, easy-to-use, configurable charting and data visualization library for Unity.
<br>
Unity数据可视化图表插件。
<br>
<a href="https://github.com/XCharts-Team/XCharts">中文文档</a>
A powerful, easy-to-use, configurable charting and data visualization library for Unity.<br/>Unity数据可视化图表插件。<br/>
<a href="https://github.com/XCharts-Team/XCharts">中文文档</a>
</p>
<p align="center">
<a href="https://github.com/XCharts-Team/XCharts/blob/master/LICENSE">
<img src="https://img.shields.io/github/license/XCharts-Team/XCharts">
<img src="https://img.shields.io/github/license/XCharts-Team/XCharts"></img>
</a>
<a href="https://github.com/XCharts-Team/XCharts/releases">
<img src="https://img.shields.io/github/v/release/XCharts-Team/XCharts?include_prereleases">
<img src="https://img.shields.io/github/v/release/XCharts-Team/XCharts?include_prereleases"></img>
</a>
<a href="">
<img src="https://img.shields.io/github/repo-size/monitor1394/unity-ugui-xcharts">
<img src="https://img.shields.io/github/repo-size/monitor1394/unity-ugui-xcharts"></img>
</a>
<a href="">
<img src="https://img.shields.io/github/languages/code-size/monitor1394/unity-ugui-xcharts">
<img src="https://img.shields.io/github/languages/code-size/monitor1394/unity-ugui-xcharts"></img>
</a>
<a href="">
<img src="https://img.shields.io/badge/Unity-5.6+-green">
<img src="https://img.shields.io/badge/Unity-5.6+-green"></img>
</a>
<a href="">
<img src="https://img.shields.io/badge/TextMeshPro-YES-green">
<img src="https://img.shields.io/badge/TextMeshPro-YES-green"></img>
</a>
</p>
<p align="center">
<a href="">
<img src="https://img.shields.io/github/stars/XCharts-Team/XCharts?style=social">
<img src="https://img.shields.io/github/stars/XCharts-Team/XCharts?style=social"></img>
</a>
<a href="">
<img src="https://img.shields.io/github/forks/XCharts-Team/XCharts?style=social">
<img src="https://img.shields.io/github/forks/XCharts-Team/XCharts?style=social"></img>
</a>
<a href="">
<img src="https://img.shields.io/github/issues-closed/XCharts-Team/XCharts?color=green&label=%20%20%20%20issues&logoColor=green&style=social">
<img src="https://img.shields.io/github/issues-closed/XCharts-Team/XCharts?color=green&label=%20%20%20%20issues&logoColor=green&style=social"></img>
</a>
</p>
@@ -47,14 +39,14 @@
## Overview
A powerful and easy-to-use data visualization library for Unity. It supports more than ten built-in charts, including line, bar, pie, radar, scatter, heatmap, ring, candlestick, polar, parallel coordinates, as well as extended charts such as 3d pie, 3d bar, 3d pyramid, funnel, gauge, liquid, pictorialbar, gantt, treemap, sankey, line3d and graph chart.
A powerful and easy-to-use data visualization library for Unity. It supports more than ten built-in charts, including line, bar, pie, radar, scatter, heatmap, ring, candlestick, polar, parallel coordinates, as well as extension charts such as 3d pie, 3d bar, 3d pyramid, funnel, gauge, liquid, pictorialbar, gantt, treemap, sankey, line3d and graph chart.
## Key Features
- __Pure Code Rendering__: Charts are rendered with pure code, eliminating the need for extra texture or shader resources.
- __Visual Configuration__: Configure parameters visually with real-time preview and support for dynamic configuration and data adjustments at runtime.
- __High Customizability__: Themes and configuration parameters can be adjusted as needed, with support for custom drawing and callbacks.
- __Built-in and Extended Charts__: Supports a variety of chart types, including 3D charts and special chart types like gauges and treemaps.
- __Built-in and Extension Charts__: Supports a variety of chart types, including 3D charts and special chart types like gauges and treemaps.
- __Multiple Chart Combinations__: Combine multiple charts of the same or different types within a single instance.
- __Various Coordinate Systems__: Supports different coordinate systems such as Cartesian, polar, and single axes.
- __Rich Components__: Includes titles, legends, tooltips, and more.
@@ -67,7 +59,7 @@ A powerful and easy-to-use data visualization library for Unity. It supports mo
## Documentation
- [XCharts3.0 Homepage](https://xcharts-team.github.io)
- [XCharts3.0 Homepage](https://xcharts-team.github.io/en)
- [XCharts3.0 Tutorial](Documentation~/en/tutorial01.md)
- [XCharts3.0 API](Documentation~/en/api.md)
- [XCharts3.0 FAQ](Documentation~/en/faq.md)
@@ -86,7 +78,7 @@ A powerful and easy-to-use data visualization library for Unity. It supports mo
- `XCharts3.0` is not fully compatible with `XCharts2.0`. Upgrading to 3.0 may require code adjustments and reconfiguration of some charts.
- `XCharts2.0` is in the maintenance phase with only critical bug fixes applied.
- While XCharts supports Unity 5.6 and above, compatibility issues may arise due to limited testing.
- This repository contains only the `XCharts` source code. For demos, visit the [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) repo or the [Online Demo](https://xcharts-team.github.io/examples/).
- This repository contains only the `XCharts` source code. For demos, visit the [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) repo or the [Online Demo](https://xcharts-team.github.io/en/examples/).
## Getting Started

150
README.md
View File

@@ -1,15 +1,8 @@
<p align="center">
<a href="">
<img src="" alt="" width="" height=""></img>
</a>
</p>
<h2 align="center">XCharts</h2>
<p align="center">
A powerful, easy-to-use, configurable charting and data visualization library for Unity.
<br/>
Unity数据可视化图表插件。
<br/>
<a href="README-en.md">English README</a>
A powerful, easy-to-use, configurable charting and data visualization library for Unity.<br/>Unity数据可视化图表插件。<br/>
<a href="README-en.md">English README</a>
</p>
<p align="center">
<a href="https://github.com/XCharts-Team/XCharts/blob/master/LICENSE">
@@ -45,7 +38,7 @@
![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/examples)
@@ -59,25 +52,24 @@
## 特性
- __纯代码绘制__图表纯代码绘制,无需额外贴图Shader资源。
- __可视化配置__参数可视化配置,效果实时预览,支持运行时代码动态修改配置和数据。
- __高自由定制__支持从主题和配置参数上任意调整;支持代码自定义绘制,自定义回调以及自定义实现图表
- __多内置图表__支持线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等多种内置图表。
- __多扩展图表__支持3D柱图、3D饼图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图、3D折线图、关系图等多种扩展图表。
- __多扩展组件__支持表格、统计数值等多种扩展UI组件
- __多图表组合__支持内置图表的任意组合,同一图中可同时显示多个相同或不同类型的图表。
- __多种坐标系__支持直角坐标系、极坐标系、单轴等多种坐标系。
- __丰富的组件__支持标题、图例、提示框、标线、标域、数据区域缩放、视觉映射等常用组件。
- __多样式线图__支持直线、曲线、虚线、面积图、阶梯线图等多种线图。
- __多样式柱图__支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图、胶囊柱图等多种柱状图。
- __多样式饼图__支持环形图、玫瑰图、环形玫瑰图等多种饼图。
- __丰富的线条__支持实线、曲线、阶梯线、虚线、点线、点划线、双点划线等线条
- __自定义绘制__支持自定义图表内容绘制提供绘制点、线、面等其他图形的强大的绘图API
- __大数据绘制__支持万级大数据量绘制支持采样绘制特殊的简化图表支持更优的性能
- __自定义主题__支持主题定制、导入和导出内置明暗两种默认主题
- __动画和交互__支持渐入动画、渐出动画、变更动画、新增动画、交互动画等多种动画支持多平台的数据筛选、视图缩放、细节展示等交互操作
- __第三方扩展__支持无缝接入`TexMeshPro``New Input System`
- __版本和兼容__支持所有`5.6`以上的`Unity`版本;支持全平台运行。
- __纯代码绘制__图表完全通过代码生成,无需额外贴图Shader 资源,轻量高效
- __可视化配置__提供直观的参数配置界面,支持实时预览效果,并可在运行时动态修改配置和数据。
- __高定制__支持从主题、组件到数据项的全面参数设置,同时允许通过代码自定义绘制逻辑、回调函数及图表实现
- __多内置图表__支持线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等多种常用的内置图表。
- __多扩展图表__支持3D柱图、3D饼图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图、3D折线图、关系图等多种高级扩展图表,满足复杂数据可视化需求
- __多扩展组件__支持多种实用 UI 组件,如表格、统计数值、滑动条、进度条等,增强图表交互性
- __多图表组合__支持在同一图表中组合显示多个相同或不同类型的图表,满足复杂场景需求
- __多种坐标系__支持直角坐标系、极坐标系、单轴等多种坐标系,适应不同数据展示需求
- __丰富的组件__提供标题、图例、提示框、标线、标域、数据区域缩放、视觉映射等常用组件,提升图表可读性
- __多样式线图__支持直线、曲线、虚线、面积图、阶梯线图等多种线图样式,满足不同数据趋势展示需求
- __多样式柱图__支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图、胶囊柱图等多种柱状图样式
- __多样式饼图__支持环形图、玫瑰图、环形玫瑰图等多种饼图样式,直观展示数据占比
- __自定义绘制__提供强大的绘图 API支持自定义绘制点、线、面等图形满足个性化需求
- __大数据绘制__支持万级数据量绘制,优化性能表现;支持采样绘制,进一步提升大数据场景下的性能
- __自定义主题__支持主题定制、导入和导出内置明暗两种默认主题轻松适配不同应用场景
- __动画和交互__支持渐入、渐出、变更、新增等多种动画效果以及数据筛选、视图缩放、细节展示等交互操作提升用户体验
- __第三方扩展__无缝集成TexMeshPro和New Input System扩展功能兼容性
- __版本和兼容__支持 Unity 5.6 及以上版本,兼容全平台运行
## 截图
@@ -85,36 +77,6 @@
![扩展图表](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)。
@@ -124,47 +86,67 @@
- 更多细节,请看[【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/) 。
- __XCharts 可以免费使用吗__
XCharts 基于 MIT 协议,核心功能完全免费。您也可以订阅 VIP 服务,享受更多高级功能和专属技术支持
## FAQ
- __XCharts 支持代码动态添加和修改数据吗__
是的XCharts 提供了丰富的数据操作接口,支持代码动态修改配置和数据。但数据来源(如 Excel 或数据库)需要您自行解析后调用 XCharts 接口添加到图表中。
- __XCharts可以免费使用吗__
`XCharts`使用`MIT`协议,可以免费使用。也可以订阅`VIP`享受更多增值服务
- __XCharts 支持哪些平台__
XCharts 专为 Unity 平台设计,支持 Unity 5.6 及以上版本。理论上,任何支持 UGUI 的 Unity 版本均可运行 XCharts。目前不支持 Winform 或 WPF 等其他平台
- __XCharts支持代码动态添加和修改数据吗支持从`Excel`或数据库中获取数据__
`XCharts`提供了各种数据操作的接口,支持代码动态修改配置,添加和修改数据,但数据来源需要自己解析和获取,再调用`XCharts`的接口添加到图表。
- __如何解决锯齿问题XCharts 支持多大的数据__
XCharts 基于 UGUI 实现,因此 UGUI 的常见问题如锯齿、Mesh 顶点数限制)在 XCharts 中也会存在。
- __锯齿问题__可通过调整抗锯齿设置或使用更高分辨率解决。
- __数据量限制__单条折线图Line支持约 2 万数据点,开启采样后可支持更多数据,但会消耗更多 CPU 资源。
更多解决方案请参考 [问答 16](Documentation~/zh/faq.md) 和 [问答 27](Documentation~/zh/faq.md)。
- __XCharts除了用在Unity平台还能用在Winform或WPF等平台吗__
`XCharts`只支持在`Unity`平台使用。理论上任何支持`UGUI``Unity`版本都能运行`XCharts`
- __锯齿怎么解决支持多大量级的数据__
`XCharts`是基于`UGUI`实现的,所以`UGUI`中碰到的问题,在`XCharts`中也会存在。比如锯齿问题,比如`Mesh`顶点数超`65535`的问题。这两个问题的解决可参考[问答16](Documentation~/zh/faq.md)和[问答27](Documentation~/zh/faq.md)。
由于`Mesh``65535`顶点数的限制,目前`XCharts`的单条`Line`支持约`2万`的数据量当然开启采样可以支持更多数据的绘制但同时也会更消耗CPU。
- __哪里可以查看 Demo__
本仓库仅包含 XCharts 源码Demo 示例请访问 [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) 仓库。您也可以在浏览器中查看 [在线 Demo](https://xcharts-team.github.io/examples/)
## 日志
- 各版本的详细更新日志请查看 [更新日志](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`的核心功能使用
- 订阅是按年付费,订阅到期后,不要求必须续订,但中断订阅期间无法享受技术更新和支持等服务
- __核心功能免费__XCharts 核心库基于 MIT 协议完全开源,可免费使用。
- __增值服务__为满足多样化需求我们提供多种订阅服务详情请查看 [订阅详情](Documentation~/zh/support.md)
- __灵活选择__订阅非强制不影响核心功能使用
- __按年付费__订阅服务按年计费到期后可选择续订。中断订阅后将无法享受更新和技术支持服务。
## 其他
- 邮箱:`monitor1394@gmail.com`
- QQ群XCharts交流群`202030963`
- 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 float m_Delay = 0;
[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();
/// <summary>
@@ -34,11 +35,15 @@ namespace XCharts.Runtime
/// </summary>
public float delay { get { return m_Delay; } set { m_Delay = value; } }
/// <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>
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>
/// the callback function of animation start.
/// ||动画开始的回调。
@@ -147,6 +152,7 @@ namespace XCharts.Runtime
{
if (!enable) return;
if (!context.start || context.end) return;
context.init = false;
context.start = false;
context.end = true;
context.currPointIndex = context.destPointIndex;
@@ -168,20 +174,19 @@ namespace XCharts.Runtime
public bool Init(float curr, float dest, int totalPointIndex)
{
if (!enable || !context.start) return false;
if (context.init || context.end) return false;
context.init = true;
context.totalProgress = dest - curr;
context.destPointIndex = totalPointIndex;
if (reverse)
{
context.currProgress = dest;
if (!context.init) context.currProgress = dest;
context.destProgress = curr;
}
else
{
context.currProgress = curr;
if (!context.init) context.currProgress = curr;
context.destProgress = dest;
}
context.init = true;
return true;
}
@@ -208,7 +213,7 @@ namespace XCharts.Runtime
if (!context.start)
return false;
else
return (m_Delay > 0 && Time.time - context.startTime < m_Delay / 1000);
return m_Delay > 0 && Time.time - context.startTime < m_Delay / 1000;
}
/// <summary>
@@ -285,8 +290,7 @@ namespace XCharts.Runtime
{
if (!context.start || !context.init || context.pause) return;
if (IsInDelay()) return;
var duration = GetCurrAnimationDuration();
var delta = (float)(total / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
var delta = GetDelta(total, m_UnscaledTime);
if (reverse)
{
context.currProgress -= delta;
@@ -330,8 +334,7 @@ namespace XCharts.Runtime
}
else
{
var duration = GetCurrAnimationDuration(dataIndex);
var delta = (destProgress - startProgress) / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
var delta = GetDelta(destProgress - startProgress, m_UnscaledTime);
currHig += delta;
if (reverse)
{
@@ -362,8 +365,7 @@ namespace XCharts.Runtime
if (IsInDelay())
return;
var duration = GetCurrAnimationDuration();
var delta = dest / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
var delta = GetDelta(dest, m_UnscaledTime);
if (reverse)
{
context.sizeProgress -= delta;
@@ -377,6 +379,20 @@ namespace XCharts.Runtime
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>
@@ -477,4 +493,14 @@ namespace XCharts.Runtime
return m_Offset.value;
}
}
/// <summary>
/// Data exchange animation. Generally used for animation of data sorting.
/// ||数据交换动画。一般用于图表数据排序时顺序变化的动画。
/// </summary>
[Since("v3.15.0")]
[System.Serializable]
public class AnimationExchange : AnimationInfo
{
}
}

View File

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

View File

@@ -44,8 +44,8 @@ namespace XCharts.Runtime
}
/// <summary>
/// the animation of serie. support animation type: fadeIn, fadeOut, change, addition.
/// ||动画组件用于控制图表的动画播放。支持配置五种动画表现FadeIn渐入动画FadeOut渐出动画Change变更动画Addition新增动画Interaction交互动画
/// the animation of serie. support animation type: fadeIn, fadeOut, change, addition, exchange.
/// ||动画组件用于控制图表的动画播放。支持配置五种动画表现FadeIn渐入动画FadeOut渐出动画Change变更动画Addition新增动画Interaction交互动画Exchange交换动画
/// 按作用的对象可以分为两类SerieAnimation系列动画和DataAnimation数据动画
/// </summary>
[System.Serializable]
@@ -62,6 +62,7 @@ namespace XCharts.Runtime
[SerializeField][Since("v3.8.0")] private AnimationAddition m_Addition = new AnimationAddition() { duration = 500 };
[SerializeField][Since("v3.8.0")] private AnimationHiding m_Hiding = new AnimationHiding() { duration = 500 };
[SerializeField][Since("v3.8.0")] private AnimationInteraction m_Interaction = new AnimationInteraction() { duration = 250 };
[SerializeField][Since("v3.15.0")] private AnimationExchange m_Exchange = new AnimationExchange() { duration = 250 };
[Obsolete("Use animation.fadeIn.delayFunction instead.", true)]
public AnimationDelayFunction fadeInDelayFunction;
@@ -138,6 +139,11 @@ namespace XCharts.Runtime
/// ||交互动画配置。
/// </summary>
public AnimationInteraction interaction { get { return m_Interaction; } }
/// <summary>
/// Exchange animation configuration. Valid in sort bar chart.
/// ||交换动画配置。如在排序柱图中有效。
/// </summary>
public AnimationExchange exchange { get { return m_Exchange; } }
private Vector3 m_LinePathLastPos;
private List<AnimationInfo> m_Animations;
@@ -147,12 +153,15 @@ namespace XCharts.Runtime
{
if (m_Animations == null)
{
m_Animations = new List<AnimationInfo>();
m_Animations.Add(m_FadeIn);
m_Animations.Add(m_FadeOut);
m_Animations.Add(m_Change);
m_Animations.Add(m_Addition);
m_Animations.Add(m_Hiding);
m_Animations = new List<AnimationInfo>
{
m_FadeIn,
m_FadeOut,
m_Change,
m_Addition,
m_Hiding,
m_Exchange
};
}
return m_Animations;
}
@@ -306,7 +315,7 @@ namespace XCharts.Runtime
startIndex = anim.context.currPointIndex == paths.Count - 1 ?
paths.Count - 2 :
anim.context.currPointIndex;
if (startIndex < 0 || startIndex > paths.Count - 2) startIndex = 0;
if (startIndex < 0 || startIndex >= paths.Count - 1) return;
}
else
{
@@ -336,9 +345,12 @@ namespace XCharts.Runtime
{
return;
}
anim.context.currPoint = sp;
anim.context.destPoint = ep;
anim.Init(currDetailProgress, totalDetailProgress, paths.Count - 1);
if (anim.Init(currDetailProgress, totalDetailProgress, paths.Count - 1))
{
anim.context.currPoint = sp;
anim.context.destPoint = ep;
}
}
public bool IsEnd()
@@ -362,12 +374,23 @@ namespace XCharts.Runtime
return true;
var animation = activedAnimation;
if (animation != null && animation.context.end)
{
return true;
}
if (IsSerieAnimation())
{
if (m_FadeOut.context.start) 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;
if (m_FadeOut.context.start)
{
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())
{
@@ -546,7 +569,15 @@ namespace XCharts.Runtime
public float GetChangeDuration()
{
if (m_Enable && m_Change.enable)
return m_Change.duration;
return m_Change.context.currDuration > 0 ? m_Change.context.currDuration : m_Change.duration;
else
return 0;
}
public float GetExchangeDuration()
{
if (m_Enable && m_Exchange.enable)
return m_Exchange.context.currDuration > 0 ? m_Exchange.context.currDuration : m_Exchange.duration;
else
return 0;
}
@@ -554,7 +585,7 @@ namespace XCharts.Runtime
public float GetAdditionDuration()
{
if (m_Enable && m_Addition.enable)
return m_Addition.duration;
return m_Addition.context.currDuration > 0 ? m_Addition.context.currDuration : m_Addition.duration;
else
return 0;
}
@@ -562,7 +593,7 @@ namespace XCharts.Runtime
public float GetInteractionDuration()
{
if (m_Enable && m_Interaction.enable)
return m_Interaction.duration;
return m_Interaction.context.currDuration > 0 ? m_Interaction.context.currDuration : m_Interaction.duration;
else
return 0;
}

View File

@@ -53,7 +53,7 @@ namespace XCharts.Runtime
if (axis.context.labelObjectList.Count <= 0)
InitAngleAxis(axis);
else
axis.UpdateLabelText(runtimeWidth, null, false);
UpdateLabelText(axis, runtimeWidth, null, false);
}
private void InitAngleAxis(AngleAxis axis)
@@ -67,7 +67,7 @@ namespace XCharts.Runtime
string objName = component.GetType().Name + axis.index;
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.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags;
@@ -85,7 +85,7 @@ namespace XCharts.Runtime
float scaleAngle = AxisHelper.GetScaleWidth(axis, total, i + 1, null);
bool inside = axis.axisLabel.inside;
var labelName = AxisHelper.GetLabelName(axis, total, i, axis.context.minValue, axis.context.maxValue,
null, isPercentStack);
null, isPercentStack, chart.useUtc);
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
new Vector2(scaleAngle, txtHig), axis,
chart.theme.axis, labelName, Color.clear);

View File

@@ -100,6 +100,7 @@ namespace XCharts.Runtime
[SerializeField] private bool m_Clockwise = true;
[SerializeField] private bool m_InsertDataToHead;
[SerializeField][Since("v3.11.0")] private float m_MinCategorySpacing = 0;
[SerializeField][Since("v3.15.0")] private bool m_MainAxis = false;
[SerializeField] protected List<Sprite> m_Icons = new List<Sprite>();
[SerializeField] protected List<string> m_Data = new List<string>();
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
@@ -115,6 +116,13 @@ namespace XCharts.Runtime
public AxisContext context = new AxisContext();
private Action<int, string> m_OnLabelClick;
/// <summary>
/// Callback function when click on the label. Parameters: labelIndex, labelName.
/// ||点击文本标签回调函数。参数labelIndex, labelName。
/// </summary>
[Since("v3.15.0")]
public Action<int, string> onLabelClick { internal get { return m_OnLabelClick; } set { m_OnLabelClick = value; } }
/// <summary>
/// Whether to show axis.
/// ||是否显示坐标轴。
@@ -292,6 +300,17 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Clockwise, value)) SetAllDirty(); }
}
/// <summary>
/// Whether it is the main axis. When both X and Y axes are of the same type, the axis set to main axis will determine the orientation,
/// such as horizontal bar chart and vertical bar chart.
/// ||是否为主轴。当XY轴类型都相同时设置为主轴的轴会决定朝向如横向柱图和纵向柱图。
/// </summary>
[Since("v3.15.0")]
public bool mainAxis
{
get { return m_MainAxis; }
set { if (PropertyUtil.SetStruct(ref m_MainAxis, value)) SetAllDirty(); }
}
/// <summary>
/// Category data, available in type: 'Category' axis.
/// ||类目数据在类目轴type: 'category')中有效。
/// </summary>
@@ -478,6 +497,7 @@ namespace XCharts.Runtime
context.maxValue = 0;
context.destMinValue = 0;
context.destMaxValue = 0;
context.labelValueList.Clear();
}
public Axis Clone()
@@ -609,13 +629,13 @@ namespace XCharts.Runtime
return m_Position == AxisPosition.Bottom;
}
public bool IsNeedShowLabel(int index, int total = 0)
public bool IsNeedShowLabel(int index, int total = 0, string content = null)
{
if (total == 0)
{
total = context.labelValueList.Count;
}
return axisLabel.IsNeedShowLabel(index, total);
return axisLabel.IsNeedShowLabel(index, total, content);
}
public void SetNeedUpdateFilterData()
@@ -836,22 +856,6 @@ namespace XCharts.Runtime
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)
{
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<double> labelValueList { get { return m_LabelValueList; } }
public List<ChartLabel> labelObjectList { get { return m_AxisLabelList; } }
public List<int> sortedDataIndices { get { return m_SortedDataIndices; } }
public int dataZoomStartIndex;
/// <summary>
/// 添加过的历史数据总数
@@ -86,6 +87,7 @@ namespace XCharts.Runtime
private List<ChartLabel> m_AxisLabelList = new List<ChartLabel>();
private List<double> m_LabelValueList = new List<double>();
private List<string> m_RuntimeData = new List<string>();
private List<int> m_SortedDataIndices = new List<int>();
internal void Clear()
{
@@ -101,41 +103,55 @@ namespace XCharts.Runtime
internal void UpdateFilterData(List<string> data, DataZoom dataZoom)
{
int start = 0, end = 0;
var range = Mathf.RoundToInt(data.Count * (dataZoom.end - dataZoom.start) / 100);
if (range <= 0)
range = 1;
if (dataZoom.context.invert)
// Use (N-1) intervals to match shadow drawing (scaleWid = width/(N-1)).
// CeilToInt for start, FloorToInt for end, so filter aligns exactly with filler.
int n = data.Count - 1;
int startIndex, endIndex;
if (n > 0)
{
end = Mathf.RoundToInt(data.Count * dataZoom.end / 100);
start = end - range;
if (start < 0) start = 0;
if (dataZoom.context.invert)
{
startIndex = Mathf.CeilToInt((float)n * (100 - dataZoom.end) / 100);
endIndex = Mathf.FloorToInt((float)n * (100 - dataZoom.start) / 100);
}
else
{
startIndex = Mathf.CeilToInt((float)n * dataZoom.start / 100);
endIndex = Mathf.FloorToInt((float)n * dataZoom.end / 100);
}
}
else
{
start = Mathf.RoundToInt(data.Count * dataZoom.start / 100);
end = start + range;
if (end > data.Count) end = data.Count;
startIndex = 0;
endIndex = 0;
}
var range = endIndex - startIndex + 1;
if (range <= 0)
range = 1;
start = startIndex;
if (start < 0) start = 0;
end = start + range;
if (end > data.Count) end = data.Count;
var minZoomRatio = (int)(data.Count * dataZoom.minZoomRatio);
if (start != filterStart ||
end != filterEnd ||
dataZoom.minShowNum != filterMinShow ||
minZoomRatio != filterMinShow ||
isNeedUpdateFilterData)
{
filterStart = start;
filterEnd = end;
filterMinShow = dataZoom.minShowNum;
filterMinShow = minZoomRatio;
isNeedUpdateFilterData = false;
if (data.Count > 0)
{
if (range < dataZoom.minShowNum)
if (range < minZoomRatio)
{
if (dataZoom.minShowNum > data.Count)
if (dataZoom.minZoomRatio > data.Count)
range = data.Count;
else
range = dataZoom.minShowNum;
range = minZoomRatio;
}
if (range > data.Count - start)
start = data.Count - range;

View File

@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using XCharts.Runtime;
using XUGL;
@@ -31,6 +33,33 @@ namespace XCharts
protected virtual Orient orient { get; set; }
public override void OnPointerClick(PointerEventData eventData)
{
if (component.onLabelClick == null) return;
var labelObjects = component.context.labelObjectList;
for (int i = 0; i < labelObjects.Count; i++)
{
var label = labelObjects[i];
if (label == null) continue;
if (label.InRect(chart.pointerPos))
{
component.onLabelClick.Invoke(i, label.text.GetText());
break;
}
}
}
// public override void DrawTop(VertexHelper vh)
// {
// var color = Color.red;
// color.a = 0.5f;
// foreach (var label in component.context.labelObjectList)
// {
// if (label == null) continue;
// UGL.DrawRectangle(vh, label.rect, color);
// }
// }
protected virtual void UpdatePointerValue(Axis axis)
{
var grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
@@ -93,10 +122,9 @@ namespace XCharts
{
if (axis is YAxis)
{
var yRate = axis.context.minMaxRange / grid.context.height;
var yValue = yRate * (chart.pointerPos.y - grid.context.y - axis.context.offset);
if (axis.context.minValue > 0)
yValue += axis.context.minValue;
var yValue = axis.context.minValue + (chart.pointerPos.y - grid.context.y) / grid.context.height * axis.context.minMaxRange;
if (axis.inverse)
yValue = -yValue;
var labelX = axis.GetLabelObjectPosition(0).x;
axis.context.pointerValue = yValue;
@@ -121,10 +149,9 @@ namespace XCharts
}
else
{
var xRate = axis.context.minMaxRange / grid.context.width;
xValue = xRate * (chart.pointerPos.x - grid.context.x - axis.context.offset);
if (axis.context.minValue > 0)
xValue += axis.context.minValue;
xValue = axis.context.minValue + (chart.pointerPos.x - grid.context.x) / grid.context.width * axis.context.minMaxRange;
if (axis.inverse)
xValue = -xValue;
}
var labelY = axis.GetLabelObjectPosition(0).y;
axis.context.pointerValue = xValue;
@@ -149,21 +176,30 @@ namespace XCharts
axis.context.minValue = 0;
axis.context.maxValue = axis.data.Count > 0 ? axis.data.Count - 1 : SeriesHelper.GetMaxSerieDataCount(chart.series) - 1;
axis.context.minMaxRange = axis.context.maxValue;
if (chart.HasRealtimeSortSerie(axis.gridIndex))
{
UpdateAxisLabelText(axis);
}
return;
}
double tempMinValue;
double tempMaxValue;
axis.context.needAnimation = Application.isPlaying && axis.animation.show;
if (axis.inverse != axis.context.lastCheckInverse)
{
foreach (var serie in chart.series)
serie.context.InvalidateMinMaxCache();
}
chart.GetSeriesMinMaxValue(axis, axisIndex, out tempMinValue, out tempMaxValue);
var dataZoom = chart.GetDataZoomOfAxis(axis);
if (dataZoom != null && dataZoom.enable)
{
if (axis is XAxis)
dataZoom.SetXAxisIndexValueInfo(axisIndex, ref tempMinValue, ref tempMaxValue);
dataZoom.SetXAxisIndexValueInfo(axisIndex, ref tempMinValue, ref tempMaxValue, axis.inverse);
else
dataZoom.SetYAxisIndexValueInfo(axisIndex, ref tempMinValue, ref tempMaxValue);
dataZoom.SetYAxisIndexValueInfo(axisIndex, ref tempMinValue, ref tempMaxValue, axis.inverse);
}
if (tempMinValue != axis.context.destMinValue ||
@@ -236,7 +272,93 @@ namespace XCharts
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
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 isY = axis is YAxis;
var showData = serie.GetDataList(dataZoom, true);
if (CheckSortedDataChanged(axis, showData))
{
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, chart.useUtc, i);
context.labelObjectList[i].SetText(text);
}
}
SaveSortedDataIndex(axis, showData);
}
if (CheckSortedDataAnimation(axis, showData))
{
float diff = axis.context.scaleWidth / 2;
for (int i = 0; i < context.labelObjectList.Count; i++)
{
var labelObject = context.labelObjectList[i];
if (labelObject != null)
{
if (i < showData.Count)
{
var serieData = showData[i];
var pos = serieData.context.exchangePosition;
if (ChartHelper.IsZeroVector(pos)) continue;
var sourPos = labelObject.GetPosition();
labelObject.SetPosition(isY ? new Vector3(sourPos.x, pos.y + diff) : new Vector3(pos.x + diff, sourPos.y));
}
}
}
}
}
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, chart.useUtc);
context.labelObjectList[i].SetText(text);
}
}
}
}
private static 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 static bool CheckSortedDataAnimation(Axis axis, List<SerieData> dataList)
{
if (!axis.IsCategory()) return false;
foreach (var data in dataList)
{
if (!data.context.exchangeEnd) return true;
}
return false;
}
private static 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)
@@ -245,7 +367,7 @@ namespace XCharts
{
var lastCount = axis.context.labelValueList.Count;
axis.context.tickValue = DateTimeUtil.UpdateTimeAxisDateTimeList(axis.context.labelValueList,
(int)axis.context.minValue, (int)axis.context.maxValue, axis.splitNumber);
axis.context.minValue, axis.context.maxValue, axis.splitNumber, axis.ceilRate, !chart.useUtc);
if (axis.context.labelValueList.Count != lastCount)
axis.SetAllDirty();
@@ -328,13 +450,17 @@ namespace XCharts
return Math.Pow(10, n);
}
internal void CheckValueLabelActive(Axis axis, int i, ChartLabel label, Vector3 pos)
internal void CheckValueLabelActive(Axis axis, int i, ChartLabel label, Vector3 pos, string content = null)
{
if (!axis.show || !axis.axisLabel.show)
{
label.SetTextActive(false);
return;
}
if (content == null)
{
content = label.text.GetText();
}
if (axis.IsValue())
{
if (orient == Orient.Horizonal)
@@ -342,12 +468,12 @@ namespace XCharts
if (i == 0)
{
var dist = GetLabelPosition(0, 1).x - pos.x;
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredWidth());
label.SetTextActive(axis.IsNeedShowLabel(i, 0, content) && dist > label.text.GetPreferredWidth());
}
else if (i == axis.context.labelValueList.Count - 1)
{
var dist = pos.x - GetLabelPosition(0, i - 1).x;
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredWidth());
label.SetTextActive(axis.IsNeedShowLabel(i, 0, content) && dist > label.text.GetPreferredWidth());
}
}
else
@@ -355,12 +481,12 @@ namespace XCharts
if (i == 0)
{
var dist = GetLabelPosition(0, 1).y - pos.y;
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredHeight());
label.SetTextActive(axis.IsNeedShowLabel(i, 0, content) && dist > label.text.GetPreferredHeight());
}
else if (i == axis.context.labelValueList.Count - 1)
{
var dist = pos.y - GetLabelPosition(0, i - 1).y;
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredHeight());
label.SetTextActive(axis.IsNeedShowLabel(i, 0, content) && dist > label.text.GetPreferredHeight());
}
}
}
@@ -372,6 +498,7 @@ namespace XCharts
var axisLength = (axis.context.end - axis.context.start).magnitude;
if (axisLength == 0) return;
chart.InitAxisRuntimeData(axis);
UpdateAxisMinMaxValue(axis.index, axis, true);
var objName = ChartCached.GetComponentObjectName(axis);
var axisObj = ChartHelper.AddObject(objName,
@@ -379,7 +506,7 @@ namespace XCharts
chart.chartMinAnchor,
chart.chartMaxAnchor,
chart.chartPivot,
chart.chartSizeDelta);
chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags;
@@ -415,13 +542,20 @@ namespace XCharts
if (axis.IsCategory() && axis.boundaryGap)
splitNumber -= 1;
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++)
{
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.destMaxValue,
dataZoom, isPercentStack);
dataZoom, isPercentStack, chart.useUtc, i);
var label = ChartHelper.AddAxisLabelObject(splitNumber, i,
ChartCached.GetAxisLabelName(i),
@@ -473,7 +607,6 @@ namespace XCharts
break;
}
}
UpdateAxisMinMaxValue(axis.index, axis, true);
}
protected void InitAxis(Axis relativedAxis, Orient orient,
@@ -481,6 +614,7 @@ namespace XCharts
{
Axis axis = component;
chart.InitAxisRuntimeData(axis);
UpdateAxisMinMaxValue(axis.index, axis, true);
var objName = ChartCached.GetComponentObjectName(axis);
var axisObj = ChartHelper.AddObject(objName,
@@ -488,7 +622,7 @@ namespace XCharts
chart.chartMinAnchor,
chart.chartMaxAnchor,
chart.chartPivot,
chart.chartSizeDelta);
chart.chartSizeDelta, -1, chart.childrenNodeNames);
axisObj.SetActive(axis.show);
axisObj.hideFlags = chart.chartHideFlags;
@@ -527,13 +661,20 @@ namespace XCharts
if (axis.IsCategory() && axis.boundaryGap)
splitNumber -= 1;
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++)
{
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.destMaxValue,
dataZoom, isPercentStack);
dataZoom, isPercentStack, chart.useUtc, i);
var label = ChartHelper.AddAxisLabelObject(splitNumber, i,
ChartCached.GetAxisLabelName(i),
@@ -549,7 +690,7 @@ namespace XCharts
var pos = GetLabelPosition(totalWidth + gapWidth, i);
label.SetPosition(pos);
CheckValueLabelActive(axis, i, label, pos);
CheckValueLabelActive(axis, i, label, pos, labelName);
axis.context.labelObjectList.Add(label);
@@ -557,8 +698,8 @@ namespace XCharts
}
if (axis.axisName.show)
{
ChartLabel label = null;
var relativedDist = (relativedAxis == null ? 0 : relativedAxis.context.offset);
ChartLabel label;
var relativedDist = relativedAxis == null ? 0 : relativedAxis.context.offset;
var zeroPos = new Vector3(axisStartX, axisStartY + relativedDist);
var offset = axis.axisName.labelStyle.offset;
var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor);
@@ -637,7 +778,6 @@ namespace XCharts
}
}
}
UpdateAxisMinMaxValue(axis.index, axis, true);
}
internal static Vector3 GetLabelPosition(int i, Orient orient, Axis axis, Axis relativedAxis, AxisTheme theme,
@@ -695,17 +835,19 @@ namespace XCharts
var lineWidth = axis.axisLine.GetWidth(theme.lineWidth);
var lineType = axis.axisLine.GetType(theme.lineType);
var lineColor = axis.axisLine.GetColor(theme.lineColor);
var sExtendLength = axis.axisLine.startExtendLength;
var eExtendLength = axis.axisLine.endExtendLength;
if (orient == Orient.Horizonal)
{
var left = new Vector3(startX - lineWidth - (inverse ? offset : 0), startY);
var right = new Vector3(startX + axisLength + lineWidth + (!inverse ? offset : 0), startY);
var left = new Vector3(startX - lineWidth - (inverse ? offset : 0) - sExtendLength, startY);
var right = new Vector3(startX + axisLength + lineWidth + (!inverse ? offset : 0) + eExtendLength, startY);
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, left, right, lineColor);
}
else
{
var bottom = new Vector3(startX, startY - lineWidth - (inverse ? offset : 0));
var top = new Vector3(startX, startY + axisLength + lineWidth + (!inverse ? offset : 0));
var bottom = new Vector3(startX, startY - lineWidth - (inverse ? offset : 0) - sExtendLength);
var top = new Vector3(startX, startY + axisLength + lineWidth + (!inverse ? offset : 0) + eExtendLength);
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, bottom, top, lineColor);
}
}

View File

@@ -116,9 +116,10 @@ namespace XCharts.Runtime
/// <param name="dataZoom"></param>
/// <returns></returns>
public static string GetLabelName(Axis axis, float coordinateWidth, int index, double minValue, double maxValue,
DataZoom dataZoom, bool forcePercent)
DataZoom dataZoom, bool forcePercent, bool useUtc, int sortIndex = -1)
{
int split = GetSplitNumber(axis, coordinateWidth, dataZoom);
if (sortIndex == -1) sortIndex = index;
if (axis.type == Axis.AxisType.Value)
{
if (minValue == 0 && maxValue == 0)
@@ -137,7 +138,7 @@ namespace XCharts.Runtime
if (forcePercent)
return string.Format("{0}%", (int)value);
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)
{
@@ -150,7 +151,7 @@ namespace XCharts.Runtime
minValue = -minValue;
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)
{
@@ -160,7 +161,7 @@ namespace XCharts.Runtime
return string.Empty;
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, !useUtc);
}
var showData = axis.GetDataList(dataZoom);
int dataCount = showData.Count;
@@ -172,18 +173,18 @@ namespace XCharts.Runtime
{
if (index > 0)
{
var residue = (dataCount - 1) - split * rate;
var residue = dataCount - 1 - split * rate;
var newIndex = residue + (index - 1) * rate;
if (newIndex < 0)
newIndex = 0;
return axis.axisLabel.GetFormatterContent(newIndex, showData[newIndex]);
return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[newIndex]);
}
else
{
if (axis.boundaryGap && coordinateWidth / dataCount > 5)
return string.Empty;
else
return axis.axisLabel.GetFormatterContent(0, showData[0]);
return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[0]);
}
}
else
@@ -191,7 +192,7 @@ namespace XCharts.Runtime
int newIndex = index * rate;
if (newIndex < dataCount)
{
return axis.axisLabel.GetFormatterContent(newIndex, showData[newIndex]);
return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[newIndex]);
}
else
{
@@ -199,7 +200,7 @@ namespace XCharts.Runtime
if (axis.boundaryGap && ((diff > 0 && diff / rate < 0.4f) || dataCount >= axis.data.Count))
return string.Empty;
else
return axis.axisLabel.GetFormatterContent(dataCount - 1, showData[dataCount - 1]);
return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[dataCount - 1]);
}
}
}
@@ -353,8 +354,8 @@ namespace XCharts.Runtime
axis.splitNumber = splitNumber;
return;
}
if (axis.type == Axis.AxisType.Time) { }
else if (axis.minMaxType == Axis.AxisMinMaxType.Custom)
if (ceilRate == 0) ceilRate = axis.ceilRate;
if (axis.minMaxType == Axis.AxisMinMaxType.Custom)
{
if (axis.min != 0 || axis.max != 0)
{
@@ -370,13 +371,19 @@ namespace XCharts.Runtime
}
}
}
else if (axis.type == Axis.AxisType.Time)
{
if (ceilRate != 0)
{
minValue = ChartHelper.GetMinCeilRate(minValue, ceilRate);
maxValue = ChartHelper.GetMaxCeilRate(maxValue, ceilRate);
}
}
else
{
if (ceilRate == 0) ceilRate = axis.ceilRate;
switch (axis.minMaxType)
{
case Axis.AxisMinMaxType.Default:
if (minValue == 0 && maxValue == 0) { }
else if (minValue > 0 && maxValue > 0)
{
@@ -488,17 +495,17 @@ namespace XCharts.Runtime
public static double GetAxisPositionValue(GridCoord grid, Axis axis, Vector3 pos)
{
if (axis is YAxis)
return GetAxisPositionValue(pos.y, grid.context.height, axis.context.minMaxRange, grid.context.y, axis.context.offset);
return GetAxisPositionValue(pos.y, grid.context.height, axis.context.minMaxRange, grid.context.y, axis.context.offset, axis.context.minValue);
else if (axis is XAxis)
return GetAxisPositionValue(pos.x, grid.context.width, axis.context.minMaxRange, grid.context.x, axis.context.offset);
return GetAxisPositionValue(pos.x, grid.context.width, axis.context.minMaxRange, grid.context.x, axis.context.offset, axis.context.minValue);
else
return 0;
}
public static double GetAxisPositionValue(float xy, float axisLength, double axisRange, float axisStart, float axisOffset)
public static double GetAxisPositionValue(float xy, float axisLength, double axisRange, float axisStart, float axisOffset, double minValue = 0)
{
var yRate = axisRange / axisLength;
return yRate * (xy - axisStart - axisOffset);
return minValue + yRate * (xy - axisStart - axisOffset);
}
/// <summary>
@@ -535,9 +542,9 @@ namespace XCharts.Runtime
/// <param name="scaleWidth"></param>
/// <param name="value"></param>
/// <returns></returns>
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value, float gap = 0)
{
return GetAxisPositionInternal(grid, axis, scaleWidth, value, false, true);
return GetAxisPositionInternal(grid, axis, scaleWidth, value, false, true, gap);
}
/// <summary>
@@ -571,10 +578,11 @@ namespace XCharts.Runtime
}
}
private static float GetAxisPositionInternal(GridCoord grid, Axis axis, float scaleWidth, double value, bool includeGridXY, bool realLength)
private static float GetAxisPositionInternal(GridCoord grid, Axis axis, float scaleWidth, double value, bool includeGridXY, bool realLength, float gap = 0)
{
var isY = axis is YAxis;
var gridHeight = isY ? grid.context.height : grid.context.width;
gridHeight -= gap;
var gridXY = isY ? grid.context.y : grid.context.x;
if (axis.IsLog())

View File

@@ -17,6 +17,7 @@ namespace XCharts.Runtime
[SerializeField] private bool m_OnZero = false;
[SerializeField] private bool m_ShowStartLabel = true;
[SerializeField] private bool m_ShowEndLabel = true;
[SerializeField][Since("v3.15.0")] private bool m_ShowZeroLabel = true;
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
/// <summary>
@@ -74,6 +75,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_ShowEndLabel, value)) SetComponentDirty(); }
}
/// <summary>
/// Whether to display the zero label.
/// ||是否显示0刻度文本。
/// </summary>
public bool showZeroLabel
{
get { return m_ShowZeroLabel; }
set { if (PropertyUtil.SetStruct(ref m_ShowZeroLabel, value)) SetComponentDirty(); }
}
/// <summary>
/// 文本限制。
/// </summary>
public TextLimit textLimit
@@ -118,6 +128,7 @@ namespace XCharts.Runtime
height = height,
showStartLabel = showStartLabel,
showEndLabel = showEndLabel,
showZeroLabel = showZeroLabel,
textLimit = textLimit.Clone()
};
axisLabel.textStyle.Copy(textStyle);
@@ -136,6 +147,7 @@ namespace XCharts.Runtime
height = axisLabel.height;
showStartLabel = axisLabel.showStartLabel;
showEndLabel = axisLabel.showEndLabel;
showZeroLabel = axisLabel.showZeroLabel;
textLimit.Copy(axisLabel.textLimit);
textStyle.Copy(axisLabel.textStyle);
}
@@ -145,7 +157,7 @@ namespace XCharts.Runtime
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))
return GetFormatterFunctionContent(labelIndex, category, category);
@@ -157,27 +169,28 @@ namespace XCharts.Runtime
else
{
var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, category);
FormatterHelper.ReplaceAxisLabelContent(ref content, category, labelIndex, totalIndex);
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)
{
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, string content = null)
{
var labelShow = show && (interval == 0 || index % (interval + 1) == 0);
if (labelShow)
{
if (!showStartLabel && index == 0) labelShow = false;
else if (!showEndLabel && index == total - 1) labelShow = false;
if (labelShow && content == "0") labelShow = showZeroLabel;
}
return labelShow;
}

View File

@@ -10,6 +10,8 @@ namespace XCharts.Runtime
public class AxisLine : BaseLine
{
[SerializeField] private bool m_OnZero;
[SerializeField] private float m_StartExtendLength;
[SerializeField] private float m_EndExtendLength;
[SerializeField] private bool m_ShowArrow;
[SerializeField] private ArrowStyle m_Arrow = new ArrowStyle();
@@ -23,6 +25,24 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_OnZero, value)) SetVerticesDirty(); }
}
/// <summary>
/// Extend length of the axis line at the start.
/// ||轴线起点延长线长度。
/// </summary>
public float startExtendLength
{
get { return m_StartExtendLength; }
set { if (PropertyUtil.SetStruct(ref m_StartExtendLength, value)) SetVerticesDirty(); }
}
/// <summary>
/// Extend length of the axis line at the end.
/// ||轴线终点延长线长度。
/// </summary>
public float endExtendLength
{
get { return m_EndExtendLength; }
set { if (PropertyUtil.SetStruct(ref m_EndExtendLength, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to show the arrow symbol of axis.
/// ||是否显示箭头。
/// </summary>

View File

@@ -80,7 +80,7 @@ namespace XCharts.Runtime
InitRadiusAxis(axis);
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 objName = component.GetType().Name + axis.index;
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.SetActive(axis.show && axis.axisLabel.show);
axisObj.hideFlags = chart.chartHideFlags;
@@ -114,7 +114,7 @@ namespace XCharts.Runtime
var inside = axis.axisLabel.inside;
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
var labelName = AxisHelper.GetLabelName(axis, radius, i, axis.context.minValue, axis.context.maxValue,
null, isPercentStack);
null, isPercentStack, chart.useUtc);
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
new Vector2(labelWidth, txtHig), axis, chart.theme.axis, labelName, Color.clear);

View File

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

View File

@@ -15,7 +15,7 @@ namespace XCharts.Runtime
component.refreshComponent = delegate ()
{
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;
backgroundObj.hideFlags = chart.chartHideFlags;

View File

@@ -15,7 +15,7 @@ namespace XCharts.Runtime
[SerializeField] private float m_BorderWidth;
[SerializeField] private Color32 m_BorderColor;
[SerializeField] private bool m_RoundedCorner = true;
[SerializeField] private float[] m_CornerRadius = new float[] { 0, 0, 0, 0 };
[SerializeField] private float[] m_CornerRadius = new float[] { 10, 10, 10, 10 };
/// <summary>
/// whether the border is visible.
@@ -82,5 +82,11 @@ namespace XCharts.Runtime
{
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

@@ -16,6 +16,7 @@ namespace XCharts.Runtime
[SerializeField][Since("v3.6.0")] private Color32 m_MarkColor;
[SerializeField] private Color32 m_BackgroundColor;
[SerializeField] private float m_BackgroundWidth;
[SerializeField][Since("v3.15.0")] private float m_BackgroundGap;
[SerializeField] private Color32 m_CenterColor;
[SerializeField] private float m_CenterGap;
[SerializeField] private float m_BorderWidth = 0;
@@ -129,6 +130,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// the gap between background and data item.
/// ||数据项背景间隙。
/// </summary>
public float backgroundGap
{
get { return m_BackgroundGap; }
set { if (PropertyUtil.SetStruct(ref m_BackgroundGap, value)) SetVerticesDirty(); }
}
/// <summary>
/// 中心区域颜色。
/// </summary>
public Color32 centerColor

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>
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
/// </summary>

View File

@@ -11,8 +11,8 @@ namespace XCharts.Runtime
[Since("v3.5.0")]
[System.Serializable]
public class MarqueeStyle : ChildComponent
{
[SerializeField][Since("v3.5.0")] private bool m_Apply = false;
{
[SerializeField][Since("v3.5.0")] private bool m_Apply = true;
[SerializeField][Since("v3.5.0")] private bool m_RealRect = false;
[SerializeField][Since("v3.5.0")] private AreaStyle m_AreaStyle = new AreaStyle();
[SerializeField][Since("v3.5.0")] private LineStyle m_LineStyle = new LineStyle();
@@ -52,7 +52,7 @@ namespace XCharts.Runtime
/// Custom checkboxes select ongoing callbacks.
/// ||自定义选取框选取进行时的回调。
/// </summary>
public Action<DataZoom> onGoing { set { m_OnStart = value; } get { return m_OnStart; } }
public Action<DataZoom> onGoing { set { m_OnGoing = value; } get { return m_OnGoing; } }
/// <summary>
/// Customize the callback at the end of the selection.
/// ||自定义选取框结束选取时的回调。

View File

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

View File

@@ -84,12 +84,16 @@ namespace XCharts.Runtime
[SerializeField] protected Sprite m_Image;
[SerializeField] protected Image.Type m_ImageType;
[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()
{
m_Show = false;
m_Type = SymbolType.EmptyCircle;
m_Size = 0f;
m_Size2 = 0f;
m_Gap = 0;
m_Width = 0f;
m_Height = 0f;
@@ -126,6 +130,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
}
/// <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.
/// ||图形标记和线条的间隙距离。
/// </summary>
@@ -183,6 +196,24 @@ namespace XCharts.Runtime
get { return m_Color; }
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); } }
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
/// <summary>

View File

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

View File

@@ -5,14 +5,33 @@ using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// comment of chart.
/// ||图表注解组件
/// The layer of comment.
/// ||注解的显示层级
/// </summary>
[Since("v3.15.0")]
public enum CommentLayer
{
/// <summary>
/// The comment is display under the serie.
/// ||注解在系列下方。
/// </summary>
Lower,
/// <summary>
/// The comment is display above the serie.
/// ||注解在系列上方。
/// </summary>
Upper
}
/// <summary>
/// comment of chart. Used to annotate special information in the chart.
/// ||图表注解组件。用于标注图表中的特殊信息。
/// </summary>
[Serializable]
[ComponentHandler(typeof(CommentHander), true)]
public class Comment : MainComponent, IPropertyChanged
{
[SerializeField] private bool m_Show = true;
[SerializeField][Since("v3.15.0")] private CommentLayer m_Layer = CommentLayer.Lower;
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
[SerializeField] private CommentMarkStyle m_MarkStyle;
[SerializeField] private List<CommentItem> m_Items = new List<CommentItem>() { new CommentItem() };
@@ -23,6 +42,11 @@ namespace XCharts.Runtime
/// </summary>
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
/// <summary>
/// The layer of comment.
/// ||注解的显示层级。
/// </summary>
public CommentLayer layer { get { return m_Layer; } set { if (PropertyUtil.SetStruct(ref m_Layer, value)) SetComponentDirty(); } }
/// <summary>
/// The items of comment.
/// ||注解项。每个注解组件可以设置多个注解项。
/// </summary>
@@ -45,7 +69,12 @@ namespace XCharts.Runtime
get { return m_MarkStyle; }
set { if (PropertyUtil.SetClass(ref m_MarkStyle, value)) SetVerticesDirty(); }
}
/// <summary>
/// Get the label style of comment item.
/// ||获取注解项的文本样式。
/// </summary>
/// <param name="index">the index of item</param>
/// <returns></returns>
public LabelStyle GetLabelStyle(int index)
{
if (index >= 0 && index < items.Count)
@@ -55,7 +84,12 @@ namespace XCharts.Runtime
}
return m_LabelStyle;
}
/// <summary>
/// Get the mark style of comment item.
/// ||获取注解项的标记样式。
/// </summary>
/// <param name="index">the index of item</param>
/// <returns></returns>
public CommentMarkStyle GetMarkStyle(int index)
{
if (index >= 0 && index < items.Count)

View File

@@ -14,7 +14,7 @@ namespace XCharts.Runtime
var comment = component;
comment.OnChanged();
comment.painter = null;
comment.refreshComponent = delegate()
comment.refreshComponent = delegate ()
{
var objName = ChartCached.GetComponentObjectName(comment);
var commentObj = ChartHelper.AddObject(objName,
@@ -22,21 +22,26 @@ namespace XCharts.Runtime
chart.chartMinAnchor,
chart.chartMaxAnchor,
chart.chartPivot,
chart.chartSizeDelta);
chart.chartSizeDelta, -1, chart.childrenNodeNames);
var siblingIndex = comment.layer == CommentLayer.Upper
? chart.topPainter.transform.GetSiblingIndex() - 1
: chart.painter.transform.GetSiblingIndex() + 1;
commentObj.SetActive(comment.show);
commentObj.transform.SetSiblingIndex(siblingIndex);
commentObj.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(commentObj);
for (int i = 0; i < comment.items.Count; i++)
{
var item = comment.items[i];
var labelStyle = comment.GetLabelStyle(i);
item.location.OnChanged();
var labelPos = chart.chartPosition + item.location.GetPosition(chart.chartWidth, chart.chartHeight);
var label = ChartHelper.AddChartLabel(s_CommentObjectName + i, commentObj.transform, labelStyle, chart.theme.common,
GetContent(item), Color.clear, TextAnchor.MiddleCenter);
label.SetActive(comment.show && item.show, true);
label.SetPosition(labelPos);
label.text.SetLocalPosition(labelStyle.offset);
label.SetPosition(labelPos + labelStyle.offset);
item.labelObject = label;
}
};
comment.refreshComponent();

View File

@@ -11,11 +11,13 @@ namespace XCharts.Runtime
public class CommentItem : ChildComponent
{
[SerializeField] private bool m_Show = true;
[SerializeField] private string m_Content = "comment";
[SerializeField] private string m_Content = "xcharts";
[SerializeField] private Rect m_MarkRect;
[SerializeField] private CommentMarkStyle m_MarkStyle = new CommentMarkStyle() { 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.BottomRight, right = 0.1f, bottom = 0.05f };
public ChartLabel labelObject { get; set; }
/// <summary>
@@ -27,7 +29,18 @@ namespace XCharts.Runtime
/// content of comment.
/// ||注解的文本内容。支持模板参数可以参考Tooltip的itemFormatter。
/// </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>
/// the mark rect of comment.
/// ||注解区域。

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -81,7 +82,7 @@ namespace XCharts.Runtime
[SerializeField] private RangeMode m_RangeMode;
[SerializeField] private float m_Start;
[SerializeField] private float m_End;
[SerializeField] private int m_MinShowNum = 2;
[SerializeField] private float m_MinZoomRatio = 0.2f;
[Range(1f, 20f)]
[SerializeField] private float m_ScrollSensitivity = 1.1f;
[SerializeField] private Orient m_Orient = Orient.Horizonal;
@@ -91,6 +92,7 @@ namespace XCharts.Runtime
[SerializeField][Since("v3.5.0")] private MarqueeStyle m_MarqueeStyle = new MarqueeStyle();
[SerializeField][Since("v3.6.0")] private bool m_StartLock;
[SerializeField][Since("v3.6.0")] private bool m_EndLock;
[SerializeField][Since("v3.12.0")] private bool m_FilterAxisRange = true;
public DataZoomContext context = new DataZoomContext();
private CustomDataZoomStartEndFunction m_StartEndFunction;
@@ -324,6 +326,16 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_EndLock, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether dataZoom filters the axis min/max range. When true, the axis scale adapts to the current zoom window.
/// When false, the axis always shows the full data range regardless of the zoom position.
/// ||是否根据DataZoom的缩放窗口过滤坐标轴的最大最小值范围。为true时坐标轴范围随缩放窗口变化为false时坐标轴始终显示全部数据范围。
/// </summary>
public bool filterAxisRange
{
get { return m_FilterAxisRange; }
set { if (PropertyUtil.SetStruct(ref m_FilterAxisRange, value)) SetVerticesDirty(); }
}
/// <summary>
/// The end percentage of the window out of the data extent, in the range of 0 ~ 100.
/// ||数据窗口范围的结束百分比。范围是0 ~ 100。
/// </summary>
@@ -336,10 +348,19 @@ namespace XCharts.Runtime
/// Minimum number of display data. Minimum number of data displayed when DataZoom is enlarged to maximum.
/// ||最小显示数据个数。当DataZoom放大到最大时最小显示的数据个数。
/// </summary>
public int minShowNum
[Obsolete("Use \"minZoomRatio\" instead", true)]
public float minShowNum
{
get { return m_MinShowNum; }
set { if (PropertyUtil.SetStruct(ref m_MinShowNum, value)) SetVerticesDirty(); }
set;get;
}
/// <summary>
/// The minimum zoom ratio of dataZoom. Range 0f-1f.
/// ||缩放区域组件的最小缩放比例范围0f-1f。
/// </summary>
public float minZoomRatio
{
get { return m_MinZoomRatio; }
set { if (PropertyUtil.SetStruct(ref m_MinZoomRatio, value)) SetVerticesDirty(); }
}
/// <summary>
/// The sensitivity of dataZoom scroll.
@@ -405,6 +426,7 @@ namespace XCharts.Runtime
public double rawMax;
public double min;
public double max;
public bool isInverse;
}
private Dictionary<int, AxisIndexValueInfo> m_XAxisIndexInfos = new Dictionary<int, AxisIndexValueInfo>();
private Dictionary<int, AxisIndexValueInfo> m_YAxisIndexInfos = new Dictionary<int, AxisIndexValueInfo>();
@@ -678,7 +700,7 @@ namespace XCharts.Runtime
context.height = chartHeight - runtimeTop - runtimeBottom;
}
internal void SetXAxisIndexValueInfo(int xAxisIndex, ref double min, ref double max)
internal void SetXAxisIndexValueInfo(int xAxisIndex, ref double min, ref double max, bool isInverse = false)
{
AxisIndexValueInfo info;
if (!m_XAxisIndexInfos.TryGetValue(xAxisIndex, out info))
@@ -688,13 +710,14 @@ namespace XCharts.Runtime
}
info.rawMin = min;
info.rawMax = max;
info.isInverse = isInverse;
info.min = min + (max - min) * start / 100;
info.max = min + (max - min) * end / 100;
min = info.min;
max = info.max;
}
internal void SetYAxisIndexValueInfo(int yAxisIndex, ref double min, ref double max)
internal void SetYAxisIndexValueInfo(int yAxisIndex, ref double min, ref double max, bool isInverse = false)
{
AxisIndexValueInfo info;
if (!m_YAxisIndexInfos.TryGetValue(yAxisIndex, out info))
@@ -704,6 +727,7 @@ namespace XCharts.Runtime
}
info.rawMin = min;
info.rawMax = max;
info.isInverse = isInverse;
info.min = min + (max - min) * start / 100;
info.max = min + (max - min) * end / 100;
min = info.min;
@@ -728,6 +752,14 @@ namespace XCharts.Runtime
var range = info.rawMax - info.rawMin;
min = info.rawMin + range * m_Start / 100;
max = info.rawMin + range * m_End / 100;
if (info.isInverse)
{
// Internal values are negated; convert back to original for data comparison
var originalMin = -max;
var originalMax = -min;
min = originalMin;
max = originalMax;
}
}
else
{
@@ -743,6 +775,14 @@ namespace XCharts.Runtime
var range = info.rawMax - info.rawMin;
min = info.rawMin + range * m_Start / 100;
max = info.rawMin + range * m_End / 100;
if (info.isInverse)
{
// Internal values are negated; convert back to original for data comparison
var originalMin = -max;
var originalMax = -min;
min = originalMin;
max = originalMax;
}
}
else
{

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
@@ -17,6 +18,11 @@ namespace XCharts.Runtime
private bool m_CheckDataZoomLabel;
private float m_DataZoomLastStartIndex;
private float m_DataZoomLastEndIndex;
private float m_LastStart;
private float m_LastEnd;
private List<double> _sampleSumPrefixCache;
private int _sampleSumPrefixMaxCount = 0;
private bool _sampleSumPrefixInverse = false;
public override void InitComponent()
{
@@ -25,7 +31,7 @@ namespace XCharts.Runtime
dataZoom.refreshComponent = delegate ()
{
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;
dataZoomObject.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(dataZoomObject);
@@ -62,6 +68,10 @@ namespace XCharts.Runtime
{
CheckDataZoomScale(component);
CheckDataZoomLabel(component);
if (m_LastStart != component.start || m_LastEnd != component.end)
{
UpdateDataZoomRange(component, component.start, component.end);
}
}
public override void DrawUpper(VertexHelper vh)
@@ -107,7 +117,7 @@ namespace XCharts.Runtime
dataZoom.context.isCoordinateDrag = true;
}
}
if (dataZoom.supportMarquee)
if (dataZoom.supportMarquee && grid.Contains(pos))
{
dataZoom.context.isMarqueeDrag = true;
dataZoom.context.marqueeStartPos = pos;
@@ -157,7 +167,7 @@ namespace XCharts.Runtime
var dataZoom = component;
var grid = chart.GetGridOfDataZoom(dataZoom);
if (dataZoom.supportMarquee)
if (dataZoom.supportMarquee && dataZoom.context.isMarqueeDrag)
{
Vector2 pos;
if (!chart.ScreenPointToChartPoint(eventData.position, out pos))
@@ -201,16 +211,38 @@ namespace XCharts.Runtime
var dataZoom = component;
if (dataZoom.supportMarquee)
if (dataZoom.supportMarquee && dataZoom.context.isMarqueeDrag)
{
dataZoom.context.isMarqueeDrag = false;
if (dataZoom.marqueeStyle.apply)
{
var grid = chart.GetGridOfDataZoom(dataZoom);
var start = (dataZoom.context.marqueeRect.x - grid.context.x) / grid.context.width * 100;
var end = (dataZoom.context.marqueeRect.x - grid.context.x + dataZoom.context.marqueeRect.width) / grid.context.width * 100;
UpdateDataZoomRange(dataZoom, start, end);
var currentRange = dataZoom.end - dataZoom.start;
var startRatio = (dataZoom.context.marqueeRect.x - grid.context.x) / grid.context.width;
var endRatio = (dataZoom.context.marqueeRect.x - grid.context.x + dataZoom.context.marqueeRect.width) / grid.context.width;
var start = dataZoom.start + startRatio * currentRange;
var end = dataZoom.start + endRatio * currentRange;
if (start > end)
{
var temp = start;
start = end;
end = temp;
}
if (start < 0) start = 0;
if (end > 100) end = 100;
if (end - start >= 1)
{
// Bypass minZoomRatio for marquee: the user explicitly selected this region.
if (!dataZoom.startLock) dataZoom.start = start;
if (!dataZoom.endLock) dataZoom.end = end;
m_LastStart = dataZoom.start;
m_LastEnd = dataZoom.end;
chart.OnDataZoomRangeChanged(dataZoom);
chart.RefreshChart();
}
}
dataZoom.context.marqueeRect = Rect.zero;
dataZoom.SetVerticesDirty();
if (dataZoom.marqueeStyle.onEnd != null)
{
dataZoom.marqueeStyle.onEnd(dataZoom);
@@ -241,31 +273,56 @@ namespace XCharts.Runtime
var dataZoom = component;
var grid = chart.GetGridOfDataZoom(dataZoom);
if (dataZoom.IsInStartZoom(localPos) ||
dataZoom.IsInEndZoom(localPos))
dataZoom.IsInEndZoom(localPos) ||
dataZoom.IsInSelectedZoom(localPos))
{
return;
}
if (dataZoom.IsInZoom(localPos) &&
!dataZoom.IsInSelectedZoom(localPos))
if (dataZoom.IsInZoom(localPos))
{
var pointerX = localPos.x;
var selectWidth = grid.context.width * (dataZoom.end - dataZoom.start) / 100;
var startX = pointerX - selectWidth / 2;
var endX = pointerX + selectWidth / 2;
if (startX < grid.context.x)
var start = dataZoom.start;
var end = dataZoom.end;
switch (dataZoom.orient)
{
startX = grid.context.x;
endX = grid.context.x + selectWidth;
case Orient.Horizonal:
var pointerX = localPos.x;
var selectWidth = dataZoom.context.width * (dataZoom.end - dataZoom.start) / 100;
var startX = pointerX - selectWidth / 2;
var endX = pointerX + selectWidth / 2;
if (startX < dataZoom.context.x)
{
startX = dataZoom.context.x;
endX = dataZoom.context.x + selectWidth;
}
else if (endX > dataZoom.context.x + dataZoom.context.width)
{
endX = dataZoom.context.x + dataZoom.context.width;
startX = dataZoom.context.x + dataZoom.context.width - selectWidth;
}
start = (startX - dataZoom.context.x) / dataZoom.context.width * 100;
end = (endX - dataZoom.context.x) / dataZoom.context.width * 100;
break;
case Orient.Vertical:
var pointerY = localPos.y;
var selectHeight = dataZoom.context.height * (dataZoom.end - dataZoom.start) / 100;
var startY = pointerY - selectHeight / 2;
var endY = pointerY + selectHeight / 2;
if (startY < dataZoom.context.y)
{
startY = dataZoom.context.y;
endY = dataZoom.context.y + selectHeight;
}
else if (endY > dataZoom.context.y + dataZoom.context.height)
{
endY = dataZoom.context.y + dataZoom.context.height;
startY = dataZoom.context.y + dataZoom.context.height - selectHeight;
}
start = (startY - dataZoom.context.y) / dataZoom.context.height * 100;
end = (endY - dataZoom.context.y) / dataZoom.context.height * 100;
break;
}
else if (endX > grid.context.x + grid.context.width)
{
endX = grid.context.x + grid.context.width;
startX = grid.context.x + grid.context.width - selectWidth;
}
var start = (startX - grid.context.x) / grid.context.width * 100;
var end = (endX - grid.context.x) / grid.context.width * 100;
UpdateDataZoomRange(dataZoom, start, end);
UpdateDataZoomRange(dataZoom, start, end, grid);
}
}
@@ -288,7 +345,7 @@ namespace XCharts.Runtime
if ((dataZoom.supportInside && dataZoom.supportInsideScroll && grid.Contains(pos)) ||
dataZoom.IsInZoom(pos))
{
ScaleDataZoom(dataZoom, eventData.scrollDelta.y * dataZoom.scrollSensitivity);
ScaleDataZoom(dataZoom, eventData.scrollDelta.y * dataZoom.scrollSensitivity, grid, pos);
}
}
@@ -369,25 +426,65 @@ namespace XCharts.Runtime
}
}
private void ScaleDataZoom(DataZoom dataZoom, float delta)
private void ScaleDataZoom(DataZoom dataZoom, float delta, GridCoord grid = null, Vector2? mousePos = null)
{
var grid = chart.GetGridOfDataZoom(dataZoom);
var deltaPercent = dataZoom.orient == Orient.Horizonal ?
Mathf.Abs(delta / grid.context.width * 100) :
Mathf.Abs(delta / grid.context.height * 100);
if (delta > 0)
if (grid == null) grid = chart.GetGridOfDataZoom(dataZoom);
var gridRange = dataZoom.orient == Orient.Horizonal ? grid.context.width : grid.context.height;
var currentRange = dataZoom.end - dataZoom.start;
if (delta > 0 && currentRange <= 0) return;
// Mouse position as a fraction [0,1] within the grid.
// The grid always maps the current [start,end] window onto its full pixel width,
// so this fraction directly equals the mouse's relative position inside the data window.
float fraction = 0.5f;
if (mousePos.HasValue && gridRange > 0)
{
if (dataZoom.end <= dataZoom.start)
return;
UpdateDataZoomRange(dataZoom, dataZoom.start + deltaPercent, dataZoom.end - deltaPercent);
float raw = dataZoom.orient == Orient.Horizonal
? (mousePos.Value.x - grid.context.x) / gridRange
: (mousePos.Value.y - grid.context.y) / gridRange;
bool isInverse = false;
if (dataZoom.orient == Orient.Horizonal && dataZoom.xAxisIndexs.Count > 0)
{
var xAxis = chart.GetChartComponent<XAxis>(dataZoom.xAxisIndexs[0]);
isInverse = xAxis != null && xAxis.inverse;
}
else if (dataZoom.orient == Orient.Vertical && dataZoom.yAxisIndexs.Count > 0)
{
var yAxis = chart.GetChartComponent<YAxis>(dataZoom.yAxisIndexs[0]);
isInverse = yAxis != null && yAxis.inverse;
}
fraction = Mathf.Clamp01(isInverse ? 1f - raw : raw);
}
else
// The data-space anchor (0~100) under the mouse — must stay at the same fraction after zoom.
var anchorPercent = dataZoom.start + fraction * currentRange;
// New range: proportional to current range for consistent zoom feel at any zoom level.
var deltaPercent = Mathf.Abs(delta / gridRange * currentRange);
var newRange = delta > 0 ? currentRange - deltaPercent : currentRange + deltaPercent;
// Place the new window so that anchorPercent stays under the mouse.
var start = anchorPercent - fraction * newRange;
var end = anchorPercent + (1f - fraction) * newRange;
// If the window goes out of [0,100], slide it to the boundary while keeping its size,
// so the zoom always feels consistent and the window never shrinks on one side only.
if (start < 0f)
{
UpdateDataZoomRange(dataZoom, dataZoom.start - deltaPercent, dataZoom.end + deltaPercent);
end = Mathf.Min(100f, newRange);
start = 0f;
}
else if (end > 100f)
{
start = Mathf.Max(0f, 100f - newRange);
end = 100f;
}
UpdateDataZoomRange(dataZoom, start, end, grid);
}
public void UpdateDataZoomRange(DataZoom dataZoom, float start, float end)
public void UpdateDataZoomRange(DataZoom dataZoom, float start, float end, GridCoord grid = null)
{
if (end > 100)
end = 100;
@@ -397,13 +494,32 @@ namespace XCharts.Runtime
if (end < start)
end = start;
if (dataZoom.startEndFunction != null)
dataZoom.startEndFunction(ref start, ref end);
if(dataZoom.minZoomRatio > 0)
{
if(grid == null) grid = chart.GetGridOfDataZoom(dataZoom);
var range = dataZoom.orient == Orient.Horizonal ? grid.context.width : grid.context.height;
var minRange = dataZoom.minZoomRatio * range;
var newRange = end - start;
var currentRange = dataZoom.end - dataZoom.start;
// Only block when shrinking the range; always allow expansion so the chart
// cannot get permanently locked after a marquee selects a narrow region.
if (newRange < minRange / range * 100 && newRange <= currentRange)
{
return;
}
}
if (!dataZoom.startLock)
dataZoom.start = start;
if (!dataZoom.endLock)
dataZoom.end = end;
if (dataZoom.startEndFunction != null)
dataZoom.startEndFunction(ref start, ref end);
m_LastStart = dataZoom.start;
m_LastEnd = dataZoom.end;
if (dataZoom.realtime)
{
chart.OnDataZoomRangeChanged(dataZoom);
@@ -436,7 +552,7 @@ namespace XCharts.Runtime
var tempPos1 = touch1.position;
var currDist = Vector2.Distance(tempPos0, tempPos1);
var lastDist = Vector2.Distance(m_LastTouchPos0, m_LastTouchPos1);
var delta = (currDist - lastDist);
var delta = currDist - lastDist;
ScaleDataZoom(dataZoom, delta / dataZoom.scrollSensitivity);
m_LastTouchPos0 = tempPos0;
m_LastTouchPos1 = tempPos1;
@@ -484,7 +600,6 @@ namespace XCharts.Runtime
}
else if (xAxis.IsTime())
{
//TODO:
dataZoom.SetStartLabelText("");
dataZoom.SetEndLabelText("");
}
@@ -524,13 +639,26 @@ namespace XCharts.Runtime
Serie serie = chart.series[0];
Axis axis = chart.GetChartComponent<YAxis>(0);
var showData = serie.GetDataList(null);
float scaleWid = dataZoom.context.width / (showData.Count - 1);
float scaleWid = showData.Count > 1 ? dataZoom.context.width / (showData.Count - 1) : dataZoom.context.width;
Vector3 lp = Vector3.zero;
Vector3 np = Vector3.zero;
double minValue = 0;
double maxValue = 0;
SeriesHelper.GetYMinMaxValue(chart, 0, axis.inverse, out minValue, out maxValue, false, false);
AxisHelper.AdjustMinMaxValue(axis, ref minValue, ref maxValue, true);
// shadow always shows the full data range, independent of DataZoom window
double minValue = SerieHelper.GetMinData(serie, 1, null, axis.inverse);
double maxValue = SerieHelper.GetMaxData(serie, 1, null, axis.inverse);
minValue = ChartHelper.GetMinDivisibleValue(minValue, 0);
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue, 0);
double xMinValue = 0;
double xMaxValue = 0;
bool useXValueForShadow = false;
var xAxisIndex = dataZoom.xAxisIndexs.Count > 0 ? dataZoom.xAxisIndexs[0] : 0;
var xAxis = chart.GetChartComponent<XAxis>(xAxisIndex);
if (xAxis != null && (xAxis.IsValue() || xAxis.IsTime()))
{
xMinValue = SerieHelper.GetMinData(serie, 0, null, xAxis.inverse);
xMaxValue = SerieHelper.GetMaxData(serie, 0, null, xAxis.inverse);
AxisHelper.AdjustMinMaxValue(xAxis, ref xMinValue, ref xMaxValue, true);
useXValueForShadow = (xMaxValue - xMinValue) > 0;
}
int rate = 1;
var sampleDist = serie.sampleDist < 2 ? 2 : serie.sampleDist;
@@ -546,12 +674,40 @@ namespace XCharts.Runtime
var animationDuration = serie.animation.GetChangeDuration();
var dataAddDuration = serie.animation.GetAdditionDuration();
var unscaledTime = serie.animation.unscaledTime;
var useCurrentData = false;
List<double> sampleSumPrefix = null;
if (serie.animation.enable)
{
useCurrentData = DataHelper.IsAnyDataChanged(ref showData, serie.minShow, maxCount);
dataChanging = useCurrentData;
}
if (!useCurrentData && rate > 1 &&
(serie.sampleType == SampleType.Sum || serie.sampleType == SampleType.Average))
{
if (_sampleSumPrefixCache == null || _sampleSumPrefixMaxCount != maxCount || _sampleSumPrefixInverse != axis.inverse)
{
_sampleSumPrefixCache = DataHelper.BuildSampleSumPrefix(ref showData, maxCount, axis.inverse);
_sampleSumPrefixMaxCount = maxCount;
_sampleSumPrefixInverse = axis.inverse;
}
sampleSumPrefix = _sampleSumPrefixCache;
}
for (int i = 0; i < maxCount; i += rate)
for (int i = serie.minShow; i < maxCount; i += rate)
{
double value = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
dataAddDuration, animationDuration, ref dataChanging, axis, unscaledTime);
float pX = dataZoom.context.x + i * scaleWid;
dataAddDuration, animationDuration, ref dataChanging, axis, unscaledTime,
useCurrentData, false, sampleSumPrefix);
float pX;
if (useXValueForShadow && i < showData.Count && showData[i].data.Count > 0)
{
var xVal = (xAxis != null && xAxis.inverse) ? -showData[i].data[0] : showData[i].data[0];
pX = dataZoom.context.x + (float)((xVal - xMinValue) / (xMaxValue - xMinValue)) * dataZoom.context.width;
}
else
{
pX = dataZoom.context.x + i * scaleWid;
}
float dataHig = (float)((maxValue - minValue) == 0 ? 0 :
(value - minValue) / (maxValue - minValue) * dataZoom.context.height);
np = new Vector3(pX, chart.chartY + dataZoom.bottom + dataHig);
@@ -619,11 +775,11 @@ namespace XCharts.Runtime
float scaleWid = dataZoom.context.height / (showData.Count - 1);
Vector3 lp = Vector3.zero;
Vector3 np = Vector3.zero;
double minValue = 0;
double maxValue = 0;
double minValue;
double maxValue;
SeriesHelper.GetYMinMaxValue(chart, 0, axis.inverse, out minValue, out maxValue);
AxisHelper.AdjustMinMaxValue(axis, ref minValue, ref maxValue, true);
minValue = ChartHelper.GetMinDivisibleValue(minValue, 0);
maxValue = ChartHelper.GetMaxDivisibleValue(maxValue, 0);
int rate = 1;
var sampleDist = serie.sampleDist < 2 ? 2 : serie.sampleDist;
var maxCount = showData.Count;
@@ -638,11 +794,30 @@ namespace XCharts.Runtime
var animationDuration = serie.animation.GetChangeDuration();
var dataAddDuration = serie.animation.GetAdditionDuration();
var unscaledTime = serie.animation.unscaledTime;
var useCurrentData = false;
List<double> sampleSumPrefix = null;
if (serie.animation.enable)
{
useCurrentData = DataHelper.IsAnyDataChanged(ref showData, serie.minShow, maxCount);
dataChanging = useCurrentData;
}
if (!useCurrentData && rate > 1 &&
(serie.sampleType == SampleType.Sum || serie.sampleType == SampleType.Average))
{
if (_sampleSumPrefixCache == null || _sampleSumPrefixMaxCount != maxCount || _sampleSumPrefixInverse != axis.inverse)
{
_sampleSumPrefixCache = DataHelper.BuildSampleSumPrefix(ref showData, maxCount, axis.inverse);
_sampleSumPrefixMaxCount = maxCount;
_sampleSumPrefixInverse = axis.inverse;
}
sampleSumPrefix = _sampleSumPrefixCache;
}
for (int i = 0; i < maxCount; i += rate)
for (int i = serie.minShow; i < maxCount; i += rate)
{
double value = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
dataAddDuration, animationDuration, ref dataChanging, axis, unscaledTime);
dataAddDuration, animationDuration, ref dataChanging, axis, unscaledTime,
useCurrentData, false, sampleSumPrefix);
float pY = dataZoom.context.y + i * scaleWid;
float dataHig = (maxValue - minValue) == 0 ? 0 :
(float)((value - minValue) / (maxValue - minValue) * dataZoom.context.width);
@@ -684,7 +859,7 @@ namespace XCharts.Runtime
private void DrawMarquee(VertexHelper vh, DataZoom dataZoom)
{
if (!dataZoom.enable || !dataZoom.supportMarquee)
if (!dataZoom.enable || !dataZoom.supportMarquee || !dataZoom.context.isMarqueeDrag)
return;
var areaColor = dataZoom.marqueeStyle.areaStyle.GetColor(chart.theme.dataZoom.dataAreaColor);
UGL.DrawRectangle(vh, dataZoom.context.marqueeRect, areaColor);

View File

@@ -75,7 +75,7 @@ namespace XCharts.Runtime
public void Init(BaseChart 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()
@@ -155,14 +155,14 @@ namespace XCharts.Runtime
}
private ChartLabel AddDebugInfoObject(string name, Transform parent, LabelStyle labelStyle,
ThemeStyle theme)
ThemeStyle theme, List<string> childrenNodeNames)
{
var anchorMax = new Vector2(0, 1);
var anchorMin = new Vector2(0, 1);
var pivot = new Vector2(0, 1);
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.hideFlags = m_Chart.chartHideFlags;
ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);

View File

@@ -68,6 +68,50 @@ namespace XCharts.Runtime
/// </summary>
End
}
/// <summary>
/// The value-based condition for showing label. Controls visibility based on threshold comparison.
/// ||标签基于值的显示条件,通过与阈值比较来控制标签的显示。
/// </summary>
public enum ShowCondition
{
/// <summary>
/// Always show label.
/// ||总是显示标签。
/// </summary>
Always,
/// <summary>
/// Show label when value is greater than showThreshold.
/// ||大于showThreshold才显示标签。
/// </summary>
GreaterThan,
/// <summary>
/// Show label when value is less than showThreshold.
/// ||小于showThreshold才显示标签。
/// </summary>
LessThan,
}
/// <summary>
/// The data-pattern-based filter for showing label. Controls visibility based on data topology.
/// ||标签基于数据形态的显示筛选,通过数据的拓扑特征(波峰/波谷)来控制标签的显示。
/// </summary>
public enum ShowFilter
{
/// <summary>
/// All data points show label.
/// ||所有数据点都显示标签。
/// </summary>
All,
/// <summary>
/// Show label when value is at a peak.
/// ||波峰才显示标签。
/// </summary>
Peak,
/// <summary>
/// Show label when value is at a valley.
/// ||波谷才显示标签。
/// </summary>
Valley
}
[SerializeField] protected bool m_Show = true;
[SerializeField] Position m_Position = Position.Default;
@@ -80,6 +124,12 @@ namespace XCharts.Runtime
[SerializeField] protected string m_NumericFormatter = "";
[SerializeField] protected float m_Width = 0;
[SerializeField] protected float m_Height = 0;
[SerializeField][Since("v3.15.0")] protected float m_FixedX = 0;
[SerializeField][Since("v3.15.0")] protected float m_FixedY = 0;
[SerializeField][Since("v3.16.0")] protected ShowCondition m_ShowCondition = ShowCondition.Always;
[SerializeField][Since("v3.16.0")] protected ShowFilter m_ShowFilter = ShowFilter.All;
[SerializeField][Since("v3.16.0")] protected double m_ShowThreshold = 0;
[SerializeField][Since("v3.16.0")] protected float m_ShowMinGap = 0;
[SerializeField] protected IconStyle m_Icon = new IconStyle();
[SerializeField] protected ImageStyle m_Background = new ImageStyle();
@@ -98,6 +148,9 @@ namespace XCharts.Runtime
m_Height = 0;
m_NumericFormatter = "";
m_AutoOffset = false;
m_ShowCondition = ShowCondition.Always;
m_ShowFilter = ShowFilter.All;
m_ShowThreshold = 0;
}
/// <summary>
@@ -131,7 +184,8 @@ namespace XCharts.Runtime
/// `{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 />
/// `{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 />
@@ -161,6 +215,7 @@ namespace XCharts.Runtime
/// `{h}`:十六进制颜色值。<br/>
/// `{y}`Y轴的类目名。<br/>
/// `{value}`:坐标轴或图例的值。<br/>
/// `{index}`:坐标轴编号。<br/>
/// 以下通配符适用UITable组件<br/>
/// `{name}` 表格的行名。<br/>
/// `{index}`:表格的行号。<br/>
@@ -286,6 +341,65 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_AutoOffset, value)) SetAllDirty(); }
}
/// <summary>
/// the fixed x of label. When not 0, it will be fixed on the specified x value.
/// ||固定的X值。不为0时会固定在指定的X值上。
/// </summary>
public float fixedX
{
get { return m_FixedX; }
set { if (PropertyUtil.SetStruct(ref m_FixedX, value)) SetComponentDirty(); }
}
/// <summary>
/// the fixed y of label. When not 0, it will be fixed on the specified y value.
/// ||固定的Y值。不为0时会固定在指定的Y值上。
/// </summary>
public float fixedY
{
get { return m_FixedY; }
set { if (PropertyUtil.SetStruct(ref m_FixedY, value)) SetComponentDirty(); }
}
/// <summary>
/// The value-based show condition of label. Default is ShowCondition.Always.
/// When set to GreaterThan or LessThan, the label is shown only when the value satisfies the threshold.
/// ||标签基于值的显示条件。默认为ShowCondition.Always总是显示。
/// 设为GreaterThan或LessThan时只有满足showThreshold阈值条件的数据点才显示标签。
/// </summary>
public ShowCondition showCondition
{
get { return m_ShowCondition; }
set { if (PropertyUtil.SetStruct(ref m_ShowCondition, value)) SetComponentDirty(); }
}
/// <summary>
/// The data-pattern-based show filter of label. Default is ShowFilter.All.
/// When set to Peak or Valley, the label is shown only at local maximum or minimum data points.
/// ||标签基于数据形态的显示筛选。默认为ShowFilter.All所有数据点都显示。
/// 设为Peak或Valley时只在局部波峰或波谷的数据点显示标签。
/// </summary>
public ShowFilter showFilter
{
get { return m_ShowFilter; }
set { if (PropertyUtil.SetStruct(ref m_ShowFilter, value)) SetComponentDirty(); }
}
/// <summary>
/// The threshold for showCondition. When showCondition is GreaterThan or LessThan, only values that satisfy the comparison will show label. Default is 0.
/// ||showCondition的阈值。当showCondition为GreaterThan或LessThan时生效只有满足比较条件的值才显示标签。默认值为0。
/// </summary>
public double showThreshold
{
get { return m_ShowThreshold; }
set { if (PropertyUtil.SetStruct(ref m_ShowThreshold, value)) SetComponentDirty(); }
}
/// <summary>
/// the gap between label and the previous label. When the distance to the previous label is less than this value,
/// the label with smaller y value will be hidden. Default is 0, which means this function is turned off.
/// 和上一个标签的最小间距。当和上一个标签的距离小于该值时隐藏对应y值较小的标签。默认为0不开启该功能。
/// </summary>
public float showMinGap
{
get { return m_ShowMinGap; }
set { if (PropertyUtil.SetStruct(ref m_ShowMinGap, value)) SetComponentDirty(); }
}
/// <summary>
/// the sytle of background.
/// ||背景图样式。
/// </summary>
@@ -373,6 +487,8 @@ namespace XCharts.Runtime
label.m_Height = m_Height;
label.m_NumericFormatter = m_NumericFormatter;
label.m_AutoOffset = m_AutoOffset;
label.m_FixedX = m_FixedX;
label.m_FixedY = m_FixedY;
label.m_Icon.Copy(m_Icon);
label.m_Background.Copy(m_Background);
label.m_TextPadding = m_TextPadding;
@@ -392,13 +508,15 @@ namespace XCharts.Runtime
m_Height = label.m_Height;
m_NumericFormatter = label.m_NumericFormatter;
m_AutoOffset = label.m_AutoOffset;
m_FixedX = label.m_FixedX;
m_FixedY = label.m_FixedY;
m_Icon.Copy(label.m_Icon);
m_Background.Copy(label.m_Background);
m_TextPadding = label.m_TextPadding;
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))
return GetFormatterFunctionContent(labelIndex, category, category);
@@ -410,12 +528,12 @@ namespace XCharts.Runtime
else
{
var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, category);
FormatterHelper.ReplaceAxisLabelContent(ref content, category, labelIndex, totalIndex);
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;
if (value == 0 && !DateTimeUtil.IsDateOrTimeRegex(newNumericFormatter))
@@ -452,17 +570,17 @@ namespace XCharts.Runtime
else
{
var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, newNumericFormatter, value);
FormatterHelper.ReplaceAxisLabelContent(ref content, newNumericFormatter, value, labelIndex, totalIndex);
return GetFormatterFunctionContent(labelIndex, value, content);
}
}
private static bool isDateFormatter = false;
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, bool local)
{
var timestamp = (int)value;
var dateTime = DateTimeUtil.GetDateTime(timestamp);
var timestamp = value;
var dateTime = DateTimeUtil.GetDateTime(timestamp, local);
var dateString = string.Empty;
if (string.IsNullOrEmpty(numericFormatter) || numericFormatter.Equals("f2"))
{
@@ -472,10 +590,10 @@ namespace XCharts.Runtime
{
try
{
if(DateTimeUtil.IsDateOrTimeRegex(numericFormatter, ref isDateFormatter, ref newFormatter))
if (DateTimeUtil.IsDateOrTimeRegex(numericFormatter, ref isDateFormatter, ref newFormatter))
{
if(isDateFormatter)
dateString = ChartCached.NumberToDateStr(timestamp, newFormatter);
if (isDateFormatter)
dateString = ChartCached.NumberToDateStr(timestamp, newFormatter, local);
else
dateString = ChartCached.NumberToTimeStr(timestamp, newFormatter);
}
@@ -492,7 +610,7 @@ namespace XCharts.Runtime
if (!string.IsNullOrEmpty(m_Formatter))
{
var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, dateString);
FormatterHelper.ReplaceAxisLabelContent(ref content, dateString, labelIndex, totalIndex);
return GetFormatterFunctionContent(labelIndex, value, content);
}
else

View File

@@ -45,7 +45,7 @@ namespace XCharts.Runtime
{
var content = serieLabel.formatter;
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue,
dataTotal, serieName, dataName, dataName, color, serieData, chart);
dataTotal, serieName, dataName, dataName, color, serieData, chart, serie.index, serie.useSortData);
if (serieLabel.formatterFunction == null)
return content;
else
@@ -53,6 +53,22 @@ namespace XCharts.Runtime
}
}
public static string GetTitleFormatterContent(Serie serie, SerieData serieData,
int dataIndex, LabelStyle titleStyle, BaseChart chart)
{
string content;
if (string.IsNullOrEmpty(titleStyle.formatter))
{
content = serieData.name;
}
else
{
content = titleStyle.formatter;
FormatterHelper.ReplaceContent(ref content, dataIndex, titleStyle.numericFormatter, serie, chart, null, serieData);
}
return content;
}
public static void SetGaugeLabelText(Serie serie)
{
var serieData = serie.GetSerieData(0);

View File

@@ -79,6 +79,9 @@ namespace XCharts.Runtime
[SerializeField] private float m_ItemGap = 10f;
[SerializeField] private bool m_ItemAutoColor = true;
[SerializeField] private float m_ItemOpacity = 1;
[SerializeField][Since("v3.15.0")] private float m_ItemInactiveOpacity = 1;
[SerializeField][Since("v3.16.0")] private float m_Width = 0;
[SerializeField][Since("v3.16.0")] private float m_Height = 0;
[SerializeField] private string m_Formatter;
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
[SerializeField][Since("v3.10.0")] private TextLimit m_TextLimit = new TextLimit();
@@ -182,6 +185,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_ItemOpacity, value)) SetComponentDirty(); }
}
/// <summary>
/// the opacity of item color when item is inactive.
/// ||图例标记的图形在非激活状态下的颜色透明度。
/// </summary>
public float itemInactiveOpacity
{
get { return m_ItemInactiveOpacity; }
set { if (PropertyUtil.SetStruct(ref m_ItemInactiveOpacity, value)) SetComponentDirty(); }
}
/// <summary>
/// No longer used, the use of LabelStyle.formatter instead.
/// ||不再使用使用LabelStyle.formatter代替。
/// </summary>
@@ -192,6 +204,25 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
}
/// <summary>
/// the width of legend component. Default is 0 for auto adapt. When set a value between 0 and 1, it means the percentage relative to chart width and height.
/// ||图例组件的宽。默认为0自适应。当设置0-1的值时表示相对于图表宽高的比例。
/// </summary>
public float width
{
get { return m_Width; }
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetComponentDirty(); }
}
/// <summary>
/// the height of legend component. Default is 0 for auto adapt. When set a value between 0 and 1, it means the percentage relative to chart width and height.
/// ||图例组件的高。默认为0自适应。当设置0-1的值时表示相对于图表宽高的比例。
/// </summary>
/// <value></value>
public float height
{
get { return m_Height; }
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetComponentDirty(); }
}
/// <summary>
/// the style of text.
/// ||文本样式。
/// </summary>

View File

@@ -55,7 +55,7 @@ namespace XCharts.Runtime
{
legend.OnChanged();
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;
legendObject.hideFlags = chart.chartHideFlags;
//ChartHelper.DestoryGameObjectByMatch(legendObject.transform, "_");
@@ -92,15 +92,15 @@ namespace XCharts.Runtime
{
if (!SeriesHelper.IsLegalLegendName(datas[i])) continue;
string legendName = datas[i];
var serieIndex = isAnySerieColorByData ? 0 : i;
var dataIndex = isAnySerieColorByData ? i : 0;
var serieIndex = isAnySerieColorByData ? 0 : i;
var dataIndex = isAnySerieColorByData ? i : 0;
var legendContent = GetFormatterContent(legend, dataIndex, datas[i], serieIndex);
if (legend.textLimit.enable)
legendContent = legend.textLimit.GetLimitContent(legendContent);
var readIndex = chart.m_LegendRealShowName.IndexOf(datas[i]);
var active = chart.IsActiveByLegend(datas[i]);
var bgColor = LegendHelper.GetIconColor(chart, legend, readIndex, datas[i], active);
bgColor.a = legend.itemOpacity;
bgColor.a = active ? legend.itemOpacity : legend.itemInactiveOpacity;
var item = LegendHelper.AddLegendItem(chart, legend, i, legendName, legendObject.transform, chart.theme,
legendContent, bgColor, active, readIndex);
legend.SetButton(legendName, item, totalLegend);

View File

@@ -16,7 +16,7 @@ namespace XCharts.Runtime
else
return !ChartHelper.IsClearColor(textStyle.color) ? textStyle.color : theme.legend.textColor;
}
else return theme.legend.unableColor;
else return theme.legend.inactiveColor;
}
public static Color GetIconColor(BaseChart chart, Legend legend, int readIndex, string legendName, bool active)
@@ -30,7 +30,7 @@ namespace XCharts.Runtime
else
return legend.GetColor(readIndex);
}
else return chart.theme.legend.unableColor;
else return chart.theme.legend.inactiveColor;
}
public static LegendItem AddLegendItem(BaseChart chart, Legend legend, int i, string legendName, Transform parent,
@@ -48,7 +48,7 @@ namespace XCharts.Runtime
var objAnchorMin = new Vector2(0, 1);
var objAnchorMax = 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 img = ChartHelper.EnsureComponent<Image>(btnObj);
img.color = Color.clear;
@@ -93,10 +93,23 @@ namespace XCharts.Runtime
var startY = 0f;
var legendMaxWidth = chartWidth - legend.location.runtimeLeft - legend.location.runtimeRight;
var legendMaxHeight = chartHeight - legend.location.runtimeTop - legend.location.runtimeBottom;
var isVertical = legend.orient == Orient.Vertical;
var fixedWidth = legend.width <= 0 ? 0
: legend.width < 1 ? chartWidth * legend.width
: legend.width;
var fixedHeight = legend.height <= 0 ? 0
: legend.height < 1 ? chartHeight * legend.height
: legend.height;
// Horizonal: width constrains layout wrapping; Vertical: height constrains layout wrapping.
// The other axis only affects the background size, not the layout.
if (!isVertical && fixedWidth > 0) legendMaxWidth = fixedWidth;
if (isVertical && fixedHeight > 0) legendMaxHeight = fixedHeight;
UpdateLegendWidthAndHeight(legend, legendMaxWidth, legendMaxHeight);
// Override context size for fixed dimensions (controls background rect size).
if (fixedWidth > 0) legend.context.width = fixedWidth;
if (fixedHeight > 0) legend.context.height = fixedHeight;
var legendRuntimeWidth = legend.context.width;
var legendRuntimeHeight = legend.context.height;
var isVertical = legend.orient == Orient.Vertical;
switch (legend.location.align)
{
case Location.Align.TopCenter:
@@ -198,11 +211,14 @@ namespace XCharts.Runtime
legend.context.eachHeight = 0;
if (legend.orient == Orient.Horizonal)
{
var maxRowWidth = 0f;
foreach (var kv in legend.context.buttonList)
{
if (width + kv.Value.width > maxWidth)
{
realWidth = width - legend.itemGap;
if (realWidth > maxRowWidth)
maxRowWidth = realWidth;
realHeight += height + legend.itemGap;
if (legend.context.eachHeight < height + legend.itemGap)
{
@@ -216,8 +232,10 @@ namespace XCharts.Runtime
height = kv.Value.height;
}
width -= legend.itemGap;
if (width > maxRowWidth)
maxRowWidth = width;
legend.context.height = realHeight + height;
legend.context.width = realWidth > 0 ? realWidth : width;
legend.context.width = maxRowWidth;
}
else
{

View File

@@ -14,7 +14,7 @@ namespace XCharts.Runtime
public override void InitComponent()
{
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;
ChartHelper.HideAllObject(m_MarkLineLabelRoot);
InitMarkArea(component);
@@ -40,7 +40,7 @@ namespace XCharts.Runtime
private void InitMarkArea(MarkArea markArea)
{
markArea.painter = chart.m_PainterUpper;
markArea.refreshComponent = delegate()
markArea.refreshComponent = delegate ()
{
var label = ChartHelper.AddChartLabel("label", m_MarkLineLabelRoot.transform, markArea.label, chart.theme.axis,
component.text, Color.clear, TextAnchor.MiddleCenter);
@@ -142,31 +142,12 @@ namespace XCharts.Runtime
else if (data.yValue != 0)
{
data.runtimeValue = data.yValue;
if (yAxis.IsCategory())
{
var pY = AxisHelper.GetAxisPosition(grid, yAxis, data.yValue, showData.Count, dataZoom);
return start ?
new Vector3(grid.context.x, pY) :
new Vector3(grid.context.x + grid.context.width, pY);
}
else
{
return GetPosition(xAxis, yAxis, grid, data.runtimeValue, start);
}
return GetPosition(yAxis, grid, data.runtimeValue, start);
}
else
{
data.runtimeValue = data.xValue;
if (xAxis.IsCategory())
{
var pX = AxisHelper.GetAxisPosition(grid, xAxis, data.xValue, showData.Count, dataZoom);
return start ? new Vector3(pX, grid.context.y + grid.context.height) :
new Vector3(pX, grid.context.y);
}
else
{
return GetPosition(xAxis, yAxis, grid, data.xValue, start);
}
return GetPosition(xAxis, grid, data.xValue, start);
}
default:
break;
@@ -178,16 +159,28 @@ namespace XCharts.Runtime
{
if (yAxis.IsCategory())
{
var pX = AxisHelper.GetAxisPosition(grid, xAxis, value);
return GetPosition(xAxis, grid, value, start);
}
else
{
return GetPosition(yAxis, grid, value, start);
}
}
private Vector3 GetPosition(Axis axis, GridCoord grid, double value, bool start)
{
if (axis is XAxis)
{
var pX = AxisHelper.GetAxisPosition(grid, axis, value);
return start ?
new Vector3(pX, grid.context.y + grid.context.height) :
new Vector3(pX, grid.context.y);
}
else
{
var pY = AxisHelper.GetAxisPosition(grid, yAxis, value);
var pY = AxisHelper.GetAxisPosition(grid, axis, value);
return start ?
new Vector3(grid.context.x, pY + grid.context.height) :
new Vector3(grid.context.x, pY) :
new Vector3(grid.context.x + grid.context.width, pY);
}
}

View File

@@ -4,25 +4,34 @@ using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// 标线类型
/// Mark line type.
/// ||标线类型
/// </summary>
public enum MarkLineType
{
None,
/// <summary>
/// 最小值。
/// Custom. You can customize the xy coordinates or values.
/// ||自定义。可自定义xy坐标或数值。
/// </summary>
Custom,
/// <summary>
/// Minimum value.
/// ||最小值。
/// </summary>
Min,
/// <summary>
/// 最大值。
/// Maximum value.
/// ||最大值。
/// </summary>
Max,
/// <summary>
/// 平均值。
/// Average value.
/// ||平均值。
/// </summary>
Average,
/// <summary>
/// 中位数。
/// Median.
/// ||中位数。
/// </summary>
Median
}
@@ -118,7 +127,7 @@ namespace XCharts.Runtime
[System.Serializable]
public class MarkLineData : ChildComponent
{
[SerializeField] private MarkLineType m_Type = MarkLineType.None;
[SerializeField] private MarkLineType m_Type = MarkLineType.Custom;
[SerializeField] private string m_Name;
[SerializeField] private int m_Dimension = 1;
[SerializeField] private float m_XPosition;
@@ -170,7 +179,7 @@ namespace XCharts.Runtime
}
/// <summary>
/// The x coordinate relative to the origin, in pixels.
/// ||相对原点的 x 坐标单位像素。当type为None时有效。
/// ||相对原点的 x 坐标单位像素。当type为Custom时有效。
/// </summary>
public float xPosition
{
@@ -179,7 +188,7 @@ namespace XCharts.Runtime
}
/// <summary>
/// The y coordinate relative to the origin, in pixels.
/// ||相对原点的 y 坐标单位像素。当type为None时有效。
/// ||相对原点的 y 坐标单位像素。当type为Custom时有效。
/// </summary>
public float yPosition
{
@@ -188,7 +197,7 @@ namespace XCharts.Runtime
}
/// <summary>
/// The value specified on the X-axis. A value specified when the X-axis is the category axis represents the index of the category axis data, otherwise a specific value.
/// ||X轴上的指定值。当X轴为类目轴时指定值表示类目轴数据的索引否则为具体的值。当type为None时有效。
/// ||X轴上的指定值。当X轴为类目轴时指定值表示类目轴数据的索引否则为具体的值。当type为Custom时有效。
/// </summary>
public double xValue
{
@@ -197,7 +206,7 @@ namespace XCharts.Runtime
}
/// <summary>
/// That's the value on the Y-axis. The value specified when the Y axis is the category axis represents the index of the category axis data, otherwise the specific value.
/// ||Y轴上的指定值。当Y轴为类目轴时指定值表示类目轴数据的索引否则为具体的值。当type为None时有效。
/// ||Y轴上的指定值。当Y轴为类目轴时指定值表示类目轴数据的索引否则为具体的值。当type为Custom时有效。
/// </summary>
public double yValue
{

View File

@@ -13,7 +13,7 @@ namespace XCharts.Runtime
public override void InitComponent()
{
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;
ChartHelper.HideAllObject(m_MarkLineLabelRoot);
InitMarkLine(component);
@@ -146,7 +146,7 @@ namespace XCharts.Runtime
data.runtimeValue = SerieHelper.GetMedianData(serie, data.dimension, dataZoom);
GetStartEndPos(yAxis, grid, data.runtimeValue, ref sp, ref ep);
break;
case MarkLineType.None:
case MarkLineType.Custom:
if (data.xPosition != 0)
{
data.runtimeValue = data.xPosition;
@@ -292,18 +292,20 @@ namespace XCharts.Runtime
switch (data.type)
{
case MarkLineType.Min:
var serieData = SerieHelper.GetMinSerieData(serie, data.dimension, dataZoom);
var serieData = SerieHelper.GetMinSerieData(serie, data.dimension, null);
data.runtimeValue = serieData.GetData(data.dimension);
var pX = GetAxisPosition(grid, xAxis, dataZoom, serieDataCount, serieData.index);
var pY = GetAxisPosition(grid, yAxis, dataZoom, serieDataCount, data.runtimeValue);
return new Vector3(pX, pY);
//return new Vector3(pX, pY);
return serieData.context.position;
case MarkLineType.Max:
serieData = SerieHelper.GetMaxSerieData(serie, data.dimension, dataZoom);
serieData = SerieHelper.GetMaxSerieData(serie, data.dimension, null);
data.runtimeValue = serieData.GetData(data.dimension);
pX = GetAxisPosition(grid, xAxis, dataZoom, serieDataCount, serieData.index);
pY = GetAxisPosition(grid, yAxis, dataZoom, serieDataCount, data.runtimeValue);
return new Vector3(pX, pY);
case MarkLineType.None:
//return new Vector3(pX, pY);
return serieData.context.position;
case MarkLineType.Custom:
if (data.zeroPosition)
{
data.runtimeValue = 0;

View File

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

View File

@@ -41,7 +41,7 @@ namespace XCharts.Runtime
{
radar.UpdateRadarCenter(chart);
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.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(radarObject.transform, INDICATOR_TEXT);
@@ -50,9 +50,9 @@ namespace XCharts.Runtime
var indicator = radar.indicatorList[i];
var pos = radar.GetIndicatorPosition(i);
var objName = INDICATOR_TEXT + "_" + i;
var content = radar.GetFormatterIndicatorContent(i, radar.indicatorList.Count);
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);
AxisHelper.AdjustCircleLabelPos(label, pos, radar.context.center, txtHig, radar.axisName.labelStyle.offset);
}

View File

@@ -8,7 +8,7 @@ namespace XCharts.Runtime
/// ||标题组件,包含主标题和副标题。
/// </summary>
[Serializable]
[ComponentHandler(typeof(TitleHander), true)]
[ComponentHandler(typeof(TitleHandler), true)]
public class Title : MainComponent, IPropertyChanged
{
[SerializeField] private bool m_Show = true;

View File

@@ -3,7 +3,7 @@ using UnityEngine;
namespace XCharts.Runtime
{
[UnityEngine.Scripting.Preserve]
internal sealed class TitleHander : MainComponentHandler<Title>
public sealed class TitleHandler : MainComponentHandler<Title>
{
private static readonly string s_TitleObjectName = "title";
private static readonly string s_SubTitleObjectName = "title_sub";
@@ -14,50 +14,68 @@ namespace XCharts.Runtime
{
var title = component;
title.painter = null;
title.refreshComponent = delegate()
title.refreshComponent = delegate ()
{
title.OnChanged();
var anchorMin = title.location.runtimeAnchorMin;
var anchorMax = title.location.runtimeAnchorMax;
var pivot = title.location.runtimePivot;
var objName = ChartCached.GetComponentObjectName(title);
var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax,
pivot, chart.chartSizeDelta);
title.gameObject = titleObject;
title.gameObject.transform.SetSiblingIndex(chart.m_PainterUpper.transform.GetSiblingIndex() + 1);
anchorMin = title.location.runtimeAnchorMin;
anchorMax = title.location.runtimeAnchorMax;
pivot = title.location.runtimePivot;
var fontSize = title.labelStyle.textStyle.GetFontSize(chart.theme.title);
ChartHelper.UpdateRectTransform(titleObject, anchorMin, anchorMax, pivot, new Vector2(chart.chartWidth, chart.chartHeight));
var titlePosition = chart.GetTitlePosition(title);
var subTitlePosition = -new Vector3(0, fontSize + title.itemGap, 0);
var titleObject = AddTitleObject(chart, title, chart.theme.title, chart.m_PainterUpper.transform.GetSiblingIndex() + 1);
titleObject.transform.localPosition = titlePosition;
titleObject.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(titleObject);
m_LabelObject = AddTitleLabel(titleObject.transform, title, chart.theme.title, chart);
m_SubLabelObject = AddSubTitleLabel(titleObject.transform, title, chart.theme.subTitle, chart);
m_LabelObject = ChartHelper.AddChartLabel(s_TitleObjectName, titleObject.transform, title.labelStyle, chart.theme.title,
GetTitleText(title), Color.clear, title.location.runtimeTextAlignment);
m_LabelObject.SetActive(title.show && title.labelStyle.show);
m_SubLabelObject = ChartHelper.AddChartLabel(s_SubTitleObjectName, titleObject.transform, title.subLabelStyle, chart.theme.subTitle,
GetSubTitleText(title), Color.clear, title.location.runtimeTextAlignment);
m_SubLabelObject.SetActive(title.show && title.subLabelStyle.show);
m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
};
title.refreshComponent();
}
public static GameObject AddTitleObject(BaseGraph graph, Title title, ComponentTheme componentTheme, int titleSiblingIndex, string objectName = null)
{
var anchorMin = title.location.runtimeAnchorMin;
var anchorMax = title.location.runtimeAnchorMax;
var pivot = title.location.runtimePivot;
var objName = objectName == null ? ChartCached.GetComponentObjectName(title) : objectName;
var titleObject = ChartHelper.AddObject(objName, graph.transform, anchorMin, anchorMax,
pivot, graph.graphSizeDelta, -1, graph.childrenNodeNames);
title.gameObject = titleObject;
title.gameObject.transform.SetSiblingIndex(titleSiblingIndex);
anchorMin = title.location.runtimeAnchorMin;
anchorMax = title.location.runtimeAnchorMax;
pivot = title.location.runtimePivot;
ChartHelper.UpdateRectTransform(titleObject, anchorMin, anchorMax, pivot, new Vector2(graph.graphWidth, graph.graphHeight));
var titlePosition = graph.GetTitlePosition(title);
titleObject.transform.localPosition = titlePosition;
titleObject.hideFlags = graph.chartHideFlags;
ChartHelper.HideAllObject(titleObject);
return titleObject;
}
public static ChartLabel AddTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
{
var m_LabelObject = ChartHelper.AddChartLabel(s_TitleObjectName, parent, title.labelStyle, componentTheme,
GetTitleText(title, chart), Color.clear, title.location.runtimeTextAlignment);
m_LabelObject.SetActive(title.show && title.labelStyle.show, true);
return m_LabelObject;
}
public static ChartLabel AddSubTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
{
var fontSize = title.labelStyle.textStyle.GetFontSize(componentTheme);
var subTitlePosition = -new Vector3(0, fontSize + title.itemGap, 0);
var m_SubLabelObject = ChartHelper.AddChartLabel(s_SubTitleObjectName, parent, title.subLabelStyle, componentTheme,
GetSubTitleText(title, chart), Color.clear, title.location.runtimeTextAlignment);
m_SubLabelObject.SetActive(title.show && title.subLabelStyle.show, true);
m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
return m_SubLabelObject;
}
public override void OnSerieDataUpdate(int serieIndex)
{
if (m_LabelObject != null && FormatterHelper.NeedFormat(component.text))
m_LabelObject.SetText(GetTitleText(component));
m_LabelObject.SetText(GetTitleText(component, chart));
if (m_SubLabelObject != null && FormatterHelper.NeedFormat(component.subText))
m_SubLabelObject.SetText(GetSubTitleText(component));
m_SubLabelObject.SetText(GetSubTitleText(component, chart));
}
private string GetTitleText(Title title)
private static string GetTitleText(Title title, BaseChart chart)
{
if (FormatterHelper.NeedFormat(title.text))
{
@@ -71,7 +89,7 @@ namespace XCharts.Runtime
}
}
private string GetSubTitleText(Title title)
private static string GetSubTitleText(Title title, BaseChart chart)
{
if (FormatterHelper.NeedFormat(title.subText))
{

View File

@@ -145,6 +145,7 @@ namespace XCharts.Runtime
[SerializeField] private float m_TitleHeight = 25f;
[SerializeField] private float m_ItemHeight = 25f;
[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 LabelStyle m_TitleLabelStyle = new LabelStyle()
@@ -453,6 +454,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
}
/// <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.
/// ||标题的文本样式。
/// </summary>
@@ -462,8 +472,8 @@ namespace XCharts.Runtime
set { if (value != null) { m_TitleLabelStyle = value; SetComponentDirty(); } }
}
/// <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>
public List<LabelStyle> contentLabelStyles
{
@@ -549,37 +559,6 @@ namespace XCharts.Runtime
SetContentActive(flag);
}
/// <summary>
/// 更新文本框位置
/// </summary>
/// <param name="pos"></param>
public void UpdateContentPos(Vector2 pos, float width, float height)
{
if (view != null)
{
switch (m_Position)
{
case Position.Auto:
#if UNITY_ANDROID || UNITY_IOS
if (m_FixedY == 0) pos.y = ChartHelper.GetActualValue(0.7f, height);
else pos.y = ChartHelper.GetActualValue(m_FixedY, height);
#endif
break;
case Position.Custom:
pos.x = ChartHelper.GetActualValue(m_FixedX, width);
pos.y = ChartHelper.GetActualValue(m_FixedY, height);
break;
case Position.FixedX:
pos.x = ChartHelper.GetActualValue(m_FixedX, width);
break;
case Position.FixedY:
pos.y = ChartHelper.GetActualValue(m_FixedY, height);
break;
}
view.UpdatePosition(pos);
}
}
/// <summary>
/// 设置文本框是否显示
/// </summary>

View File

@@ -11,6 +11,8 @@ namespace XCharts.Runtime
internal sealed class TooltipHandler : MainComponentHandler<Tooltip>
{
private Dictionary<string, ChartLabel> m_IndicatorLabels = new Dictionary<string, ChartLabel>();
private Dictionary<Serie, Dictionary<int, List<SerieData>>> m_SortedAxisDataCache =
new Dictionary<Serie, Dictionary<int, List<SerieData>>>();
private GameObject m_LabelRoot;
private ISerieContainer m_PointerContainer;
@@ -53,7 +55,7 @@ namespace XCharts.Runtime
{
var objName = ChartCached.GetComponentObjectName(tooltip);
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;
tooltipObject.transform.localPosition = Vector3.zero;
tooltipObject.hideFlags = chart.chartHideFlags;
@@ -255,6 +257,11 @@ namespace XCharts.Runtime
{
if (label == null) return;
if (double.IsNaN(axis.context.pointerValue)) return;
if (!axis.show || !axis.indicatorLabel.show)
{
label.SetActive(false, false);
return;
}
label.SetActive(true, true);
label.SetTextActive(true);
label.SetPosition(axis.context.pointerLabelPosition + axis.indicatorLabel.offset);
@@ -264,15 +271,15 @@ namespace XCharts.Runtime
var index = (int)axis.context.pointerValue;
var dataZoom = chart.GetDataZoomOfAxis(axis);
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())
{
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, !chart.useUtc));
}
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);
if (ChartHelper.IsClearColor(axis.indicatorLabel.background.color))
@@ -356,6 +363,7 @@ namespace XCharts.Runtime
if (isTriggerAxis)
{
var index = serie.context.dataZoomStartIndex + (int)yAxis.context.pointerValue;
if (serie.useSortData) index = yAxis.context.sortedDataIndices[index];
serie.context.pointerEnter = true;
serie.context.pointerAxisDataIndexs.Add(index);
serie.context.pointerItemDataIndex = index;
@@ -375,6 +383,7 @@ namespace XCharts.Runtime
if (isTriggerAxis)
{
var index = serie.context.dataZoomStartIndex + (int)xAxis.context.pointerValue;
if (serie.useSortData) index = xAxis.context.sortedDataIndices[index];
if (chart.isTriggerOnClick)
{
if (serie.insertDataToHead)
@@ -418,8 +427,10 @@ namespace XCharts.Runtime
private void GetSerieDataByXYAxis(Serie serie, Axis xAxis, Axis yAxis)
{
var xAxisIndex = AxisHelper.GetAxisValueSplitIndex(xAxis, xAxis.context.pointerValue, false);
var yAxisIndex = AxisHelper.GetAxisValueSplitIndex(yAxis, yAxis.context.pointerValue, false);
var xPointerInternal = xAxis.inverse ? -xAxis.context.pointerValue : xAxis.context.pointerValue;
var yPointerInternal = yAxis.inverse ? -yAxis.context.pointerValue : yAxis.context.pointerValue;
var xAxisIndex = AxisHelper.GetAxisValueSplitIndex(xAxis, xPointerInternal, false);
var yAxisIndex = AxisHelper.GetAxisValueSplitIndex(yAxis, yPointerInternal, false);
serie.context.pointerItemDataIndex = -1;
if (serie is Heatmap)
{
@@ -432,8 +443,10 @@ namespace XCharts.Runtime
}
foreach (var serieData in serie.data)
{
var x = AxisHelper.GetAxisValueSplitIndex(xAxis, serieData.GetData(0), true);
var y = AxisHelper.GetAxisValueSplitIndex(yAxis, serieData.GetData(1), true);
var xData = xAxis.inverse ? -serieData.GetData(0) : serieData.GetData(0);
var yData = yAxis.inverse ? -serieData.GetData(1) : serieData.GetData(1);
var x = AxisHelper.GetAxisValueSplitIndex(xAxis, xData, true);
var y = AxisHelper.GetAxisValueSplitIndex(yAxis, yData, true);
if (xAxisIndex == x && y == yAxisIndex)
{
serie.context.pointerItemDataIndex = serieData.index;
@@ -444,40 +457,140 @@ namespace XCharts.Runtime
private void GetSerieDataIndexByAxis(Serie serie, Axis axis, GridCoord grid, int dimension = 0)
{
var currValue = 0d;
var lastValue = 0d;
var nextValue = 0d;
var axisValue = axis.context.pointerValue;
var isTimeAxis = axis.IsTime();
var dataCount = serie.dataCount;
var themeSymbolSize = chart.theme.serie.scatterSymbolSize;
var data = serie.data;
if (!isTimeAxis)
serie.context.pointerAxisDataIndexs.Clear();
if (axis.IsTime())
{
serie.context.sortedData.Clear();
for (int i = 0; i < dataCount; i++)
FindSerieDataIndexByAxisLinear(serie, axis, axisValue, dimension);
}
else
{
var sortedData = GetSortedAxisData(serie, dimension);
var nearestIndex = GetNearestSerieDataIndex(sortedData, axisValue, dimension, axis.context.tickValue);
if (nearestIndex >= 0)
serie.context.pointerAxisDataIndexs.Add(nearestIndex);
}
if (serie.context.pointerAxisDataIndexs.Count > 0)
{
var index = serie.context.pointerAxisDataIndexs[0];
serie.context.pointerItemDataIndex = index;
var dataValue = serie.GetSerieData(index).GetData(dimension);
axis.context.axisTooltipValue = axis.inverse ? -dataValue : dataValue;
}
else
{
serie.context.pointerItemDataIndex = -1;
axis.context.axisTooltipValue = 0;
}
}
private List<SerieData> GetSortedAxisData(Serie serie, int dimension)
{
Dictionary<int, List<SerieData>> dimensionCache;
if (!m_SortedAxisDataCache.TryGetValue(serie, out dimensionCache))
{
dimensionCache = new Dictionary<int, List<SerieData>>();
m_SortedAxisDataCache[serie] = dimensionCache;
}
List<SerieData> sortedData;
if (!dimensionCache.TryGetValue(dimension, out sortedData))
{
sortedData = new List<SerieData>();
dimensionCache[dimension] = sortedData;
}
if (serie.dataDirty || sortedData.Count != serie.dataCount)
{
sortedData.Clear();
for (int i = 0; i < serie.dataCount; i++)
{
var serieData = serie.data[i];
serie.context.sortedData.Add(serieData);
sortedData.Add(serie.data[i]);
}
serie.context.sortedData.Sort(delegate (SerieData a, SerieData b)
sortedData.Sort(delegate (SerieData a, SerieData b)
{
return a.GetData(dimension).CompareTo(b.GetData(dimension));
});
data = serie.context.sortedData;
}
serie.context.pointerAxisDataIndexs.Clear();
return sortedData;
}
private int GetNearestSerieDataIndex(List<SerieData> sortedData, double axisValue, int dimension, double tickValue)
{
var dataCount = sortedData.Count;
if (dataCount <= 0) return -1;
if (dataCount == 1)
{
var currValue = sortedData[0].GetData(dimension);
var diff = tickValue * 0.5f;
return axisValue >= currValue - diff && axisValue <= currValue + diff
? sortedData[0].index
: -1;
}
var firstValue = sortedData[0].GetData(dimension);
var secondValue = sortedData[1].GetData(dimension);
if (axisValue <= firstValue + (secondValue - firstValue) / 2)
return sortedData[0].index;
var lastValue = sortedData[dataCount - 1].GetData(dimension);
var beforeLastValue = sortedData[dataCount - 2].GetData(dimension);
if (axisValue > beforeLastValue + (lastValue - beforeLastValue) / 2)
return sortedData[dataCount - 1].index;
var low = 1;
var high = dataCount - 2;
while (low <= high)
{
var mid = (low + high) / 2;
var prevValue = sortedData[mid - 1].GetData(dimension);
var currValue = sortedData[mid].GetData(dimension);
var nextValue = sortedData[mid + 1].GetData(dimension);
var leftBound = currValue - (currValue - prevValue) / 2;
var rightBound = currValue + (nextValue - currValue) / 2;
if (axisValue > leftBound && axisValue <= rightBound)
return sortedData[mid].index;
if (axisValue <= leftBound)
high = mid - 1;
else
low = mid + 1;
}
return -1;
}
private void FindSerieDataIndexByAxisLinear(Serie serie, Axis axis, double axisValue, int dimension)
{
var currValue = 0d;
var lastValue = 0d;
var nextValue = 0d;
var dataCount = serie.dataCount;
var data = serie.data;
for (int i = 0; i < dataCount; i++)
{
var serieData = data[i];
currValue = serieData.GetData(dimension);
if (i == 0 && i + 1 < dataCount)
if (i == 0)
{
nextValue = data[i + 1].GetData(dimension);
if (axisValue <= currValue + (nextValue - currValue) / 2)
if (i + 1 < dataCount)
{
serie.context.pointerAxisDataIndexs.Add(serieData.index);
break;
nextValue = data[i + 1].GetData(dimension);
if (axisValue <= currValue + (nextValue - currValue) / 2)
{
serie.context.pointerAxisDataIndexs.Add(serieData.index);
break;
}
}
else
{
var diff = axis.context.tickValue * 0.5f;
if (axisValue >= currValue - diff && axisValue <= currValue + diff)
{
serie.context.pointerAxisDataIndexs.Add(serieData.index);
break;
}
}
}
else if (i == dataCount - 1)
@@ -499,28 +612,18 @@ namespace XCharts.Runtime
}
lastValue = currValue;
}
if (serie.context.pointerAxisDataIndexs.Count > 0)
{
var index = serie.context.pointerAxisDataIndexs[0];
serie.context.pointerItemDataIndex = index;
axis.context.axisTooltipValue = serie.GetSerieData(index).GetData(dimension);
}
else
{
serie.context.pointerItemDataIndex = -1;
axis.context.axisTooltipValue = 0;
}
}
private void GetSerieDataIndexByItem(Serie serie, Axis axis, GridCoord grid, int dimension = 0)
{
if (serie.context.pointerItemDataIndex >= 0)
{
axis.context.axisTooltipValue = serie.GetSerieData(serie.context.pointerItemDataIndex).GetData(dimension);
var dataValue = serie.GetSerieData(serie.context.pointerItemDataIndex).GetData(dimension);
axis.context.axisTooltipValue = axis.inverse ? -dataValue : dataValue;
}
else if (component.type == Tooltip.Type.Cross)
{
axis.context.axisTooltipValue = axis.context.pointerValue;
axis.context.axisTooltipValue = axis.inverse ? -axis.context.pointerValue : axis.context.pointerValue;
}
else
{
@@ -546,7 +649,7 @@ namespace XCharts.Runtime
tooltip.SetActive(m_ShowTooltip);
tooltip.view.Refresh();
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
TooltipHelper.LimitInRect(chart, tooltip, chart.chartRect);
return true;
}
@@ -614,7 +717,21 @@ namespace XCharts.Runtime
var serieData = serie.GetSerieData(serie.context.pointerItemDataIndex);
if (serieData != null)
{
tooltip.context.data.title = DateTimeUtil.GetDefaultDateTimeString((int)serieData.GetData(0), axisRange);
var value = (int)serieData.GetData(0);
if (string.IsNullOrEmpty(tooltip.titleLabelStyle.numericFormatter))
tooltip.context.data.title = DateTimeUtil.GetDefaultDateTimeString(value, axisRange, !chart.useUtc);
else
{
var dateTime = DateTimeUtil.GetDateTime(value, !chart.useUtc);
try
{
tooltip.context.data.title = dateTime.ToString(tooltip.titleLabelStyle.numericFormatter);
}
catch
{
tooltip.context.data.title = DateTimeUtil.GetDefaultDateTimeString(value, axisRange, !chart.useUtc);
}
}
}
}
serie.handler.UpdateTooltipSerieParams(dataIndex, showCategory, category,
@@ -633,7 +750,7 @@ namespace XCharts.Runtime
tooltip.SetActive(m_ShowTooltip);
if (tooltip.view != null)
tooltip.view.Refresh();
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
TooltipHelper.LimitInRect(chart, tooltip, chart.chartRect);
return true;
}
return false;
@@ -704,6 +821,7 @@ namespace XCharts.Runtime
private void DrawXAxisIndicator(VertexHelper vh, Tooltip tooltip, GridCoord grid)
{
if (!tooltip.lineStyle.show) return;
var xAxes = chart.GetChartComponents<XAxis>();
var lineType = tooltip.lineStyle.GetType(chart.theme.tooltip.lineType);
var lineWidth = tooltip.lineStyle.GetWidth(chart.theme.tooltip.lineWidth);

View File

@@ -16,8 +16,9 @@ namespace XCharts.Runtime
else
{
tooltip.context.data.title = tooltip.titleFormatter;
FormatterHelper.ReplaceContent(ref tooltip.context.data.title, -1,
tooltip.numericFormatter, null, chart);
var numericFormatter = string.IsNullOrEmpty(tooltip.titleLabelStyle.numericFormatter)
? tooltip.numericFormatter : tooltip.titleLabelStyle.numericFormatter;
FormatterHelper.ReplaceContent(ref tooltip.context.data.title, -1, numericFormatter, null, chart);
}
}
for (int i = tooltip.context.data.param.Count - 1; i >= 0; i--)
@@ -44,7 +45,8 @@ namespace XCharts.Runtime
param.serieData.name,
param.color,
param.serieData,
chart);
chart,
param.serieIndex);
foreach (var item in content.Split('|'))
{
param.columns.Add(item);
@@ -55,10 +57,10 @@ namespace XCharts.Runtime
public static bool IsIgnoreFormatter(string itemFormatter)
{
return "-".Equals(itemFormatter) ||"{i}".Equals(itemFormatter, StringComparison.CurrentCultureIgnoreCase);
return "-".Equals(itemFormatter) || "{i}".Equals(itemFormatter, StringComparison.CurrentCultureIgnoreCase);
}
public static void LimitInRect(Tooltip tooltip, Rect chartRect)
public static void LimitInRect(BaseChart chart, Tooltip tooltip, Rect chartRect)
{
if (tooltip.view == null)
return;
@@ -78,7 +80,55 @@ namespace XCharts.Runtime
}
if (pos.y > chartRect.y + chartRect.height)
pos.y = chartRect.y + chartRect.height;
tooltip.UpdateContentPos(pos, chartRect.width / 2, chartRect.height / 2);
var screenGap = 10;
var screenPos = chart.LocalPointToScreenPoint(pos);
if (screenPos.x < screenGap)
pos.x += Mathf.Abs(screenPos.x) + screenGap;
if (screenPos.x + tooltip.context.width > Screen.width - screenGap)
pos.x -= Mathf.Abs(screenPos.x + tooltip.context.width - Screen.width) + screenGap;
if (screenPos.y < tooltip.context.height + screenGap)
pos.y += Mathf.Abs(screenPos.y - tooltip.context.height) + screenGap;
if (screenPos.y > Screen.height - screenGap)
pos.y -= Mathf.Abs(screenPos.y - Screen.height) + screenGap;
UpdateContentPos(tooltip, pos, chartRect);
}
/// <summary>
/// 更新文本框位置
/// </summary>
/// <param name="pos"></param>
private static void UpdateContentPos(Tooltip tooltip, Vector2 pos, Rect chartRect)
{
if (tooltip.view != null)
{
var width = chartRect.width;
var height = chartRect.height;
switch (tooltip.position)
{
case Tooltip.Position.Auto:
#if UNITY_ANDROID || UNITY_IOS
if (tooltip.fixedY == 0) pos.y = chartRect.x + ChartHelper.GetActualValue(0.7f, height);
else pos.y = chartRect.y + ChartHelper.GetActualValue(tooltip.fixedY, height);
#endif
break;
case Tooltip.Position.Custom:
pos = new Vector2(chartRect.x, chartRect.y);
pos.x += ChartHelper.GetActualValue(tooltip.fixedX, width);
pos.y += ChartHelper.GetActualValue(tooltip.fixedY, height);
break;
case Tooltip.Position.FixedX:
pos = new Vector2(chartRect.x, pos.y);
pos.x += ChartHelper.GetActualValue(tooltip.fixedX, width);
break;
case Tooltip.Position.FixedY:
pos = new Vector2(pos.x, chartRect.y);
pos.y += ChartHelper.GetActualValue(tooltip.fixedY, height);
break;
}
tooltip.view.UpdatePosition(pos);
}
}
public static string GetItemNumericFormatter(Tooltip tooltip, Serie serie, SerieData serieData)

View File

@@ -60,6 +60,7 @@ namespace XCharts.Runtime
ChartHelper.SetActive(gameObject, m_Active);
if (!flag)
{
m_ColumnMaxWidth.Clear();
foreach (var item in m_Items)
item.gameObject.SetActive(false);
}
@@ -75,8 +76,6 @@ namespace XCharts.Runtime
ChartHelper.SetActive(title, titleActive);
title.SetText(data.title);
m_ColumnMaxWidth.Clear();
var contentLabelStyle0 = tooltip.GetContentLabelStyle(0);
for (int i = 0; i < data.param.Count; i++)
{
var item = GetItem(i);
@@ -89,17 +88,21 @@ namespace XCharts.Runtime
item.gameObject.SetActive(true);
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.SetText(param.columns[j]);
if (j == 0 && contentLabelStyle0 != null && ChartHelper.IsClearColor(contentLabelStyle0.textStyle.color))
column.text.SetColor(param.color);
if (j == 0)
{
var labelStyle = tooltip.GetContentLabelStyle(j);
if (labelStyle != null && ChartHelper.IsClearColor(labelStyle.textStyle.color))
column.text.SetColor(param.color);
}
if (j >= m_ColumnMaxWidth.Count)
m_ColumnMaxWidth.Add(0);
var columnWidth = column.GetWidth();
var columnWidth = column.text.GetPreferredWidth() + GetTooltipColumnGapWidth(tooltip, j);
if (m_ColumnMaxWidth[j] < columnWidth)
m_ColumnMaxWidth[j] = columnWidth;
}
@@ -117,6 +120,22 @@ namespace XCharts.Runtime
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()
{
var maxHig = 0f;
@@ -158,8 +177,10 @@ namespace XCharts.Runtime
var xPos = 0f;
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];
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));
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;
ChartLabel column;
if (i < item.columns.Count)
{
return item.columns[i];
column = item.columns[i];
}
else
{
var column = CreateViewItemColumn(i, item.gameObject.transform, tooltip, theme);
column = CreateViewItemColumn(i, item.gameObject.transform, tooltip, theme);
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)
@@ -234,6 +260,7 @@ namespace XCharts.Runtime
view.layout.childControlWidth = false;
view.layout.childForceExpandHeight = false;
view.layout.childForceExpandWidth = false;
view.layout.childAlignment = tooltip.titleLabelStyle.textStyle.alignment;
view.layout.padding = new RectOffset(tooltip.paddingLeftRight,
tooltip.paddingLeftRight,
tooltip.paddingTopBottom,
@@ -266,8 +293,9 @@ namespace XCharts.Runtime
private static ChartLabel CreateViewItemColumn(int i, Transform parent, Tooltip tooltip, ComponentTheme theme)
{
var labelStyle = tooltip.GetContentLabelStyle(i);
labelStyle.textStyle.autoAlign = false;
var label = ChartHelper.AddChartLabel("column" + i, parent, labelStyle, theme,
"", Color.clear, TextAnchor.MiddleLeft);
"", Color.clear, TextAnchor.MiddleLeft, true);
return label;
}
}

View File

@@ -12,7 +12,7 @@ namespace XCharts.Runtime
{
var grid = component;
grid.painter = chart.painter;
grid.refreshComponent = delegate()
grid.refreshComponent = delegate ()
{
grid.UpdateRuntimeData(chart);
chart.OnCoordinateChanged();
@@ -51,6 +51,7 @@ namespace XCharts.Runtime
public override void DrawBase(VertexHelper vh)
{
DrawBackground(vh, component);
if (!SeriesHelper.IsAnyClipSerie(chart.series))
{
DrawCoord(vh, component);
@@ -64,7 +65,7 @@ namespace XCharts.Runtime
}
}
private void DrawCoord(VertexHelper vh, GridCoord grid)
private void DrawBackground(VertexHelper vh, GridCoord grid)
{
if (!grid.show) return;
if (!ChartHelper.IsClearColor(grid.backgroundColor))
@@ -75,6 +76,11 @@ namespace XCharts.Runtime
var p4 = new Vector2(grid.context.x + grid.context.width, grid.context.y);
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, grid.backgroundColor);
}
}
private void DrawCoord(VertexHelper vh, GridCoord grid)
{
if (!grid.show) return;
if (grid.showBorder)
{
var borderWidth = grid.borderWidth == 0 ? chart.theme.axis.lineWidth * 2 : grid.borderWidth;

View File

@@ -18,12 +18,20 @@ namespace XCharts.Runtime
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_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)
{
return !string.IsNullOrEmpty(content) && content.IndexOf('{') >= 0;
}
public static bool NeedTotalContent(string content)
{
if (string.IsNullOrEmpty(content)) return false;
return content.IndexOf("{d", System.StringComparison.OrdinalIgnoreCase) >= 0 ||
content.IndexOf("{f", System.StringComparison.OrdinalIgnoreCase) >= 0;
}
/// <summary>
/// 替换字符串中的通配符,支持的通配符有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}、{h}、{y}。
/// </summary>
@@ -36,7 +44,7 @@ namespace XCharts.Runtime
/// <param name="category">选中的类目,一般用在折线图和柱状图</param>
/// <returns></returns>
public static bool ReplaceContent(ref string content, int dataIndex, string numericFormatter, Serie serie,
BaseChart chart, string colorName = null)
BaseChart chart, string colorName = null, SerieData serieData = null)
{
var foundDot = false;
var mc = s_Regex.Matches(content);
@@ -111,7 +119,7 @@ namespace XCharts.Runtime
}
else
{
var serieData = serie.GetSerieData(bIndex);
serieData = serie.GetSerieData(bIndex);
content = content.Replace(old, serieData.name);
}
}
@@ -149,7 +157,7 @@ namespace XCharts.Runtime
else if (p == 'c' || p == 'C' || p == 'd' || p == 'D' || p == 'f' || p == 'f')
{
var isPercent = p == 'd' || p == 'D';
var isTotal = p == 'f' || p == 'f';
var isTotal = p == 'f' || p == 'F';
var bIndex = dataIndex;
var dimensionIndex = -1;
if (argsCount >= 2)
@@ -206,12 +214,17 @@ namespace XCharts.Runtime
}
}
}
if (serieData != null)
{
ReplaceIndexContent(ref content, serie.useSortData ? serieData.sortIndex : serieData.index, serie.dataCount);
}
content = s_RegexNewLine.Replace(content, PH_NN);
return foundDot;
}
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,
bool sortData = false)
{
var mc = s_RegexForSerieLabel.Matches(content);
foreach (var m in mc)
@@ -270,6 +283,14 @@ namespace XCharts.Runtime
}
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));
}
else if (p == 'g' || p == 'G')
@@ -300,6 +321,10 @@ namespace XCharts.Runtime
}
}
}
if (serieData != null)
{
ReplaceIndexContent(ref content, sortData ? serieData.sortIndex : serieData.index, dataCount);
}
content = TrimAndReplaceLine(content);
}
@@ -326,7 +351,7 @@ namespace XCharts.Runtime
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);
foreach (var m in mc)
@@ -341,10 +366,11 @@ namespace XCharts.Runtime
}
content = content.Replace(old, ChartCached.FloatToStr(value, numericFormatter));
}
ReplaceIndexContent(ref content, index, totalIndex);
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);
foreach (var m in mc)
@@ -355,8 +381,26 @@ namespace XCharts.Runtime
if (argsCount <= 0) continue;
content = content.Replace(old, value);
}
ReplaceIndexContent(ref content, index, totalIndex);
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

@@ -31,6 +31,11 @@ namespace XCharts.Runtime
}
}
/// <summary>
/// Whether to use UTC time for the chart.
/// ||图表的时间是否都显示为UTC时间。
/// </summary>
public bool useUtc { get { return m_UseUtc; } set { m_UseUtc = value; } }
/// <summary>
/// The theme.
/// ||</summary>
public ThemeStyle theme { get { return m_Theme; } set { m_Theme = value; } }
@@ -69,6 +74,7 @@ namespace XCharts.Runtime
/// </summary>
public Vector3 chartPosition { get { return m_ChartPosition; } }
public Rect chartRect { get { return m_ChartRect; } }
public Painter topPainter { get { return m_PainterTop; } }
/// <summary>
/// The callback function of chart init.
/// ||图表的初始化完成回调。
@@ -587,11 +593,6 @@ namespace XCharts.Runtime
}
}
public Vector3 GetTitlePosition(Title title)
{
return chartPosition + title.location.GetPosition(chartWidth, chartHeight);
}
public int GetLegendRealShowNameIndex(string name)
{
return m_LegendRealShowName.IndexOf(name);
@@ -656,10 +657,12 @@ namespace XCharts.Runtime
}
}
private Background m_Background;
public Color32 GetChartBackgroundColor()
{
var background = GetChartComponent<Background>();
return theme.GetBackgroundColor(background);
if (m_Background == null) m_Background = GetChartComponent<Background>();
//var background = GetChartComponent<Background>();
return theme.GetBackgroundColor(m_Background);
}
/// <summary>
@@ -775,5 +778,27 @@ namespace XCharts.Runtime
foreach (var component in m_Components) component.ResetStatus();
foreach (var handler in m_SerieHandlers) handler.ForceUpdateSerieContext();
}
/// <summary>
/// Export chart configuration and data to JSON string.
/// ||导出图表配置和数据为JSON字符串。
/// </summary>
[Since("v3.16.0")]
public string ExportToJson(bool prettyPrint = true)
{
return XCharts.Runtime.ChartJsonSerializer.Serialize(this, prettyPrint);
}
/// <summary>
/// Import JSON and update current chart configuration.
/// ||导入JSON并更新当前图表配置。
/// </summary>
[Since("v3.16.0")]
public void ImportFromJson(string json)
{
XCharts.Runtime.ChartJsonDeserializer.Deserialize(json, this);
RefreshAllComponent();
RefreshChart();
}
}
}

View File

@@ -52,6 +52,7 @@ namespace XCharts.Runtime
public MainComponent AddChartComponent(Type type)
{
InitListForFieldInfos();
if (!CanAddChartComponent(type))
{
Debug.LogError("XCharts ERROR: CanAddChartComponent:" + type.Name);
@@ -428,6 +429,19 @@ namespace XCharts.Runtime
return true;
}
public Axis GetMainAxis()
{
foreach (var component in m_Components)
{
if (component is Axis)
{
var axis = component as Axis;
if (axis.show && axis.mainAxis) return axis;
}
}
return null;
}
/// <summary>
/// 纯类目轴。
/// </summary>
@@ -482,7 +496,15 @@ namespace XCharts.Runtime
relativedAxis = null;
return false;
}
var isY = yAxis.IsCategory() && !xAxis.IsCategory();
bool isY;
if (xAxis.type == yAxis.type)
{
isY = yAxis.mainAxis;
}
else
{
isY = yAxis.IsCategory() && !xAxis.IsCategory();
}
if (isY)
{
axis = yAxis;

View File

@@ -11,32 +11,60 @@ namespace XCharts.Runtime
public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double tempMinValue, out double tempMaxValue)
{
var needAnimationData = !axis.context.needAnimation;
bool isX = false, isY = false, isZ = false;
tempMinValue = 0;
tempMaxValue = 0;
if (axis is XAxis3D)
{
SeriesHelper.GetXMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
}
isX = true;
else if (axis is ZAxis3D)
{
SeriesHelper.GetZMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
isZ = true;
}
else if (axis is YAxis3D)
{
SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
isY = true;
}
else if (IsAllAxisValue())
{
if (axis is XAxis)
var mainAxis = GetMainAxis();
if (mainAxis == null)
{
SeriesHelper.GetXMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
if (axis is XAxis)
{
isX = true;
}
else
{
isY = true;
}
}
else
{
SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
if (axis == mainAxis)
{
isX = true;
}
else
{
isY = true;
}
}
}
else
{
SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
isY = true;
}
if (isX)
{
SeriesHelper.GetXMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, needAnimationData);
}
else if (isY)
{
SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, needAnimationData);
}
else if(isZ)
{
SeriesHelper.GetZMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, needAnimationData);
}
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
}

View File

@@ -54,8 +54,8 @@ namespace XCharts.Runtime
p4 = ClampInGrid(grid, p4);
}
if (!clip ||
(clip && (grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) &&
grid.Contains(p4))))
(clip && grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) &&
grid.Contains(p4)))
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,
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 (!clip || (clip && (grid.Contains(pos))))
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,
@@ -101,22 +101,22 @@ namespace XCharts.Runtime
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
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,
gap, cornerRadius, Vector3.zero);
gap, cornerRadius, Vector3.zero, symbolSize2);
}
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
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();
if (ChartHelper.IsClearColor(emptyColor))
emptyColor = backgroundColor;
var smoothness = settings.cicleSmoothness;
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)

View File

@@ -101,6 +101,28 @@ namespace XCharts.Runtime
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
{
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;
for (int i = 0; i < m_Series.Count; i++)
@@ -839,6 +861,7 @@ namespace XCharts.Runtime
var serie = m_Series[i];
if (serie.show && serie is T)
{
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (serie.barGap != 0)
{
gap = serie.barGap;
@@ -848,7 +871,7 @@ namespace XCharts.Runtime
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;
double total = 0;
@@ -856,6 +879,7 @@ namespace XCharts.Runtime
{
if (serie is T)
{
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (stack.Equals(serie.stack))
{
total += serie.data[dataIndex].data[1];
@@ -865,7 +889,7 @@ namespace XCharts.Runtime
return total;
}
public int GetSerieBarRealCount<T>() where T : Serie
public int GetSerieBarRealCount<T>(int gridIndex) where T : Serie
{
var count = 0;
barStackSet.Clear();
@@ -875,6 +899,7 @@ namespace XCharts.Runtime
if (!serie.show) continue;
if (serie is T)
{
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (!string.IsNullOrEmpty(serie.stack))
{
if (barStackSet.Contains(serie.stack)) continue;
@@ -887,8 +912,26 @@ namespace XCharts.Runtime
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>();
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 lastGap = 0;
@@ -899,6 +942,7 @@ namespace XCharts.Runtime
if (!serie.show) continue;
if (serie is T)
{
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (!string.IsNullOrEmpty(serie.stack))
{
if (barStackSet.Contains(serie.stack)) continue;
@@ -921,12 +965,12 @@ namespace XCharts.Runtime
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;
var total = 0f;
var count = 0;
var totalRealBarCount = GetSerieBarRealCount<T>();
var totalRealBarCount = GetSerieBarRealCount<T>(gridIndex);
barStackSet.Clear();
for (int i = 0; i < m_Series.Count; i++)
{
@@ -934,6 +978,7 @@ namespace XCharts.Runtime
if (!serie.show) continue;
if (serie is T)
{
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (!string.IsNullOrEmpty(serie.stack))
{
if (barStackSet.Contains(serie.stack)) continue;
@@ -983,7 +1028,7 @@ namespace XCharts.Runtime
}
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();
int index = 0;
@@ -992,6 +1037,7 @@ namespace XCharts.Runtime
var serie = m_Series[i];
if (!serie.show) continue;
if (!(serie is T)) continue;
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
if (string.IsNullOrEmpty(serie.stack))
{
if (serie.index == currSerie.index) return index;

View File

@@ -16,6 +16,7 @@ namespace XCharts.Runtime
public partial class BaseChart : BaseGraph, ISerializationCallbackReceiver
{
[SerializeField] protected string m_ChartName;
[SerializeField] protected bool m_UseUtc = true;
[SerializeField] protected ThemeStyle m_Theme = new ThemeStyle();
[SerializeField] protected Settings m_Settings;
[SerializeField] protected DebugInfo m_DebugInfo = new DebugInfo();
@@ -204,7 +205,7 @@ namespace XCharts.Runtime
protected override void OnValidate()
{
base.OnValidate();
foreach (var handler in m_SerieHandlers) handler.ForceUpdateSerieContext();
ResetChartStatus();
}
#endif
@@ -377,7 +378,7 @@ namespace XCharts.Runtime
serie.index = i;
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);
}
@@ -394,7 +395,7 @@ namespace XCharts.Runtime
{
var index = settings.reversePainter ? settings.maxPainter - 1 - i : i;
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.type = Painter.Type.Serie;
painter.onPopulateMesh = OnDrawPainterSerie;
@@ -404,7 +405,7 @@ namespace XCharts.Runtime
m_PainterList.Add(painter);
}
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.onPopulateMesh = OnDrawPainterUpper;
m_PainterUpper.SetActive(true, m_DebugInfo.showAllChartObject);
@@ -412,7 +413,7 @@ namespace XCharts.Runtime
m_PainterUpper.transform.SetSiblingIndex(settings.maxPainter + 1);
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.onPopulateMesh = OnDrawPainterTop;
m_PainterTop.SetActive(true, m_DebugInfo.showAllChartObject);
@@ -626,6 +627,8 @@ namespace XCharts.Runtime
vh.Clear();
var maxPainter = settings.maxPainter;
var maxSeries = m_Series.Count;
if (painter == null || painter.index < 0 || painter.index >= maxPainter)
return;
var rate = Mathf.CeilToInt(maxSeries * 1.0f / maxPainter);
m_PainterUpper.Refresh();
m_PainterTop.Refresh();
@@ -724,7 +727,7 @@ namespace XCharts.Runtime
private void InitListForFieldInfos()
{
if (m_TypeListForSerie.Count != 0) return;
if (m_TypeListForSerie.Count != 0 || m_TypeListForComponent.Count != 0) return;
m_TypeListForComponent.Clear();
m_TypeListForSerie.Clear();
var fileds1 = GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

View File

@@ -158,8 +158,8 @@ namespace XCharts.Runtime
/// </summary>
public void RebuildChartObject()
{
ChartHelper.DestroyAllChildren(transform);
SetAllComponentDirty();
ChartHelper.DestoryGameObjectByMatch(transform, m_ChildNodeNames);
//SetAllComponentDirty();
}
public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint)
@@ -209,15 +209,25 @@ namespace XCharts.Runtime
/// </summary>
/// <param name="imageType">type of image: png, jpg, exr</param>
/// <param name="savePath">save path</param>
public void SaveAsImage(string imageType = "png", string savePath = "")
/// <param name="exportScale">export resolution scale. 1 means original size</param>
/// <param name="useRecursiveBackgroundColor">whether to recursively use lower-level UI background color</param>
public void SaveAsImage(string imageType = "png", string savePath = "", float exportScale = 1f,
bool useRecursiveBackgroundColor = false)
{
StartCoroutine(SaveAsImageSync(imageType, savePath));
StartCoroutine(SaveAsImageSync(imageType, savePath, exportScale, useRecursiveBackgroundColor));
}
private IEnumerator SaveAsImageSync(string imageType, string path)
private IEnumerator SaveAsImageSync(string imageType, string path, float exportScale,
bool useRecursiveBackgroundColor)
{
yield return new WaitForEndOfFrame();
ChartHelper.SaveAsImage(rectTransform, canvas, imageType, path);
ChartHelper.SaveAsImage(rectTransform, canvas, imageType, path, exportScale,
useRecursiveBackgroundColor);
}
public Vector3 GetTitlePosition(Title title)
{
return graphPosition + title.location.GetPosition(graphWidth, graphHeight);
}
}
}

View File

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

Some files were not shown because too many files have changed in this diff Show More