修复因XChartsMgr不存在,而创建新对象时导致的死循环问题。 由于Awake会在组件被创建时同步执行一次,而在执行Awake时m_XCharts并没有被赋值,所以导致死循环。 让对象处于关闭状态,添加组件时就不会同步执行Awake方法,而是延迟到下一次开启对象时执行。 在下一次开启对象时,m_XCharts已经被赋值,所以不会导致死循环问题。 死循环发生在Awake时调用XThemeMgr.ReloadThemeList,而ReloadThemeList方法中有调用了实例。
XCharts
A powerful, easy-to-use, configurable charting and data visualization library for Unity.
一款基于UGUI的数据可视化图表插件。
A powerful, easy-to-use, configurable charting and data visualization library for Unity. Supporting line, bar, pie, radar, scatter, heatmap, gauge, ring, polar, liquid and other common chart.
XCharts Homepage
XCharts Q&A
XCharts API
XCharts Configuration
XCharts Changelog
Tutorial - Get start with XCharts in 5 minute
XCharts 2.0
- Underlevel reconstruction, layered rendering, optimized scalability, support more data.
- Support for multi-component patterns.
- Support for any combination of most charts.
- Support theme customization, import and export, and more theme configuration parameters.
- Support global adjustment of configuration parameters.
- Added support for
TextMeshPro. - Added
CandlestickChart. - __ Note:__
2.0has undergone a lot of refactoring and adjustments and is not fully compatible with version1.0, so1.0should not be directly upgraded to2.0. Some parameter Settings may be reset to default values after upgrading.
Features
- Rich built-in examples and templates, parameter visualization configuration, effect real-time preview, pure code drawing.
- Support line, bar, pie, radar, scatter, heatmaps, gauge, ring, polar, liquid and other common chart.
- Support line graph, curve graph, area graph, step graph and other LineChart.
- Support parallel bar, stack bar, stack percentage bar, zebra bar and other BarChart.
- Support ring, rose and other PieChart.
- Support line-bar chart, scatter-line chart and other combination chart.
- Support solid line, curve, ladder line, dotted line, dash line, dot line, double dot line and other lines.
- Support custom theme, built-in theme switching.
- Support custom chart content drawing, drawing points, line, curve, triangle, quadrilateral, circle, ring, sector, border, arrow and other drawing API.
- Support interactive operations such as data filtering, view zooming and detail display on PC and mobile terminals.
- Support 10,000-level big data rendering.
Screenshot
Cheat Sheet
XCharts consist of components and data. Different components and data can be combined into different types of charts. The component is divided into main component and sub component. The main component contains the sub components.
XCharts main components:
Themetheme component, which can configure the default colors, fonts and so on.Titletitle component, which contains the main title and subtitle.Legendlegend component, which represent different sets of symbols, colors, and names. You can control which series are not displayed by clicking on the legend.Gridgrid component, drawing grid in rectangular coordinate system. Up to two X axes and two Y axes can be placed within a grid component. You can draw line, bar and scatter chart on the grid.Axisaxis component, the axis of a rectangular coordinate system. Supports the upper and lower X axes and the left and right Y axes.Seriesseries component, a list of serie. A chart can contain many different series, and each series determines its own chart type by type.Tooltiptooltip component, feedback more details of the data indicated by the mouse at the time.DataZoomdata zoom component, used for area zooming so you can focus on detailed data information, or overview the data as a whole, or remove the impact of outliers.VisualMapvisual mapping component, you can map data in different colors.Radarradar component, suitable for radar chart only.Settingsglobal Settings component, Some global parameters can be adjusted. Use the default values in general and adjust them as needed.
XCharts support chart:
LineChartBarChartPieChartRadarChartScatterChartHeatmapChartGuageChartRingChartPolarChartLiquidChart
The following is the relationship structure of LineChart:
.
├── LineChart
. ├── ThemeInfo
├── Title
│ └── Location
├── Legend
│ └── Location
├── Tooltip
├── DataZoom
├── VisualMap
├── Grid
├── Axis
│ ├── AxisLine
│ ├── AxisName
│ ├── AxisLabel
│ ├── AxisTick
│ └── AxisSplitArea
├── Series
│ ├── ItemStyle
│ ├── AreaStyle
│ ├── SerieSymbol
│ ├── LineStyle
│ ├── LineArrow
│ ├── SerieLabel
│ ├── Emphasis
│ ├── Animation
│ └── SerieData
└── Settings
Environment
- Unity2017.4.27f1
- .Net 3.5
- macOS 10.15.4
Usage
-
This project was developed under
Unity 2017.4.27f1and.net 3.5, tested normally onUnity 5,Unity 2018andUnity 2019. It can theoretically run on any version that supportsUGUI. -
Download the source code or
unitypackageto import into your project. IfUnityversion are2018.3or above, it is recommended to import packages throughPackage Manager:- Open the
manifest.jsonfile underPackagesdirectory and add underdependencies:
"com.monitor1394.xcharts": "https://github.com/monitor1394/unity-ugui-XCharts.git#2.0-upm",- Going back to
Unity, it may take 3 to 5 minutes to download. - If you want to delete
XCharts, just delete the content added in step 1. - If you want to update
XCharts, openmanifest.jsonfile , delete the content aboutcom.monitor1394.xchartsunderlock, it will download anagain. Also can check For update incomponents-> XCharts -> Check For Update.
- Open the
-
Add a chart in Editor quickly:
- In
Hierarchy, right-click menuXChart->LineChart. - In unity menu bar,
Component->XCharts->LineChart. - In
Inspector,Add Component->LineChart. - Then a simple line chart is done.
- In
Inspectoryou can adjust the parameters of components, and inGamewill feedback the adjustment effect in realtime 。the detail of parameters go to see: XCharts Configuration.
- In
-
See more examples of code dynamic control: Tutorial - Get start with XCharts in 5 minute.
-
Enable TextMeshPro:
XCharts -> TextMeshPro EnableorProject Setting -> XCharts -> Enable TextMeshProProject Setting -> XCharts -> Settings -> TMP Fontset the TextMeshPro font.- If the chart does not initialize properly, you can use the
Remove All Chart Objectbutton to clean up the chart and reinitialize it.
Documents
- XCharts Homepage
- XCharts Q&A
- XCharts API
- XCharts Configuration
- XCharts Changelog
- XCharts Tutorial: Get start with XCharts in 5 minute
Changelog
Licenses
Contact
gmail: monitor1394@gmail.com











