mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-06-17 16:33:45 +00:00
Compare commits
71 Commits
v3.11.2
...
b9c72c8cb9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9c72c8cb9 | ||
|
|
3db02b86b4 | ||
|
|
151ed168b5 | ||
|
|
be6a91b4c2 | ||
|
|
43de03951c | ||
|
|
21cd72b995 | ||
|
|
d466ac2bc1 | ||
|
|
6e9d9bfd3d | ||
|
|
d1438dd76f | ||
|
|
074c1a3992 | ||
|
|
5d24580725 | ||
|
|
301c66eccf | ||
|
|
2fc87d03cd | ||
|
|
33b71dc711 | ||
|
|
f5ec47c105 | ||
|
|
2e604529ee | ||
|
|
333dfb8e37 | ||
|
|
7eddebd660 | ||
|
|
d76b474a61 | ||
|
|
19744ec124 | ||
|
|
1bdb756ad1 | ||
|
|
bc1a11c4e3 | ||
|
|
6c42fe6399 | ||
|
|
ad77a79308 | ||
|
|
d5647a448d | ||
|
|
756df47fe3 | ||
|
|
1dd31f747e | ||
|
|
6568595abb | ||
|
|
61fb717d20 | ||
|
|
0a923400b2 | ||
|
|
7fb0765c6c | ||
|
|
e6c68be728 | ||
|
|
fdc7b41e8e | ||
|
|
45972a4cd9 | ||
|
|
d0d25b0221 | ||
|
|
143a037761 | ||
|
|
dc254fb722 | ||
|
|
b0d6bea256 | ||
|
|
4f38b59288 | ||
|
|
2acb841d2e | ||
|
|
ad3a8f9ad8 | ||
|
|
8c1dc44e1e | ||
|
|
25a06afb50 | ||
|
|
df4223421f | ||
|
|
f9b1eadd40 | ||
|
|
c61ad794a7 | ||
|
|
3b6ce91c65 | ||
|
|
c2a19ee47b | ||
|
|
768cf8d404 | ||
|
|
9a98d6a5df | ||
|
|
e40e19c197 | ||
|
|
59cd12d0eb | ||
|
|
8af1796ff8 | ||
|
|
78a07aa2ae | ||
|
|
fe867d18e6 | ||
|
|
757ccb04fb | ||
|
|
b4cb62241f | ||
|
|
0fb1cab302 | ||
|
|
ead9034870 | ||
|
|
20c87265a5 | ||
|
|
1e31cf3010 | ||
|
|
d33e2f66ef | ||
|
|
ff4fbb2176 | ||
|
|
9fc3ff862f | ||
|
|
bc31f86fcf | ||
|
|
c6412f5d78 | ||
|
|
0e60a26333 | ||
|
|
59bb60950b | ||
|
|
b3320bd2cd | ||
|
|
71cfbc15f3 | ||
|
|
8fbda1fa73 |
10231
Documentation~/en/api.md
10231
Documentation~/en/api.md
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,14 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 61
|
||||||
|
slug: /changelog
|
||||||
|
---
|
||||||
|
|
||||||
# 更新日志
|
# Changelog
|
||||||
|
|
||||||
[master](#master)
|
[master](#master)
|
||||||
|
[v3.13.0](#v3130)
|
||||||
|
[v3.12.1](#v3121)
|
||||||
|
[v3.12.0](#v3120)
|
||||||
[v3.11.2](#v3112)
|
[v3.11.2](#v3112)
|
||||||
[v3.11.1](#v3111)
|
[v3.11.1](#v3111)
|
||||||
[v3.11.0](#v3110)
|
[v3.11.0](#v3110)
|
||||||
@@ -71,6 +78,77 @@
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
## v3.13.0
|
||||||
|
|
||||||
|
Key Features:
|
||||||
|
|
||||||
|
* Added the `UIText` extension component
|
||||||
|
* Added the `UIToggle` extension component
|
||||||
|
* Added the `UISlider` extension component
|
||||||
|
* Refactored the `UIProgress` extension component
|
||||||
|
* Added `borderWidth` and `emptyColor` configurations to `SymbolStyle`
|
||||||
|
* Added the `size2` parameter to `SymbolStyle` to support rectangular markers
|
||||||
|
* Other optimizations and bug fixes
|
||||||
|
|
||||||
|
Detailed Changelog:
|
||||||
|
|
||||||
|
* (2025.01.01) Released `v3.13.0`
|
||||||
|
* (2024.12.27) Added the `size2` parameter to `SymbolStyle` to support rectangular markers
|
||||||
|
* (2024.12.26) Optimized `Text` alignment in `TextMeshPro` for proper centering
|
||||||
|
* (2024.12.25) Added support for `{f0}` in the `Tooltip`'s `itemFormatter` setting
|
||||||
|
* (2024.12.25) Fixed an issue where some labels on the `YAxis` might not display during range refresh
|
||||||
|
* (2024.12.23) Added `borderWidth` and `emptyColor` configurations to `SymbolStyle`
|
||||||
|
* (2024.12.17) Added the `UISlider` extension component
|
||||||
|
* (2024.12.10) Added the `UIToggle` extension component
|
||||||
|
* (2024.12.09) Fixed an issue where the `UITable`'s `scrollbar` could not be dragged
|
||||||
|
* (2024.12.07) Fixed an issue where custom nodes could not be placed under the `Chart` node
|
||||||
|
* (2024.12.05) Added the `UIText` extension component
|
||||||
|
* (2024.12.04) Removed the unused `tmpAlignment` option from `TextStyle`
|
||||||
|
|
||||||
|
## v3.12.1
|
||||||
|
|
||||||
|
Version Highlights:
|
||||||
|
|
||||||
|
* Enhanced Chinese and English support for the official website documentation.
|
||||||
|
* Optimized the rendering performance of line charts when data points are densely packed.
|
||||||
|
* Other issue fixes.
|
||||||
|
|
||||||
|
Log Details:
|
||||||
|
|
||||||
|
* (2024.12.01) Released `v3.12.1` version.
|
||||||
|
* (2024.11.30) Fixed an issue where the `Tooltip` displayed incorrectly on mobile devices when setting other anchors in charts.
|
||||||
|
* (2024.11.27) Resolved some code warning issues in `Unity6`.
|
||||||
|
* (2024.11.26) Fixed a problem where the `Tooltip` might exceed the screen and appear incomplete under specific circumstances.
|
||||||
|
* (2024.11.24) Fixed an issue where `UITable` would also select items during dragging.
|
||||||
|
* (2024.11.22) Fixed an abnormal effect issue when dynamically changing the `Time` timeline with `Animation` enabled.
|
||||||
|
* (2024.11.18) Optimized `Line` rendering for better performance when data points are densely packed.
|
||||||
|
* (2024.11.16) Fixed an issue where `Animation` could not be enabled through code (#334).
|
||||||
|
* (2024.11.13) Fixed a problem where dynamically modifying the `start` and `end` of `DataZoom` through code did not refresh the chart.
|
||||||
|
* (2024.11.05) Fixed an issue where the `Title` remained visible after being set to hidden.
|
||||||
|
* (2024.11.01) Improved `website` documentation in both English and Chinese.
|
||||||
|
|
||||||
|
## v3.12.0
|
||||||
|
|
||||||
|
Version Highlights:
|
||||||
|
|
||||||
|
* Added `radiusGradient` parameter for `Ring` to set the gradient direction
|
||||||
|
* Added support for `date` and `time` in `numericFormatter`
|
||||||
|
* Improved `origin` parameter setting for `AreaStyle` to define the starting position of area filling
|
||||||
|
* Adjusted and perfected the documentation
|
||||||
|
* Other optimizations and fixes
|
||||||
|
|
||||||
|
Log Details:
|
||||||
|
|
||||||
|
* (2024.09.30) Released version `v3.12.0`
|
||||||
|
* (2024.09.27) Improved the `5-minute tutorial`
|
||||||
|
* (2024.09.24) Improved support for multiple Series in `Legend`'s `formatter` (#332)
|
||||||
|
* (2024.09.22) Adjusted the display style of the `Documentation`
|
||||||
|
* (2024.09.09) Added support for `date` and `time` in `numericFormatter`
|
||||||
|
* (2024.09.03) Improved the setting of the `origin` parameter for `AreaStyle` to define the starting position of area filling
|
||||||
|
* (2024.09.01) Added `radiusGradient` parameter for `Ring` to set the gradient direction
|
||||||
|
* (2024.09.01) Optimized the position of the first Label when `Axis` is used as a time axis
|
||||||
|
|
||||||
|
|
||||||
## v3.11.2
|
## v3.11.2
|
||||||
|
|
||||||
* (2024.08.01) Release `v3.11.2`
|
* (2024.08.01) Release `v3.11.2`
|
||||||
@@ -130,7 +208,7 @@ Changelog Details:
|
|||||||
## v3.10.2
|
## v3.10.2
|
||||||
|
|
||||||
* (2024.03.11) Release `v3.10.2`
|
* (2024.03.11) Release `v3.10.2`
|
||||||
* (2024.03.11) Fix to `Legend`'s `formatter` showing possible mismatches when setting {d} (#304)
|
* (2024.03.11) Fix to `Legend`'s `formatter` showing possible mismatches when setting `{d}` (#304)
|
||||||
* (2024.03.11) Fix to `Tooltip` still showing after moving out of coordinate system
|
* (2024.03.11) Fix to `Tooltip` still showing after moving out of coordinate system
|
||||||
* (2024.03.08) Fixed an issue where `Tooltip`'s title might not appear after upgrading from an older version
|
* (2024.03.08) Fixed an issue where `Tooltip`'s title might not appear after upgrading from an older version
|
||||||
|
|
||||||
@@ -148,7 +226,7 @@ Highlights:
|
|||||||
* Added chart border Settings to support rounded corner charts
|
* Added chart border Settings to support rounded corner charts
|
||||||
* Fixed several issues
|
* Fixed several issues
|
||||||
|
|
||||||
Extended features:
|
Extension features:
|
||||||
|
|
||||||
* Added `SankeyChart` Sankey chart
|
* Added `SankeyChart` Sankey chart
|
||||||
* Added `border` Settings for `UITable`
|
* Added `border` Settings for `UITable`
|
||||||
@@ -189,7 +267,7 @@ Highlights:
|
|||||||
* Perfect code comments and documentation
|
* Perfect code comments and documentation
|
||||||
* Fixed several issues
|
* Fixed several issues
|
||||||
|
|
||||||
Extended features:
|
Extension features:
|
||||||
|
|
||||||
* `UITable` adds the carousel function
|
* `UITable` adds the carousel function
|
||||||
* `UITable` adds data api and callback functions
|
* `UITable` adds data api and callback functions
|
||||||
@@ -354,7 +432,7 @@ Log details:
|
|||||||
|
|
||||||
Highlights:
|
Highlights:
|
||||||
|
|
||||||
* Updated documentation structure, added [Official XCharts Homepage](https://xcharts-team.github.io)
|
* Updated documentation structure, added [Official XCharts Homepage](https://xcharts-team.github.io/en)
|
||||||
* Added support for the DataZoom box selected.
|
* Added support for the DataZoom box selected.
|
||||||
* Added support for maximum width Settings for bars.
|
* Added support for maximum width Settings for bars.
|
||||||
* Other optimizations.
|
* Other optimizations.
|
||||||
@@ -606,7 +684,7 @@ Details:
|
|||||||
* (2022.03.20) Release `v2.7.0` version
|
* (2022.03.20) Release `v2.7.0` version
|
||||||
* (2022.02.21) Fixed chart name repeat check error #183
|
* (2022.02.21) Fixed chart name repeat check error #183
|
||||||
* (2022.02.17) Fixed bug where axis split line might be displayed outside the coordinate system #181
|
* (2022.02.17) Fixed bug where axis split line might be displayed outside the coordinate system #181
|
||||||
* (2022.02.08) Fixed {d} formatter error when value is 0
|
* (2022.02.08) Fixed `{d}` formatter error when value is 0
|
||||||
* (2022.02.08) Fixed `YAxis` `AxisLabel`'s `onZero` does not work
|
* (2022.02.08) Fixed `YAxis` `AxisLabel`'s `onZero` does not work
|
||||||
* (2022.01.06) Improved `Zebra` bar chart
|
* (2022.01.06) Improved `Zebra` bar chart
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,155 +1,127 @@
|
|||||||
# XCharts FAQ
|
---
|
||||||
|
sidebar_position: 41
|
||||||
|
slug: /faq
|
||||||
|
---
|
||||||
|
|
||||||
[FAQ 1: How to adjust the margin between the axis and the background?](#how-to-adjust-the-margin-between-the-axis-and-the-background)
|
# FAQ
|
||||||
[FAQ 2: How to play agian the fadeIn animation?](#how-to-play-agian-the-fadein-animation)
|
|
||||||
[FAQ 3: How to customize the color of data item in line chart and pie chart?](#how-to-customize-the-color-of-data-item-in-line-chart-and-pie-chart)
|
|
||||||
[FAQ 4: How to formatter the text of axis label, such as add a units text?](#how-to-formatter-the-text-of-axis-label-such-as-add-a-units-text)
|
|
||||||
[FAQ 5: How to stack the bar of bar chart](#how-to-stack-the-bar-of-bar-chart)
|
|
||||||
[FAQ 6: How to make the bar serie in the same bar but not stack?](#how-to-make-the-bar-serie-in-the-same-bar-but-not-stack)
|
|
||||||
[FAQ 7: How to adjust the bar width and gap of barchart?](#how-to-adjust-the-bar-width-and-gap-of-barchart)
|
|
||||||
[FAQ 8: How to adjust the color of bar?](#how-to-adjust-the-color-of-bar)
|
|
||||||
[FAQ 9: Can I adjust the anchor of chart?](#can-i-adjust-the-anchor-of-chart)
|
|
||||||
[FAQ 10: Can display more than 1000 data?](#can-display-more-than-1000-data)
|
|
||||||
[FAQ 11: Can line chart drawing be dash, dot and dash-dot?](#can-line-chart-drawing-be-dash-dot-and-dash-dot)
|
|
||||||
[FAQ 12: How to limit the value range of the Y-axis?](#how-to-limit-the-value-range-of-the-y-axis)
|
|
||||||
[FAQ 13: How to customize the tick value range of value axis?](#how-to-customize-the-tick-value-range-of-value-axis)
|
|
||||||
[FAQ 14: How to display text at the top of data items?](#how-to-display-text-at-the-top-of-data-items)
|
|
||||||
[FAQ 15: How do I customize icons for data items?](#how-do-i-customize-icons-for-data-items)
|
|
||||||
[FAQ 16: How to anti-aliasing and make the chart smoother?](#how-to-anti-aliasing-and-make-the-chart-smoother)
|
|
||||||
[FAQ 17: Why does mouse over chart Tooltip not show?](#why-does-mouse-over-chart-tooltip-not-show)
|
|
||||||
[FAQ 18: How not to display the bar line of Tooltip?](#how-not-to-display-the-bar-line-of-tooltip)
|
|
||||||
[FAQ 19: How do I customize the display of Tooltip?](#how-do-i-customize-the-display-of-tooltip)
|
|
||||||
[FAQ 20: How do I get the Y-axis to display multiple decimal places?](#how-do-i-get-the-y-axis-to-display-multiple-decimal-places)
|
|
||||||
[FAQ 21: How do I dynamically update data with code?](#how-do-i-dynamically-update-data-with-code)
|
|
||||||
[FAQ 22: How to display legend? Why are legends sometimes not displayed?](#how-to-display-legend-why-are-legends-sometimes-not-displayed)
|
|
||||||
[FAQ 23: How to make chart as prefab?](#how-to-make-chart-as-prefab)
|
|
||||||
[FAQ 24: How do I draw custom graphic in chart,such as line or dot?](#how-do-i-draw-custom-content-in-chart-such-as-line-or-dot)
|
|
||||||
[FAQ 25: How to achieve similar data movement effect of ELECTRO cardiogram?](#how-to-achieve-similar-data-movement-effect-of-electro-cardiogram)
|
|
||||||
[FAQ 26: How do I use the background component? What are the conditions?](#how-do-i-use-the-background-component-what-are-the-conditions)
|
|
||||||
[FAQ 27: Mesh can not have more than 65000 vertices?](#mesh-cannot-have-more-than-65000-vertices)
|
|
||||||
[FAQ 28: Why are the parameters set in Serie reset after they run?](#why-are-the-parameters-set-in-serie-reset-after-they-run)
|
|
||||||
[FAQ 29: How to change the color of serie symbol?](#how-to-change-the-color-of-serie-symbol)
|
|
||||||
[FAQ 30: How to deal with TMP errors when importing or updating XCharts?](#what-if-tmp-errors-occur-when-importing-or-updating-xcharts)
|
|
||||||
[FAQ 31: Support empty data? How to achieve the effect of line chart disconnection?](#support-empty-data-how-to-achieve-the-effect-of-line-chart-disconnection)
|
|
||||||
[FAQ 32: 2.x What are the common problems when upgrading version 3.x?](#what-are-the-common-problems-when-upgrading-xcharts2-to-xcharts3)
|
|
||||||
|
|
||||||
## how-to-adjust-the-margin-between-the-axis-and-the-background
|
## FAQ 1: How to adjust the margin between the axis and the background?
|
||||||
|
|
||||||
`Grid` conponent,which can adjust the left, right, up, down margins of chart.
|
`Grid` conponent,which can adjust the left, right, up, down margins of chart.
|
||||||
|
|
||||||
## how-to-play-agian-the-fadein-animation
|
## FAQ 2: How to play agian the fadeIn animation?
|
||||||
|
|
||||||
call the `chart.AnimationReset()` API.
|
call the `chart.AnimationReset()` API.
|
||||||
|
|
||||||
## how-to-customize-the-color-of-data-item-in-line chart-and-pie-chart
|
## FAQ 3: How to customize the color of data item in line chart and pie chart?
|
||||||
|
|
||||||
`Theme`->`colorPalette`, or the sub component `LineStyle` and `ItemStyle` of `Serie`.
|
`Theme`->`colorPalette`, or the sub component `LineStyle` and `ItemStyle` of `Serie`.
|
||||||
|
|
||||||
## how-to-formatter-the-text-of-axis-label-such-as-add-a-units-text
|
## FAQ 4: How to formatter the text of axis label, such as add a units text?
|
||||||
|
|
||||||
Adjust `formatter` and `numericFormatter` parameter of `Legend`, `AxisLabel`, `Tooltop`, `SerieLabel`.
|
Adjust `formatter` and `numericFormatter` parameter of `Legend`, `AxisLabel`, `Tooltop`, `SerieLabel`.
|
||||||
|
|
||||||
## how-to-stack-the-bar-of-bar-chart
|
## FAQ 5: How to stack the bar of bar chart?
|
||||||
|
|
||||||
Set the `stack` parameter of `Serie`, the series will stack in a bar with the same `stack`.
|
Set the `stack` parameter of `Serie`, the series will stack in a bar with the same `stack`.
|
||||||
|
|
||||||
## how-to-make-the-bar-serie-in-the-same-bar-but-not-stack
|
## FAQ 6: How to make the bar serie in the same bar but not stack?
|
||||||
|
|
||||||
Set the `barGap` of `Serie` to `-1`,`stack` to null.
|
Set the `barGap` of `Serie` to `-1`,`stack` to null.
|
||||||
|
|
||||||
## how-to-adjust-the-bar-width-and-gap-of-barchart
|
## FAQ 7: How to adjust the bar width and gap of barchart?
|
||||||
|
|
||||||
Adjust the `barWidth` and `barGap` parameter of `Serie`, the last `serie`'s `barWidth` and `barGap` are valid when multiple `serie`.
|
Adjust the `barWidth` and `barGap` parameter of `Serie`, the last `serie`'s `barWidth` and `barGap` are valid when multiple `serie`.
|
||||||
|
|
||||||
## how-to-adjust-the-color-of-bar
|
## FAQ 8: How to adjust the color of bar?
|
||||||
|
|
||||||
Adjust the `ItemStyle` of `Data` in `inspector`.
|
Adjust the `ItemStyle` of `Data` in `inspector`.
|
||||||
|
|
||||||
## can-i-adjust-the-anchor-of-chart
|
## FAQ 9: Can I adjust the anchor of chart?
|
||||||
|
|
||||||
Yes, you can set any one of 16 anchors but the value use default.
|
Yes, you can set any one of 16 anchors but the value use default.
|
||||||
|
|
||||||
## can-display-more-than-1000-data
|
## FAQ 10: Can display more than 1000 data?
|
||||||
|
|
||||||
Yes. But `UGUI` limits `65000` vertices to a single `Graphic`, so too much data may not be displayed completely. The sampling simplification curve can be turned on by setting the sampling distance `sampleDist`. You can also set some parameters to reduce the number of vertices in the chart to help show more data. Such as reducing the size of the chart, close or reduce the axis of the client drawing, close `Symbol` and `Label` display. A `Normal` line chart occupies fewer vertices than a `Smooth` line chart. The `1.5.0` and above versions can set `large` and `largeThreshold` parameters to enable performance mode.
|
Yes. But `UGUI` limits `65000` vertices to a single `Graphic`, so too much data may not be displayed completely. The sampling simplification curve can be turned on by setting the sampling distance `sampleDist`. You can also set some parameters to reduce the number of vertices in the chart to help show more data. Such as reducing the size of the chart, close or reduce the axis of the client drawing, close `Symbol` and `Label` display. A `Normal` line chart occupies fewer vertices than a `Smooth` line chart. The `1.5.0` and above versions can set `large` and `largeThreshold` parameters to enable performance mode.
|
||||||
|
|
||||||
## can-line-chart-drawing-be-dash-dot-and-dash-dot
|
## FAQ 11: Can line chart drawing be dash, dot and dash-dot?
|
||||||
|
|
||||||
Yes. Adjust the `lineType` of `Serie`.
|
Yes. Adjust the `lineType` of `Serie`.
|
||||||
|
|
||||||
## how-to-limit-the-value-range-of-the-y-axis
|
## FAQ 12: How to limit the value range of the Y-axis?
|
||||||
|
|
||||||
Select the `minMaxType` of `Axis` as `Custom`, then set `min` and `max` to the values you want.
|
Select the `minMaxType` of `Axis` as `Custom`, then set `min` and `max` to the values you want.
|
||||||
|
|
||||||
## how-to-customize-the-tick-value-range-of-value-axis
|
## FAQ 13: How to customize the tick value range of value axis?
|
||||||
|
|
||||||
By default, it is automatically split by the `splitNumber` of `Axis`. Also, you can customize the `interval` to the range you want.
|
By default, it is automatically split by the `splitNumber` of `Axis`. Also, you can customize the `interval` to the range you want.
|
||||||
|
|
||||||
## how-to-display-text-at-the-top-of-data-items
|
## FAQ 14: How to display text at the top of data items?
|
||||||
|
|
||||||
Adjust the `Label` of `Serie`.
|
Adjust the `Label` of `Serie`.
|
||||||
|
|
||||||
## how-do-i-customize-icons-for-data-items
|
## FAQ 15: How do I customize icons for data items?
|
||||||
|
|
||||||
Set the `Icon` of `Data` in `Serie`.
|
Set the `Icon` of `Data` in `Serie`.
|
||||||
|
|
||||||
## how-to-anti-aliasing-and-make-the-chart-smoother
|
## FAQ 16: How to anti-aliasing and make the chart smoother?
|
||||||
|
|
||||||
Open the `Anti-Aliasing` setting in `Unity`. Selected the UI Canvas `Render Mode` as `Screen Space-Camera`, selected `MSAA`, set `4` times or higher anti-aliasing. The sawtooth can only be reduced and unavoidable. The higher the pixel, the less obvious the sawtooth is.
|
Open the `Anti-Aliasing` setting in `Unity`. Selected the UI Canvas `Render Mode` as `Screen Space-Camera`, selected `MSAA`, set `4` times or higher anti-aliasing. The sawtooth can only be reduced and unavoidable. The higher the pixel, the less obvious the sawtooth is.
|
||||||
|
|
||||||
## why-does-mouse-over-chart-tooltip-not-show
|
## FAQ 17: Why does mouse over chart Tooltip not show?
|
||||||
|
|
||||||
Verify `Toolip` is opened. Verify that the parent node of chart has turned off mouse events.
|
Verify `Toolip` is opened. Verify that the parent node of chart has turned off mouse events.
|
||||||
|
|
||||||
## how-not-to-display-the-bar-line-of-tooltip
|
## FAQ 18: How not to display the bar line of Tooltip?
|
||||||
|
|
||||||
Set the `type` of `Tooltup` as `None`. Or adjust the parameters of `lineStyle`.
|
Set the `type` of `Tooltup` as `None`. Or adjust the parameters of `lineStyle`.
|
||||||
|
|
||||||
## how-do-i-customize-the-display-of-tooltip
|
## FAQ 19: How do I customize the display of Tooltip?
|
||||||
|
|
||||||
See the `formatter`, `itemFormatter`, `titleFormatter` parameters of `Tooltip`.
|
See the `formatter`, `itemFormatter`, `titleFormatter` parameters of `Tooltip`.
|
||||||
|
|
||||||
## how-do-i-get-the-y-axis-to-display-multiple-decimal-places
|
## FAQ 20: How do I get the Y-axis to display multiple decimal places?
|
||||||
|
|
||||||
Set the `numericFormatter` parameter of `AxisLabel`.
|
Set the `numericFormatter` parameter of `AxisLabel`.
|
||||||
|
|
||||||
## how-do-i-dynamically-update-data-with-code
|
## FAQ 21: How do I dynamically update data with code?
|
||||||
|
|
||||||
See example: `Example01_UpdateData.cs`
|
See example: `Example01_UpdateData.cs`
|
||||||
|
|
||||||
## how-to-display-legend-why-are-legends-sometimes-not-displayed
|
## FAQ 22: How to display legend? Why are legends sometimes not displayed?
|
||||||
|
|
||||||
First, the `name` in `Serie` must have a value that is not null. Then set `Legend` is `show`, where `data` can be empty by default, indicating that all legends are displayed. If you only want to display part of the `Serie` legend, fill in `data` with the `name` of the legend you want to display. If none of the values in `data` are `name` of the series, the legend will not be displayed.
|
First, the `name` in `Serie` must have a value that is not null. Then set `Legend` is `show`, where `data` can be empty by default, indicating that all legends are displayed. If you only want to display part of the `Serie` legend, fill in `data` with the `name` of the legend you want to display. If none of the values in `data` are `name` of the series, the legend will not be displayed.
|
||||||
|
|
||||||
## how-to-make-chart-as-prefab
|
## FAQ 23: How to make chart as prefab?
|
||||||
|
|
||||||
Before make prefab, please delete all sub gameObject under chart which auto-created by `XCharts`.
|
Before make prefab, please delete all sub gameObject under chart which auto-created by `XCharts`.
|
||||||
|
|
||||||
## how-do-i-draw-custom-content-in-chart-such-as-line-or-dot
|
## FAQ 24: How do I draw custom graphic in chart,such as line or dot?
|
||||||
|
|
||||||
Implement `onCustomDraw` of chart, see `Example12_CustomDrawing.cs`.
|
Implement `onCustomDraw` of chart, see `Example12_CustomDrawing.cs`.
|
||||||
|
|
||||||
## how-to-achieve-similar-data-movement-effect-of-electro-cardiogram
|
## FAQ 25: How to achieve similar data movement effect of ELECTRO cardiogram?
|
||||||
|
|
||||||
See `Example_Dynamic.cs`.
|
See `Example_Dynamic.cs`.
|
||||||
|
|
||||||
## how-do-i-use-the-background-component-what-are-the-conditions
|
## FAQ 26: How do I use the background component? What are the conditions?
|
||||||
|
|
||||||
Setting `show` to `true` for the `background` component.
|
Setting `show` to `true` for the `background` component.
|
||||||
|
|
||||||
## mesh-cannot-have-more-than-65000-vertices
|
## FAQ 27: Mesh can not have more than 65000 vertices?
|
||||||
|
|
||||||
This is the limit of `UGUI` on the number of vertices for a single `Graphic`. `XCharts` is draw chart on a single `Graphic`, so there is also this limitation. The solution can be referred to: [FAQ 10: Can display more than 1000 data](#can-display-more-than-1000-data)
|
This is the limit of `UGUI` on the number of vertices for a single `Graphic`. `XCharts` is draw chart on a single `Graphic`, so there is also this limitation. The solution can be referred to: [FAQ 10: Can display more than 1000 data?](#FAQ-10-can-display-more-than-1000-data)
|
||||||
|
|
||||||
## why-are-the-parameters-set-in-serie-reset-after-they-run
|
## FAQ 28: Why are the parameters set in Serie reset after they run?
|
||||||
|
|
||||||
Check whether `RemoveData()` and add new `Serie` in the code. If you want to keep the configuration of `Serie`, you can only `ClearData()` which just clear data and then readd the data to the old serie.
|
Check whether `RemoveData()` and add new `Serie` in the code. If you want to keep the configuration of `Serie`, you can only `ClearData()` which just clear data and then readd the data to the old serie.
|
||||||
|
|
||||||
## how-to-change-the-color-of-serie-symbol
|
## FAQ 29: How to change the color of serie symbol?
|
||||||
|
|
||||||
The color of 'Symbol' is the color of 'ItemStyle' used.
|
The color of 'Symbol' is the color of 'ItemStyle' used.
|
||||||
|
|
||||||
## what-if-tmp-errors-occur-when-importing-or-updating-xcharts
|
## FAQ 30: How to deal with TMP errors when importing or updating XCharts?
|
||||||
|
|
||||||
XCharts does not enable TMP by default, so there are no references to TMP on asmdef. This issue may occur when updating XCharts after TMP is enabled locally. It can be solved in the following two ways:
|
XCharts does not enable TMP by default, so there are no references to TMP on asmdef. This issue may occur when updating XCharts after TMP is enabled locally. It can be solved in the following two ways:
|
||||||
|
|
||||||
@@ -158,11 +130,23 @@ XCharts does not enable TMP by default, so there are no references to TMP on asm
|
|||||||
|
|
||||||
Version ` 3.8.0 ` after adding Daemon [XCharts - Daemon](https://github.com/XCharts-Team/XCharts-Daemon), will be XCharts - Daemon import project, When updating XCharts, the daemon automatically refreshes the asmdef based on the locally enabled TMP to ensure proper compilation.
|
Version ` 3.8.0 ` after adding Daemon [XCharts - Daemon](https://github.com/XCharts-Team/XCharts-Daemon), will be XCharts - Daemon import project, When updating XCharts, the daemon automatically refreshes the asmdef based on the locally enabled TMP to ensure proper compilation.
|
||||||
|
|
||||||
## support-empty-data-how-to-achieve-the-effect-of-line-chart-disconnection
|
## FAQ 31: Support empty data? How to achieve the effect of line chart disconnection?
|
||||||
|
|
||||||
`data` of `Serie` is of type `double`, so it cannot represent empty data. Empty data can be achieved by turning on Serie's ignore and specifying ignoreValue. You can also set the ignore parameter for each SerieData. The ignoreLineBreak parameter can be set to disconnect or connect after ignoring data.
|
`data` of `Serie` is of type `double`, so it cannot represent empty data. Empty data can be achieved by turning on Serie's ignore and specifying ignoreValue. You can also set the ignore parameter for each SerieData. The ignoreLineBreak parameter can be set to disconnect or connect after ignoring data.
|
||||||
|
|
||||||
## what-are-the-common-problems-when-upgrading-xcharts2-to-xcharts3
|
## FAQ 32: 2.x What are the common problems when upgrading version 3.x?
|
||||||
|
|
||||||
1. `XCharts.Runtime.XChartsMgr` is missing the class attribute `ExtensionOfNativeClass`!
|
1. `XCharts.Runtime.XChartsMgr` is missing the class attribute `ExtensionOfNativeClass`!
|
||||||
3.x version does not need to mount XChartsMgr, directly delete the `_xcharts_` node on the scene.
|
3.x version does not need to mount XChartsMgr, directly delete the `_xcharts_` node on the scene.
|
||||||
|
|
||||||
|
## FAQ 33: How to display a line chart without white space on both sides and start from the 0 coordinate?
|
||||||
|
|
||||||
|
Set the `boundaryGap` parameter of the X-axis.
|
||||||
|
|
||||||
|
## FAQ 34: How to set some Series not to display Tooltips?
|
||||||
|
|
||||||
|
Setting the `itemFormatter` of `itemStyle` in `serie` to `'-'` can ignore `tooltip`.
|
||||||
|
|
||||||
|
## FAQ 35: Sometimes an overlapping line appears in the area line chart when using semi-transparent colors
|
||||||
|
|
||||||
|
This is a bug in the drawing of the area line chart. You can use light opaque colors instead of semi-transparent colors.
|
||||||
|
|||||||
BIN
Documentation~/en/img/tutorial01_axisdata.png
Normal file
BIN
Documentation~/en/img/tutorial01_axisdata.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
Documentation~/en/img/tutorial01_seriedata.png
Normal file
BIN
Documentation~/en/img/tutorial01_seriedata.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
9
Documentation~/en/support.md
Normal file
9
Documentation~/en/support.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
title: Support
|
||||||
|
sidebar_position: 51
|
||||||
|
slug: /support
|
||||||
|
---
|
||||||
|
|
||||||
|
# Support
|
||||||
|
|
||||||
|
For technical support and to purchase additional charts, you can subscribe to the `VIP` service. For details, please send an email to `monitor1394@gmail.com` for consultation.
|
||||||
@@ -1,103 +1,170 @@
|
|||||||
---
|
---
|
||||||
title: Introductory tutorial: Get started with XCharts 3.0 in 5 minutes
|
title: Getting Started
|
||||||
sidebar_position: 11
|
sidebar_position: 11
|
||||||
slug: /tutorial01
|
slug: /tutorial01
|
||||||
---
|
---
|
||||||
|
|
||||||
# Tutorial: Get started with XCharts 3.0 in 5 minutes
|
# Getting Started with XCharts in 5 Minutes
|
||||||
|
|
||||||
> Note: This tutorial is for XCharts 3.x version only
|
:::warning
|
||||||
|
|
||||||
## What do I need to know before using XCharts
|
Note: This tutorial is only applicable to the XCharts 3.x version. For the 2.x version, please refer to [Tutorial: Mastering XCharts 2.0](https://github.com/XCharts-Team/XCharts/blob/2.0/Doc/tutorial--get-start-with-xcharts-in-5-minute-EN.md)
|
||||||
|
|
||||||
- Have used Unity, know the basic operation of Unity.
|
:::
|
||||||
- Understand UGUI and can use UGUI.
|
|
||||||
- Understand MonoBehavior script usage in Unity, know how to hang scripts, manipulate scripts with code.
|
|
||||||
|
|
||||||
## Get and import XCharts
|
## Prerequisites for XCharts
|
||||||
|
|
||||||
XCharts can be imported into a project in any of the following ways:
|
XCharts is a Unity chart plugin, currently only available for use on the Unity platform.
|
||||||
|
|
||||||
- Source XCharts directly into the project
|
Before using XCharts, you need to:
|
||||||
|
|
||||||
After downloading the XCharts source code, copy the XCharts directory directly to the Assets directory of the Unity project.
|
- Have a basic understanding of how to use Unity.
|
||||||
|
- Understand the basic usage of UGUI for making UI.
|
||||||
|
- Know how to use Unity's MonoBehavior scripts, how to attach scripts, and how to manipulate scripts with code.
|
||||||
|
|
||||||
- Import XCharts through `Assets/Import Package`
|
If you are new to Unity, it is recommended to learn some basic Unity tutorials before using XCharts.
|
||||||
|
|
||||||
After downloading the.unitypackage file for XCharts, open Unity and go to the menu bar Assets--> Import Package--> Select.unitypackage import to start using XCharts.
|
## Obtaining and Importing XCharts
|
||||||
|
|
||||||
- Import XCharts through the Package Manager
|
XCharts is primarily maintained and released through Github. You can download the source code and Package from the [Github Homepage](https://github.com/XCharts-Team).
|
||||||
|
|
||||||
For Unity 2018.3 and later, XCharts can be imported through the Package Manager. After opening the Package Manager, run the `Add package form git URL...`, input XCharts dead simple URL: ` https://github.com/XCharts-Team/XCharts.git use XCharts after ` wait a moment.
|
XCharts can be imported into your project in any of the following ways:
|
||||||
|
|
||||||
You can also add the package directly to the manifest.json file: Open the manifest.json file in the Packages directory and add it under dependencies:
|
### Copying the XCharts Source Code Directly into the Project
|
||||||
|
|
||||||
``` json
|
After downloading the XCharts source code, simply copy the XCharts directory into the Assets directory of your Unity project. Once compiled, it is ready to use.
|
||||||
"com.monitor1394.xcharts" : "https://github.com/XCharts-Team/XCharts.git",
|
|
||||||
```
|
|
||||||
|
|
||||||
To update XCharts, remove com.monitor1394.xcharts from the manifest.json file under lock (some versions of Unity may be packages-lock.json) and re-download and compile.
|
### Importing XCharts through Import Package
|
||||||
|
|
||||||
- Recommended daemon into XCharts (not required)
|
After downloading the .unitypackage file of XCharts, open Unity, go to the menu bar Assets-->Import Package-->select the downloaded .unitypackage to import. After the import is complete and compiled, you can start using XCharts.
|
||||||
|
|
||||||
[XCharts Daemon](https://github.com/XCharts-Team/XCharts-Daemon) can ensure update compilation is normal, when the local open TextMeshPro or NewInputSystem would be very useful. After importing Xchart-daemon into a project, when updating XCharts, the Daemon will automatically refresh asmdef according to the status of local TMP, etc., to ensure normal compilation and facilitate the execution of automated processes such as CI-CD.
|
### Importing XCharts through Package Manager
|
||||||
|
|
||||||
## Add a simple chart
|
For Unity versions above 2018.3, you can import XCharts through the Package Manager. Open the Package Manager, then use `Add package from git URL...`, enter the GitHub URL of XCharts: `https://github.com/XCharts-Team/XCharts.git`. After compiling, you can use XCharts.
|
||||||
|
|
||||||
Right-click in `Hierarchy` view or menu bar `GameObject` drop down and select `XCharts->LineChart`, can quickly create a default line chart out:
|
For some Unity versions, you can also directly add the package to the `manifest.json` file: Open the `manifest.json` file under the `Packages` directory, and add the following under `dependencies`:
|
||||||
|
|
||||||
|
>"com.monitor1394.xcharts": "https://github.com/XCharts-Team/XCharts.git",
|
||||||
|
|
||||||
|
If you need to update `XCharts`, delete the relevant content of `com.monitor1394.xcharts` under the `lock` of the `manifest.json` file (some Unity versions may be the packages-lock.json file), and it will re-download and compile.
|
||||||
|
|
||||||
|
### Recommended Import of XCharts Daemon
|
||||||
|
|
||||||
|
The daemon [XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon) ensures that the compilation is normal when updating. It is very useful when TextMeshPro or NewInputSystem is turned on locally. After importing XCharts-Daemon into the project, the daemon will automatically refresh XCharts' asmdef according to the local situation of TMP when updating XCharts, ensuring that the compilation is normal without manual intervention, which is convenient for automated processes such as CI/CD.
|
||||||
|
|
||||||
|
The import method of XCharts-Daemon can refer to the previous import method of XCharts. It can be imported into the project through source code or Package. The GitHub URL of XCharts-Daemon: https://github.com/XCharts-Team/XCharts-Daemon.git
|
||||||
|
|
||||||
|
## Basic Usage of XCharts
|
||||||
|
|
||||||
|
After importing XCharts and compiling, the XCharts menu will appear in the Unity editor's menu bar, and you can start using XCharts.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
Note: The XCharts menu in the Unity menu bar indicates that XCharts is available.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Adding a Simple Chart
|
||||||
|
|
||||||
|
In the `Hierarchy` view, right-click `UI->XCharts->LineChart` or select `LineChart` from the menu bar `XCharts` to quickly create a default line chart:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Add multiple Seire
|
If you need to create a chart under a certain node, you can select the node and right-click `UI->XCharts->LineChart` to create a chart under the node.
|
||||||
|
|
||||||
In the Inspector view, locate LineChart's panel, and with the `Add Serie` button, you can add a second Line line:
|
### Modifying Chart Data
|
||||||
|
|
||||||
|
For the newly created chart, its data can be modified on the Inspector panel.
|
||||||
|
|
||||||
|
For X-axis data, you can add, delete, and modify by expanding: `XAxis->Data`:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
For Serie data, you can add, delete, and modify by expanding: `Serie->Data`:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Serie supports multi-dimensional data, and generally, a line chart only uses two-dimensional data: the first dimension represents the ID of the X-axis category data, and the second dimension represents the corresponding value.
|
||||||
|
|
||||||
|
### Adding Multiple Series
|
||||||
|
|
||||||
|
In the `Inspector` view, find the `LineChart` panel, and click the `Add Serie` button to add a second `Line` line:
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
## Add other components
|
:::tip
|
||||||
|
|
||||||
The default chart does not have a `Legend`, and a `Legend` Component can be added via the `Add Component` button:
|
Series are added through the `Add Serie` button. Different types of Series can be added. [What kinds of Series does XCharts have?](https://xcharts-team.github.io/en/docs/configuration#serie-系列)
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Adding Other Main Components
|
||||||
|
|
||||||
|
By default, the chart does not have a `Legend`. If you need a `Legend` component, you can add it through the `Add Component` button:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Add Serie components
|
:::tip
|
||||||
|
|
||||||
Serie comes with only a few common components, and others are added as needed. For example, if you need to fill a line chart area with color, you can add a separate `AreaStyle` component to Serie:
|
Main components are added through the `Add Component` button. [What main components does XCharts have?](https://xcharts-team.github.io/en/docs/configuration/#maincomponent-主组件)
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Adding Serie Components
|
||||||
|
|
||||||
|
Serie only comes with a few common components, and other components need to be added when used. For example, if you need to fill the area color for the line chart, you can add an `AreaStyle` component to `Serie` separately:
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
## Add the SerieData component
|
:::tip
|
||||||
|
|
||||||
If you need to personalize the configuration of each data item, you can add a Component to each SerieData separately. For example, we give the second data of the line chart a separate display `Label`:
|
Serie components are added through the button on the right side of Serie. [What components can be added to Serie in XCharts?](https://xcharts-team.github.io/en/docs/configuration/#iseriecomponent-可添加到serie的组件)
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Adding SerieData Components
|
||||||
|
|
||||||
|
If you need to customize the configuration of each data item individually, you can add components to each `SerieData` separately. For example, we can display `Label` for the second data of the line chart individually:
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
## More components and configuration parameters
|
:::tip
|
||||||
|
|
||||||
XCharts has been iteratively optimized and now has dozens of main and sub-components, each with a few to dozens of configurable parameters to support a variety of flexible and complex functions.
|
SerieData components are added through the button on the right side of SerieData after expanding. [What components can be added to SerieData in XCharts?](https://xcharts-team.github.io/en/docs/configuration/#iseriedatacomponent-可添加到seriedata的组件)
|
||||||
|
|
||||||
Using XCharts for the first time, you can add various charts in the `Inspector` view, add or adjust the components in the chart, and the `Game` view gives real-time feedback on the effects of adjustments to familiarize yourself with the use of various components. Detailed parameter descriptions of each component can be found in the [XCharts Configuration](Configuration.md).
|
:::
|
||||||
|
|
||||||
## How to adjust parameters quickly
|
### More Components and Configuration Parameters
|
||||||
|
|
||||||
XCharts is configuration and data driven. Want what effect, only need to adjust the configuration parameters under the corresponding component can be, do not need to change the nodes under the `Hierarchy` view, because those nodes are generated by the `XCharts` internal according to the configuration and data, even if changed will be restored in the refresh.
|
XCharts has been continuously iterated and optimized, and now has dozens of main components and sub-components, each with several to dozens of configurable parameters to support a variety of functions.
|
||||||
|
|
||||||
How to quickly locate the component corresponding to the effect you want to change requires a certain understanding of the component. For example, if we want to show an arrow at the end of the X-axis, how do we position it? First, position the X-axis to `XAxis0`; Second, locate the axis to `AxisLine`; Finally, check to see if there are any parameters in the AxisLine component that can achieve this effect, and check [XCharts configuration](Configuration.md) for uncertain parameters.
|
When using XCharts for the first time, it is recommended to personally test the actual effects of each chart, each component. The `Inspector` view can directly add various charts, components, and adjust various configuration parameters, and the `Game` view will provide real-time feedback on the adjustments. A detailed description of each component's parameters can be found in the [XCharts Configuration Manual](configuration.md).
|
||||||
|
|
||||||
`XCharts` provides a full range of parameter configuration from the global` Theme `, series` Serie `, and single data item `SerieData`. The priority in descending order is: `SerieData` -> `Serie` -> `Theme`. Take the color of `ItemStyle` for example:
|
### How to Quickly Adjust Parameters
|
||||||
|
|
||||||
1. If the `ItemStyle` of `SerieData` has a color value other than `0000`, this color value is preferred.
|
XCharts is driven by data and parameters. To achieve the desired effect, simply adjust the configuration parameters under the corresponding component. Do not modify the nodes under the `Hierarchy` view, as those nodes are generated by XCharts internally based on configuration and data, and will be restored upon refresh.
|
||||||
2. If the ItemStyle of `Serie` is configured with a color value other than `0000`, this color value takes precedence.
|
|
||||||
3. Otherwise, the Color value is taken from the Color Palette of the Theme.
|
|
||||||
|
|
||||||
Usually, `0000` indicates the theme default color, and 0 or null indicates the theme default.
|
To quickly locate the component corresponding to the effect you want to change, you need to have a certain understanding of the components. For example, we want to display an arrow at the end of the X-axis line. How to locate it? The first step, the X-axis is located at `XAxis0`; the second step, the axis line is located at `AxisLine`; finally, check if there is such a parameter under the `AxisLine` component to achieve this effect. If you are not sure about the parameters, you can refer to the [XCharts Configuration Manual](configuration.md).
|
||||||
|
|
||||||
## Add line charts with code
|
`XCharts` provides comprehensive parameter configuration from the global `Theme`, series `Serie`, and individual data items `SerieData`. The priority order from high to low is: `SerieData`->`Serie`->`Theme`. Take the color of `ItemStyle` as
|
||||||
|
an example:
|
||||||
|
|
||||||
Attach the `LineChart` script to the gameObject:
|
1. If the `ItemStyle` of `SerieData` has a color value other than `0000`, this color value is used first.
|
||||||
|
2. If the `ItemStyle` of `Serie` has a color value other than `0000`, this color value is used.
|
||||||
|
3. Otherwise, the color value is taken from the `Color Palette` of the theme `Theme`.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
The color value is usually `0000` when using the default color of the theme; other parameters are `0` or null when using the default configuration of the theme; pay attention to transparency when setting colors.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Adding a Line Chart with Code
|
||||||
|
|
||||||
|
Attach the `LineChart` script to `gameObject`:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
var chart = gameObject.GetComponent<LineChart>();
|
var chart = gameObject.GetComponent<LineChart>();
|
||||||
@@ -108,10 +175,10 @@ if (chart == null)
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Resize:
|
Adjust the size:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
chart.SetSize(580, 300);//代码动态设置尺寸,或直接操作chart.rectTransform,或直接在Inspector上改
|
chart.SetSize(580, 300);//Dynamically set the size with code, or directly operate chart.rectTransform, or directly change it in the Inspector
|
||||||
```
|
```
|
||||||
|
|
||||||
Set the title:
|
Set the title:
|
||||||
@@ -121,7 +188,7 @@ var title = chart.EnsureChartComponent<Title>();
|
|||||||
title.text = "Simple Line";
|
title.text = "Simple Line";
|
||||||
```
|
```
|
||||||
|
|
||||||
Set whether prompt boxes and legends are displayed:
|
Set whether to display the tooltip and legend:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
var tooltip = chart.EnsureChartComponent<Tooltip>();
|
var tooltip = chart.EnsureChartComponent<Tooltip>();
|
||||||
@@ -131,7 +198,7 @@ var legend = chart.EnsureChartComponent<Legend>();
|
|||||||
legend.show = false;
|
legend.show = false;
|
||||||
```
|
```
|
||||||
|
|
||||||
Set axes:
|
Set the coordinate axis:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
var xAxis = chart.EnsureChartComponent<XAxis>();
|
var xAxis = chart.EnsureChartComponent<XAxis>();
|
||||||
@@ -143,14 +210,22 @@ var yAxis = chart.EnsureChartComponent<YAxis>();
|
|||||||
yAxis.type = Axis.AxisType.Value;
|
yAxis.type = Axis.AxisType.Value;
|
||||||
```
|
```
|
||||||
|
|
||||||
Clear default data and add `Line` type `Serie` for receiving data:
|
Clear all default data (including Series), add a `Line` type `Serie` to receive data:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
chart.RemoveData();
|
chart.RemoveData();
|
||||||
chart.AddSerie<Line>("line");
|
chart.AddSerie<Line>("line");
|
||||||
```
|
```
|
||||||
|
|
||||||
Add 10 data:
|
If the Serie is fixed, it is recommended to only clear the data, not to remove the Serie:
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
chart.ClearData();
|
||||||
|
```
|
||||||
|
|
||||||
|
This way, you can set the configuration parameters of Serie in the UI in advance.
|
||||||
|
|
||||||
|
Add 10 data points:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
@@ -160,59 +235,86 @@ for (int i = 0; i < 10; i++)
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
So a simple line chart comes out:
|
Now, a simple line chart is ready:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
If there are multiple series in a Chart, the data of Axis only needs to be added once, rather than repeated in multiple cycles. Remember: the number of data in Axis should be the same as the number in Serie.
|
If there are multiple series in a Chart, the data of Axis only needs to be added once, and should not be repeated in multiple loops.
|
||||||
|
|
||||||
See `Examples`: `Example13_LineSimple.cs` for the complete code
|
:::tip
|
||||||
|
|
||||||
You can also use code to control more parameters, there are more Examples under `Examples`, all the configurable parameters seen in the `Inspector` can be set by code. All parameters in [XCharts configuration](Configuration.md) can be controlled by code.
|
Remember: The number of Axis data should be consistent with the number of Serie data.
|
||||||
|
|
||||||
In addition, unless customized, it is recommended to call the `public` interface provided under `Chart`, especially in the data-related operations section. These interfaces do some associated processing inside, such as refreshing charts. Common interfaces are:
|
:::
|
||||||
|
|
||||||
1. `Chart.ClearData()` : Clear chart data (without removing Series)
|
For the complete code, please refer to `Examples`: `Example13_LineSimple.cs`
|
||||||
2. `Chart.RemoveData()` : Clear chart data (will remove all Serie)
|
|
||||||
3. `chart.AddSerie()` : AddSerie
|
|
||||||
4. `chart.AddXAxisData()` : Add X-axis data
|
|
||||||
5. `chart.AddData()` : Adds Serie data
|
|
||||||
6. `chart.UpdateData()` : Updates Serie data
|
|
||||||
7. `chart.UpdateXAxisData()` : Updates the X-axis data
|
|
||||||
8. `chart.UpdateDataName()` : Updates the Serie data name
|
|
||||||
|
|
||||||
XCharts has an automatic refresh mechanism inside, but it only triggers under certain conditions. If you call the interface of the internal component, encounter the component did not refresh, and indeed can not find the reason, you can use the following two interfaces to force refresh:
|
You can also control more parameters with code. There are more examples in `Examples`. All parameters that can be configured in the `Inspector` can be set with code. All parameters in the [XCharts Configuration Manual](configuration.md) can be controlled by code.
|
||||||
|
|
||||||
1. `chart.RefreshAllComponent()` : refresh chart component, to initialize all of the components, often is not recommended.
|
### Setting the Default Font
|
||||||
2. `chart.RefreshChart()` : refreshes the chart drawing, only the drawing part is refreshed, and the component text, position, etc., is not refreshed.
|
|
||||||
3. Individual components can also refresh only themselves by `SetAllDirty()`.
|
|
||||||
|
|
||||||
## Use TextMeshPro
|
The default font used by XCharts is Unity's default font `Arial`, which may not display Chinese characters on the WebGL platform. When using XCharts in your project, it is recommended to set the font first:
|
||||||
|
|
||||||
XCharts supports TextMeshPro, but it is disabled by default and needs to be switched manually. It can be turned on and off in the following ways:
|
- Find the `XCharts/Resources/XCSetting.asset` resource and modify the `Font` inside and save.
|
||||||
|
- Find the `XCharts/Resources/XCTheme-Default.asset` and `XCharts/Resources/XCTheme-Dark.asset` font configurations, and click the `Sync Font from Setting` and `Sync Font to Sub Theme` buttons to synchronize the font to the theme configuration files.
|
||||||
|
|
||||||
|
After the font is set, newly created charts will use the newly set font. For old charts, you can click the `Rebuild Chart Object` button to refresh.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
It is recommended to set the font before using XCharts; when updating XCharts, pay attention to the potential restoration of the set font.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Using TextMeshPro
|
||||||
|
|
||||||
|
XCharts supports TextMeshPro, but it is not enabled by default and needs to be switched on manually. It can be turned on and off in the following ways:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
After opening, you need to set the global font used by TextMeshPro, or you can set it separately in the Theme:
|
After turning it on, you need to set the global font to be used by TextMeshPro, and it can also be set individually in the Theme:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
It is recommended to plan whether to use TextMeshPro at the beginning of the project and set the font. When switching TMP with many existing charts, some charts may not refresh automatically. You can manually click the `Rebuild Chart Object` button to rebuild the chart, which can be initialized normally.
|
It is recommended to plan whether to use TextMeshPro at the beginning of the project and set the font accordingly. When switching to TMP in a project with many charts, some charts may not refresh automatically, and you can manually click the `Rebuild Chart Object` button to rebuild the chart, which will initialize normally.
|
||||||
|
|
||||||
When updating XCharts for TMP projects, you may encounter problems with missing TMP references and failing to compile. These problems can be solved in one of two ways:
|
If you have enabled TMP in your project, you may encounter compilation failures due to lost TMP references when updating XCharts. This can be solved in the following two ways:
|
||||||
|
|
||||||
1. Find `XCharts.Runtime.asmdef` and `XCharts.Editor.asmdef` and manually add references to `TextMeshPro`
|
1. Find `XCharts.Runtime.asmdef` and `XCharts.Editor.asmdef`, and manually add references to `TextMeshPro`.
|
||||||
2. Remove the `dUI_TextMeshPro` macro for Scripting Define Symbols in PlayerSetting
|
2. Remove the `dUI_TextMeshPro` macro from the `Scripting Define Symbols` in `PlayerSetting`.
|
||||||
|
|
||||||
Version `3.8.0` after adding daemon[XCharts - Daemon](https://github.com/XCharts-Team/XCharts-Daemon), will be XCharts-Daemon import project, When updating XCharts, the daemon automatically refreshes the asmdef based on the locally enabled TMP to ensure proper compilation.
|
After the `3.8.0` version, the [XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon) daemon was added. After importing XCharts-Daemon into the project, the daemon will automatically refresh the asmdef based on the local situation of the enabled TMP when updating XCharts, ensuring normal compilation.
|
||||||
|
|
||||||
## Change chart parameters with code
|
## XCharts Code Control
|
||||||
|
|
||||||
All parameters seen on Inspector can be modified with code, the key is to identify whether the parameters you want to change are on the component, on the Serie, or on the specific data item SerieData.
|
All parameters seen in the `Inspector` can be modified with code. The key is to locate the parameter you want to change, whether it is on the component, the Serie, or the specific data item SerieData.
|
||||||
|
|
||||||
### Change the parameters on the main component
|
In addition, unless customized, it is recommended to call the `public` interfaces provided under `Chart`, especially for data-related and list operations. These interfaces will do some associated processing internally, such as refreshing the chart. Common interfaces include:
|
||||||
|
|
||||||
You need to obtain the component first, and then modify the parameters in it:
|
1. `chart.ClearData()`: Clear chart data (does not remove Series)
|
||||||
|
2. `chart.RemoveData()`: Clear chart data (will remove all Series)
|
||||||
|
3. `chart.AddSerie()`: Add Serie
|
||||||
|
4. `chart.AddXAxisData()`: Add X-axis data
|
||||||
|
5. `chart.AddData()`: Add Serie data
|
||||||
|
6. `chart.UpdateData()`: Update Serie data
|
||||||
|
7. `chart.UpdateXAxisData()`: Update X-axis data
|
||||||
|
8. `chart.UpdateDataName()`: Update the name of Serie data
|
||||||
|
|
||||||
|
XCharts has an automatic refresh mechanism, but it is also triggered under certain conditions. If you have called the internal component interfaces and encountered components that have not been refreshed, and you cannot find the reason, you can use the following two interfaces to force a refresh:
|
||||||
|
|
||||||
|
1. `chart.RefreshAllComponent()`: Refresh chart components, which will re-initialize all components. It is not recommended to use it frequently.
|
||||||
|
2. `chart.RefreshChart()`: Refresh chart rendering, which only refreshes the rendering part and will not refresh component text, position, etc.
|
||||||
|
3. Each component can also refresh itself by calling `SetAllDirty()`.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
Use APIs to manipulate data and various lists, not directly access the list for processing.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### Changing Parameters on Main Components
|
||||||
|
|
||||||
|
You need to obtain the component first, then modify its parameters:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
var title = chart.EnsureChartComponent<Title>();
|
var title = chart.EnsureChartComponent<Title>();
|
||||||
@@ -225,11 +327,15 @@ xAxis.boundaryGap = true;
|
|||||||
xAxis.type = Axis.AxisType.Category;
|
xAxis.type = Axis.AxisType.Category;
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note: When the earlier version does not have the EnsureChartComponent() interface, GetOrAddChartComponent() is used.
|
:::tip
|
||||||
|
|
||||||
### Change Serie parameters
|
In older versions without the `EnsureChartComponent()` interface, use `GetOrAddChartComponent()`
|
||||||
|
|
||||||
For newly added Serie:
|
:::
|
||||||
|
|
||||||
|
### Changing Serie Parameters
|
||||||
|
|
||||||
|
For newly added Series:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
var serie = chart.AddSerie<Pie>();
|
var serie = chart.AddSerie<Pie>();
|
||||||
@@ -241,7 +347,7 @@ serie.animation.dataChangeEnable = true;
|
|||||||
serie.roundCap = true;
|
serie.roundCap = true;
|
||||||
```
|
```
|
||||||
|
|
||||||
For existing Serie:
|
For existing Series:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
var serie = chart.GetSerie<Pie>();
|
var serie = chart.GetSerie<Pie>();
|
||||||
@@ -253,7 +359,7 @@ serie.animation.dataChangeEnable = true;
|
|||||||
serie.roundCap = true;
|
serie.roundCap = true;
|
||||||
```
|
```
|
||||||
|
|
||||||
Add additional components to Serie:
|
Adding additional components to Serie:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
serie.EnsureComponent<AreaStyle>();
|
serie.EnsureComponent<AreaStyle>();
|
||||||
@@ -262,14 +368,14 @@ var label = serie1.EnsureComponent<LabelStyle>();
|
|||||||
label.offset = new Vector3(0,20,0);
|
label.offset = new Vector3(0,20,0);
|
||||||
```
|
```
|
||||||
|
|
||||||
### Change the parameter on the data item SerieData
|
### Changing Parameters on Data Item SerieData
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
var serieData = chart.AddData(0, 20);
|
var serieData = chart.AddData(0, 20);
|
||||||
//var serieData = serie.GetSerieData(0); //从已有数据中获取
|
//var serieData = serie.GetSerieData(0); //To get from existing data
|
||||||
serieData.radius = 10;
|
serieData.radius = 10;
|
||||||
|
|
||||||
var itemStyle = serieData.EnsureComponent<ItemStyle>(); //给数据项添加ItemStyle组件
|
var itemStyle = serieData.EnsureComponent<ItemStyle>(); //Add ItemStyle component to the data item
|
||||||
itemStyle.color = Color.blue;
|
itemStyle.color = Color.blue;
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
10229
Documentation~/zh/api.md
10229
Documentation~/zh/api.md
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,9 @@ slug: /changelog
|
|||||||
# 更新日志
|
# 更新日志
|
||||||
|
|
||||||
[master](#master)
|
[master](#master)
|
||||||
|
[v3.13.0](#v3130)
|
||||||
|
[v3.12.1](#v3121)
|
||||||
|
[v3.12.0](#v3120)
|
||||||
[v3.11.2](#v3112)
|
[v3.11.2](#v3112)
|
||||||
[v3.11.1](#v3111)
|
[v3.11.1](#v3111)
|
||||||
[v3.11.0](#v3110)
|
[v3.11.0](#v3110)
|
||||||
@@ -76,6 +79,76 @@ slug: /changelog
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
## v3.13.0
|
||||||
|
|
||||||
|
版本要点:
|
||||||
|
|
||||||
|
* 新增`UIText`扩展组件
|
||||||
|
* 新增`UIToggle`扩展组件
|
||||||
|
* 新增`UISlider`扩展组件
|
||||||
|
* 重构`UIProgress`扩展组件
|
||||||
|
* 增加`SymbolStyle`的`borderWidth`和`emptyColor`配置
|
||||||
|
* 增加`SymbolStyle`的`size2`参数支持长方形标记
|
||||||
|
* 其他优化和问题修复
|
||||||
|
|
||||||
|
日志详情:
|
||||||
|
|
||||||
|
* (2025.01.01) 发布`v3.13.0`版本
|
||||||
|
* (2024.12.27) 增加`SymbolStyle`的`size2`参数支持长方形标记
|
||||||
|
* (2024.12.26) 优化`Text`在`TextMeshPro`下的居中对齐方式
|
||||||
|
* (2024.12.25) 增加`Tooltip`的`itemFormatter`设置`{f0}`支持
|
||||||
|
* (2024.12.25) 修复`YAxis`在范围变更刷新时部分label可能不显示的问题
|
||||||
|
* (2024.12.23) 增加`SymbolStyle`的`borderWidth`和`emptyColor`配置
|
||||||
|
* (2024.12.17) 增加`UISlider`扩展组件
|
||||||
|
* (2024.12.10) 增加`UIToggle`扩展组件
|
||||||
|
* (2024.12.09) 修复`UITable`的`scrollbar`无法拖动的问题
|
||||||
|
* (2024.12.07) 修复`Chart`节点下不能放自定义节点的问题
|
||||||
|
* (2024.12.05) 增加`UIText`扩展组件
|
||||||
|
* (2024.12.04) 删除`TextStyle`的无用配置项`tmpAlignment`
|
||||||
|
|
||||||
|
## v3.12.1
|
||||||
|
|
||||||
|
版本要点:
|
||||||
|
|
||||||
|
* 完善官网文档的中英文支持
|
||||||
|
* 优化折线图数据密集时的绘制效果
|
||||||
|
* 其他问题修复
|
||||||
|
|
||||||
|
日志详情:
|
||||||
|
|
||||||
|
* (2024.12.01) 发布`v3.12.1`版本
|
||||||
|
* (2024.11.30) 修复`Tooltip`在图表设置其他锚点时手机上显示位置异常的问题
|
||||||
|
* (2024.11.27) 修复`Unity6`的一些代码警告问题
|
||||||
|
* (2024.11.26) 修复`Tooltip`在特殊情况下可能会超出屏幕显示不完整的问题
|
||||||
|
* (2024.11.24) 修复`UITable`在拖拽时也会点选的问题
|
||||||
|
* (2024.11.22) 修复`Time`时间轴在开启`Animation`时动态变更效果异常的问题
|
||||||
|
* (2024.11.18) 优化`Line`在数据点过密时有更好的绘制效果
|
||||||
|
* (2024.11.16) 修复`Animation`无法通过代码开启的问题 (#334)
|
||||||
|
* (2024.11.13) 修复`DataZoom`的start和end在代码动态修改时图表不刷新的问题
|
||||||
|
* (2024.11.05) 修复`Title`设置隐藏后运行还显示的问题
|
||||||
|
* (2024.11.01) 完善`website`中英文文档
|
||||||
|
|
||||||
|
## v3.12.0
|
||||||
|
|
||||||
|
版本要点:
|
||||||
|
|
||||||
|
* 增加`Ring`的`radiusGradient`参数设置渐变方向
|
||||||
|
* 增加`numericFormatter`对`date`和`time`的支持
|
||||||
|
* 完善`AreaStyle`的`origin`参数设置区域填充起始位置
|
||||||
|
* 调整和完善文档
|
||||||
|
* 其他优化和修复
|
||||||
|
|
||||||
|
日志详情:
|
||||||
|
|
||||||
|
* (2024.09.30) 发布`v3.12.0`版本
|
||||||
|
* (2024.09.27) 完善`5分钟教程`
|
||||||
|
* (2024.09.24) 完善`Legend`的`formatter`对多Serie的支持 (#332)
|
||||||
|
* (2024.09.22) 调整`Documentation`文档显示样式
|
||||||
|
* (2024.09.09) 增加`numericFormatter`对`date`和`time`的支持
|
||||||
|
* (2024.09.03) 完善`AreaStyle`的`origin`参数设置区域填充起始位置
|
||||||
|
* (2024.09.01) 增加`Ring`的`radiusGradient`参数设置渐变方向
|
||||||
|
* (2024.09.01) 优化`Axis`为时间轴时首个Label的位置
|
||||||
|
|
||||||
## v3.11.2
|
## v3.11.2
|
||||||
|
|
||||||
* (2024.08.01) 发布`v3.11.2`版本
|
* (2024.08.01) 发布`v3.11.2`版本
|
||||||
@@ -167,12 +240,19 @@ slug: /changelog
|
|||||||
* (2024.01.23) 增加`{y}`通配符用于获取Y轴的类目名
|
* (2024.01.23) 增加`{y}`通配符用于获取Y轴的类目名
|
||||||
* (2024.01.23) 增加`Line`支持X轴和Y轴都为`Category`类目轴
|
* (2024.01.23) 增加`Line`支持X轴和Y轴都为`Category`类目轴
|
||||||
* (2024.01.18) 修复`Animation`的`type`代码动态修改无效的问题
|
* (2024.01.18) 修复`Animation`的`type`代码动态修改无效的问题
|
||||||
|
* (2024.01.16) 增加`UIImage`图片组件
|
||||||
|
* (2024.01.16) 优化`Background`组件,可设置圆角和边框
|
||||||
* (2024.01.13) 增加`Chart`的更多快捷创建图表菜单
|
* (2024.01.13) 增加`Chart`的更多快捷创建图表菜单
|
||||||
* (2024.01.09) 增加`Background`的`borderStyle`,给图表默认设置圆角
|
* (2024.01.09) 增加`Background`的`borderStyle`,给图表默认设置圆角
|
||||||
* (2024.01.07) 修复`Tooltop`的第一个`ContentLabelStyle`设置`color`无效的问题
|
* (2024.01.07) 修复`Tooltop`的第一个`ContentLabelStyle`设置`color`无效的问题
|
||||||
|
* (2024.01.03) 增加`UITable`的`carouselStyle`的`hoverPause`
|
||||||
|
* (2024.01.02) 增加`UITable`的`scrollStyle`的`borderStyle`
|
||||||
|
* (2024.01.02) 增加`UITable`的`columnHeadStyle`的`opaque`
|
||||||
|
* (2024.01.01) 调整`UITable`的`border`边框相关设置,用`BorderStyle`代替
|
||||||
* (2024.01.01) 增加`BorderStyle`边框样式
|
* (2024.01.01) 增加`BorderStyle`边框样式
|
||||||
* (2023.12.26) 增加`Heatmap`的`maxCache`参数支持
|
* (2023.12.26) 增加`Heatmap`的`maxCache`参数支持
|
||||||
* (2023.12.25) 优化`Line`开启`clip`时绘制的顶点数
|
* (2023.12.25) 优化`Line`开启`clip`时绘制的顶点数
|
||||||
|
* (2023.12.22) 增加`UITable`的行边框
|
||||||
* (2023.12.22) 修复`Scatter`散点图部分边界数据不显示的问题
|
* (2023.12.22) 修复`Scatter`散点图部分边界数据不显示的问题
|
||||||
* (2023.12.21) 修复`TriggerTooltip()`接口在指定0或最大index时可能无法触发的问题
|
* (2023.12.21) 修复`TriggerTooltip()`接口在指定0或最大index时可能无法触发的问题
|
||||||
* (2023.12.19) 修复`Legend`的`LabelStyle`设置`formatter`后不生效的问题
|
* (2023.12.19) 修复`Legend`的`LabelStyle`设置`formatter`后不生效的问题
|
||||||
@@ -211,15 +291,27 @@ slug: /changelog
|
|||||||
* (2023.11.23) 增加`Axis`的`Animation`支持动画效果
|
* (2023.11.23) 增加`Axis`的`Animation`支持动画效果
|
||||||
* (2023.11.16) 取消`Legend`的`formatter`,用`LabelStyle`的代替
|
* (2023.11.16) 取消`Legend`的`formatter`,用`LabelStyle`的代替
|
||||||
* (2023.11.14) 完善`LabelStyle`的`formatter`的注释和文档(#291)
|
* (2023.11.14) 完善`LabelStyle`的`formatter`的注释和文档(#291)
|
||||||
|
* (2023.11.14) 增加`UITable`的`GetData()`和`GetContent()`接口
|
||||||
|
* (2023.11.12) 增加`UITable`的`onTableClick`点击表格回调
|
||||||
|
* (2023.11.11) 重构`UITable`的`SeparatorStyle`,可分开设置行列的分割线
|
||||||
* (2023.11.11) 修复`Documentation`部分注释生成文档不完整的问题 (#290)
|
* (2023.11.11) 修复`Documentation`部分注释生成文档不完整的问题 (#290)
|
||||||
* (2023.11.11) 修复`Legend`的`formatter`在数据变更时没有自动刷新的问题
|
* (2023.11.11) 修复`Legend`的`formatter`在数据变更时没有自动刷新的问题
|
||||||
|
* (2023.11.05) 增加`UITable`的`ColumnStyle`,重构Column相关参数
|
||||||
|
* (2023.11.05) 增加`UITable`的`RowStyle`,重构Row相关参数
|
||||||
* (2023.11.05) 修复`SerieEventData`的`value`一直是0的问题 (#287)
|
* (2023.11.05) 修复`SerieEventData`的`value`一直是0的问题 (#287)
|
||||||
* (2023.11.03) 修复`Bar`设置渐变色时鼠标移出效果异常的问题 (#285)
|
* (2023.11.03) 修复`Bar`设置渐变色时鼠标移出效果异常的问题 (#285)
|
||||||
* (2023.11.02) 优化`SerieData`设置`ignore`时`formatter`的忽略问题
|
* (2023.11.02) 优化`SerieData`设置`ignore`时`formatter`的忽略问题
|
||||||
|
* (2023.11.01) 增加`UITable`的`CarouselStyle`轮播功能
|
||||||
|
* (2023.11.01) 增加`UITable`的`AddColumn()`和`UpdateColumn()`接口
|
||||||
* (2023.11.01) 增加`MarkLine`的`onTop`设置是否显示在最上层
|
* (2023.11.01) 增加`MarkLine`的`onTop`设置是否显示在最上层
|
||||||
|
* (2023.10.23) 修复`UITable`点击`Rebuild Object`异常的问题
|
||||||
|
* (2023.10.23) 修复`UITable`尺寸变化时不刷新的问题
|
||||||
* (2023.10.21) 修复`Pie`有0数据时`Label`的位置异常的问题
|
* (2023.10.21) 修复`Pie`有0数据时`Label`的位置异常的问题
|
||||||
* (2023.10.21) 增加`Axis`的对数轴支持子刻度
|
* (2023.10.21) 增加`Axis`的对数轴支持子刻度
|
||||||
* (2023.10.19) 修复`Pie`设置玫瑰图时引导线异常的问题
|
* (2023.10.19) 修复`Pie`设置玫瑰图时引导线异常的问题
|
||||||
|
* (2023.10.17) 修复`UITable`首次初始化异常的问题
|
||||||
|
* (2023.10.17) 增加`UITable`的数据操作接口
|
||||||
|
* (2023.10.17) 增加`UITable`的`RefreshTable()`刷新接口
|
||||||
* (2023.10.15) 修复`Line`设置`Animation`为`AlongPath`时动画异常的问题 (#281)
|
* (2023.10.15) 修复`Line`设置`Animation`为`AlongPath`时动画异常的问题 (#281)
|
||||||
* (2023.10.12) 修复`MarkLine`指定`yValue`时对数值轴无效的问题
|
* (2023.10.12) 修复`MarkLine`指定`yValue`时对数值轴无效的问题
|
||||||
* (2023.10.11) 修复`Serie`的`showDataDimension`设置无效的问题
|
* (2023.10.11) 修复`Serie`的`showDataDimension`设置无效的问题
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,183 +5,147 @@ slug: /faq
|
|||||||
|
|
||||||
# 常见问题
|
# 常见问题
|
||||||
|
|
||||||
[FAQ 1:如何调整坐标轴与背景的边距?](#如何调整坐标轴与背景的边距)
|
## FAQ 1:如何调整坐标轴与背景的边距?
|
||||||
[FAQ 2:如何让初始动画重新播放?](#如何让初始动画重新播放)
|
|
||||||
[FAQ 3:如何自定义折线图饼图的颜色?](#如何自定义折线图饼图的颜色)
|
|
||||||
[FAQ 4:如何给坐标轴上的文本加上单位?](#如何给坐标轴上的文本加上单位)
|
|
||||||
[FAQ 5:如何让柱形图的柱子堆叠显示?](#如何让柱形图的柱子堆叠显示)
|
|
||||||
[FAQ 6:如何让柱形图的柱子同柱但不重叠?](#如何让柱形图的柱子同柱但不重叠)
|
|
||||||
[FAQ 7:如何调整柱形图的柱子宽度和间距?](#如何调整柱形图的柱子宽度和间距)
|
|
||||||
[FAQ 8:如何调整柱形图单个柱子的颜色?](#如何调整柱形图单个柱子的颜色)
|
|
||||||
[FAQ 9:如何调整图表的对齐方式?](#如何调整图表的对齐方式)
|
|
||||||
[FAQ 10:可以显示超过1000以上的大数据吗?](#可以显示超过1000以上的大数据吗)
|
|
||||||
[FAQ 11:折线图可以画虚线、点线、点划线吗?](#折线图可以画虚线点线点划线吗)
|
|
||||||
[FAQ 12:如何限定Y轴的值范围?](#如何限定y轴的值范围)
|
|
||||||
[FAQ 13:如何自定义数值轴刻度大小?](#如何自定义数值轴刻度大小)
|
|
||||||
[FAQ 14:如何在数据项顶上显示文本?](#如何在数据项顶上显示文本)
|
|
||||||
[FAQ 15:如何给数据项自定义图标?](#如何给数据项自定义图标)
|
|
||||||
[FAQ 16:锯齿太严重,如何让图表更顺滑?](#锯齿太严重如何让图表更顺滑)
|
|
||||||
[FAQ 17:为什么鼠标移上图表Tooltip不显示?](#为什么鼠标移上图表tooltip不显示)
|
|
||||||
[FAQ 18:如何取消Tooltip的竖线?](#如何取消tooltip的竖线)
|
|
||||||
[FAQ 19:如何自定义Tooltip的显示内容?](#如何自定义tooltip的显示内容)
|
|
||||||
[FAQ 20:如何让y轴显示多位小数?](#如何让y轴显示多位小数)
|
|
||||||
[FAQ 21:如何用代码动态更新数据?](#如何用代码动态更新数据)
|
|
||||||
[FAQ 22:如何显示图例?为什么有时候图例无法显示?](#如何显示图例为什么有时候图例无法显示)
|
|
||||||
[FAQ 23:如何做成预设?](#如何做成预设)
|
|
||||||
[FAQ 24:如何在图表上画点画线等自定义内容?](#如何在图表上画点画线等自定义内容)
|
|
||||||
[FAQ 25:如何实现心电图类似的数据移动效果?](#如何实现心电图类似的数据移动效果)
|
|
||||||
[FAQ 26:如何使用背景组件?有什么条件限制?](#如何使用背景组件有什么条件限制)
|
|
||||||
[FAQ 27:Mesh can not have more than 65000 vertices?](#mesh_cannot_have_more_than_65000_vertices)
|
|
||||||
[FAQ 28:为什么serie里设置的参数运行后又被重置了?](#为什么serie里设置的参数运行后又被重置了)
|
|
||||||
[FAQ 29:如何修改serie的symbol的颜色?](#如何修改serie的symbol的颜色)
|
|
||||||
[FAQ 30:导入或更新XCharts时TMP报错如何处理?](#导入或更新xcharts时tmp报错怎么办)
|
|
||||||
[FAQ 31:支持空数据吗?如何实现折线图断开的效果?](#支持空数据吗如何实现折线图断开的效果)
|
|
||||||
[FAQ 32:2.x版本升级3.x版本时常见的问题有哪些?](#xcharts2升级xcharts3时常见的问题有哪些)
|
|
||||||
[FAQ 33:折线图如何两边不留空白而从0坐标开始显示?](#折线图如何两边不留空白而从0坐标开始显示)
|
|
||||||
[FAQ 34:如何设置部分Serie不显示Tooltip?](#如何设置部分serie不显示tooltip)
|
|
||||||
|
|
||||||
## 如何调整坐标轴与背景的边距
|
|
||||||
|
|
||||||
调整`Grid`组件,可调整上下左右边距。
|
调整`Grid`组件,可调整上下左右边距。
|
||||||
|
|
||||||
## 如何让初始动画重新播放
|
## FAQ 2:如何让初始动画重新播放?
|
||||||
|
|
||||||
调用`chart.AnimationReset()`接口。
|
调用`chart.AnimationReset()`接口。
|
||||||
|
|
||||||
## 如何自定义折线图饼图的颜色
|
## FAQ 3:如何自定义折线图饼图的颜色?
|
||||||
|
|
||||||
通过`Theme`的`colorPalette`调整,或者部分`Serie`下的`LineStyle`和`ItemStyle`。
|
通过`Theme`的`colorPalette`调整,或者部分`Serie`下的`LineStyle`和`ItemStyle`。
|
||||||
|
|
||||||
## 如何给坐标轴上的文本加上单位
|
## FAQ 4:如何给坐标轴上的文本加上单位?
|
||||||
|
|
||||||
通过`formatter`和`numericFormatter`参数,在`Legend`、`Axis`的`AxisLabel`、`Tooltop`、`Serie`的`Label`都提供该参数的配置。
|
通过`formatter`和`numericFormatter`参数,在`Legend`、`Axis`的`AxisLabel`、`Tooltop`、`Serie`的`Label`都提供该参数的配置。
|
||||||
|
|
||||||
## 如何让柱形图的柱子堆叠显示
|
## FAQ 5:如何让柱形图的柱子堆叠显示?
|
||||||
|
|
||||||
设置`Serie`下的`stack`,`stack`相同的`serie`会堆叠显示在一个柱子上。
|
设置`Serie`下的`stack`,`stack`相同的`serie`会堆叠显示在一个柱子上。
|
||||||
|
|
||||||
## 如何让柱形图的柱子同柱但不重叠
|
## FAQ 6:如何让柱形图的柱子同柱但不重叠?
|
||||||
|
|
||||||
设置`Serie`下的`barGap`为`-1`,`stack`为空。
|
设置`Serie`下的`barGap`为`-1`,`stack`为空。
|
||||||
|
|
||||||
## 如何调整柱形图的柱子宽度和间距
|
## FAQ 7:如何调整柱形图的柱子宽度和间距?
|
||||||
|
|
||||||
调整`Serie`下的`barWidth`和`barGap`,多个`serie`时最后一个`serie`的`barWidth`和`barGap`有效。
|
调整`Serie`下的`barWidth`和`barGap`,多个`serie`时最后一个`serie`的`barWidth`和`barGap`有效。
|
||||||
|
|
||||||
## 如何调整柱形图单个柱子的颜色
|
## FAQ 8:如何调整柱形图单个柱子的颜色?
|
||||||
|
|
||||||
可通过调整单个`Data`下的`ItemStyle`调整,也可以通过两个`serie`同柱不堆叠来实现,通过设置数据项为`0`来达到类似效果。
|
可通过调整单个`Data`下的`ItemStyle`调整,也可以通过两个`serie`同柱不堆叠来实现,通过设置数据项为`0`来达到类似效果。
|
||||||
|
|
||||||
## 如何调整图表的对齐方式
|
## FAQ 9:如何调整图表的对齐方式?
|
||||||
|
|
||||||
调整RectTransform的锚点,和UGUI的其他组件的用法一致。
|
调整RectTransform的锚点,和UGUI的其他组件的用法一致。
|
||||||
|
|
||||||
## 可以显示超过1000以上的大数据吗
|
## FAQ 10:可以显示超过1000以上的大数据吗?
|
||||||
|
|
||||||
可以。但`UGUI`对单个`Graphic`限制`65000`个顶点,所以太多的数据不一定能显示完全。可通过设置采样距离`sampleDist`开启采样简化过密曲线。也可以通过设置一些参数来减少图表的顶点数有助于显示更多数据。如缩小图表的尺寸,关闭或减少坐标轴的客户端绘制,关闭`Serie`的`symbol`和`label`显示等。折线图的普通线图`Normal`比平滑线图`Smooth`占用顶点数更少。`1.5.0`以上版本可以设置`large`和`largeThreshold`参数来开启性能模式。
|
可以。但`UGUI`对单个`Graphic`限制`65000`个顶点,所以太多的数据不一定能显示完全。可通过设置采样距离`sampleDist`开启采样简化过密曲线。也可以通过设置一些参数来减少图表的顶点数有助于显示更多数据。如缩小图表的尺寸,关闭或减少坐标轴的客户端绘制,关闭`Serie`的`symbol`和`label`显示等。折线图的普通线图`Normal`比平滑线图`Smooth`占用顶点数更少。`1.5.0`以上版本可以设置`large`和`largeThreshold`参数来开启性能模式。
|
||||||
|
|
||||||
## 折线图可以画虚线点线点划线吗
|
## FAQ 11:折线图可以画虚线、点线、点划线吗?
|
||||||
|
|
||||||
可以。通过`Serie`下的`lineType`选择线条样式。当要显示的数据过多(成千以上)数据间过密时建议使用`Normal`或者`Step`样式。
|
可以。通过`Serie`下的`lineType`选择线条样式。当要显示的数据过多(成千以上)数据间过密时建议使用`Normal`或者`Step`样式。
|
||||||
|
|
||||||
## 如何限定y轴的值范围
|
## FAQ 12:如何限定Y轴的值范围?
|
||||||
|
|
||||||
设置`Axis`下的`minMaxType`为`Custom`,自定义`min`和`max`。
|
设置`Axis`下的`minMaxType`为`Custom`,自定义`min`和`max`。
|
||||||
|
|
||||||
## 如何自定义数值轴刻度大小
|
## FAQ 13:如何自定义数值轴刻度大小?
|
||||||
|
|
||||||
默认时通过`Axis`下的`splitNumer`进行自动划分。也可以设置`interval`自定义刻度大小。
|
默认时通过`Axis`下的`splitNumer`进行自动划分。也可以设置`interval`自定义刻度大小。
|
||||||
|
|
||||||
## 如何在数据项顶上显示文本
|
## FAQ 14:如何在数据项顶上显示文本?
|
||||||
|
|
||||||
通过设置`Serie`下的`Label`。3.0版本需要先添加`LabelStyle`组件。
|
通过设置`Serie`下的`Label`。3.0版本需要先添加`LabelStyle`组件。
|
||||||
|
|
||||||
## 如何给数据项自定义图标
|
## FAQ 15:如何给数据项自定义图标?
|
||||||
|
|
||||||
通过设置`Serie`的`data`下的数据项可单独设置`icon`相关参数。
|
通过设置`Serie`的`data`下的数据项可单独设置`icon`相关参数。
|
||||||
|
|
||||||
## 锯齿太严重如何让图表更顺滑
|
## FAQ 16:锯齿太严重,如何让图表更顺滑?
|
||||||
|
|
||||||
开启抗锯齿设置(在`Unity`里设置)。调整UI渲染模式为`Camera`模式,开启`MSAA`,设置`4`倍或更高抗锯齿。
|
开启抗锯齿设置(在`Unity`里设置)。调整UI渲染模式为`Camera`模式,开启`MSAA`,设置`4`倍或更高抗锯齿。
|
||||||
|
|
||||||
## 为什么鼠标移上图表tooltip不显示
|
## FAQ 17:为什么鼠标移上图表Tooltip不显示?
|
||||||
|
|
||||||
确认`Tooltip`是否开启;确认父节点是否关闭了鼠标事件。
|
确认`Tooltip`是否开启;确认父节点是否关闭了鼠标事件。
|
||||||
|
|
||||||
## 如何取消tooltip的竖线
|
## FAQ 18:如何取消Tooltip的竖线?
|
||||||
|
|
||||||
设置`Tooltip`的`type`为`None`。或者调整`lineStyle`的参数。
|
设置`Tooltip`的`type`为`None`。或者调整`lineStyle`的参数。
|
||||||
|
|
||||||
## 如何自定义tooltip的显示内容
|
## FAQ 19:如何自定义Tooltip的显示内容?
|
||||||
|
|
||||||
自定义总的内容可以通过`Tooltip`的`formatter`。如果只是想调整所有的`serie`的显示格式可以用`itemFormatter`和`titleFormatter`结合。如果想每个`serie`的显示格式不一样,可以定制`serie`的`itemStyle`里的`tooltipFormatter`。具体的用法请查阅[XCharts配置项手册](https://xcharts-team.github.io/docs/configuration#Tooltip-itemFormatter)。
|
自定义总的内容可以通过`Tooltip`的`formatter`。如果只是想调整所有的`serie`的显示格式可以用`itemFormatter`和`titleFormatter`结合。如果想每个`serie`的显示格式不一样,可以定制`serie`的`itemStyle`里的`tooltipFormatter`。具体的用法请查阅[XCharts配置项手册](https://xcharts-team.github.io/docs/configuration#Tooltip-itemFormatter)。
|
||||||
|
|
||||||
## 如何让y轴显示多位小数
|
## FAQ 20:如何让y轴显示多位小数?
|
||||||
|
|
||||||
设置`Axis`下的`AxisLabel`中的`formatter`为`{value:f1}`或`{value:f2}`。`1.5.0`及以上版本通过`numericFormatter`设置。
|
设置`Axis`下的`AxisLabel`中的`formatter`为`{value:f1}`或`{value:f2}`。`1.5.0`及以上版本通过`numericFormatter`设置。
|
||||||
|
|
||||||
## 如何用代码动态更新数据
|
## FAQ 21:如何用代码动态更新数据?
|
||||||
|
|
||||||
请查阅`Example`下的代码,`Example13_LineSimple.cs`就是一个简单添加数据构建折线图的例子,其他`Demo`也都是通过代码控制不同的组件实现不同的功能,相关API请查看文档:[XChartsAPI接口](api.md) 。
|
请查阅`Example`下的代码,`Example13_LineSimple.cs`就是一个简单添加数据构建折线图的例子,其他`Demo`也都是通过代码控制不同的组件实现不同的功能,相关API请查看文档:[XChartsAPI接口](api.md) 。
|
||||||
|
|
||||||
## 如何显示图例为什么有时候图例无法显示
|
## FAQ 22:如何显示图例?为什么有时候图例无法显示?
|
||||||
|
|
||||||
首先,你的`serie`里的`name`需有值不为空。然后开启`Legend`显示,里面的`data`可以默认为空,表示显示所有的图例。如果你只想显示部分`serie`的图例,在`data`中填入要显示的图例的`name`即可。如果`data`中的值都不是系列的`name`,那图例就不会显示。
|
首先,你的`serie`里的`name`需有值不为空。然后开启`Legend`显示,里面的`data`可以默认为空,表示显示所有的图例。如果你只想显示部分`serie`的图例,在`data`中填入要显示的图例的`name`即可。如果`data`中的值都不是系列的`name`,那图例就不会显示。
|
||||||
|
|
||||||
## 如何做成预设
|
## FAQ 23:如何做成预设?
|
||||||
|
|
||||||
做成prefab前,执行一下`Rebuild Chart Object`重新刷新节点,避免有冗余的节点存在。
|
做成prefab前,执行一下`Rebuild Chart Object`重新刷新节点,避免有冗余的节点存在。
|
||||||
|
|
||||||
## 如何在图表上画点画线等自定义内容
|
## FAQ 24:如何在图表上画点画线等自定义内容?
|
||||||
|
|
||||||
`XCharts`有自定义绘制回调`onCustomDraw`,具体可参考`Example12_CustomDrawing.cs`
|
`XCharts`有自定义绘制回调`onCustomDraw`,具体可参考`Example12_CustomDrawing.cs`
|
||||||
|
|
||||||
## 如何实现心电图类似的数据移动效果
|
## FAQ 25:如何实现心电图类似的数据移动效果?
|
||||||
|
|
||||||
参考`Example`目录下的`Example_Dynamic.cs`。主要通过设置`maxCache`参数实现。`axis`和`serie`都设置相同的`maxCache`。`maxCache`可固定数据个数,当数据超过设定时会先删除第一个在添加新数据,实现数据移动效果。
|
参考`Example`目录下的`Example_Dynamic.cs`。主要通过设置`maxCache`参数实现。`axis`和`serie`都设置相同的`maxCache`。`maxCache`可固定数据个数,当数据超过设定时会先删除第一个在添加新数据,实现数据移动效果。
|
||||||
|
|
||||||
## 如何使用背景组件有什么条件限制
|
## FAQ 26:如何使用背景组件?有什么条件限制?
|
||||||
|
|
||||||
设置`background`组件的`show`为`true`。
|
设置`background`组件的`show`为`true`。
|
||||||
|
|
||||||
## 区域折线图在用半透明颜色时有时候会一条叠加的线
|
## FAQ 27:Mesh can not have more than 65000 vertices?
|
||||||
|
|
||||||
这是区域折线图绘制的bug。可以用浅的不透的颜色替代半透明颜色。
|
|
||||||
|
|
||||||
## mesh_cannot_have_more_than_65000_vertices
|
|
||||||
|
|
||||||
这是`UGUI`对单个`Graphic`的顶点数限制。`XCharts`是将图形绘制在单个`Graphic`上,所以也会有这个限制。解决的办法可以参考:[FAQ 10:可以显示超过1000以上的大数据吗?](#可以显示超过1000以上的大数据吗)
|
这是`UGUI`对单个`Graphic`的顶点数限制。`XCharts`是将图形绘制在单个`Graphic`上,所以也会有这个限制。解决的办法可以参考:[FAQ 10:可以显示超过1000以上的大数据吗?](#可以显示超过1000以上的大数据吗)
|
||||||
|
|
||||||
## 为什么serie里设置的参数运行后又被重置了
|
## FAQ 28:为什么serie里设置的参数运行后又被重置了?
|
||||||
|
|
||||||
检测下代码里是否调用了`RemoveData()`并重新添加`Serie`了。如果想保留`Serie`的配置可以只`ClearData()`,然后重新添加数据。
|
检测下代码里是否调用了`RemoveData()`并重新添加`Serie`了。如果想保留`Serie`的配置可以只`ClearData()`,然后重新添加数据。
|
||||||
|
|
||||||
## 如何修改serie的symbol的颜色
|
## FAQ 29:如何修改serie的symbol的颜色?
|
||||||
|
|
||||||
`Symbol` 的颜色是使用的 `ItemStyle` 的 `color`。
|
`Symbol` 的颜色是使用的 `ItemStyle` 的 `color`。
|
||||||
|
|
||||||
## 导入或更新xcharts时tmp报错怎么办
|
## FAQ 30:导入或更新XCharts时TMP报错如何处理?
|
||||||
|
|
||||||
XCharts默认时不开启TMP,所以asmdef上没有TMP的引用。当本地开启TMP后再更新XCharts可能会出现这个问题。可通过以下两种方式解决:
|
XCharts默认时不开启TMP,所以asmdef上没有TMP的引用。当本地开启TMP后再更新XCharts可能会出现这个问题。可通过以下两种方式的任意一种解决:
|
||||||
|
|
||||||
1. 找到`XCharts.Runtime.asmdef`和`XCharts.Editor.asmdef`,手动加上 `TextMeshPro`的引用
|
1. 找到`XCharts.Runtime.asmdef`和`XCharts.Editor.asmdef`,手动加上 `TextMeshPro`的引用
|
||||||
2. 移除`PlayerSetting`中`Scripting Define Symbols`的`dUI_TextMeshPro`宏
|
2. 移除`PlayerSetting`中`Scripting Define Symbols`的`dUI_TextMeshPro`宏
|
||||||
|
|
||||||
`3.8.0`版本后增加[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)守护程序,将XCharts-Daemon导入项目后,在更新XCharts时守护程序会自动根据本地开启的TMP情况刷新asmdef,确保编译正常。
|
`3.8.0`版本后增加[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)守护程序,将XCharts-Daemon导入项目后,在更新XCharts时守护程序会自动根据本地开启的TMP情况刷新asmdef,确保编译正常。
|
||||||
|
|
||||||
## 支持空数据吗如何实现折线图断开的效果
|
## FAQ 31:支持空数据吗?如何实现折线图断开的效果?
|
||||||
|
|
||||||
`Serie`的`data`是`double`类型,所以无法表示空数据。可通过开启`Serie`的`ignore`和指定`ignoreValue`来达到空数据的效果。也可以每个`SerieData`设置`ignore`参数。忽略数据后断开还是连接可设置`ignoreLineBreak`参数。
|
`Serie`的`data`是`double`类型,所以无法表示空数据。可通过开启`Serie`的`ignore`和指定`ignoreValue`来达到空数据的效果。也可以每个`SerieData`设置`ignore`参数。忽略数据后断开还是连接可设置`ignoreLineBreak`参数。
|
||||||
|
|
||||||
## xcharts2升级xcharts3时常见的问题有哪些
|
## FAQ 32:2.x版本升级3.x版本时常见的问题有哪些?
|
||||||
|
|
||||||
1. 'XCharts.Runtime.XChartsMgr' is missing the class attribute 'ExtensionOfNativeClass'!
|
1. 出现:`'XCharts.Runtime.XChartsMgr' is missing the class attribute 'ExtensionOfNativeClass'!`的问题时,是因为3.x版本时不需要挂载XChartsMgr,直接删掉场景上的`_xcharts_`节点即可。
|
||||||
3.x版本时不需要挂载XChartsMgr,直接删掉场景上的`_xcharts_`节点即可。
|
|
||||||
|
|
||||||
## 折线图如何两边不留空白而从0坐标开始显示
|
## FAQ 33:折线图如何两边不留空白而从0坐标开始显示?
|
||||||
|
|
||||||
设置X轴的`boundaryGap`参数。
|
设置X轴的`boundaryGap`参数。
|
||||||
|
|
||||||
## 如何设置部分serie不显示tooltip
|
## FAQ 34:如何设置部分Serie不显示Tooltip?
|
||||||
|
|
||||||
`serie`的`itemStyle`的`itemFormatter`设置为`-`可以忽略`tooltip`。
|
`serie`的`itemStyle`的`itemFormatter`设置为`-`可以忽略该`serie`的`tooltip`。
|
||||||
|
|
||||||
|
## FAQ 35:区域折线图在用半透明颜色时有时候会一条叠加的线
|
||||||
|
|
||||||
|
这是区域折线图绘制的bug。可以用浅的不透的颜色替代半透明颜色。
|
||||||
|
|||||||
BIN
Documentation~/zh/img/tutorial01_axisdata.png
Normal file
BIN
Documentation~/zh/img/tutorial01_axisdata.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
Documentation~/zh/img/tutorial01_seriedata.png
Normal file
BIN
Documentation~/zh/img/tutorial01_seriedata.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -6,84 +6,146 @@ slug: /tutorial01
|
|||||||
|
|
||||||
# 教程:5分钟上手 XCharts 3.0
|
# 教程:5分钟上手 XCharts 3.0
|
||||||
|
|
||||||
> 注:本教程适用XCharts 3.x版本,2.x版本请看 [教程:5分钟上手XCharts 2.0](https://github.com/XCharts-Team/XCharts/blob/2.0/Doc/教程:5分钟上手XCharts.md)
|
:::warning
|
||||||
|
|
||||||
## 使用 XCharts 前需要掌握什么
|
Note:本教程仅适用XCharts 3.x版本,2.x版本请看 [教程:5分钟上手XCharts 2.0](https://github.com/XCharts-Team/XCharts/blob/2.0/Doc/教程:5分钟上手XCharts.md)
|
||||||
|
|
||||||
- 会简单使用Unity
|
:::
|
||||||
- 了解UGUI,会使用UGUI
|
|
||||||
- 了解Unity的MonoBehavior脚本用法,知道怎么挂脚本,用代码操作脚本
|
|
||||||
|
|
||||||
## 获取和导入 XCharts
|
## XCharts的前提条件
|
||||||
|
|
||||||
XCharts可通过以下任意一种方式导入到项目:
|
XCharts是一个Unity图表插件,目前只能在Unity平台使用。
|
||||||
|
|
||||||
- 直接将XCharts源码到项目
|
使用XCharts前,你需要:
|
||||||
|
|
||||||
下载好XCharts源码后,直接将XCharts目录拷贝到Unity项目工程的Assets目录下。
|
- 掌握Unity的基本用法。
|
||||||
|
- 掌握UGUI制作UI的基本用法。
|
||||||
|
- 了解Unity的MonoBehavior脚本用法,知道怎么挂脚本和用代码操作脚本。
|
||||||
|
|
||||||
- 通过`Assets/Import Package`导入XCharts
|
如果你刚接触Unity,建议先学习Unity相关的基础教程再使用XCharts。
|
||||||
|
|
||||||
下载好XCharts的.unitypackage文件后,打开Unity,菜单栏 Assets-->Import Package-->选中.unitypackage导入即可开始使用XCharts。
|
## XCharts的获取和导入
|
||||||
|
|
||||||
- 通过`Package Manager`导入XCharts
|
XCharts主要通过Github来维护更新和发布,可以到[【Github主页】](https://github.com/XCharts-Team)进行下载获取源码和Pacakge;对于无Github访问条件的用户,可以访问[【国内镜像】](https://gitee.com/monitor1394/unity-ugui-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。
|
XCharts可通过以下任意一种方式导入到你的项目:
|
||||||
|
|
||||||
也可以直接将package加入到`manifest.json`文件:打开`Packages`目录下的`manifest.json`文件,在`dependencies`下加入:
|
### 直接将XCharts源码拷贝到项目
|
||||||
|
|
||||||
``` json
|
下载好XCharts源码后,直接将XCharts目录拷贝到Unity项目工程的Assets目录下。编译通过后即可使用。
|
||||||
"com.monitor1394.xcharts": "https://github.com/XCharts-Team/XCharts.git#3.0",
|
|
||||||
```
|
|
||||||
|
|
||||||
如需更新`XCharts`,删除`manifest.json`文件(部分Unity版本可能是packages-lock.json文件)的`lock`下的`com.monitor1394.xcharts`相关内容即会重新下载编译。
|
### 通过Import Package导入XCharts
|
||||||
|
|
||||||
- 建议先导入XCharts的守护程序(非必须)
|
下载好XCharts的.unitypackage文件后,打开Unity,菜单栏 Assets-->Import Package-->选中下载好的.unitypackage进行导入。导入完成并通过编译后即可开始使用XCharts。
|
||||||
|
|
||||||
守护程序[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)可以确保更新时编译正常,当本地开启TextMeshPro或NewInputSystem时将会非常有用。将XCharts-Daemon导入项目后,在更新XCharts时守护程序会自动根据本地TMP等的开启情况刷新asmdef,确保编译正常,不用手动去解决,方便CI-CD等自动化流程执行。
|
### 通过Package Manager导入XCharts
|
||||||
|
|
||||||
## 添加一个简单图表
|
对于2018.3以上的Unity版本,可通过Package Manager来导入XCharts,打开Package Manager后,通过 `Add package form git URL...`,输入XCharts的GitHub URL: `https://github.com/XCharts-Team/XCharts.git` 编译通过后即可使用XCharts。
|
||||||
|
|
||||||
在`Hierarchy`视图下右键`UI->XCharts->LineChart`或菜单栏`GameObject`下拉选择`XCharts->LineChart`,即可快速创建一个默认的折线图出来:
|
对于部分Unity版本,也可以直接将package加入到`manifest.json`文件:打开`Packages`目录下的`manifest.json`文件,在`dependencies`下加入:
|
||||||
|
|
||||||
|
>"com.monitor1394.xcharts": "https://github.com/XCharts-Team/XCharts.git",
|
||||||
|
|
||||||
|
如需更新`XCharts`,删除`manifest.json`文件(部分Unity版本可能是packages-lock.json文件)的`lock`下的`com.monitor1394.xcharts`相关内容即会重新下载编译。
|
||||||
|
|
||||||
|
### 建议导入XCharts的守护程序
|
||||||
|
|
||||||
|
守护程序[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)可以确保更新时编译正常,当本地开启TextMeshPro或NewInputSystem时将会非常有用。将XCharts-Daemon导入项目后,在更新XCharts时守护程序会自动根据本地TMP等的开启情况刷新XCharts的asmdef,确保编译正常,不用手动去解决,方便CI/CD等自动化流程执行。
|
||||||
|
|
||||||
|
XCharts-Daemon的导入方式可参考刚才的XCharts导入方式。可以通过源码或Package的方式导入项目,XCharts-Daemon的Github URL:https://github.com/XCharts-Team/XCharts-Daemon.git
|
||||||
|
|
||||||
|
## XCharts的基本使用
|
||||||
|
|
||||||
|
导入XCharts并编译通过后,Unity编辑器的菜单栏会显示XCharts,这时可以开始使用XCharts了。
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
Unity的菜单栏出现XCharts菜单时才表示XCharts可用。
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### 添加一个简单图表
|
||||||
|
|
||||||
|
在`Hierarchy`视图下右键`UI->XCharts->LineChart`或菜单栏`XCharts`下拉选择`LineChart`,即可快速创建一个默认的折线图:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 添加多个Seire
|
如需在某个节点下创建图表,可以选中节点右键`UI->XCharts->LineChart`即可在节点下创建图表。
|
||||||
|
|
||||||
|
### 修改图表数据
|
||||||
|
|
||||||
|
刚创建的图表,它的数据可以在Inspector视图面板上进行修改。
|
||||||
|
|
||||||
|
对于X轴数据,可通过:`XAxis->Data`展开后进行增删和修改:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
对于Serie数据,可通过:`Serie->Data`展开后进行增删和修改:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Serie支持多维数据,一般折线图只用到二维数据:第一维表示X轴类目数据的编号,第二维表示对应的数值。
|
||||||
|
|
||||||
|
### 添加多个Seire
|
||||||
|
|
||||||
在`Inspector`视图,找到`LineChart`的面板,通过`Add Serie`按钮,可以添加第二条`Line`折线:
|
在`Inspector`视图,找到`LineChart`的面板,通过`Add Serie`按钮,可以添加第二条`Line`折线:
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
## 添加其他组件
|
:::tip
|
||||||
|
|
||||||
|
Serie通过`Add Serie`按钮添加。可添加不同类型的Serie。[XCharts有哪些Serie?](https://xcharts-team.github.io/docs/configuration#serie-系列)
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### 添加其他主组件
|
||||||
|
|
||||||
默认图表没有`Legend`,需要`Legend`组件可通过`Add Component`按钮添加:
|
默认图表没有`Legend`,需要`Legend`组件可通过`Add Component`按钮添加:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## 添加Serie组件
|
:::tip
|
||||||
|
|
||||||
Serie只自带了几个常见的组件,其他组件按需额外添加。比如,需要给折线图区域填充颜色,可单独给`Serie`添加`AreaStyle`组件:
|
主组件通过`Add Component`按钮添加。[XCharts有哪些主组件?](https://xcharts-team.github.io/docs/configuration/#maincomponent-主组件)
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### 添加Serie组件
|
||||||
|
|
||||||
|
Serie只自带了几个常见的组件,其他组件用到时需额外添加。比如,需要给折线图进行区域填充颜色,可单独给`Serie`添加`AreaStyle`组件:
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
## 添加SerieData组件
|
:::tip
|
||||||
|
|
||||||
如果需要个性化定制每个数据项的配置,可以单独给每个`SerieData`添加`Component`。比如我们给折线图的第二个数据单独显示`Label`:
|
Serie组件通过Serie右边的按钮添加。[XCharts有哪些Serie组件?](https://xcharts-team.github.io/docs/configuration/#iseriecomponent-可添加到serie的组件)
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### 添加SerieData组件
|
||||||
|
|
||||||
|
如果需要个性化定制每个数据项的配置,可以单独给每个`SerieData`添加组件。比如我们给折线图的第二个数据单独显示`Label`:
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
## 更多组件和配置参数
|
:::tip
|
||||||
|
|
||||||
XCharts经过不断的迭代优化,目前已有多达几十种的主组件和子组件,每个组件有几个至几十个不等的可配置参数,以支持各种灵活而复杂的功能。
|
SerieData组件通过展开SerieData后Component右边的按钮添加。[XCharts有哪些SerieData组件?](https://xcharts-team.github.io/docs/configuration/#iseriedatacomponent-可添加到seriedata的组件)
|
||||||
|
|
||||||
首次使用XCharts,可在 `Inspector` 视图添加各种图表,给图表添加或调整里面组件,`Game` 视图会实时反馈调整后的效果,以熟悉各种组件的使用。各个组件的详细参数说明可查阅[XCharts配置项手册](configuration.md)。
|
:::
|
||||||
|
|
||||||
## 如何快速调整参数
|
### 更多组件和配置参数
|
||||||
|
|
||||||
`XCharts`是配置和数据来驱动的。想要什么效果,只需要去调整对应组件下的配置参数就可以,不需要去改`Hierarchy`视图下的节点,因为那些节点是由`XCharts`内部根据配置和数据生成的,即使改了也会在刷新时还原回来。
|
XCharts经过不断的迭代优化,目前已有多达几十种的主组件和子组件,每个组件有几个到几十个的可配置参数,用来支持多样化的功能。
|
||||||
|
|
||||||
|
首次使用XCharts,建议亲自去测试下各个图表各个组件的实际效果。`Inspector` 视图可以直接添加各种图表,各种组件以及调整各个配置参数,`Game` 视图会实时反馈调整后的效果。各个组件的详细参数说明可查阅[XCharts配置项手册](configuration.md)。
|
||||||
|
|
||||||
|
### 如何快速调整参数
|
||||||
|
|
||||||
|
XCharts是数据和参数驱动的。想要什么效果,只需要去调整对应组件下的配置参数就可以,不能去改`Hierarchy`视图下的节点,因为那些节点是由XCharts内部根据配置和数据生成的,即使改了也会在刷新时被还原掉。
|
||||||
|
|
||||||
如何快速定位你想要改的效果所对应的组件,这就需要对组件有一定的了解。比如我们想要让X轴的轴线末端显示箭头,如何定位?第一步,X轴定位到`XAxis0`;第二步,轴线定位到`AxisLine`;最后,再去看`AxisLine`组件下有没有这样的参数可以实现这个效果,对于不太确定的参数可以查阅[XCharts配置项手册](configuration.md)。
|
如何快速定位你想要改的效果所对应的组件,这就需要对组件有一定的了解。比如我们想要让X轴的轴线末端显示箭头,如何定位?第一步,X轴定位到`XAxis0`;第二步,轴线定位到`AxisLine`;最后,再去看`AxisLine`组件下有没有这样的参数可以实现这个效果,对于不太确定的参数可以查阅[XCharts配置项手册](configuration.md)。
|
||||||
|
|
||||||
@@ -93,9 +155,13 @@ XCharts经过不断的迭代优化,目前已有多达几十种的主组件和
|
|||||||
2. 如果`Serie`的`ItemStyle`配置有非`0000`颜色值,则优先用这个颜色值。
|
2. 如果`Serie`的`ItemStyle`配置有非`0000`颜色值,则优先用这个颜色值。
|
||||||
3. 否则颜色值取自主题`Theme`的`Color Palette`。
|
3. 否则颜色值取自主题`Theme`的`Color Palette`。
|
||||||
|
|
||||||
通常颜色值为0000时表示用主题默认颜色,配置为0或null时表示用主题默认配置。
|
:::tip
|
||||||
|
|
||||||
## 用代码添加折线图
|
通常颜色值为0000时表示用主题默认颜色;其他参数为0或null时表示用主题默认配置;设置颜色时注意透明度。
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### 用代码添加折线图
|
||||||
|
|
||||||
给`gameObject`挂上`LineChart`脚本:
|
给`gameObject`挂上`LineChart`脚本:
|
||||||
|
|
||||||
@@ -143,13 +209,21 @@ var yAxis = chart.EnsureChartComponent<YAxis>();
|
|||||||
yAxis.type = Axis.AxisType.Value;
|
yAxis.type = Axis.AxisType.Value;
|
||||||
```
|
```
|
||||||
|
|
||||||
清空默认数据,添加`Line`类型的`Serie`用于接收数据:
|
清空所有默认数据(包含Serie),添加`Line`类型的`Serie`用于接收数据:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
chart.RemoveData();
|
chart.RemoveData();
|
||||||
chart.AddSerie<Line>("line");
|
chart.AddSerie<Line>("line");
|
||||||
```
|
```
|
||||||
|
|
||||||
|
如果Serie是固定的,建议只是清空数据,不用把Serie也清掉:
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
chart.ClearData();
|
||||||
|
```
|
||||||
|
|
||||||
|
这样可以提前在UI上设置好Serie的配置参数。
|
||||||
|
|
||||||
添加10个数据:
|
添加10个数据:
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
@@ -164,30 +238,34 @@ for (int i = 0; i < 10; i++)
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
如果一个Chart里面有多个系列时,则Axis的data只需要加一次,不要多个循环加重复了。记住:Axis的数据个数要和Serie的数据个数一致。
|
如果一个Chart里面有多个系列时,则Axis的data只需要加一次,不要多个循环加重复了。
|
||||||
|
|
||||||
|
:::danger
|
||||||
|
|
||||||
|
请确保Axis的数据个数和Serie的数据个数一致。
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
完整代码请查阅`Examples`:`Example13_LineSimple.cs`
|
完整代码请查阅`Examples`:`Example13_LineSimple.cs`
|
||||||
|
|
||||||
你还可以用代码控制更多的参数,`Examples`下还有更多的其他例子,凡是`Inspector`上看到的可配置的参数,都可以通过代码来设置。[XCharts配置项手册](configuration.md)里面的所有参数都是可以通过代码控制的。
|
你还可以用代码控制更多的参数,`Examples`下还有更多的其他例子,凡是`Inspector`上看到的可配置的参数,都可以通过代码来设置。[XCharts配置项手册](configuration.md)里面的所有参数都是可以通过代码控制的。
|
||||||
|
|
||||||
另外,除非定制,建议调用`Chart`下提供的`public`接口,特别是数据相关操作部分。这些接口内部会做一些关联处理,比如刷新图表等。常见的接口有:
|
### 设置默认字体
|
||||||
|
|
||||||
1. `chart.ClearData()`:清空图表数据(不移除Series)
|
XCharts默认使用的是Unity默认字体`Arial`,在WebGL平台上可能无法显示中文。在将XCharts用在你的项目时,建议先设置好字体:
|
||||||
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内部有自动刷新机制,但也是在一定条件才会触发。如果自己调用了内部组件的接口,碰到组件没有刷新,确实找不到原因的话,可以用以下两个接口强制刷新:
|
- 找到`XCharts/Resources/XCSetting.asset`资源,修改里面的`Font`并保存。
|
||||||
|
- 找到`XCharts/Resources/XCTheme-Default.asset`和`XCharts/Resources/XCTheme-Default.asset`两个字体配置,点击`Sync Font from Setting`和`Sync Font to Sub Theme`按钮将字体同步到主题配置文件上。
|
||||||
|
|
||||||
1. `chart.RefreshAllComponent()`:刷新图表组件,会重新初始化所有组件,不建议频繁待用。
|
字体设置好后,新创建的图表就会用新设置的字体了。对于旧图表,可以点击`Rebuild Chart Object`进行刷新。
|
||||||
2. `chart.RefreshChart()`:刷新图表绘制,只刷新绘制部分,不会刷新组件文本,位置等部分。
|
|
||||||
3. 各个组件也可以通过`SetAllDirty()`只刷新自己。
|
|
||||||
|
|
||||||
## 使用TextMeshPro
|
:::warning
|
||||||
|
|
||||||
|
使用XCharts前建议先设置好字体;更新XCharts时注意设置的字体可能被还原的问题。
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
### 使用TextMeshPro
|
||||||
|
|
||||||
XCharts支持TextMeshPro,但默认是不开启的,需要自己手动切换。可通过以下方式开启和关闭:
|
XCharts支持TextMeshPro,但默认是不开启的,需要自己手动切换。可通过以下方式开启和关闭:
|
||||||
|
|
||||||
@@ -206,10 +284,33 @@ XCharts支持TextMeshPro,但默认是不开启的,需要自己手动切换
|
|||||||
|
|
||||||
`3.8.0`版本后增加[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)守护程序,将XCharts-Daemon导入项目后,在更新XCharts时守护程序会自动根据本地开启的TMP情况刷新asmdef,确保编译正常。
|
`3.8.0`版本后增加[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)守护程序,将XCharts-Daemon导入项目后,在更新XCharts时守护程序会自动根据本地开启的TMP情况刷新asmdef,确保编译正常。
|
||||||
|
|
||||||
## 用代码改图表参数
|
## XCharts的代码控制
|
||||||
|
|
||||||
`Inspector`上看到的所有参数都可以用代码来修改,关键是要定位好你要改的参数是在组件上、还是Serie上、还是在具体的数据项SerieData上。
|
`Inspector`上看到的所有参数都可以用代码来修改,关键是要定位好你要改的参数是在组件上、还是Serie上、还是在具体的数据项SerieData上。
|
||||||
|
|
||||||
|
另外,除非定制,建议调用`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()`:刷新图表绘制,只刷新绘制部分,不会刷新组件文本,位置等部分。
|
||||||
|
3. 各个组件也可以通过`SetAllDirty()`只刷新自己。
|
||||||
|
|
||||||
|
:::danger
|
||||||
|
|
||||||
|
用API去操作数据和各种list,而不是直接访问list进行处理
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
### 改主组件上的参数
|
### 改主组件上的参数
|
||||||
|
|
||||||
需要先获取组件,再修改里面的参数:
|
需要先获取组件,再修改里面的参数:
|
||||||
@@ -225,7 +326,11 @@ xAxis.boundaryGap = true;
|
|||||||
xAxis.type = Axis.AxisType.Category;
|
xAxis.type = Axis.AxisType.Category;
|
||||||
```
|
```
|
||||||
|
|
||||||
> 注:低版本没有`EnsureChartComponent()`接口时,用`GetOrAddChartComponent()`
|
:::note
|
||||||
|
|
||||||
|
低版本没有`EnsureChartComponent()`接口时,用`GetOrAddChartComponent()`
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
### 改Serie的参数
|
### 改Serie的参数
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,10 @@ namespace XCharts.Editor
|
|||||||
}
|
}
|
||||||
PropertyField(prop, "m_Color");
|
PropertyField(prop, "m_Color");
|
||||||
PropertyField(prop, "m_Size");
|
PropertyField(prop, "m_Size");
|
||||||
|
PropertyField(prop, "m_Size2");
|
||||||
PropertyField(prop, "m_Gap");
|
PropertyField(prop, "m_Gap");
|
||||||
|
PropertyField(prop, "m_BorderWidth");
|
||||||
|
PropertyField(prop, "m_EmptyColor");
|
||||||
PropertyField(prop, "m_Offset");
|
PropertyField(prop, "m_Offset");
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,14 +27,13 @@ namespace XCharts.Editor
|
|||||||
PropertyField(prop, "m_Color");
|
PropertyField(prop, "m_Color");
|
||||||
PropertyField(prop, "m_FontSize");
|
PropertyField(prop, "m_FontSize");
|
||||||
PropertyField(prop, "m_LineSpacing");
|
PropertyField(prop, "m_LineSpacing");
|
||||||
|
PropertyField(prop, "m_Alignment");
|
||||||
|
PropertyField(prop, "m_AutoAlign");
|
||||||
#if dUI_TextMeshPro
|
#if dUI_TextMeshPro
|
||||||
PropertyField(prop, "m_TMPFontStyle");
|
PropertyField(prop, "m_TMPFontStyle");
|
||||||
PropertyField(prop, "m_TMPSpriteAsset");
|
PropertyField(prop, "m_TMPSpriteAsset");
|
||||||
PropertyField(prop, "m_TMPAlignment");
|
|
||||||
#else
|
#else
|
||||||
PropertyField(prop, "m_FontStyle");
|
PropertyField(prop, "m_FontStyle");
|
||||||
PropertyField(prop, "m_Alignment");
|
|
||||||
PropertyField(prop, "m_AutoAlign");
|
|
||||||
PropertyField(prop, "m_AutoWrap");
|
PropertyField(prop, "m_AutoWrap");
|
||||||
#endif
|
#endif
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace XCharts.Editor
|
|||||||
PropertyField("m_RoundCap");
|
PropertyField("m_RoundCap");
|
||||||
PropertyField("m_Clockwise");
|
PropertyField("m_Clockwise");
|
||||||
PropertyField("m_AvoidLabelOverlap");
|
PropertyField("m_AvoidLabelOverlap");
|
||||||
|
PropertyField("m_RadiusGradient");
|
||||||
|
|
||||||
PropertyField("m_ItemStyle");
|
PropertyField("m_ItemStyle");
|
||||||
PropertyField("m_Animation");
|
PropertyField("m_Animation");
|
||||||
|
|||||||
@@ -108,11 +108,11 @@ namespace XCharts.Editor
|
|||||||
{
|
{
|
||||||
EditorGUI.LabelField(drawRect, name);
|
EditorGUI.LabelField(drawRect, name);
|
||||||
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
|
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
|
||||||
var diff = 13 + EditorGUI.indentLevel * 14;
|
var diff = 12 + EditorGUI.indentLevel * 14;
|
||||||
var offset = diff - INDENT_WIDTH;
|
var offset = diff - INDENT_WIDTH;
|
||||||
var tempWidth = (rectWidth - startX + diff) / 2;
|
var tempWidth = (rectWidth - startX + diff) / 2;
|
||||||
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1);
|
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1);
|
||||||
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1);
|
var centerYRect = new Rect(centerXRect.x + tempWidth - offset + 3.4f, drawRect.y, tempWidth - 1, drawRect.height - 1);
|
||||||
EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
|
EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
|
||||||
EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
|
EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
@@ -326,7 +326,13 @@ namespace XCharts.Editor
|
|||||||
var foldoutRect = drawRect;
|
var foldoutRect = drawRect;
|
||||||
foldoutRect.xMax -= 10;
|
foldoutRect.xMax -= 10;
|
||||||
bool flag = EditorGUI.Foldout(foldoutRect, foldout, listProp.displayName, true);
|
bool flag = EditorGUI.Foldout(foldoutRect, foldout, listProp.displayName, true);
|
||||||
ChartEditorHelper.DrawMenu(drawRect, menus);
|
if (!flag)
|
||||||
|
{
|
||||||
|
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
|
||||||
|
var sizeRect = new Rect(startX, drawRect.y + 1f, (EditorGUI.indentLevel + 1) * 15, drawRect.height - 1);
|
||||||
|
EditorGUI.IntField(sizeRect, GUIContent.none, listProp.arraySize);
|
||||||
|
DrawMenu(drawRect, menus);
|
||||||
|
}
|
||||||
height += headerHeight;
|
height += headerHeight;
|
||||||
drawRect.y += headerHeight;
|
drawRect.y += headerHeight;
|
||||||
drawRect.width = rawWidth;
|
drawRect.width = rawWidth;
|
||||||
|
|||||||
@@ -19,7 +19,11 @@ namespace XCharts.Editor
|
|||||||
GameObject selectObj = Selection.activeGameObject;
|
GameObject selectObj = Selection.activeGameObject;
|
||||||
if (selectObj == null)
|
if (selectObj == null)
|
||||||
{
|
{
|
||||||
|
#if UNITY_2023_1_OR_NEWER
|
||||||
|
var canvas = UnityEngine.Object.FindFirstObjectByType<Canvas>();
|
||||||
|
#else
|
||||||
var canvas = GameObject.FindObjectOfType<Canvas>();
|
var canvas = GameObject.FindObjectOfType<Canvas>();
|
||||||
|
#endif
|
||||||
if (canvas != null) return canvas.transform;
|
if (canvas != null) return canvas.transform;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
40
README-en.md
40
README-en.md
@@ -1,45 +1,37 @@
|
|||||||
|
<h2 align="center">XCharts</h2>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="">
|
A powerful, easy-to-use, configurable charting and data visualization library for Unity.<br/>Unity数据可视化图表插件。<br/>
|
||||||
<img src="" alt="" width="" height="">
|
<a href="https://github.com/XCharts-Team/XCharts">中文文档</a>
|
||||||
</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>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/XCharts-Team/XCharts/blob/master/LICENSE">
|
<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>
|
||||||
<a href="https://github.com/XCharts-Team/XCharts/releases">
|
<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>
|
||||||
<a href="">
|
<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>
|
||||||
<a href="">
|
<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>
|
||||||
<a href="">
|
<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>
|
||||||
<a href="">
|
<a href="">
|
||||||
<img src="https://img.shields.io/badge/TextMeshPro-YES-green">
|
<img src="https://img.shields.io/badge/TextMeshPro-YES-green"></img>
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="">
|
<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>
|
||||||
<a href="">
|
<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>
|
||||||
<a href="">
|
<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>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -47,14 +39,14 @@
|
|||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
A powerful and easy-to-use data visualization library for Unity. It supports more than ten built-in charts, including line, bar, pie, radar, scatter, heatmap, ring, candlestick, polar, parallel coordinates, as well as extended charts such as 3d pie, 3d bar, 3d pyramid, funnel, gauge, liquid, pictorialbar, gantt, treemap, sankey, line3d and graph chart.
|
A powerful and easy-to-use data visualization library for Unity. It supports more than ten built-in charts, including line, bar, pie, radar, scatter, heatmap, ring, candlestick, polar, parallel coordinates, as well as extension charts such as 3d pie, 3d bar, 3d pyramid, funnel, gauge, liquid, pictorialbar, gantt, treemap, sankey, line3d and graph chart.
|
||||||
|
|
||||||
## Key Features
|
## Key Features
|
||||||
|
|
||||||
- __Pure Code Rendering__: Charts are rendered with pure code, eliminating the need for extra texture or shader resources.
|
- __Pure Code Rendering__: Charts are rendered with pure code, eliminating the need for extra texture or shader resources.
|
||||||
- __Visual Configuration__: Configure parameters visually with real-time preview and support for dynamic configuration and data adjustments at runtime.
|
- __Visual Configuration__: Configure parameters visually with real-time preview and support for dynamic configuration and data adjustments at runtime.
|
||||||
- __High Customizability__: Themes and configuration parameters can be adjusted as needed, with support for custom drawing and callbacks.
|
- __High Customizability__: Themes and configuration parameters can be adjusted as needed, with support for custom drawing and callbacks.
|
||||||
- __Built-in and Extended Charts__: Supports a variety of chart types, including 3D charts and special chart types like gauges and treemaps.
|
- __Built-in and Extension Charts__: Supports a variety of chart types, including 3D charts and special chart types like gauges and treemaps.
|
||||||
- __Multiple Chart Combinations__: Combine multiple charts of the same or different types within a single instance.
|
- __Multiple Chart Combinations__: Combine multiple charts of the same or different types within a single instance.
|
||||||
- __Various Coordinate Systems__: Supports different coordinate systems such as Cartesian, polar, and single axes.
|
- __Various Coordinate Systems__: Supports different coordinate systems such as Cartesian, polar, and single axes.
|
||||||
- __Rich Components__: Includes titles, legends, tooltips, and more.
|
- __Rich Components__: Includes titles, legends, tooltips, and more.
|
||||||
@@ -67,7 +59,7 @@ A powerful and easy-to-use data visualization library for Unity. It supports mo
|
|||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
- [XCharts3.0 Homepage](https://xcharts-team.github.io)
|
- [XCharts3.0 Homepage](https://xcharts-team.github.io/en)
|
||||||
- [XCharts3.0 Tutorial](Documentation~/en/tutorial01.md)
|
- [XCharts3.0 Tutorial](Documentation~/en/tutorial01.md)
|
||||||
- [XCharts3.0 API](Documentation~/en/api.md)
|
- [XCharts3.0 API](Documentation~/en/api.md)
|
||||||
- [XCharts3.0 FAQ](Documentation~/en/faq.md)
|
- [XCharts3.0 FAQ](Documentation~/en/faq.md)
|
||||||
@@ -86,7 +78,7 @@ A powerful and easy-to-use data visualization library for Unity. It supports mo
|
|||||||
- `XCharts3.0` is not fully compatible with `XCharts2.0`. Upgrading to 3.0 may require code adjustments and reconfiguration of some charts.
|
- `XCharts3.0` is not fully compatible with `XCharts2.0`. Upgrading to 3.0 may require code adjustments and reconfiguration of some charts.
|
||||||
- `XCharts2.0` is in the maintenance phase with only critical bug fixes applied.
|
- `XCharts2.0` is in the maintenance phase with only critical bug fixes applied.
|
||||||
- While XCharts supports Unity 5.6 and above, compatibility issues may arise due to limited testing.
|
- While XCharts supports Unity 5.6 and above, compatibility issues may arise due to limited testing.
|
||||||
- This repository contains only the `XCharts` source code. For demos, visit the [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) repo or the [Online Demo](https://xcharts-team.github.io/examples/).
|
- This repository contains only the `XCharts` source code. For demos, visit the [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) repo or the [Online Demo](https://xcharts-team.github.io/en/examples/).
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -1,15 +1,8 @@
|
|||||||
<p align="center">
|
|
||||||
<a href="">
|
|
||||||
<img src="" alt="" width="" height=""></img>
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
<h2 align="center">XCharts</h2>
|
<h2 align="center">XCharts</h2>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
A powerful, easy-to-use, configurable charting and data visualization library for Unity.
|
A powerful, easy-to-use, configurable charting and data visualization library for Unity.<br/>Unity数据可视化图表插件。<br/>
|
||||||
<br/>
|
<a href="README-en.md">English README</a>
|
||||||
Unity数据可视化图表插件。
|
|
||||||
<br/>
|
|
||||||
<a href="README-en.md">English README</a>
|
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/XCharts-Team/XCharts/blob/master/LICENSE">
|
<a href="https://github.com/XCharts-Team/XCharts/blob/master/LICENSE">
|
||||||
@@ -133,10 +126,10 @@
|
|||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
- __XCharts可以免费使用吗?__
|
- __XCharts可以免费使用吗?__
|
||||||
`XCharts`使用`MIT`协议,可以免费使用。也可以订阅`VIP`享受更多增值服务。
|
`XCharts`使用`MIT`协议,可以免费使用。也可以订阅`VIP`享受更多增值服务。
|
||||||
|
|
||||||
- __XCharts支持代码动态添加和修改数据吗?支持从`Excel`或数据库中获取数据吗?__
|
- __XCharts支持代码动态添加和修改数据吗?支持从`Excel`或数据库中获取数据吗?__
|
||||||
`XCharts`提供了各种数据操作的接口,支持代码动态修改配置,添加和修改数据,但数据来源需要自己解析和获取,再调用`XCharts`的接口添加到图表。
|
`XCharts`提供了各种数据操作的接口,支持代码动态修改配置,添加和修改数据,但数据来源需要自己解析和获取,再调用`XCharts`的接口添加到图表。
|
||||||
|
|
||||||
- __XCharts除了用在Unity平台,还能用在Winform或WPF等平台吗?__
|
- __XCharts除了用在Unity平台,还能用在Winform或WPF等平台吗?__
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
string objName = component.GetType().Name + axis.index;
|
string objName = component.GetType().Name + axis.index;
|
||||||
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
axisObj.transform.localPosition = Vector3.zero;
|
axisObj.transform.localPosition = Vector3.zero;
|
||||||
axisObj.SetActive(axis.show);
|
axisObj.SetActive(axis.show);
|
||||||
axisObj.hideFlags = chart.chartHideFlags;
|
axisObj.hideFlags = chart.chartHideFlags;
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ namespace XCharts
|
|||||||
var axisLength = (axis.context.end - axis.context.start).magnitude;
|
var axisLength = (axis.context.end - axis.context.start).magnitude;
|
||||||
if (axisLength == 0) return;
|
if (axisLength == 0) return;
|
||||||
chart.InitAxisRuntimeData(axis);
|
chart.InitAxisRuntimeData(axis);
|
||||||
|
UpdateAxisMinMaxValue(axis.index, axis, true);
|
||||||
|
|
||||||
var objName = ChartCached.GetComponentObjectName(axis);
|
var objName = ChartCached.GetComponentObjectName(axis);
|
||||||
var axisObj = ChartHelper.AddObject(objName,
|
var axisObj = ChartHelper.AddObject(objName,
|
||||||
@@ -379,7 +380,7 @@ namespace XCharts
|
|||||||
chart.chartMinAnchor,
|
chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor,
|
chart.chartMaxAnchor,
|
||||||
chart.chartPivot,
|
chart.chartPivot,
|
||||||
chart.chartSizeDelta);
|
chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
|
|
||||||
axisObj.SetActive(axis.show);
|
axisObj.SetActive(axis.show);
|
||||||
axisObj.hideFlags = chart.chartHideFlags;
|
axisObj.hideFlags = chart.chartHideFlags;
|
||||||
@@ -473,7 +474,6 @@ namespace XCharts
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UpdateAxisMinMaxValue(axis.index, axis, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void InitAxis(Axis relativedAxis, Orient orient,
|
protected void InitAxis(Axis relativedAxis, Orient orient,
|
||||||
@@ -481,6 +481,7 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
Axis axis = component;
|
Axis axis = component;
|
||||||
chart.InitAxisRuntimeData(axis);
|
chart.InitAxisRuntimeData(axis);
|
||||||
|
UpdateAxisMinMaxValue(axis.index, axis, true);
|
||||||
|
|
||||||
var objName = ChartCached.GetComponentObjectName(axis);
|
var objName = ChartCached.GetComponentObjectName(axis);
|
||||||
var axisObj = ChartHelper.AddObject(objName,
|
var axisObj = ChartHelper.AddObject(objName,
|
||||||
@@ -488,7 +489,7 @@ namespace XCharts
|
|||||||
chart.chartMinAnchor,
|
chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor,
|
chart.chartMaxAnchor,
|
||||||
chart.chartPivot,
|
chart.chartPivot,
|
||||||
chart.chartSizeDelta);
|
chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
|
|
||||||
axisObj.SetActive(axis.show);
|
axisObj.SetActive(axis.show);
|
||||||
axisObj.hideFlags = chart.chartHideFlags;
|
axisObj.hideFlags = chart.chartHideFlags;
|
||||||
@@ -637,7 +638,6 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UpdateAxisMinMaxValue(axis.index, axis, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Vector3 GetLabelPosition(int i, Orient orient, Axis axis, Axis relativedAxis, AxisTheme theme,
|
internal static Vector3 GetLabelPosition(int i, Orient orient, Axis axis, Axis relativedAxis, AxisTheme theme,
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ namespace XCharts.Runtime
|
|||||||
var radius = polar.context.outsideRadius - polar.context.insideRadius;
|
var radius = polar.context.outsideRadius - polar.context.insideRadius;
|
||||||
var objName = component.GetType().Name + axis.index;
|
var objName = component.GetType().Name + axis.index;
|
||||||
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
axisObj.transform.localPosition = Vector3.zero;
|
axisObj.transform.localPosition = Vector3.zero;
|
||||||
axisObj.SetActive(axis.show && axis.axisLabel.show);
|
axisObj.SetActive(axis.show && axis.axisLabel.show);
|
||||||
axisObj.hideFlags = chart.chartHideFlags;
|
axisObj.hideFlags = chart.chartHideFlags;
|
||||||
|
|||||||
@@ -100,6 +100,12 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetClass(ref m_BorderStyle, value)) SetComponentDirty(); }
|
set { if (PropertyUtil.SetClass(ref m_BorderStyle, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// the rect of background.
|
||||||
|
/// ||背景的矩形区域。
|
||||||
|
/// </summary>
|
||||||
|
public Rect rect { get; set; }
|
||||||
|
|
||||||
public override void SetDefaultValue()
|
public override void SetDefaultValue()
|
||||||
{
|
{
|
||||||
m_Show = true;
|
m_Show = true;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace XCharts.Runtime
|
|||||||
component.refreshComponent = delegate ()
|
component.refreshComponent = delegate ()
|
||||||
{
|
{
|
||||||
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor,
|
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
component.gameObject = backgroundObj;
|
component.gameObject = backgroundObj;
|
||||||
backgroundObj.hideFlags = chart.chartHideFlags;
|
backgroundObj.hideFlags = chart.chartHideFlags;
|
||||||
|
|
||||||
|
|||||||
@@ -82,5 +82,11 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
return m_Show && roundedCorner ? m_CornerRadius : null;
|
return m_Show && roundedCorner ? m_CornerRadius : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsCricle()
|
||||||
|
{
|
||||||
|
return roundedCorner && m_CornerRadius[0] == 1 && m_CornerRadius[1] == 1 &&
|
||||||
|
m_CornerRadius[2] == 1 && m_CornerRadius[3] == 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,10 +209,29 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetClass(ref m_ItemMarker, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetClass(ref m_ItemMarker, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Standard numeric format strings.
|
/// Standard number and date format string. Used to format a Double value or a DateTime date as a string.
|
||||||
/// ||标准数字格式字符串。用于将数值格式化显示为字符串。
|
/// numericFormatter is used as an argument to either `Double.ToString ()` or `DateTime.ToString()`. <br />
|
||||||
/// 使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。
|
/// The number format uses the Axx format: A is a single-character format specifier that supports C currency,
|
||||||
/// 参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings
|
/// D decimal, E exponent, F fixed-point number, G regular, N digit, P percentage, R round trip, and X hexadecimal.
|
||||||
|
/// xx is precision specification, from 0-99. E.g. F1, E2<br />
|
||||||
|
/// Date format: Starts with `date`, which is used to format DateTime. Common date formats are:
|
||||||
|
/// yyyy year, MM month, dd day, HH hour, mm minute, ss second, fff millisecond. For example: date:yyyy-MM-dd HH:mm:ss<br />
|
||||||
|
/// Time format: Starts with `time`, which is used to format TimeSpan. Common time formats are:
|
||||||
|
/// d day, HH hour, mm minute, ss second, fffffff fractional part.
|
||||||
|
/// Only the version of Unity2018 or later can support formatting, and the characters inside should be escaped.
|
||||||
|
/// For example: time:HH\:mm\:ss<br />
|
||||||
|
/// number format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
||||||
|
/// date format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
||||||
|
/// Note: The date and time formats are only supported by 'v3.12.0' or later.<br/>
|
||||||
|
/// ||标准数字和日期格式字符串。用于将Double数值或DateTime日期格式化显示为字符串。numericFormatter用来作为Double.ToString()或DateTime.ToString()的参数。<br/>
|
||||||
|
/// 数字格式使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。如:F1, E2<br/>
|
||||||
|
/// 日期格式:以`date`开头,用来格式化DateTime,常见格式有:yyyy年,MM月,dd日,HH时,mm分,ss秒,fff毫秒。如:date:yyyy-MM-dd HH:mm:ss<br/>
|
||||||
|
/// 时间格式:以`time`开头,用来格式化TimeSpan,常见格式有:d日,HH时,mm分,ss秒,fffffff小数部分。
|
||||||
|
/// 需要Unity2018以上版本才支持格式化,并且里面的字符要转义。如:time:d\.HH\:mm\:ss<br/>
|
||||||
|
/// 数值格式化参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings <br/>
|
||||||
|
/// 日期格式化参考:https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-date-and-time-format-strings <br/>
|
||||||
|
/// 时间格式化参考:https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-timespan-format-strings <br/>
|
||||||
|
/// 注意:date和time格式需要`v3.12.0`以上版本才支持。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string numericFormatter
|
public string numericFormatter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -349,6 +349,69 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Rect GetRect(float graphX, float graphY, float graphWidth, float graphHeight, float rectWidth, float rectHeight)
|
||||||
|
{
|
||||||
|
UpdateRuntimeData(graphWidth, graphWidth);
|
||||||
|
|
||||||
|
float x, y, width, height;
|
||||||
|
|
||||||
|
width = rectWidth == 0 ? graphWidth - runtimeLeft - runtimeRight : rectWidth;
|
||||||
|
height = rectHeight == 0 ? graphHeight - runtimeBottom - runtimeTop : rectHeight;
|
||||||
|
|
||||||
|
switch (align)
|
||||||
|
{
|
||||||
|
case Align.BottomCenter:
|
||||||
|
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
|
||||||
|
y = graphY + runtimeBottom;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Align.BottomLeft:
|
||||||
|
x = graphX + runtimeLeft;
|
||||||
|
y = graphY + runtimeBottom;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Align.BottomRight:
|
||||||
|
x = graphX + graphWidth - runtimeRight - width;
|
||||||
|
y = graphY + runtimeBottom;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Align.Center:
|
||||||
|
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
|
||||||
|
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Align.CenterLeft:
|
||||||
|
x = graphX + runtimeLeft;
|
||||||
|
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Align.CenterRight:
|
||||||
|
x = graphX + graphWidth - runtimeRight - width;
|
||||||
|
y = graphY + runtimeBottom + (graphHeight - runtimeBottom - runtimeTop - height) / 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Align.TopCenter:
|
||||||
|
x = graphX + runtimeLeft + (graphWidth - runtimeLeft - runtimeRight - width) / 2;
|
||||||
|
y = graphY + graphHeight - runtimeTop - height;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Align.TopLeft:
|
||||||
|
x = graphX + runtimeLeft;
|
||||||
|
y = graphY + graphHeight - runtimeTop - height;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Align.TopRight:
|
||||||
|
x = graphX + graphWidth - runtimeRight - width;
|
||||||
|
y = graphY + graphHeight - runtimeTop - height;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return new Rect(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
return new Rect(x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
|
/// 属性变更时更新textAnchor,minAnchor,maxAnchor,pivot
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -84,12 +84,16 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] protected Sprite m_Image;
|
[SerializeField] protected Sprite m_Image;
|
||||||
[SerializeField] protected Image.Type m_ImageType;
|
[SerializeField] protected Image.Type m_ImageType;
|
||||||
[SerializeField] protected Color32 m_Color;
|
[SerializeField] protected Color32 m_Color;
|
||||||
|
[SerializeField][Since("v3.13.0")] protected float m_BorderWidth = 0f;
|
||||||
|
[SerializeField][Since("v3.13.0")] protected Color32 m_EmptyColor;
|
||||||
|
[SerializeField][Since("v3.13.0")] protected float m_Size2 = 0f;
|
||||||
|
|
||||||
public virtual void Reset()
|
public virtual void Reset()
|
||||||
{
|
{
|
||||||
m_Show = false;
|
m_Show = false;
|
||||||
m_Type = SymbolType.EmptyCircle;
|
m_Type = SymbolType.EmptyCircle;
|
||||||
m_Size = 0f;
|
m_Size = 0f;
|
||||||
|
m_Size2 = 0f;
|
||||||
m_Gap = 0;
|
m_Gap = 0;
|
||||||
m_Width = 0f;
|
m_Width = 0f;
|
||||||
m_Height = 0f;
|
m_Height = 0f;
|
||||||
@@ -126,6 +130,15 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// the size of symbol.
|
||||||
|
/// ||标记的大小。当为Rect时,size2表示高度。
|
||||||
|
/// </summary>
|
||||||
|
public float size2
|
||||||
|
{
|
||||||
|
get { return m_Size2; }
|
||||||
|
set { if (PropertyUtil.SetStruct(ref m_Size2, value)) SetVerticesDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// the gap of symbol and line segment.
|
/// the gap of symbol and line segment.
|
||||||
/// ||图形标记和线条的间隙距离。
|
/// ||图形标记和线条的间隙距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -183,6 +196,24 @@ namespace XCharts.Runtime
|
|||||||
get { return m_Color; }
|
get { return m_Color; }
|
||||||
set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); }
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// the border width of symbol.
|
||||||
|
/// ||图形的边框宽度。
|
||||||
|
/// </summary>
|
||||||
|
public float borderWidth
|
||||||
|
{
|
||||||
|
get { return m_BorderWidth; }
|
||||||
|
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// the color of empty symbol.
|
||||||
|
/// ||空心图形的颜色。
|
||||||
|
/// </summary>
|
||||||
|
public Color32 emptyColor
|
||||||
|
{
|
||||||
|
get { return m_EmptyColor; }
|
||||||
|
set { if (PropertyUtil.SetStruct(ref m_EmptyColor, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
|
public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
|
||||||
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
|
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ namespace XCharts.Runtime
|
|||||||
#if dUI_TextMeshPro
|
#if dUI_TextMeshPro
|
||||||
[SerializeField] private TMP_FontAsset m_TMPFont;
|
[SerializeField] private TMP_FontAsset m_TMPFont;
|
||||||
[SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal;
|
[SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal;
|
||||||
[SerializeField] private TextAlignmentOptions m_TMPAlignment = TextAlignmentOptions.Left;
|
|
||||||
[SerializeField][Since("v3.1.0")] private TMP_SpriteAsset m_TMPSpriteAsset;
|
[SerializeField][Since("v3.1.0")] private TMP_SpriteAsset m_TMPSpriteAsset;
|
||||||
#endif
|
#endif
|
||||||
public bool show
|
public bool show
|
||||||
@@ -147,15 +146,6 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the text alignment of TextMeshPro.
|
|
||||||
/// ||TextMeshPro字体对齐方式。
|
|
||||||
/// </summary>
|
|
||||||
public TextAlignmentOptions tmpAlignment
|
|
||||||
{
|
|
||||||
get { return m_TMPAlignment; }
|
|
||||||
set { if (PropertyUtil.SetStruct(ref m_TMPAlignment, value)) SetComponentDirty(); }
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// the sprite asset of TextMeshPro.
|
/// the sprite asset of TextMeshPro.
|
||||||
/// ||TextMeshPro的Sprite Asset。
|
/// ||TextMeshPro的Sprite Asset。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -214,11 +204,7 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public void UpdateAlignmentByLocation(Location location)
|
public void UpdateAlignmentByLocation(Location location)
|
||||||
{
|
{
|
||||||
#if dUI_TextMeshPro
|
|
||||||
m_TMPAlignment = location.runtimeTMPTextAlignment;
|
|
||||||
#else
|
|
||||||
m_Alignment = location.runtimeTextAlignment;
|
m_Alignment = location.runtimeTextAlignment;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetColor(Color defaultColor)
|
public Color GetColor(Color defaultColor)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace XCharts.Runtime
|
|||||||
chart.chartMinAnchor,
|
chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor,
|
chart.chartMaxAnchor,
|
||||||
chart.chartPivot,
|
chart.chartPivot,
|
||||||
chart.chartSizeDelta);
|
chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
|
|
||||||
commentObj.SetActive(comment.show);
|
commentObj.SetActive(comment.show);
|
||||||
commentObj.hideFlags = chart.chartHideFlags;
|
commentObj.hideFlags = chart.chartHideFlags;
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace XCharts.Runtime
|
|||||||
private bool m_CheckDataZoomLabel;
|
private bool m_CheckDataZoomLabel;
|
||||||
private float m_DataZoomLastStartIndex;
|
private float m_DataZoomLastStartIndex;
|
||||||
private float m_DataZoomLastEndIndex;
|
private float m_DataZoomLastEndIndex;
|
||||||
|
private float m_LastStart;
|
||||||
|
private float m_LastEnd;
|
||||||
|
|
||||||
public override void InitComponent()
|
public override void InitComponent()
|
||||||
{
|
{
|
||||||
@@ -25,7 +27,7 @@ namespace XCharts.Runtime
|
|||||||
dataZoom.refreshComponent = delegate ()
|
dataZoom.refreshComponent = delegate ()
|
||||||
{
|
{
|
||||||
var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + dataZoom.index, chart.transform,
|
var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + dataZoom.index, chart.transform,
|
||||||
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
dataZoom.gameObject = dataZoomObject;
|
dataZoom.gameObject = dataZoomObject;
|
||||||
dataZoomObject.hideFlags = chart.chartHideFlags;
|
dataZoomObject.hideFlags = chart.chartHideFlags;
|
||||||
ChartHelper.HideAllObject(dataZoomObject);
|
ChartHelper.HideAllObject(dataZoomObject);
|
||||||
@@ -62,6 +64,10 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
CheckDataZoomScale(component);
|
CheckDataZoomScale(component);
|
||||||
CheckDataZoomLabel(component);
|
CheckDataZoomLabel(component);
|
||||||
|
if (m_LastStart != component.start || m_LastEnd != component.end)
|
||||||
|
{
|
||||||
|
UpdateDataZoomRange(component, component.start, component.end);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawUpper(VertexHelper vh)
|
public override void DrawUpper(VertexHelper vh)
|
||||||
@@ -404,6 +410,8 @@ namespace XCharts.Runtime
|
|||||||
dataZoom.start = start;
|
dataZoom.start = start;
|
||||||
if (!dataZoom.endLock)
|
if (!dataZoom.endLock)
|
||||||
dataZoom.end = end;
|
dataZoom.end = end;
|
||||||
|
m_LastStart = dataZoom.start;
|
||||||
|
m_LastEnd = dataZoom.end;
|
||||||
if (dataZoom.realtime)
|
if (dataZoom.realtime)
|
||||||
{
|
{
|
||||||
chart.OnDataZoomRangeChanged(dataZoom);
|
chart.OnDataZoomRangeChanged(dataZoom);
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace XCharts.Runtime
|
|||||||
public void Init(BaseChart chart)
|
public void Init(BaseChart chart)
|
||||||
{
|
{
|
||||||
m_Chart = chart;
|
m_Chart = chart;
|
||||||
m_Label = AddDebugInfoObject("debug", chart.transform, m_LabelStyle, chart.theme);
|
m_Label = AddDebugInfoObject("debug", chart.transform, m_LabelStyle, chart.theme, chart.childrenNodeNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
@@ -155,14 +155,14 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ChartLabel AddDebugInfoObject(string name, Transform parent, LabelStyle labelStyle,
|
private ChartLabel AddDebugInfoObject(string name, Transform parent, LabelStyle labelStyle,
|
||||||
ThemeStyle theme)
|
ThemeStyle theme, List<string> childrenNodeNames)
|
||||||
{
|
{
|
||||||
var anchorMax = new Vector2(0, 1);
|
var anchorMax = new Vector2(0, 1);
|
||||||
var anchorMin = new Vector2(0, 1);
|
var anchorMin = new Vector2(0, 1);
|
||||||
var pivot = new Vector2(0, 1);
|
var pivot = new Vector2(0, 1);
|
||||||
var sizeDelta = new Vector2(100, 100);
|
var sizeDelta = new Vector2(100, 100);
|
||||||
|
|
||||||
var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
var labelGameObject = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta, -1, childrenNodeNames);
|
||||||
labelGameObject.transform.SetAsLastSibling();
|
labelGameObject.transform.SetAsLastSibling();
|
||||||
labelGameObject.hideFlags = m_Chart.chartHideFlags;
|
labelGameObject.hideFlags = m_Chart.chartHideFlags;
|
||||||
ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);
|
ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);
|
||||||
|
|||||||
@@ -184,16 +184,29 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
|
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Standard number and date format string. Used to format a Double value or a DateTime date as a string. numericFormatter is used as an argument to either `Double.ToString ()` or `DateTime.ToString()`. <br />
|
/// Standard number and date format string. Used to format a Double value or a DateTime date as a string.
|
||||||
/// The number format uses the Axx format: A is a single-character format specifier that supports C currency, D decimal, E exponent, F fixed-point number, G regular, N digit, P percentage, R round trip, and X hexadecimal. xx is precision specification, from 0-99. E.g. F1, E2<br />
|
/// numericFormatter is used as an argument to either `Double.ToString ()` or `DateTime.ToString()`. <br />
|
||||||
/// Date format Common date formats are: yyyy year, MM month, dd day, HH hour, mm minute, ss second, fff millisecond. For example: yyyy-MM-dd HH:mm:ss<br />
|
/// The number format uses the Axx format: A is a single-character format specifier that supports C currency,
|
||||||
|
/// D decimal, E exponent, F fixed-point number, G regular, N digit, P percentage, R round trip, and X hexadecimal.
|
||||||
|
/// xx is precision specification, from 0-99. E.g. F1, E2<br />
|
||||||
|
/// Date format: Starts with `date`, which is used to format DateTime. Common date formats are:
|
||||||
|
/// yyyy year, MM month, dd day, HH hour, mm minute, ss second, fff millisecond. For example: date:yyyy-MM-dd HH:mm:ss<br />
|
||||||
|
/// Time format: Starts with `time`, which is used to format TimeSpan. Common time formats are:
|
||||||
|
/// d day, HH hour, mm minute, ss second, fffffff fractional part.
|
||||||
|
/// Only the version of Unity2018 or later can support formatting, and the characters inside should be escaped.
|
||||||
|
/// For example: time:HH\:mm\:ss<br />
|
||||||
/// number format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
/// number format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
||||||
/// date format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
/// date format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
||||||
|
/// Note: The date and time formats are only supported by 'v3.12.0' or later.<br/>
|
||||||
/// ||标准数字和日期格式字符串。用于将Double数值或DateTime日期格式化显示为字符串。numericFormatter用来作为Double.ToString()或DateTime.ToString()的参数。<br/>
|
/// ||标准数字和日期格式字符串。用于将Double数值或DateTime日期格式化显示为字符串。numericFormatter用来作为Double.ToString()或DateTime.ToString()的参数。<br/>
|
||||||
/// 数字格式使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。如:F1, E2<br/>
|
/// 数字格式使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。如:F1, E2<br/>
|
||||||
/// 日期格式常见的格式:yyyy年,MM月,dd日,HH时,mm分,ss秒,fff毫秒。如:yyyy-MM-dd HH:mm:ss<br/>
|
/// 日期格式:以`date`开头,用来格式化DateTime,常见格式有:yyyy年,MM月,dd日,HH时,mm分,ss秒,fff毫秒。如:date:yyyy-MM-dd HH:mm:ss<br/>
|
||||||
|
/// 时间格式:以`time`开头,用来格式化TimeSpan,常见格式有:d日,HH时,mm分,ss秒,fffffff小数部分。
|
||||||
|
/// 需要Unity2018以上版本才支持格式化,并且里面的字符要转义。如:time:d\.HH\:mm\:ss<br/>
|
||||||
/// 数值格式化参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings <br/>
|
/// 数值格式化参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings <br/>
|
||||||
/// 日期格式化参考:https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-date-and-time-format-strings
|
/// 日期格式化参考:https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-date-and-time-format-strings <br/>
|
||||||
|
/// 时间格式化参考:https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-timespan-format-strings <br/>
|
||||||
|
/// 注意:date和time格式需要`v3.12.0`以上版本才支持。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string numericFormatter
|
public string numericFormatter
|
||||||
{
|
{
|
||||||
@@ -405,7 +418,7 @@ namespace XCharts.Runtime
|
|||||||
public virtual string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
|
public virtual string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||||
{
|
{
|
||||||
var newNumericFormatter = numericFormatter;
|
var newNumericFormatter = numericFormatter;
|
||||||
if (value == 0)
|
if (value == 0 && !DateTimeUtil.IsDateOrTimeRegex(newNumericFormatter))
|
||||||
{
|
{
|
||||||
newNumericFormatter = "f0";
|
newNumericFormatter = "f0";
|
||||||
}
|
}
|
||||||
@@ -444,6 +457,8 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool isDateFormatter = false;
|
||||||
|
private static string newFormatter = null;
|
||||||
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue)
|
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue)
|
||||||
{
|
{
|
||||||
var timestamp = (int)value;
|
var timestamp = (int)value;
|
||||||
@@ -457,7 +472,17 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dateString = dateTime.ToString(numericFormatter);
|
if(DateTimeUtil.IsDateOrTimeRegex(numericFormatter, ref isDateFormatter, ref newFormatter))
|
||||||
|
{
|
||||||
|
if(isDateFormatter)
|
||||||
|
dateString = ChartCached.NumberToDateStr(timestamp, newFormatter);
|
||||||
|
else
|
||||||
|
dateString = ChartCached.NumberToTimeStr(timestamp, newFormatter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dateString = dateTime.ToString(numericFormatter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
var content = serieLabel.formatter;
|
var content = serieLabel.formatter;
|
||||||
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue,
|
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue,
|
||||||
dataTotal, serieName, dataName, dataName, color, serieData, chart);
|
dataTotal, serieName, dataName, dataName, color, serieData, chart, serie.index);
|
||||||
if (serieLabel.formatterFunction == null)
|
if (serieLabel.formatterFunction == null)
|
||||||
return content;
|
return content;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
legend.OnChanged();
|
legend.OnChanged();
|
||||||
var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, chart.transform, chart.chartMinAnchor,
|
var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, chart.transform, chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
legend.gameObject = legendObject;
|
legend.gameObject = legendObject;
|
||||||
legendObject.hideFlags = chart.chartHideFlags;
|
legendObject.hideFlags = chart.chartHideFlags;
|
||||||
//ChartHelper.DestoryGameObjectByMatch(legendObject.transform, "_");
|
//ChartHelper.DestoryGameObjectByMatch(legendObject.transform, "_");
|
||||||
@@ -87,11 +87,14 @@ namespace XCharts.Runtime
|
|||||||
ChartHelper.HideAllObject(legendObject);
|
ChartHelper.HideAllObject(legendObject);
|
||||||
if (!legend.show) return;
|
if (!legend.show) return;
|
||||||
var textLimitInitFlag = false;
|
var textLimitInitFlag = false;
|
||||||
|
var isAnySerieColorByData = SeriesHelper.IsAnyColorByDataSerie(chart.series);
|
||||||
for (int i = 0; i < datas.Count; i++)
|
for (int i = 0; i < datas.Count; i++)
|
||||||
{
|
{
|
||||||
if (!SeriesHelper.IsLegalLegendName(datas[i])) continue;
|
if (!SeriesHelper.IsLegalLegendName(datas[i])) continue;
|
||||||
string legendName = datas[i];
|
string legendName = datas[i];
|
||||||
var legendContent = GetFormatterContent(legend, i, datas[i]);
|
var serieIndex = isAnySerieColorByData ? 0 : i;
|
||||||
|
var dataIndex = isAnySerieColorByData ? i : 0;
|
||||||
|
var legendContent = GetFormatterContent(legend, dataIndex, datas[i], serieIndex);
|
||||||
if (legend.textLimit.enable)
|
if (legend.textLimit.enable)
|
||||||
legendContent = legend.textLimit.GetLimitContent(legendContent);
|
legendContent = legend.textLimit.GetLimitContent(legendContent);
|
||||||
var readIndex = chart.m_LegendRealShowName.IndexOf(datas[i]);
|
var readIndex = chart.m_LegendRealShowName.IndexOf(datas[i]);
|
||||||
@@ -158,7 +161,7 @@ namespace XCharts.Runtime
|
|||||||
legend.refreshComponent();
|
legend.refreshComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetFormatterContent(Legend legend, int dataIndex, string category)
|
private string GetFormatterContent(Legend legend, int dataIndex, string category, int serieIndex)
|
||||||
{
|
{
|
||||||
#pragma warning disable 0618
|
#pragma warning disable 0618
|
||||||
if (string.IsNullOrEmpty(legend.formatter) && string.IsNullOrEmpty(legend.labelStyle.formatter))
|
if (string.IsNullOrEmpty(legend.formatter) && string.IsNullOrEmpty(legend.labelStyle.formatter))
|
||||||
@@ -168,7 +171,7 @@ namespace XCharts.Runtime
|
|||||||
var formatter = string.IsNullOrEmpty(legend.labelStyle.formatter) ? legend.formatter : legend.labelStyle.formatter;
|
var formatter = string.IsNullOrEmpty(legend.labelStyle.formatter) ? legend.formatter : legend.labelStyle.formatter;
|
||||||
var content = formatter.Replace("{name}", category);
|
var content = formatter.Replace("{name}", category);
|
||||||
content = content.Replace("{value}", category);
|
content = content.Replace("{value}", category);
|
||||||
var serie = chart.GetSerie(0);
|
var serie = chart.GetSerie(serieIndex);
|
||||||
FormatterHelper.ReplaceContent(ref content, dataIndex, legend.labelStyle.numericFormatter, serie, chart, category);
|
FormatterHelper.ReplaceContent(ref content, dataIndex, legend.labelStyle.numericFormatter, serie, chart, category);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace XCharts.Runtime
|
|||||||
var objAnchorMin = new Vector2(0, 1);
|
var objAnchorMin = new Vector2(0, 1);
|
||||||
var objAnchorMax = new Vector2(0, 1);
|
var objAnchorMax = new Vector2(0, 1);
|
||||||
var objPivot = new Vector2(0, 1);
|
var objPivot = new Vector2(0, 1);
|
||||||
var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta);
|
var btnObj = ChartHelper.AddObject(objName, parent, objAnchorMin, objAnchorMax, objPivot, sizeDelta, -1, chart.childrenNodeNames);
|
||||||
var iconObj = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta);
|
var iconObj = ChartHelper.AddObject("icon", btnObj.transform, anchorMin, anchorMax, pivot, iconSizeDelta);
|
||||||
var img = ChartHelper.EnsureComponent<Image>(btnObj);
|
var img = ChartHelper.EnsureComponent<Image>(btnObj);
|
||||||
img.color = Color.clear;
|
img.color = Color.clear;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace XCharts.Runtime
|
|||||||
public override void InitComponent()
|
public override void InitComponent()
|
||||||
{
|
{
|
||||||
m_MarkLineLabelRoot = ChartHelper.AddObject("markarea" + component.index, chart.transform, chart.chartMinAnchor,
|
m_MarkLineLabelRoot = ChartHelper.AddObject("markarea" + component.index, chart.transform, chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags;
|
m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags;
|
||||||
ChartHelper.HideAllObject(m_MarkLineLabelRoot);
|
ChartHelper.HideAllObject(m_MarkLineLabelRoot);
|
||||||
InitMarkArea(component);
|
InitMarkArea(component);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace XCharts.Runtime
|
|||||||
public override void InitComponent()
|
public override void InitComponent()
|
||||||
{
|
{
|
||||||
m_MarkLineLabelRoot = ChartHelper.AddObject("markline", chart.transform, chart.chartMinAnchor,
|
m_MarkLineLabelRoot = ChartHelper.AddObject("markline", chart.transform, chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags;
|
m_MarkLineLabelRoot.hideFlags = chart.chartHideFlags;
|
||||||
ChartHelper.HideAllObject(m_MarkLineLabelRoot);
|
ChartHelper.HideAllObject(m_MarkLineLabelRoot);
|
||||||
InitMarkLine(component);
|
InitMarkLine(component);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
radar.UpdateRadarCenter(chart);
|
radar.UpdateRadarCenter(chart);
|
||||||
var radarObject = ChartHelper.AddObject("Radar" + radar.index, chart.transform, chart.chartMinAnchor,
|
var radarObject = ChartHelper.AddObject("Radar" + radar.index, chart.transform, chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
radar.gameObject = radarObject;
|
radar.gameObject = radarObject;
|
||||||
radar.gameObject.hideFlags = chart.chartHideFlags;
|
radar.gameObject.hideFlags = chart.chartHideFlags;
|
||||||
ChartHelper.HideAllObject(radarObject.transform, INDICATOR_TEXT);
|
ChartHelper.HideAllObject(radarObject.transform, INDICATOR_TEXT);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace XCharts.Runtime
|
|||||||
var pivot = title.location.runtimePivot;
|
var pivot = title.location.runtimePivot;
|
||||||
var objName = ChartCached.GetComponentObjectName(title);
|
var objName = ChartCached.GetComponentObjectName(title);
|
||||||
var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax,
|
var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax,
|
||||||
pivot, chart.chartSizeDelta);
|
pivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
title.gameObject = titleObject;
|
title.gameObject = titleObject;
|
||||||
title.gameObject.transform.SetSiblingIndex(chart.m_PainterUpper.transform.GetSiblingIndex() + 1);
|
title.gameObject.transform.SetSiblingIndex(chart.m_PainterUpper.transform.GetSiblingIndex() + 1);
|
||||||
anchorMin = title.location.runtimeAnchorMin;
|
anchorMin = title.location.runtimeAnchorMin;
|
||||||
@@ -39,11 +39,11 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
m_LabelObject = ChartHelper.AddChartLabel(s_TitleObjectName, titleObject.transform, title.labelStyle, chart.theme.title,
|
m_LabelObject = ChartHelper.AddChartLabel(s_TitleObjectName, titleObject.transform, title.labelStyle, chart.theme.title,
|
||||||
GetTitleText(title), Color.clear, title.location.runtimeTextAlignment);
|
GetTitleText(title), Color.clear, title.location.runtimeTextAlignment);
|
||||||
m_LabelObject.SetActive(title.show && title.labelStyle.show);
|
m_LabelObject.SetActive(title.show && title.labelStyle.show, true);
|
||||||
|
|
||||||
m_SubLabelObject = ChartHelper.AddChartLabel(s_SubTitleObjectName, titleObject.transform, title.subLabelStyle, chart.theme.subTitle,
|
m_SubLabelObject = ChartHelper.AddChartLabel(s_SubTitleObjectName, titleObject.transform, title.subLabelStyle, chart.theme.subTitle,
|
||||||
GetSubTitleText(title), Color.clear, title.location.runtimeTextAlignment);
|
GetSubTitleText(title), Color.clear, title.location.runtimeTextAlignment);
|
||||||
m_SubLabelObject.SetActive(title.show && title.subLabelStyle.show);
|
m_SubLabelObject.SetActive(title.show && title.subLabelStyle.show, true);
|
||||||
m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
|
m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
|
||||||
};
|
};
|
||||||
title.refreshComponent();
|
title.refreshComponent();
|
||||||
|
|||||||
@@ -293,16 +293,29 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string itemFormatter { get { return m_ItemFormatter; } set { m_ItemFormatter = value; } }
|
public string itemFormatter { get { return m_ItemFormatter; } set { m_ItemFormatter = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Standard number and date format string. Used to format a Double value or a DateTime date as a string. numericFormatter is used as an argument to either `Double.ToString ()` or `DateTime.ToString()`. <br />
|
/// Standard number and date format string. Used to format a Double value or a DateTime date as a string.
|
||||||
/// The number format uses the Axx format: A is a single-character format specifier that supports C currency, D decimal, E exponent, F fixed-point number, G regular, N digit, P percentage, R round trip, and X hexadecimal. xx is precision specification, from 0-99. E.g. F1, E2<br />
|
/// numericFormatter is used as an argument to either `Double.ToString ()` or `DateTime.ToString()`. <br />
|
||||||
/// Date format Common date formats are: yyyy year, MM month, dd day, HH hour, mm minute, ss second, fff millisecond. For example: yyyy-MM-dd HH:mm:ss<br />
|
/// The number format uses the Axx format: A is a single-character format specifier that supports C currency,
|
||||||
|
/// D decimal, E exponent, F fixed-point number, G regular, N digit, P percentage, R round trip, and X hexadecimal.
|
||||||
|
/// xx is precision specification, from 0-99. E.g. F1, E2<br />
|
||||||
|
/// Date format: Starts with `date`, which is used to format DateTime. Common date formats are:
|
||||||
|
/// yyyy year, MM month, dd day, HH hour, mm minute, ss second, fff millisecond. For example: date:yyyy-MM-dd HH:mm:ss<br />
|
||||||
|
/// Time format: Starts with `time`, which is used to format TimeSpan. Common time formats are:
|
||||||
|
/// d day, HH hour, mm minute, ss second, fffffff fractional part.
|
||||||
|
/// Only the version of Unity2018 or later can support formatting, and the characters inside should be escaped.
|
||||||
|
/// For example: time:HH\:mm\:ss<br />
|
||||||
/// number format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
/// number format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
||||||
/// date format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
/// date format reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings<br/>
|
||||||
|
/// Note: The date and time formats are only supported by 'v3.12.0' or later.<br/>
|
||||||
/// ||标准数字和日期格式字符串。用于将Double数值或DateTime日期格式化显示为字符串。numericFormatter用来作为Double.ToString()或DateTime.ToString()的参数。<br/>
|
/// ||标准数字和日期格式字符串。用于将Double数值或DateTime日期格式化显示为字符串。numericFormatter用来作为Double.ToString()或DateTime.ToString()的参数。<br/>
|
||||||
/// 数字格式使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。如:F1, E2<br/>
|
/// 数字格式使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。如:F1, E2<br/>
|
||||||
/// 日期格式常见的格式:yyyy年,MM月,dd日,HH时,mm分,ss秒,fff毫秒。如:yyyy-MM-dd HH:mm:ss<br/>
|
/// 日期格式:以`date`开头,用来格式化DateTime,常见格式有:yyyy年,MM月,dd日,HH时,mm分,ss秒,fff毫秒。如:date:yyyy-MM-dd HH:mm:ss<br/>
|
||||||
|
/// 时间格式:以`time`开头,用来格式化TimeSpan,常见格式有:d日,HH时,mm分,ss秒,fffffff小数部分。
|
||||||
|
/// 需要Unity2018以上版本才支持格式化,并且里面的字符要转义。如:time:d\.HH\:mm\:ss<br/>
|
||||||
/// 数值格式化参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings <br/>
|
/// 数值格式化参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings <br/>
|
||||||
/// 日期格式化参考:https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-date-and-time-format-strings
|
/// 日期格式化参考:https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-date-and-time-format-strings <br/>
|
||||||
|
/// 时间格式化参考:https://learn.microsoft.com/zh-cn/dotnet/standard/base-types/standard-timespan-format-strings <br/>
|
||||||
|
/// 注意:date和time格式需要`v3.12.0`以上版本才支持。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string numericFormatter
|
public string numericFormatter
|
||||||
{
|
{
|
||||||
@@ -536,37 +549,6 @@ namespace XCharts.Runtime
|
|||||||
SetContentActive(flag);
|
SetContentActive(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 更新文本框位置
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pos"></param>
|
|
||||||
public void UpdateContentPos(Vector2 pos, float width, float height)
|
|
||||||
{
|
|
||||||
if (view != null)
|
|
||||||
{
|
|
||||||
switch (m_Position)
|
|
||||||
{
|
|
||||||
case Position.Auto:
|
|
||||||
#if UNITY_ANDROID || UNITY_IOS
|
|
||||||
if (m_FixedY == 0) pos.y = ChartHelper.GetActualValue(0.7f, height);
|
|
||||||
else pos.y = ChartHelper.GetActualValue(m_FixedY, height);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case Position.Custom:
|
|
||||||
pos.x = ChartHelper.GetActualValue(m_FixedX, width);
|
|
||||||
pos.y = ChartHelper.GetActualValue(m_FixedY, height);
|
|
||||||
break;
|
|
||||||
case Position.FixedX:
|
|
||||||
pos.x = ChartHelper.GetActualValue(m_FixedX, width);
|
|
||||||
break;
|
|
||||||
case Position.FixedY:
|
|
||||||
pos.y = ChartHelper.GetActualValue(m_FixedY, height);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
view.UpdatePosition(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置文本框是否显示
|
/// 设置文本框是否显示
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
var objName = ChartCached.GetComponentObjectName(tooltip);
|
var objName = ChartCached.GetComponentObjectName(tooltip);
|
||||||
tooltip.gameObject = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
tooltip.gameObject = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
var tooltipObject = tooltip.gameObject;
|
var tooltipObject = tooltip.gameObject;
|
||||||
tooltipObject.transform.localPosition = Vector3.zero;
|
tooltipObject.transform.localPosition = Vector3.zero;
|
||||||
tooltipObject.hideFlags = chart.chartHideFlags;
|
tooltipObject.hideFlags = chart.chartHideFlags;
|
||||||
@@ -546,7 +546,7 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
tooltip.SetActive(m_ShowTooltip);
|
tooltip.SetActive(m_ShowTooltip);
|
||||||
tooltip.view.Refresh();
|
tooltip.view.Refresh();
|
||||||
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
|
TooltipHelper.LimitInRect(chart, tooltip, chart.chartRect);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,7 +633,7 @@ namespace XCharts.Runtime
|
|||||||
tooltip.SetActive(m_ShowTooltip);
|
tooltip.SetActive(m_ShowTooltip);
|
||||||
if (tooltip.view != null)
|
if (tooltip.view != null)
|
||||||
tooltip.view.Refresh();
|
tooltip.view.Refresh();
|
||||||
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
|
TooltipHelper.LimitInRect(chart, tooltip, chart.chartRect);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ namespace XCharts.Runtime
|
|||||||
param.serieData.name,
|
param.serieData.name,
|
||||||
param.color,
|
param.color,
|
||||||
param.serieData,
|
param.serieData,
|
||||||
chart);
|
chart,
|
||||||
|
param.serieIndex);
|
||||||
foreach (var item in content.Split('|'))
|
foreach (var item in content.Split('|'))
|
||||||
{
|
{
|
||||||
param.columns.Add(item);
|
param.columns.Add(item);
|
||||||
@@ -58,7 +59,7 @@ namespace XCharts.Runtime
|
|||||||
return "-".Equals(itemFormatter) ||"{i}".Equals(itemFormatter, StringComparison.CurrentCultureIgnoreCase);
|
return "-".Equals(itemFormatter) ||"{i}".Equals(itemFormatter, StringComparison.CurrentCultureIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LimitInRect(Tooltip tooltip, Rect chartRect)
|
public static void LimitInRect(BaseChart chart, Tooltip tooltip, Rect chartRect)
|
||||||
{
|
{
|
||||||
if (tooltip.view == null)
|
if (tooltip.view == null)
|
||||||
return;
|
return;
|
||||||
@@ -78,7 +79,55 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
if (pos.y > chartRect.y + chartRect.height)
|
if (pos.y > chartRect.y + chartRect.height)
|
||||||
pos.y = chartRect.y + chartRect.height;
|
pos.y = chartRect.y + chartRect.height;
|
||||||
tooltip.UpdateContentPos(pos, chartRect.width / 2, chartRect.height / 2);
|
var screenGap = 10;
|
||||||
|
var screenPos = chart.LocalPointToScreenPoint(pos);
|
||||||
|
if (screenPos.x < screenGap)
|
||||||
|
pos.x += Mathf.Abs(screenPos.x) + screenGap;
|
||||||
|
if (screenPos.x + tooltip.context.width > Screen.width - screenGap)
|
||||||
|
pos.x -= Mathf.Abs(screenPos.x + tooltip.context.width - Screen.width) + screenGap;
|
||||||
|
|
||||||
|
if (screenPos.y < tooltip.context.height + screenGap)
|
||||||
|
pos.y += Mathf.Abs(screenPos.y - tooltip.context.height) + screenGap;
|
||||||
|
if (screenPos.y > Screen.height - screenGap)
|
||||||
|
pos.y -= Mathf.Abs(screenPos.y - Screen.height) + screenGap;
|
||||||
|
|
||||||
|
UpdateContentPos(tooltip, pos, chartRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新文本框位置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pos"></param>
|
||||||
|
private static void UpdateContentPos(Tooltip tooltip, Vector2 pos, Rect chartRect)
|
||||||
|
{
|
||||||
|
if (tooltip.view != null)
|
||||||
|
{
|
||||||
|
var width = chartRect.width;
|
||||||
|
var height = chartRect.height;
|
||||||
|
switch (tooltip.position)
|
||||||
|
{
|
||||||
|
case Tooltip.Position.Auto:
|
||||||
|
#if UNITY_ANDROID || UNITY_IOS
|
||||||
|
if (tooltip.fixedY == 0) pos.y = chartRect.x + ChartHelper.GetActualValue(0.7f, height);
|
||||||
|
else pos.y = chartRect.y + ChartHelper.GetActualValue(tooltip.fixedY, height);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case Tooltip.Position.Custom:
|
||||||
|
pos = new Vector2(chartRect.x, chartRect.y);
|
||||||
|
pos.x += ChartHelper.GetActualValue(tooltip.fixedX, width);
|
||||||
|
pos.y += ChartHelper.GetActualValue(tooltip.fixedY, height);
|
||||||
|
break;
|
||||||
|
case Tooltip.Position.FixedX:
|
||||||
|
pos = new Vector2(chartRect.x, pos.y);
|
||||||
|
pos.x += ChartHelper.GetActualValue(tooltip.fixedX, width);
|
||||||
|
break;
|
||||||
|
case Tooltip.Position.FixedY:
|
||||||
|
pos = new Vector2(pos.x, chartRect.y);
|
||||||
|
pos.y += ChartHelper.GetActualValue(tooltip.fixedY, height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tooltip.view.UpdatePosition(pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetItemNumericFormatter(Tooltip tooltip, Serie serie, SerieData serieData)
|
public static string GetItemNumericFormatter(Tooltip tooltip, Serie serie, SerieData serieData)
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ namespace XCharts.Runtime
|
|||||||
else if (p == 'c' || p == 'C' || p == 'd' || p == 'D' || p == 'f' || p == 'f')
|
else if (p == 'c' || p == 'C' || p == 'd' || p == 'D' || p == 'f' || p == 'f')
|
||||||
{
|
{
|
||||||
var isPercent = p == 'd' || p == 'D';
|
var isPercent = p == 'd' || p == 'D';
|
||||||
var isTotal = p == 'f' || p == 'f';
|
var isTotal = p == 'f' || p == 'F';
|
||||||
var bIndex = dataIndex;
|
var bIndex = dataIndex;
|
||||||
var dimensionIndex = -1;
|
var dimensionIndex = -1;
|
||||||
if (argsCount >= 2)
|
if (argsCount >= 2)
|
||||||
@@ -211,7 +211,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void ReplaceSerieLabelContent(ref string content, string numericFormatter, int dataCount, double value, double total,
|
public static void ReplaceSerieLabelContent(ref string content, string numericFormatter, int dataCount, double value, double total,
|
||||||
string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null)
|
string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null, int serieIndex = 0)
|
||||||
{
|
{
|
||||||
var mc = s_RegexForSerieLabel.Matches(content);
|
var mc = s_RegexForSerieLabel.Matches(content);
|
||||||
foreach (var m in mc)
|
foreach (var m in mc)
|
||||||
@@ -270,6 +270,14 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
else if (p == 'f' || p == 'f')
|
else if (p == 'f' || p == 'f')
|
||||||
{
|
{
|
||||||
|
if (pIndex != 1 && chart != null)
|
||||||
|
{
|
||||||
|
var serie = chart.GetSerie(serieIndex);
|
||||||
|
if (serie != null)
|
||||||
|
{
|
||||||
|
total = serie.GetDataTotal(pIndex, serieData);
|
||||||
|
}
|
||||||
|
}
|
||||||
content = content.Replace(old, ChartCached.NumberToStr(total, numericFormatter));
|
content = content.Replace(old, ChartCached.NumberToStr(total, numericFormatter));
|
||||||
}
|
}
|
||||||
else if (p == 'g' || p == 'G')
|
else if (p == 'g' || p == 'G')
|
||||||
|
|||||||
@@ -656,10 +656,12 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Background m_Background;
|
||||||
public Color32 GetChartBackgroundColor()
|
public Color32 GetChartBackgroundColor()
|
||||||
{
|
{
|
||||||
var background = GetChartComponent<Background>();
|
if (m_Background == null) m_Background = GetChartComponent<Background>();
|
||||||
return theme.GetBackgroundColor(background);
|
//var background = GetChartComponent<Background>();
|
||||||
|
return theme.GetBackgroundColor(m_Background);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ namespace XCharts.Runtime
|
|||||||
p4 = ClampInGrid(grid, p4);
|
p4 = ClampInGrid(grid, p4);
|
||||||
}
|
}
|
||||||
if (!clip ||
|
if (!clip ||
|
||||||
(clip && (grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) &&
|
(clip && grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) &&
|
||||||
grid.Contains(p4))))
|
grid.Contains(p4)))
|
||||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, startColor, toColor);
|
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, startColor, toColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,12 +83,12 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public void DrawClipSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
public void DrawClipSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
||||||
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, float gap,
|
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor, float gap,
|
||||||
bool clip, float[] cornerRadius, GridCoord grid, Vector3 startPos)
|
bool clip, float[] cornerRadius, GridCoord grid, Vector3 startPos, float symbolSize2 = 0)
|
||||||
{
|
{
|
||||||
if (!IsInChart(pos)) return;
|
if (!IsInChart(pos)) return;
|
||||||
if (!clip || (clip && (grid.Contains(pos))))
|
if (!clip || (clip && (grid.Contains(pos))))
|
||||||
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor,
|
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor,
|
||||||
gap, cornerRadius, startPos);
|
gap, cornerRadius, startPos, symbolSize2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawClipZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,
|
public void DrawClipZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,
|
||||||
@@ -101,22 +101,22 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
||||||
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor,
|
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor,
|
||||||
float gap, float[] cornerRadius)
|
float gap, float[] cornerRadius, float symbolSize2 = 0)
|
||||||
{
|
{
|
||||||
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor,
|
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, emptyColor, borderColor,
|
||||||
gap, cornerRadius, Vector3.zero);
|
gap, cornerRadius, Vector3.zero, symbolSize2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
public void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
||||||
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor,
|
Vector3 pos, Color32 color, Color32 toColor, Color32 emptyColor, Color32 borderColor,
|
||||||
float gap, float[] cornerRadius, Vector3 startPos)
|
float gap, float[] cornerRadius, Vector3 startPos, float symbolSize2 = 0)
|
||||||
{
|
{
|
||||||
var backgroundColor = GetChartBackgroundColor();
|
var backgroundColor = GetChartBackgroundColor();
|
||||||
if (ChartHelper.IsClearColor(emptyColor))
|
if (ChartHelper.IsClearColor(emptyColor))
|
||||||
emptyColor = backgroundColor;
|
emptyColor = backgroundColor;
|
||||||
var smoothness = settings.cicleSmoothness;
|
var smoothness = settings.cicleSmoothness;
|
||||||
ChartDrawer.DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap,
|
ChartDrawer.DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap,
|
||||||
cornerRadius, emptyColor, backgroundColor, borderColor, smoothness, startPos);
|
cornerRadius, emptyColor, backgroundColor, borderColor, smoothness, startPos, symbolSize2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, GridCoord grid)
|
public Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, GridCoord grid)
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
var index = settings.reversePainter ? settings.maxPainter - 1 - i : i;
|
var index = settings.reversePainter ? settings.maxPainter - 1 - i : i;
|
||||||
var painter = ChartHelper.AddPainterObject("painter_" + index, transform, m_GraphMinAnchor,
|
var painter = ChartHelper.AddPainterObject("painter_" + index, transform, m_GraphMinAnchor,
|
||||||
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + index);
|
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + index, m_ChildNodeNames);
|
||||||
painter.index = m_PainterList.Count;
|
painter.index = m_PainterList.Count;
|
||||||
painter.type = Painter.Type.Serie;
|
painter.type = Painter.Type.Serie;
|
||||||
painter.onPopulateMesh = OnDrawPainterSerie;
|
painter.onPopulateMesh = OnDrawPainterSerie;
|
||||||
@@ -404,7 +404,7 @@ namespace XCharts.Runtime
|
|||||||
m_PainterList.Add(painter);
|
m_PainterList.Add(painter);
|
||||||
}
|
}
|
||||||
m_PainterUpper = ChartHelper.AddPainterObject("painter_u", transform, m_GraphMinAnchor,
|
m_PainterUpper = ChartHelper.AddPainterObject("painter_u", transform, m_GraphMinAnchor,
|
||||||
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter);
|
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter, m_ChildNodeNames);
|
||||||
m_PainterUpper.type = Painter.Type.Top;
|
m_PainterUpper.type = Painter.Type.Top;
|
||||||
m_PainterUpper.onPopulateMesh = OnDrawPainterUpper;
|
m_PainterUpper.onPopulateMesh = OnDrawPainterUpper;
|
||||||
m_PainterUpper.SetActive(true, m_DebugInfo.showAllChartObject);
|
m_PainterUpper.SetActive(true, m_DebugInfo.showAllChartObject);
|
||||||
@@ -412,7 +412,7 @@ namespace XCharts.Runtime
|
|||||||
m_PainterUpper.transform.SetSiblingIndex(settings.maxPainter + 1);
|
m_PainterUpper.transform.SetSiblingIndex(settings.maxPainter + 1);
|
||||||
|
|
||||||
m_PainterTop = ChartHelper.AddPainterObject("painter_t", transform, m_GraphMinAnchor,
|
m_PainterTop = ChartHelper.AddPainterObject("painter_t", transform, m_GraphMinAnchor,
|
||||||
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter);
|
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter, m_ChildNodeNames);
|
||||||
m_PainterTop.type = Painter.Type.Top;
|
m_PainterTop.type = Painter.Type.Top;
|
||||||
m_PainterTop.onPopulateMesh = OnDrawPainterTop;
|
m_PainterTop.onPopulateMesh = OnDrawPainterTop;
|
||||||
m_PainterTop.SetActive(true, m_DebugInfo.showAllChartObject);
|
m_PainterTop.SetActive(true, m_DebugInfo.showAllChartObject);
|
||||||
|
|||||||
@@ -158,8 +158,8 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void RebuildChartObject()
|
public void RebuildChartObject()
|
||||||
{
|
{
|
||||||
ChartHelper.DestroyAllChildren(transform);
|
ChartHelper.DestoryGameObjectByMatch(transform, m_ChildNodeNames);
|
||||||
SetAllComponentDirty();
|
//SetAllComponentDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint)
|
public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@@ -14,6 +15,7 @@ namespace XCharts.Runtime
|
|||||||
IDragHandler, IEndDragHandler, IScrollHandler
|
IDragHandler, IEndDragHandler, IScrollHandler
|
||||||
{
|
{
|
||||||
[SerializeField] protected bool m_EnableTextMeshPro = false;
|
[SerializeField] protected bool m_EnableTextMeshPro = false;
|
||||||
|
[SerializeField] protected List<string> m_ChildNodeNames = new List<string>();
|
||||||
|
|
||||||
protected Painter m_Painter;
|
protected Painter m_Painter;
|
||||||
protected int m_SiblingIndex;
|
protected int m_SiblingIndex;
|
||||||
@@ -52,8 +54,11 @@ namespace XCharts.Runtime
|
|||||||
public virtual HideFlags chartHideFlags { get { return HideFlags.None; } }
|
public virtual HideFlags chartHideFlags { get { return HideFlags.None; } }
|
||||||
|
|
||||||
private ScrollRect m_ScrollRect;
|
private ScrollRect m_ScrollRect;
|
||||||
|
private Vector2 m_PointerDownPos;
|
||||||
|
|
||||||
public Painter painter { get { return m_Painter; } }
|
public Painter painter { get { return m_Painter; } }
|
||||||
|
public List<string> childrenNodeNames { get { return m_ChildNodeNames; } }
|
||||||
|
public bool isDragingClick { get; set; }
|
||||||
|
|
||||||
protected virtual void InitComponent()
|
protected virtual void InitComponent()
|
||||||
{
|
{
|
||||||
@@ -158,7 +163,7 @@ namespace XCharts.Runtime
|
|||||||
protected virtual void InitPainter()
|
protected virtual void InitPainter()
|
||||||
{
|
{
|
||||||
m_Painter = ChartHelper.AddPainterObject("painter_b", transform, m_GraphMinAnchor,
|
m_Painter = ChartHelper.AddPainterObject("painter_b", transform, m_GraphMinAnchor,
|
||||||
m_GraphMaxAnchor, m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight), chartHideFlags, 1);
|
m_GraphMaxAnchor, m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight), chartHideFlags, 1, m_ChildNodeNames);
|
||||||
m_Painter.type = Painter.Type.Base;
|
m_Painter.type = Painter.Type.Base;
|
||||||
m_Painter.onPopulateMesh = OnDrawPainterBase;
|
m_Painter.onPopulateMesh = OnDrawPainterBase;
|
||||||
m_Painter.transform.SetSiblingIndex(0);
|
m_Painter.transform.SetSiblingIndex(0);
|
||||||
@@ -284,11 +289,13 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public virtual void OnPointerDown(PointerEventData eventData)
|
public virtual void OnPointerDown(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
|
m_PointerDownPos = eventData.position;
|
||||||
if (m_OnPointerDown != null) m_OnPointerDown(eventData, this);
|
if (m_OnPointerDown != null) m_OnPointerDown(eventData, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnPointerUp(PointerEventData eventData)
|
public virtual void OnPointerUp(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
|
isDragingClick = Vector2.Distance(eventData.position, m_PointerDownPos) > 6;
|
||||||
if (m_OnPointerUp != null) m_OnPointerUp(eventData, this);
|
if (m_OnPointerUp != null) m_OnPointerUp(eventData, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -187,13 +187,13 @@ namespace XCharts.Runtime
|
|||||||
m_TMPText.alignment = TextAlignmentOptions.BottomRight;
|
m_TMPText.alignment = TextAlignmentOptions.BottomRight;
|
||||||
break;
|
break;
|
||||||
case TextAnchor.MiddleCenter:
|
case TextAnchor.MiddleCenter:
|
||||||
m_TMPText.alignment = TextAlignmentOptions.Center;
|
m_TMPText.alignment = TextAlignmentOptions.Midline;
|
||||||
break;
|
break;
|
||||||
case TextAnchor.MiddleLeft:
|
case TextAnchor.MiddleLeft:
|
||||||
m_TMPText.alignment = TextAlignmentOptions.Left;
|
m_TMPText.alignment = TextAlignmentOptions.MidlineLeft;
|
||||||
break;
|
break;
|
||||||
case TextAnchor.MiddleRight:
|
case TextAnchor.MiddleRight:
|
||||||
m_TMPText.alignment = TextAlignmentOptions.Right;
|
m_TMPText.alignment = TextAlignmentOptions.MidlineRight;
|
||||||
break;
|
break;
|
||||||
case TextAnchor.UpperCenter:
|
case TextAnchor.UpperCenter:
|
||||||
m_TMPText.alignment = TextAlignmentOptions.Top;
|
m_TMPText.alignment = TextAlignmentOptions.Top;
|
||||||
@@ -205,8 +205,7 @@ namespace XCharts.Runtime
|
|||||||
m_TMPText.alignment = TextAlignmentOptions.TopRight;
|
m_TMPText.alignment = TextAlignmentOptions.TopRight;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
m_TMPText.alignment = TextAlignmentOptions.Center;
|
m_TMPText.alignment = TextAlignmentOptions.Midline;
|
||||||
m_TextAlignment = TextAnchor.MiddleCenter;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
[SerializeField] private bool m_DebugModel = false;
|
[SerializeField] private bool m_DebugModel = false;
|
||||||
[SerializeField] protected UIComponentTheme m_Theme = new UIComponentTheme();
|
[SerializeField] protected UIComponentTheme m_Theme = new UIComponentTheme();
|
||||||
[SerializeField] private Background m_Background = new Background() { show = true };
|
[SerializeField] protected Background m_Background = new Background() { show = true };
|
||||||
|
|
||||||
protected bool m_DataDirty;
|
protected bool m_DataDirty;
|
||||||
private ThemeType m_CheckTheme = 0;
|
private ThemeType m_CheckTheme = 0;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ namespace XCharts.Runtime
|
|||||||
private static Dictionary<double, Dictionary<string, string>> s_NumberToStr = new Dictionary<double, Dictionary<string, string>>();
|
private static Dictionary<double, Dictionary<string, string>> s_NumberToStr = new Dictionary<double, Dictionary<string, string>>();
|
||||||
private static Dictionary<int, Dictionary<string, string>> s_PrecisionToStr = new Dictionary<int, Dictionary<string, string>>();
|
private static Dictionary<int, Dictionary<string, string>> s_PrecisionToStr = new Dictionary<int, Dictionary<string, string>>();
|
||||||
private static Dictionary<string, Dictionary<int, string>> s_StringIntDict = new Dictionary<string, Dictionary<int, string>>();
|
private static Dictionary<string, Dictionary<int, string>> s_StringIntDict = new Dictionary<string, Dictionary<int, string>>();
|
||||||
|
private static Dictionary<double, DateTime> s_TimestampToDateTimeDict = new Dictionary<double, DateTime>();
|
||||||
|
private static Dictionary<double, TimeSpan> s_NumberToTimeSpanDict = new Dictionary<double, TimeSpan>();
|
||||||
|
|
||||||
private static CultureInfo GetDefaultCultureInfo()
|
private static CultureInfo GetDefaultCultureInfo()
|
||||||
{
|
{
|
||||||
@@ -64,10 +66,19 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
if (!s_NumberToStr[value].ContainsKey(formatter))
|
if (!s_NumberToStr[value].ContainsKey(formatter))
|
||||||
{
|
{
|
||||||
|
bool isDateFormatter = false;
|
||||||
|
string newFormatter = null;
|
||||||
if (string.IsNullOrEmpty(formatter))
|
if (string.IsNullOrEmpty(formatter))
|
||||||
{
|
{
|
||||||
s_NumberToStr[value][formatter] = value.ToString();
|
s_NumberToStr[value][formatter] = value.ToString();
|
||||||
}
|
}
|
||||||
|
else if (DateTimeUtil.IsDateOrTimeRegex(formatter,ref isDateFormatter, ref newFormatter))
|
||||||
|
{
|
||||||
|
if(isDateFormatter)
|
||||||
|
s_NumberToStr[value][formatter] = NumberToDateStr(value, newFormatter);
|
||||||
|
else
|
||||||
|
s_NumberToStr[value][formatter] = NumberToTimeStr(value, newFormatter);
|
||||||
|
}
|
||||||
else if (formatter.StartsWith(NUMERIC_FORMATTER_D) ||
|
else if (formatter.StartsWith(NUMERIC_FORMATTER_D) ||
|
||||||
formatter.StartsWith(NUMERIC_FORMATTER_d) ||
|
formatter.StartsWith(NUMERIC_FORMATTER_d) ||
|
||||||
formatter.StartsWith(NUMERIC_FORMATTER_X) ||
|
formatter.StartsWith(NUMERIC_FORMATTER_X) ||
|
||||||
@@ -89,6 +100,56 @@ namespace XCharts.Runtime
|
|||||||
return NumberToStr(value, numericFormatter);
|
return NumberToStr(value, numericFormatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string NumberToDateStr(double timestamp, string formatter)
|
||||||
|
{
|
||||||
|
var dt = NumberToDateTime(timestamp);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return dt.ToString(formatter, ci);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
XLog.LogError("Not support DateTime format: " + formatter);
|
||||||
|
return timestamp.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string NumberToTimeStr(double timestamp, string formatter)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ts = NumberToTimeSpan(timestamp);
|
||||||
|
#if UNITY_2018_3_OR_NEWER
|
||||||
|
return ts.ToString(formatter, ci);
|
||||||
|
#else
|
||||||
|
return ts.ToString();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
XLog.LogError("Not support TimeSpan format: " + formatter);
|
||||||
|
return timestamp.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DateTime NumberToDateTime(double timestamp)
|
||||||
|
{
|
||||||
|
if (!s_TimestampToDateTimeDict.ContainsKey(timestamp))
|
||||||
|
{
|
||||||
|
s_TimestampToDateTimeDict[timestamp] = DateTimeUtil.GetDateTime(timestamp);
|
||||||
|
}
|
||||||
|
return s_TimestampToDateTimeDict[timestamp];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TimeSpan NumberToTimeSpan(double timestamp)
|
||||||
|
{
|
||||||
|
if(!s_NumberToTimeSpanDict.ContainsKey(timestamp))
|
||||||
|
{
|
||||||
|
s_NumberToTimeSpanDict[timestamp] = TimeSpan.FromSeconds(timestamp);
|
||||||
|
}
|
||||||
|
return s_NumberToTimeSpanDict[timestamp];
|
||||||
|
}
|
||||||
|
|
||||||
public static string ColorToStr(Color color)
|
public static string ColorToStr(Color color)
|
||||||
{
|
{
|
||||||
if (s_ColorToStr.ContainsKey(color))
|
if (s_ColorToStr.ContainsKey(color))
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
public static void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
public static void DrawSymbol(VertexHelper vh, SymbolType type, float symbolSize, float tickness,
|
||||||
Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
|
Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius,
|
||||||
Color32 emptyColor, Color32 backgroundColor, Color32 borderColor, float smoothness, Vector3 startPos)
|
Color32 emptyColor, Color32 backgroundColor, Color32 borderColor, float smoothness,
|
||||||
|
Vector3 startPos, float symbolSize2 = 0f)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@@ -22,13 +23,14 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (tickness > 0)
|
if (tickness > 0 && !ChartHelper.IsClearColor(borderColor))
|
||||||
UGL.DrawDoughnut(vh, pos, symbolSize, symbolSize + tickness, borderColor, borderColor, color, smoothness);
|
UGL.DrawDoughnut(vh, pos, symbolSize, symbolSize + tickness, borderColor, borderColor, color, smoothness);
|
||||||
else
|
else
|
||||||
UGL.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness);
|
UGL.DrawCricle(vh, pos, symbolSize, color, toColor, smoothness);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SymbolType.EmptyCircle:
|
case SymbolType.EmptyCircle:
|
||||||
|
if (tickness == 0) tickness = 4f;
|
||||||
if (gap > 0)
|
if (gap > 0)
|
||||||
{
|
{
|
||||||
UGL.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness);
|
UGL.DrawCricle(vh, pos, symbolSize + gap, backgroundColor, smoothness);
|
||||||
@@ -40,23 +42,31 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SymbolType.Rect:
|
case SymbolType.Rect:
|
||||||
if (gap > 0)
|
if (symbolSize2 > 0 && symbolSize2 != symbolSize)
|
||||||
{
|
{
|
||||||
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
|
UGL.DrawRectangle(vh, pos, symbolSize, symbolSize2, color, toColor);
|
||||||
UGL.DrawSquare(vh, pos, symbolSize, color, toColor);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (tickness > 0)
|
if (gap > 0)
|
||||||
{
|
{
|
||||||
UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true);
|
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
|
||||||
UGL.DrawBorder(vh, pos, symbolSize, symbolSize, tickness, borderColor, 0, cornerRadius);
|
UGL.DrawSquare(vh, pos, symbolSize, color, toColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true);
|
{
|
||||||
|
if (tickness > 0)
|
||||||
|
{
|
||||||
|
UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true);
|
||||||
|
UGL.DrawBorder(vh, pos, symbolSize, symbolSize, tickness, borderColor, 0, cornerRadius);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
UGL.DrawRoundRectangle(vh, pos, symbolSize * 2, symbolSize * 2, color, color, 0, cornerRadius, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SymbolType.EmptyRect:
|
case SymbolType.EmptyRect:
|
||||||
|
if (tickness == 0) tickness = 4f;
|
||||||
if (gap > 0)
|
if (gap > 0)
|
||||||
{
|
{
|
||||||
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
|
UGL.DrawSquare(vh, pos, symbolSize + gap, backgroundColor);
|
||||||
@@ -75,6 +85,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
if (type == SymbolType.EmptyTriangle)
|
if (type == SymbolType.EmptyTriangle)
|
||||||
{
|
{
|
||||||
|
if (tickness == 0) tickness = 4f;
|
||||||
UGL.DrawEmptyTriangle(vh, pos, symbolSize * 1.4f, tickness * 2f, color, emptyColor);
|
UGL.DrawEmptyTriangle(vh, pos, symbolSize * 1.4f, tickness * 2f, color, emptyColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -92,6 +103,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
if (type == SymbolType.EmptyDiamond)
|
if (type == SymbolType.EmptyDiamond)
|
||||||
{
|
{
|
||||||
|
if (tickness == 0) tickness = 4f;
|
||||||
UGL.DrawEmptyDiamond(vh, pos, xRadius, yRadius, tickness, color, emptyColor);
|
UGL.DrawEmptyDiamond(vh, pos, xRadius, yRadius, tickness, color, emptyColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -124,6 +136,7 @@ namespace XCharts.Runtime
|
|||||||
arrowOffset, arrowDent, color);
|
arrowOffset, arrowDent, color);
|
||||||
if (type == SymbolType.EmptyArrow)
|
if (type == SymbolType.EmptyArrow)
|
||||||
{
|
{
|
||||||
|
if (tickness == 0) tickness = 4f;
|
||||||
arrowWidth = (symbolSize - tickness) * 2;
|
arrowWidth = (symbolSize - tickness) * 2;
|
||||||
arrowHeight = arrowWidth * 1.5f;
|
arrowHeight = arrowWidth * 1.5f;
|
||||||
arrowOffset = 0;
|
arrowOffset = 0;
|
||||||
|
|||||||
@@ -156,6 +156,21 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void DestoryGameObjectByMatch(Transform parent, List<string> children)
|
||||||
|
{
|
||||||
|
if (parent == null) return;
|
||||||
|
if (children == null || children.Count == 0) return;
|
||||||
|
var childCount = parent.childCount;
|
||||||
|
for (int i = childCount - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
var go = parent.GetChild(i);
|
||||||
|
if (go != null && children.Contains(go.name))
|
||||||
|
{
|
||||||
|
GameObject.DestroyImmediate(go.gameObject, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void DestoryGameObject(GameObject go)
|
public static void DestoryGameObject(GameObject go)
|
||||||
{
|
{
|
||||||
if (go != null) GameObject.DestroyImmediate(go, true);
|
if (go != null) GameObject.DestroyImmediate(go, true);
|
||||||
@@ -233,7 +248,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject AddObject(string name, Transform parent, Vector2 anchorMin,
|
public static GameObject AddObject(string name, Transform parent, Vector2 anchorMin,
|
||||||
Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, int replaceIndex = -1)
|
Vector2 anchorMax, Vector2 pivot, Vector2 sizeDelta, int replaceIndex = -1, List<string> cacheNames = null)
|
||||||
{
|
{
|
||||||
GameObject obj;
|
GameObject obj;
|
||||||
if (parent.Find(name))
|
if (parent.Find(name))
|
||||||
@@ -267,6 +282,8 @@ namespace XCharts.Runtime
|
|||||||
rect.anchorMax = anchorMax;
|
rect.anchorMax = anchorMax;
|
||||||
rect.pivot = pivot;
|
rect.pivot = pivot;
|
||||||
rect.anchoredPosition3D = Vector3.zero;
|
rect.anchoredPosition3D = Vector3.zero;
|
||||||
|
|
||||||
|
if (cacheNames != null && !cacheNames.Contains(name)) cacheNames.Add(name);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +314,11 @@ namespace XCharts.Runtime
|
|||||||
chartText.tmpText.fontStyle = textStyle.tmpFontStyle;
|
chartText.tmpText.fontStyle = textStyle.tmpFontStyle;
|
||||||
chartText.tmpText.richText = true;
|
chartText.tmpText.richText = true;
|
||||||
chartText.tmpText.raycastTarget = false;
|
chartText.tmpText.raycastTarget = false;
|
||||||
|
#if UNITY_2023_2_OR_NEWER
|
||||||
|
chartText.tmpText.textWrappingMode = textStyle.autoWrap ? TextWrappingModes.Normal : TextWrappingModes.NoWrap;
|
||||||
|
#else
|
||||||
chartText.tmpText.enableWordWrapping = textStyle.autoWrap;
|
chartText.tmpText.enableWordWrapping = textStyle.autoWrap;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
chartText.text = EnsureComponent<Text>(txtObj);
|
chartText.text = EnsureComponent<Text>(txtObj);
|
||||||
chartText.text.font = textStyle.font == null ? theme.font : textStyle.font;
|
chartText.text.font = textStyle.font == null ? theme.font : textStyle.font;
|
||||||
@@ -319,7 +340,7 @@ namespace XCharts.Runtime
|
|||||||
chartText.SetActive(textStyle.show);
|
chartText.SetActive(textStyle.show);
|
||||||
|
|
||||||
RectTransform rect = EnsureComponent<RectTransform>(txtObj);
|
RectTransform rect = EnsureComponent<RectTransform>(txtObj);
|
||||||
rect.localPosition = Vector3.zero;
|
rect.anchoredPosition3D = Vector3.zero;
|
||||||
rect.sizeDelta = sizeDelta;
|
rect.sizeDelta = sizeDelta;
|
||||||
rect.anchorMin = anchorMin;
|
rect.anchorMin = anchorMin;
|
||||||
rect.anchorMax = anchorMax;
|
rect.anchorMax = anchorMax;
|
||||||
@@ -328,9 +349,9 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Painter AddPainterObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax,
|
public static Painter AddPainterObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax,
|
||||||
Vector2 pivot, Vector2 sizeDelta, HideFlags hideFlags, int siblingIndex)
|
Vector2 pivot, Vector2 sizeDelta, HideFlags hideFlags, int siblingIndex, List<string> childNodeNames)
|
||||||
{
|
{
|
||||||
var painterObj = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
var painterObj = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta, -1, childNodeNames);
|
||||||
painterObj.hideFlags = hideFlags;
|
painterObj.hideFlags = hideFlags;
|
||||||
painterObj.transform.SetSiblingIndex(siblingIndex);
|
painterObj.transform.SetSiblingIndex(siblingIndex);
|
||||||
return ChartHelper.EnsureComponent<Painter>(painterObj);
|
return ChartHelper.EnsureComponent<Painter>(painterObj);
|
||||||
@@ -492,7 +513,7 @@ namespace XCharts.Runtime
|
|||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdateAnchorAndPivotByTextAlignment(TextAnchor alignment, out Vector2 anchorMin, out Vector2 anchorMax,
|
public static void UpdateAnchorAndPivotByTextAlignment(TextAnchor alignment, out Vector2 anchorMin, out Vector2 anchorMax,
|
||||||
out Vector2 pivot)
|
out Vector2 pivot)
|
||||||
{
|
{
|
||||||
switch (alignment)
|
switch (alignment)
|
||||||
@@ -770,6 +791,14 @@ namespace XCharts.Runtime
|
|||||||
return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate;
|
return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float GetMaxCeilRate(float value, float ceilRate)
|
||||||
|
{
|
||||||
|
if (ceilRate == 0) return value;
|
||||||
|
var mod = value % ceilRate;
|
||||||
|
int rate = (int)(value / ceilRate);
|
||||||
|
return mod == 0 ? value : (value < 0 ? rate : rate + 1) * ceilRate;
|
||||||
|
}
|
||||||
|
|
||||||
public static double GetMinCeilRate(double value, double ceilRate)
|
public static double GetMinCeilRate(double value, double ceilRate)
|
||||||
{
|
{
|
||||||
if (ceilRate == 0) return value;
|
if (ceilRate == 0) return value;
|
||||||
@@ -778,6 +807,14 @@ namespace XCharts.Runtime
|
|||||||
return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate;
|
return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float GetMinCeilRate(float value, float ceilRate)
|
||||||
|
{
|
||||||
|
if (ceilRate == 0) return value;
|
||||||
|
var mod = value % ceilRate;
|
||||||
|
int rate = (int)(value / ceilRate);
|
||||||
|
return mod == 0 ? value : (value < 0 ? rate - 1 : rate) * ceilRate;
|
||||||
|
}
|
||||||
|
|
||||||
public static double GetMinDivisibleValue(double min, double ceilRate)
|
public static double GetMinDivisibleValue(double min, double ceilRate)
|
||||||
{
|
{
|
||||||
if (min == 0) return 0;
|
if (min == 0) return 0;
|
||||||
|
|||||||
@@ -11,43 +11,66 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class UIHelper
|
public static class UIHelper
|
||||||
{
|
{
|
||||||
internal static void DrawBackground(VertexHelper vh, UIComponent component)
|
public static void DrawBackground(VertexHelper vh, UIComponent component)
|
||||||
{
|
{
|
||||||
var background = component.background;
|
var background = component.background;
|
||||||
|
var rect = component.graphRect;
|
||||||
|
if (background.imageWidth > 0 || background.imageHeight > 0)
|
||||||
|
{
|
||||||
|
if (background.imageWidth > 0)
|
||||||
|
{
|
||||||
|
rect.width = background.imageWidth;
|
||||||
|
rect.x = component.graphX + (component.graphWidth - background.imageWidth) / 2;
|
||||||
|
}
|
||||||
|
if (background.imageHeight > 0)
|
||||||
|
{
|
||||||
|
rect.height = background.imageHeight;
|
||||||
|
rect.y = component.graphY + (component.graphHeight - background.imageHeight) / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
background.rect = rect;
|
||||||
if (!background.show)
|
if (!background.show)
|
||||||
return;
|
return;
|
||||||
if (background.image != null)
|
if (background.image != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var backgroundColor = component.theme.GetBackgroundColor(background);
|
var backgroundColor = component.theme.GetBackgroundColor(background);
|
||||||
|
DrawBackground(vh, background, backgroundColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DrawBackground(VertexHelper vh, Background background, Color32 color, float smoothness = 2)
|
||||||
|
{
|
||||||
|
if (!background.show)
|
||||||
|
return;
|
||||||
|
if (background.image != null)
|
||||||
|
return;
|
||||||
var borderWidth = background.borderStyle.GetRuntimeBorderWidth();
|
var borderWidth = background.borderStyle.GetRuntimeBorderWidth();
|
||||||
var borderColor = background.borderStyle.GetRuntimeBorderColor();
|
var borderColor = background.borderStyle.GetRuntimeBorderColor();
|
||||||
var cornerRadius = background.borderStyle.GetRuntimeCornerRadius();
|
var cornerRadius = background.borderStyle.GetRuntimeCornerRadius();
|
||||||
UGL.DrawRoundRectangleWithBorder(vh, component.graphRect, backgroundColor, backgroundColor, cornerRadius,
|
UGL.DrawRoundRectangleWithBorder(vh, background.rect, color, color, cornerRadius,
|
||||||
borderWidth, borderColor);
|
borderWidth, borderColor, 0, smoothness);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void InitBackground(UIComponent table)
|
internal static void InitBackground(UIComponent component)
|
||||||
{
|
{
|
||||||
if (table.background.show == false ||
|
if (component.background.show == false ||
|
||||||
(table.background.image == null && ChartHelper.IsClearColor(table.background.imageColor)))
|
(component.background.image == null && ChartHelper.IsClearColor(component.background.imageColor)))
|
||||||
{
|
{
|
||||||
ChartHelper.DestoryGameObject(table.transform, "Background");
|
ChartHelper.DestoryGameObject(component.transform, "Background");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var sizeDelta = table.background.imageWidth > 0 && table.background.imageHeight > 0 ?
|
var sizeDelta = component.background.imageWidth > 0 && component.background.imageHeight > 0 ?
|
||||||
new Vector2(table.background.imageWidth, table.background.imageHeight) :
|
new Vector2(component.background.imageWidth, component.background.imageHeight) :
|
||||||
table.graphSizeDelta;
|
component.graphSizeDelta;
|
||||||
var backgroundObj = ChartHelper.AddObject("Background", table.transform, table.graphMinAnchor,
|
var backgroundObj = ChartHelper.AddObject("Background", component.transform, component.graphMinAnchor,
|
||||||
table.graphMaxAnchor, table.graphPivot, sizeDelta);
|
component.graphMaxAnchor, component.graphPivot, sizeDelta);
|
||||||
backgroundObj.hideFlags = table.chartHideFlags;
|
backgroundObj.hideFlags = component.chartHideFlags;
|
||||||
|
|
||||||
var backgroundImage = ChartHelper.EnsureComponent<Image>(backgroundObj);
|
var backgroundImage = ChartHelper.EnsureComponent<Image>(backgroundObj);
|
||||||
ChartHelper.UpdateRectTransform(backgroundObj, table.graphMinAnchor,
|
ChartHelper.UpdateRectTransform(backgroundObj, component.graphMinAnchor,
|
||||||
table.graphMaxAnchor, table.graphPivot, sizeDelta);
|
component.graphMaxAnchor, component.graphPivot, sizeDelta);
|
||||||
ChartHelper.SetBackground(backgroundImage, table.background);
|
ChartHelper.SetBackground(backgroundImage, component.background);
|
||||||
backgroundObj.transform.SetSiblingIndex(0);
|
backgroundObj.transform.SetSiblingIndex(0);
|
||||||
backgroundObj.SetActive(table.background.show && table.background.image != null);
|
backgroundObj.SetActive(component.background.show && component.background.image != null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,8 +21,8 @@ namespace XCharts.Runtime
|
|||||||
[ExecuteInEditMode]
|
[ExecuteInEditMode]
|
||||||
public static class XChartsMgr
|
public static class XChartsMgr
|
||||||
{
|
{
|
||||||
public static readonly string version = "3.11.2";
|
public static readonly string version = "3.13.0";
|
||||||
public static readonly int versionDate = 20240801;
|
public static readonly int versionDate = 20250101;
|
||||||
public static string fullVersion { get { return version + "-" + versionDate; } }
|
public static string fullVersion { get { return version + "-" + versionDate; } }
|
||||||
|
|
||||||
internal static List<BaseChart> chartList = new List<BaseChart>();
|
internal static List<BaseChart> chartList = new List<BaseChart>();
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ namespace XCharts.Runtime
|
|||||||
var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serie.context.colorIndex, state);
|
var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serie.context.colorIndex, state);
|
||||||
serieData.context.rect = new Rect(pos.x - symbolSize / 2, pos.y - symbolSize / 2, symbolSize, symbolSize);
|
serieData.context.rect = new Rect(pos.x - symbolSize / 2, pos.y - symbolSize / 2, symbolSize, symbolSize);
|
||||||
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
||||||
color, color, emptyColor, borderColor, symbol.gap, cornerRadius);
|
color, color, emptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visualMap.hoverLink && highlight && emphasisStyle != null &&
|
if (visualMap.hoverLink && highlight && emphasisStyle != null &&
|
||||||
@@ -461,7 +461,7 @@ namespace XCharts.Runtime
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
||||||
color, color, emptyColor, borderColor, symbol.gap, cornerRadius);
|
color, color, emptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visualMap.hoverLink && highlight && emphasisStyle != null &&
|
if (visualMap.hoverLink && highlight && emphasisStyle != null &&
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
|
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
|
||||||
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.context.position,
|
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.context.position,
|
||||||
symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius);
|
symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,27 @@ namespace XCharts.Runtime
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var gridXY = (isY ? grid.context.x : grid.context.y);
|
var gridXY = (isY ? grid.context.x : grid.context.y);
|
||||||
|
var min = gridXY;
|
||||||
|
var max = gridXY + (isY ? grid.context.width : grid.context.height);
|
||||||
|
var start = 0f;
|
||||||
|
switch(serie.areaStyle.origin)
|
||||||
|
{
|
||||||
|
case AreaStyle.AreaOrigin.Start:
|
||||||
|
start = min;
|
||||||
|
break;
|
||||||
|
case AreaStyle.AreaOrigin.End:
|
||||||
|
start = max;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
start = gridXY + relativedAxis.context.offset;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (lastStackSerie == null)
|
if (lastStackSerie == null)
|
||||||
{
|
{
|
||||||
DrawSerieLineNormalArea(vh, serie, isY,
|
DrawSerieLineNormalArea(vh, serie, isY,
|
||||||
gridXY + relativedAxis.context.offset,
|
start,
|
||||||
gridXY,
|
min,
|
||||||
gridXY + (isY ? grid.context.width : grid.context.height),
|
max,
|
||||||
areaColor,
|
areaColor,
|
||||||
areaToColor,
|
areaToColor,
|
||||||
visualMap,
|
visualMap,
|
||||||
@@ -52,9 +67,9 @@ namespace XCharts.Runtime
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawSerieLineStackArea(vh, serie, lastStackSerie, isY,
|
DrawSerieLineStackArea(vh, serie, lastStackSerie, isY,
|
||||||
gridXY + relativedAxis.context.offset,
|
start,
|
||||||
gridXY,
|
min,
|
||||||
gridXY + (isY ? grid.context.width : grid.context.height),
|
max,
|
||||||
areaColor,
|
areaColor,
|
||||||
areaToColor,
|
areaToColor,
|
||||||
visualMap,
|
visualMap,
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ namespace XCharts.Runtime
|
|||||||
SerieHelper.GetItemColor(out symbolColor, out symbolToColor, out symbolEmptyColor, serie, serieData, chart.theme, colorIndex, serieState);
|
SerieHelper.GetItemColor(out symbolColor, out symbolToColor, out symbolEmptyColor, serie, serieData, chart.theme, colorIndex, serieState);
|
||||||
SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, serieData, chart.theme, serieState);
|
SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, serieData, chart.theme, serieState);
|
||||||
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, point, symbolColor,
|
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, point, symbolColor,
|
||||||
symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius);
|
symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius, symbol.size2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -495,7 +495,7 @@ namespace XCharts.Runtime
|
|||||||
symbolToColor = m_RadarCoord.outRangeColor;
|
symbolToColor = m_RadarCoord.outRangeColor;
|
||||||
}
|
}
|
||||||
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor,
|
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor,
|
||||||
symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
|
symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius, serie.symbol.size2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!serie.animation.IsFinish())
|
if (!serie.animation.IsFinish())
|
||||||
|
|||||||
@@ -9,7 +9,20 @@ namespace XCharts.Runtime
|
|||||||
[SerieDataExtraField()]
|
[SerieDataExtraField()]
|
||||||
public class Ring : Serie
|
public class Ring : Serie
|
||||||
{
|
{
|
||||||
|
[SerializeField][Since("v3.12.0")] private bool m_RadiusGradient = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether to use gradient color in pie chart.
|
||||||
|
/// || 是否开启半径方向的渐变效果。
|
||||||
|
/// </summary>
|
||||||
|
public bool radiusGradient
|
||||||
|
{
|
||||||
|
get { return m_RadiusGradient; }
|
||||||
|
set { if (PropertyUtil.SetStruct(ref m_RadiusGradient, value)) { SetVerticesDirty(); } }
|
||||||
|
}
|
||||||
|
|
||||||
public override SerieColorBy defaultColorBy { get { return SerieColorBy.Data; } }
|
public override SerieColorBy defaultColorBy { get { return SerieColorBy.Data; } }
|
||||||
|
|
||||||
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
|
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
|
||||||
{
|
{
|
||||||
var serie = chart.AddSerie<Ring>(serieName);
|
var serie = chart.AddSerie<Ring>(serieName);
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ namespace XCharts.Runtime
|
|||||||
DrawBackground(vh, serie, serieData, j, insideRadius, outsideRadius);
|
DrawBackground(vh, serie, serieData, j, insideRadius, outsideRadius);
|
||||||
UGL.DrawDoughnut(vh, serie.context.center, insideRadius, outsideRadius, itemColor, itemToColor,
|
UGL.DrawDoughnut(vh, serie.context.center, insideRadius, outsideRadius, itemColor, itemToColor,
|
||||||
Color.clear, startDegree, toDegree, borderWidth, borderColor, 0, chart.settings.cicleSmoothness,
|
Color.clear, startDegree, toDegree, borderWidth, borderColor, 0, chart.settings.cicleSmoothness,
|
||||||
roundCap, serie.clockwise);
|
roundCap, serie.clockwise, serie.radiusGradient);
|
||||||
DrawCenter(vh, serie, serieData, insideRadius, j == data.Count - 1);
|
DrawCenter(vh, serie, serieData, insideRadius, j == data.Count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2007,8 +2007,11 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void AnimationEnable(bool flag)
|
public void AnimationEnable(bool flag)
|
||||||
{
|
{
|
||||||
if (animation.enable) animation.enable = flag;
|
if (animation.enable != flag)
|
||||||
SetVerticesDirty();
|
{
|
||||||
|
animation.enable = flag;
|
||||||
|
SetVerticesDirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
var objName = s_SerieRootObjectName + "_" + serie.index;
|
var objName = s_SerieRootObjectName + "_" + serie.index;
|
||||||
m_SerieRoot = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
m_SerieRoot = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||||
m_SerieRoot.hideFlags = chart.chartHideFlags;
|
m_SerieRoot.hideFlags = chart.chartHideFlags;
|
||||||
ChartHelper.SetActive(m_SerieRoot, true);
|
ChartHelper.SetActive(m_SerieRoot, true);
|
||||||
ChartHelper.HideAllObject(m_SerieRoot);
|
ChartHelper.HideAllObject(m_SerieRoot);
|
||||||
@@ -762,7 +762,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
var color = symbol.GetColor(defaultColor);
|
var color = symbol.GetColor(defaultColor);
|
||||||
chart.DrawSymbol(vh, symbol.type, symbol.size, 1, pos,
|
chart.DrawSymbol(vh, symbol.type, symbol.size, 1, pos,
|
||||||
color, color, ColorUtil.clearColor32, color, symbol.gap, null);
|
color, color, ColorUtil.clearColor32, color, symbol.gap, null, symbol.size2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnPointerDown(PointerEventData eventData)
|
public override void OnPointerDown(PointerEventData eventData)
|
||||||
|
|||||||
@@ -132,6 +132,21 @@ namespace XCharts.Runtime
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// check if series has any serie which is color by data.
|
||||||
|
/// || 是否有任何一个系列是按数据颜色的。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="series"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsAnyColorByDataSerie(List<Serie> series)
|
||||||
|
{
|
||||||
|
foreach (var serie in series)
|
||||||
|
{
|
||||||
|
if (serie.defaultColorBy == SerieColorBy.Data) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得上一个同堆叠且显示的serie。
|
/// 获得上一个同堆叠且显示的serie。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
private static Dictionary<string, Color32> s_ColorCached = new Dictionary<string, Color32>();
|
private static Dictionary<string, Color32> s_ColorCached = new Dictionary<string, Color32>();
|
||||||
public static readonly Color32 clearColor32 = new Color32(0, 0, 0, 0);
|
public static readonly Color32 clearColor32 = new Color32(0, 0, 0, 0);
|
||||||
|
public static readonly Color32 white = new Color32(255, 255, 255, 255);
|
||||||
public static readonly Vector2 zeroVector2 = Vector2.zero;
|
public static readonly Vector2 zeroVector2 = Vector2.zero;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace XCharts.Runtime
|
namespace XCharts.Runtime
|
||||||
@@ -7,10 +8,11 @@ namespace XCharts.Runtime
|
|||||||
public static class DateTimeUtil
|
public static class DateTimeUtil
|
||||||
{
|
{
|
||||||
#if UNITY_2018_3_OR_NEWER
|
#if UNITY_2018_3_OR_NEWER
|
||||||
private static readonly DateTime k_DateTime1970 = TimeZoneInfo.ConvertTimeFromUtc(new DateTime(1970, 1, 1), TimeZoneInfo.Local);
|
private static readonly DateTime k_LocalDateTime1970 = TimeZoneInfo.ConvertTimeFromUtc(new DateTime(1970, 1, 1), TimeZoneInfo.Local);
|
||||||
#else
|
#else
|
||||||
private static readonly DateTime k_DateTime1970 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
private static readonly DateTime k_LocalDateTime1970 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
||||||
#endif
|
#endif
|
||||||
|
private static readonly DateTime k_DateTime1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||||
public static readonly int ONE_SECOND = 1;
|
public static readonly int ONE_SECOND = 1;
|
||||||
public static readonly int ONE_MINUTE = ONE_SECOND * 60;
|
public static readonly int ONE_MINUTE = ONE_SECOND * 60;
|
||||||
public static readonly int ONE_HOUR = ONE_MINUTE * 60;
|
public static readonly int ONE_HOUR = ONE_MINUTE * 60;
|
||||||
@@ -26,22 +28,54 @@ namespace XCharts.Runtime
|
|||||||
//private static string s_MinuteDateFormatter = "mm:ss";
|
//private static string s_MinuteDateFormatter = "mm:ss";
|
||||||
private static string s_SecondDateFormatter = "HH:mm:ss";
|
private static string s_SecondDateFormatter = "HH:mm:ss";
|
||||||
//private static string s_FullDateFormatter = "yyyy-MM-dd HH:mm:ss";
|
//private static string s_FullDateFormatter = "yyyy-MM-dd HH:mm:ss";
|
||||||
|
private static Regex s_DateOrTimeRegex = new Regex(@"^(date|time)\s*[:\s]+(.*)", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
public static bool IsDateOrTimeRegex(string regex)
|
||||||
|
{
|
||||||
|
return regex.StartsWith("date") || regex.StartsWith("time");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsDateOrTimeRegex(string regex, ref bool date, ref string formatter)
|
||||||
|
{
|
||||||
|
if(IsDateOrTimeRegex(regex))
|
||||||
|
{
|
||||||
|
if(regex == "date" || regex == "time")
|
||||||
|
{
|
||||||
|
date = regex == "date";
|
||||||
|
formatter = "";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
var mc = s_DateOrTimeRegex.Matches(regex);
|
||||||
|
date = mc[0].Groups[1].Value == "date";
|
||||||
|
formatter = mc[0].Groups[2].Value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static int GetTimestamp()
|
public static int GetTimestamp()
|
||||||
{
|
{
|
||||||
return (int)(DateTime.Now - k_DateTime1970).TotalSeconds;
|
return (int)(DateTime.Now - k_LocalDateTime1970).TotalSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetTimestamp(DateTime time)
|
public static int GetTimestamp(DateTime time, bool local = false)
|
||||||
{
|
{
|
||||||
return (int)(time - k_DateTime1970).TotalSeconds;
|
if (local)
|
||||||
|
{
|
||||||
|
return (int)(time - k_LocalDateTime1970).TotalSeconds;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (int)(time - k_DateTime1970).TotalSeconds;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetTimestamp(string dateTime)
|
public static int GetTimestamp(string dateTime, bool local = false)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return GetTimestamp(DateTime.Parse(dateTime));
|
|
||||||
|
return GetTimestamp(DateTime.Parse(dateTime), local);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -49,14 +83,9 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DateTime GetDateTime(double timestamp)
|
public static DateTime GetDateTime(double timestamp, bool local = true)
|
||||||
{
|
{
|
||||||
return k_DateTime1970.AddSeconds(timestamp);
|
return local ? k_LocalDateTime1970.AddSeconds(timestamp) : k_DateTime1970.AddSeconds(timestamp);
|
||||||
}
|
|
||||||
|
|
||||||
public static DateTime GetDateTime(int timestamp)
|
|
||||||
{
|
|
||||||
return k_DateTime1970.AddSeconds(timestamp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetDefaultDateTimeString(int timestamp, double range = 0)
|
public static string GetDefaultDateTimeString(int timestamp, double range = 0)
|
||||||
@@ -132,6 +161,7 @@ namespace XCharts.Runtime
|
|||||||
? (new DateTime(dtMin.Year, dtMin.Month, 1).AddMonths(1))
|
? (new DateTime(dtMin.Year, dtMin.Month, 1).AddMonths(1))
|
||||||
: (minTimestamp > firstValue ? DateTimeUtil.GetDateTime(secondValue) : DateTimeUtil.GetDateTime(firstValue));
|
: (minTimestamp > firstValue ? DateTimeUtil.GetDateTime(secondValue) : DateTimeUtil.GetDateTime(firstValue));
|
||||||
tick = num * 365 * 24 * 3600;
|
tick = num * 365 * 24 * 3600;
|
||||||
|
dtStart = new DateTime(dtStart.Year, dtStart.Month, 1);
|
||||||
while (dtStart.Ticks < dtMax.Ticks)
|
while (dtStart.Ticks < dtMax.Ticks)
|
||||||
{
|
{
|
||||||
list.Add(DateTimeUtil.GetTimestamp(dtStart));
|
list.Add(DateTimeUtil.GetTimestamp(dtStart));
|
||||||
@@ -144,6 +174,7 @@ namespace XCharts.Runtime
|
|||||||
var dtStart = (firstValue == 0 || secondValue == 0 || (minTimestamp > firstValue && minTimestamp > secondValue))
|
var dtStart = (firstValue == 0 || secondValue == 0 || (minTimestamp > firstValue && minTimestamp > secondValue))
|
||||||
? (new DateTime(dtMin.Year, dtMin.Month, 1).AddMonths(1))
|
? (new DateTime(dtMin.Year, dtMin.Month, 1).AddMonths(1))
|
||||||
: (minTimestamp > firstValue ? DateTimeUtil.GetDateTime(secondValue) : DateTimeUtil.GetDateTime(firstValue));
|
: (minTimestamp > firstValue ? DateTimeUtil.GetDateTime(secondValue) : DateTimeUtil.GetDateTime(firstValue));
|
||||||
|
dtStart = new DateTime(dtStart.Year, dtStart.Month, 1);
|
||||||
tick = num * 30 * 24 * 3600;
|
tick = num * 30 * 24 * 3600;
|
||||||
while (dtStart.Ticks < dtMax.Ticks)
|
while (dtStart.Ticks < dtMax.Ticks)
|
||||||
{
|
{
|
||||||
@@ -154,7 +185,8 @@ namespace XCharts.Runtime
|
|||||||
else if (range >= ONE_DAY * MIN_TIME_SPLIT_NUMBER)
|
else if (range >= ONE_DAY * MIN_TIME_SPLIT_NUMBER)
|
||||||
{
|
{
|
||||||
tick = GetTickSecond(range, splitNumber, ONE_DAY);
|
tick = GetTickSecond(range, splitNumber, ONE_DAY);
|
||||||
var startTimestamp = (minTimestamp - minTimestamp % tick) + tick;
|
var let = minTimestamp % tick;
|
||||||
|
var startTimestamp = let == 0 ? minTimestamp : (minTimestamp - let) + tick;
|
||||||
AddTickTimestamp(list, startTimestamp, maxTimestamp, tick);
|
AddTickTimestamp(list, startTimestamp, maxTimestamp, tick);
|
||||||
}
|
}
|
||||||
else if (range >= ONE_HOUR * MIN_TIME_SPLIT_NUMBER)
|
else if (range >= ONE_HOUR * MIN_TIME_SPLIT_NUMBER)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
using UnityEditor.Build;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace XCharts.Runtime
|
namespace XCharts.Runtime
|
||||||
@@ -16,6 +17,22 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
var flag = false;
|
var flag = false;
|
||||||
var num = 0;
|
var num = 0;
|
||||||
|
#if UNITY_2022_1_OR_NEWER
|
||||||
|
foreach (var buildTargetGroup in (BuildTargetGroup[]) Enum.GetValues(typeof(BuildTargetGroup)))
|
||||||
|
{
|
||||||
|
if (IsValidBuildTargetGroup(buildTargetGroup))
|
||||||
|
{
|
||||||
|
var buildTargetName = NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup);
|
||||||
|
var symbols = PlayerSettings.GetScriptingDefineSymbols(buildTargetName);
|
||||||
|
symbols = symbols.Replace(" ", "");
|
||||||
|
if (Array.IndexOf(symbols.Split(';'), symbol) != -1) continue;
|
||||||
|
flag = true;
|
||||||
|
num++;
|
||||||
|
var defines = symbols + (symbols.Length > 0 ? ";" + symbol : symbol);
|
||||||
|
PlayerSettings.SetScriptingDefineSymbols(buildTargetName, defines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
foreach (var buildTargetGroup in (BuildTargetGroup[]) Enum.GetValues(typeof(BuildTargetGroup)))
|
foreach (var buildTargetGroup in (BuildTargetGroup[]) Enum.GetValues(typeof(BuildTargetGroup)))
|
||||||
{
|
{
|
||||||
if (IsValidBuildTargetGroup(buildTargetGroup))
|
if (IsValidBuildTargetGroup(buildTargetGroup))
|
||||||
@@ -29,6 +46,7 @@ namespace XCharts.Runtime
|
|||||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, defines);
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, defines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
Debug.LogFormat("Added global define symbol \"{0}\" to {1} BuildTargetGroups.", symbol, num);
|
Debug.LogFormat("Added global define symbol \"{0}\" to {1} BuildTargetGroups.", symbol, num);
|
||||||
@@ -39,6 +57,29 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
var flag = false;
|
var flag = false;
|
||||||
var num = 0;
|
var num = 0;
|
||||||
|
#if UNITY_2022_1_OR_NEWER
|
||||||
|
foreach (var buildTargetGroup in (BuildTargetGroup[]) Enum.GetValues(typeof(BuildTargetGroup)))
|
||||||
|
{
|
||||||
|
if (IsValidBuildTargetGroup(buildTargetGroup))
|
||||||
|
{
|
||||||
|
var buildTargetName = NamedBuildTarget.FromBuildTargetGroup(buildTargetGroup);
|
||||||
|
var symbols = PlayerSettings.GetScriptingDefineSymbols(buildTargetName).Split(';');
|
||||||
|
if (Array.IndexOf(symbols, symbol) == -1) continue;
|
||||||
|
flag = true;
|
||||||
|
num++;
|
||||||
|
s_StringBuilder.Length = 0;
|
||||||
|
foreach (var str in symbols)
|
||||||
|
{
|
||||||
|
if (!str.Equals(symbol))
|
||||||
|
{
|
||||||
|
if (s_StringBuilder.Length > 0) s_StringBuilder.Append(";");
|
||||||
|
s_StringBuilder.Append(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlayerSettings.SetScriptingDefineSymbols(buildTargetName, s_StringBuilder.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
foreach (var buildTargetGroup in (BuildTargetGroup[]) Enum.GetValues(typeof(BuildTargetGroup)))
|
foreach (var buildTargetGroup in (BuildTargetGroup[]) Enum.GetValues(typeof(BuildTargetGroup)))
|
||||||
{
|
{
|
||||||
if (IsValidBuildTargetGroup(buildTargetGroup))
|
if (IsValidBuildTargetGroup(buildTargetGroup))
|
||||||
@@ -59,6 +100,7 @@ namespace XCharts.Runtime
|
|||||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, s_StringBuilder.ToString());
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, s_StringBuilder.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
Debug.LogFormat("Removed global define symbol \"{0}\" to {1} BuildTargetGroups.", symbol, num);
|
Debug.LogFormat("Removed global define symbol \"{0}\" to {1} BuildTargetGroups.", symbol, num);
|
||||||
|
|||||||
@@ -259,17 +259,27 @@ namespace XUGL
|
|||||||
/// <returns>相交则返回 true, 否则返回 false</returns>
|
/// <returns>相交则返回 true, 否则返回 false</returns>
|
||||||
public static bool GetIntersection(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, ref Vector3 intersection)
|
public static bool GetIntersection(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, ref Vector3 intersection)
|
||||||
{
|
{
|
||||||
var d = (p2.x - p1.x) * (p4.y - p3.y) - (p2.y - p1.y) * (p4.x - p3.x);
|
float dx1 = p2.x - p1.x;
|
||||||
if (d == 0)
|
float dy1 = p2.y - p1.y;
|
||||||
|
float dx2 = p4.x - p3.x;
|
||||||
|
float dy2 = p4.y - p3.y;
|
||||||
|
|
||||||
|
float d = dx1 * dy2 - dy1 * dx2;
|
||||||
|
if (Mathf.Abs(d) < 1e-6f)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var u = ((p3.x - p1.x) * (p4.y - p3.y) - (p3.y - p1.y) * (p4.x - p3.x)) / d;
|
float dx3 = p3.x - p1.x;
|
||||||
var v = ((p3.x - p1.x) * (p2.y - p1.y) - (p3.y - p1.y) * (p2.x - p1.x)) / d;
|
float dy3 = p3.y - p1.y;
|
||||||
if (u < 0 || u > 1 || v < 0 || v > 1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
intersection.x = p1.x + u * (p2.x - p1.x);
|
float u = (dx3 * dy2 - dy3 * dx2) / d;
|
||||||
intersection.y = p1.y + u * (p2.y - p1.y);
|
if (u < 0 || u > 1) return false;
|
||||||
|
|
||||||
|
float v = (dx3 * dy1 - dy3 * dx1) / d;
|
||||||
|
if (v < 0 || v > 1) return false;
|
||||||
|
|
||||||
|
intersection.x = p1.x + u * dx1;
|
||||||
|
intersection.y = p1.y + u * dy1;
|
||||||
|
intersection.z = p1.z;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,40 +347,93 @@ namespace XUGL
|
|||||||
clp = cp - dir2v;
|
clp = cp - dir2v;
|
||||||
crp = cp + dir2v;
|
crp = cp + dir2v;
|
||||||
|
|
||||||
if (Vector3.Cross(dir1, dir2) == Vector3.zero && np != cp)
|
float crossMagnitude = Vector3.Cross(dir1, dir2).sqrMagnitude;
|
||||||
|
if (crossMagnitude < 1e-6f && np != cp)
|
||||||
{
|
{
|
||||||
itp = clp;
|
itp = clp;
|
||||||
ibp = crp;
|
ibp = crp;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ldist = (Vector3.Distance(cp, lp) + 1) * dir1;
|
var ldist = (Vector3.Distance(cp, lp) + width) * dir1;
|
||||||
var rdist = (Vector3.Distance(cp, np) + 1) * dir2;
|
var rdist = (Vector3.Distance(cp, np) + width) * dir2;
|
||||||
|
|
||||||
bitp = true;
|
bitp = UGLHelper.GetIntersection(ltp, ltp + ldist, ntp, ntp + rdist, ref itp);
|
||||||
if (!UGLHelper.GetIntersection(ltp, ltp + ldist, ntp, ntp + rdist, ref itp))
|
bibp = UGLHelper.GetIntersection(lbp, lbp + ldist, nbp, nbp + rdist, ref ibp);
|
||||||
|
if (bitp == bibp)
|
||||||
{
|
{
|
||||||
itp = cp - dir1v;
|
if (!bitp)
|
||||||
clp = cp - dir1v;
|
{
|
||||||
crp = cp - dir2v;
|
if (cp == np)
|
||||||
bitp = false;
|
{
|
||||||
|
ltp = cp - dir1v;
|
||||||
|
clp = cp + dir1v;
|
||||||
|
crp = cp + dir1v;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Vector3 ibp2 = Vector3.zero;
|
||||||
|
if (UGLHelper.GetIntersection(lbp, lbp + ldist, ntp, nbp, ref ibp2))
|
||||||
|
{
|
||||||
|
bibp = true;
|
||||||
|
ibp = ibp2;
|
||||||
|
clp = cp - dir1v;
|
||||||
|
crp = cp - dir2v;
|
||||||
|
}
|
||||||
|
else if (UGLHelper.GetIntersection(ltp, ltp + ldist, nbp, ntp, ref ibp2))
|
||||||
|
{
|
||||||
|
bitp = true;
|
||||||
|
itp = ibp2;
|
||||||
|
clp = cp + dir1v;
|
||||||
|
crp = cp + dir2v;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (IsUp(lp, cp, np))
|
||||||
|
{
|
||||||
|
bibp = true;
|
||||||
|
|
||||||
|
clp = cp - dir1v;
|
||||||
|
crp = cp - dir2v;
|
||||||
|
ibp = cp - Vector3.Cross((crp - clp).normalized, Vector3.back).normalized * width * 2f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bitp = true;
|
||||||
|
clp = cp + dir1v;
|
||||||
|
crp = cp + dir2v;
|
||||||
|
itp = cp + Vector3.Cross((crp - clp).normalized, Vector3.back).normalized * width * 2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bibp = true;
|
else
|
||||||
if (!UGLHelper.GetIntersection(lbp, lbp + ldist, nbp, nbp + rdist, ref ibp))
|
|
||||||
{
|
{
|
||||||
ibp = cp + dir1v;
|
if (!bitp)
|
||||||
clp = cp + dir1v;
|
{
|
||||||
crp = cp + dir2v;
|
itp = cp;
|
||||||
bibp = false;
|
clp = cp - dir1v;
|
||||||
}
|
crp = cp - dir2v;
|
||||||
if (bitp == false && bibp == false && cp == np)
|
}
|
||||||
{
|
else
|
||||||
ltp = cp - dir1v;
|
{
|
||||||
clp = cp + dir1v;
|
ibp = cp;
|
||||||
crp = cp + dir1v;
|
clp = cp + dir1v;
|
||||||
|
crp = cp + dir2v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsUp(Vector3 p1, Vector3 p2, Vector3 p3)
|
||||||
|
{
|
||||||
|
var v1 = p1 - p2;
|
||||||
|
var v2 = p3 - p2;
|
||||||
|
var cross = v1.x * v2.y - v1.y * v2.x;
|
||||||
|
return cross > 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsPointInTriangle(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 check)
|
public static bool IsPointInTriangle(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 check)
|
||||||
{
|
{
|
||||||
var dire1 = check - p1;
|
var dire1 = check - p1;
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
"displayName": "XCharts",
|
"displayName": "XCharts",
|
||||||
"author": "monitor1394",
|
"author": "monitor1394",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "3.11.2",
|
"version": "3.13.0",
|
||||||
"date": "20240801",
|
"date": "20250101",
|
||||||
"checkdate": "20240801",
|
"checkdate": "20250101",
|
||||||
"unity": "2018.3",
|
"unity": "2018.3",
|
||||||
"description": "A charting and data visualization library for Unity. Support line chart, bar chart, pie chart, radar chart, scatter chart, heatmap chart, ring chart, candlestick chart, polar chart and parallel coordinates.",
|
"description": "A charting and data visualization library for Unity. Support line chart, bar chart, pie chart, radar chart, scatter chart, heatmap chart, ring chart, candlestick chart, polar chart and parallel coordinates.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
Reference in New Issue
Block a user