XCharts 2.0

This commit is contained in:
monitor1394
2021-01-12 13:11:15 +08:00
parent d9724ee7f3
commit d36a9fda9d
6 changed files with 912 additions and 686 deletions

View File

@@ -17,12 +17,21 @@ public class ChartEditorHelper
public const float ARROW_WIDTH = 13; public const float ARROW_WIDTH = 13;
public const float GAP_WIDTH = 0; public const float GAP_WIDTH = 0;
#endif #endif
public static GUIStyle headerStyle = EditorStyles.boldLabel;
public static GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout) private class Styles
{ {
font = headerStyle.font, public static readonly GUIStyle headerStyle = EditorStyles.boldLabel;
fontStyle = headerStyle.fontStyle, public static readonly GUIStyle foldoutStyle = new GUIStyle(EditorStyles.foldout)
}; {
font = headerStyle.font,
fontStyle = headerStyle.fontStyle,
};
public static readonly GUIContent iconAdd = EditorGUIUtility.TrIconContent("Toolbar Plus", "Add");
public static readonly GUIContent iconRemove = EditorGUIUtility.TrIconContent("Toolbar Minus", "Remove");
public static readonly GUIContent iconUp = new GUIContent("↑", "Up");
public static readonly GUIContent iconDown = new GUIContent("↓", "Down");
public static readonly GUIStyle invisibleButton = "InvisibleButton";
}
public static void SecondField(Rect drawRect, SerializedProperty prop) public static void SecondField(Rect drawRect, SerializedProperty prop)
{ {
@@ -126,7 +135,7 @@ public class ChartEditorHelper
float defaultWidth = drawRect.width; float defaultWidth = drawRect.width;
float defaultX = drawRect.x; float defaultX = drawRect.x;
drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH; drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH;
moduleToggle = EditorGUI.Foldout(drawRect, moduleToggle, content, bold ? foldoutStyle : EditorStyles.foldout); moduleToggle = EditorGUI.Foldout(drawRect, moduleToggle, content, bold ? Styles.foldoutStyle : EditorStyles.foldout);
MakeBool(drawRect, prop); MakeBool(drawRect, prop);
drawRect.width = defaultWidth; drawRect.width = defaultWidth;
drawRect.x = defaultX; drawRect.x = defaultX;
@@ -139,7 +148,7 @@ public class ChartEditorHelper
float defaultWidth = drawRect.width; float defaultWidth = drawRect.width;
float defaultX = drawRect.x; float defaultX = drawRect.x;
drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH; drawRect.width = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH;
moduleToggle[key] = EditorGUI.Foldout(drawRect, moduleToggle[key], content, bold ? foldoutStyle : EditorStyles.foldout); moduleToggle[key] = EditorGUI.Foldout(drawRect, moduleToggle[key], content, bold ? Styles.foldoutStyle : EditorStyles.foldout);
if (prop != null) if (prop != null)
{ {
if (prop.propertyType == SerializedPropertyType.Boolean) if (prop.propertyType == SerializedPropertyType.Boolean)
@@ -218,7 +227,7 @@ public class ChartEditorHelper
drawRect.width = EditorGUIUtility.labelWidth; drawRect.width = EditorGUIUtility.labelWidth;
#endif #endif
var displayName = string.IsNullOrEmpty(moduleName) ? prop.displayName : moduleName; var displayName = string.IsNullOrEmpty(moduleName) ? prop.displayName : moduleName;
toggle = EditorGUI.Foldout(drawRect, toggle, displayName, bold ? foldoutStyle : EditorStyles.foldout); toggle = EditorGUI.Foldout(drawRect, toggle, displayName, bold ? Styles.foldoutStyle : EditorStyles.foldout);
if (moduleToggle[key] != toggle) if (moduleToggle[key] != toggle)
{ {
@@ -268,7 +277,7 @@ public class ChartEditorHelper
{ {
iconRect.x += BLOCK_WIDTH; iconRect.x += BLOCK_WIDTH;
} }
if (GUI.Button(iconRect, new GUIContent("+", "add"))) if (GUI.Button(iconRect, Styles.iconAdd, Styles.invisibleButton))
{ {
if (listProp.displayName.Equals("Series")) if (listProp.displayName.Equals("Series"))
{ {
@@ -336,7 +345,7 @@ public class ChartEditorHelper
{ {
iconRect.x += BLOCK_WIDTH; iconRect.x += BLOCK_WIDTH;
} }
if (GUI.Button(iconRect, new GUIContent("↑", "up"))) if (GUI.Button(iconRect, Styles.iconUp, Styles.invisibleButton))
{ {
if (i > 0) listProp.MoveArrayElement(i, i - 1); if (i > 0) listProp.MoveArrayElement(i, i - 1);
} }
@@ -345,7 +354,7 @@ public class ChartEditorHelper
{ {
iconRect.x += BLOCK_WIDTH; iconRect.x += BLOCK_WIDTH;
} }
if (GUI.Button(iconRect, new GUIContent("↓", "down"))) if (GUI.Button(iconRect, Styles.iconDown, Styles.invisibleButton))
{ {
if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1); if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1);
} }
@@ -354,7 +363,7 @@ public class ChartEditorHelper
{ {
iconRect.x += BLOCK_WIDTH; iconRect.x += BLOCK_WIDTH;
} }
if (GUI.Button(iconRect, new GUIContent("-", "delete"))) if (GUI.Button(iconRect, Styles.iconRemove, Styles.invisibleButton))
{ {
if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i); if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i);
} }
@@ -385,7 +394,7 @@ public class ChartEditorHelper
{ {
EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal();
listSize = EditorGUILayout.IntField("Size", listSize); listSize = EditorGUILayout.IntField("Size", listSize);
if (GUILayout.Button(new GUIContent("+", "add"), GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) if (GUILayout.Button(Styles.iconAdd, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15)))
{ {
listProp.arraySize++; listProp.arraySize++;
} }
@@ -428,15 +437,15 @@ public class ChartEditorHelper
{ {
EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(element, true); EditorGUILayout.PropertyField(element, true);
if (GUILayout.Button(new GUIContent("↑", "up"), GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) if (GUILayout.Button(Styles.iconUp, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15)))
{ {
if (i > 0) listProp.MoveArrayElement(i, i - 1); if (i > 0) listProp.MoveArrayElement(i, i - 1);
} }
if (GUILayout.Button(new GUIContent("↓", "down"), GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) if (GUILayout.Button(Styles.iconDown, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15)))
{ {
if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1); if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1);
} }
if (GUILayout.Button(new GUIContent("-", "delete"), GUILayout.MinWidth(15), GUILayout.MaxWidth(15))) if (GUILayout.Button(Styles.iconRemove, Styles.invisibleButton, GUILayout.MinWidth(15), GUILayout.MaxWidth(15)))
{ {
if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i); if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i);
} }

View File

@@ -30,8 +30,8 @@ namespace XCharts.Examples
var pos = dataPoints[3]; var pos = dataPoints[3];
var zeroPos = new Vector3(chart.grid.runtimeX, chart.grid.runtimeY); var zeroPos = new Vector3(chart.grid.runtimeX, chart.grid.runtimeY);
var startPos = new Vector3(pos.x, zeroPos.y); var startPos = new Vector3(pos.x, zeroPos.y);
var endPos = new Vector3(pos.x, zeroPos.y + chart.grid.runtimeWidth); var endPos = new Vector3(pos.x, zeroPos.y + chart.grid.runtimeHeight);
UGL.DrawLine(vh, startPos, endPos, 1, Color.blue); UGL.DrawLine(vh, startPos, endPos, chart.theme.serie.lineWidth, Color.blue);
UGL.DrawCricle(vh, pos, 5, Color.blue); UGL.DrawCricle(vh, pos, 5, Color.blue);
} }
}; };

View File

@@ -5,17 +5,16 @@
[![downloads per month](http://img.shields.io/npm/dm/unity-ugui-xcharts.svg)](https://www.npmjs.org/package/unity-ugui-xcharts) [![downloads per month](http://img.shields.io/npm/dm/unity-ugui-xcharts.svg)](https://www.npmjs.org/package/unity-ugui-xcharts)
![qq](https://img.shields.io/badge/QQ群-202030963-green) ![qq](https://img.shields.io/badge/QQ群-202030963-green)
--- ## XCharts 2.0
__XCharts 2.0 is comming soon!__ * Framework reconstruction, layered rendering, optimized scalability, support more data.
* Support for TextMeshPro.
* Framework reconstruction, layered rendering, support more data * Support for multi-component patterns.
* Support TextMeshPro * Support for any combination of most charts.
* Support multi-chart, multi-component mode * Support theme customization, import and export, and more theme configuration parameters.
* A friendlier editing interface * Support global adjustment of configuration parameters.
* More … * Better editing interface.
* Other details optimized.
---
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. 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.
@@ -127,7 +126,7 @@ The following is the relationship structure of LineChart:
* Download the source code or `unitypackage` to import into your project. If `Unity` version are `2018.3` or above, it is recommended to import packages through `Package Manager`: * Download the source code or `unitypackage` to import into your project. If `Unity` version are `2018.3` or above, it is recommended to import packages through `Package Manager`:
1. Open the `manifest.json` file under `Packages` directory and add under `dependencies`: 1. Open the `manifest.json` file under `Packages` directory and add under `dependencies`:
``` json ``` json
"com.monitor1394.xcharts": "https://github.com/monitor1394/unity-ugui-XCharts.git#package", "com.monitor1394.xcharts": "https://github.com/monitor1394/unity-ugui-XCharts.git#upm",
``` ```
2. Going back to `Unity`, it may take 3 to 5 minutes to download. 2. Going back to `Unity`, it may take 3 to 5 minutes to download.
3. If you want to delete `XCharts`, just delete the content added in step 1. 3. If you want to delete `XCharts`, just delete the content added in step 1.

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,7 @@ If your project use `Unity 2018.3` or above, your can import `XCharts` by `Packa
1. Open the `mamnifest.json` file in `Packages` directory, and add: 1. Open the `mamnifest.json` file in `Packages` directory, and add:
``` json ``` json
"com.monitor1394.xcharts": "https://github.com/monitor1394/unity-ugui-XCharts.git#package", "com.monitor1394.xcharts": "https://github.com/monitor1394/unity-ugui-XCharts.git#upm",
``` ```
2. Switch to `Unity`, It may take 3 to 5 minutes to download and compile, and once successful you can start using `XCharts`. 2. Switch to `Unity`, It may take 3 to 5 minutes to download and compile, and once successful you can start using `XCharts`.
3. If you want to delete `XCharts`, undo step 1. 3. If you want to delete `XCharts`, undo step 1.

View File

@@ -9,8 +9,6 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
[English Documents](Assets/XCharts/README.md) [English Documents](Assets/XCharts/README.md)
---
## XCharts 2.0 ## XCharts 2.0
* 底层重构,分层绘制,优化可扩展性,支持更多数据。 * 底层重构,分层绘制,优化可扩展性,支持更多数据。
@@ -22,8 +20,6 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
* 更友好的编辑界面。 * 更友好的编辑界面。
* 其他细节优化。 * 其他细节优化。
---
一款基于`UGUI`的功能强大、易用、参数可配置的数据可视化图表插件。支持折线图、柱状图、饼图、雷达图、散点图、热力图、仪表盘、环形图、极坐标、水位图等常见图表。 一款基于`UGUI`的功能强大、易用、参数可配置的数据可视化图表插件。支持折线图、柱状图、饼图、雷达图、散点图、热力图、仪表盘、环形图、极坐标、水位图等常见图表。
[XCharts问答](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts问答.md) [XCharts问答](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Assets/XCharts/Documentation/XCharts问答.md)