增加JsonUtil工具类

This commit is contained in:
monitor1394
2024-05-09 13:13:51 +08:00
parent b86cae6717
commit 4e3182edfc
10 changed files with 161 additions and 24 deletions

View File

@@ -447,16 +447,16 @@ namespace XCharts.Runtime
/// ||添加一个关系图的关系数据。
/// </summary>
/// <param name="serieIndex">the index of serie</param>
/// <param name="sourceName">the source name of link</param>
/// <param name="targetName">the target name of link</param>
/// <param name="sourceId">the source id of link</param>
/// <param name="targetId">the target id of link</param>
/// <param name="value">the value of link</param>
/// <returns></returns>
public SerieDataLink AddLink(int serieIndex, string sourceName, string targetName, double value)
public SerieDataLink AddLink(int serieIndex, string sourceId, string targetId, double value = 0)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
var link = serie.AddLink(sourceName, targetName, value);
var link = serie.AddLink(sourceId, targetId, value);
RefreshPainter(serie.painter);
return link;
}

View File

@@ -209,7 +209,7 @@ namespace XCharts.Runtime
}
}
public GraphNode AddNode(string nodeId, string nodeName, int dataIndex)
public GraphNode AddNode(string nodeId, string nodeName, int dataIndex, double value)
{
if (nodeMap.ContainsKey(nodeId))
{
@@ -248,9 +248,9 @@ namespace XCharts.Runtime
XLog.Warning("GraphData.AddEdge(): node2 is null");
return null;
}
if (node1 == node2)
if (directed && node1 == node2)
{
XLog.Warning("GraphData.AddEdge(): node1 == node2");
XLog.Warning("GraphData.AddEdge(): node1 == node2:" + node1);
return null;
}
string edgeKey = nodeId1 + "_" + nodeId2;
@@ -377,6 +377,7 @@ namespace XCharts.Runtime
{
public string id;
public string name;
public double value;
public List<GraphEdge> edges = new List<GraphEdge>();
public List<GraphEdge> inEdges = new List<GraphEdge>();
public List<GraphEdge> outEdges = new List<GraphEdge>();
@@ -386,11 +387,10 @@ namespace XCharts.Runtime
public int depth = -1;
public bool expand = true;
public int level = 0;
public Vector3 position;
public Vector3 delta;
public Vector3 position = Vector3.zero;
public Vector3 pp = Vector3.zero;
public float weight;
public float repulsion;
public Vector3 pp;
public GraphNode(string id, string name, int dataIndex)
{