mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 14:00:12 +00:00
XCharts 2.0
This commit is contained in:
@@ -41,16 +41,16 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
|
||||
|
||||
## Screenshot
|
||||
|
||||
<img src="https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-line.png" width="550" height="auto"/>
|
||||
<img src="https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-bar.png" width="550" height="auto"/>
|
||||
<img src="https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-pie.png" width="550" height="auto"/>
|
||||
<img src="https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-radar.png" width="550" height="auto"/>
|
||||
<img src="https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-scatter.png" width="550" height="auto"/>
|
||||
<img src="https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-heatmap.png" width="550" height="auto"/>
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## Cheat Sheet
|
||||
|
||||
<img src="https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-cheatsheet.gif" />
|
||||

|
||||
|
||||
`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.
|
||||
|
||||
|
||||
@@ -308,24 +308,19 @@ namespace XCharts
|
||||
base.InitPainter();
|
||||
m_PainterList.Clear();
|
||||
if (settings == null) return;
|
||||
var sizeDelta = new Vector2(m_GraphWidth, m_GraphHeight);
|
||||
for (int i = 0; i < settings.maxPainter; i++)
|
||||
{
|
||||
var painterObj = ChartHelper.AddObject("painter_" + i, transform, m_GraphMinAnchor, m_GraphMaxAnchor,
|
||||
m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight));
|
||||
painterObj.hideFlags = chartHideFlags;
|
||||
painterObj.transform.SetSiblingIndex(2 + i);
|
||||
var painter = ChartHelper.GetOrAddComponent<Painter>(painterObj);
|
||||
var painter = ChartHelper.AddPainterObject("painter_" + i, transform, m_GraphMinAnchor,
|
||||
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + i);
|
||||
painter.index = m_PainterList.Count;
|
||||
painter.type = Painter.Type.Serie;
|
||||
painter.onPopulateMesh = OnDrawPainterSerie;
|
||||
painter.SetActive(false, m_DebugMode);
|
||||
m_PainterList.Add(painter);
|
||||
}
|
||||
var painterTopObj = ChartHelper.AddObject("painter_t", transform, m_GraphMinAnchor, m_GraphMaxAnchor,
|
||||
m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight));
|
||||
painterTopObj.hideFlags = chartHideFlags;
|
||||
painterTopObj.transform.SetSiblingIndex(2 + settings.maxPainter);
|
||||
m_PainterTop = ChartHelper.GetOrAddComponent<Painter>(painterTopObj);
|
||||
m_PainterTop = ChartHelper.AddPainterObject("painter_t", transform, m_GraphMinAnchor,
|
||||
m_GraphMaxAnchor, m_GraphPivot, sizeDelta, chartHideFlags, 2 + settings.maxPainter);
|
||||
m_PainterTop.type = Painter.Type.Top;
|
||||
m_PainterTop.onPopulateMesh = OnDrawPainterTop;
|
||||
m_PainterTop.SetActive(true, m_DebugMode);
|
||||
@@ -684,8 +679,6 @@ namespace XCharts
|
||||
m_Painter.Refresh();
|
||||
foreach (var painter in m_PainterList) painter.Refresh();
|
||||
m_PainterTop.Refresh();
|
||||
//SetAllDirty();
|
||||
//SetVerticesDirty();
|
||||
m_RefreshChart = false;
|
||||
}
|
||||
}
|
||||
@@ -826,7 +819,6 @@ namespace XCharts
|
||||
|
||||
protected override void OnDrawPainterBase(VertexHelper vh, Painter painter)
|
||||
{
|
||||
//Debug.LogError("OnDrawPainterBase:" + Time.frameCount + "," + painter.name);
|
||||
vh.Clear();
|
||||
DrawBackground(vh);
|
||||
DrawPainterBase(vh);
|
||||
@@ -835,7 +827,6 @@ namespace XCharts
|
||||
|
||||
protected virtual void OnDrawPainterSerie(VertexHelper vh, Painter painter)
|
||||
{
|
||||
//Debug.LogError("OnDrawPainterSerie:" + Time.frameCount + "," + painter.name);
|
||||
vh.Clear();
|
||||
var maxPainter = settings.maxPainter;
|
||||
var maxSeries = m_Series.Count;
|
||||
@@ -851,7 +842,6 @@ namespace XCharts
|
||||
|
||||
protected virtual void OnDrawPainterTop(VertexHelper vh, Painter painter)
|
||||
{
|
||||
//Debug.LogError("OnDrawPainterTop:" + Time.frameCount + "," + painter.name);
|
||||
vh.Clear();
|
||||
if (m_OnCustomDrawCallback != null)
|
||||
{
|
||||
|
||||
@@ -219,11 +219,8 @@ namespace XCharts
|
||||
|
||||
protected virtual void InitPainter()
|
||||
{
|
||||
var painterObj = ChartHelper.AddObject("painter_b", transform, m_GraphMinAnchor, m_GraphMaxAnchor,
|
||||
m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight));
|
||||
painterObj.transform.SetSiblingIndex(1);
|
||||
painterObj.hideFlags = chartHideFlags;
|
||||
m_Painter = ChartHelper.GetOrAddComponent<Painter>(painterObj);
|
||||
m_Painter = ChartHelper.AddPainterObject("painter_b", transform, m_GraphMinAnchor,
|
||||
m_GraphMaxAnchor, m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight), chartHideFlags, 1);
|
||||
m_Painter.type = Painter.Type.Base;
|
||||
m_Painter.onPopulateMesh = OnDrawPainterBase;
|
||||
}
|
||||
@@ -339,7 +336,6 @@ namespace XCharts
|
||||
|
||||
protected virtual void OnDrawPainterBase(VertexHelper vh, Painter painter)
|
||||
{
|
||||
Debug.LogError("OnDrawPainterBase:" + Time.frameCount + "," + painter.name);
|
||||
DrawBackground(vh);
|
||||
DrawPainterBase(vh);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
@@ -38,12 +37,10 @@ namespace XCharts
|
||||
{
|
||||
if (visualMap.enable && (visualMap.min != min || visualMap.max != max))
|
||||
{
|
||||
//Debug.LogError("minmax:"+min+","+max);
|
||||
if (max >= min)
|
||||
{
|
||||
visualMap.min = min;
|
||||
visualMap.max = max;
|
||||
//Debug.LogError("minmax2222:"+visualMap.min+","+visualMap.max);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -11,7 +11,8 @@ using System;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public partial class Painter : MaskableGraphic
|
||||
[RequireComponent(typeof(CanvasRenderer))]
|
||||
public class Painter : MaskableGraphic
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
@@ -32,7 +33,6 @@ namespace XCharts
|
||||
if (gameObject == null) return;
|
||||
if (!gameObject.activeSelf) return;
|
||||
m_Refresh = true;
|
||||
//Debug.LogError("refresh painter:"+name);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
|
||||
@@ -365,6 +365,15 @@ namespace XCharts
|
||||
return tooltipObj;
|
||||
}
|
||||
|
||||
internal static Painter AddPainterObject(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax,
|
||||
Vector2 pivot, Vector2 sizeDelta, HideFlags hideFlags, int siblingIndex)
|
||||
{
|
||||
var painterObj = ChartHelper.AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
||||
painterObj.hideFlags = hideFlags;
|
||||
painterObj.transform.SetSiblingIndex(siblingIndex);
|
||||
return ChartHelper.GetOrAddComponent<Painter>(painterObj);
|
||||
}
|
||||
|
||||
public static GameObject AddIcon(string name, Transform parent, float width, float height)
|
||||
{
|
||||
var anchorMax = new Vector2(0.5f, 0.5f);
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace XCharts
|
||||
|
||||
private void CheckVersionWebRequest(UnityWebRequest web)
|
||||
{
|
||||
if (IsNetworkError(web))
|
||||
if (IsWebRequestError(web))
|
||||
{
|
||||
isNetworkError = true;
|
||||
networkError = web.error;
|
||||
@@ -240,29 +240,18 @@ namespace XCharts
|
||||
changeLog = sb.ToString();
|
||||
}
|
||||
|
||||
#if UNITY_5 || UNITY_2017_1
|
||||
public bool IsNetworkError(UnityWebRequest request)
|
||||
public bool IsWebRequestError(UnityWebRequest request)
|
||||
{
|
||||
return request.isError && !IsHttpError(request);
|
||||
}
|
||||
#else
|
||||
public bool IsNetworkError(UnityWebRequest request)
|
||||
{
|
||||
return request.isNetworkError;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_5
|
||||
public bool IsHttpError(UnityWebRequest request)
|
||||
{
|
||||
return request.responseCode >= 400;
|
||||
}
|
||||
return request.isError && ! request.responseCode >= 400;
|
||||
#elif UNITY_2017_1
|
||||
return request.isError && ! request.isHttpError;
|
||||
#elif UNITY_2020_2
|
||||
return (int)request.result > 1;
|
||||
#else
|
||||
public bool IsHttpError(UnityWebRequest request)
|
||||
{
|
||||
return request.isHttpError;
|
||||
}
|
||||
return request.isNetworkError;
|
||||
#endif
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace XCharts
|
||||
AssetDatabase.importPackageCompleted += ImportCallback;
|
||||
|
||||
string packageFullPath = GetPackageFullPath();
|
||||
Debug.LogError("packageFullPath:" + packageFullPath);
|
||||
AssetDatabase.ImportPackage(packageFullPath + "/Package Resources/XCharts Essential Resources.unitypackage", false);
|
||||
}
|
||||
GUILayout.Space(5f);
|
||||
@@ -110,7 +109,6 @@ namespace XCharts
|
||||
}
|
||||
|
||||
packagePath = Path.GetFullPath("Assets/..");
|
||||
Debug.LogError("packagePath:" + packagePath + ":" + Directory.Exists(packagePath));
|
||||
if (Directory.Exists(packagePath))
|
||||
{
|
||||
// Search default location for development package
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XChartsDemo
|
||||
|
||||
16
README.md
16
README.md
@@ -45,16 +45,16 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
|
||||
|
||||
## 截图
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
## 术语
|
||||
|
||||

|
||||

|
||||
|
||||
XCharts的图表由组件和数据组成。不同的组件和数据可以组合成不同类型的图表。组件分为主组件和子组件,主组件包含子组件。
|
||||
|
||||
@@ -168,6 +168,6 @@ VIP群:XCharts技术支持VIP群(`867291970`)
|
||||
|
||||
企业赞助请备注公司名称。
|
||||
|
||||

|
||||

|
||||
|
||||
如需商业技术支持,捐助280¥可加VIP群(`867291970`,验证信息请输入捐助的支付宝账号)。
|
||||
|
||||
Reference in New Issue
Block a user