XCharts 2.0

This commit is contained in:
monitor1394
2021-01-17 10:16:30 +08:00
parent ee4aae2019
commit f5c76ce3c5
10 changed files with 42 additions and 65 deletions

View File

@@ -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"/>
![linechart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-line.png)
![barchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-bar.png)
![piechart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-pie.png)
![radarchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-radar.png)
![scatterchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-scatter.png)
![heatmapchart](https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-heatmap.png)
## Cheat Sheet
<img src="https://github.com/monitor1394/unity-ugui-XCharts/blob/master/Doc/screenshot/xcharts-cheatsheet.gif" />
![cheatsheet](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.

View File

@@ -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)
{

View File

@@ -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);
}

View File

@@ -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
{

View File

@@ -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()

View File

@@ -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);

View File

@@ -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()
{

View File

@@ -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

View File

@@ -5,9 +5,7 @@
/* */
/************************************************/
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace XChartsDemo

View File

@@ -45,16 +45,16 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
## 截图
![xcharts-line](Doc/screenshot/xcharts-line.png)
![xcharts-bar](Doc/screenshot/xcharts-bar.png)
![xcharts-pie](Doc/screenshot/xcharts-pie.png)
![xcharts-radar](Doc/screenshot/xcharts-radar.png)
![xcharts-scatter](Doc/screenshot/xcharts-scatter.png)
![xcharts-heatmap](Doc/screenshot/xcharts-heatmap.png)
![linechart](Doc/screenshot/xcharts-line.png)
![barchart](Doc/screenshot/xcharts-bar.png)
![piechart](Doc/screenshot/xcharts-pie.png)
![radarchart](Doc/screenshot/xcharts-radar.png)
![scatterchart](Doc/screenshot/xcharts-scatter.png)
![heatmapchart](Doc/screenshot/xcharts-heatmap.png)
## 术语
![xcharts-cheatsheet](Doc/screenshot/xcharts-cheatsheet.gif)
![cheatsheet](Doc/screenshot/xcharts-cheatsheet.gif)
XCharts的图表由组件和数据组成。不同的组件和数据可以组合成不同类型的图表。组件分为主组件和子组件主组件包含子组件。
@@ -168,6 +168,6 @@ VIP群XCharts技术支持VIP群`867291970`
企业赞助请备注公司名称。
![xcharts-alipay](Doc/alipay.png)
![alipay](Doc/alipay.png)
如需商业技术支持捐助280¥可加VIP群`867291970`,验证信息请输入捐助的支付宝账号)。