增加桑基图相关支持

This commit is contained in:
monitor1394
2023-12-09 23:22:00 +08:00
parent 1c6904f074
commit e8c8ab87aa
23 changed files with 948 additions and 34 deletions

View File

@@ -79,6 +79,9 @@ slug: /api
- [EmphasisStyle](#emphasisstyle) - [EmphasisStyle](#emphasisstyle)
- [EndLabelStyle](#endlabelstyle) - [EndLabelStyle](#endlabelstyle)
- [FormatterHelper](#formatterhelper) - [FormatterHelper](#formatterhelper)
- [Graph](#graph)
- [GraphEdge](#graphedge)
- [GraphNode](#graphnode)
- [GridCoord](#gridcoord) - [GridCoord](#gridcoord)
- [GridCoordContext](#gridcoordcontext) - [GridCoordContext](#gridcoordcontext)
- [GridLayout](#gridlayout) - [GridLayout](#gridlayout)
@@ -169,6 +172,7 @@ slug: /api
- [SerieDataComponentAttribute](#seriedatacomponentattribute) - [SerieDataComponentAttribute](#seriedatacomponentattribute)
- [SerieDataContext](#seriedatacontext) - [SerieDataContext](#seriedatacontext)
- [SerieDataExtraFieldAttribute](#seriedataextrafieldattribute) - [SerieDataExtraFieldAttribute](#seriedataextrafieldattribute)
- [SerieDataLink](#seriedatalink)
- [SerieEventData](#serieeventdata) - [SerieEventData](#serieeventdata)
- [SerieEventDataPool](#serieeventdatapool) - [SerieEventDataPool](#serieeventdatapool)
- [SerieHandler](#seriehandler) - [SerieHandler](#seriehandler)
@@ -689,6 +693,7 @@ Background component.
|AddData()||public SerieData AddData(string serieName, double xValue, double yValue, string dataName = null, string dataId = null)<br/>Add a (x,y) data to serie. | |AddData()||public SerieData AddData(string serieName, double xValue, double yValue, string dataName = null, string dataId = null)<br/>Add a (x,y) data to serie. |
|AddData()||public SerieData AddData(string serieName, List&lt;double&gt; multidimensionalData, string dataName = null, string dataId = null)<br/>Add an arbitray dimension data to serie,such as (x,y,z,...). | |AddData()||public SerieData AddData(string serieName, List&lt;double&gt; multidimensionalData, string dataName = null, string dataId = null)<br/>Add an arbitray dimension data to serie,such as (x,y,z,...). |
|AddData()||public SerieData AddData(string serieName, params double[] multidimensionalData)<br/>Add an arbitray dimension data to serie,such as (x,y,z,...). | |AddData()||public SerieData AddData(string serieName, params double[] multidimensionalData)<br/>Add an arbitray dimension data to serie,such as (x,y,z,...). |
|AddLink()||public SerieDataLink AddLink(int serieIndex, string sourceName, string targetName, double value)<br/>Add a link data to serie. |
|AddSerie&lt;T&gt;()||public T AddSerie&lt;T&gt;(string serieName = null, bool show = true, bool addToHead = false) where T : Serie| |AddSerie&lt;T&gt;()||public T AddSerie&lt;T&gt;(string serieName = null, bool show = true, bool addToHead = false) where T : Serie|
|AddXAxisData()||public void AddXAxisData(string category, int xAxisIndex = 0)<br/>Add a category data to xAxis. | |AddXAxisData()||public void AddXAxisData(string category, int xAxisIndex = 0)<br/>Add a category data to xAxis. |
|AddXAxisIcon()||public void AddXAxisIcon(Sprite icon, int xAxisIndex = 0)<br/>Add an icon to xAxis. | |AddXAxisIcon()||public void AddXAxisIcon(Sprite icon, int xAxisIndex = 0)<br/>Add an icon to xAxis. |
@@ -707,9 +712,10 @@ Background component.
|CanMultipleComponent()||public bool CanMultipleComponent(Type type)| |CanMultipleComponent()||public bool CanMultipleComponent(Type type)|
|ClampInChart()||public void ClampInChart(ref Vector3 pos)| |ClampInChart()||public void ClampInChart(ref Vector3 pos)|
|ClampInGrid()||public Vector3 ClampInGrid(GridCoord grid, Vector3 pos)| |ClampInGrid()||public Vector3 ClampInGrid(GridCoord grid, Vector3 pos)|
|ClearComponentData()||public virtual void ClearComponentData()<br/>Clear the data of all components. | |ClearComponentData()|v3.4.0|public virtual void ClearComponentData()<br/>Clear the data of all components. |
|ClearData()||public virtual void ClearData()<br/>Clear all components and series data. Note: serie only empties the data and does not remove serie. | |ClearData()||public virtual void ClearData()<br/>Clear all components and series data. Note: serie only empties the data and does not remove serie. |
|ClearSerieData()||public virtual void ClearSerieData()<br/>Clear the data of all series. | |ClearSerieData()|v3.4.0|public virtual void ClearSerieData()<br/>Clear the data of all series. |
|ClearSerieLinks()|v3.10.0|public virtual void ClearSerieLinks()<br/>Clear the link data of all series. |
|ClickLegendButton()||public void ClickLegendButton(int legendIndex, string legendName, bool show)<br/>点击图例按钮 | |ClickLegendButton()||public void ClickLegendButton(int legendIndex, string legendName, bool show)<br/>点击图例按钮 |
|ConvertSerie()||public bool ConvertSerie(Serie serie, Type type)| |ConvertSerie()||public bool ConvertSerie(Serie serie, Type type)|
|ConvertSerie&lt;T&gt;()||public bool ConvertSerie&lt;T&gt;(Serie serie) where T : Serie| |ConvertSerie&lt;T&gt;()||public bool ConvertSerie&lt;T&gt;(Serie serie) where T : Serie|
@@ -733,7 +739,7 @@ Background component.
|GetItemColor()||public Color32 GetItemColor(Serie serie, SerieData serieData, int colorIndex)| |GetItemColor()||public Color32 GetItemColor(Serie serie, SerieData serieData, int colorIndex)|
|GetLegendRealShowNameColor()||public Color32 GetLegendRealShowNameColor(string name)| |GetLegendRealShowNameColor()||public Color32 GetLegendRealShowNameColor(string name)|
|GetLegendRealShowNameIndex()||public int GetLegendRealShowNameIndex(string name)| |GetLegendRealShowNameIndex()||public int GetLegendRealShowNameIndex(string name)|
|GetMarkColor()||public Color32 GetMarkColor(Serie serie, SerieData serieData)<br/>获得Serie的标识颜色。 | |GetMarkColor()|v3.4.0|public Color32 GetMarkColor(Serie serie, SerieData serieData)<br/>获得Serie的标识颜色。 |
|GetOrAddChartComponent&lt;T&gt;()||public T GetOrAddChartComponent&lt;T&gt;() where T : MainComponent| |GetOrAddChartComponent&lt;T&gt;()||public T GetOrAddChartComponent&lt;T&gt;() where T : MainComponent|
|GetPainter()||public Painter GetPainter(int index)| |GetPainter()||public Painter GetPainter(int index)|
|GetSerie()||public Serie GetSerie(int serieIndex)| |GetSerie()||public Serie GetSerie(int serieIndex)|
@@ -809,6 +815,7 @@ Background component.
|RemoveSerie()||public void RemoveSerie(string serieName)| |RemoveSerie()||public void RemoveSerie(string serieName)|
|RemoveSerie&lt;T&gt;()||public void RemoveSerie&lt;T&gt;() where T : Serie| |RemoveSerie&lt;T&gt;()||public void RemoveSerie&lt;T&gt;() where T : Serie|
|ReplaceSerie()||public bool ReplaceSerie(Serie oldSerie, Serie newSerie)| |ReplaceSerie()||public bool ReplaceSerie(Serie oldSerie, Serie newSerie)|
|ResetChartStatus()|v3.10.0|public void ResetChartStatus()<br/>reset chart status. When some parameters are set, due to the animation effect, the chart status may not be correct. |
|ResetDataIndex()||public bool ResetDataIndex(int serieIndex)<br/>重置serie的数据项索引。避免数据项索引异常。 | |ResetDataIndex()||public bool ResetDataIndex(int serieIndex)<br/>重置serie的数据项索引。避免数据项索引异常。 |
|SetBasePainterMaterial()||public void SetBasePainterMaterial(Material material)<br/>设置Base Painter的材质球 | |SetBasePainterMaterial()||public void SetBasePainterMaterial(Material material)<br/>设置Base Painter的材质球 |
|SetMaxCache()||public void SetMaxCache(int maxCache)<br/>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 | |SetMaxCache()||public void SetMaxCache(int maxCache)<br/>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 |
@@ -1129,7 +1136,7 @@ Configurations of blur state.
## ChildComponent ## ChildComponent
> class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle),[AxisAnimation](#axisanimation),[AxisName](#axisname),[AxisSplitArea](#axissplitarea),[AreaStyle](#areastyle),[ArrowStyle](#arrowstyle),[BaseLine](#baseline),[IconStyle](#iconstyle),[ImageStyle](#imagestyle),[ItemStyle](#itemstyle),[Level](#level),[LevelStyle](#levelstyle),[LineArrow](#linearrow),[LineStyle](#linestyle),[Location](#location),[MLValue](#mlvalue),[MarqueeStyle](#marqueestyle),[Padding](#padding),[StageColor](#stagecolor),[SymbolStyle](#symbolstyle),[TextLimit](#textlimit),[TextStyle](#textstyle),[CommentItem](#commentitem),[CommentMarkStyle](#commentmarkstyle),[LabelLine](#labelline),[LabelStyle](#labelstyle),[MarkAreaData](#markareadata),[MarkLineData](#marklinedata),[StateStyle](#statestyle),[VisualMapRange](#visualmaprange),[UIComponentTheme](#uicomponenttheme),[SerieData](#seriedata),[ComponentTheme](#componenttheme),[SerieTheme](#serietheme),[ThemeStyle](#themestyle) > class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle),[AxisAnimation](#axisanimation),[AxisName](#axisname),[AxisSplitArea](#axissplitarea),[AreaStyle](#areastyle),[ArrowStyle](#arrowstyle),[BaseLine](#baseline),[IconStyle](#iconstyle),[ImageStyle](#imagestyle),[ItemStyle](#itemstyle),[Level](#level),[LevelStyle](#levelstyle),[LineArrow](#linearrow),[LineStyle](#linestyle),[Location](#location),[MLValue](#mlvalue),[MarqueeStyle](#marqueestyle),[Padding](#padding),[StageColor](#stagecolor),[SymbolStyle](#symbolstyle),[TextLimit](#textlimit),[TextStyle](#textstyle),[CommentItem](#commentitem),[CommentMarkStyle](#commentmarkstyle),[LabelLine](#labelline),[LabelStyle](#labelstyle),[MarkAreaData](#markareadata),[MarkLineData](#marklinedata),[StateStyle](#statestyle),[VisualMapRange](#visualmaprange),[UIComponentTheme](#uicomponenttheme),[SerieData](#seriedata),[SerieDataLink](#seriedatalink),[ComponentTheme](#componenttheme),[SerieTheme](#serietheme),[ThemeStyle](#themestyle)
|public method|since|description| |public method|since|description|
@@ -1369,6 +1376,53 @@ Configurations of emphasis state.
|TrimAndReplaceLine()||public static string TrimAndReplaceLine(string content)| |TrimAndReplaceLine()||public static string TrimAndReplaceLine(string content)|
|TrimAndReplaceLine()||public static string TrimAndReplaceLine(StringBuilder sb)| |TrimAndReplaceLine()||public static string TrimAndReplaceLine(StringBuilder sb)|
## Graph
> class in XCharts.Runtime
the data struct of graph.
|public method|since|description|
|--|--|--|
|AddEdge()||public GraphEdge AddEdge(string nodeId1, string nodeId2, double value)|
|AddNode()||public GraphNode AddNode(string nodeId, string nodeName, int dataIndex)|
|BreadthFirstTraverse()||public void BreadthFirstTraverse(GraphNode startNode, System.Action&lt;GraphNode&gt; onTraverse)|
|Clear()||public void Clear()|
|DeepFirstTraverse()||public void DeepFirstTraverse(GraphNode startNode, System.Action&lt;GraphNode&gt; onTraverse)|
|EachNode()||public void EachNode(System.Action&lt;GraphNode&gt; onEach)|
|GetDepthNodes()||public List&lt;List&lt;GraphNode&gt;&gt; GetDepthNodes()|
|GetEdge()||public GraphEdge GetEdge(string nodeId1, string nodeId2)|
|GetMaxDepth()||public int GetMaxDepth()|
|GetNode()||public GraphNode GetNode(string nodeId)|
|GetNodeDepth()||// public int GetNodeDepth(GraphNode node)|
|GetNodeDepth()||// public void GetNodeDepth(GraphNode node, ref int depth, int recursiveCount = 0)|
|GetNodeDepth()||public int GetNodeDepth(GraphNode node, int recursiveCount = 0)|
|GetNodesTotalValue()||public static double GetNodesTotalValue(List&lt;GraphNode&gt; nodes)|
|GetRootNodes()||public List&lt;GraphNode&gt; GetRootNodes()|
|Graph()||public Graph(bool directed)|
|Refresh()||public void Refresh()|
## GraphEdge
> class in XCharts.Runtime
The edge of graph.
|public method|since|description|
|--|--|--|
|GraphEdge()||public GraphEdge(GraphNode node1, GraphNode node2, double value)|
## GraphNode
> class in XCharts.Runtime
The node of graph.
|public method|since|description|
|--|--|--|
|GraphNode()||public GraphNode(string id, string name, int dataIndex)|
|ToString()||public override string ToString()|
## GridCoord ## GridCoord
> class in XCharts.Runtime / Inherits from: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer) > class in XCharts.Runtime / Inherits from: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer)
@@ -1735,6 +1789,8 @@ Legend component.The legend component shows different sets of tags, colors, and
> class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent) > class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
> Since `v3.10.0`
## Line ## Line
@@ -2242,6 +2298,7 @@ Configurations of select state.
|AddData()||public SerieData AddData(List&lt;double&gt; valueList, string dataName = null, string dataId = null)<br/>将一组数据添加到系列中。 如果数据只有一个默认添加到维度Y中。 | |AddData()||public SerieData AddData(List&lt;double&gt; valueList, string dataName = null, string dataId = null)<br/>将一组数据添加到系列中。 如果数据只有一个默认添加到维度Y中。 |
|AddData()||public SerieData AddData(params double[] values)<br/>添加任意维数据到系列中。 | |AddData()||public SerieData AddData(params double[] values)<br/>添加任意维数据到系列中。 |
|AddExtraComponent&lt;T&gt;()||public T AddExtraComponent&lt;T&gt;() where T : ChildComponent, ISerieComponent| |AddExtraComponent&lt;T&gt;()||public T AddExtraComponent&lt;T&gt;() where T : ChildComponent, ISerieComponent|
|AddLink()||public SerieDataLink AddLink(string sourceName, string targetName, double value)<br/>Add a link data. |
|AddSerieData()||public void AddSerieData(SerieData serieData)| |AddSerieData()||public void AddSerieData(SerieData serieData)|
|AddXYData()||public SerieData AddXYData(double xValue, double yValue, string dataName = null, string dataId = null)<br/>添加xy数据到维度X和维度Y | |AddXYData()||public SerieData AddXYData(double xValue, double yValue, string dataName = null, string dataId = null)<br/>添加xy数据到维度X和维度Y |
|AddYData()||public SerieData AddYData(double value, string dataName = null, string dataId = null)<br/>添加一个数据到维度Y此时维度X对应的数据是索引 | |AddYData()||public SerieData AddYData(double value, string dataName = null, string dataId = null)<br/>添加一个数据到维度Y此时维度X对应的数据是索引 |
@@ -2258,6 +2315,7 @@ Configurations of select state.
|ClearData()||public override void ClearData()<br/>清空所有数据 | |ClearData()||public override void ClearData()<br/>清空所有数据 |
|ClearDirty()||public override void ClearDirty()| |ClearDirty()||public override void ClearDirty()|
|ClearHighlight()||public void ClearHighlight()<br/>清除所有数据的高亮标志 | |ClearHighlight()||public void ClearHighlight()<br/>清除所有数据的高亮标志 |
|ClearLinks()||public void ClearLinks()<br/>清空所有Link数据 |
|ClearSerieNameDirty()||public void ClearSerieNameDirty()| |ClearSerieNameDirty()||public void ClearSerieNameDirty()|
|ClearVerticesDirty()||public override void ClearVerticesDirty()| |ClearVerticesDirty()||public override void ClearVerticesDirty()|
|Clone()||public Serie Clone()| |Clone()||public Serie Clone()|
@@ -2435,6 +2493,14 @@ The attribute for serie data component.
|SerieDataExtraFieldAttribute()||public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6)| |SerieDataExtraFieldAttribute()||public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6)|
|SerieDataExtraFieldAttribute()||public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6, string field7)| |SerieDataExtraFieldAttribute()||public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6, string field7)|
## SerieDataLink
> class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
> Since `v3.10.0`
the link of serie data. Used for sankey chart. Sankey chart only supports directed acyclic graph. make sure the data link is directed acyclic graph.
## SerieEventData ## SerieEventData
> class in XCharts.Runtime > class in XCharts.Runtime
@@ -2472,6 +2538,7 @@ the data of serie event.
|ForceUpdateSerieContext()||public virtual void ForceUpdateSerieContext() { }| |ForceUpdateSerieContext()||public virtual void ForceUpdateSerieContext() { }|
|InitComponent()||public virtual void InitComponent() { }| |InitComponent()||public virtual void InitComponent() { }|
|OnBeginDrag()||public virtual void OnBeginDrag(PointerEventData eventData) { }| |OnBeginDrag()||public virtual void OnBeginDrag(PointerEventData eventData) { }|
|OnDataUpdate()||public virtual void OnDataUpdate() { }|
|OnDrag()||public virtual void OnDrag(PointerEventData eventData) { }| |OnDrag()||public virtual void OnDrag(PointerEventData eventData) { }|
|OnEndDrag()||public virtual void OnEndDrag(PointerEventData eventData) { }| |OnEndDrag()||public virtual void OnEndDrag(PointerEventData eventData) { }|
|OnLegendButtonClick()||public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }| |OnLegendButtonClick()||public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }|

View File

@@ -121,6 +121,7 @@ import APITable from '@site/src/components/APITable';
- [RadiusAxisTheme](#radiusaxistheme) - [RadiusAxisTheme](#radiusaxistheme)
- [SelectStyle](#selectstyle) - [SelectStyle](#selectstyle)
- [SerieData](#seriedata) - [SerieData](#seriedata)
- [SerieDataLink](#seriedatalink)
- [SerieSymbol](#seriesymbol) - [SerieSymbol](#seriesymbol)
- [SerieTheme](#serietheme) - [SerieTheme](#serietheme)
- [StageColor](#stagecolor) - [StageColor](#stagecolor)
@@ -744,7 +745,7 @@ Configurations of blur state.
## ChildComponent ## ChildComponent
> class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle), [AxisAnimation](#axisanimation), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [IconStyle](#iconstyle), [ImageStyle](#imagestyle), [ItemStyle](#itemstyle), [Level](#level), [LevelStyle](#levelstyle), [LineArrow](#linearrow), [LineStyle](#linestyle), [Location](#location), [MLValue](#mlvalue), [MarqueeStyle](#marqueestyle), [Padding](#padding), [StageColor](#stagecolor), [SymbolStyle](#symbolstyle), [TextLimit](#textlimit), [TextStyle](#textstyle), [CommentItem](#commentitem), [CommentMarkStyle](#commentmarkstyle), [LabelLine](#labelline), [LabelStyle](#labelstyle), [MarkAreaData](#markareadata), [MarkLineData](#marklinedata), [StateStyle](#statestyle), [VisualMapRange](#visualmaprange), [UIComponentTheme](#uicomponenttheme), [SerieData](#seriedata), [ComponentTheme](#componenttheme), [SerieTheme](#serietheme), [ThemeStyle](#themestyle) > class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle), [AxisAnimation](#axisanimation), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [IconStyle](#iconstyle), [ImageStyle](#imagestyle), [ItemStyle](#itemstyle), [Level](#level), [LevelStyle](#levelstyle), [LineArrow](#linearrow), [LineStyle](#linestyle), [Location](#location), [MLValue](#mlvalue), [MarqueeStyle](#marqueestyle), [Padding](#padding), [StageColor](#stagecolor), [SymbolStyle](#symbolstyle), [TextLimit](#textlimit), [TextStyle](#textstyle), [CommentItem](#commentitem), [CommentMarkStyle](#commentmarkstyle), [LabelLine](#labelline), [LabelStyle](#labelstyle), [MarkAreaData](#markareadata), [MarkLineData](#marklinedata), [StateStyle](#statestyle), [VisualMapRange](#visualmaprange), [UIComponentTheme](#uicomponenttheme), [SerieData](#seriedata), [SerieDataLink](#seriedatalink), [ComponentTheme](#componenttheme), [SerieTheme](#serietheme), [ThemeStyle](#themestyle)
## Comment ## Comment
@@ -1341,9 +1342,11 @@ Legend component.The legend component shows different sets of tags, colors, and
|field|default|since|comment| |field|default|since|comment|
|--|--|--|--| |--|--|--|--|
|label|||文本标签样式。 [LabelStyle](#labelstyle)| |depth|0|v3.10.0|the depth of level.
|upperLabel|||上方的文本标签样式。 [LabelStyle](#labelstyle)| |label|||the label style of level. [LabelStyle](#labelstyle)|
|itemStyle|||数据项样式。 [ItemStyle](#itemstyle)| |upperLabel|||the upper label style of level. [LabelStyle](#labelstyle)|
|lineStyle||v3.10.0|the line style of level. [LineStyle](#linestyle)|
|itemStyle|||the item style of level. [ItemStyle](#itemstyle)|
```mdx-code-block ```mdx-code-block
</APITable> </APITable>
@@ -1353,6 +1356,8 @@ Legend component.The legend component shows different sets of tags, colors, and
> class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent) > class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
> Since `v3.10.0`
```mdx-code-block ```mdx-code-block
<APITable name="LevelStyle"> <APITable name="LevelStyle">
``` ```
@@ -1836,6 +1841,7 @@ Configurations of select state.
|animation|||The start animation. [AnimationStyle](#animationstyle)| |animation|||The start animation. [AnimationStyle](#animationstyle)|
|itemStyle|||The style of data item. [ItemStyle](#itemstyle)| |itemStyle|||The style of data item. [ItemStyle](#itemstyle)|
|data|||系列中的数据内容数组。SerieData可以设置1到n维数据。 |data|||系列中的数据内容数组。SerieData可以设置1到n维数据。
|links|||数据节点的边。
```mdx-code-block ```mdx-code-block
</APITable> </APITable>
@@ -1868,6 +1874,29 @@ A data item of serie.
</APITable> </APITable>
``` ```
## SerieDataLink
> class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
> Since `v3.10.0`
the link of serie data. Used for sankey chart. Sankey chart only supports directed acyclic graph. make sure the data link is directed acyclic graph.
```mdx-code-block
<APITable name="SerieDataLink">
```
|field|default|since|comment|
|--|--|--|--|
|source|||the source node name.
|target|||the target node name.
|value|||the value of link. decide the width of link.
```mdx-code-block
</APITable>
```
## SerieSymbol ## SerieSymbol
> class in XCharts.Runtime / Inherits from: [SymbolStyle](#symbolstyle), [ISerieDataComponent](#iseriedatacomponent) > class in XCharts.Runtime / Inherits from: [SymbolStyle](#symbolstyle), [ISerieDataComponent](#iseriedatacomponent)

View File

@@ -79,6 +79,9 @@ slug: /api
- [EmphasisStyle](#emphasisstyle) - [EmphasisStyle](#emphasisstyle)
- [EndLabelStyle](#endlabelstyle) - [EndLabelStyle](#endlabelstyle)
- [FormatterHelper](#formatterhelper) - [FormatterHelper](#formatterhelper)
- [Graph](#graph)
- [GraphEdge](#graphedge)
- [GraphNode](#graphnode)
- [GridCoord](#gridcoord) - [GridCoord](#gridcoord)
- [GridCoordContext](#gridcoordcontext) - [GridCoordContext](#gridcoordcontext)
- [GridLayout](#gridlayout) - [GridLayout](#gridlayout)
@@ -169,6 +172,7 @@ slug: /api
- [SerieDataComponentAttribute](#seriedatacomponentattribute) - [SerieDataComponentAttribute](#seriedatacomponentattribute)
- [SerieDataContext](#seriedatacontext) - [SerieDataContext](#seriedatacontext)
- [SerieDataExtraFieldAttribute](#seriedataextrafieldattribute) - [SerieDataExtraFieldAttribute](#seriedataextrafieldattribute)
- [SerieDataLink](#seriedatalink)
- [SerieEventData](#serieeventdata) - [SerieEventData](#serieeventdata)
- [SerieEventDataPool](#serieeventdatapool) - [SerieEventDataPool](#serieeventdatapool)
- [SerieHandler](#seriehandler) - [SerieHandler](#seriehandler)
@@ -689,6 +693,7 @@ slug: /api
|AddData()||public SerieData AddData(string serieName, double xValue, double yValue, string dataName = null, string dataId = null)<br/>添加x,y数据到指定系列中。 | |AddData()||public SerieData AddData(string serieName, double xValue, double yValue, string dataName = null, string dataId = null)<br/>添加x,y数据到指定系列中。 |
|AddData()||public SerieData AddData(string serieName, List&lt;double&gt; multidimensionalData, string dataName = null, string dataId = null)<br/>添加多维数据x,y,z...)到指定的系列中。 | |AddData()||public SerieData AddData(string serieName, List&lt;double&gt; multidimensionalData, string dataName = null, string dataId = null)<br/>添加多维数据x,y,z...)到指定的系列中。 |
|AddData()||public SerieData AddData(string serieName, params double[] multidimensionalData)<br/>添加多维数据x,y,z...)到指定的系列中。 | |AddData()||public SerieData AddData(string serieName, params double[] multidimensionalData)<br/>添加多维数据x,y,z...)到指定的系列中。 |
|AddLink()||public SerieDataLink AddLink(int serieIndex, string sourceName, string targetName, double value)<br/>添加一个关系图的关系数据。 |
|AddSerie&lt;T&gt;()||public T AddSerie&lt;T&gt;(string serieName = null, bool show = true, bool addToHead = false) where T : Serie| |AddSerie&lt;T&gt;()||public T AddSerie&lt;T&gt;(string serieName = null, bool show = true, bool addToHead = false) where T : Serie|
|AddXAxisData()||public void AddXAxisData(string category, int xAxisIndex = 0)<br/>添加一个类目数据到指定的x轴。 | |AddXAxisData()||public void AddXAxisData(string category, int xAxisIndex = 0)<br/>添加一个类目数据到指定的x轴。 |
|AddXAxisIcon()||public void AddXAxisIcon(Sprite icon, int xAxisIndex = 0)<br/>添加一个图标到指定的x轴。 | |AddXAxisIcon()||public void AddXAxisIcon(Sprite icon, int xAxisIndex = 0)<br/>添加一个图标到指定的x轴。 |
@@ -707,9 +712,10 @@ slug: /api
|CanMultipleComponent()||public bool CanMultipleComponent(Type type)| |CanMultipleComponent()||public bool CanMultipleComponent(Type type)|
|ClampInChart()||public void ClampInChart(ref Vector3 pos)| |ClampInChart()||public void ClampInChart(ref Vector3 pos)|
|ClampInGrid()||public Vector3 ClampInGrid(GridCoord grid, Vector3 pos)| |ClampInGrid()||public Vector3 ClampInGrid(GridCoord grid, Vector3 pos)|
|ClearComponentData()||public virtual void ClearComponentData()<br/>清空所有组件的数据。 | |ClearComponentData()|v3.4.0|public virtual void ClearComponentData()<br/>清空所有组件的数据。 |
|ClearData()||public virtual void ClearData()<br/>清空所有组件和Serie的数据。注意Serie只是清空数据不会移除Serie。 | |ClearData()||public virtual void ClearData()<br/>清空所有组件和Serie的数据。注意Serie只是清空数据不会移除Serie。 |
|ClearSerieData()||public virtual void ClearSerieData()<br/>清空所有serie的数据。 | |ClearSerieData()|v3.4.0|public virtual void ClearSerieData()<br/>清空所有serie的数据。 |
|ClearSerieLinks()|v3.10.0|public virtual void ClearSerieLinks()<br/>清空所有serie的link数据。 |
|ClickLegendButton()||public void ClickLegendButton(int legendIndex, string legendName, bool show)<br/>点击图例按钮 | |ClickLegendButton()||public void ClickLegendButton(int legendIndex, string legendName, bool show)<br/>点击图例按钮 |
|ConvertSerie()||public bool ConvertSerie(Serie serie, Type type)| |ConvertSerie()||public bool ConvertSerie(Serie serie, Type type)|
|ConvertSerie&lt;T&gt;()||public bool ConvertSerie&lt;T&gt;(Serie serie) where T : Serie| |ConvertSerie&lt;T&gt;()||public bool ConvertSerie&lt;T&gt;(Serie serie) where T : Serie|
@@ -733,7 +739,7 @@ slug: /api
|GetItemColor()||public Color32 GetItemColor(Serie serie, SerieData serieData, int colorIndex)| |GetItemColor()||public Color32 GetItemColor(Serie serie, SerieData serieData, int colorIndex)|
|GetLegendRealShowNameColor()||public Color32 GetLegendRealShowNameColor(string name)| |GetLegendRealShowNameColor()||public Color32 GetLegendRealShowNameColor(string name)|
|GetLegendRealShowNameIndex()||public int GetLegendRealShowNameIndex(string name)| |GetLegendRealShowNameIndex()||public int GetLegendRealShowNameIndex(string name)|
|GetMarkColor()||public Color32 GetMarkColor(Serie serie, SerieData serieData)<br/>获得Serie的标识颜色。 | |GetMarkColor()|v3.4.0|public Color32 GetMarkColor(Serie serie, SerieData serieData)<br/>获得Serie的标识颜色。 |
|GetOrAddChartComponent&lt;T&gt;()||public T GetOrAddChartComponent&lt;T&gt;() where T : MainComponent| |GetOrAddChartComponent&lt;T&gt;()||public T GetOrAddChartComponent&lt;T&gt;() where T : MainComponent|
|GetPainter()||public Painter GetPainter(int index)| |GetPainter()||public Painter GetPainter(int index)|
|GetSerie()||public Serie GetSerie(int serieIndex)| |GetSerie()||public Serie GetSerie(int serieIndex)|
@@ -809,6 +815,7 @@ slug: /api
|RemoveSerie()||public void RemoveSerie(string serieName)| |RemoveSerie()||public void RemoveSerie(string serieName)|
|RemoveSerie&lt;T&gt;()||public void RemoveSerie&lt;T&gt;() where T : Serie| |RemoveSerie&lt;T&gt;()||public void RemoveSerie&lt;T&gt;() where T : Serie|
|ReplaceSerie()||public bool ReplaceSerie(Serie oldSerie, Serie newSerie)| |ReplaceSerie()||public bool ReplaceSerie(Serie oldSerie, Serie newSerie)|
|ResetChartStatus()|v3.10.0|public void ResetChartStatus()<br/>重置图表状态。当设置某些参数后,由于动画影响,可能导致图表状态不正确,此时可以调用该接口重置图表状态。 |
|ResetDataIndex()||public bool ResetDataIndex(int serieIndex)<br/>重置serie的数据项索引。避免数据项索引异常。 | |ResetDataIndex()||public bool ResetDataIndex(int serieIndex)<br/>重置serie的数据项索引。避免数据项索引异常。 |
|SetBasePainterMaterial()||public void SetBasePainterMaterial(Material material)<br/>设置Base Painter的材质球 | |SetBasePainterMaterial()||public void SetBasePainterMaterial(Material material)<br/>设置Base Painter的材质球 |
|SetMaxCache()||public void SetMaxCache(int maxCache)<br/>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 | |SetMaxCache()||public void SetMaxCache(int maxCache)<br/>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 |
@@ -1129,7 +1136,7 @@ slug: /api
## ChildComponent ## ChildComponent
> class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle),[AxisAnimation](#axisanimation),[AxisName](#axisname),[AxisSplitArea](#axissplitarea),[AreaStyle](#areastyle),[ArrowStyle](#arrowstyle),[BaseLine](#baseline),[IconStyle](#iconstyle),[ImageStyle](#imagestyle),[ItemStyle](#itemstyle),[Level](#level),[LevelStyle](#levelstyle),[LineArrow](#linearrow),[LineStyle](#linestyle),[Location](#location),[MLValue](#mlvalue),[MarqueeStyle](#marqueestyle),[Padding](#padding),[StageColor](#stagecolor),[SymbolStyle](#symbolstyle),[TextLimit](#textlimit),[TextStyle](#textstyle),[CommentItem](#commentitem),[CommentMarkStyle](#commentmarkstyle),[LabelLine](#labelline),[LabelStyle](#labelstyle),[MarkAreaData](#markareadata),[MarkLineData](#marklinedata),[StateStyle](#statestyle),[VisualMapRange](#visualmaprange),[UIComponentTheme](#uicomponenttheme),[SerieData](#seriedata),[ComponentTheme](#componenttheme),[SerieTheme](#serietheme),[ThemeStyle](#themestyle) > class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle),[AxisAnimation](#axisanimation),[AxisName](#axisname),[AxisSplitArea](#axissplitarea),[AreaStyle](#areastyle),[ArrowStyle](#arrowstyle),[BaseLine](#baseline),[IconStyle](#iconstyle),[ImageStyle](#imagestyle),[ItemStyle](#itemstyle),[Level](#level),[LevelStyle](#levelstyle),[LineArrow](#linearrow),[LineStyle](#linestyle),[Location](#location),[MLValue](#mlvalue),[MarqueeStyle](#marqueestyle),[Padding](#padding),[StageColor](#stagecolor),[SymbolStyle](#symbolstyle),[TextLimit](#textlimit),[TextStyle](#textstyle),[CommentItem](#commentitem),[CommentMarkStyle](#commentmarkstyle),[LabelLine](#labelline),[LabelStyle](#labelstyle),[MarkAreaData](#markareadata),[MarkLineData](#marklinedata),[StateStyle](#statestyle),[VisualMapRange](#visualmaprange),[UIComponentTheme](#uicomponenttheme),[SerieData](#seriedata),[SerieDataLink](#seriedatalink),[ComponentTheme](#componenttheme),[SerieTheme](#serietheme),[ThemeStyle](#themestyle)
|API|版本|描述| |API|版本|描述|
@@ -1369,6 +1376,53 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息
|TrimAndReplaceLine()||public static string TrimAndReplaceLine(string content)| |TrimAndReplaceLine()||public static string TrimAndReplaceLine(string content)|
|TrimAndReplaceLine()||public static string TrimAndReplaceLine(StringBuilder sb)| |TrimAndReplaceLine()||public static string TrimAndReplaceLine(StringBuilder sb)|
## Graph
> class in XCharts.Runtime
数据结构-图。
|API|版本|描述|
|--|--|--|
|AddEdge()||public GraphEdge AddEdge(string nodeId1, string nodeId2, double value)|
|AddNode()||public GraphNode AddNode(string nodeId, string nodeName, int dataIndex)|
|BreadthFirstTraverse()||public void BreadthFirstTraverse(GraphNode startNode, System.Action&lt;GraphNode&gt; onTraverse)|
|Clear()||public void Clear()|
|DeepFirstTraverse()||public void DeepFirstTraverse(GraphNode startNode, System.Action&lt;GraphNode&gt; onTraverse)|
|EachNode()||public void EachNode(System.Action&lt;GraphNode&gt; onEach)|
|GetDepthNodes()||public List&lt;List&lt;GraphNode&gt;&gt; GetDepthNodes()|
|GetEdge()||public GraphEdge GetEdge(string nodeId1, string nodeId2)|
|GetMaxDepth()||public int GetMaxDepth()|
|GetNode()||public GraphNode GetNode(string nodeId)|
|GetNodeDepth()||// public int GetNodeDepth(GraphNode node)|
|GetNodeDepth()||// public void GetNodeDepth(GraphNode node, ref int depth, int recursiveCount = 0)|
|GetNodeDepth()||public int GetNodeDepth(GraphNode node, int recursiveCount = 0)|
|GetNodesTotalValue()||public static double GetNodesTotalValue(List&lt;GraphNode&gt; nodes)|
|GetRootNodes()||public List&lt;GraphNode&gt; GetRootNodes()|
|Graph()||public Graph(bool directed)|
|Refresh()||public void Refresh()|
## GraphEdge
> class in XCharts.Runtime
图的边。
|API|版本|描述|
|--|--|--|
|GraphEdge()||public GraphEdge(GraphNode node1, GraphNode node2, double value)|
## GraphNode
> class in XCharts.Runtime
图的节点。
|API|版本|描述|
|--|--|--|
|GraphNode()||public GraphNode(string id, string name, int dataIndex)|
|ToString()||public override string ToString()|
## GridCoord ## GridCoord
> class in XCharts.Runtime / 继承自: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer) > class in XCharts.Runtime / 继承自: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer)
@@ -1735,6 +1789,8 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart
> class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) > class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
> 从 `v3.10.0` 开始支持
## Line ## Line
@@ -2242,6 +2298,7 @@ Radar coordinate conponnet for radar charts. 雷达图坐标系组件,只适
|AddData()||public SerieData AddData(List&lt;double&gt; valueList, string dataName = null, string dataId = null)<br/>将一组数据添加到系列中。 如果数据只有一个默认添加到维度Y中。 | |AddData()||public SerieData AddData(List&lt;double&gt; valueList, string dataName = null, string dataId = null)<br/>将一组数据添加到系列中。 如果数据只有一个默认添加到维度Y中。 |
|AddData()||public SerieData AddData(params double[] values)<br/>添加任意维数据到系列中。 | |AddData()||public SerieData AddData(params double[] values)<br/>添加任意维数据到系列中。 |
|AddExtraComponent&lt;T&gt;()||public T AddExtraComponent&lt;T&gt;() where T : ChildComponent, ISerieComponent| |AddExtraComponent&lt;T&gt;()||public T AddExtraComponent&lt;T&gt;() where T : ChildComponent, ISerieComponent|
|AddLink()||public SerieDataLink AddLink(string sourceName, string targetName, double value)<br/>添加一个关系图的关系数据。 |
|AddSerieData()||public void AddSerieData(SerieData serieData)| |AddSerieData()||public void AddSerieData(SerieData serieData)|
|AddXYData()||public SerieData AddXYData(double xValue, double yValue, string dataName = null, string dataId = null)<br/>添加xy数据到维度X和维度Y | |AddXYData()||public SerieData AddXYData(double xValue, double yValue, string dataName = null, string dataId = null)<br/>添加xy数据到维度X和维度Y |
|AddYData()||public SerieData AddYData(double value, string dataName = null, string dataId = null)<br/>添加一个数据到维度Y此时维度X对应的数据是索引 | |AddYData()||public SerieData AddYData(double value, string dataName = null, string dataId = null)<br/>添加一个数据到维度Y此时维度X对应的数据是索引 |
@@ -2258,6 +2315,7 @@ Radar coordinate conponnet for radar charts. 雷达图坐标系组件,只适
|ClearData()||public override void ClearData()<br/>清空所有数据 | |ClearData()||public override void ClearData()<br/>清空所有数据 |
|ClearDirty()||public override void ClearDirty()| |ClearDirty()||public override void ClearDirty()|
|ClearHighlight()||public void ClearHighlight()<br/>清除所有数据的高亮标志 | |ClearHighlight()||public void ClearHighlight()<br/>清除所有数据的高亮标志 |
|ClearLinks()||public void ClearLinks()<br/>清空所有Link数据 |
|ClearSerieNameDirty()||public void ClearSerieNameDirty()| |ClearSerieNameDirty()||public void ClearSerieNameDirty()|
|ClearVerticesDirty()||public override void ClearVerticesDirty()| |ClearVerticesDirty()||public override void ClearVerticesDirty()|
|Clone()||public Serie Clone()| |Clone()||public Serie Clone()|
@@ -2435,6 +2493,14 @@ Radar coordinate conponnet for radar charts. 雷达图坐标系组件,只适
|SerieDataExtraFieldAttribute()||public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6)| |SerieDataExtraFieldAttribute()||public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6)|
|SerieDataExtraFieldAttribute()||public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6, string field7)| |SerieDataExtraFieldAttribute()||public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6, string field7)|
## SerieDataLink
> class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
> 从 `v3.10.0` 开始支持
数据节点之间的连线。可用于桑基图等,桑基图只支持有向无环图,请保证数据的连线是有向无环图。
## SerieEventData ## SerieEventData
> class in XCharts.Runtime > class in XCharts.Runtime
@@ -2472,6 +2538,7 @@ serie事件的数据。
|ForceUpdateSerieContext()||public virtual void ForceUpdateSerieContext() { }| |ForceUpdateSerieContext()||public virtual void ForceUpdateSerieContext() { }|
|InitComponent()||public virtual void InitComponent() { }| |InitComponent()||public virtual void InitComponent() { }|
|OnBeginDrag()||public virtual void OnBeginDrag(PointerEventData eventData) { }| |OnBeginDrag()||public virtual void OnBeginDrag(PointerEventData eventData) { }|
|OnDataUpdate()||public virtual void OnDataUpdate() { }|
|OnDrag()||public virtual void OnDrag(PointerEventData eventData) { }| |OnDrag()||public virtual void OnDrag(PointerEventData eventData) { }|
|OnEndDrag()||public virtual void OnEndDrag(PointerEventData eventData) { }| |OnEndDrag()||public virtual void OnEndDrag(PointerEventData eventData) { }|
|OnLegendButtonClick()||public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }| |OnLegendButtonClick()||public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }|

View File

@@ -70,6 +70,8 @@ slug: /changelog
## master ## master
* (2023.12.09) 增加`LevelStyle``LineStyle``depth`支持
* (2023.12.09) 增加`Serie``Link`可用于桑基图添加节点边关系
* (2023.12.05) 增加`ResetChartStatus()`可主动重置图表状态 * (2023.12.05) 增加`ResetChartStatus()`可主动重置图表状态
## v3.9.0 ## v3.9.0

View File

@@ -121,6 +121,7 @@ import APITable from '@site/src/components/APITable';
- [RadiusAxisTheme](#radiusaxistheme) - [RadiusAxisTheme](#radiusaxistheme)
- [SelectStyle](#selectstyle) - [SelectStyle](#selectstyle)
- [SerieData](#seriedata) - [SerieData](#seriedata)
- [SerieDataLink](#seriedatalink)
- [SerieSymbol](#seriesymbol) - [SerieSymbol](#seriesymbol)
- [SerieTheme](#serietheme) - [SerieTheme](#serietheme)
- [StageColor](#stagecolor) - [StageColor](#stagecolor)
@@ -725,7 +726,7 @@ import APITable from '@site/src/components/APITable';
## ChildComponent ## ChildComponent
> class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle), [AxisAnimation](#axisanimation), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [IconStyle](#iconstyle), [ImageStyle](#imagestyle), [ItemStyle](#itemstyle), [Level](#level), [LevelStyle](#levelstyle), [LineArrow](#linearrow), [LineStyle](#linestyle), [Location](#location), [MLValue](#mlvalue), [MarqueeStyle](#marqueestyle), [Padding](#padding), [StageColor](#stagecolor), [SymbolStyle](#symbolstyle), [TextLimit](#textlimit), [TextStyle](#textstyle), [CommentItem](#commentitem), [CommentMarkStyle](#commentmarkstyle), [LabelLine](#labelline), [LabelStyle](#labelstyle), [MarkAreaData](#markareadata), [MarkLineData](#marklinedata), [StateStyle](#statestyle), [VisualMapRange](#visualmaprange), [UIComponentTheme](#uicomponenttheme), [SerieData](#seriedata), [ComponentTheme](#componenttheme), [SerieTheme](#serietheme), [ThemeStyle](#themestyle) > class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle), [AxisAnimation](#axisanimation), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [IconStyle](#iconstyle), [ImageStyle](#imagestyle), [ItemStyle](#itemstyle), [Level](#level), [LevelStyle](#levelstyle), [LineArrow](#linearrow), [LineStyle](#linestyle), [Location](#location), [MLValue](#mlvalue), [MarqueeStyle](#marqueestyle), [Padding](#padding), [StageColor](#stagecolor), [SymbolStyle](#symbolstyle), [TextLimit](#textlimit), [TextStyle](#textstyle), [CommentItem](#commentitem), [CommentMarkStyle](#commentmarkstyle), [LabelLine](#labelline), [LabelStyle](#labelstyle), [MarkAreaData](#markareadata), [MarkLineData](#marklinedata), [StateStyle](#statestyle), [VisualMapRange](#visualmaprange), [UIComponentTheme](#uicomponenttheme), [SerieData](#seriedata), [SerieDataLink](#seriedatalink), [ComponentTheme](#componenttheme), [SerieTheme](#serietheme), [ThemeStyle](#themestyle)
## Comment ## Comment
@@ -1302,8 +1303,10 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart
|参数|默认|版本|描述| |参数|默认|版本|描述|
|--|--|--|--| |--|--|--|--|
|depth|0|v3.10.0|层级深度。
|label|||文本标签样式。 [LabelStyle](#labelstyle)| |label|||文本标签样式。 [LabelStyle](#labelstyle)|
|upperLabel|||上方的文本标签样式。 [LabelStyle](#labelstyle)| |upperLabel|||上方的文本标签样式。 [LabelStyle](#labelstyle)|
|lineStyle||v3.10.0|线条样式。 [LineStyle](#linestyle)|
|itemStyle|||数据项样式。 [ItemStyle](#itemstyle)| |itemStyle|||数据项样式。 [ItemStyle](#itemstyle)|
```mdx-code-block ```mdx-code-block
@@ -1314,6 +1317,8 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart
> class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) > class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
> 从 `v3.10.0` 开始支持
```mdx-code-block ```mdx-code-block
<APITable name="LevelStyle"> <APITable name="LevelStyle">
``` ```
@@ -1781,6 +1786,7 @@ Radar coordinate conponnet for radar charts. 雷达图坐标系组件,只适
|animation|||起始动画。 [AnimationStyle](#animationstyle)| |animation|||起始动画。 [AnimationStyle](#animationstyle)|
|itemStyle|||图形样式。 [ItemStyle](#itemstyle)| |itemStyle|||图形样式。 [ItemStyle](#itemstyle)|
|data|||系列中的数据内容数组。SerieData可以设置1到n维数据。 |data|||系列中的数据内容数组。SerieData可以设置1到n维数据。
|links|||数据节点的边。
```mdx-code-block ```mdx-code-block
</APITable> </APITable>
@@ -1812,6 +1818,28 @@ Radar coordinate conponnet for radar charts. 雷达图坐标系组件,只适
</APITable> </APITable>
``` ```
## SerieDataLink
> class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
> 从 `v3.10.0` 开始支持
数据节点之间的连线。可用于桑基图等,桑基图只支持有向无环图,请保证数据的连线是有向无环图。
```mdx-code-block
<APITable name="SerieDataLink">
```
|参数|默认|版本|描述|
|--|--|--|--|
|source|||边的源节点名称。
|target|||边的目标节点名称。
|value|||边的值。决定边的宽度。
```mdx-code-block
</APITable>
```
## SerieSymbol ## SerieSymbol
> class in XCharts.Runtime / 继承自: [SymbolStyle](#symbolstyle), [ISerieDataComponent](#iseriedatacomponent) > class in XCharts.Runtime / 继承自: [SymbolStyle](#symbolstyle), [ISerieDataComponent](#iseriedatacomponent)

View File

@@ -27,11 +27,16 @@ namespace XCharts.Editor
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{ {
base.OnGUI(pos, prop, label); base.OnGUI(pos, prop, label);
if (MakeComponentFoldout(prop, "m_Depth", true))
{
++EditorGUI.indentLevel; ++EditorGUI.indentLevel;
PropertyField(prop, "m_Depth");
PropertyField(prop, "m_Label"); PropertyField(prop, "m_Label");
PropertyField(prop, "m_UpperLabel"); PropertyField(prop, "m_UpperLabel");
PropertyField(prop, "m_LineStyle");
PropertyField(prop, "m_ItemStyle"); PropertyField(prop, "m_ItemStyle");
--EditorGUI.indentLevel; --EditorGUI.indentLevel;
} }
} }
}
} }

View File

@@ -92,7 +92,7 @@ namespace XCharts.Editor
{ {
PropertyListField("m_Data", true, new HeaderMenuInfo("Import ECharts Axis Data", () => PropertyListField("m_Data", true, new HeaderMenuInfo("Import ECharts Axis Data", () =>
{ {
PraseExternalDataEditor.UpdateData(chart, null, component as Axis); PraseExternalDataEditor.UpdateData(chart, null, component as Axis, false);
PraseExternalDataEditor.ShowWindow(); PraseExternalDataEditor.ShowWindow();
})); }));
} }

View File

@@ -0,0 +1,24 @@
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
namespace XCharts.Editor
{
[CustomPropertyDrawer(typeof(SerieDataLink), true)]
public class SerieDataLinkDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Link"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeComponentFoldout(prop, "", true))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Source");
PropertyField(prop, "m_Target");
PropertyField(prop, "m_Value");
--EditorGUI.indentLevel;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 877ff0f4c473d47f29e7e7e3a3eaf53b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -12,6 +12,8 @@ namespace XCharts.Editor
private bool m_DataFoldout = false; private bool m_DataFoldout = false;
private bool m_DataComponentFoldout = true; private bool m_DataComponentFoldout = true;
private Dictionary<int, bool> m_DataElementFoldout = new Dictionary<int, bool>(); private Dictionary<int, bool> m_DataElementFoldout = new Dictionary<int, bool>();
private bool m_LinksFoldout = false;
private Dictionary<int, bool> m_LinksElementFoldout = new Dictionary<int, bool>();
public override void OnInspectorGUI() public override void OnInspectorGUI()
{ {
@@ -31,12 +33,16 @@ namespace XCharts.Editor
OnCustomInspectorGUI(); OnCustomInspectorGUI();
OnExtraInspectorGUI(); OnExtraInspectorGUI();
PropertyFieldData(); PropertyFieldData();
OnEndCustomInspectorGUI();
--EditorGUI.indentLevel; --EditorGUI.indentLevel;
} }
public virtual void OnCustomInspectorGUI() public virtual void OnCustomInspectorGUI()
{ } { }
public virtual void OnEndCustomInspectorGUI()
{ }
private void OnExtraInspectorGUI() private void OnExtraInspectorGUI()
{ {
foreach (var kv in Serie.extraComponentMap) foreach (var kv in Serie.extraComponentMap)
@@ -52,7 +58,7 @@ namespace XCharts.Editor
m_DataFoldout = ChartEditorHelper.DrawHeader("Data", m_DataFoldout, false, null, null, m_DataFoldout = ChartEditorHelper.DrawHeader("Data", m_DataFoldout, false, null, null,
new HeaderMenuInfo("Import ECharts Data", () => new HeaderMenuInfo("Import ECharts Data", () =>
{ {
PraseExternalDataEditor.UpdateData(chart, serie, null); PraseExternalDataEditor.UpdateData(chart, serie, null, false);
PraseExternalDataEditor.ShowWindow(); PraseExternalDataEditor.ShowWindow();
})); }));
if (!m_DataFoldout) return; if (!m_DataFoldout) return;
@@ -97,6 +103,48 @@ namespace XCharts.Editor
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
} }
protected void PropertyFieldLinks()
{
m_LinksFoldout = ChartEditorHelper.DrawHeader("Links", m_LinksFoldout, false, null, null,
new HeaderMenuInfo("Import ECharts Link", () =>
{
//PraseExternalDataEditor.UpdateData(chart, serie, null, true);
//PraseExternalDataEditor.ShowWindow();
}));
if (!m_LinksFoldout) return;
EditorGUI.indentLevel++;
var m_Links = FindProperty("m_Links");
var listSize = m_Links.arraySize;
listSize = EditorGUILayout.IntField("Size", listSize);
if (listSize < 0) listSize = 0;
if (listSize != m_Links.arraySize)
{
while (listSize > m_Links.arraySize) m_Links.arraySize++;
while (listSize < m_Links.arraySize) m_Links.arraySize--;
}
if (listSize > 30) // && !XCSettings.editorShowAllListData)
{
int num = listSize > 10 ? 10 : listSize;
for (int i = 0; i < num; i++)
{
DrawSerieDataLink(m_Links, i);
}
if (num >= 10)
{
ChartEditorHelper.DrawHeader("... ", false, false, null, null);
DrawSerieDataLink(m_Links, listSize - 1);
}
}
else
{
for (int i = 0; i < m_Links.arraySize; i++)
{
DrawSerieDataLink(m_Links, i);
}
}
EditorGUI.indentLevel--;
}
protected void PropertyFiledMore(System.Action action) protected void PropertyFiledMore(System.Action action)
{ {
m_MoreFoldout = ChartEditorHelper.DrawHeader(MORE, m_MoreFoldout, false, null, null); m_MoreFoldout = ChartEditorHelper.DrawHeader(MORE, m_MoreFoldout, false, null, null);
@@ -118,7 +166,7 @@ namespace XCharts.Editor
var serieData = m_Datas.GetArrayElementAtIndex(index); var serieData = m_Datas.GetArrayElementAtIndex(index);
var dataIndex = serieData.FindPropertyRelative("m_Index").intValue; var dataIndex = serieData.FindPropertyRelative("m_Index").intValue;
m_DataElementFoldout[index] = ChartEditorHelper.DrawHeader("SerieData " + dataIndex, flag, false, null, m_DataElementFoldout[index] = ChartEditorHelper.DrawHeader("SerieData " + dataIndex, flag, false, null,
delegate(Rect drawRect) delegate (Rect drawRect)
{ {
//drawRect.width -= 2f; //drawRect.width -= 2f;
var maxX = drawRect.xMax; var maxX = drawRect.xMax;
@@ -242,5 +290,38 @@ namespace XCharts.Editor
} }
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
} }
private void DrawSerieDataLink(SerializedProperty m_Datas, int index)
{
bool flag;
if (!m_LinksElementFoldout.TryGetValue(index, out flag))
{
flag = false;
m_LinksElementFoldout[index] = false;
}
var dataLink = m_Datas.GetArrayElementAtIndex(index);
m_LinksElementFoldout[index] = ChartEditorHelper.DrawHeader("Link " + index, flag, false, null,
delegate (Rect drawRect)
{
var sourceIndex = dataLink.FindPropertyRelative("m_Source");
var targetIndex = dataLink.FindPropertyRelative("m_Target");
var value = dataLink.FindPropertyRelative("m_Value");
ChartEditorHelper.MakeThreeField(ref drawRect, drawRect.width, sourceIndex, targetIndex, value, "");
});
if (m_LinksElementFoldout[index])
{
DrawSerieDataLinkDetail(m_Datas, index);
}
}
private void DrawSerieDataLinkDetail(SerializedProperty m_Links, int index)
{
EditorGUI.indentLevel++;
var dataLink = m_Links.GetArrayElementAtIndex(index);
PropertyField(dataLink.FindPropertyRelative("m_Source"));
PropertyField(dataLink.FindPropertyRelative("m_Target"));
PropertyField(dataLink.FindPropertyRelative("m_Value"));
EditorGUI.indentLevel--;
}
} }
} }

View File

@@ -106,6 +106,23 @@ namespace XCharts.Editor
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
} }
public static void MakeThreeField(ref Rect drawRect, float rectWidth, SerializedProperty prop1,
SerializedProperty prop2, SerializedProperty prop3, string name)
{
EditorGUI.LabelField(drawRect, name);
var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH;
var diff = 13 + EditorGUI.indentLevel * 14;
var offset = diff - INDENT_WIDTH;
var tempWidth = (rectWidth - startX + diff) / 3;
var centerXRect = new Rect(startX, drawRect.y, tempWidth, drawRect.height - 1);
var centerYRect = new Rect(centerXRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1);
var centerZRect = new Rect(centerYRect.x + tempWidth - offset, drawRect.y, tempWidth - 1, drawRect.height - 1);
EditorGUI.PropertyField(centerXRect, prop1, GUIContent.none);
EditorGUI.PropertyField(centerYRect, prop2, GUIContent.none);
EditorGUI.PropertyField(centerZRect, prop3, GUIContent.none);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
public static void MakeVector2(ref Rect drawRect, float rectWidth, SerializedProperty prop, string name) public static void MakeVector2(ref Rect drawRect, float rectWidth, SerializedProperty prop, string name)
{ {
EditorGUI.LabelField(drawRect, name); EditorGUI.LabelField(drawRect, name);

View File

@@ -11,6 +11,7 @@ namespace XCharts.Editor
private static BaseChart s_Chart; private static BaseChart s_Chart;
private static Serie s_Serie; private static Serie s_Serie;
private static Axis s_Axis; private static Axis s_Axis;
private static bool s_LinksData;
private static PraseExternalDataEditor window; private static PraseExternalDataEditor window;
private static string inputJsonText = ""; private static string inputJsonText = "";
@@ -23,11 +24,12 @@ namespace XCharts.Editor
window.Show(); window.Show();
} }
public static void UpdateData(BaseChart chart, Serie serie, Axis axis) public static void UpdateData(BaseChart chart, Serie serie, Axis axis, bool linksData)
{ {
s_Chart = chart; s_Chart = chart;
s_Serie = serie; s_Serie = serie;
s_Axis = axis; s_Axis = axis;
s_LinksData = linksData;
inputJsonText = UnityEngine.GUIUtility.systemCopyBuffer; inputJsonText = UnityEngine.GUIUtility.systemCopyBuffer;
} }
@@ -97,7 +99,8 @@ namespace XCharts.Editor
{ {
arrayData = arrayData.Trim(); arrayData = arrayData.Trim();
if (!arrayData.StartsWith("data: Array")) return false; if (!arrayData.StartsWith("data: Array")) return false;
serie.ClearData(); if (s_LinksData) serie.ClearLinks();
else serie.ClearData();
var list = arrayData.Split('\n'); var list = arrayData.Split('\n');
for (int i = 1; i < list.Length; i++) for (int i = 1; i < list.Length; i++)
{ {
@@ -140,7 +143,8 @@ namespace XCharts.Editor
private static bool ParseJsonData(Serie serie, string jsonData) private static bool ParseJsonData(Serie serie, string jsonData)
{ {
if (!CheckJsonData(ref jsonData)) return false; if (!CheckJsonData(ref jsonData)) return false;
serie.ClearData(); if (s_LinksData) serie.ClearLinks();
else serie.ClearData();
if (jsonData.IndexOf("],") > -1 || jsonData.IndexOf("] ,") > -1) if (jsonData.IndexOf("],") > -1 || jsonData.IndexOf("] ,") > -1)
{ {
string[] datas = jsonData.Split(new string[] { "],", "] ," }, StringSplitOptions.RemoveEmptyEntries); string[] datas = jsonData.Split(new string[] { "],", "] ," }, StringSplitOptions.RemoveEmptyEntries);

View File

@@ -6,19 +6,35 @@ namespace XCharts.Runtime
[System.Serializable] [System.Serializable]
public class Level : ChildComponent public class Level : ChildComponent
{ {
[SerializeField][Since("v3.10.0")] private int m_Depth = 0;
[SerializeField] private LabelStyle m_Label = new LabelStyle(); [SerializeField] private LabelStyle m_Label = new LabelStyle();
[SerializeField] private LabelStyle m_UpperLabel = new LabelStyle(); [SerializeField] private LabelStyle m_UpperLabel = new LabelStyle();
[SerializeField][Since("v3.10.0")] private LineStyle m_LineStyle = new LineStyle();
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle(); [SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
/// <summary> /// <summary>
/// 文本标签样式。 /// the depth of level.
/// ||层级深度。
/// </summary>
public int depth { get { return m_Depth; } set { m_Depth = value; } }
/// <summary>
/// the label style of level.
/// ||文本标签样式。
/// </summary> /// </summary>
public LabelStyle label { get { return m_Label; } } public LabelStyle label { get { return m_Label; } }
/// <summary> /// <summary>
/// 上方的文本标签样式。 /// the upper label style of level.
/// ||上方的文本标签样式。
/// </summary> /// </summary>
public LabelStyle upperLabel { get { return m_UpperLabel; } } public LabelStyle upperLabel { get { return m_UpperLabel; } }
/// <summary> /// <summary>
/// 数据项样式。 /// the line style of level.
/// ||线条样式。
/// </summary>
public LineStyle lineStyle { get { return m_LineStyle; } }
/// <summary>
/// the item style of level.
/// ||数据项样式。
/// </summary> /// </summary>
public ItemStyle itemStyle { get { return m_ItemStyle; } } public ItemStyle itemStyle { get { return m_ItemStyle; } }
} }

View File

@@ -222,14 +222,15 @@ namespace XCharts.Runtime
public virtual void ClearData() public virtual void ClearData()
{ {
ClearSerieData(); ClearSerieData();
ClearSerieLinks();
ClearComponentData(); ClearComponentData();
} }
[Since("v3.4.0")]
/// <summary> /// <summary>
/// Clear the data of all series. /// Clear the data of all series.
/// ||清空所有serie的数据。 /// ||清空所有serie的数据。
/// </summary> /// </summary>
[Since("v3.4.0")]
public virtual void ClearSerieData() public virtual void ClearSerieData()
{ {
foreach (var serie in m_Series) foreach (var serie in m_Series)
@@ -238,11 +239,24 @@ namespace XCharts.Runtime
RefreshChart(); RefreshChart();
} }
[Since("v3.4.0")] /// <summary>
/// Clear the link data of all series.
/// ||清空所有serie的link数据。
/// </summary>
[Since("v3.10.0")]
public virtual void ClearSerieLinks()
{
foreach (var serie in m_Series)
serie.ClearLinks();
m_CheckAnimation = false;
RefreshChart();
}
/// <summary> /// <summary>
/// Clear the data of all components. /// Clear the data of all components.
/// ||清空所有组件的数据。 /// ||清空所有组件的数据。
/// </summary> /// </summary>
[Since("v3.4.0")]
public virtual void ClearComponentData() public virtual void ClearComponentData()
{ {
foreach (var component in m_Components) foreach (var component in m_Components)
@@ -625,13 +639,13 @@ namespace XCharts.Runtime
return theme.GetBackgroundColor(background); return theme.GetBackgroundColor(background);
} }
[Since("v3.4.0")]
/// <summary> /// <summary>
/// 获得Serie的标识颜色。 /// 获得Serie的标识颜色。
/// </summary> /// </summary>
/// <param name="serie"></param> /// <param name="serie"></param>
/// <param name="serieData"></param> /// <param name="serieData"></param>
/// <returns></returns> /// <returns></returns>
[Since("v3.4.0")]
public Color32 GetMarkColor(Serie serie, SerieData serieData) public Color32 GetMarkColor(Serie serie, SerieData serieData)
{ {
var itemStyle = SerieHelper.GetItemStyle(serie, serieData); var itemStyle = SerieHelper.GetItemStyle(serie, serieData);

View File

@@ -442,6 +442,27 @@ namespace XCharts.Runtime
return null; return null;
} }
/// <summary>
/// Add a link data to serie.
/// ||添加一个关系图的关系数据。
/// </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="value">the value of link</param>
/// <returns></returns>
public SerieDataLink AddLink(int serieIndex, string sourceName, string targetName, double value)
{
var serie = GetSerie(serieIndex);
if (serie != null)
{
var link = serie.AddLink(sourceName, targetName, value);
RefreshPainter(serie.painter);
return link;
}
return null;
}
/// <summary> /// <summary>
/// Update serie data by serie name. /// Update serie data by serie name.
/// ||更新指定系列中的指定索引数据。 /// ||更新指定系列中的指定索引数据。

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fcb8d4f1ad56b432f8a8eae9fa5941b3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,412 @@
using System.Collections.Generic;
using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// the data struct of graph.
/// ||数据结构-图。
/// </summary>
public class Graph
{
public bool directed;
public List<GraphNode> nodes = new List<GraphNode>();
public List<GraphEdge> edges = new List<GraphEdge>();
public Dictionary<string, GraphNode> nodeMap = new Dictionary<string, GraphNode>();
public Dictionary<string, GraphEdge> edgeMap = new Dictionary<string, GraphEdge>();
public Graph(bool directed)
{
this.directed = directed;
}
public void Clear()
{
nodes.Clear();
edges.Clear();
nodeMap.Clear();
edgeMap.Clear();
}
public void Refresh()
{
foreach (var node in nodes)
{
node.depth = GetNodeDepth(node);
}
}
public static double GetNodesTotalValue(List<GraphNode> nodes)
{
double totalValue = 0;
foreach (var node in nodes)
{
totalValue += node.totalValues;
}
return totalValue;
}
public List<List<GraphNode>> GetDepthNodes()
{
List<List<GraphNode>> depthNodes = new List<List<GraphNode>>();
var maxDepth = GetMaxDepth();
for (int i = 0; i <= maxDepth; i++)
{
depthNodes.Add(new List<GraphNode>());
}
foreach (var node in nodes)
{
if (node.inDegree == 0)
{
depthNodes[0].Add(node);
}
else
{
int deep = GetNodeDepth(node);
depthNodes[maxDepth - deep].Add(node);
}
}
return depthNodes;
}
public List<GraphNode> GetRootNodes()
{
List<GraphNode> rootNodes = new List<GraphNode>();
foreach (var node in nodes)
{
if (node.inDegree == 0)
{
rootNodes.Add(node);
}
}
return rootNodes;
}
public int GetMaxDepth()
{
int maxDepth = 0;
foreach (var node in nodes)
{
int deep = GetNodeDepth(node);
if (deep > maxDepth)
{
maxDepth = deep;
}
}
return maxDepth;
}
// public int GetNodeDepth(GraphNode node)
// {
// int depth = 0;
// GetNodeDepth(node, ref depth);
// return depth;
// }
// public void GetNodeDepth(GraphNode node, ref int depth, int recursiveCount = 0)
// {
// if (recursiveCount > 50)
// {
// XLog.Error("Graph.GetNodeDeep(): recursiveCount > 50, maybe graph is ring");
// return;
// }
// if (node.inDegree == 0)
// {
// return;
// }
// else
// {
// depth += 1;
// foreach (var edge in node.inEdges)
// {
// GetNodeDepth(edge.node1, ref depth, recursiveCount + 1);
// }
// }
// }
public int GetNodeDepth(GraphNode node, int recursiveCount = 0)
{
if (recursiveCount > 50)
{
XLog.Error("Graph.GetNodeDeep(): recursiveCount > 50, maybe graph is ring");
return 0;
}
int depth = 0;
if (node.outDegree == 0)
{
return depth;
}
else
{
foreach (var edge in node.outEdges)
{
int otherDeep = GetNodeDepth(edge.node2, recursiveCount + 1);
if (otherDeep > depth)
{
depth = otherDeep;
}
}
return depth + 1;
}
}
public GraphNode GetNode(string nodeId)
{
if (nodeMap.ContainsKey(nodeId))
{
return nodeMap[nodeId];
}
else
{
return null;
}
}
public GraphEdge GetEdge(string nodeId1, string nodeId2)
{
if (directed)
{
return edgeMap[nodeId1 + "_" + nodeId2];
}
else
{
var key = nodeId1 + "_" + nodeId2;
if (edgeMap.ContainsKey(key))
{
return edgeMap[key];
}
else
{
key = nodeId2 + "_" + nodeId1;
if (edgeMap.ContainsKey(key))
{
return edgeMap[key];
}
else
{
return null;
}
}
}
}
public GraphNode AddNode(string nodeId, string nodeName, int dataIndex)
{
if (nodeMap.ContainsKey(nodeId))
{
return nodeMap[nodeId];
}
else
{
GraphNode node = new GraphNode(nodeId, nodeName, dataIndex);
node.hostGraph = this;
nodeMap.Add(nodeId, node);
nodes.Add(node);
return node;
}
}
public GraphEdge AddEdge(string nodeId1, string nodeId2, double value)
{
GraphNode node1, node2;
if (!nodeMap.TryGetValue(nodeId1, out node1))
{
XLog.Warning("Graph.AddEdge(): " + nodeId1 + " not exist");
return null;
}
if (!nodeMap.TryGetValue(nodeId2, out node2))
{
XLog.Warning("Graph.AddEdge(): " + nodeId2 + " not exist");
return null;
}
if (node1 == null)
{
XLog.Warning("Graph.AddEdge(): node1 is null");
return null;
}
if (node2 == null)
{
XLog.Warning("Graph.AddEdge(): node2 is null");
return null;
}
if (node1 == node2)
{
XLog.Warning("Graph.AddEdge(): node1 == node2");
return null;
}
string edgeKey = nodeId1 + "_" + nodeId2;
if (edgeMap.ContainsKey(edgeKey))
{
return edgeMap[edgeKey];
}
else
{
GraphEdge edge = new GraphEdge(node1, node2, value);
edge.key = edgeKey;
edge.hostGraph = this;
if (directed)
{
node1.outEdges.Add(edge);
node2.inEdges.Add(edge);
}
node1.edges.Add(edge);
if (node1 != node2)
{
node2.edges.Add(edge);
}
edgeMap.Add(edgeKey, edge);
edges.Add(edge);
return edge;
}
}
public void EachNode(System.Action<GraphNode> onEach)
{
if (onEach == null) return;
foreach (var node in nodes)
{
onEach(node);
}
}
public void BreadthFirstTraverse(GraphNode startNode, System.Action<GraphNode> onTraverse)
{
if (startNode == null) return;
foreach (var node in nodes)
{
node.visited = false;
}
onTraverse(startNode);
startNode.visited = true;
Queue<GraphNode> queue = new Queue<GraphNode>();
queue.Enqueue(startNode);
while (queue.Count > 0)
{
var currentNode = queue.Dequeue();
foreach (var edge in currentNode.edges)
{
var otherNode = edge.node1 == currentNode ? edge.node2 : edge.node1;
if (!otherNode.visited)
{
onTraverse(otherNode);
otherNode.visited = true;
queue.Enqueue(otherNode);
}
}
}
}
public void DeepFirstTraverse(GraphNode startNode, System.Action<GraphNode> onTraverse)
{
if (startNode == null) return;
foreach (var node in nodes)
{
node.visited = false;
}
Stack<GraphNode> stack = new Stack<GraphNode>();
stack.Push(startNode);
while (stack.Count > 0)
{
var currentNode = stack.Pop();
if (!currentNode.visited)
{
onTraverse(currentNode);
currentNode.visited = true;
}
foreach (var edge in currentNode.edges)
{
var otherNode = edge.node1 == currentNode ? edge.node2 : edge.node1;
if (!otherNode.visited)
{
stack.Push(otherNode);
}
}
}
}
}
/// <summary>
/// The node of graph.
/// ||图的节点。
/// </summary>
public class GraphNode
{
public string id;
public string name;
public List<GraphEdge> edges = new List<GraphEdge>();
public List<GraphEdge> inEdges = new List<GraphEdge>();
public List<GraphEdge> outEdges = new List<GraphEdge>();
public Graph hostGraph;
public int dataIndex;
public bool visited;
public int depth = -1;
public GraphNode(string id, string name, int dataIndex)
{
this.id = id;
this.name = name;
this.dataIndex = dataIndex;
}
public int degree { get { return edges.Count; } }
public int inDegree { get { return inEdges.Count; } }
public int outDegree { get { return outEdges.Count; } }
public double totalValues
{
get
{
double totalValue = 0;
if (inEdges.Count == 0)
{
foreach (var edge in outEdges)
{
totalValue += edge.value;
}
}
else
{
foreach (var edge in inEdges)
{
totalValue += edge.value;
}
}
return totalValue;
}
}
public override string ToString()
{
return name;
}
}
/// <summary>
/// The edge of graph.
/// ||图的边。
/// </summary>
public class GraphEdge
{
public string key;
public GraphNode node1;
public GraphNode node2;
public double value;
public Graph hostGraph;
public GraphEdge(GraphNode node1, GraphNode node2, double value)
{
this.node1 = node1;
this.node2 = node2;
this.value = value;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d778205a63524227a09c7e5b0e8736f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -309,6 +309,7 @@ namespace XCharts.Runtime
[SerializeField] private AnimationStyle m_Animation = new AnimationStyle(); [SerializeField] private AnimationStyle m_Animation = new AnimationStyle();
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle(); [SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
[SerializeField] private List<SerieData> m_Data = new List<SerieData>(); [SerializeField] private List<SerieData> m_Data = new List<SerieData>();
[SerializeField] private List<SerieDataLink> m_Links = new List<SerieDataLink>();
[NonSerialized] internal int m_FilterStart; [NonSerialized] internal int m_FilterStart;
[NonSerialized] internal int m_FilterEnd; [NonSerialized] internal int m_FilterEnd;
@@ -966,6 +967,10 @@ namespace XCharts.Runtime
/// </summary> /// </summary>
public List<SerieData> data { get { return m_Data; } } public List<SerieData> data { get { return m_Data; } }
/// <summary> /// <summary>
/// 数据节点的边。
/// </summary>
public List<SerieDataLink> links { get { return m_Links; } }
/// <summary>
/// 取色策略是否为按数据项分配。 /// 取色策略是否为按数据项分配。
/// </summary> /// </summary>
public bool colorByData { get { return colorBy == SerieColorBy.Data; } } public bool colorByData { get { return colorBy == SerieColorBy.Data; } }
@@ -1271,6 +1276,15 @@ namespace XCharts.Runtime
SetVerticesDirty(); SetVerticesDirty();
} }
/// <summary>
/// 清空所有Link数据
/// </summary>
public void ClearLinks()
{
m_Links.Clear();
SetVerticesDirty();
}
/// <summary> /// <summary>
/// 移除指定索引的数据 /// 移除指定索引的数据
/// </summary> /// </summary>
@@ -1504,6 +1518,26 @@ namespace XCharts.Runtime
} }
} }
/// <summary>
/// Add a link data.
/// ||添加一个关系图的关系数据。
/// </summary>
/// <param name="sourceName"></param>
/// <param name="targetName"></param>
/// <param name="value"></param>
/// <returns></returns>
public SerieDataLink AddLink(string sourceName, string targetName, double value)
{
var link = new SerieDataLink();
link.source = sourceName;
link.target = targetName;
link.value = value;
m_Links.Add(link);
SetVerticesDirty();
labelDirty = true;
return link;
}
private void CheckMaxCache() private void CheckMaxCache()
{ {
if (m_MaxCache <= 0) return; if (m_MaxCache <= 0) return;

View File

@@ -69,6 +69,8 @@ namespace XCharts.Runtime
} }
private bool m_Highligth; private bool m_Highligth;
public bool selected; public bool selected;
public double inTotalValue;
public double outTotalValue;
public void Reset() public void Reset()
{ {

View File

@@ -0,0 +1,47 @@
using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// the link of serie data. Used for sankey chart. Sankey chart only supports directed acyclic graph. make sure the data link is directed acyclic graph.
/// ||数据节点之间的连线。可用于桑基图等,桑基图只支持有向无环图,请保证数据的连线是有向无环图。
/// </summary>
[System.Serializable]
[Since("v3.10.0")]
public class SerieDataLink : ChildComponent
{
[SerializeField] private string m_Source;
[SerializeField] private string m_Target;
[SerializeField] private double m_Value;
/// <summary>
/// the source node name.
/// ||边的源节点名称。
/// </summary>
public string source
{
get { return m_Source; }
set { m_Source = value; }
}
/// <summary>
/// the target node name.
/// ||边的目标节点名称。
/// </summary>
public string target
{
get { return m_Target; }
set { m_Target = value; }
}
/// <summary>
/// the value of link. decide the width of link.
/// ||边的值。决定边的宽度。
/// </summary>
public double value
{
get { return m_Value; }
set { m_Value = value; }
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7402f12ebc4aa4421939efecae53624d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -31,6 +31,7 @@ namespace XCharts.Runtime
public virtual void OnBeginDrag(PointerEventData eventData) { } public virtual void OnBeginDrag(PointerEventData eventData) { }
public virtual void OnEndDrag(PointerEventData eventData) { } public virtual void OnEndDrag(PointerEventData eventData) { }
public virtual void OnScroll(PointerEventData eventData) { } public virtual void OnScroll(PointerEventData eventData) { }
public virtual void OnDataUpdate() { }
public virtual void RefreshLabelNextFrame() { } public virtual void RefreshLabelNextFrame() { }
public virtual void RefreshLabelInternal() { } public virtual void RefreshLabelInternal() { }
public virtual void ForceUpdateSerieContext() { } public virtual void ForceUpdateSerieContext() { }
@@ -38,7 +39,8 @@ namespace XCharts.Runtime
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory, public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory,
string category, string marker, string category, string marker,
string itemFormatter, string numericFormatter, string ignoreDataDefaultContent, string itemFormatter, string numericFormatter, string ignoreDataDefaultContent,
ref List<SerieParams> paramList, ref string title) { } ref List<SerieParams> paramList, ref string title)
{ }
public virtual void OnLegendButtonClick(int index, string legendName, bool show) { } public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }
public virtual void OnLegendButtonEnter(int index, string legendName) { } public virtual void OnLegendButtonEnter(int index, string legendName) { }
public virtual void OnLegendButtonExit(int index, string legendName) { } public virtual void OnLegendButtonExit(int index, string legendName) { }
@@ -76,7 +78,7 @@ namespace XCharts.Runtime
internal override void SetSerie(Serie serie) internal override void SetSerie(Serie serie)
{ {
this.serie = (T) serie; this.serie = (T)serie;
this.serie.context.param.serieType = typeof(T); this.serie.context.param.serieType = typeof(T);
m_NeedInitComponent = true; m_NeedInitComponent = true;
AnimationStyleHelper.UpdateSerieAnimation(serie); AnimationStyleHelper.UpdateSerieAnimation(serie);
@@ -107,6 +109,7 @@ namespace XCharts.Runtime
} }
if (serie.dataDirty) if (serie.dataDirty)
{ {
OnDataUpdate();
SeriesHelper.UpdateSerieNameList(chart, ref chart.m_LegendRealShowName); SeriesHelper.UpdateSerieNameList(chart, ref chart.m_LegendRealShowName);
chart.OnSerieDataUpdate(serie.index); chart.OnSerieDataUpdate(serie.index);
serie.OnDataUpdate(); serie.OnDataUpdate();
@@ -387,7 +390,7 @@ namespace XCharts.Runtime
return; return;
} }
InitRoot(); InitRoot();
var dataAutoColor = (Color) chart.GetLegendRealShowNameColor(serie.legendName); var dataAutoColor = (Color)chart.GetLegendRealShowNameColor(serie.legendName);
m_EndLabel = ChartHelper.AddChartLabel(s_SerieEndLabelObjectName, m_SerieRoot.transform, serie.endLabel, m_EndLabel = ChartHelper.AddChartLabel(s_SerieEndLabelObjectName, m_SerieRoot.transform, serie.endLabel,
chart.theme.common, "", dataAutoColor, TextAnchor.MiddleLeft); chart.theme.common, "", dataAutoColor, TextAnchor.MiddleLeft);
m_EndLabel.SetActive(serie.endLabel.show); m_EndLabel.SetActive(serie.endLabel.show);
@@ -599,7 +602,7 @@ namespace XCharts.Runtime
var colorIndex = serie.colorByData ? serieData.index : serie.index; var colorIndex = serie.colorByData ? serieData.index : serie.index;
Color32 color, toColor; Color32 color, toColor;
SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal, false); SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal, false);
return (Color) color; return (Color)color;
} }
protected void UpdateCoordSerieParams(ref List<SerieParams> paramList, ref string title, protected void UpdateCoordSerieParams(ref List<SerieParams> paramList, ref string title,