Merge branch 'master' into 3.0

This commit is contained in:
monitor1394
2022-11-01 07:54:45 +08:00
58 changed files with 3605 additions and 3257 deletions

View File

@@ -2,6 +2,7 @@
# 更新日志
[master](#master)
[v3.4.0](#v3.4.0)
[v3.3.0](#v3.3.0)
[v3.2.0](#v3.2.0)
[v3.1.0](#v3.1.0)
@@ -59,6 +60,37 @@
## master
## v3.4.0
### 版本要点
* 增加`Axis``indicatorLabel`,可单独设置不同的指示文本样式
* 增加`Serie``markColor`可设置标识颜色
* 增加`RadarCoord``startAngle`可设置`Radar`起始角度
* 优化`Axis`的数值间隔表现
* 增加`DataZoom`对数值轴的支持
* 增加`Line``SmoothLimit`可控制平滑曲线不同效果
### 日志详情
* (2022.11.01) 发布`v3.4.0`版本
* (2022.10.30) 增加`API``AddData()``ClearSerieData()``ClearComponentData()`
* (2022.10.30) 增加`Axis``indicatorLabel`,移除`Tooltip``indicatorLabelStyle` (#226)
* (2022.10.29) 增加`Serie``markColor`可设置标识颜色用于`Legend``Tooltip`的展示 (#229)
* (2022.10.26) 增加`RadarCoord``startAngle`可设置`Radar`起始角度
* (2022.10.21) 修复`Chart`在受`Layout`控制时`Label`显示不正常的问题 (#231)
* (2022.10.21) 修复`Unity2019.2`上的兼容问题
* (2022.10.18) 优化`Axis`的数值表现
* (2022.10.15) 修复`Axis``Label``DataZoom`开启时可能显示不正常的问题 (#227)
* (2022.10.14) 增加`DataZoom`对数值轴的支持
* (2022.10.13) 修复`Pie`的环形饼图设置边框时效果异常的问题 (#225)
* (2022.10.13) 修复`Download`的接口造成`iOS`平台打包失败的问题
* (2022.10.12) 增加`Animation``UnscaledTime`支持设置动画是否受TimeScale的影响 (#223)
* (2022.10.10) 优化`Documentation`文档格式
* (2022.10.10) 增加`Line``SmoothLimit`可控制平滑曲线不同效果
* (2022.10.05) 修复`Serie`隐藏时`Tooltip`还显示信息的问题
* (2022.09.30) 修复`Chart`在很小尺寸时出现`DivideByZeroException`异常的问题 (#230)
## v3.3.0
### 版本要点
@@ -72,6 +104,7 @@
### 日志详情
* (2022.09.28) 发布`v3.3.0`版本
* (2022.09.26) 优化`Axis`在类目轴时的默认分割段数
* (2022.09.25) 修复`API`文档中部分接口没有导出的问题
* (2022.09.24) 优化`FunnelChart`

View File

@@ -2,6 +2,7 @@
# 更新日志
[master](#master)
[v3.4.0](#v3.4.0)
[v3.3.0](#v3.3.0)
[v3.2.0](#v3.2.0)
[v3.1.0](#v3.1.0)
@@ -59,9 +60,40 @@
## master
## v3.4.0
### Highlights
* Added `indicatorLabel` of `Axis` to set different indicator text styles separately
* Add `markColor` of `Serie` to set the logo color
* Add `startAngle` of `RadarCoord` to set the starting Angle of `Radar`
* Optimize the numerical interval representation of `Axis`
* Added `DataZoom` support for numeric axes
* Add `SmoothLimit` of `Line` to control different effects of smoothing curves
### Details
* (2022.11.01) Release `v3.4.0` version
* (2022.10.30) adds API: `AddData()`, `ClearSerieData()`, `ClearComponentData()`
* (2022.10.30) Added `Axis`'s `indicatorLabel`, removed `Tooltip`'s `indicatorLabelStyle` (#226)
* (2022.10.29) Add `Serie` `markColor` to set logo colors for display of `Legend` and `Tooltip` (#229)
* (2022.10.26) increase the startAngle of RadarCoord to set the startAngle of Radar
* (2022.10.21) Fixed `Chart` not displaying `Label` properly when controlled by `Layout` (#231)
* (2022.10.21) fixed compatibility issues on Unity2019.2
* (2022.10.18) Optimize the numerical performance of `Axis`
* (2022.10.15) Fixed an issue where `Axis` `Label` might not appear properly when `DataZoom` is enabled (#227)
* (2022.10.14) Added `DataZoom` support for numeric axes
* (2022.10.13) Fixed the `Pie` circle with abnormal border Settings (#225)
* (2022.10.13) Fixed the `Download` interface causing the `iOS` platform packaging failure
* (2022.10.12) Added support for `Animation` `UnscaledTime` to set whether the animation is affected by TimeScale (#223)
* (2022.10.10) Optimizes the `Documentation` format
* (2022.10.10) Add `Line` `SmoothLimit` to control different effects of smoothing curves
* (2022.10.05) Fixed an issue where `Serie` hid information when `Tooltip` was also displayed
* (2022.09.30) Fixed `DivideByZeroException` when Chart `is very small (#230)
## v3.3.0
### Main points
### Highlights
* Optimized chart details to support more functions
* Add lots of Demo examples
@@ -70,7 +102,7 @@
* Added a HeatmapChart type
* Improved Tooltip display
### Log details
### Details
* (2022.09.26) Optimizes the default number of segments for `Axis` at the category Axis
* (2022.09.25) Fixed the problem that some interfaces in the `API` document were not exported
@@ -109,7 +141,7 @@
## v3.2.0
### Main points
### Highlights
* `Serie` supports highlighting, EmphasisStyle, EmphasisStyle, BlurStyle, and SelectStyle
* `Axis` supports sub-scale and sub-partition of coordinate axes:`MinorTick` and `MinorSplitLine`
@@ -119,7 +151,7 @@
* `DataZoom` supports timeline
* Other optimizations and issue fixes
### Log details
### Details
* (2022.08.16) Release `v3.2.0` version
* (2022.08.15) optimized `Smooth` Bezier curve algorithm
@@ -274,7 +306,7 @@
## v2.4.0
### Main points
### Highlights
* LineChart support the line of ignore data is disconnected or connected
* LineChart support animation at a constant speed
@@ -299,7 +331,7 @@
## v2.3.0
### Main points
### Highlights
* Data store upgraded from `float` to `double`
* Added `MarkLine`

View File

@@ -19,7 +19,7 @@
| |免费用户|付费咨询|个人`VIP` | 个人`SVIP` | 企业`VIP` |
| ----- |--|--|--|--|--|
| 订阅费用 | -- | `98`¥ | `298`¥ | 首年`1298`¥</br>后续`298¥`* | `联系我们` |
| 订阅费用 | -- | `98`¥ | `298`¥ | 首年`1298`¥<br/>后续`298¥`* | `联系我们` |
| 订阅时长 | -- | `7`天* | `1`年 | `1`年* | `1`
| 订阅席位 | -- | `1`个席位 | `1`个席位 |`1`个席位|`5`个以上席位|
| __`服务方式:`__|

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
# XCharts FAQ
[XCharts Homepage](https://github.com/XCharts-Team/XCharts)</br>
[XCharts API](XChartsAPI-EN.md)</br>
[XCharts Homepage](https://github.com/XCharts-Team/XCharts)<br/>
[XCharts API](XChartsAPI-EN.md)<br/>
[XCharts Configuration](XChartsConfiguration-EN.md)
[QA 1: How to adjust the margin between the axis and the background?](#How-to-adjust-the-margin-between-the-axis-and-the=-background)
@@ -145,6 +145,6 @@ A: This is the limit of `UGUI` on the number of vertices for a single `Graphic`.
A: 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.
[XCharts Homepage](https://github.com/XCharts-Team/XCharts)</br>
[XCharts API](XChartsAPI-EN.md)</br>
[XCharts Homepage](https://github.com/XCharts-Team/XCharts)<br/>
[XCharts API](XChartsAPI-EN.md)<br/>
[XCharts Configuration](XChartsConfiguration-EN.md)

View File

@@ -1,4 +1,4 @@
# XCharts问答
# 问答
[XCharts主页](https://github.com/XCharts-Team/XCharts)
[XChartsAPI](XChartsAPI-ZH.md)

View File

@@ -1,8 +1,8 @@
# 教程5分钟上手 XCharts 3.0
[XCharts主页](https://github.com/XCharts-Team/XCharts)</br>
[XCharts问答](XChartsFAQ-ZH.md)</br>
[XChartsAPI接口](XChartsAPI-ZH.md)</br>
[XCharts主页](https://github.com/XCharts-Team/XCharts)<br/>
[XCharts问答](XChartsFAQ-ZH.md)<br/>
[XChartsAPI接口](XChartsAPI-ZH.md)<br/>
[XCharts配置项手册](XChartsConfiguration-ZH.md)
## 获取和导入 XCharts
@@ -257,7 +257,7 @@ itemStyle.color = Color.blue;
```
[XCharts主页](https://github.com/XCharts-Team/XCharts)</br>
[XCharts问答](XChartsFAQ-ZH.md)</br>
[XChartsAPI接口](XChartsAPI-ZH.md)</br>
[XCharts主页](https://github.com/XCharts-Team/XCharts)<br/>
[XCharts问答](XChartsFAQ-ZH.md)<br/>
[XChartsAPI接口](XChartsAPI-ZH.md)<br/>
[XCharts配置项手册](XChartsConfiguration-ZH.md)

View File

@@ -1,8 +1,8 @@
# 教程5分钟上手 XCharts 3.0
[XCharts主页](https://github.com/XCharts-Team/XCharts)</br>
[XCharts问答](XChartsFAQ-ZH.md)</br>
[XChartsAPI接口](XChartsAPI-ZH.md)</br>
[XCharts主页](https://github.com/XCharts-Team/XCharts)<br/>
[XCharts问答](XChartsFAQ-ZH.md)<br/>
[XChartsAPI接口](XChartsAPI-ZH.md)<br/>
[XCharts配置项手册](XChartsConfiguration-ZH.md)
## 获取和导入 XCharts
@@ -64,17 +64,17 @@ Serie只自带了几个常见的组件其他组件按需额外添加。比如
## 更多组件和配置参数
功能越丰富就越需要更多的组件和参数支持。XCharts有多达几十种的主组件和子组件,每个组件有几个至几十个不等的可配置参数,以支持各种灵活而复杂的功能。
XCharts经过不断的迭代优化目前已有多达几十种的主组件和子组件,每个组件有几个至几十个不等的可配置参数,以支持各种灵活而复杂的功能。
首次接触XCharts可在 `Inspector` 视图下可以添加和调整各个组件,`Game` 视图会实时反馈调整的效果,以熟悉各种组件实现的效果。各个组件的详细参数说明可查阅[XCharts配置项手册](XChartsConfiguration-ZH.md)。
首次使用XCharts可在 `Inspector` 视图添加各种图表,给图表添加或调整里面组件,`Game` 视图会实时反馈调整的效果,以熟悉各种组件的使用。各个组件的详细参数说明可查阅[XCharts配置项手册](XChartsConfiguration-ZH.md)。
## 如何快速调整参数
`XCharts`是配置参数驱动。想要什么效果,只需要去调整对应组件下的配置参数就可以,不需要去改`Hierarchy`视图下的节点,因为那些节点是由`XCharts`内部根据配置参数生成的,即使改了也会在刷新时还原回来。
`XCharts`是配置和数据来驱动。想要什么效果,只需要去调整对应组件下的配置参数就可以,不需要去改`Hierarchy`视图下的节点,因为那些节点是由`XCharts`内部根据配置和数据生成的,即使改了也会在刷新时还原回来。
快速定位你想要改的效果对应的组件这就需要对组件有一定的了解。比如我们想要让X轴的轴线末端显示箭头如何定位第一步X轴定位到`XAxis0`;第二步,轴线定位到`AxisLine`;最后,再去看`AxisLine`组件下有没有这样的参数可以实现这个效果。
如何快速定位你想要改的效果对应的组件这就需要对组件有一定的了解。比如我们想要让X轴的轴线末端显示箭头如何定位第一步X轴定位到`XAxis0`;第二步,轴线定位到`AxisLine`;最后,再去看`AxisLine`组件下有没有这样的参数可以实现这个效果,对于不太确定的参数可以查阅[XCharts配置项手册](XChartsConfiguration-ZH.md)
`XCharts`提供从全局`Theme`、系列`Serie`、单个数据项`SerieData`全方位的参数配置。优先级从大到小为:`SerieData`->`Serie`->`Theme`。以`ItemStyle`的颜色为例:
`XCharts`提供从全局`Theme`、系列`Serie`、单个数据项`SerieData`三方面全方位的参数配置。优先级从大到小为:`SerieData`->`Serie`->`Theme`。以`ItemStyle`的颜色为例:
1. 如果`SerieData`的`ItemStyle`配置有非`0000`颜色值,则优先用这个颜色值。
2. 如果`Serie`的`ItemStyle`配置有非`0000`颜色值,则优先用这个颜色值。
@@ -168,7 +168,7 @@ for (int i = 0; i < 10; i++)
7. `chart.UpdateXAxisData()`更新X轴数据
8. `chart.UpdateDataName()`更新Serie数据的名字
XCharts内部有自动刷新机制但也是在一定条件。如果自己调用了内部组件的接口,碰到组件没有刷新,确实找不到原因的话,可以用以下两个接口强制刷新:
XCharts内部有自动刷新机制但也是在一定条件才会触发。如果自己调用了内部组件的接口,碰到组件没有刷新,确实找不到原因的话,可以用以下两个接口强制刷新:
1. `chart.RefreshAllComponent()`:刷新图表组件,会重新初始化所有组件,不建议频繁待用。
2. `chart.RefreshChart()`:刷新图表绘制,只刷新绘制部分,不会刷新组件文本,位置等部分。
@@ -193,7 +193,7 @@ XCharts支持TextMeshPro但默认是不开启的需要自己手动切换
## 用代码改图表参数
`Inspector`上看到的所有参数都可以用代码来修改,关键是要定位好你要改的参数是在组件上、还是serie上、还是在具体的数据项上
`Inspector`上看到的所有参数都可以用代码来修改,关键是要定位好你要改的参数是在组件上、还是Serie上、还是在具体的数据项SerieData上。
### 改主组件上的参数
@@ -212,7 +212,7 @@ xAxis.type = Axis.AxisType.Category;
### 改Serie的参数
新添加的Serie
对于新添加的Serie
```C#
var serie = chart.AddSerie<Pie>();
@@ -224,7 +224,7 @@ serie.animation.dataChangeEnable = true;
serie.roundCap = true;
```
已存在的Serie
对于已存在的Serie
```C#
var serie = chart.GetSerie<Pie>();
@@ -257,7 +257,7 @@ itemStyle.color = Color.blue;
```
[XCharts主页](https://github.com/XCharts-Team/XCharts)</br>
[XCharts问答](XChartsFAQ-ZH.md)</br>
[XChartsAPI接口](XChartsAPI-ZH.md)</br>
[XCharts主页](https://github.com/XCharts-Team/XCharts)<br/>
[XCharts问答](XChartsFAQ-ZH.md)<br/>
[XChartsAPI接口](XChartsAPI-ZH.md)<br/>
[XCharts配置项手册](XChartsConfiguration-ZH.md)

View File

@@ -21,7 +21,11 @@ namespace XCharts.Editor
PropertyField(prop, "m_FadeOutDelay");
PropertyField(prop, "m_DataChangeEnable");
PropertyField(prop, "m_DataChangeDuration");
PropertyField(prop, "m_ActualDuration");
PropertyField(prop, "m_UnscaledTime");
// using(new EditorGUI.DisabledGroupScope(true))
// {
// PropertyField(prop, "m_ActualDuration");
// }
--EditorGUI.indentLevel;
}
}

View File

@@ -78,6 +78,7 @@ namespace XCharts.Editor
PropertyField("m_AxisLabel");
PropertyField("m_SplitLine");
PropertyField("m_SplitArea");
PropertyField("m_IndicatorLabel");
if (type != Axis.AxisType.Category)
{
PropertyField("m_MinorTick");

View File

@@ -15,6 +15,7 @@ namespace XCharts.Editor
PropertyTwoFiled("m_Center");
PropertyField("m_Radius");
PropertyField("m_SplitNumber");
PropertyField("m_StartAngle");
PropertyField("m_CeilRate");
PropertyField("m_IsAxisTooltip");
PropertyField("m_OutRangeColor");

View File

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

View File

@@ -47,6 +47,7 @@ namespace XCharts.Editor
PropertyField("m_Large");
PropertyField("m_LargeThreshold");
PropertyField("m_PlaceHolder");
PropertyField("m_MarkColor");
});
PropertyField("m_ItemStyle");
PropertyField("m_Animation");

View File

@@ -18,6 +18,10 @@ namespace XCharts.Editor
PropertyField("m_YAxisIndex");
}
PropertyField("m_LineType");
if (serie.lineType == LineType.Smooth)
{
PropertyField("m_SmoothLimit");
}
//PropertyField("m_Clip");
PropertyFiledMore(() =>
{
@@ -33,6 +37,7 @@ namespace XCharts.Editor
PropertyField("m_ShowAsPositiveNumber");
PropertyField("m_Large");
PropertyField("m_LargeThreshold");
PropertyField("m_MarkColor");
});
PropertyField("m_Symbol");
PropertyField("m_LineStyle");

View File

@@ -1,49 +1,49 @@
<p align="center">
<a href="">
<img src="" alt="" width="" height="">
<img src="" alt="" width="" height=""></img>
</a>
</p>
<h2 align="center">XCharts</h3>
<h2 align="center">XCharts</h2>
<p align="center">
A powerful, easy-to-use, configurable charting and data visualization library for Unity.
<br>
<br/>
Unity数据可视化图表插件。
<br>
<br/>
<a href="Documentation/README.md">English README</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>
一款基于`UGUI`的功能强大、易用、参数可配置的数据可视化图表插件。支持`折线图``柱状图``饼图``雷达图``散点图``热力图``环形图``K线图``极坐标``平行坐标`等十种内置图表,以及`3D饼图``3D柱图``3D金字塔``漏斗图``仪表盘``水位图``象形柱图``甘特图``矩形树图`多种扩展图表。
一款基于`UGUI`的功能强大、简单易用的数据可视化图表插件。支持`折线图``柱状图``饼图``雷达图``散点图``热力图``环形图``K线图``极坐标``平行坐标`等十种内置图表,以及`3D饼图``3D柱图``3D金字塔``漏斗图``仪表盘``水位图``象形柱图``甘特图``矩形树图`等扩展图表。
[XCharts3.0 教程](Documentation/XChartsTutorial01-ZH.md)
[XCharts3.0 API](Documentation/XChartsAPI-ZH.md)
@@ -60,13 +60,14 @@
- 支持直线图、曲线图、面积图、阶梯线图等折线图。
- 支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图等柱状图。
- 支持环形图、玫瑰图等饼图。
- 支持内置图表的任意组合,同一图中可同时显示多个相同或不同类型的图表。
- 支持内置图表的任意组合,同一图中可同时显示多个相同或不同类型的图表。
- 支持实线、曲线、阶梯线、虚线、点线、点划线、双点划线等线条。
- 支持主题定制、导入和导出,内置两种默认主题。
- 支持自定义图表内容绘制,提供绘制点、线、曲线、三角形、四边形、圆形、环形、扇形、边框、箭头等强大的绘图API。
- 支持主题定制、导入和导出,内置明暗两种默认主题。
- 支持自定义图表内容绘制,提供绘制点、线、面等其他图形的强大的绘图API。
- 支持PC端和手机端上的数据筛选、视图缩放、细节展示等交互操作。
- 支持万级大数据绘制。
- 支持万级大数据量绘制,支持采样绘制。
- 支持`TexMeshPro`
- 支持所有`5.6`以上的`Unity`版本。
## 截图
@@ -74,7 +75,7 @@
![扩展图表](https://github.com/XCharts-Team/XCharts-Demo/blob/master/extendchart.png)
更多示例请看 [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) 仓库,也可以在浏览器查看`WebGL`下的运行效果 [在线Demo](https://xcharts-team.github.io/demo/) 。
XCharts不再内置DemoDemo已独立出单独的仓库 [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo),也可以在浏览器查看`WebGL`下的运行效果 [在线Demo](https://xcharts-team.github.io/demo/) 。
## `XCharts3.0`
@@ -104,20 +105,28 @@
## 注意
- `XCharts3.0` 不完全兼容 `XCharts2.0` 版本,建议旧项目可以继续使用`XCharts2.0`,新项目推荐使用`XCharts3.0`
- `XCharts3.0` 不完全兼容 `XCharts2.0` 版本,升级`3.0`可能需要调整部分代码和配置。建议旧项目可以继续使用`XCharts2.0`,新项目推荐使用`XCharts3.0`
- `XCharts2.0` 进入维护阶段,后续只修复严重`bug`,理论上不再加新功能。
- `XCharts` 理论上支持`Unity 5.6`及以上版本,但由于版本测试有限难免疏漏,发现版本兼容问题可提`Issue`
- 本仓库只包含`XCharts`源码,不包含`Demo`示例部分。需要查看`Demo`示例请到[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)仓库。
- 本仓库只包含`XCharts`源码,不包含`Demo`示例部分。需要查看`Demo`请到[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)仓库。
## 使用
1. 导入`XCharts``unitypackage`或者源码到项目。
2.`Hierarchy`视图下右键选择`XCharts->LineChart`,即可创建一个默认的折线图。
3.`Inspector`视图可以调整各个组件的参数,并在`Game`视图看到实时效果。
3.`Inspector`视图可以调整各个组件的参数,`Game`视图看到实时效果。
更多教程请看:[XCharts教程5分钟上手教程](Documentation/XChartsTutorial01-ZH.md)
- 更多使用细节,请看:[XCharts教程5分钟上手教程](Documentation/XChartsTutorial01-ZH.md)
- 首次使用,建议先认真看一遍教程。
首次使用,建议先认真看一遍教程。
## 分支
- `master`:开发分支。最新的修改和新功能都先提交到`master`分支,一段时间后再从`master`分支`merge``3.0`分支,并发布`release`版本。
- `3.0`XCharts 3.0的稳定分支。一般一个月一更新,从`master`分支`merge`最新改动过来,并发布`release`版本。
- `2.0`XCharts 2.0的稳定分支。带Demo目前基本不再维护仅修改严重bug。
- `2.0-upm`XCharts 2.0的稳定UMP分支。不带Demo只包含Package部分专门给UMP用不再维护。
- `1.0`XCharts 1.0的稳定分支。带Demo不再维护。
- `1.0-upm`XCharts 1.0的稳定UMP分支。不带Demo不再维护。
## FAQ
@@ -125,28 +134,28 @@
答:`XCharts`使用`MIT`协议,可以免费使用。也可以订阅`VIP`享受更多增值服务。
2. `XCharts`支持代码动态添加和修改数据吗?支持从`Excel`或数据库中获取数据吗?
答:`XCharts`提供了各种数据操作的接口,支持代码动态添加和修改数据,但数据需要自己解析或获取,再调用`XCharts`的接口添加到`XCharts`
答:`XCharts`提供了各种数据操作的接口,支持代码动态修改配置,添加和修改数据,但数据来源需要自己解析或获取,再调用`XCharts`的接口添加到`XCharts`
3. 这个插件除了用在`Unity`,还能用在其他平台(如`Winform``WPF`)吗?
答:目前只支持在`Unity`平台使用。理论上任何支持`UGUI``Unity`版本都能运行`XCharts`
4. 锯齿怎么解决?支持多大量级的数据?
答:`XCharts`是基于`UGUI`实现的,所以`UGUI`中碰到的问题,在`XCharts`中也会存在。比如锯齿问题,比如`Mesh`顶点数超`65535`的问题。这两个问题的解决可参考`问答16``问答27`
由于`Mesh``65535`顶点数的限制,目前`XCharts`的单条`Line`大概支持`2万`左右的数据量,当然开采样可以支持更多数据,但可能会更消耗CPU。
答:`XCharts`是基于`UGUI`实现的,所以`UGUI`中碰到的问题,在`XCharts`中也会存在。比如锯齿问题,比如`Mesh`顶点数超`65535`的问题。这两个问题的解决可参考[问答16](Documentation/XChartsFAQ-ZH.md)和[问答27](Documentation/XChartsFAQ-ZH.md)
由于`Mesh``65535`顶点数的限制,目前`XCharts`的单条`Line`支持`2万`的数据量,当然开采样可以支持更多数据的绘制,但同时也会更消耗CPU。
## Licenses
[MIT License](LICENSE.md)
可免费商用,可二次开发
- [MIT License](LICENSE.md)
- 可免费商用,可二次开发
- 扩展图表需单独购买授权
## 日志
[更新日志](CHANGELOG.md)
- [更新日志](CHANGELOG.md)
## 其他
邮箱:`monitor1394@gmail.com`
QQ群XCharts交流群`202030963`
VIP群XCharts技术支持VIP群`867291970`
捐助、合作和技术支持:[☞ 看这里](Documentation/SUPPORT.md)
- 邮箱:`monitor1394@gmail.com`
- QQ群XCharts交流群`202030963`
- VIP群XCharts技术支持VIP群`867291970`
- 捐助、合作和技术支持:[☞ 看这里](Documentation/SUPPORT.md)

View File

@@ -61,6 +61,7 @@ namespace XCharts.Runtime
[SerializeField] private bool m_DataChangeEnable = true;
[SerializeField] private float m_DataChangeDuration = 500;
[SerializeField] private float m_ActualDuration;
[SerializeField][Since("v3.4.0")] private bool m_UnscaledTime;
/// <summary>
/// 自定义渐入动画延时函数。返回ms值。
/// </summary>
@@ -133,6 +134,11 @@ namespace XCharts.Runtime
/// </summary>
public float dataChangeDuration { get { return m_DataChangeDuration; } set { m_DataChangeDuration = value < 0 ? 0 : value; } }
/// <summary>
/// Animation updates independently of Time.timeScale.
/// |动画是否受TimeScaled的影响。默认为 false 受TimeScaled的影响。
/// </summary>
public bool unscaledTime { get { return m_UnscaledTime; } set { m_UnscaledTime = value; } }
/// <summary>
/// 渐入动画完成回调
/// </summary>
public Action fadeInFinishCallback { get; set; }
@@ -464,7 +470,7 @@ namespace XCharts.Runtime
m_ActualDuration = (int) ((Time.time - startTime) * 1000) - fadeInDelay;
var duration = GetCurrAnimationDuration();
var delta = (float) (total / duration * Time.deltaTime);
var delta = (float) (total / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
if (m_FadeOut)
{
m_CurrDetailProgress -= delta;
@@ -522,7 +528,7 @@ namespace XCharts.Runtime
else
{
var duration = GetCurrAnimationDuration(dataIndex);
var delta = (destProgress - startProgress) / duration * Time.deltaTime;
var delta = (destProgress - startProgress) / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
currHig = currHig + (m_FadeOut ? -delta : delta);
if (m_FadeOut)
{
@@ -555,7 +561,7 @@ namespace XCharts.Runtime
return;
var duration = GetCurrAnimationDuration();
var delta = dest / duration * Time.deltaTime;
var delta = dest / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
if (m_FadeOut)
{
m_CurrSymbolProgress -= delta;

View File

@@ -103,6 +103,7 @@ namespace XCharts.Runtime
[SerializeField] protected AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
[SerializeField][Since("v3.2.0")] protected AxisMinorTick m_MinorTick = AxisMinorTick.defaultMinorTick;
[SerializeField][Since("v3.2.0")] protected AxisMinorSplitLine m_MinorSplitLine = AxisMinorSplitLine.defaultMinorSplitLine;
[SerializeField][Since("v3.4.0")] protected LabelStyle m_IndicatorLabel = new LabelStyle() { numericFormatter = "f2" };
public AxisContext context = new AxisContext();
@@ -372,6 +373,15 @@ namespace XCharts.Runtime
set { if (value != null) { m_MinorSplitLine = value; SetVerticesDirty(); } }
}
/// <summary>
/// Style of axis tooltip indicator label.
/// |指示器文本的样式。Tooltip为Cross时使用。
/// </summary>
public LabelStyle indicatorLabel
{
get { return m_IndicatorLabel; }
set { if (value != null) { m_IndicatorLabel = value; SetComponentDirty(); } }
}
/// <summary>
/// Whether to add new data at the head or at the end of the list.
/// |添加新数据时是在列表的头部还是尾部加入。
/// </summary>
@@ -401,7 +411,8 @@ namespace XCharts.Runtime
{
return m_ComponentDirty ||
axisName.anyDirty ||
axisLabel.anyDirty;
axisLabel.anyDirty ||
indicatorLabel.anyDirty;
}
}
@@ -410,6 +421,7 @@ namespace XCharts.Runtime
base.ClearComponentDirty();
axisName.ClearComponentDirty();
axisLabel.ClearComponentDirty();
indicatorLabel.ClearComponentDirty();
}
public override void ClearVerticesDirty()
@@ -422,6 +434,7 @@ namespace XCharts.Runtime
splitArea.ClearVerticesDirty();
minorTick.ClearVerticesDirty();
minorSplitLine.ClearVerticesDirty();
indicatorLabel.ClearComponentDirty();
}
public override void SetComponentDirty()
@@ -455,6 +468,7 @@ namespace XCharts.Runtime
axis.splitArea = splitArea.Clone();
axis.minorTick = minorTick.Clone();
axis.minorSplitLine = minorSplitLine.Clone();
axis.indicatorLabel = indicatorLabel.Clone();
axis.icons = new List<Sprite>();
axis.data = new List<string>();
ChartHelper.CopyList(axis.data, data);
@@ -485,6 +499,7 @@ namespace XCharts.Runtime
splitArea.Copy(axis.splitArea);
minorTick.Copy(axis.minorTick);
minorSplitLine.Copy(axis.minorSplitLine);
indicatorLabel.Copy(axis.indicatorLabel);
ChartHelper.CopyList(data, axis.data);
ChartHelper.CopyList<Sprite>(icons, axis.icons);
}
@@ -719,8 +734,6 @@ namespace XCharts.Runtime
}
}
/// <summary>
/// 获得指定区域缩放的类目数据列表
/// </summary>

View File

@@ -56,6 +56,7 @@ namespace XCharts.Runtime
public double pointerValue;
public Vector3 pointerLabelPosition;
public double axisTooltipValue;
public TextAnchor aligment;
public List<string> runtimeData { get { return m_RuntimeData; } }
public List<double> labelValueList { get { return m_LabelValueList; } }
public List<ChartLabel> labelObjectList { get { return m_AxisLabelList; } }

View File

@@ -233,7 +233,9 @@ namespace XCharts
{
var each = GetTick(range);
tick = each;
if (range / tick > 8)
if (range / 4 % each == 0)
tick = range / 4;
else if (range / tick > 8)
tick = 2 * each;
else if (range / tick < 4)
tick = each / 2;
@@ -273,6 +275,7 @@ namespace XCharts
private static double GetTick(double max)
{
if (max <= 1) return max / 5;
if (max > 1 && max < 10) return 1;
var bigger = Math.Ceiling(Math.Abs(max));
int n = 1;
while (bigger / (Mathf.Pow(10, n)) > 10)
@@ -368,6 +371,9 @@ namespace XCharts
((inside && axis.IsLeft()) || (!inside && axis.IsRight()) ?
TextAnchor.MiddleLeft :
TextAnchor.MiddleRight);
if (axis.IsCategory() && axis.boundaryGap)
splitNumber -= 1;
axis.context.aligment = defaultAlignment;
for (int i = 0; i < splitNumber; i++)
{
var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);

View File

@@ -261,7 +261,7 @@ namespace XCharts.Runtime
else
{
var data = axis.GetDataList(dataZoom);
if (axis.IsCategory() && data.Count > 0)
if (axis.IsCategory() && data.Count > 0 && splitNum > 0)
{
var count = axis.boundaryGap ? data.Count : data.Count - 1;
int tick = count / splitNum;

View File

@@ -143,7 +143,7 @@ namespace XCharts.Runtime
m_TextLimit.SetRelatedText(txt, labelWidth);
}
public string GetFormatterContent(int labelIndex, string category)
public override string GetFormatterContent(int labelIndex, string category)
{
if (string.IsNullOrEmpty(category))
return GetFormatterFunctionContent(labelIndex, category, category);
@@ -160,71 +160,13 @@ namespace XCharts.Runtime
}
}
public string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
public override string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
{
if (showAsPositiveNumber && value < 0)
{
value = Math.Abs(value);
}
if (string.IsNullOrEmpty(m_Formatter))
{
if (isLog)
{
return GetFormatterFunctionContent(labelIndex, value, ChartCached.NumberToStr(value, numericFormatter));
}
if (minValue >= -1 && minValue <= 1 && maxValue >= -1 && maxValue <= 1)
{
int minAcc = ChartHelper.GetFloatAccuracy(minValue);
int maxAcc = ChartHelper.GetFloatAccuracy(maxValue);
int curAcc = ChartHelper.GetFloatAccuracy(value);
int acc = Mathf.Max(Mathf.Max(minAcc, maxAcc), curAcc);
return GetFormatterFunctionContent(labelIndex, value, ChartCached.FloatToStr(value, numericFormatter, acc));
}
return GetFormatterFunctionContent(labelIndex, value, ChartCached.NumberToStr(value, numericFormatter));
}
else
{
var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, numericFormatter, value);
return GetFormatterFunctionContent(labelIndex, value, content);
}
}
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue)
{
var timestamp = (int) value;
var dateTime = DateTimeUtil.GetDateTime(timestamp);
var dateString = string.Empty;
if (string.IsNullOrEmpty(numericFormatter))
{
dateString = DateTimeUtil.GetDateTimeFormatString(dateTime, maxValue - minValue);
}
else
{
dateString = dateTime.ToString(numericFormatter);
}
if (!string.IsNullOrEmpty(m_Formatter))
{
var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, dateString);
return GetFormatterFunctionContent(labelIndex, value, m_TextLimit.GetLimitContent(content));
}
else
{
return GetFormatterFunctionContent(labelIndex, value, m_TextLimit.GetLimitContent(dateString));
}
}
private string GetFormatterFunctionContent(int labelIndex, string category, string currentContent)
{
return m_FormatterFunction == null ? currentContent :
m_FormatterFunction(labelIndex, labelIndex, category, currentContent);
}
private string GetFormatterFunctionContent(int labelIndex, double value, string currentContent)
{
return m_FormatterFunction == null ? currentContent :
m_FormatterFunction(labelIndex, labelIndex, null, currentContent);
return base.GetFormatterContent(labelIndex, value, minValue, maxValue, isLog);
}
}
}

View File

@@ -478,11 +478,13 @@ namespace XCharts.Runtime
var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage :
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
var dataChanging = false;
var animationDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
for (int i = 0; i < maxCount; i += rate)
{
double value = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
serie.animation.GetUpdateAnimationDuration(), ref dataChanging, axis);
animationDuration, ref dataChanging, axis, unscaledTime);
float pX = dataZoom.context.x + i * scaleWid;
float dataHig = (float) ((maxValue - minValue) == 0 ? 0 :
(value - minValue) / (maxValue - minValue) * dataZoom.context.height);
@@ -567,11 +569,13 @@ namespace XCharts.Runtime
var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage :
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
var dataChanging = false;
var animationDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
for (int i = 0; i < maxCount; i += rate)
{
double value = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
serie.animation.GetUpdateAnimationDuration(), ref dataChanging, axis);
animationDuration, ref dataChanging, axis, unscaledTime);
float pY = dataZoom.context.y + i * scaleWid;
float dataHig = (maxValue - minValue) == 0 ? 0 :
(float) ((value - minValue) / (maxValue - minValue) * dataZoom.context.width);

View File

@@ -1,3 +1,4 @@
using System;
using UnityEngine;
namespace XCharts.Runtime
@@ -315,5 +316,85 @@ namespace XCharts.Runtime
m_TextPadding = label.m_TextPadding;
m_TextStyle.Copy(label.m_TextStyle);
}
public virtual string GetFormatterContent(int labelIndex, string category)
{
if (string.IsNullOrEmpty(category))
return GetFormatterFunctionContent(labelIndex, category, category);
if (string.IsNullOrEmpty(m_Formatter))
{
return GetFormatterFunctionContent(labelIndex, category, category);
}
else
{
var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, category);
return GetFormatterFunctionContent(labelIndex, category, category);
}
}
public virtual string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
{
if (string.IsNullOrEmpty(m_Formatter))
{
if (isLog)
{
return GetFormatterFunctionContent(labelIndex, value, ChartCached.NumberToStr(value, numericFormatter));
}
if (minValue >= -1 && minValue <= 1 && maxValue >= -1 && maxValue <= 1)
{
int minAcc = ChartHelper.GetFloatAccuracy(minValue);
int maxAcc = ChartHelper.GetFloatAccuracy(maxValue);
int curAcc = ChartHelper.GetFloatAccuracy(value);
int acc = Mathf.Max(Mathf.Max(minAcc, maxAcc), curAcc);
return GetFormatterFunctionContent(labelIndex, value, ChartCached.FloatToStr(value, numericFormatter, acc));
}
return GetFormatterFunctionContent(labelIndex, value, ChartCached.NumberToStr(value, numericFormatter));
}
else
{
var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, numericFormatter, value);
return GetFormatterFunctionContent(labelIndex, value, content);
}
}
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue)
{
var timestamp = (int) value;
var dateTime = DateTimeUtil.GetDateTime(timestamp);
var dateString = string.Empty;
if (string.IsNullOrEmpty(numericFormatter) || numericFormatter.Equals("f2"))
{
dateString = DateTimeUtil.GetDateTimeFormatString(dateTime, maxValue - minValue);
}
else
{
dateString = dateTime.ToString(numericFormatter);
}
if (!string.IsNullOrEmpty(m_Formatter))
{
var content = m_Formatter;
FormatterHelper.ReplaceAxisLabelContent(ref content, dateString);
return GetFormatterFunctionContent(labelIndex, value, content);
}
else
{
return GetFormatterFunctionContent(labelIndex, value, dateString);
}
}
protected string GetFormatterFunctionContent(int labelIndex, string category, string currentContent)
{
return m_FormatterFunction == null ? currentContent :
m_FormatterFunction(labelIndex, labelIndex, category, currentContent);
}
protected string GetFormatterFunctionContent(int labelIndex, double value, string currentContent)
{
return m_FormatterFunction == null ? currentContent :
m_FormatterFunction(labelIndex, labelIndex, null, currentContent);
}
}
}

View File

@@ -108,6 +108,7 @@ namespace XCharts.Runtime
[SerializeField] private Color32 m_OutRangeColor = Color.red;
[SerializeField] private bool m_ConnectCenter = false;
[SerializeField] private bool m_LineGradient = true;
[SerializeField][Since("v3.4.0")] private float m_StartAngle;
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
public RadarCoordContext context = new RadarCoordContext();
@@ -264,6 +265,14 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_LineGradient, value)) SetAllDirty(); }
}
/// <summary>
/// 起始角度。和时钟一样12点钟位置是0度顺时针到360度。
/// </summary>
public float startAngle
{
get { return m_StartAngle; }
set { if (PropertyUtil.SetStruct(ref m_StartAngle, value)) SetVerticesDirty(); }
}
/// <summary>
/// the indicator list.
/// |指示器列表。
/// </summary>

View File

@@ -124,7 +124,8 @@ namespace XCharts.Runtime
int indicatorNum = radar.indicatorList.Count;
Vector3 p1, p2, p3, p4;
Vector3 p = radar.context.center;
float angle = 2 * Mathf.PI / indicatorNum;
var startAngle = radar.startAngle * Mathf.PI / 180;
var angle = 2 * Mathf.PI / indicatorNum;
var lineColor = radar.axisLine.GetColor(chart.theme.axis.splitLineColor);
var lineWidth = radar.axisLine.GetWidth(chart.theme.axis.lineWidth);
var lineType = radar.axisLine.GetType(chart.theme.axis.lineType);
@@ -135,11 +136,11 @@ namespace XCharts.Runtime
{
var color = radar.splitArea.GetColor(i, chart.theme.axis);
outsideRadius = insideRadius + block;
p1 = new Vector3(p.x + insideRadius * Mathf.Sin(0), p.y + insideRadius * Mathf.Cos(0));
p2 = new Vector3(p.x + outsideRadius * Mathf.Sin(0), p.y + outsideRadius * Mathf.Cos(0));
p1 = new Vector3(p.x + insideRadius * Mathf.Sin(startAngle), p.y + insideRadius * Mathf.Cos(startAngle));
p2 = new Vector3(p.x + outsideRadius * Mathf.Sin(startAngle), p.y + outsideRadius * Mathf.Cos(startAngle));
for (int j = 0; j <= indicatorNum; j++)
{
float currAngle = j * angle;
float currAngle = startAngle + j * angle;
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
p4 = new Vector3(p.x + insideRadius * Mathf.Sin(currAngle),
@@ -161,7 +162,7 @@ namespace XCharts.Runtime
{
for (int j = 0; j <= indicatorNum; j++)
{
float currAngle = j * angle;
float currAngle = startAngle + j * angle;
p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle),
p.y + outsideRadius * Mathf.Cos(currAngle));
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p, p3, lineColor);

View File

@@ -120,7 +120,6 @@ namespace XCharts.Runtime
[SerializeField] private float m_ItemHeight = 25f;
[SerializeField] private Color32 m_BorderColor = new Color32(230, 230, 230, 255);
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None);
[SerializeField] private LabelStyle m_IndicatorLabelStyle = new LabelStyle();
[SerializeField]
private LabelStyle m_TitleLabelStyle = new LabelStyle()
{
@@ -178,56 +177,56 @@ namespace XCharts.Runtime
/// The placeholder {I} can be set separately to indicate that the title is ignored and not displayed.
/// Template see itemFormatter.
/// |提示框标题内容的字符串模版格式器。支持用 \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>
/// {f}为数据总和。</br>
/// {g}为数据总个数。</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}、{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/>
/// {f}为数据总和。<br/>
/// {g}为数据总个数。<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}"
/// </summary>
/// </summary>
public string titleFormatter { get { return m_TitleFormatter; } set { m_TitleFormatter = value; } }
/// <summary>
/// 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>
/// {.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>
/// 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/>
/// {.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/>
/// |提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 换行。用|来表示多个列的分隔。
/// 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。</br>
/// 模板变量有{.}、{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>
/// {c0}表示当前数据项维度为0的数据。</br>
/// {c1}表示当前数据项维度为1的数据。</br>
/// {d3}表示维度3的数据的百分比。它的分母是默认维度一般是1维度数据。</br>
/// {.}为当前所指示的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/>
/// {c0}表示当前数据项维度为0的数据。<br/>
/// {c1}表示当前数据项维度为1的数据。<br/>
/// {d3}表示维度3的数据的百分比。它的分母是默认维度一般是1维度数据。<br/>
/// |表示多个列的分隔。<br>
/// 示例:"{i}", "{.}|{a}|{c}", "{.}|{b}|{c2:f2}"
/// </summary>
@@ -378,15 +377,6 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
}
/// <summary>
/// the label style of tooltip axis indicator label.
/// |提示框的坐标轴指示器文本的样式。
/// </summary>
public LabelStyle indicatorLabelStyle
{
get { return m_IndicatorLabelStyle; }
set { if (value != null) { m_IndicatorLabelStyle = value; SetComponentDirty(); } }
}
/// <summary>
/// the textstyle of title.
/// |标题的文本样式。
/// </summary>
@@ -420,14 +410,13 @@ namespace XCharts.Runtime
/// </summary>
public override bool componentDirty
{
get { return m_ComponentDirty || lineStyle.componentDirty || indicatorLabelStyle.componentDirty; }
get { return m_ComponentDirty || lineStyle.componentDirty; }
}
public override void ClearComponentDirty()
{
base.ClearComponentDirty();
lineStyle.ClearComponentDirty();
indicatorLabelStyle.ClearComponentDirty();
}
/// <summary>
/// 当前提示框所指示的Serie索引目前只对散点图有效

View File

@@ -9,7 +9,7 @@ namespace XCharts.Runtime
[UnityEngine.Scripting.Preserve]
internal sealed class TooltipHandler : MainComponentHandler<Tooltip>
{
private List<ChartLabel> m_IndicatorLabels = new List<ChartLabel>();
private Dictionary<string, ChartLabel> m_IndicatorLabels = new Dictionary<string, ChartLabel>();
private GameObject m_LabelRoot;
private ISerieContainer m_PointerContainer;
@@ -52,28 +52,35 @@ namespace XCharts.Runtime
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
ChartHelper.HideAllObject(m_LabelRoot);
m_IndicatorLabels.Clear();
for (int i = 0; i < 2; i++)
foreach (var com in chart.components)
{
var labelName = "label_" + i;
var item = ChartHelper.AddTooltipIndicatorLabel(component, labelName, m_LabelRoot.transform,
chart.theme, TextAnchor.MiddleCenter);
item.SetActive(false);
m_IndicatorLabels.Add(item);
if (com is Axis)
{
var axis = com as Axis;
var labelName = ChartCached.GetComponentObjectName(axis);
var item = ChartHelper.AddTooltipIndicatorLabel(component, labelName, m_LabelRoot.transform,
chart.theme, axis.context.aligment, axis.indicatorLabel);
item.SetActive(false);
m_IndicatorLabels[labelName] = item;
}
}
};
tooltip.refreshComponent();
}
private ChartLabel GetIndicatorLabel(int index)
private ChartLabel GetIndicatorLabel(Axis axis)
{
if (m_LabelRoot == null) return null;
if (index < m_IndicatorLabels.Count) return m_IndicatorLabels[index];
var key = ChartCached.GetComponentObjectName(axis);
if (m_IndicatorLabels.ContainsKey(key))
{
return m_IndicatorLabels[key];
}
else
{
var labelName = "label_" + index;
var item = ChartHelper.AddTooltipIndicatorLabel(component, labelName, m_LabelRoot.transform,
chart.theme, TextAnchor.MiddleCenter);
m_IndicatorLabels.Add(item);
var item = ChartHelper.AddTooltipIndicatorLabel(component, key, m_LabelRoot.transform,
chart.theme, TextAnchor.MiddleCenter, axis.indicatorLabel);
m_IndicatorLabels[key] = item;
return item;
}
}
@@ -138,7 +145,6 @@ namespace XCharts.Runtime
{
if (tooltip.type == Tooltip.Type.Corss)
{
var labelCount = 0;
if (m_PointerContainer is GridCoord)
{
var grid = m_PointerContainer as GridCoord;
@@ -150,7 +156,7 @@ namespace XCharts.Runtime
var axis = component as Axis;
if (axis.gridIndex == grid.index)
{
var label = GetIndicatorLabel(labelCount++);
var label = GetIndicatorLabel(axis);
SetTooltipIndicatorLabel(tooltip, axis, label);
}
}
@@ -167,7 +173,7 @@ namespace XCharts.Runtime
var axis = component as Axis;
if (axis.polarIndex == polar.index)
{
var label = GetIndicatorLabel(labelCount++);
var label = GetIndicatorLabel(axis);
SetTooltipIndicatorLabel(tooltip, axis, label);
}
}
@@ -183,16 +189,27 @@ namespace XCharts.Runtime
if (double.IsNaN(axis.context.pointerValue)) return;
label.SetActive(true);
label.SetTextActive(true);
label.SetPosition(axis.context.pointerLabelPosition);
label.SetPosition(axis.context.pointerLabelPosition + axis.indicatorLabel.offset);
if (axis.IsCategory())
label.SetText(axis.GetData((int) axis.context.pointerValue));
{
var index = (int) axis.context.pointerValue;
var category = axis.GetData(index);
label.SetText(axis.indicatorLabel.GetFormatterContent(index, category));
}
else if (axis.IsTime())
{
label.SetText(axis.indicatorLabel.GetFormatterDateTime(0, axis.context.pointerValue, axis.context.minValue, axis.context.maxValue));
}
else
label.SetText(axis.context.pointerValue.ToString("f2"));
{
label.SetText(axis.indicatorLabel.GetFormatterContent(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(tooltip.indicatorLabelStyle.background.color))
if (ChartHelper.IsClearColor(axis.indicatorLabel.background.color))
label.color = textColor;
else
label.color = tooltip.indicatorLabelStyle.background.color;
label.color = axis.indicatorLabel.background.color;
label.SetTextColor(Color.white);
}
@@ -447,6 +464,7 @@ namespace XCharts.Runtime
for (int i = 0; i < series.Count; i++)
{
var serie = series[i];
if (!serie.show) continue;
serie.context.isTriggerByAxis = isTriggerByAxis;
if (isTriggerByAxis && dataIndex >= 0 && serie.context.pointerItemDataIndex < 0)
serie.context.pointerItemDataIndex = dataIndex;

View File

@@ -187,9 +187,31 @@ namespace XCharts.Runtime
/// |清空所有组件和Serie的数据。注意Serie只是清空数据不会移除Serie。
/// </summary>
public virtual void ClearData()
{
ClearSerieData();
ClearComponentData();
}
[Since("v3.4.0")]
/// <summary>
/// Clear the data of all series.
/// |清空所有serie的数据。
/// </summary>
public virtual void ClearSerieData()
{
foreach (var serie in m_Series)
serie.ClearData();
m_CheckAnimation = false;
RefreshChart();
}
[Since("v3.4.0")]
/// <summary>
/// Clear the data of all components.
/// |清空所有组件的数据。
/// </summary>
public virtual void ClearComponentData()
{
foreach (var component in m_Components)
component.ClearData();
m_CheckAnimation = false;
@@ -568,6 +590,25 @@ namespace XCharts.Runtime
return theme.GetBackgroundColor(background);
}
[Since("v3.4.0")]
/// <summary>
/// 获得Serie的标识颜色。
/// </summary>
/// <param name="serie"></param>
/// <param name="serieData"></param>
/// <returns></returns>
public Color32 GetMarkColor(Serie serie, SerieData serieData)
{
if (ChartHelper.IsClearColor(serie.markColor))
{
return GetItemColor(serie, serieData);
}
else
{
return serie.markColor;
}
}
public Color32 GetItemColor(Serie serie, SerieData serieData)
{
Color32 color, toColor;

View File

@@ -14,7 +14,7 @@ namespace XCharts.Runtime
{
if (axis is XAxis)
{
SeriesHelper.GetXMinMaxValue(this, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
SeriesHelper.GetXMinMaxValue(this, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue, false, false);
}
else
{

View File

@@ -304,6 +304,46 @@ namespace XCharts.Runtime
return null;
}
[Since("v3.4.0")]
/// <summary>
/// Add an arbitray dimension data to serie,such as (x,y,z,...).
/// |添加多维数据x,y,z...)到指定的系列中。
/// </summary>
/// <param name="serieIndex">the index of serie</param>
/// <param name="multidimensionalData">the (x,y,z,...) data</param>
/// <returns></returns>
public SerieData AddData(int serieIndex, params double[] multidimensionalData)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
var serieData = serie.AddData(multidimensionalData);
RefreshPainter(serie.painter);
return serieData;
}
return null;
}
[Since("v3.4.0")]
/// <summary>
/// Add an arbitray dimension data to serie,such as (x,y,z,...).
/// |添加多维数据x,y,z...)到指定的系列中。
/// </summary>
/// <param name="serieName">the name of serie</param>
/// <param name="multidimensionalData">the (x,y,z,...) data</param>
/// <returns></returns>
public SerieData AddData(string serieName, params double[] multidimensionalData)
{
var serie = GetSerie(serieName);
if (serie != null)
{
var serieData = serie.AddData(multidimensionalData);
RefreshPainter(serie.painter);
return serieData;
}
return null;
}
/// <summary>
/// Add a (x,y) data to serie.
/// |添加x,y数据到指定系列中。

View File

@@ -300,6 +300,7 @@ namespace XCharts.Runtime
base.SetAllComponentDirty();
m_Theme.SetAllDirty();
foreach (var com in m_Components) com.SetAllDirty();
foreach (var handler in m_SerieHandlers) handler.InitComponent();
m_RefreshChart = true;
}
@@ -691,7 +692,7 @@ namespace XCharts.Runtime
public void OnBeforeSerialize()
{
#if UNITY_EDITOR && UNITY_2019_1_OR_NEWER
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
if (!UnityEditor.EditorUtility.IsDirty(this))
return;
UnityEditor.EditorUtility.ClearDirty(this);

View File

@@ -440,11 +440,11 @@ namespace XCharts.Runtime
}
internal static ChartLabel AddTooltipIndicatorLabel(Tooltip tooltip, string name, Transform parent,
ThemeStyle theme, TextAnchor alignment)
ThemeStyle theme, TextAnchor alignment, LabelStyle labelStyle)
{
var label = ChartHelper.AddChartLabel(name, parent, tooltip.indicatorLabelStyle, theme.tooltip,
var label = ChartHelper.AddChartLabel(name, parent, labelStyle, theme.tooltip,
"", Color.clear, alignment);
label.SetActive(tooltip.show && tooltip.indicatorLabelStyle.show);
label.SetActive(tooltip.show && labelStyle.show);
return label;
}
@@ -635,12 +635,20 @@ namespace XCharts.Runtime
n++;
}
double mm = bigger;
var pown = Mathf.Pow(10, n);
var powmax = Mathf.Pow(10, n + 1);
var aliquot = mm % pown == 0;
if (mm > 10 && n < 38)
{
mm = bigger - bigger % (Mathf.Pow(10, n));
mm += max > 0 ? Mathf.Pow(10, n) : -Mathf.Pow(10, n);
mm = bigger - bigger % pown;
if (!aliquot)
mm += max > 0 ? pown : -pown;
}
var mmm = mm - Mathf.Pow(10, n) / 2;
var mmm = mm;
if (max > 100 && !aliquot && (max / mm < 0.8f))
mmm -= Mathf.Pow(10, n) / 2;
if (mmm >= (powmax - pown) && mmm < powmax)
mmm = powmax;
if (max < 0) return -Math.Ceiling(mmm > -max ? mmm : mm);
else return Math.Ceiling(mmm > max ? mmm : mm);
}
@@ -898,8 +906,10 @@ namespace XCharts.Runtime
else return valueOrRate;
}
#if UNITY_WEBGL
[DllImport("__Internal")]
private static extern void Download(string base64str, string fileName);
#endif
public static Texture2D SaveAsImage(RectTransform rectTransform, Canvas canvas, string imageType = "png", string path = "")
{

View File

@@ -23,7 +23,7 @@ namespace XCharts.Runtime
public static double SampleValue(ref List<SerieData> showData, SampleType sampleType, int rate,
int minCount, int maxCount, double totalAverage, int index, float dataChangeDuration,
ref bool dataChanging, Axis axis)
ref bool dataChanging, Axis axis, bool unscaledTime)
{
var inverse = axis.inverse;
var minValue = axis.context.minValue;
@@ -33,7 +33,7 @@ namespace XCharts.Runtime
if (showData[index].IsDataChanged())
dataChanging = true;
return showData[index].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue);
return showData[index].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
}
switch (sampleType)
{
@@ -44,7 +44,7 @@ namespace XCharts.Runtime
for (int i = index; i > index - rate; i--)
{
count++;
total += showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue);
total += showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
if (showData[i].IsDataChanged())
dataChanging = true;
}
@@ -57,7 +57,7 @@ namespace XCharts.Runtime
double max = double.MinValue;
for (int i = index; i > index - rate; i--)
{
var value = showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue);
var value = showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
if (value > max)
max = value;
@@ -70,7 +70,7 @@ namespace XCharts.Runtime
double min = double.MaxValue;
for (int i = index; i > index - rate; i--)
{
var value = showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue);
var value = showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
if (value < min)
min = value;
@@ -85,7 +85,7 @@ namespace XCharts.Runtime
total = 0;
for (int i = index; i > index - rate; i--)
{
var value = showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue);
var value = showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
total += value;
if (value < min)
min = value;
@@ -104,7 +104,7 @@ namespace XCharts.Runtime
if (showData[index].IsDataChanged())
dataChanging = true;
return showData[index].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue);
return showData[index].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
}
}
}

View File

@@ -20,8 +20,8 @@ namespace XCharts.Runtime
[ExecuteInEditMode]
public static class XChartsMgr
{
public static readonly string version = "3.3.0";
public static readonly int versionDate = 20220928;
public static readonly string version = "3.4.0";
public static readonly int versionDate = 20221101;
public static string fullVersion { get { return version + "-" + versionDate; } }
internal static List<BaseChart> chartList = new List<BaseChart>();

View File

@@ -221,7 +221,7 @@ namespace XCharts.Runtime
var state = SerieHelper.GetSerieState(serie, serieData);
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, state);
var value = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse);
var relativedValue = serieData.GetCurrData(1, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue);
var relativedValue = serieData.GetCurrData(1, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue, serie.animation.unscaledTime);
var borderWidth = relativedValue == 0 ? 0 : itemStyle.runtimeBorderWidth;
var borderGap = relativedValue == 0 ? 0 : itemStyle.borderGap;
var borderGapAndWidth = borderWidth + borderGap;

View File

@@ -162,7 +162,7 @@ namespace XCharts.Runtime
var highlight = serieData.context.highlight || serie.highlight;
var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
var value = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse);
var relativedValue = serieData.GetCurrData(1, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue);
var relativedValue = serieData.GetCurrData(1, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue, serie.animation.unscaledTime);
var borderWidth = relativedValue == 0 ? 0 : itemStyle.runtimeBorderWidth;
if (!serieData.interact.TryGetColor(ref areaColor, ref areaToColor, ref interacting))

View File

@@ -29,7 +29,7 @@ namespace XCharts.Runtime
title = category;
var color = chart.GetItemColor(serie, serieData);
var color = chart.GetMarkColor(serie, serieData);
var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker);
var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
@@ -71,7 +71,7 @@ namespace XCharts.Runtime
param.columns.Clear();
param.columns.Add(param.marker);
param.columns.Add(XCSettings.lang.GetCandlestickDimensionName(i-1));
param.columns.Add(XCSettings.lang.GetCandlestickDimensionName(i - 1));
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
paramList.Add(param);
@@ -100,6 +100,7 @@ namespace XCharts.Runtime
bool dataChanging = false;
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
double yMinValue = yAxis.context.minValue;
double yMaxValue = yAxis.context.maxValue;
var isYAxis = false;
@@ -118,10 +119,10 @@ namespace XCharts.Runtime
var state = SerieHelper.GetSerieState(serie, serieData);
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, state);
var startDataIndex = serieData.data.Count > 4 ? 1 : 0;
var open = serieData.GetCurrData(startDataIndex, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var close = serieData.GetCurrData(startDataIndex + 1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var lowest = serieData.GetCurrData(startDataIndex + 2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var heighest = serieData.GetCurrData(startDataIndex + 3, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var open = serieData.GetCurrData(startDataIndex, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
var close = serieData.GetCurrData(startDataIndex + 1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
var lowest = serieData.GetCurrData(startDataIndex + 2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
var heighest = serieData.GetCurrData(startDataIndex + 3, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
var isRise = yAxis.inverse ? close<open : close> open;
var borderWidth = open == 0 ? 0f :
(itemStyle.runtimeBorderWidth == 0 ? theme.serie.candlestickBorderWidth :

View File

@@ -29,7 +29,7 @@ namespace XCharts.Runtime
title = category;
var color = chart.GetItemColor(serie, serieData);
var color = chart.GetMarkColor(serie, serieData);
var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker);
var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
@@ -100,6 +100,7 @@ namespace XCharts.Runtime
bool dataChanging = false;
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
double yMinValue = yAxis.context.minValue;
double yMaxValue = yAxis.context.maxValue;
var isYAxis = false;
@@ -117,10 +118,10 @@ namespace XCharts.Runtime
continue;
}
var startDataIndex = serieData.data.Count > 4 ? 1 : 0;
var open = serieData.GetCurrData(startDataIndex, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var close = serieData.GetCurrData(startDataIndex + 1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var lowest = serieData.GetCurrData(startDataIndex + 2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var heighest = serieData.GetCurrData(startDataIndex + 3, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var open = serieData.GetCurrData(startDataIndex, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
var close = serieData.GetCurrData(startDataIndex + 1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
var lowest = serieData.GetCurrData(startDataIndex + 2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
var heighest = serieData.GetCurrData(startDataIndex + 3, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
var isRise = yAxis.inverse ? close<open : close> open;
var borderWidth = open == 0 ? 0f :
(itemStyle.runtimeBorderWidth == 0 ? theme.serie.candlestickBorderWidth :

View File

@@ -30,7 +30,7 @@ namespace XCharts.Runtime
[SerieDataExtraField()]
public class Heatmap : Serie, INeedSerieContainer
{
[SerializeField][Since("3.3.0")] private HeatmapType m_HeatmapType = HeatmapType.Data;
[SerializeField][Since("v3.3.0")] private HeatmapType m_HeatmapType = HeatmapType.Data;
/// <summary>
/// The mapping type of heatmap.

View File

@@ -206,6 +206,7 @@ namespace XCharts.Runtime
serie.animation.InitProgress(0, xCount);
var animationIndex = serie.animation.GetCurrIndex();
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
var dataChanging = false;
serie.containerIndex = m_SerieGrid.index;
serie.containterInstanceId = m_SerieGrid.instanceId;
@@ -242,7 +243,7 @@ namespace XCharts.Runtime
var isRectSymbol = symbol.type == SymbolType.Rect;
SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, serieData, chart.theme, state);
var value = serieData.GetCurrData(dimension, dataChangeDuration, yAxis.inverse,
yAxis.context.minValue, yAxis.context.maxValue);
yAxis.context.minValue, yAxis.context.maxValue, unscaledTime);
if (serieData.IsDataChanged()) dataChanging = true;
var pos = new Vector3(zeroX + (i + 0.5f) * xWidth,
zeroY + (j + 0.5f) * yWidth);

View File

@@ -287,6 +287,7 @@ namespace XCharts.Runtime
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
var dataChanging = false;
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
var interacting = false;
var lineWidth = LineHelper.GetLineWidth(ref interacting, serie, chart.theme.serie.lineWidth);
@@ -321,7 +322,7 @@ namespace XCharts.Runtime
var np = Vector3.zero;
var xValue = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse);
var relativedValue = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow,
maxCount, totalAverage, i, dataChangeDuration, ref dataChanging, relativedAxis);
maxCount, totalAverage, i, dataChangeDuration, ref dataChanging, relativedAxis, unscaledTime);
serieData.context.stackHeight = GetDataPoint(isY, axis, relativedAxis, m_SerieGrid, xValue, relativedValue,
i, scaleWid, isStack, ref np);

View File

@@ -505,7 +505,7 @@ namespace XCharts.Runtime
if (isY)
UGLHelper.GetBezierListVertical(ref s_CurvesPosList, sp, ep, smoothness, setting.lineSmoothStyle);
else
UGLHelper.GetBezierList(ref s_CurvesPosList, sp, ep, lsp, nep, smoothness, setting.lineSmoothStyle, true);
UGLHelper.GetBezierList(ref s_CurvesPosList, sp, ep, lsp, nep, smoothness, setting.lineSmoothStyle, serie.smoothLimit);
for (int j = 1; j < s_CurvesPosList.Count; j++)
{
serie.context.drawPoints.Add(new PointInfo(s_CurvesPosList[j], ignore));

View File

@@ -174,6 +174,7 @@ namespace XCharts.Runtime
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
var dataChanging = false;
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
var interacting = false;
var lineWidth = LineHelper.GetLineWidth(ref interacting, serie, chart.theme.serie.lineWidth);
@@ -200,7 +201,7 @@ namespace XCharts.Runtime
var np = Vector3.zero;
var xValue = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse);
var relativedValue = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow,
maxCount, totalAverage, i, dataChangeDuration, ref dataChanging, relativedAxis);
maxCount, totalAverage, i, dataChangeDuration, ref dataChanging, relativedAxis, unscaledTime);
serieData.context.stackHeight = GetDataPoint(isY, axis, relativedAxis, m_SerieGrid, xValue, relativedValue,
i, scaleWid, false, ref np);

View File

@@ -191,6 +191,7 @@ namespace XCharts.Runtime
sd.context.canShowLabel = false;
}
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
bool isAllZeroValue = SerieHelper.IsAllZeroValue(serie, 1);
var dataTotalFilterMinAngle = runtimePieDataTotal;
if (isAllZeroValue)
@@ -208,7 +209,7 @@ namespace XCharts.Runtime
for (int n = 0; n < data.Count; n++)
{
var serieData = data[n];
var value = isAllZeroValue ? zeroReplaceValue : serieData.GetCurrData(1, dataChangeDuration);
var value = isAllZeroValue ? zeroReplaceValue : serieData.GetCurrData(1, dataChangeDuration, unscaledTime);
serieData.context.startAngle = startDegree;
serieData.context.toAngle = startDegree;
serieData.context.halfAngle = startDegree;

View File

@@ -11,7 +11,7 @@ namespace XCharts.Runtime
[SerieDataExtraField()]
public class Radar : Serie, INeedSerieContainer
{
[SerializeField][Since("3.2.0")] private bool m_Smooth = false;
[SerializeField][Since("v3.2.0")] private bool m_Smooth = false;
/// <summary>
/// Whether use smooth curve.

View File

@@ -221,8 +221,10 @@ namespace XCharts.Runtime
var dataChanging = false;
var interacting = false;
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
SerieHelper.GetAllMinMaxData(serie, m_RadarCoord.ceilRate);
Color32 areaColor, areaToColor;
var startAngle = m_RadarCoord.startAngle * Mathf.PI / 180;
for (int j = 0; j < serie.data.Count; j++)
{
var serieData = serie.data[j];
@@ -246,7 +248,7 @@ namespace XCharts.Runtime
if (n >= serieData.data.Count) break;
var min = m_RadarCoord.GetIndicatorMin(n);
var max = m_RadarCoord.GetIndicatorMax(n);
var value = serieData.GetCurrData(n, dataChangeDuration);
var value = serieData.GetCurrData(n, dataChangeDuration, unscaledTime);
if (serieData.IsDataChanged()) dataChanging = true;
if (max == 0)
{
@@ -263,7 +265,7 @@ namespace XCharts.Runtime
}
}
var radius = (float) (m_RadarCoord.context.dataRadius * (value - min) / (max - min));
var currAngle = (n + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
var currAngle = startAngle + (n + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
radius *= rate;
if (n == 0)
{
@@ -361,8 +363,10 @@ namespace XCharts.Runtime
var rate = serie.animation.GetCurrRate();
var dataChanging = false;
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
var startIndex = GetStartShowIndex(serie);
var endIndex = GetEndShowIndex(serie);
var startAngle = m_RadarCoord.startAngle * Mathf.PI / 180;
SerieHelper.UpdateMinMaxData(serie, 1, m_RadarCoord.ceilRate);
for (int j = 0; j < serie.data.Count; j++)
{
@@ -383,7 +387,7 @@ namespace XCharts.Runtime
var index = serieData.index;
var p = m_RadarCoord.context.center;
var max = m_RadarCoord.GetIndicatorMax(index);
var value = serieData.GetCurrData(1, dataChangeDuration);
var value = serieData.GetCurrData(1, dataChangeDuration, unscaledTime);
if (serieData.IsDataChanged()) dataChanging = true;
if (max == 0)
{
@@ -395,7 +399,7 @@ namespace XCharts.Runtime
}
var radius = (float) (max < 0 ? m_RadarCoord.context.dataRadius - m_RadarCoord.context.dataRadius * value / max :
m_RadarCoord.context.dataRadius * value / max);
var currAngle = (index + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
var currAngle = startAngle + (index + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
radius *= rate;
if (index == startIndex)
{

View File

@@ -182,6 +182,7 @@ namespace XCharts.Runtime
serie.animation.InitProgress(serie.startAngle, serie.startAngle + 360);
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
var ringWidth = serie.context.outsideRadius - serie.context.insideRadius;
var dataChanging = false;
for (int j = 0; j < data.Count; j++)
@@ -189,7 +190,7 @@ namespace XCharts.Runtime
var serieData = data[j];
if (!serieData.show) continue;
if (serieData.IsDataChanged()) dataChanging = true;
var value = serieData.GetFirstData(dataChangeDuration);
var value = serieData.GetFirstData(unscaledTime, dataChangeDuration);
var max = serieData.GetLastData();
var degree = (float) (360 * value / max);
var startDegree = GetStartAngle(serie);

View File

@@ -37,7 +37,7 @@ namespace XCharts.Runtime
param.dimension = 1;
param.dataCount = serie.dataCount;
param.serieData = serieData;
param.color = chart.GetItemColor(serie, serieData);
param.color = chart.GetMarkColor(serie, serieData);
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
@@ -135,6 +135,7 @@ namespace XCharts.Runtime
serie.animation.InitProgress(0, 1);
var rate = serie.animation.GetCurrRate();
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
var dataChanging = false;
var interacting = false;
var dataList = serie.GetDataList(xDataZoom);
@@ -157,8 +158,8 @@ namespace XCharts.Runtime
SerieHelper.GetItemColor(out color, out toColor, out emptyColor, serie, serieData, chart.theme, colorIndex, state);
SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, serieData, chart.theme, state);
double xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
double yValue = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
double xValue = serieData.GetCurrData(0, dataChangeDuration, unscaledTime, xAxis.inverse);
double yValue = serieData.GetCurrData(1, dataChangeDuration, unscaledTime, yAxis.inverse);
if (serieData.IsDataChanged())
dataChanging = true;
@@ -238,6 +239,7 @@ namespace XCharts.Runtime
var rate = serie.animation.GetCurrRate();
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
var dataChanging = false;
var dataList = serie.GetDataList(xDataZoom);
var isEffectScatter = serie is EffectScatter;
@@ -263,7 +265,7 @@ namespace XCharts.Runtime
dataChanging = true;
var pos = Vector3.zero;
var xValue = serieData.GetCurrData(0, dataChangeDuration, axis.inverse);
var xValue = serieData.GetCurrData(0, dataChangeDuration, unscaledTime, axis.inverse);
if (axis.orient == Orient.Horizonal)
{

View File

@@ -11,9 +11,10 @@ namespace XCharts.Runtime
{
base.Update();
var symbolSize = serie.symbol.GetSize(null, chart.theme.serie.scatterSymbolSize);
var deltaTime = serie.animation.unscaledTime? Time.unscaledDeltaTime : Time.deltaTime;
for (int i = 0; i < serie.symbol.animationSize.Count; ++i)
{
serie.symbol.animationSize[i] += m_EffectScatterSpeed * Time.deltaTime;
serie.symbol.animationSize[i] += m_EffectScatterSpeed * deltaTime;
if (serie.symbol.animationSize[i] > symbolSize)
{
serie.symbol.animationSize[i] = i * 5;

View File

@@ -230,6 +230,7 @@ namespace XCharts.Runtime
[SerializeField] private string m_SerieName;
[SerializeField][Since("v3.2.0")] private SerieState m_State = SerieState.Normal;
[SerializeField][Since("v3.2.0")] private SerieColorBy m_ColorBy = SerieColorBy.Default;
[SerializeField][Since("v3.4.0")] private Color32 m_MarkColor;
[SerializeField] private string m_Stack;
[SerializeField] private int m_XAxisIndex = 0;
[SerializeField] private int m_YAxisIndex = 0;
@@ -247,6 +248,7 @@ namespace XCharts.Runtime
[SerializeField] private float m_SampleAverage = 0;
[SerializeField] private LineType m_LineType = LineType.Normal;
[SerializeField][Since("v3.4.0")] private bool m_SmoothLimit = true;
[SerializeField] private BarType m_BarType = BarType.Normal;
[SerializeField] private bool m_BarPercentStack = false;
[SerializeField] private float m_BarWidth = 0;
@@ -373,6 +375,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_ColorBy, value)) { SetAllDirty(); } }
}
/// <summary>
/// Serie's mark color. It is only used to display Legend and Tooltip, and does not affect the drawing color. The default value is clear.
/// |Serie的标识颜色。仅用于Legend和Tooltip的展示不影响绘制颜色默认为clear。
/// </summary>
public Color32 markColor
{
get { return m_MarkColor; }
set { if (PropertyUtil.SetStruct(ref m_MarkColor, value)) { SetAllDirty(); } }
}
/// <summary>
/// If stack the value. On the same category axis, the series with the same stack name would be put on top of each other.
/// |数据堆叠同个类目轴上系列配置相同的stack值后后一个系列的值会在前一个系列的值上相加。
/// </summary>
@@ -492,6 +503,16 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
}
/// <summary>
/// Whether to restrict the curve. When true, the curve between two continuous data of the same value
/// is restricted to not exceed the data point, and is flat to the data point.
/// |是否限制曲线。当为true时两个连续相同数值的数据间的曲线会限制为不超出数据点和数据点是平直的。
/// </summary>
public bool smoothLimit
{
get { return m_SmoothLimit; }
set { if (PropertyUtil.SetStruct(ref m_SmoothLimit, value)) { SetVerticesDirty(); } }
}
/// <summary>
/// the min pixel dist of sample.
/// |采样的最小像素距离默认为0时不采样。当两个数据点间的水平距离小于改值时开启采样保证两点间的水平距离不小于改值。
/// </summary>
@@ -1125,10 +1146,11 @@ namespace XCharts.Runtime
else
{
var duration = animation.GetUpdateAnimationDuration();
var unscaledTime = animation.unscaledTime;
foreach (var sdata in data)
{
if (sdata.show && !IsIgnoreValue(sdata.data[1]))
total += sdata.GetCurrData(1, duration);
total += sdata.GetCurrData(1, duration, unscaledTime);
}
}
return total;
@@ -1351,6 +1373,40 @@ namespace XCharts.Runtime
}
}
/// <summary>
/// 添加任意维数据到系列中。
/// </summary>
/// <param name="values">任意维数据</param>
/// <returns></returns>
public SerieData AddData(params double[] values)
{
if (values == null || values.Length == 0) return null;
string dataName = null;
string dataId = null;
if (values.Length == 1)
return AddYData(values[0], dataName, dataId);
else if (values.Length == 2)
return AddXYData(values[0], values[1], dataName, dataId);
else
{
CheckMaxCache();
m_ShowDataDimension = values.Length;
var serieData = SerieDataPool.Get();
serieData.name = dataName;
serieData.index = m_Data.Count;
serieData.id = dataId;
for (int i = 0; i < values.Length; i++)
{
serieData.data.Add(values[i]);
}
AddSerieData(serieData);
SetVerticesDirty();
CheckDataName(dataName);
labelDirty = true;
return serieData;
}
}
public SerieData AddChildData(SerieData parent, double value, string name, string id)
{
var serieData = new SerieData();
@@ -1448,7 +1504,7 @@ namespace XCharts.Runtime
var serieData = GetDataList(dataZoom);
if (index < serieData.Count)
{
var value = serieData[index].GetCurrData(1, animation.GetUpdateAnimationDuration());
var value = serieData[index].GetCurrData(1, animation.GetUpdateAnimationDuration(), animation.unscaledTime);
if (showAsPositiveNumber)
value = Math.Abs(value);
return value;
@@ -1611,7 +1667,8 @@ namespace XCharts.Runtime
{
var animationOpen = animation.enable;
var animationDuration = animation.GetUpdateAnimationDuration();
var flag = m_Data[index].UpdateData(dimension, value, animationOpen, animationDuration);
var unscaledTime = animation.unscaledTime;
var flag = m_Data[index].UpdateData(dimension, value, animationOpen, unscaledTime, animationDuration);
if (flag)
{
SetVerticesDirty();
@@ -1637,8 +1694,9 @@ namespace XCharts.Runtime
var serieData = m_Data[index];
var animationOpen = animation.enable;
var animationDuration = animation.GetUpdateAnimationDuration();
var unscaledTime = animation.unscaledTime;
for (int i = 0; i < values.Count; i++)
serieData.UpdateData(i, values[i], animationOpen, animationDuration);
serieData.UpdateData(i, values[i], animationOpen, unscaledTime, animationDuration);
SetVerticesDirty();
dataDirty = true;
return true;

View File

@@ -381,9 +381,9 @@ namespace XCharts.Runtime
else return 0;
}
public double GetFirstData(float animationDuration = 500f)
public double GetFirstData(bool unscaledTime, float animationDuration = 500f)
{
if (m_Data.Count > 0) return GetCurrData(0, animationDuration);
if (m_Data.Count > 0) return GetCurrData(0, animationDuration, unscaledTime);
return 0;
}
@@ -393,23 +393,23 @@ namespace XCharts.Runtime
return 0;
}
public double GetCurrData(int index, float animationDuration = 500f, bool inverse = false)
public double GetCurrData(int index, float animationDuration = 500f, bool unscaledTime = false, bool inverse = false)
{
return GetCurrData(index, animationDuration, inverse, 0, 0);
return GetCurrData(index, animationDuration, inverse, 0, 0, unscaledTime);
}
public double GetCurrData(int index, float animationDuration, bool inverse, double min, double max)
public double GetCurrData(int index, float animationDuration, bool inverse, double min, double max, bool unscaledTime)
{
if (index < m_DataUpdateFlag.Count && m_DataUpdateFlag[index] && animationDuration > 0)
{
var time = Time.time - m_DataUpdateTime[index];
var time = (unscaledTime ? Time.unscaledTime : Time.time) - m_DataUpdateTime[index];
var total = animationDuration / 1000;
var rate = time / total;
if (rate > 1) rate = 1;
if (rate < 1)
{
CheckLastData();
CheckLastData(unscaledTime);
var curr = MathUtil.Lerp(GetPreviousData(index), GetData(index), rate);
if (min != 0 || max != 0)
{
@@ -503,14 +503,14 @@ namespace XCharts.Runtime
return total;
}
public bool UpdateData(int dimension, double value, bool updateAnimation, float animationDuration = 500f)
public bool UpdateData(int dimension, double value, bool updateAnimation, bool unscaledTime, float animationDuration = 500f)
{
if (dimension >= 0 && dimension < data.Count)
{
CheckLastData();
m_PreviousData[dimension] = GetCurrData(dimension, animationDuration);
CheckLastData(unscaledTime);
m_PreviousData[dimension] = GetCurrData(dimension, animationDuration, unscaledTime);
//m_PreviousData[dimension] = data[dimension];;
m_DataUpdateTime[dimension] = Time.time;
m_DataUpdateTime[dimension] = (unscaledTime ? Time.unscaledTime : Time.time);
m_DataUpdateFlag[dimension] = updateAnimation;
data[dimension] = value;
return true;
@@ -528,7 +528,7 @@ namespace XCharts.Runtime
return false;
}
private void CheckLastData()
private void CheckLastData(bool unscaledTime)
{
if (m_PreviousData.Count != m_Data.Count)
{
@@ -538,7 +538,7 @@ namespace XCharts.Runtime
for (int i = 0; i < m_Data.Count; i++)
{
m_PreviousData.Add(m_Data[i]);
m_DataUpdateTime.Add(Time.time);
m_DataUpdateTime.Add((unscaledTime ? Time.unscaledTime : Time.time));
m_DataUpdateFlag.Add(false);
}
}

View File

@@ -368,6 +368,7 @@ namespace XCharts.Runtime
return;
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var unscaledTime = serie.animation.unscaledTime;
var needCheck = serie.context.dataIndexs.Count > 0;
foreach (var serieData in serie.data)
{
@@ -395,7 +396,7 @@ namespace XCharts.Runtime
{
if (i >= serieData.context.dataPoints.Count) continue;
var labelObject = serieData.context.dataLabels[i];
var value = serieData.GetCurrData(i, dataChangeDuration);
var value = serieData.GetCurrData(i, dataChangeDuration, unscaledTime);
var content = string.IsNullOrEmpty(currLabel.formatter) ?
ChartCached.NumberToStr(value, currLabel.numericFormatter) :
SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
@@ -415,7 +416,7 @@ namespace XCharts.Runtime
}
else
{
var value = serieData.GetCurrData(defaultDimension, dataChangeDuration);
var value = serieData.GetCurrData(defaultDimension, dataChangeDuration, unscaledTime);
var total = serie.GetDataTotal(defaultDimension, serieData);
var color = chart.GetItemColor(serie, serieData);
var content = string.IsNullOrEmpty(currLabel.formatter) ?
@@ -527,7 +528,7 @@ namespace XCharts.Runtime
param.value = serieData.GetData(dimension);
param.ignore = ignore;
param.total = serie.yTotal;
param.color = chart.GetItemColor(serie, serieData);
param.color = chart.GetMarkColor(serie, serieData);
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
param.itemFormatter = itemFormatter;
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);

View File

@@ -106,9 +106,16 @@ namespace XCharts.Runtime
break;
}
}
Color32 color, toColor;
SerieHelper.GetItemColor(out color, out toColor, destSerie, destSerieData, chart.theme, index, SerieState.Normal);
return color;
if (ChartHelper.IsClearColor(destSerie.markColor))
{
Color32 color, toColor;
SerieHelper.GetItemColor(out color, out toColor, destSerie, destSerieData, chart.theme, index, SerieState.Normal);
return color;
}
else
{
return destSerie.markColor;
}
}
/// <summary>
@@ -339,6 +346,7 @@ namespace XCharts.Runtime
(!isPolar && serie.yAxisIndex != axisIndex) ||
!serie.show) continue;
var updateDuration = serie.animation.enable?serie.animation.dataChangeDuration : 0;
var unscaledTime = serie.animation.unscaledTime;
if (isPercentStack && SeriesHelper.IsPercentStack<Bar>(series, serie.serieName))
{
if (100 > max) max = 100;
@@ -363,7 +371,7 @@ namespace XCharts.Runtime
foreach (var data in showData)
{
var currData = performanceMode? data.GetData(yValue?1 : 0, inverse):
data.GetCurrData(yValue ? 1 : 0, updateDuration, inverse);
data.GetCurrData(yValue ? 1 : 0, updateDuration, unscaledTime, inverse);
if (!serie.IsIgnoreValue(currData))
{
if (currData > max) max = currData;

View File

@@ -1695,10 +1695,14 @@ namespace XUGL
if (isGradient)
{
var tcolor = Color32.Lerp(color, toColor, i * 1.0f / segments);
if (i == 0 && (needSpace || needBorder))
UGL.DrawTriangle(vh, p1, p2, p3, color, tcolor, tcolor);
AddVertToVertexHelper(vh, p3, p4, tcolor, tcolor, i > 0);
}
else
{
if (i == 0 && (needSpace || needBorder))
UGL.DrawTriangle(vh, p1, p2, p3, color);
AddVertToVertexHelper(vh, p3, p4, color, color, i > 0);
}
p1 = p4;

View File

@@ -1,9 +1,9 @@
{
"name": "com.monitor1394.xcharts",
"displayName": "XCharts",
"version": "3.3.0",
"date": "20220928",
"checkdate": "20220928",
"version": "3.4.0",
"date": "20221101",
"checkdate": "20221101",
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
"unity": "2018.3",
"description": "A charting and data visualization library for Unity.",