This commit is contained in:
monitor1394
2022-06-01 07:59:00 +08:00
parent 9549159a58
commit 6e87f82131
13 changed files with 267 additions and 62 deletions

View File

@@ -2,6 +2,7 @@
# 更新日志
[master](#master)
[v3.0.0](#v3.0.0)
[v3.0.0-preivew9](#v3.0.0-preivew9)
[v3.0.0-preivew8](#v3.0.0-preivew8)
[v3.0.0-preivew7](#v3.0.0-preivew7)
@@ -52,7 +53,27 @@
## master
* (2022.05.06) 修复代码动态创建图表异常的问题
## v3.0.0
* 更健壮的底层框架。
* 更强大的性能。
* 更小的序列化文件。
* 更好的交互体验。
* 更多的组件支持。
* 更强大的文本自述能力。
* 更合理的组件调整。
* 更灵活的组件插拔。
* 更高效的二次开发。
* 更丰富的Demo示例。
* 增加`Time`时间轴。
* 增加`SingleAxis`单轴。
* 增加`Comment`文本组件。
* 增加`Widgets`小组件。
* 增加多种坐标系:`Grid``Polar``Radar``SingleAxis`
* 增加多种动画方式。
* 增加多种图表交互。
* 增加国际化支持。
* 增加多种扩展图表。
## v3.0.0-preivew9

View File

@@ -2,6 +2,7 @@
# 更新日志
[master](#master)
[v3.0.0](#v3.0.0)
[v2.3.0](#v2.3.0)
[v2.2.3](#v2.2.3)
[v2.2.2](#v2.2.2)
@@ -37,22 +38,26 @@
[v0.5.0](#v0.5.0)
[v0.1.0](#v0.1.0)
## master
## v3.0.0
* (2022.04.23) Remove `Serie` `IconStyle` component
* (2022.04.23) Enhance `LabelStyle`, all components `TextStyle` will be upgraded to `LabelStyle`
* (2022.04.19) Added `Label` `rotate` to support setting rotation
* (2022.04.17) Fixed animation invalidation of `Bar` when the value is negative
* (2022.04.17) Added `BorderGap` support for `ItemStyle` to set border spacing
* (2022.04.16) Optimize the `Border` and `Capsule` histogram of `Bar`
* (2021.08.15) Fixed the problem of displaying exceptions after adding data again when `DataZoom` is enable (#163)
* (2021.08.15) Improved `Axis`'s `AxisLabel` text rotate setting to avoid inconsistency offset in `DataZoom` (#163)
* (2021.08.14) Added `Legend`'s `textAutoColor` to set the text color match with `Serie` color (#163)
* (2021.08.12) Optimize `BarChart` setting `Corner` when the positive and negative columns are fillet symmetric
* (2021.08.03) Fixed y axis not displaying when all data is 0
* (2021.07.29) Fixed ignored data will also participate in calculations when `ignore` is enabled (#161)
* (2021.07.29) Improved `BarChart`'s `Zebra` gradient support
* (2021.07.26) Fixed issue where `XCharts` path could not be found when `TextMeshPro Enable` (#160)
* More robust underlying framework.
* More powerful performance.
* Smaller serialized files.
* Better interactive experience.
* More component support.
* More powerful ability to self-report text.
* More reasonable component adjustments.
* More flexible component insertion and removal.
* More efficient secondary development.
* Richer Demo examples.
* Added `Time` axis.
* Added `SingleAxis`.
* Added multiple coordinate systems: `Grid`, `Polar`, `Radar`, `SingleAxis`.
* Added multiple animation methods.
* Added multiple chart interactions.
* Added internationalization support.
* Added `Widgets`.
* Added multiple extension charts.
## v2.3.0

View File

@@ -0,0 +1,141 @@
<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>
</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">
</a>
<a href="https://github.com/XCharts-Team/XCharts/releases">
<img src="https://img.shields.io/github/v/release/XCharts-Team/XCharts?include_prereleases">
</a>
<a href="">
<img src="https://img.shields.io/github/repo-size/monitor1394/unity-ugui-xcharts">
</a>
<a href="">
<img src="https://img.shields.io/github/languages/code-size/monitor1394/unity-ugui-xcharts">
</a>
<a href="">
<img src="https://img.shields.io/badge/Unity-5.6+-green">
</a>
<a href="">
<img src="https://img.shields.io/badge/TextMeshPro-YES-green">
</a>
</p>
<p align="center">
<a href="">
<img src="https://img.shields.io/github/stars/XCharts-Team/XCharts?style=social">
</a>
<a href="">
<img src="https://img.shields.io/github/forks/XCharts-Team/XCharts?style=social">
</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">
</a>
</p>
A powerful, easy-to-use, configurable charting and data visualization library for Unity. Supporting line, bar, pie, radar, scatter, heatmap, ring, candlestick, polar, liquid and other common chart. Also support 3d pie, 3d bar, 3d pyramid, funnel, gauge, liquid, pictorialbar, gantt, treemap and ther extended chart.
[XCharts3.0 Tutorial](XChartsTutorial01-EN.md)
[XCharts3.0 API](XChartsAPI-EN.md)
[XCharts3.0 FAQ](XChartsFAQ-EN.md)
[XCharts3.0 Configurate](XChartsConfiguration-EN.md)
[XCharts3.0 Changelog](../CHANGELOG.md)
[XCharts3.0 Support](SUPPORT.md)
## Features
* Rich built-in examples and templates, parameter visualization configuration, effect real-time preview, pure code drawing.
* Support line, bar, pie, radar, scatter, heatmaps, gauge, ring, polar, liquid and other common chart.
* Support line graph, curve graph, area graph, step graph and other LineChart.
* Support parallel bar, stack bar, stack percentage bar, zebra bar and other BarChart.
* Support ring, rose and other PieChart.
* Support line-bar chart, scatter-line chart and other combination chart.
* Support solid line, curve, ladder line, dotted line, dash line, dot line, double dot line and other lines.
* Support custom theme, built-in theme switching.
* Support custom chart content drawing, drawing points, line, curve, triangle, quadrilateral, circle, ring, sector, border, arrow and other drawing API.
* Support interactive operations such as data filtering, view zooming and detail display on PC and mobile terminals.
* Support 10,000-level big data rendering.
* Support TextMeshPro.
## XCharts3.0 new feature
* Added `Time` axis.
* Added `SingleAxis`.
* Added multiple coordinate systems: `Grid`, `Polar`, `Radar`, `SingleAxis`.
* Added multiple animation methods.
* Added multiple chart interactions.
* Added internationalization support.
* Added `Widgets`.
* Added multiple extension charts.
## XCharts3.0 improvements over XCharts2.0
* More robust underlying framework.
* More powerful performance.
* Smaller serialized files.
* Better interactive experience.
* More component support.
* More powerful ability to self-report text.
* More reasonable component adjustments.
* More flexible component insertion and removal.
* More efficient secondary development.
* Richer Demo examples.
## XCharts3.0 and 2.0 data comparison
| Case | XCharts2.0 | XCharts3.0 | Note |
| -- | -- | -- | -- |
| Fps of 2000 data line chart | ` 20 ` | ` 83 ` | Performance improvements `3` times |
| Vertices of 2000 data line chart | ` 36.5 k ` | ` 6.7 k ` | Vertices reduce `4` times |
| Prefab size of 2000 data line chart | ` 11.1 MB ` | ` 802 KB ` | Serialized file size to reduce `10` times |
| Max data of a single line chart | ` 4.1 k ` | ` 19 k ` | Single Serie data capacity improvement `4` times |
| Num of chart support | ` 11 ` | ` 23 ` | More than `1` times as many chart are supported |
## Screenshots
![buildinchart](https://github.com/XCharts-Team/XCharts-Demo/blob/master/buildinchart.png)
![extendchart](https://github.com/XCharts-Team/XCharts-Demo/blob/master/extendchart.png)
For more examples, see [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo), You can also go to [Online Demo](https://xcharts-team.github.io/demo/) to see the running effect of `WebGL`.
## Use
1. Import `XCharts` unitypackage or source code into the project.
2. Right-click `Hierarchy` view and choose `XCharts->LineChart` to create a default LineChart.
3. You can adjust the parameters of each component in `Inspector` and see the real-time effects in `Game` view.
See more tutorial: [XCharts tutorial: 5 minutes overhand tutorial](XChartsTutorial01-EN.md)
## FAQ
1. Is `XCharts` free to use?
A: `XCharts` uses the `MIT` licence and is free to use. You can also subscribe to `VIP` to enjoy more value-added services.
2. Does `XCharts` support code to dynamically add and modify data? Does it support getting data from `Excel` or a database?
A: Support code to dynamically add and modify data, but data needs to be parsed or retrieved by itself, and then added to `XCharts` by calling the public interface of `XCharts`.
3. Does this plugin work on other platforms (e.g. Winform or WPF) besides Unity?
A: It is currently only supported on Unity. Theoretically any version of Unity that supports `UGUI` can run `XCharts`.
## Changelog
[Changelog](CHANGELOG.md)
## Licenses
[MIT License](LICENSE.md)
## Other
email: `monitor1394@gmail.com`

View File

@@ -696,7 +696,6 @@ Inherits or Implemented: [BaseChart](#BaseChart)
|public method|description|
|--|--|
| `CopyFolder()` |public static bool CopyFolder(string sourPath, string destPath)</br> |
| `GetAllAssemblyTypes()` |public static IEnumerable<Type> GetAllAssemblyTypes()</br> |
| `GetAllTypesDerivedFrom()` |public static IEnumerable<Type> GetAllTypesDerivedFrom(Type type)</br> |
| `GetAllTypesDerivedFrom<T>()` |public static IEnumerable<Type> GetAllTypesDerivedFrom<T>()</br> |

View File

@@ -696,7 +696,6 @@ Inherits or Implemented: [BaseChart](#BaseChart)
|public method|description|
|--|--|
| `CopyFolder()` |public static bool CopyFolder(string sourPath, string destPath)</br> |
| `GetAllAssemblyTypes()` |public static IEnumerable<Type> GetAllAssemblyTypes()</br> |
| `GetAllTypesDerivedFrom()` |public static IEnumerable<Type> GetAllTypesDerivedFrom(Type type)</br> |
| `GetAllTypesDerivedFrom<T>()` |public static IEnumerable<Type> GetAllTypesDerivedFrom<T>()</br> |

View File

@@ -711,7 +711,7 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent
|field|default|comment|
|--|--|--|
| `show` |true | Whether the label line is showed. |
| `lineType` | | the type of visual guide line.</br>`LineType`:</br>- `Normal`: the normal line chart 普通折线图。</br>- `Smooth`: the smooth line chart 平滑曲线。</br>- `StepStart`: step line.</br>- `StepMiddle`: step line.</br>- `StepEnd`: step line.</br>|
| `lineType` | | the type of visual guide line.</br>`LineType`:</br>- `Normal`: the normal line chart</br>- `Smooth`: the smooth line chart</br>- `StepStart`: step line.</br>- `StepMiddle`: step line.</br>- `StepEnd`: step line.</br>|
| `lineColor` |ChartConst.clearColor32 | the color of visual guild line. |
| `lineAngle` |0 | the angle of visual guild line. |
| `lineWidth` |1.0f | the width of visual guild line. |
@@ -1048,8 +1048,8 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
| `sampleDist` |0 | the min pixel dist of sample. |
| `sampleType` | | the type of sample.</br>`SampleType`:</br>- `Peak`: Take a peak. When the average value of the filter point is greater than or equal to 'sampleAverage', take the maximum value; If you do it the other way around, you get the minimum.</br>- `Average`: Take the average of the filter points.</br>- `Max`: Take the maximum value of the filter point.</br>- `Min`: Take the minimum value of the filter point.</br>- `Sum`: Take the sum of the filter points.</br>|
| `sampleAverage` |0 | 设定的采样平均值。当sampleType 为 Peak 时用于和过滤数据的平均值做对比是取最大值还是最小值。默认为0时会实时计算所有数据的平均值。 |
| `lineType` | | The type of line chart.</br>`LineType`:</br>- `Normal`: the normal line chart 普通折线图。</br>- `Smooth`: the smooth line chart 平滑曲线。</br>- `StepStart`: step line.</br>- `StepMiddle`: step line.</br>- `StepEnd`: step line.</br>|
| `barType` | | 柱形图类型。</br>`BarType`:</br>- `Normal`: 普通柱形图</br>- `Zebra`: 斑马柱形图</br>- `Capsule`: 胶囊柱形图</br>|
| `lineType` | | The type of line chart.</br>`LineType`:</br>- `Normal`: the normal line chart</br>- `Smooth`: the smooth line chart</br>- `StepStart`: step line.</br>- `StepMiddle`: step line.</br>- `StepEnd`: step line.</br>|
| `barType` | | 柱形图类型。</br>`BarType`:</br>- `Normal`: normal bar.</br>- `Zebra`: zebra bar.</br>- `Capsule`: capsule bar.</br>|
| `barPercentStack` |false | 柱形图是否为百分比堆积。相同stack的serie只要有一个barPercentStack为true则就显示成百分比堆叠柱状图。 |
| `barWidth` |0 | The width of the bar. Adaptive when default 0. |
| `barGap` |0.1f | The gap between bars between different series, is a percent value like '0.3f' , which means 30% of the bar width, can be set as a fixed value. |
@@ -1066,7 +1066,7 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
| `roundCap` | | 是否开启圆弧效果。 |
| `splitNumber` | | 刻度分割段数。最大可设置36。 |
| `clickOffset` |true | Whether offset when mouse click pie chart item. |
| `roseType` | | Whether to show as Nightingale chart.</br>`RoseType`:</br>- `None`: Don't show as Nightingale chart.不展示成南丁格尔玫瑰图</br>- `Radius`: Use central angle to show the percentage of data, radius to show data size.</br>- `Area`: All the sectors will share the same central angle, the data size is shown only through radiuses.</br>|
| `roseType` | | Whether to show as Nightingale chart.</br>`RoseType`:</br>- `None`: Don't show as Nightingale chart.</br>- `Radius`: Use central angle to show the percentage of data, radius to show data size.</br>- `Area`: All the sectors will share the same central angle, the data size is shown only through radiuses.</br>|
| `gap` | | gap of item. |
| `center` | | the center of chart. |
| `radius` | | the radius of chart. |
@@ -1081,7 +1081,7 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
| `large` |true | 是否开启大数据量优化,在数据图形特别多而出现卡顿时候可以开启。 开启后配合 largeThreshold 在数据量大于指定阈值的时候对绘制进行优化。 缺点优化后不能自定义设置单个数据项的样式不能显示Label。 |
| `largeThreshold` |200 | 开启大数量优化的阈值。只有当开启了large并且数据量大于该阀值时才进入性能模式。 |
| `avoidLabelOverlap` |false | 在饼图且标签外部显示的情况下,是否启用防止标签重叠策略,默认关闭,在标签拥挤重叠的情况下会挪动各个标签的位置,防止标签间的重叠。 |
| `radarType` | | 雷达图类型。</br>`RadarType`:</br>- `Multiple`: 多圈雷达图。此时可一个雷达里绘制多个圈一个serieData就可组成一个圈多维数据。</br>- `Single`: 单圈雷达图。此时一个雷达只能绘制一个圈多个serieData组成一个圈数据取自`data[1]`</br>|
| `radarType` | | 雷达图类型。</br>`RadarType`:</br>- `Multiple`: multiple radar.</br>- `Single`: single radar.</br>|
| `placeHolder` |false | 占位模式。占位模式时,数据有效但不参与渲染和显示。 |
| `dataSortType` | | 组件的数据排序。</br>`SerieDataSortType`:</br>- `None`: 按 data 的顺序</br>- `Ascending`: 升序</br>- `Descending`: 降序</br>|
| `orient` | | 组件的朝向。</br>`Orient`:</br>- `Horizonal`: 水平</br>- `Vertical`: 垂直</br>|

View File

@@ -711,7 +711,7 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent
|field|default|comment|
|--|--|--|
| `show` |true | 是否显示视觉引导线。 |
| `lineType` | | 视觉引导线类型。</br>`LineType`:</br>- `Normal`: the normal line chart 普通折线图。</br>- `Smooth`: the smooth line chart 平滑曲线。</br>- `StepStart`: 阶梯线图:当前点。</br>- `StepMiddle`: 阶梯线图:当前点和下一个点的中间。</br>- `StepEnd`: 阶梯线图:下一个拐点。</br>|
| `lineType` | | 视觉引导线类型。</br>`LineType`:</br>- `Normal`: 普通折线图。</br>- `Smooth`: 平滑曲线。</br>- `StepStart`: 阶梯线图:当前点。</br>- `StepMiddle`: 阶梯线图:当前点和下一个点的中间。</br>- `StepEnd`: 阶梯线图:下一个拐点。</br>|
| `lineColor` |ChartConst.clearColor32 | 视觉引导线颜色。默认和serie一致取自调色板。 |
| `lineAngle` |0 | 视觉引导线的固定角度。对折线和曲线有效。 |
| `lineWidth` |1.0f | 视觉引导线的宽度。 |
@@ -1048,8 +1048,8 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
| `sampleDist` |0 | 采样的最小像素距离默认为0时不采样。当两个数据点间的水平距离小于改值时开启采样保证两点间的水平距离不小于改值。 |
| `sampleType` | | 采样类型。当sampleDist大于0时有效。</br>`SampleType`:</br>- `Peak`: 取峰值。</br>- `Average`: 取过滤点的平均值。</br>- `Max`: 取过滤点的最大值。</br>- `Min`: 取过滤点的最小值。</br>- `Sum`: 取过滤点的和。</br>|
| `sampleAverage` |0 | 设定的采样平均值。当sampleType 为 Peak 时用于和过滤数据的平均值做对比是取最大值还是最小值。默认为0时会实时计算所有数据的平均值。 |
| `lineType` | | 折线图样式类型。</br>`LineType`:</br>- `Normal`: the normal line chart 普通折线图。</br>- `Smooth`: the smooth line chart 平滑曲线。</br>- `StepStart`: 阶梯线图:当前点。</br>- `StepMiddle`: 阶梯线图:当前点和下一个点的中间。</br>- `StepEnd`: 阶梯线图:下一个拐点。</br>|
| `barType` | | 柱形图类型。</br>`BarType`:</br>- `Normal`: 普通柱形图</br>- `Zebra`: 斑马柱形图</br>- `Capsule`: 胶囊柱形图</br>|
| `lineType` | | 折线图样式类型。</br>`LineType`:</br>- `Normal`: 普通折线图。</br>- `Smooth`: 平滑曲线。</br>- `StepStart`: 阶梯线图:当前点。</br>- `StepMiddle`: 阶梯线图:当前点和下一个点的中间。</br>- `StepEnd`: 阶梯线图:下一个拐点。</br>|
| `barType` | | 柱形图类型。</br>`BarType`:</br>- `Normal`: 普通柱形图</br>- `Zebra`: 斑马柱形图</br>- `Capsule`: 胶囊柱形图</br>|
| `barPercentStack` |false | 柱形图是否为百分比堆积。相同stack的serie只要有一个barPercentStack为true则就显示成百分比堆叠柱状图。 |
| `barWidth` |0 | 柱条的宽度,不设时自适应。支持设置成相对于类目宽度的百分比。 |
| `barGap` |0.1f | <para>Set barGap as '-1' can overlap bars that belong to different series, which is useful when making a series of bar be background. |
@@ -1066,7 +1066,7 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
| `roundCap` | | 是否开启圆弧效果。 |
| `splitNumber` | | 刻度分割段数。最大可设置36。 |
| `clickOffset` |true | 鼠标点击时是否开启偏移一般用在PieChart图表中。 |
| `roseType` | | 是否展示成南丁格尔图,通过半径区分数据大小。</br>`RoseType`:</br>- `None`: Don't show as Nightingale chart.不展示成南丁格尔玫瑰图</br>- `Radius`: 扇区圆心角展现数据的百分比,半径展现数据的大小。</br>- `Area`: 所有扇区圆心角相同,仅通过半径展现数据大小。</br>|
| `roseType` | | 是否展示成南丁格尔图,通过半径区分数据大小。</br>`RoseType`:</br>- `None`: 不展示成南丁格尔玫瑰图</br>- `Radius`: 扇区圆心角展现数据的百分比,半径展现数据的大小。</br>- `Area`: 所有扇区圆心角相同,仅通过半径展现数据大小。</br>|
| `gap` | | 间距。 |
| `center` | | 中心点。 |
| `radius` | | 半径。radius[0]表示内径radius[1]表示外径。 |

View File

@@ -7,56 +7,58 @@
## 获取和导入 XCharts
1. 直接放入XCharts源码到项目
XCharts可通过以下任意一种方式导入到项目
- 直接将XCharts源码到项目
下载好XCharts源码后直接将XCharts目录拷贝到Unity项目工程的Assets目录下。
2. 通过`Assets/Import Package`导入XCharts
- 通过`Assets/Import Package`导入XCharts
下载好XCharts的.unitypackage文件后打开Unity菜单栏 Assets-->Import Package-->选中.unitypackage导入即可开始使用XCharts。
3. 通过`Package Manager`导入XCharts
- 通过`Package Manager`导入XCharts
对于Unity 2018.3以上版本,可通过 Package Manager来导入XCharts打开Package Manager后通过 `Add package form git URL...`输入XCharts的github URL: https://github.com/XCharts-Team/XCharts.git#master 稍等片刻后即可使用XCharts。
对于Unity 2018.3以上版本,可通过 Package Manager来导入XCharts打开Package Manager后通过 `Add package form git URL...`输入XCharts3.0的GitHub URL: `https://github.com/XCharts-Team/XCharts.git#3.0` 稍等片刻后即可使用XCharts。
也可以直接将package加入到`manifest.json`文件:打开`Packages`目录下的`manifest.json`文件,在`dependencies`下加入:
``` json
"com.monitor1394.xcharts": "https://github.com/XCharts-Team/XCharts.git#master",
"com.monitor1394.xcharts": "https://github.com/XCharts-Team/XCharts.git#3.0",
```
如需更新`XCharts`,删除`manifest.json`文件部分Unity版本可能是packages-lock.json文件的`lock`下的`com.monitor1394.xcharts`相关内容即会重新下载编译。
## 添加一个简单图表
在`Hierarchy`图下右键或菜单栏`GameObject`下拉`XCharts->LineChart`
![op_addchart](res/op_addchart.png)
即可快速创建一个简单的折线图出来:
在`Hierarchy`图下右键或菜单栏`GameObject`下拉选择`XCharts->LineChart`,即可快速创建一个默认的折线图出来
![linechart1](res/linechart1.png)
## 添加多个Seire
如何在上图的基础上添加两条折线呢,只需`Add Serie`按钮,选择对应的`Serie`类型即可
在`Inspector`视图,找到`LineChart`的面板,通过`Add Serie`按钮,可以添加第二条`Line`折线
![op_addserie](res/op_addserie.png)
![linechart2](res/linechart2.png)
## 添加其他组件
默认图表没有`Legend`,需要`Legend`组件可通过`Add Component`按钮添加:
![op_addcomponent](res/op_addcomponent.png)
## 添加Serie组件
如果需要给折线图区域填充颜色,可单独给`Serie`添加`Component`
Serie只自带了几个常见的组件其他组件按需额外添加。比如需要给折线图区域填充颜色,可单独给`Serie`添加`AreaStyle`组件
![op_addseriecomponent](res/op_addseriecomponent.png)
![linechart3](res/linechart3.png)
## 添加SerieData组件
如果需要个性化定制每个数据项的配置,可以单独给每个`SerieData`添加`Component`。比如我们给第一个折线图的第二个数据单独显示`Label`
如果需要个性化定制每个数据项的配置,可以单独给每个`SerieData`添加`Component`。比如我们给折线图的第二个数据单独显示`Label`
![op_addseriedatacomponent](res/op_addseriedatacomponent.png)
![linechart4](res/linechart4.png)
@@ -68,11 +70,17 @@
## 如何快速调整参数
`XCharts`是配置参数驱动。想要什么效果,你只需要去调整对应组件下的配置参数就可以,不需要去改`Hierarchy`图下的节点,因为那些节点是由`XCharts`内部根据配置参数生成的。你改了也会变还原
`XCharts`是配置参数驱动。想要什么效果,你只需要去调整对应组件下的配置参数就可以,不需要去改`Hierarchy`图下的节点,因为那些节点是由`XCharts`内部根据配置参数生成的,即使改了也会在刷新时被还原回来
快速定位你想要改的效果对应的组件。这就需要对组件有一定的了解。比如我们想要让X轴的轴线末端显示箭头如何定位第一步X轴定位到`XAxis0`;第二步,轴线定位到`AxisLine`;最后,再去看`AxisLine`组件下有没有这样的参数可以实现这个效果。
`XCharts`提供从全局`Theme`、系列`Serie`、单个数据项`SerieData`全方位的参数配置。优先级从大到小为:`SerieData`->`Serie`->`Theme`。以`ItemStyle`的颜色例,如果`SerieData`的`ItemStyle`配置有颜色值,则优先用这个颜色值。
`XCharts`提供从全局`Theme`、系列`Serie`、单个数据项`SerieData`全方位的参数配置。优先级从大到小为:`SerieData`->`Serie`->`Theme`。以`ItemStyle`的颜色为例:
1. 如果`SerieData`的`ItemStyle`配置有非`0000`颜色值,则优先用这个颜色值。
2. 如果`Serie`的`ItemStyle`配置有非`0000`颜色值,则优先用这个颜色值。
3. 否则颜色值取自主题`Theme`的`Color Palette`。
通常颜色值为0000时表示用主题默认颜色配置为0或null时表示用主题默认配置。
## 用代码添加折线图
@@ -140,6 +148,7 @@ for (int i = 0; i < 10; i++)
```
这样一个简单的折线图就出来了:
![linechart-simple](res/linechart-simple.png)
如果一个Chart里面有多个系列时则Axis的data只需要加一次不要多个循环加重复了。记住Axis的数据个数要和Serie的数据个数一致。
@@ -148,16 +157,38 @@ for (int i = 0; i < 10; i++)
你还可以用代码控制更多的参数,`Examples`下还有更多的其他例子,凡是`Inspector`上看到的可配置的参数,都可以通过代码来设置。[XCharts配置项手册](XChartsConfiguration-ZH.md)里面的所有参数都是可以通过代码控制的。
另外,除非定制,建议调用[XChartsAPI接口](https://github.com/XCharts-Team/XCharts/master/Documentation/XChartsAPI-ZH.md) 里面的接口,这些接口内部会做一些关联处理,比如刷新图表等。如果自己调用了内部组件的接口,需要自己处理刷新等其他问题。
另外,除非定制,建议调用`Chart`下提供的`public`接口,特别是数据相关操作部分。这些接口内部会做一些关联处理,比如刷新图表等。常见的接口有:
1. `chart.ClearData()`清空图表数据不移除Series
2. `chart.RemoveData()`清除图表数据会移除所有Serie
3. `chart.AddSerie()`添加Serie
4. `chart.AddXAxisData()`添加X轴数据
5. `chart.AddData()`添加Serie数据
6. `chart.UpdateData()`更新Serie数据
7. `chart.UpdateXAxisData()`更新X轴数据
8. `chart.UpdateDataName()`更新Serie数据的名字
XCharts内部有自动刷新机制但也是在一定条件下。如果自己调用了内部组件的接口碰到组件没有刷新确实找不到原因的话可以用以下两个接口强制刷新
1. `chart.RefreshAllComponent()`:刷新图表组件,会重新初始化所有组件,不建议频繁待用。
2. `chart.RefreshChart()`:刷新图表绘制,只刷新绘制部分,不会刷新组件文本,位置等部分。
## 使用TextMeshPro
XCharts支持TextMeshPro但默认是不开启的需要自己手动切换。可通过一下两种方式开启和关闭:
XCharts支持TextMeshPro但默认是不开启的需要自己手动切换。可通过以下方式开启和关闭:
![textmeshpro1](res/op_textmeshpro.png)
![textmeshpro2](res/op_textmeshpro2.png)
开启后需要设置好TextMeshPro要用的全局字体也可以在主题Theme里单独设置
![textmeshpro-font](res/op_textmeshpro3.png)
建议在项目初就规划好是否使用TextMeshPro在有很多图表的情况下再切换可能导致某些图表无法正常初始化这时可能需要每个图表单独的使用`Remove All Chart Object`来清理让图表重新初始化。
建议在项目初就规划好是否使用TextMeshPro并设置好字体。在已有很多图表的情况下切换TMP时可能某些图表无法自动刷新可以手动点击`Rebuild Chart Object`按钮来重建图表,即可正常初始化。
开启了TMP项目在更新XCharts时可能会碰到丢失了TMP引用而无法编译通过的问题可通过以下两种方式解决
1. 找到`XCharts.Runtime.asmdef`和`XCharts.Editor.asmdef`,手动加上 `TextMeshPro`的引用
2. 移除`PlayerSetting`中`Scripting Define Symbols`的`dUI_TextMeshPro`宏
## 用代码改图表参数
@@ -180,7 +211,7 @@ xAxis.type = Axis.AxisType.Category;
### 改Serie的参数
新添加Serie
新添加Serie
```C#
var serie = chart.AddSerie<Pie>();
@@ -220,7 +251,7 @@ var serieData = chart.AddData(0, 20);
//var serieData = serie.GetSerieData(0); //从已有数据中获取
serieData.radius = 10;
var itemStyle = serieData.GetOrAddComponent<ItemStyle>(); //启用SerieData的Component
var itemStyle = serieData.GetOrAddComponent<ItemStyle>(); //给数据项添加ItemStyle组件
itemStyle.color = Color.blue;
```

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018 monitor1394
Copyright (c) 2018 - 2022 monitor1394
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -9,7 +9,7 @@
<br>
Unity数据可视化图表插件。
<br>
<a href="README-EN.md">English Doc</a>
<a href="Documentation/README-EN.md">English README</a>
</p>
<p align="center">
<a href="https://github.com/XCharts-Team/XCharts/blob/master/LICENSE">

View File

@@ -21,7 +21,7 @@ namespace XCharts.Runtime
public static class XChartsMgr
{
public static readonly string version = "3.0.0";
public static readonly int versionDate = 20220522;
public static readonly int versionDate = 20220601;
public static string fullVersion { get { return version + "-" + versionDate; } }
internal static List<BaseChart> chartList = new List<BaseChart>();

View File

@@ -11,7 +11,8 @@ namespace XCharts.Runtime
public enum RoseType
{
/// <summary>
/// Don't show as Nightingale chart.不展示成南丁格尔玫瑰图
/// Don't show as Nightingale chart.
/// |不展示成南丁格尔玫瑰图。
/// </summary>
None,
/// <summary>
@@ -34,12 +35,12 @@ namespace XCharts.Runtime
{
/// <summary>
/// the normal line chart
/// 普通折线图。
/// |普通折线图。
/// </summary>
Normal,
/// <summary>
/// the smooth line chart
/// 平滑曲线。
/// |平滑曲线。
/// </summary>
Smooth,
/// <summary>
@@ -59,33 +60,41 @@ namespace XCharts.Runtime
StepEnd
}
/// <summary>
/// the type of bar. |柱状图类型。
/// </summary>
public enum BarType
{
/// <summary>
/// 普通柱形图
/// normal bar.
/// |普通柱形图。
/// </summary>
Normal,
/// <summary>
/// 斑马柱形图
/// zebra bar.
/// |斑马柱形图。
/// </summary>
Zebra,
/// <summary>
/// 胶囊柱形图
/// capsule bar.
/// |胶囊柱形图。
/// </summary>
Capsule
}
/// <summary>
/// 雷达图类型
/// the type of radar. |雷达图类型
/// </summary>
public enum RadarType
{
/// <summary>
/// 多圈雷达图。此时可一个雷达里绘制多个圈一个serieData就可组成一个圈多维数据
/// multiple radar.
/// |多圈雷达图。此时可一个雷达里绘制多个圈一个serieData就可组成一个圈多维数据
/// </summary>
Multiple,
/// <summary>
/// 单圈雷达图。此时一个雷达只能绘制一个圈多个serieData组成一个圈数据取自`data[1]`。
/// single radar.
/// |单圈雷达图。此时一个雷达只能绘制一个圈多个serieData组成一个圈数据取自`data[1]`。
/// </summary>
Single
}

View File

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