From 99b1624b549c8d242c15afc1ab2ec83dd9975f86 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 20 Mar 2024 08:31:05 +0800 Subject: [PATCH 01/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=9B=BE=E7=9A=84=E6=8A=98=E5=8F=A0=E5=92=8C=E5=B1=95=E5=BC=80?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/en/api.md | 11 ++- Documentation~/zh/api.md | 11 ++- .../Internal/Data/{Graph.cs => GraphData.cs} | 75 ++++++++++++++++--- .../Data/{Graph.cs.meta => GraphData.cs.meta} | 2 +- Runtime/Serie/SerieDataContext.cs | 15 ++-- 5 files changed, 87 insertions(+), 27 deletions(-) rename Runtime/Internal/Data/{Graph.cs => GraphData.cs} (84%) rename Runtime/Internal/Data/{Graph.cs.meta => GraphData.cs.meta} (83%) diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index e9ee5cd8..4b9da63d 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -80,7 +80,7 @@ slug: /api - [EmphasisStyle](#emphasisstyle) - [EndLabelStyle](#endlabelstyle) - [FormatterHelper](#formatterhelper) -- [Graph](#graph) +- [GraphData](#graphdata) - [GraphEdge](#graphedge) - [GraphNode](#graphnode) - [GridCoord](#gridcoord) @@ -1410,7 +1410,7 @@ Configurations of emphasis state. |TrimAndReplaceLine()||public static string TrimAndReplaceLine(string content)| |TrimAndReplaceLine()||public static string TrimAndReplaceLine(StringBuilder sb)| -## Graph +## GraphData > class in XCharts.Runtime @@ -1424,6 +1424,8 @@ the data struct of graph. |Clear()||public void Clear()| |DeepFirstTraverse()||public void DeepFirstTraverse(GraphNode startNode, System.Action<GraphNode> onTraverse)| |EachNode()||public void EachNode(System.Action<GraphNode> onEach)| +|ExpandAllNodes()||public void ExpandAllNodes(bool flag, int level = -1)| +|ExpandNode()||public void ExpandNode(string nodeId, bool flag)| |GetDepthNodes()||public List<List<GraphNode>> GetDepthNodes()| |GetEdge()||public GraphEdge GetEdge(string nodeId1, string nodeId2)| |GetMaxDepth()||public int GetMaxDepth()| @@ -1433,7 +1435,7 @@ the data struct of graph. |GetNodeDepth()||public int GetNodeDepth(GraphNode node, int recursiveCount = 0)| |GetNodesTotalValue()||public static double GetNodesTotalValue(List<GraphNode> nodes)| |GetRootNodes()||public List<GraphNode> GetRootNodes()| -|Graph()||public Graph(bool directed)| +|GraphData()||public GraphData(bool directed)| |Refresh()||public void Refresh()| ## GraphEdge @@ -1454,7 +1456,10 @@ The node of graph. |public method|since|description| |--|--|--| +|Expand()||public void Expand(bool flag)| |GraphNode()||public GraphNode(string id, string name, int dataIndex)| +|IsAllInEdgesCollapsed()||public bool IsAllInEdgesCollapsed()| +|IsAnyInEdgesExpanded()||public bool IsAnyInEdgesExpanded()| |ToString()||public override string ToString()| ## GridCoord diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index cd862f3d..910ab3d5 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -80,7 +80,7 @@ slug: /api - [EmphasisStyle](#emphasisstyle) - [EndLabelStyle](#endlabelstyle) - [FormatterHelper](#formatterhelper) -- [Graph](#graph) +- [GraphData](#graphdata) - [GraphEdge](#graphedge) - [GraphNode](#graphnode) - [GridCoord](#gridcoord) @@ -1410,7 +1410,7 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息 |TrimAndReplaceLine()||public static string TrimAndReplaceLine(string content)| |TrimAndReplaceLine()||public static string TrimAndReplaceLine(StringBuilder sb)| -## Graph +## GraphData > class in XCharts.Runtime @@ -1424,6 +1424,8 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息 |Clear()||public void Clear()| |DeepFirstTraverse()||public void DeepFirstTraverse(GraphNode startNode, System.Action<GraphNode> onTraverse)| |EachNode()||public void EachNode(System.Action<GraphNode> onEach)| +|ExpandAllNodes()||public void ExpandAllNodes(bool flag, int level = -1)| +|ExpandNode()||public void ExpandNode(string nodeId, bool flag)| |GetDepthNodes()||public List<List<GraphNode>> GetDepthNodes()| |GetEdge()||public GraphEdge GetEdge(string nodeId1, string nodeId2)| |GetMaxDepth()||public int GetMaxDepth()| @@ -1433,7 +1435,7 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息 |GetNodeDepth()||public int GetNodeDepth(GraphNode node, int recursiveCount = 0)| |GetNodesTotalValue()||public static double GetNodesTotalValue(List<GraphNode> nodes)| |GetRootNodes()||public List<GraphNode> GetRootNodes()| -|Graph()||public Graph(bool directed)| +|GraphData()||public GraphData(bool directed)| |Refresh()||public void Refresh()| ## GraphEdge @@ -1454,7 +1456,10 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息 |API|版本|描述| |--|--|--| +|Expand()||public void Expand(bool flag)| |GraphNode()||public GraphNode(string id, string name, int dataIndex)| +|IsAllInEdgesCollapsed()||public bool IsAllInEdgesCollapsed()| +|IsAnyInEdgesExpanded()||public bool IsAnyInEdgesExpanded()| |ToString()||public override string ToString()| ## GridCoord diff --git a/Runtime/Internal/Data/Graph.cs b/Runtime/Internal/Data/GraphData.cs similarity index 84% rename from Runtime/Internal/Data/Graph.cs rename to Runtime/Internal/Data/GraphData.cs index 496301a3..b7ea07d8 100644 --- a/Runtime/Internal/Data/Graph.cs +++ b/Runtime/Internal/Data/GraphData.cs @@ -7,7 +7,7 @@ namespace XCharts.Runtime /// the data struct of graph. /// ||数据结构-图。 /// - public class Graph + public class GraphData { public bool directed; public List nodes = new List(); @@ -16,7 +16,7 @@ namespace XCharts.Runtime public Dictionary nodeMap = new Dictionary(); public Dictionary edgeMap = new Dictionary(); - public Graph(bool directed) + public GraphData(bool directed) { this.directed = directed; } @@ -108,7 +108,7 @@ namespace XCharts.Runtime // { // if (recursiveCount > 50) // { - // XLog.Error("Graph.GetNodeDeep(): recursiveCount > 50, maybe graph is ring"); + // XLog.Error("GraphData.GetNodeDeep(): recursiveCount > 50, maybe graph is ring"); // return; // } // if (node.inDegree == 0) @@ -129,7 +129,7 @@ namespace XCharts.Runtime { if (recursiveCount > 50) { - XLog.Error("Graph.GetNodeDeep(): recursiveCount > 50, maybe graph is ring"); + XLog.Error("GraphData.GetNodeDeep(): recursiveCount > 50, maybe graph is ring"); return 0; } int depth = 0; @@ -214,27 +214,27 @@ namespace XCharts.Runtime GraphNode node1, node2; if (!nodeMap.TryGetValue(nodeId1, out node1)) { - XLog.Warning("Graph.AddEdge(): " + nodeId1 + " not exist"); + XLog.Warning("GraphData.AddEdge(): " + nodeId1 + " not exist"); return null; } if (!nodeMap.TryGetValue(nodeId2, out node2)) { - XLog.Warning("Graph.AddEdge(): " + nodeId2 + " not exist"); + XLog.Warning("GraphData.AddEdge(): " + nodeId2 + " not exist"); return null; } if (node1 == null) { - XLog.Warning("Graph.AddEdge(): node1 is null"); + XLog.Warning("GraphData.AddEdge(): node1 is null"); return null; } if (node2 == null) { - XLog.Warning("Graph.AddEdge(): node2 is null"); + XLog.Warning("GraphData.AddEdge(): node2 is null"); return null; } if (node1 == node2) { - XLog.Warning("Graph.AddEdge(): node1 == node2"); + XLog.Warning("GraphData.AddEdge(): node1 == node2"); return null; } string edgeKey = nodeId1 + "_" + nodeId2; @@ -331,6 +331,26 @@ namespace XCharts.Runtime } } } + + public void ExpandNode(string nodeId, bool flag) + { + var node = GetNode(nodeId); + if (node != null) + { + node.Expand(flag); + } + } + + public void ExpandAllNodes(bool flag, int level = -1) + { + foreach (var node in nodes) + { + if (level < 0 || node.level == level) + { + node.Expand(flag); + } + } + } } /// @@ -344,10 +364,12 @@ namespace XCharts.Runtime public List edges = new List(); public List inEdges = new List(); public List outEdges = new List(); - public Graph hostGraph; + public GraphData hostGraph; public int dataIndex; public bool visited; public int depth = -1; + public bool expand = true; + public int level = 0; public GraphNode(string id, string name, int dataIndex) { @@ -388,6 +410,36 @@ namespace XCharts.Runtime { return name; } + + public bool IsAllInEdgesCollapsed() + { + if (inEdges.Count == 0) return false; + foreach (var edge in inEdges) + { + if (!edge.expand) return false; + } + return true; + } + + public bool IsAnyInEdgesExpanded() + { + if (inEdges.Count == 0) return true; + foreach (var edge in inEdges) + { + if (edge.expand) return true; + } + return false; + } + + public void Expand(bool flag) + { + if (expand == flag) return; + expand = flag; + foreach (var edge in outEdges) + { + edge.expand = flag; + } + } } /// @@ -400,11 +452,12 @@ namespace XCharts.Runtime public GraphNode node1; public GraphNode node2; public double value; - public Graph hostGraph; + public GraphData hostGraph; public List points = new List(); public float width; public bool highlight; + public bool expand = true; public GraphEdge(GraphNode node1, GraphNode node2, double value) { diff --git a/Runtime/Internal/Data/Graph.cs.meta b/Runtime/Internal/Data/GraphData.cs.meta similarity index 83% rename from Runtime/Internal/Data/Graph.cs.meta rename to Runtime/Internal/Data/GraphData.cs.meta index 67978019..bb2ee871 100644 --- a/Runtime/Internal/Data/Graph.cs.meta +++ b/Runtime/Internal/Data/GraphData.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 1d778205a63524227a09c7e5b0e8736f +guid: 9d8951dd10b1247c9baf8515b3a22771 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/Serie/SerieDataContext.cs b/Runtime/Serie/SerieDataContext.cs index d8a7e114..0e99efa0 100644 --- a/Runtime/Serie/SerieDataContext.cs +++ b/Runtime/Serie/SerieDataContext.cs @@ -59,16 +59,13 @@ namespace XCharts.Runtime /// Whether the data item is highlighted. /// ||该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。 /// - public bool highlight - { - get { return m_Highligth; } - set - { - m_Highligth = value; - } - } - private bool m_Highligth; + public bool highlight; public bool selected; + /// + /// the id of the node in the graph. + /// ||图中节点的id。 + /// + public string graphNodeId; public double inTotalValue; public double outTotalValue; From 0990b11c1c26622ff33a3a2060441863c225bd1f Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 20 Mar 2024 13:34:21 +0800 Subject: [PATCH 02/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`Tooltip`=E7=9A=84`trig?= =?UTF-8?q?gerOn`=E6=8C=87=E5=AE=9A=E8=A7=A6=E5=8F=91=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/en/api.md | 2 + Documentation~/en/configuration.md | 1 + Documentation~/zh/api.md | 2 + Documentation~/zh/changelog.md | 2 + Documentation~/zh/configuration.md | 1 + Editor/MainComponents/TooltipEditor.cs | 1 + Examples/Example01_RandomData.cs | 67 +++++++-- Runtime/Component/Axis/XAxis/XAxisHander.cs | 24 +++- Runtime/Component/Tooltip/Tooltip.cs | 33 +++++ Runtime/Component/Tooltip/TooltipContext.cs | 1 + Runtime/Component/Tooltip/TooltipHandler.cs | 143 +++++++++++++++----- Runtime/Internal/BaseChart.API.cs | 23 +++- Runtime/Internal/BaseGraph.API.cs | 11 +- Runtime/Internal/BaseGraph.cs | 25 +++- Runtime/Serie/SerieContext.cs | 1 + Runtime/Serie/SerieHandler.cs | 1 + package.json | 6 +- 17 files changed, 284 insertions(+), 60 deletions(-) diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index 4b9da63d..6b971eb0 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -835,6 +835,7 @@ Bar chart shows different data through the height of a bar, which is used in rec |ResetChartStatus()|v3.10.0|public void ResetChartStatus()
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)
重置serie的数据项索引。避免数据项索引异常。 | |SetBasePainterMaterial()||public void SetBasePainterMaterial(Material material)
设置Base Painter的材质球 | +|SetInsertDataToHead()|v3.11.0|public void SetInsertDataToHead(bool insertDataToHead)
set insert data to head. | |SetMaxCache()||public void SetMaxCache(int maxCache)
设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 | |SetPainterActive()||public void SetPainterActive(int index, bool flag)| |SetSerieActive()||public void SetSerieActive(int serieIndex, bool active)
Whether to show serie. | @@ -3093,6 +3094,7 @@ Tooltip component. |public method|since|description| |--|--|--| +|onClickIndex||public System.Action<int> onClickIndex
the callback of tooltip click index. | |AddSerieDataIndex()||public void AddSerieDataIndex(int serieIndex, int dataIndex)| |ClearComponentDirty()||public override void ClearComponentDirty()| |ClearData()||public override void ClearData()| diff --git a/Documentation~/en/configuration.md b/Documentation~/en/configuration.md index ecdbbd29..3d34f3f9 100644 --- a/Documentation~/en/configuration.md +++ b/Documentation~/en/configuration.md @@ -2302,6 +2302,7 @@ Tooltip component. |show|true||Whether to show the tooltip component. |type|||Indicator type.
`Tooltip.Type`:
- `Line`: line indicator.
- `Shadow`: shadow crosshair indicator.
- `None`: no indicator displayed.
- `Corss`: crosshair indicator, which is actually the shortcut of enable two axisPointers of two orthometric axes.
- `Auto`: Auto select indicator according to serie type.
| |trigger|||Type of triggering.
`Tooltip.Trigger`:
- `Item`: Triggered by data item, which is mainly used for charts that don't have a category axis like scatter charts or pie charts.
- `Axis`: Triggered by axes, which is mainly used for charts that have category axes, like bar charts or line charts.
- `None`: Trigger nothing.
- `Auto`: Auto select trigger according to serie type.
| +|triggerOn||v3.11.0|Condition of trigger tooltip.
`Tooltip.TriggerOn`:
- `MouseMove`: Trigger when mouse move.
- `Click`: Trigger when mouse click.
| |position||v3.3.0|Type of position.
`Tooltip.Position`:
- `Auto`: Auto. The mobile platform is displayed at the top, and the non-mobile platform follows the mouse position.
- `Custom`: Custom. Fully customize display position (x,y).
- `FixedX`: Just fix the coordinate X. Y follows the mouse position.
- `FixedY`:
| |itemFormatter|||a string template formatter for a single Serie or data item content. Support for wrapping lines with \n. Template variables are {.}, {a}, {b}, {c}, {d}.
{.} is the dot of the corresponding color of a Serie that is currently indicated or whose index is 0.
{a} is the series name of the serie that is currently indicated or whose index is 0.
{b} is the name of the data item serieData that is currently indicated or whose index is 0, or a category value (such as the X-axis of a line chart).
{c} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0.
{d} is the percentage value of Y-dimensions (dimesion is 1) from serie that is currently indicated or whose index is 0, with no % sign.
{e} is the name of the data item serieData that is currently indicated or whose index is 0.
{f} is sum of data.
{y} is category value of y axis.
{.1} represents a dot from serie corresponding color that specifies index as 1.
1 in {a1}, {b1}, {c1} represents a serie that specifies an index of 1.
{c1:2} represents the third data from serie's current indication data item indexed to 1 (a data item has multiple data, index 2 represents the third data).
{c1:2-2} represents the third data item from serie's third data item indexed to 1 (i.e., which data item must be specified to specify).
{d1:2: F2} indicates that a formatted string with a value specified separately is F2 (numericFormatter is used when numericFormatter is not specified).
{d:0.##} indicates that a formatted string with a value specified separately is 0.## (used for percentage, reserved 2 valid digits while avoiding the situation similar to "100.00%" when using f2 ).
Example: "{a}, {c}", "{a1}, {c1: f1}", "{a1}, {c1:0: f1}", "{a1} : {c1:1-1: f1}"
|titleFormatter|||String template formatter for tooltip title content. \n line wrapping is supported. The placeholder {i} can be set separately to indicate that title is ignored and not displayed. Template variables are {.}, {a}, {b}, {c}, {d}, {e}, {f}, and {g}.
{.} is the dot of the corresponding color of serie currently indicated or index 0.
{a} is the series name name of serie currently indicated or index 0.
{b} is the name of the serie data item serieData currently indicated or index 0, or the category value (such as the X-axis of a line chart).
{c} is the value of the serie y-dimension (dimesion is 1) currently indicated or index is 0.
{d} is the serie y-dimensional (dimesion 1) percentage value of the currently indicated or index 0, note without the % sign.
{e} is the name of the serie data item serieData currently indicated or whose index is 0.
{h} is the hexadecimal color value of serieData for the serie data item currently indicated or index 0.
{f} is the sum of data.
{g} indicates the total number of data.
{y} is category value of y axis.
{.1} represents a dot of the corresponding color with serie specified as index 1.
The 1 in {a1}, {b1}, {c1} represents serie where index is specified as 1.
{c1:2} represents the third data of the current indicator data item in serie with index 1 (one data item has multiple data, index 2 represents the third data).
{c1:2-2} represents the third data of serie third data item with index 1 (that is, the number of data items must be specified when specifying the number of data items).
{d1:2:f2} indicates that a format string with a single value is f2 (numericFormatter is used if no value is specified).
{d:0.##} indicates that the format string with a value specified alone is 0.## # (for percentages, preserving a 2-digit significant number while avoiding the "100.00%" situation with f2).
example: "{a}, {c}", "{a1}, {c1: f1}", "{a1}, {c1:0: f1}", "{a1}, {c1:1-1: f1}" diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index 910ab3d5..8955a3ac 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -835,6 +835,7 @@ slug: /api |ResetChartStatus()|v3.10.0|public void ResetChartStatus()
重置图表状态。当设置某些参数后,由于动画影响,可能导致图表状态不正确,此时可以调用该接口重置图表状态。 | |ResetDataIndex()||public bool ResetDataIndex(int serieIndex)
重置serie的数据项索引。避免数据项索引异常。 | |SetBasePainterMaterial()||public void SetBasePainterMaterial(Material material)
设置Base Painter的材质球 | +|SetInsertDataToHead()|v3.11.0|public void SetInsertDataToHead(bool insertDataToHead)
设置数据插入到头部。 | |SetMaxCache()||public void SetMaxCache(int maxCache)
设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 | |SetPainterActive()||public void SetPainterActive(int index, bool flag)| |SetSerieActive()||public void SetSerieActive(int serieIndex, bool active)
设置指定系列是否显示。 | @@ -3093,6 +3094,7 @@ Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种 |API|版本|描述| |--|--|--| +|onClickIndex||public System.Action<int> onClickIndex
Tooltip为Click触发时,点击的X轴索引的回调。 | |AddSerieDataIndex()||public void AddSerieDataIndex(int serieIndex, int dataIndex)| |ClearComponentDirty()||public override void ClearComponentDirty()| |ClearData()||public override void ClearData()| diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 8656fed8..03fd4317 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,8 @@ slug: /changelog ## master +* (2024.03.20) 增加`Tooltip`的`triggerOn`设置触发条件 + ## v3.10.2 * (2024.03.11) 发布`v3.10.2`版本 diff --git a/Documentation~/zh/configuration.md b/Documentation~/zh/configuration.md index 885954ea..db80a6fe 100644 --- a/Documentation~/zh/configuration.md +++ b/Documentation~/zh/configuration.md @@ -2231,6 +2231,7 @@ Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种 |show|true||是否显示提示框组件。 |type|||提示框指示器类型。
`Tooltip.Type`:
- `Line`: 直线指示器
- `Shadow`: 阴影指示器
- `None`: 无指示器
- `Corss`: 十字准星指示器。坐标轴显示Label和交叉线。
- `Auto`: 根据serie的类型自动选择显示指示器。
| |trigger|||触发类型。
`Tooltip.Trigger`:
- `Item`: 数据项图形触发,主要在散点图,饼图等无类目轴的图表中使用。
- `Axis`: 坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用。
- `None`: 什么都不触发。
- `Auto`: 根据serie的类型自动选择触发类型。
| +|triggerOn||v3.11.0|触发条件。
`Tooltip.TriggerOn`:
- `MouseMove`: 鼠标移动时触发。
- `Click`: 鼠标点击时触发。
| |position||v3.3.0|显示位置类型。
`Tooltip.Position`:
- `Auto`: 自适应。移动平台靠顶部显示,非移动平台跟随鼠标位置。
- `Custom`: 自定义。完全自定义显示位置(x,y)。
- `FixedX`: 只固定坐标X。Y跟随鼠标位置。
- `FixedY`:
| |itemFormatter|||提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 换行。用|来表示多个列的分隔。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。
{i}或-表示忽略当前项。 {.}为当前所指示的serie或数据项的对应颜色的圆点。
{a}为当前所指示的serie或数据项的系列名name。
{b}为当前所指示的serie或数据项的数据项serieData的name,或者类目值(如折线图的X轴)。
{c}为当前所指示的serie或数据项的y维(dimesion为1)的数值。
{d}为当前所指示的serie或数据项的y维(dimesion为1)百分比值,注意不带%号。
{e}为当前所指示的serie或数据项的数据项serieData的name。
{f}为当前所指示的serie的默认维度的数据总和。
{g}为当前所指示的serie的数据总个数。
{h}为当前所指示的serie的十六进制颜色值。
{y}为当前所指示的serie的y轴的类目值。
{c0}表示当前数据项维度为0的数据。
{c1}表示当前数据项维度为1的数据。
{d3}表示维度3的数据的百分比。它的分母是默认维度(一般是1维度)数据。
|表示多个列的分隔。
示例:"{i}", "{.}|{a}|{c}", "{.}|{b}|{c2:f2}", "{.}|{b}|{y}" |titleFormatter|||提示框标题内容的字符串模版格式器。支持用 \n 换行。可以单独设置占位符{i}表示忽略不显示title。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。
{.}为当前所指示或index为0的serie的对应颜色的圆点。
{a}为当前所指示或index为0的serie的系列名name。
{b}为当前所指示或index为0的serie的数据项serieData的name,或者类目值(如折线图的X轴)。
{c}为当前所指示或index为0的serie的y维(dimesion为1)的数值。
{d}为当前所指示或index为0的serie的y维(dimesion为1)百分比值,注意不带%号。
{e}为当前所指示或index为0的serie的数据项serieData的name。
{h}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。
{f}为数据总和。
{g}为数据总个数。
{f}为value所对应的y轴的类目值。
{.1}表示指定index为1的serie对应颜色的圆点。
{a1}、{b1}、{c1}中的1表示指定index为1的serie。
{c1:2}表示索引为1的serie的当前指示数据项的第3个数据(一个数据项有多个数据,index为2表示第3个数据)。
{c1:2-2}表示索引为1的serie的第3个数据项的第3个数据(也就是要指定第几个数据项时必须要指定第几个数据)。
{d1:2:f2}表示单独指定了数值的格式化字符串为f2(不指定时用numericFormatter)。
{d:0.##} 表示单独指定了数值的格式化字符串为 0.## (用于百分比,保留2位有效数同时又能避免使用 f2 而出现的类似于"100.00%"的情况 )。
示例:"{a}:{c}"、"{a1}:{c1:f1}"、"{a1}:{c1:0:f1}"、"{a1}:{c1:1-1:f1}" diff --git a/Editor/MainComponents/TooltipEditor.cs b/Editor/MainComponents/TooltipEditor.cs index 179048e5..1fe592f5 100644 --- a/Editor/MainComponents/TooltipEditor.cs +++ b/Editor/MainComponents/TooltipEditor.cs @@ -11,6 +11,7 @@ namespace XCharts.Editor ++EditorGUI.indentLevel; PropertyField("m_Type"); PropertyField("m_Trigger"); + PropertyField("m_TriggerOn"); PropertyField("m_Position"); PropertyField("m_FixedX"); PropertyField("m_FixedY"); diff --git a/Examples/Example01_RandomData.cs b/Examples/Example01_RandomData.cs index c3c32376..80eb1281 100644 --- a/Examples/Example01_RandomData.cs +++ b/Examples/Example01_RandomData.cs @@ -17,24 +17,52 @@ namespace XCharts.Example public bool loopUpdate = false; public float loopUpadteTime = 1f; public int maxCache = 0; + public bool insertDataToHead = false; BaseChart chart; float lastAddTime; float lastUpdateTime; int dataCount; + int lastMaxCache = 0; + bool lastInsertDataToHead = false; + void Awake() { chart = gameObject.GetComponent(); + chart.onInit = () => + { + dataCount = chart.GetSerie(0).dataCount; + SetMaxCache(maxCache); + SetInsertDataToHead(insertDataToHead); + lastMaxCache = maxCache; + lastInsertDataToHead = insertDataToHead; + }; } - void Start() + void SetMaxCache(int maxCache) { - if (maxCache > 0) + chart.SetMaxCache(maxCache); + } + + void SetInsertDataToHead(bool insertDataToHead) + { + foreach (var serie in chart.series) + serie.insertDataToHead = insertDataToHead; + + var coms = chart.GetChartComponents(); + if (coms != null) { - chart.SetMaxCache(maxCache); + foreach (var com in coms) + { + var axis = com as XAxis; + if (axis.type == Axis.AxisType.Category) + { + axis.insertDataToHead = insertDataToHead; + Debug.LogError("axis:" + axis + "," + insertDataToHead); + } + } } - dataCount = chart.GetSerie(0).dataCount; } void Update() @@ -51,6 +79,16 @@ namespace XCharts.Example { chart.ClearData(); } + if (lastMaxCache != maxCache) + { + lastMaxCache = maxCache; + SetMaxCache(maxCache); + } + if (lastInsertDataToHead != insertDataToHead) + { + lastInsertDataToHead = insertDataToHead; + SetInsertDataToHead(insertDataToHead); + } lastAddTime += Time.deltaTime; if (loopAdd && lastAddTime >= loopAddTime) { @@ -84,14 +122,8 @@ namespace XCharts.Example } else { + AddXAxisData(); var xAxis = chart.GetChartComponent(); - if (xAxis != null) - { - if (xAxis.type == Axis.AxisType.Category) - { - chart.AddXAxisData("x" + (xAxis.GetAddedDataCount() + 1)); - } - } foreach (var serie in chart.series) { AddSerieRandomData(serie, xAxis); @@ -99,6 +131,19 @@ namespace XCharts.Example } } + void AddXAxisData() + { + var xAxes = chart.GetChartComponents(); + foreach (var com in xAxes) + { + var xAxis = com as XAxis; + if (xAxis.type == Axis.AxisType.Category) + { + chart.AddXAxisData("x" + (xAxis.GetAddedDataCount() + 1), xAxis.index); + } + } + } + void UpdateData() { foreach (var serie in chart.series) diff --git a/Runtime/Component/Axis/XAxis/XAxisHander.cs b/Runtime/Component/Axis/XAxis/XAxisHander.cs index c1b5cf14..04731658 100644 --- a/Runtime/Component/Axis/XAxis/XAxisHander.cs +++ b/Runtime/Component/Axis/XAxis/XAxisHander.cs @@ -1,5 +1,6 @@ using UnityEngine; using UnityEngine.UI; +using UnityEngine.EventSystems; namespace XCharts.Runtime { @@ -16,7 +17,28 @@ namespace XCharts.Runtime public override void Update() { UpdateAxisMinMaxValue(component.index, component); - UpdatePointerValue(component); + if (!chart.isTriggerOnClick) + { + UpdatePointerValue(component); + } + } + + public override void OnPointerClick(PointerEventData eventData) + { + base.OnPointerClick(eventData); + if (chart.isTriggerOnClick) + { + UpdatePointerValue(component); + } + } + + public override void OnPointerExit(PointerEventData eventData) + { + base.OnPointerExit(eventData); + if (chart.isTriggerOnClick) + { + component.context.pointerValue = double.PositiveInfinity; + } } public override void DrawBase(VertexHelper vh) diff --git a/Runtime/Component/Tooltip/Tooltip.cs b/Runtime/Component/Tooltip/Tooltip.cs index 13cac7f7..fd6718b0 100644 --- a/Runtime/Component/Tooltip/Tooltip.cs +++ b/Runtime/Component/Tooltip/Tooltip.cs @@ -73,6 +73,23 @@ namespace XCharts.Runtime Auto } /// + /// the condition of trigger tooltip. + /// ||触发条件。 + /// + public enum TriggerOn + { + /// + /// Trigger when mouse move. + /// ||鼠标移动时触发。 + /// + MouseMove, + /// + /// Trigger when mouse click. + /// ||鼠标点击时触发。 + /// + Click, + } + /// /// Position type. /// ||坐标类型。 /// @@ -102,6 +119,7 @@ namespace XCharts.Runtime [SerializeField] private bool m_Show = true; [SerializeField] private Type m_Type = Type.Auto; [SerializeField] private Trigger m_Trigger = Trigger.Auto; + [SerializeField][Since("v3.11.0")] private TriggerOn m_TriggerOn = TriggerOn.MouseMove; [SerializeField][Since("v3.3.0")] private Position m_Position = Position.Auto; [SerializeField] private string m_ItemFormatter; [SerializeField] private string m_TitleFormatter; @@ -144,6 +162,12 @@ namespace XCharts.Runtime public TooltipContext context = new TooltipContext(); public TooltipView view; + /// + /// the callback of tooltip click index. + /// ||Tooltip为Click触发时,点击的X轴索引的回调。 + /// + public System.Action onClickIndex { get; set; } + /// /// Whether to show the tooltip component. /// ||是否显示提示框组件。 @@ -172,6 +196,15 @@ namespace XCharts.Runtime set { if (PropertyUtil.SetStruct(ref m_Trigger, value)) SetAllDirty(); } } /// + /// Condition of trigger tooltip. + /// ||触发条件。 + /// + public TriggerOn triggerOn + { + get { return m_TriggerOn; } + set { if (PropertyUtil.SetStruct(ref m_TriggerOn, value)) SetAllDirty(); } + } + /// /// Type of position. /// ||显示位置类型。 /// diff --git a/Runtime/Component/Tooltip/TooltipContext.cs b/Runtime/Component/Tooltip/TooltipContext.cs index e0674e3a..b7e090ed 100644 --- a/Runtime/Component/Tooltip/TooltipContext.cs +++ b/Runtime/Component/Tooltip/TooltipContext.cs @@ -19,6 +19,7 @@ namespace XCharts.Runtime public float width; public float height; public float angle; + public int xAxisClickIndex = -1; public Tooltip.Type type; public Tooltip.Trigger trigger; public TooltipData data = new TooltipData(); diff --git a/Runtime/Component/Tooltip/TooltipHandler.cs b/Runtime/Component/Tooltip/TooltipHandler.cs index aec2878a..aeb21bea 100644 --- a/Runtime/Component/Tooltip/TooltipHandler.cs +++ b/Runtime/Component/Tooltip/TooltipHandler.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Text; using UnityEngine; +using UnityEngine.EventSystems; using UnityEngine.UI; using XUGL; @@ -36,6 +37,15 @@ namespace XCharts.Runtime DrawTooltipIndicator(vh, component); } + public override void OnPointerExit(PointerEventData eventData) + { + base.OnPointerExit(eventData); + if (chart.isTriggerOnClick) + { + component.context.xAxisClickIndex = -1; + } + } + private void InitTooltip(Tooltip tooltip) { tooltip.painter = chart.m_PainterUpper; @@ -70,6 +80,7 @@ namespace XCharts.Runtime m_IndicatorLabels[labelName] = item; } } + chart.isTriggerOnClick = tooltip.triggerOn == Tooltip.TriggerOn.Click; }; tooltip.refreshComponent(); } @@ -93,39 +104,54 @@ namespace XCharts.Runtime private void UpdateTooltipData(Tooltip tooltip) { - showTooltip = false; + m_ShowTooltip = false; if (tooltip.trigger == Tooltip.Trigger.None) return; - if (chart.isPointerInChart && tooltip.show) + chart.isTriggerOnClick = tooltip.triggerOn == Tooltip.TriggerOn.Click; + if (!chart.isPointerInChart || !tooltip.show || (chart.isTriggerOnClick && !chart.isPointerClick)) { for (int i = chart.series.Count - 1; i >= 0; i--) { var serie = chart.series[i]; if (!(serie is INeedSerieContainer)) { - showTooltip = true; - containerSeries = null; + m_ShowTooltip = true; + m_ContainerSeries = null; return; } } - containerSeries = ListPool.Get(); - UpdatePointerContainerAndSeriesAndTooltip(tooltip, ref containerSeries); - if (containerSeries.Count > 0) + m_ContainerSeries = ListPool.Get(); + UpdatePointerContainerAndSeriesAndTooltip(tooltip, ref m_ContainerSeries); + if (m_ContainerSeries.Count > 0) { - showTooltip = true; + m_ShowTooltip = true; + m_ContainerSeries = null; + return; } } - if (!showTooltip && tooltip.IsActive()) + m_ContainerSeries = ListPool.Get(); + UpdatePointerContainerAndSeriesAndTooltip(tooltip, ref m_ContainerSeries); + if (m_ContainerSeries.Count > 0) { - tooltip.ClearValue(); - tooltip.SetActive(false); + m_ShowTooltip = true; + } + else + { + m_ShowTooltip = false; + if (tooltip.IsActive()) + { + tooltip.ClearValue(); + tooltip.SetActive(false); + component.context.xAxisClickIndex = -1; + chart.pointerClickEventData = null; + } } } - private bool showTooltip; - private List containerSeries; + private bool m_ShowTooltip; + private List m_ContainerSeries; private void UpdateTooltip(Tooltip tooltip) { - if (!showTooltip) return; + if (!m_ShowTooltip) return; var anyTrigger = false; for (int i = chart.series.Count - 1; i >= 0; i--) { @@ -140,24 +166,27 @@ namespace XCharts.Runtime } } } - if (containerSeries != null) + if (m_ContainerSeries != null) { - if (!SetSerieTooltip(tooltip, containerSeries)) - showTooltip = false; + if (!SetSerieTooltip(tooltip, m_ContainerSeries)) + m_ShowTooltip = false; else anyTrigger = true; - ListPool.Release(containerSeries); + ListPool.Release(m_ContainerSeries); } - if (!showTooltip || !anyTrigger) + if (!m_ShowTooltip || !anyTrigger) { if (tooltip.context.type == Tooltip.Type.Corss && m_PointerContainer != null && m_PointerContainer.IsPointerEnter()) { + m_ShowTooltip = true; tooltip.SetActive(true); tooltip.SetContentActive(false); } else { + m_ShowTooltip = false; tooltip.SetActive(false); + chart.pointerClickEventData = null; } } else @@ -274,20 +303,26 @@ namespace XCharts.Runtime serie.context.tooltipTrigger : tooltip.trigger; } var isTriggerAxis = tooltip.IsTriggerAxis(); + var inchart = true; if (container is GridCoord) { var xAxis = chart.GetChartComponent(serie.xAxisIndex); var yAxis = chart.GetChartComponent(serie.yAxisIndex); - UpdateAxisPointerDataIndex(serie, xAxis, yAxis, container as GridCoord, isTriggerAxis); + inchart = UpdateAxisPointerDataIndex(serie, xAxis, yAxis, container as GridCoord, isTriggerAxis); } else if (container is PolarCoord) { var m_AngleAxis = ComponentHelper.GetAngleAxis(chart.components, container.index); tooltip.context.angle = (float)m_AngleAxis.context.pointerValue; } - list.Add(serie); - if (!isTriggerAxis) - chart.RefreshTopPainter(); + if (inchart) + { + list.Add(serie); + if (!isTriggerAxis) + { + chart.RefreshTopPainter(); + } + } } } m_PointerContainer = container; @@ -296,10 +331,11 @@ namespace XCharts.Runtime } } - private void UpdateAxisPointerDataIndex(Serie serie, XAxis xAxis, YAxis yAxis, GridCoord grid, bool isTriggerAxis) + private bool UpdateAxisPointerDataIndex(Serie serie, XAxis xAxis, YAxis yAxis, GridCoord grid, bool isTriggerAxis) { serie.context.pointerAxisDataIndexs.Clear(); - if (xAxis == null || yAxis == null) return; + if (xAxis == null || yAxis == null) return false; + var flag = true; if (serie is Heatmap) { GetSerieDataByXYAxis(serie, xAxis, yAxis); @@ -328,20 +364,45 @@ namespace XCharts.Runtime if (isTriggerAxis) { var index = serie.context.dataZoomStartIndex + (int)xAxis.context.pointerValue; + if (chart.isTriggerOnClick) + { + if (serie.insertDataToHead) + index = index + (serie.context.totalDataIndex - serie.context.clickTotalDataIndex); + else if (serie.context.totalDataIndex >= serie.dataCount) + index = index - (serie.context.totalDataIndex - serie.context.clickTotalDataIndex); + if (index < 0 || index >= serie.dataCount) + { + index = -1; + flag = false; + } + } + if (component.context.xAxisClickIndex != index) + { + component.context.xAxisClickIndex = index; + if (component.onClickIndex != null) + { + component.onClickIndex(index); + } + } serie.context.pointerEnter = true; serie.context.pointerAxisDataIndexs.Add(index); serie.context.pointerItemDataIndex = index; - xAxis.context.axisTooltipValue = xAxis.context.pointerValue; + xAxis.context.axisTooltipValue = index; } } else { - serie.context.pointerEnter = true; if (isTriggerAxis) + { + serie.context.pointerEnter = true; GetSerieDataIndexByAxis(serie, xAxis, grid); + } else + { GetSerieDataIndexByItem(serie, xAxis, grid); + } } + return flag; } private void GetSerieDataByXYAxis(Serie serie, Axis xAxis, Axis yAxis) @@ -464,7 +525,7 @@ namespace XCharts.Runtime if (tooltip.context.trigger == Tooltip.Trigger.None) return false; tooltip.context.data.param.Clear(); tooltip.context.data.title = serie.serieName; - tooltip.context.pointer = chart.pointerPos; + tooltip.context.pointer = GetTooltipPointerPos(); serie.handler.UpdateTooltipSerieParams(serie.context.pointerItemDataIndex, false, null, tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter, tooltip.ignoreDataDefaultContent, @@ -472,12 +533,20 @@ namespace XCharts.Runtime ref tooltip.context.data.title); TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart); - tooltip.SetActive(true); + tooltip.SetActive(m_ShowTooltip); tooltip.view.Refresh(); TooltipHelper.LimitInRect(tooltip, chart.chartRect); return true; } + private Vector2 GetTooltipPointerPos() + { + if (chart.isTriggerOnClick && chart.isPointerClick) + return chart.clickPos; + else + return chart.pointerPos; + } + private bool SetSerieTooltip(Tooltip tooltip, List series) { if (tooltip.context.trigger == Tooltip.Trigger.None) @@ -489,10 +558,10 @@ namespace XCharts.Runtime string category = null; var showCategory = false; var isTriggerByAxis = false; - var isTriggerByItem = false; + var isTriggerByItem = tooltip.context.trigger == Tooltip.Trigger.Item; var dataIndex = -1; tooltip.context.data.param.Clear(); - tooltip.context.pointer = chart.pointerPos; + tooltip.context.pointer = GetTooltipPointerPos(); if (m_PointerContainer is GridCoord) { GetAxisCategory(m_PointerContainer.index, ref dataIndex, ref category); @@ -514,11 +583,13 @@ namespace XCharts.Runtime } } + var triggerSerieCount = 0; for (int i = 0; i < series.Count; i++) { var serie = series[i]; if (!serie.show) continue; if (isTriggerByItem && serie.context.pointerItemDataIndex < 0) continue; + triggerSerieCount++; serie.context.isTriggerByAxis = isTriggerByAxis; if (isTriggerByAxis && dataIndex >= 0 && serie.context.pointerItemDataIndex < 0) serie.context.pointerItemDataIndex = dataIndex; @@ -528,10 +599,14 @@ namespace XCharts.Runtime ref tooltip.context.data.param, ref tooltip.context.data.title); } + if (triggerSerieCount <= 0) + { + return false; + } TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart); if (tooltip.context.data.param.Count > 0 || !string.IsNullOrEmpty(tooltip.context.data.title)) { - tooltip.SetActive(true); + tooltip.SetActive(m_ShowTooltip); if (tooltip.view != null) tooltip.view.Refresh(); TooltipHelper.LimitInRect(tooltip, chart.chartRect); @@ -551,7 +626,7 @@ namespace XCharts.Runtime { dataIndex = double.IsNaN(axis.context.pointerValue) ? axis.context.dataZoomStartIndex - : axis.context.dataZoomStartIndex + (int)axis.context.pointerValue; + : axis.context.dataZoomStartIndex + (int)axis.context.axisTooltipValue; category = axis.GetData(dataIndex); return true; } @@ -616,7 +691,7 @@ namespace XCharts.Runtime case Tooltip.Type.Line: float pX = grid.context.x; pX += xAxis.IsCategory() ? - (float)(xAxis.context.pointerValue * splitWidth + (xAxis.boundaryGap ? splitWidth / 2 : 0)) : + (float)(xAxis.context.axisTooltipValue * splitWidth + (xAxis.boundaryGap ? splitWidth / 2 : 0)) : xAxis.GetDistance(xAxis.context.axisTooltipValue, grid.context.width); if (pX < grid.context.x) break; diff --git a/Runtime/Internal/BaseChart.API.cs b/Runtime/Internal/BaseChart.API.cs index 9da4fdf2..f61a647f 100644 --- a/Runtime/Internal/BaseChart.API.cs +++ b/Runtime/Internal/BaseChart.API.cs @@ -566,6 +566,26 @@ namespace XCharts.Runtime } } + /// + /// set insert data to head. + /// ||设置数据插入到头部。 + /// + /// + [Since("v3.11.0")] + public void SetInsertDataToHead(bool insertDataToHead) + { + foreach (var serie in m_Series) + serie.insertDataToHead = insertDataToHead; + + var coms = GetChartComponents(); + foreach (var com in coms) + { + var axis = com as XAxis; + if (axis.type == Axis.AxisType.Category) + axis.insertDataToHead = insertDataToHead; + } + } + public Vector3 GetTitlePosition(Title title) { return chartPosition + title.location.GetPosition(chartWidth, chartHeight); @@ -735,7 +755,8 @@ namespace XCharts.Runtime [Since("v3.7.0")] public void CancelTooltip() { - m_PointerEventData = null; + pointerMoveEventData = null; + pointerClickEventData = null; var tooltip = GetChartComponent(); if (tooltip != null) { diff --git a/Runtime/Internal/BaseGraph.API.cs b/Runtime/Internal/BaseGraph.API.cs index f659a233..210d681e 100644 --- a/Runtime/Internal/BaseGraph.API.cs +++ b/Runtime/Internal/BaseGraph.API.cs @@ -43,16 +43,21 @@ namespace XCharts.Runtime public Vector2 graphMaxAnchor { get { return m_GraphMaxAnchor; } } public Vector2 graphAnchoredPosition { get { return m_GraphAnchoredPosition; } } /// - /// The postion of pointer. + /// The postion of pointer move. /// ||鼠标位置。 /// public Vector2 pointerPos { get; protected set; } + public Vector2 clickPos { get; protected set; } /// /// Whether the mouse pointer is in the chart. /// ||鼠标是否在图表内。 /// - public bool isPointerInChart - { get { return m_PointerEventData != null; } } + public bool isPointerInChart { get { return pointerMoveEventData != null; } } + /// + /// Whether the mouse click the chart. + /// ||鼠标是否点击了图表。 + /// + public bool isPointerClick { get { return pointerClickEventData != null; } } /// /// 警告信息。 /// diff --git a/Runtime/Internal/BaseGraph.cs b/Runtime/Internal/BaseGraph.cs index c723a829..2bf81ac1 100644 --- a/Runtime/Internal/BaseGraph.cs +++ b/Runtime/Internal/BaseGraph.cs @@ -35,7 +35,9 @@ namespace XCharts.Runtime protected bool m_PainerDirty = false; protected bool m_IsOnValidate = false; protected Vector3 m_LastLocalPosition; - protected PointerEventData m_PointerEventData; + internal PointerEventData pointerMoveEventData; + internal PointerEventData pointerClickEventData; + internal bool isTriggerOnClick = false; protected Action m_OnPointerClick; protected Action m_OnPointerDown; @@ -213,17 +215,23 @@ namespace XCharts.Runtime private void CheckPointerPos() { - if (!isPointerInChart) return; if (canvas == null) return; - Vector2 mousePos = m_PointerEventData.position; + if (pointerMoveEventData != null) + { + pointerPos = MousePos2ChartPos(pointerMoveEventData.position); + } + } + + private Vector2 MousePos2ChartPos(Vector2 mousePos) + { Vector2 local; if (!ScreenPointToChartPoint(mousePos, out local)) { - pointerPos = Vector2.zero; + return Vector2.zero; } else { - pointerPos = local; + return local; } } @@ -269,6 +277,8 @@ namespace XCharts.Runtime public virtual void OnPointerClick(PointerEventData eventData) { + pointerClickEventData = eventData; + clickPos = MousePos2ChartPos(pointerClickEventData.position); if (m_OnPointerClick != null) m_OnPointerClick(eventData, this); } @@ -284,13 +294,14 @@ namespace XCharts.Runtime public virtual void OnPointerEnter(PointerEventData eventData) { - m_PointerEventData = eventData; + pointerMoveEventData = eventData; if (m_OnPointerEnter != null) m_OnPointerEnter(eventData, this); } public virtual void OnPointerExit(PointerEventData eventData) { - m_PointerEventData = null; + pointerMoveEventData = null; + pointerClickEventData = null; if (m_OnPointerExit != null) m_OnPointerExit(eventData, this); } diff --git a/Runtime/Serie/SerieContext.cs b/Runtime/Serie/SerieContext.cs index 624e0d9e..d3b3931a 100644 --- a/Runtime/Serie/SerieContext.cs +++ b/Runtime/Serie/SerieContext.cs @@ -119,6 +119,7 @@ namespace XCharts.Runtime public Tooltip.Type tooltipType; public Tooltip.Trigger tooltipTrigger; public int totalDataIndex; + public int clickTotalDataIndex; /// /// 水平方向的 /// diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs index 7ebfc2c7..fd232af3 100644 --- a/Runtime/Serie/SerieHandler.cs +++ b/Runtime/Serie/SerieHandler.cs @@ -741,6 +741,7 @@ namespace XCharts.Runtime public override void OnPointerClick(PointerEventData eventData) { + serie.context.clickTotalDataIndex = serie.context.totalDataIndex; if (serie.onClick == null && chart.onSerieClick == null) return; if (!serie.context.pointerEnter) return; var dataIndex = GetPointerItemDataIndex(); diff --git a/package.json b/package.json index a5b150d6..6425d8bc 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "displayName": "XCharts", "author": "monitor1394", "license": "MIT", - "version": "3.10.2", - "date": "20240311", - "checkdate": "20240311", + "version": "3.11.0-preview1", + "date": "20240223", + "checkdate": "20240223", "unity": "2018.3", "description": "A charting and data visualization library for Unity. Support line chart, bar chart, pie chart, radar chart, scatter chart, heatmap chart, ring chart, candlestick chart, polar chart and parallel coordinates.", "keywords": [ From 4b8374b1aee4be44b9c36d1f4646ead70a01f44b Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 19 Mar 2024 22:33:19 +0800 Subject: [PATCH 03/37] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Pie`=E5=9C=A8=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE`ItemStyle`=E7=9A=84`opacity`=E6=97=B6=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E4=B8=8D=E5=AF=B9=E7=9A=84=E9=97=AE=E9=A2=98=20(#309)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Serie/SerieHelper.cs | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 03fd4317..87946a32 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -74,6 +74,7 @@ slug: /changelog ## master * (2024.03.20) 增加`Tooltip`的`triggerOn`设置触发条件 +* (2024.03.19) 修复`Pie`在设置`ItemStyle`的`opacity`时颜色不对的问题 (#309) ## v3.10.2 diff --git a/Runtime/Serie/SerieHelper.cs b/Runtime/Serie/SerieHelper.cs index 61c6e4d3..e64438a2 100644 --- a/Runtime/Serie/SerieHelper.cs +++ b/Runtime/Serie/SerieHelper.cs @@ -320,7 +320,7 @@ namespace XCharts.Runtime { var style = GetItemStyle(serie, serieData, SerieState.Normal); GetColor(ref color, style.color, style.color, style.opacity, theme, index, opacity); - GetColor(ref toColor, style.toColor, color, style.opacity, theme, index, opacity); + GetColor(ref toColor, style.toColor, color, style.opacity, theme, index, opacity, true); switch (state) { case SerieState.Emphasis: @@ -342,7 +342,7 @@ namespace XCharts.Runtime else { GetColor(ref color, stateStyle.itemStyle.color, stateStyle.itemStyle.color, stateStyle.itemStyle.opacity, theme, index, opacity); - GetColor(ref toColor, stateStyle.itemStyle.toColor, color, stateStyle.itemStyle.opacity, theme, index, opacity); + GetColor(ref toColor, stateStyle.itemStyle.toColor, color, stateStyle.itemStyle.opacity, theme, index, opacity, true); } } @@ -359,7 +359,7 @@ namespace XCharts.Runtime { var style = GetItemStyle(serie, serieData, SerieState.Normal); GetColor(ref color, style.color, style.color, style.opacity, theme, index, opacity); - GetColor(ref toColor, style.toColor, color, style.opacity, theme, index, opacity); + GetColor(ref toColor, style.toColor, color, style.opacity, theme, index, opacity, true); backgroundColor = style.backgroundColor; switch (state) { @@ -383,7 +383,7 @@ namespace XCharts.Runtime { backgroundColor = stateStyle.itemStyle.backgroundColor; GetColor(ref color, stateStyle.itemStyle.color, stateStyle.itemStyle.color, stateStyle.itemStyle.opacity, theme, index, opacity); - GetColor(ref toColor, stateStyle.itemStyle.toColor, color, stateStyle.itemStyle.opacity, theme, index, opacity); + GetColor(ref toColor, stateStyle.itemStyle.toColor, color, stateStyle.itemStyle.opacity, theme, index, opacity, true); } } @@ -580,7 +580,7 @@ namespace XCharts.Runtime innerFill = areaStyle.innerFill; toTop = areaStyle.toTop; GetColor(ref color, areaStyle.color, serie.itemStyle.color, areaStyle.opacity, theme, index); - GetColor(ref toColor, areaStyle.toColor, color, areaStyle.opacity, theme, index); + GetColor(ref toColor, areaStyle.toColor, color, areaStyle.opacity, theme, index, true); switch (state) { case SerieState.Emphasis: @@ -606,7 +606,7 @@ namespace XCharts.Runtime innerFill = stateStyle.areaStyle.innerFill; toTop = stateStyle.areaStyle.toTop; GetColor(ref color, stateStyle.areaStyle.color, stateStyle.itemStyle.color, stateStyle.areaStyle.opacity, theme, index); - GetColor(ref toColor, stateStyle.areaStyle.toColor, color, stateStyle.areaStyle.opacity, theme, index); + GetColor(ref toColor, stateStyle.areaStyle.toColor, color, stateStyle.areaStyle.opacity, theme, index, true, true); } else { @@ -646,10 +646,14 @@ namespace XCharts.Runtime } public static void GetColor(ref Color32 color, Color32 checkColor, Color32 itemColor, - float opacity, ThemeStyle theme, int colorIndex, bool setOpacity = true) + float opacity, ThemeStyle theme, int colorIndex, bool setOpacity = true, bool resetOpacity = false) { if (!ChartHelper.IsClearColor(checkColor)) color = checkColor; - else if (!ChartHelper.IsClearColor(itemColor)) color = itemColor; + else if (!ChartHelper.IsClearColor(itemColor)) + { + color = itemColor; + if (resetOpacity) opacity = 1; + } if (ChartHelper.IsClearColor(color) && colorIndex >= 0) color = theme.GetColor(colorIndex); if (setOpacity) ChartHelper.SetColorOpacity(ref color, opacity); } From 42079848dcb414555f4d96fe69efd178a2c8dc0b Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 20 Mar 2024 22:23:58 +0800 Subject: [PATCH 04/37] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A1=91=E5=90=89?= =?UTF-8?q?=E5=9B=BE=E6=8A=98=E5=8F=A0=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Internal/Data/GraphData.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Runtime/Internal/Data/GraphData.cs b/Runtime/Internal/Data/GraphData.cs index b7ea07d8..cc293751 100644 --- a/Runtime/Internal/Data/GraphData.cs +++ b/Runtime/Internal/Data/GraphData.cs @@ -42,11 +42,27 @@ namespace XCharts.Runtime double totalValue = 0; foreach (var node in nodes) { - totalValue += node.totalValues; + if (node.IsAnyInEdgesExpanded()) + { + totalValue += node.totalValues; + } } return totalValue; } + public static int GetExpandedNodesCount(List nodes) + { + int count = 0; + foreach (var node in nodes) + { + if (node.IsAnyInEdgesExpanded()) + { + count++; + } + } + return count; + } + public List> GetDepthNodes() { List> depthNodes = new List>(); From f5a41b511932efe824fe2b3a87b9d2de8b5f6b88 Mon Sep 17 00:00:00 2001 From: Stefan Bursuc Date: Mon, 8 Apr 2024 11:07:27 +0200 Subject: [PATCH 05/37] Fix for GC Allocations inside TooltipHandler In the case where the pointer is not in the chart, both calls to ListPool.Get() from inside the function UpdateTooltipData are executed. And because the pointer is not in the chart, m_ShowTooltip is set to false in the last else clause. This makes UpdateTooltip to skip all logic and miss the chance to release the list back to the pool. --- Runtime/Component/Tooltip/TooltipHandler.cs | 40 +++++++++++---------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/Runtime/Component/Tooltip/TooltipHandler.cs b/Runtime/Component/Tooltip/TooltipHandler.cs index aeb21bea..5aea9015 100644 --- a/Runtime/Component/Tooltip/TooltipHandler.cs +++ b/Runtime/Component/Tooltip/TooltipHandler.cs @@ -107,7 +107,11 @@ namespace XCharts.Runtime m_ShowTooltip = false; if (tooltip.trigger == Tooltip.Trigger.None) return; chart.isTriggerOnClick = tooltip.triggerOn == Tooltip.TriggerOn.Click; - if (!chart.isPointerInChart || !tooltip.show || (chart.isTriggerOnClick && !chart.isPointerClick)) + + if ((tooltip.show && chart.isPointerInChart) && + ((tooltip.triggerOn == Tooltip.TriggerOn.Click && chart.isPointerClick) || + (tooltip.triggerOn == Tooltip.TriggerOn.MouseMove)) + ) { for (int i = chart.series.Count - 1; i >= 0; i--) { @@ -124,26 +128,16 @@ namespace XCharts.Runtime if (m_ContainerSeries.Count > 0) { m_ShowTooltip = true; - m_ContainerSeries = null; return; } } - m_ContainerSeries = ListPool.Get(); - UpdatePointerContainerAndSeriesAndTooltip(tooltip, ref m_ContainerSeries); - if (m_ContainerSeries.Count > 0) + + if (!m_ShowTooltip && tooltip.IsActive()) { - m_ShowTooltip = true; - } - else - { - m_ShowTooltip = false; - if (tooltip.IsActive()) - { - tooltip.ClearValue(); - tooltip.SetActive(false); - component.context.xAxisClickIndex = -1; - chart.pointerClickEventData = null; - } + tooltip.ClearValue(); + tooltip.SetActive(false); + component.context.xAxisClickIndex = -1; + chart.pointerClickEventData = null; } } @@ -151,7 +145,16 @@ namespace XCharts.Runtime private List m_ContainerSeries; private void UpdateTooltip(Tooltip tooltip) { - if (!m_ShowTooltip) return; + if (!m_ShowTooltip) + { + if (m_ContainerSeries != null) + { + ListPool.Release(m_ContainerSeries); + m_ContainerSeries = null; + } + return; + } + var anyTrigger = false; for (int i = chart.series.Count - 1; i >= 0; i--) { @@ -173,6 +176,7 @@ namespace XCharts.Runtime else anyTrigger = true; ListPool.Release(m_ContainerSeries); + m_ContainerSeries = null; } if (!m_ShowTooltip || !anyTrigger) { From a361e191da5829cffb9e75725080da56dd739e6e Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Fri, 12 Apr 2024 08:30:34 +0800 Subject: [PATCH 06/37] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Candlesticks`=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E4=B8=8D=E5=AF=B9=E7=9A=84=E9=97=AE=E9=A2=98=20(#313)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Serie/Candlestick/Candlestick.cs | 14 +++++--- .../Serie/Candlestick/CandlestickHandler.cs | 32 +++++++++++++------ .../Candlestick/SimplifiedCandlestick.cs | 13 ++++---- .../SimplifiedCandlestickHandler.cs | 22 ++++++++++--- 5 files changed, 56 insertions(+), 26 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 87946a32..b5d5aca2 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,7 @@ slug: /changelog ## master +* (2024.04.12) 修复`Candlesticks`效果不对的问题 (#313) * (2024.03.20) 增加`Tooltip`的`triggerOn`设置触发条件 * (2024.03.19) 修复`Pie`在设置`ItemStyle`的`opacity`时颜色不对的问题 (#309) diff --git a/Runtime/Serie/Candlestick/Candlestick.cs b/Runtime/Serie/Candlestick/Candlestick.cs index 26583938..dcfbfddf 100644 --- a/Runtime/Serie/Candlestick/Candlestick.cs +++ b/Runtime/Serie/Candlestick/Candlestick.cs @@ -17,13 +17,17 @@ namespace XCharts.Runtime { var serie = chart.AddSerie(serieName); var defaultDataCount = 5; - for (int i = 0; i < defaultDataCount; i++) + var lastValue = 50d; + for (int i = 0; i < 5; i++) { - var open = Random.Range(20, 60); - var close = Random.Range(40, 90); - var lowest = Random.Range(0, 50); - var heighest = Random.Range(50, 100); + var open = lastValue; + var close = open + Random.Range(-20, 20); + var min = open < close ? open : close; + var max = open > close ? open : close; + var lowest = min + Random.Range(-10, -10); + var heighest = max + Random.Range(10, 10); chart.AddData(serie.index, i, open, close, lowest, heighest); + lastValue = close; } return serie; } diff --git a/Runtime/Serie/Candlestick/CandlestickHandler.cs b/Runtime/Serie/Candlestick/CandlestickHandler.cs index da9f9898..7e8c0cde 100644 --- a/Runtime/Serie/Candlestick/CandlestickHandler.cs +++ b/Runtime/Serie/Candlestick/CandlestickHandler.cs @@ -124,7 +124,7 @@ namespace XCharts.Runtime var close = serieData.GetCurrData(startDataIndex + 1, dataAddDuration, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime); var lowest = serieData.GetCurrData(startDataIndex + 2, dataAddDuration, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime); var heighest = serieData.GetCurrData(startDataIndex + 3, dataAddDuration, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime); - var isRise = yAxis.inverse ? close open; + var isRise = yAxis.inverse ? close < open : close > open; var borderWidth = open == 0 ? 0f : (itemStyle.borderWidth == 0 ? theme.serie.candlestickBorderWidth : itemStyle.borderWidth); @@ -138,18 +138,30 @@ namespace XCharts.Runtime var minCut = (yMinValue > 0 ? yMinValue : 0); if (valueTotal != 0) { - barHig = (float) ((close - open) / valueTotal * grid.context.height); - pY += (float) ((open - minCut) / valueTotal * grid.context.height); + barHig = (float)((close - open) / valueTotal * grid.context.height); + pY += (float)((open - minCut) / valueTotal * grid.context.height); } serieData.context.stackHeight = barHig; float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig); Vector3 plb, plt, prt, prb, top; - plb = new Vector3(pX + gap + borderWidth, pY + borderWidth); - plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth); - prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth); - prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth); - top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth); + var offset = 2 * borderWidth; + if (isRise) + { + plb = new Vector3(pX + gap + offset, pY + offset); + plt = new Vector3(pX + gap + offset, pY + currHig - offset); + prt = new Vector3(pX + gap + barWidth - offset, pY + currHig - offset); + prb = new Vector3(pX + gap + barWidth - offset, pY + offset); + top = new Vector3(pX + gap + barWidth / 2, pY + currHig - offset); + } + else + { + plb = new Vector3(pX + gap + offset, pY - offset); + plt = new Vector3(pX + gap + offset, pY + currHig + offset); + prt = new Vector3(pX + gap + barWidth - offset, pY + currHig + offset); + prb = new Vector3(pX + gap + barWidth - offset, pY - offset); + top = new Vector3(pX + gap + barWidth / 2, pY + currHig + offset); + } if (serie.clip) { plb = chart.ClampInGrid(grid, plb); @@ -169,8 +181,8 @@ namespace XCharts.Runtime var itemWidth = Mathf.Abs(prt.x - plb.x); var itemHeight = Mathf.Abs(plt.y - prb.y); var center = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2); - var lowPos = new Vector3(center.x, zeroY + (float) ((lowest - minCut) / valueTotal * grid.context.height)); - var heighPos = new Vector3(center.x, zeroY + (float) ((heighest - minCut) / valueTotal * grid.context.height)); + var lowPos = new Vector3(center.x, zeroY + (float)((lowest - minCut) / valueTotal * grid.context.height)); + var heighPos = new Vector3(center.x, zeroY + (float)((heighest - minCut) / valueTotal * grid.context.height)); var openCenterPos = new Vector3(center.x, prb.y); var closeCenterPos = new Vector3(center.x, prt.y); if (intensive) diff --git a/Runtime/Serie/Candlestick/SimplifiedCandlestick.cs b/Runtime/Serie/Candlestick/SimplifiedCandlestick.cs index 911f6eb2..918cd97b 100644 --- a/Runtime/Serie/Candlestick/SimplifiedCandlestick.cs +++ b/Runtime/Serie/Candlestick/SimplifiedCandlestick.cs @@ -17,16 +17,17 @@ namespace XCharts.Runtime public static Serie AddDefaultSerie(BaseChart chart, string serieName) { var serie = chart.AddSerie(serieName); - var lastValue = 50d; for (int i = 0; i < 50; i++) { - lastValue += UnityEngine.Random.Range(-10, 20); - var open = lastValue + Random.Range(-10, 5); - var close = lastValue + Random.Range(-5, 10); - var lowest = lastValue + Random.Range(-15, -10); - var heighest = lastValue + Random.Range(10, 20); + var open = lastValue; + var close = open + Random.Range(-20, 20); + var min = open < close ? open : close; + var max = open > close ? open : close; + var lowest = min + Random.Range(-10, -10); + var heighest = max + Random.Range(10, 10); chart.AddData(serie.index, i, open, close, lowest, heighest); + lastValue = close; } return serie; } diff --git a/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs b/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs index 2fbf64f5..94e85c40 100644 --- a/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs +++ b/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs @@ -144,11 +144,23 @@ namespace XCharts.Runtime float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig); Vector3 plb, plt, prt, prb, top; - plb = new Vector3(pX + gap + borderWidth, pY + borderWidth); - plt = new Vector3(pX + gap + borderWidth, pY + currHig - borderWidth); - prt = new Vector3(pX + gap + barWidth - borderWidth, pY + currHig - borderWidth); - prb = new Vector3(pX + gap + barWidth - borderWidth, pY + borderWidth); - top = new Vector3(pX + gap + barWidth / 2, pY + currHig - borderWidth); + var offset = 2 * borderWidth; + if (isRise) + { + plb = new Vector3(pX + gap + offset, pY + offset); + plt = new Vector3(pX + gap + offset, pY + currHig - offset); + prt = new Vector3(pX + gap + barWidth - offset, pY + currHig - offset); + prb = new Vector3(pX + gap + barWidth - offset, pY + offset); + top = new Vector3(pX + gap + barWidth / 2, pY + currHig - offset); + } + else + { + plb = new Vector3(pX + gap + offset, pY - offset); + plt = new Vector3(pX + gap + offset, pY + currHig + offset); + prt = new Vector3(pX + gap + barWidth - offset, pY + currHig + offset); + prb = new Vector3(pX + gap + barWidth - offset, pY - offset); + top = new Vector3(pX + gap + barWidth / 2, pY + currHig + offset); + } // if (serie.clip) // { // plb = chart.ClampInGrid(grid, plb); From 3ef2e7c23cbfc64d7d3f804a356dbaa6a5426fe8 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 14 Apr 2024 19:09:08 +0800 Subject: [PATCH 07/37] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Tooltip`=E7=9A=84`Cros?= =?UTF-8?q?s`=E5=9C=A8=E5=BC=80=E5=90=AF`DataZoom`=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B`label`=E4=BD=8D=E7=BD=AE=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98=20(#315)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Component/Tooltip/Tooltip.cs | 2 +- Runtime/Component/Tooltip/TooltipHandler.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Runtime/Component/Tooltip/Tooltip.cs b/Runtime/Component/Tooltip/Tooltip.cs index fd6718b0..18149b85 100644 --- a/Runtime/Component/Tooltip/Tooltip.cs +++ b/Runtime/Component/Tooltip/Tooltip.cs @@ -244,7 +244,7 @@ namespace XCharts.Runtime /// {h}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。
/// {f}为数据总和。
/// {g}为数据总个数。
- /// {f}为value所对应的y轴的类目值。
+ /// {y}为value所对应的y轴的类目值。
/// {.1}表示指定index为1的serie对应颜色的圆点。
/// {a1}、{b1}、{c1}中的1表示指定index为1的serie。
/// {c1:2}表示索引为1的serie的当前指示数据项的第3个数据(一个数据项有多个数据,index为2表示第3个数据)。
diff --git a/Runtime/Component/Tooltip/TooltipHandler.cs b/Runtime/Component/Tooltip/TooltipHandler.cs index aeb21bea..ff466cbd 100644 --- a/Runtime/Component/Tooltip/TooltipHandler.cs +++ b/Runtime/Component/Tooltip/TooltipHandler.cs @@ -252,7 +252,8 @@ namespace XCharts.Runtime if (axis.IsCategory()) { var index = (int)axis.context.pointerValue; - var category = axis.GetData(index); + var dataZoom = chart.GetDataZoomOfAxis(axis); + var category = axis.GetData(index, dataZoom); label.SetText(axis.indicatorLabel.GetFormatterContent(index, category)); } else if (axis.IsTime()) From 58e6108bb27b7faa72e9a9c1cbfbebcadcbf7eb1 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 15 Apr 2024 08:18:12 +0800 Subject: [PATCH 08/37] =?UTF-8?q?=E4=BC=98=E5=8C=96`GridCoord`=E5=9C=A8?= =?UTF-8?q?=E5=BC=80=E5=90=AF`GridLayout`=E6=97=B6=E4=B9=9F=E6=98=BE?= =?UTF-8?q?=E7=A4=BA`Left`=20`Right`=20`Top`=20`Bottom`=E5=8F=82=E6=95=B0?= =?UTF-8?q?=20(#316)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 2 ++ Editor/MainComponents/GridCoordEditor.cs | 11 ++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index b5d5aca2..7000dd0e 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,8 @@ slug: /changelog ## master +* (2024.04.15) 优化`GridCoord`在开启`GridLayout`时也显示`Left` `Right` `Top` `Bottom`参数 (#316) +* (2024.04.14) 修复`Tooltip`的`Cross`在开启`DataZoom`的情况下`label`位置不正确的问题 (#315) * (2024.04.12) 修复`Candlesticks`效果不对的问题 (#313) * (2024.03.20) 增加`Tooltip`的`triggerOn`设置触发条件 * (2024.03.19) 修复`Pie`在设置`ItemStyle`的`opacity`时颜色不对的问题 (#309) diff --git a/Editor/MainComponents/GridCoordEditor.cs b/Editor/MainComponents/GridCoordEditor.cs index cc39f58b..adb60fd6 100644 --- a/Editor/MainComponents/GridCoordEditor.cs +++ b/Editor/MainComponents/GridCoordEditor.cs @@ -11,13 +11,10 @@ namespace XCharts.Editor ++EditorGUI.indentLevel; var layoutIndex = baseProperty.FindPropertyRelative("m_LayoutIndex").intValue; PropertyField("m_LayoutIndex"); - if (layoutIndex < 0) - { - PropertyField("m_Left"); - PropertyField("m_Right"); - PropertyField("m_Top"); - PropertyField("m_Bottom"); - } + PropertyField("m_Left"); + PropertyField("m_Right"); + PropertyField("m_Top"); + PropertyField("m_Bottom"); PropertyField("m_BackgroundColor"); PropertyField("m_ShowBorder"); PropertyField("m_BorderWidth"); From e2120b3da667d6f966a017a72df92d63ccf42b96 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 16 Apr 2024 22:30:04 +0800 Subject: [PATCH 09/37] =?UTF-8?q?=E4=BC=98=E5=8C=96`DateTimeUtil`=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=88=B3=E8=BD=AC`DateTime`=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=97=B6=E5=8C=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Utilities/DateTimeUtil.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Runtime/Utilities/DateTimeUtil.cs b/Runtime/Utilities/DateTimeUtil.cs index 7c14cfe5..c47ae94d 100644 --- a/Runtime/Utilities/DateTimeUtil.cs +++ b/Runtime/Utilities/DateTimeUtil.cs @@ -6,8 +6,7 @@ namespace XCharts.Runtime { public static class DateTimeUtil { - //private static readonly DateTime k_DateTime1970 = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Local); - private static readonly DateTime k_DateTime1970 = new DateTime(1970, 1, 1); + private static readonly DateTime k_DateTime1970 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); public static readonly int ONE_SECOND = 1; public static readonly int ONE_MINUTE = ONE_SECOND * 60; public static readonly int ONE_HOUR = ONE_MINUTE * 60; @@ -34,10 +33,21 @@ namespace XCharts.Runtime return (int)(time - k_DateTime1970).TotalSeconds; } + public static int GetTimestamp(string dateTime) + { + try + { + return GetTimestamp(DateTime.Parse(dateTime)); + } + catch (Exception e) + { + throw e; + } + } + public static DateTime GetDateTime(int timestamp) { - long span = ((long)timestamp) * 10000000; - return k_DateTime1970.Add(new TimeSpan(span)); + return k_DateTime1970.AddSeconds(timestamp); } internal static string GetDateTimeFormatString(DateTime dateTime, double range) From 120c6d5408d71f58aa6e6f70201dbcace8b9ee94 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 22 Apr 2024 22:25:12 +0800 Subject: [PATCH 10/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`GridCoord3D`3D?= =?UTF-8?q?=E5=9D=90=E6=A0=87=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/en/api.md | 119 +++++++- Documentation~/en/configuration.md | 95 +++++- Documentation~/zh/api.md | 119 +++++++- Documentation~/zh/changelog.md | 2 + Documentation~/zh/configuration.md | 95 +++++- Editor/ChildComponents/LineDrawer.cs | 1 + Editor/ChildComponents/ViewControlDrawer.cs | 23 ++ .../ChildComponents/ViewControlDrawer.cs.meta | 11 + Editor/MainComponents/AxisEditor.cs | 9 + Editor/MainComponents/GridCoord3DEditor.cs | 23 ++ .../MainComponents/GridCoord3DEditor.cs.meta | 11 + Editor/Series/SerieBaseEditor.cs | 4 +- Runtime/Component/Axis/Axis.cs | 9 +- Runtime/Component/Axis/Axis3DHelper.cs | 160 +++++++++++ Runtime/Component/Axis/Axis3DHelper.cs.meta | 11 + Runtime/Component/Axis/AxisContext.cs | 4 + Runtime/Component/Axis/AxisHandler.cs | 110 +++++++ Runtime/Component/Axis/AxisSplitLine.cs | 10 + .../Axis/ParallelAxis/ParallelAxisHander.cs | 2 + .../Component/Axis/SingleAxis/SingleAxis.cs | 6 + Runtime/Component/Axis/XAxis/XAxisHander.cs | 5 + Runtime/Component/Axis/XAxis3D.meta | 8 + Runtime/Component/Axis/XAxis3D/XAxis3D.cs | 36 +++ .../Component/Axis/XAxis3D/XAxis3D.cs.meta | 11 + .../Component/Axis/XAxis3D/XAxis3DHander.cs | 190 ++++++++++++ .../Axis/XAxis3D/XAxis3DHander.cs.meta | 11 + Runtime/Component/Axis/YAxis/YAxisHander.cs | 5 + Runtime/Component/Axis/YAxis3D.meta | 8 + Runtime/Component/Axis/YAxis3D/YAxis3D.cs | 33 +++ .../Component/Axis/YAxis3D/YAxis3D.cs.meta | 11 + .../Component/Axis/YAxis3D/YAxis3DHander.cs | 176 ++++++++++++ .../Axis/YAxis3D/YAxis3DHander.cs.meta | 11 + Runtime/Component/Axis/ZAxis3D.meta | 8 + Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs | 33 +++ .../Component/Axis/ZAxis3D/ZAxis3D.cs.meta | 11 + .../Component/Axis/ZAxis3D/ZAxis3DHander.cs | 198 +++++++++++++ .../Axis/ZAxis3D/ZAxis3DHander.cs.meta | 11 + Runtime/Component/VisualMap/VisualMap.cs | 25 +- Runtime/Coord/Grid3D.meta | 8 + Runtime/Coord/Grid3D/GridCoord3D.cs | 270 ++++++++++++++++++ Runtime/Coord/Grid3D/GridCoord3D.cs.meta | 11 + Runtime/Coord/Grid3D/GridCoord3DContext.cs | 23 ++ .../Coord/Grid3D/GridCoord3DContext.cs.meta | 11 + Runtime/Coord/Grid3D/GridCoord3DHandler.cs | 80 ++++++ .../Coord/Grid3D/GridCoord3DHandler.cs.meta | 11 + Runtime/Internal/BaseChart.Custom.cs | 6 +- Runtime/Internal/Data/GraphData.cs | 6 + Runtime/Internal/Utilities/DataHelper.cs | 2 +- Runtime/Serie/Candlestick/Candlestick.cs | 1 - Runtime/Serie/Line/LineHandler.GridCoord.cs | 2 +- Runtime/Serie/Line/LineHelper.cs | 7 +- Runtime/Serie/Line/SimplifiedLineHandler.cs | 2 +- Runtime/Serie/SerieContext.cs | 14 +- Runtime/Serie/SeriesHelper.cs | 25 +- Runtime/XUGL/UGLHelper.cs | 19 +- 55 files changed, 2062 insertions(+), 51 deletions(-) create mode 100644 Editor/ChildComponents/ViewControlDrawer.cs create mode 100644 Editor/ChildComponents/ViewControlDrawer.cs.meta create mode 100644 Editor/MainComponents/GridCoord3DEditor.cs create mode 100644 Editor/MainComponents/GridCoord3DEditor.cs.meta create mode 100644 Runtime/Component/Axis/Axis3DHelper.cs create mode 100644 Runtime/Component/Axis/Axis3DHelper.cs.meta create mode 100644 Runtime/Component/Axis/XAxis3D.meta create mode 100644 Runtime/Component/Axis/XAxis3D/XAxis3D.cs create mode 100644 Runtime/Component/Axis/XAxis3D/XAxis3D.cs.meta create mode 100644 Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs create mode 100644 Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs.meta create mode 100644 Runtime/Component/Axis/YAxis3D.meta create mode 100644 Runtime/Component/Axis/YAxis3D/YAxis3D.cs create mode 100644 Runtime/Component/Axis/YAxis3D/YAxis3D.cs.meta create mode 100644 Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs create mode 100644 Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs.meta create mode 100644 Runtime/Component/Axis/ZAxis3D.meta create mode 100644 Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs create mode 100644 Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs.meta create mode 100644 Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs create mode 100644 Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs.meta create mode 100644 Runtime/Coord/Grid3D.meta create mode 100644 Runtime/Coord/Grid3D/GridCoord3D.cs create mode 100644 Runtime/Coord/Grid3D/GridCoord3D.cs.meta create mode 100644 Runtime/Coord/Grid3D/GridCoord3DContext.cs create mode 100644 Runtime/Coord/Grid3D/GridCoord3DContext.cs.meta create mode 100644 Runtime/Coord/Grid3D/GridCoord3DHandler.cs create mode 100644 Runtime/Coord/Grid3D/GridCoord3DHandler.cs.meta diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index 6b971eb0..92c6fdf5 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -22,6 +22,7 @@ slug: /api - [AreaStyle](#areastyle) - [ArrowStyle](#arrowstyle) - [Axis](#axis) +- [Axis3DHelper](#axis3dhelper) - [AxisAnimation](#axisanimation) - [AxisContext](#axiscontext) - [AxisHandler<T>](#axishandlert) @@ -67,6 +68,7 @@ slug: /api - [ComponentTheme](#componenttheme) - [CoordOptionsAttribute](#coordoptionsattribute) - [CoordSystem](#coordsystem) +- [DataHelper](#datahelper) - [DataZoom](#datazoom) - [DataZoomContext](#datazoomcontext) - [DataZoomHelper](#datazoomhelper) @@ -84,6 +86,8 @@ slug: /api - [GraphEdge](#graphedge) - [GraphNode](#graphnode) - [GridCoord](#gridcoord) +- [GridCoord3D](#gridcoord3d) +- [GridCoord3DContext](#gridcoord3dcontext) - [GridCoordContext](#gridcoordcontext) - [GridLayout](#gridlayout) - [GridLayoutContext](#gridlayoutcontext) @@ -119,6 +123,7 @@ slug: /api - [Line](#line) - [LineArrow](#linearrow) - [LineChart](#linechart) +- [LineHelper](#linehelper) - [LineStyle](#linestyle) - [ListFor](#listfor) - [ListForComponent](#listforcomponent) @@ -225,12 +230,14 @@ slug: /api - [UIComponent](#uicomponent) - [UIComponentTheme](#uicomponenttheme) - [UIHelper](#uihelper) +- [ViewControl](#viewcontrol) - [VisualMap](#visualmap) - [VisualMapContext](#visualmapcontext) - [VisualMapHelper](#visualmaphelper) - [VisualMapRange](#visualmaprange) - [VisualMapTheme](#visualmaptheme) - [XAxis](#xaxis) +- [XAxis3D](#xaxis3d) - [XChartsMgr](#xchartsmgr) - [XCResourceImporterWindow](#xcresourceimporterwindow) - [XCResourcesImporter](#xcresourcesimporter) @@ -238,6 +245,8 @@ slug: /api - [XCThemeMgr](#xcthememgr) - [XLog](#xlog) - [YAxis](#yaxis) +- [YAxis3D](#yaxis3d) +- [ZAxis3D](#zaxis3d) ## AngleAxis @@ -418,7 +427,7 @@ The style of area. ## Axis -> class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) / Subclasses: [AngleAxis](#angleaxis),[ParallelAxis](#parallelaxis),[RadiusAxis](#radiusaxis),[SingleAxis](#singleaxis),[XAxis](#xaxis),[YAxis](#yaxis) +> class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) / Subclasses: [AngleAxis](#angleaxis),[ParallelAxis](#parallelaxis),[RadiusAxis](#radiusaxis),[SingleAxis](#singleaxis),[XAxis](#xaxis),[XAxis3D](#xaxis3d),[YAxis](#yaxis),[YAxis3D](#yaxis3d),[ZAxis3D](#zaxis3d) The axis in rectangular coordinate. @@ -434,7 +443,7 @@ The axis in rectangular coordinate. |GetAddedDataCount()||public int GetAddedDataCount()
get the history data count. | |GetData()||public string GetData(int index)
获得指定索引的类目数据 | |GetData()||public string GetData(int index, DataZoom dataZoom)
获得在dataZoom范围内指定索引的类目数据 | -|GetDistance()||public float GetDistance(double value, float axisLength)
获得值在坐标轴上的距离 | +|GetDistance()||public float GetDistance(double value, float axisLength = 0)
获得值在坐标轴上的距离 | |GetIcon()||public Sprite GetIcon(int index)| |GetLabelValue()||public double GetLabelValue(int index)| |GetLastLabelValue()||public double GetLastLabelValue()| @@ -458,6 +467,17 @@ The axis in rectangular coordinate. |UpdateIcon()||public void UpdateIcon(int index, Sprite icon)
更新图标 | |UpdateZeroOffset()||public void UpdateZeroOffset(float axisLength)| +## Axis3DHelper + +> class in XCharts.Runtime + + +|public method|since|description| +|--|--|--| +|Get3DGridPosition()||public static Vector3 Get3DGridPosition(GridCoord3D grid, XAxis3D xAxis, YAxis3D yAxis, double xValue, double yValue)| +|Get3DGridPosition()||public static Vector3 Get3DGridPosition(GridCoord3D grid, XAxis3D xAxis, YAxis3D yAxis, ZAxis3D zAxis, double xValue, double yValue, double zValue)| +|GetLabelPosition()||public static Vector3 GetLabelPosition(int i, Axis axis, Axis relativedAxis, AxisTheme theme, float scaleWid)| + ## AxisAnimation > class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent) @@ -1171,7 +1191,7 @@ A candlestick chart is a style of financial chart used to describe price movemen ## ChildComponent -> class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle),[AxisAnimation](#axisanimation),[AxisName](#axisname),[AxisSplitArea](#axissplitarea),[AreaStyle](#areastyle),[ArrowStyle](#arrowstyle),[BaseLine](#baseline),[BorderStyle](#borderstyle),[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) +> class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle),[AxisAnimation](#axisanimation),[AxisName](#axisname),[AxisSplitArea](#axissplitarea),[AreaStyle](#areastyle),[ArrowStyle](#arrowstyle),[BaseLine](#baseline),[BorderStyle](#borderstyle),[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),[ViewControl](#viewcontrol),[UIComponentTheme](#uicomponenttheme),[SerieData](#seriedata),[SerieDataLink](#seriedatalink),[ComponentTheme](#componenttheme),[SerieTheme](#serietheme),[ThemeStyle](#themestyle) |public method|since|description| @@ -1269,10 +1289,15 @@ the comment mark style. ## CoordSystem -> class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) / Subclasses: [RadarCoord](#radarcoord),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[ParallelCoord](#parallelcoord),[PolarCoord](#polarcoord),[SingleAxisCoord](#singleaxiscoord) +> class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) / Subclasses: [RadarCoord](#radarcoord),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[GridCoord3D](#gridcoord3d),[ParallelCoord](#parallelcoord),[PolarCoord](#polarcoord),[SingleAxisCoord](#singleaxiscoord) Coordinate system component. +## DataHelper + +> class in XCharts.Runtime + + ## DataZoom > class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent),[IUpdateRuntimeData](#iupdateruntimedata) @@ -1332,6 +1357,7 @@ DataZoom component is used for zooming a specific area, which enables user to in |GetDateTime()||public static DateTime GetDateTime(int timestamp)| |GetTimestamp()||public static int GetTimestamp()| |GetTimestamp()||public static int GetTimestamp(DateTime time)| +|GetTimestamp()||public static int GetTimestamp(string dateTime)| ## DebugInfo @@ -1429,6 +1455,7 @@ the data struct of graph. |ExpandNode()||public void ExpandNode(string nodeId, bool flag)| |GetDepthNodes()||public List<List<GraphNode>> GetDepthNodes()| |GetEdge()||public GraphEdge GetEdge(string nodeId1, string nodeId2)| +|GetExpandedNodesCount()||public static int GetExpandedNodesCount(List<GraphNode> nodes)| |GetMaxDepth()||public int GetMaxDepth()| |GetNode()||public GraphNode GetNode(string nodeId)| |GetNodeDepth()||// public int GetNodeDepth(GraphNode node)| @@ -1485,6 +1512,28 @@ Grid component. |NotAnyIntersect()|v3.10.0|public bool NotAnyIntersect(Vector3 sp, Vector3 ep)
Determines whether a given line segment will not intersect the Grid boundary at all. | |UpdateRuntimeData()||public void UpdateRuntimeData(BaseChart chart)| +## GridCoord3D + +> class in XCharts.Runtime / Inherits from: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer) + +> Since `v3.11.0` + +Grid component. + +|public method|since|description| +|--|--|--| +|Clamp()||public void Clamp(ref Vector3 pos)
Clamp the position of pos to the grid. | +|Contains()||public bool Contains(Vector3 pos)
Whether the given position is in the grid. | +|IsLeft()||public bool IsLeft()
The opening of the coordinate system faces to the left. 坐标系开口朝向左边。 | +|IsPointerEnter()||public bool IsPointerEnter()
Whether the pointer is in the grid. | +|NotAnyIntersect()||public bool NotAnyIntersect(Vector3 sp, Vector3 ep)
Determines whether a given line segment will not intersect the Grid boundary at all. | +|UpdateRuntimeData()||public void UpdateRuntimeData(BaseChart chart)| + +## GridCoord3DContext + +> class in XCharts.Runtime / Inherits from: [MainComponentContext](#maincomponentcontext) + + ## GridCoordContext > class in XCharts.Runtime / Inherits from: [MainComponentContext](#maincomponentcontext) @@ -1635,7 +1684,7 @@ The interface for serie component. ## ISerieContainer -> class in XCharts.Runtime / Subclasses: [RadarCoord](#radarcoord),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[ParallelCoord](#parallelcoord),[PolarCoord](#polarcoord) +> class in XCharts.Runtime / Subclasses: [RadarCoord](#radarcoord),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[GridCoord3D](#gridcoord3d),[ParallelCoord](#parallelcoord),[PolarCoord](#polarcoord) ## ISerieDataComponent @@ -1671,7 +1720,7 @@ The interface for serie data component. ## IUpdateRuntimeData -> class in XCharts.Runtime / Subclasses: [SingleAxis](#singleaxis),[DataZoom](#datazoom),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[GridLayout](#gridlayout),[ParallelCoord](#parallelcoord) +> class in XCharts.Runtime / Subclasses: [SingleAxis](#singleaxis),[DataZoom](#datazoom),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[GridLayout](#gridlayout),[GridCoord3D](#gridcoord3d),[ParallelCoord](#parallelcoord) ## LabelLine @@ -1870,6 +1919,16 @@ Line chart relates all the data points symbol by broken lines, which is used to |DefaultStepLineChart()||public void DefaultStepLineChart()
default step line chart. | |DefaultTimeLineChart()||public void DefaultTimeLineChart()
default time line chart. | +## LineHelper + +> class in XCharts.Runtime + + +|public method|since|description| +|--|--|--| +|GetDataAverageRate()||public static int GetDataAverageRate(Serie serie, float axisLength, int maxCount, bool isYAxis)| +|GetLineWidth()||public static float GetLineWidth(ref bool interacting, Serie serie, float defaultWidth)| + ## LineStyle > class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent),[ISerieDataComponent](#iseriedatacomponent) @@ -1967,7 +2026,7 @@ Location type. Quick to set the general location. ## MainComponentContext -> class in XCharts.Runtime / Subclasses: [AxisContext](#axiscontext),[DataZoomContext](#datazoomcontext),[LegendContext](#legendcontext),[RadarCoordContext](#radarcoordcontext),[VisualMapContext](#visualmapcontext),[GridCoordContext](#gridcoordcontext),[GridLayoutContext](#gridlayoutcontext),[ParallelCoordContext](#parallelcoordcontext),[PolarCoordContext](#polarcoordcontext) +> class in XCharts.Runtime / Subclasses: [AxisContext](#axiscontext),[DataZoomContext](#datazoomcontext),[LegendContext](#legendcontext),[RadarCoordContext](#radarcoordcontext),[VisualMapContext](#visualmapcontext),[GridCoordContext](#gridcoordcontext),[GridLayoutContext](#gridlayoutcontext),[GridCoord3DContext](#gridcoord3dcontext),[ParallelCoordContext](#parallelcoordcontext),[PolarCoordContext](#polarcoordcontext) ## MainComponentHandler @@ -3220,6 +3279,7 @@ UGUI Graphics Library. |IsClearColor()||public static bool IsClearColor(Color32 color)| |IsPointInPolygon()||public static bool IsPointInPolygon(Vector3 p, List<Vector2> polyons)| |IsPointInPolygon()||public static bool IsPointInPolygon(Vector3 p, List<Vector3> polyons)| +|IsPointInPolygon()||public static bool IsPointInPolygon(Vector3 p, params Vector3[] polyons)| |IsPointInTriangle()||public static bool IsPointInTriangle(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 check)| |IsValueEqualsColor()||public static bool IsValueEqualsColor(Color color1, Color color2)| |IsValueEqualsColor()||public static bool IsValueEqualsColor(Color32 color1, Color32 color2)| @@ -3259,6 +3319,14 @@ UI组件基类。 UI帮助类。 +## ViewControl + +> class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent) + +> Since `v3.11.0` + +View control component in 3D coordinate system. + ## VisualMap > class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) @@ -3272,6 +3340,7 @@ VisualMap component. Mapping data to visual elements such as colors. |ClearComponentDirty()||public override void ClearComponentDirty()| |ClearVerticesDirty()||public override void ClearVerticesDirty()| |GetColor()||public Color32 GetColor(double value)| +|GetColor()||public Color32 GetColor(double xValue, double yValue, double zValue, byte alpha = 255)| |GetIndex()||public int GetIndex(double value)| |GetValue()||public double GetValue(Vector3 pos, Rect chartRect)| |IsInRangeMaxRect()||public bool IsInRangeMaxRect(Vector3 local, Rect chartRect, float triangleLen)| @@ -3329,6 +3398,18 @@ The x axis in cartesian(rectangular) coordinate. |--|--|--| |SetDefaultValue()||public override void SetDefaultValue()
The x axis in cartesian(rectangular) coordinate. | +## XAxis3D + +> class in XCharts.Runtime / Inherits from: [Axis](#axis) + +> Since `v3.11.0` + +The x axis in cartesian(rectangular) coordinate. + +|public method|since|description| +|--|--|--| +|SetDefaultValue()||public override void SetDefaultValue()
The x axis in cartesian(rectangular) coordinate. | + ## XChartsMgr > class in XCharts.Runtime @@ -3434,3 +3515,27 @@ The x axis in cartesian(rectangular) coordinate. |--|--|--| |SetDefaultValue()||public override void SetDefaultValue()
The x axis in cartesian(rectangular) coordinate. | +## YAxis3D + +> class in XCharts.Runtime / Inherits from: [Axis](#axis) + +> Since `v3.11.0` + +The x axis in cartesian(rectangular) coordinate. + +|public method|since|description| +|--|--|--| +|SetDefaultValue()||public override void SetDefaultValue()
The x axis in cartesian(rectangular) coordinate. | + +## ZAxis3D + +> class in XCharts.Runtime / Inherits from: [Axis](#axis) + +> Since `v3.11.0` + +The x axis in cartesian(rectangular) coordinate. + +|public method|since|description| +|--|--|--| +|SetDefaultValue()||public override void SetDefaultValue()
The x axis in cartesian(rectangular) coordinate. | + diff --git a/Documentation~/en/configuration.md b/Documentation~/en/configuration.md index 3d34f3f9..3f87ec82 100644 --- a/Documentation~/en/configuration.md +++ b/Documentation~/en/configuration.md @@ -56,6 +56,7 @@ import APITable from '@site/src/components/APITable'; - [CoordSystem](#coordsystem) - [DataZoom](#datazoom) - [GridCoord](#gridcoord) +- [GridCoord3D](#gridcoord3d) - [GridLayout](#gridlayout) - [Legend](#legend) - [MarkArea](#markarea) @@ -72,7 +73,10 @@ import APITable from '@site/src/components/APITable'; - [Tooltip](#tooltip) - [VisualMap](#visualmap) - [XAxis](#xaxis) +- [XAxis3D](#xaxis3d) - [YAxis](#yaxis) +- [YAxis3D](#yaxis3d) +- [ZAxis3D](#zaxis3d) ## ChildComponent @@ -137,6 +141,7 @@ import APITable from '@site/src/components/APITable'; - [TitleTheme](#titletheme) - [TooltipTheme](#tooltiptheme) - [UIComponentTheme](#uicomponenttheme) +- [ViewControl](#viewcontrol) - [VisualMapRange](#visualmaprange) - [VisualMapTheme](#visualmaptheme) @@ -385,7 +390,7 @@ The style of area. ## Axis -> class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) / Subclasses: [AngleAxis](#angleaxis), [ParallelAxis](#parallelaxis), [RadiusAxis](#radiusaxis), [SingleAxis](#singleaxis), [XAxis](#xaxis), [YAxis](#yaxis) +> class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) / Subclasses: [AngleAxis](#angleaxis), [ParallelAxis](#parallelaxis), [RadiusAxis](#radiusaxis), [SingleAxis](#singleaxis), [XAxis](#xaxis), [XAxis3D](#xaxis3d), [YAxis](#yaxis), [YAxis3D](#yaxis3d), [ZAxis3D](#zaxis3d) The axis in rectangular coordinate. @@ -402,7 +407,7 @@ The axis in rectangular coordinate. |gridIndex|||The index of the grid on which the axis are located, by default, is in the first grid. |polarIndex|||The index of the polar on which the axis are located, by default, is in the first polar. |parallelIndex|||The index of the parallel on which the axis are located, by default, is in the first parallel. -|position|||the position of axis in grid.
`Axis.AxisPosition`:
- `Left`: the position of axis in grid.
- `Right`: the position of axis in grid.
- `Bottom`: the position of axis in grid.
- `Top`: the position of axis in grid.
| +|position|||the position of axis in grid.
`Axis.AxisPosition`:
- `Left`: the position of axis in grid.
- `Right`: the position of axis in grid.
- `Bottom`: the position of axis in grid.
- `Top`: the position of axis in grid.
- `Center`: the position of axis in grid.
| |offset|||the offset of axis from the default position. Useful when the same position has multiple axes. |min|||The minimun value of axis.Valid when `minMaxType` is `Custom` |max|||The maximum value of axis.Valid when `minMaxType` is `Custom` @@ -606,6 +611,7 @@ Split line of axis in grid area. |autoColor|||auto color. |showStartLine|true|v3.3.0|Whether to show the first split line. |showEndLine|true|v3.3.0|Whether to show the last split line. +|showZLine|true|v3.11.0|Whether to show the Z axis part of the split line. Generally used for 3D coordinate systems. ```mdx-code-block @@ -774,7 +780,7 @@ The style of border. ## ChildComponent -> class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle), [AxisAnimation](#axisanimation), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [BorderStyle](#borderstyle), [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) +> class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle), [AxisAnimation](#axisanimation), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [BorderStyle](#borderstyle), [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), [ViewControl](#viewcontrol), [UIComponentTheme](#uicomponenttheme), [SerieData](#seriedata), [SerieDataLink](#seriedatalink), [ComponentTheme](#componenttheme), [SerieTheme](#serietheme), [ThemeStyle](#themestyle) ## Comment @@ -865,7 +871,7 @@ the comment mark style. ## CoordSystem -> class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) / Subclasses: [RadarCoord](#radarcoord), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [ParallelCoord](#parallelcoord), [PolarCoord](#polarcoord), [SingleAxisCoord](#singleaxiscoord) +> class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) / Subclasses: [RadarCoord](#radarcoord), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [GridCoord3D](#gridcoord3d), [ParallelCoord](#parallelcoord), [PolarCoord](#polarcoord), [SingleAxisCoord](#singleaxiscoord) Coordinate system component. @@ -1022,6 +1028,37 @@ Grid component. ``` +## GridCoord3D + +> class in XCharts.Runtime / Inherits from: [CoordSystem](#coordsystem), [IUpdateRuntimeData](#iupdateruntimedata), [ISerieContainer](#iseriecontainer) + +> Since `v3.11.0` + +Grid component. + +```mdx-code-block + +``` + + +|field|default|since|comment| +|--|--|--|--| +|show|true||Whether to show the grid in rectangular coordinate. +|left|0.15f||Distance between grid component and the left side of the container. +|right|0.2f||Distance between grid component and the right side of the container. +|top|0.3f||Distance between grid component and the top side of the container. +|bottom|0.15f||Distance between grid component and the bottom side of the container. +|showBorder|false||Whether to show the grid border. +|boxWidth|0.55f||The width of the box in the coordinate system. +|boxHeight|0.4f||The height of the box in the coordinate system. +|boxDepth|0.2f||The depth of the box in the coordinate system. +|xYExchanged|false|| +|viewControl|||View control component in 3D coordinate system. [ViewControl](#viewcontrol)| + +```mdx-code-block + +``` + ## GridLayout > class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent), [IUpdateRuntimeData](#iupdateruntimedata) @@ -1177,7 +1214,7 @@ The interface for serie component. ## ISerieContainer -> class in XCharts.Runtime / Subclasses: [RadarCoord](#radarcoord), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [ParallelCoord](#parallelcoord), [PolarCoord](#polarcoord) +> class in XCharts.Runtime / Subclasses: [RadarCoord](#radarcoord), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [GridCoord3D](#gridcoord3d), [ParallelCoord](#parallelcoord), [PolarCoord](#polarcoord) ## ISerieDataComponent @@ -1229,7 +1266,7 @@ The interface for serie data component. ## IUpdateRuntimeData -> class in XCharts.Runtime / Subclasses: [SingleAxis](#singleaxis), [DataZoom](#datazoom), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [GridLayout](#gridlayout), [ParallelCoord](#parallelcoord) +> class in XCharts.Runtime / Subclasses: [SingleAxis](#singleaxis), [DataZoom](#datazoom), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [GridLayout](#gridlayout), [GridCoord3D](#gridcoord3d), [ParallelCoord](#parallelcoord) ## LabelLine @@ -2377,6 +2414,28 @@ Tooltip component. ``` +## ViewControl + +> class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent) + +> Since `v3.11.0` + +View control component in 3D coordinate system. + +```mdx-code-block + +``` + + +|field|default|since|comment| +|--|--|--|--| +|alpha|90f||The angle of the view in the x-z plane. +|beta|55f||The angle of the view in the y-z plane. + +```mdx-code-block + +``` + ## VisualMap > class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) @@ -2467,6 +2526,14 @@ VisualMap component. Mapping data to visual elements such as colors. The x axis in cartesian(rectangular) coordinate. +## XAxis3D + +> class in XCharts.Runtime / Inherits from: [Axis](#axis) + +> Since `v3.11.0` + +The x axis in cartesian(rectangular) coordinate. + ## XCResourcesImporter > class in XCharts.Runtime @@ -2528,3 +2595,19 @@ The x axis in cartesian(rectangular) coordinate. The x axis in cartesian(rectangular) coordinate. +## YAxis3D + +> class in XCharts.Runtime / Inherits from: [Axis](#axis) + +> Since `v3.11.0` + +The x axis in cartesian(rectangular) coordinate. + +## ZAxis3D + +> class in XCharts.Runtime / Inherits from: [Axis](#axis) + +> Since `v3.11.0` + +The x axis in cartesian(rectangular) coordinate. + diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index 8955a3ac..c9c54379 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -22,6 +22,7 @@ slug: /api - [AreaStyle](#areastyle) - [ArrowStyle](#arrowstyle) - [Axis](#axis) +- [Axis3DHelper](#axis3dhelper) - [AxisAnimation](#axisanimation) - [AxisContext](#axiscontext) - [AxisHandler<T>](#axishandlert) @@ -67,6 +68,7 @@ slug: /api - [ComponentTheme](#componenttheme) - [CoordOptionsAttribute](#coordoptionsattribute) - [CoordSystem](#coordsystem) +- [DataHelper](#datahelper) - [DataZoom](#datazoom) - [DataZoomContext](#datazoomcontext) - [DataZoomHelper](#datazoomhelper) @@ -84,6 +86,8 @@ slug: /api - [GraphEdge](#graphedge) - [GraphNode](#graphnode) - [GridCoord](#gridcoord) +- [GridCoord3D](#gridcoord3d) +- [GridCoord3DContext](#gridcoord3dcontext) - [GridCoordContext](#gridcoordcontext) - [GridLayout](#gridlayout) - [GridLayoutContext](#gridlayoutcontext) @@ -119,6 +123,7 @@ slug: /api - [Line](#line) - [LineArrow](#linearrow) - [LineChart](#linechart) +- [LineHelper](#linehelper) - [LineStyle](#linestyle) - [ListFor](#listfor) - [ListForComponent](#listforcomponent) @@ -225,12 +230,14 @@ slug: /api - [UIComponent](#uicomponent) - [UIComponentTheme](#uicomponenttheme) - [UIHelper](#uihelper) +- [ViewControl](#viewcontrol) - [VisualMap](#visualmap) - [VisualMapContext](#visualmapcontext) - [VisualMapHelper](#visualmaphelper) - [VisualMapRange](#visualmaprange) - [VisualMapTheme](#visualmaptheme) - [XAxis](#xaxis) +- [XAxis3D](#xaxis3d) - [XChartsMgr](#xchartsmgr) - [XCResourceImporterWindow](#xcresourceimporterwindow) - [XCResourcesImporter](#xcresourcesimporter) @@ -238,6 +245,8 @@ slug: /api - [XCThemeMgr](#xcthememgr) - [XLog](#xlog) - [YAxis](#yaxis) +- [YAxis3D](#yaxis3d) +- [ZAxis3D](#zaxis3d) ## AngleAxis @@ -418,7 +427,7 @@ slug: /api ## Axis -> class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类: [AngleAxis](#angleaxis),[ParallelAxis](#parallelaxis),[RadiusAxis](#radiusaxis),[SingleAxis](#singleaxis),[XAxis](#xaxis),[YAxis](#yaxis) +> class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类: [AngleAxis](#angleaxis),[ParallelAxis](#parallelaxis),[RadiusAxis](#radiusaxis),[SingleAxis](#singleaxis),[XAxis](#xaxis),[XAxis3D](#xaxis3d),[YAxis](#yaxis),[YAxis3D](#yaxis3d),[ZAxis3D](#zaxis3d) 直角坐标系的坐标轴组件。 @@ -434,7 +443,7 @@ slug: /api |GetAddedDataCount()||public int GetAddedDataCount()
获得添加过的历史数据总数 | |GetData()||public string GetData(int index)
获得指定索引的类目数据 | |GetData()||public string GetData(int index, DataZoom dataZoom)
获得在dataZoom范围内指定索引的类目数据 | -|GetDistance()||public float GetDistance(double value, float axisLength)
获得值在坐标轴上的距离 | +|GetDistance()||public float GetDistance(double value, float axisLength = 0)
获得值在坐标轴上的距离 | |GetIcon()||public Sprite GetIcon(int index)| |GetLabelValue()||public double GetLabelValue(int index)| |GetLastLabelValue()||public double GetLastLabelValue()| @@ -458,6 +467,17 @@ slug: /api |UpdateIcon()||public void UpdateIcon(int index, Sprite icon)
更新图标 | |UpdateZeroOffset()||public void UpdateZeroOffset(float axisLength)| +## Axis3DHelper + +> class in XCharts.Runtime + + +|API|版本|描述| +|--|--|--| +|Get3DGridPosition()||public static Vector3 Get3DGridPosition(GridCoord3D grid, XAxis3D xAxis, YAxis3D yAxis, double xValue, double yValue)| +|Get3DGridPosition()||public static Vector3 Get3DGridPosition(GridCoord3D grid, XAxis3D xAxis, YAxis3D yAxis, ZAxis3D zAxis, double xValue, double yValue, double zValue)| +|GetLabelPosition()||public static Vector3 GetLabelPosition(int i, Axis axis, Axis relativedAxis, AxisTheme theme, float scaleWid)| + ## AxisAnimation > class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) @@ -1171,7 +1191,7 @@ slug: /api ## ChildComponent -> class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle),[AxisAnimation](#axisanimation),[AxisName](#axisname),[AxisSplitArea](#axissplitarea),[AreaStyle](#areastyle),[ArrowStyle](#arrowstyle),[BaseLine](#baseline),[BorderStyle](#borderstyle),[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) +> class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle),[AxisAnimation](#axisanimation),[AxisName](#axisname),[AxisSplitArea](#axissplitarea),[AreaStyle](#areastyle),[ArrowStyle](#arrowstyle),[BaseLine](#baseline),[BorderStyle](#borderstyle),[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),[ViewControl](#viewcontrol),[UIComponentTheme](#uicomponenttheme),[SerieData](#seriedata),[SerieDataLink](#seriedatalink),[ComponentTheme](#componenttheme),[SerieTheme](#serietheme),[ThemeStyle](#themestyle) |API|版本|描述| @@ -1269,10 +1289,15 @@ slug: /api ## CoordSystem -> class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类: [RadarCoord](#radarcoord),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[ParallelCoord](#parallelcoord),[PolarCoord](#polarcoord),[SingleAxisCoord](#singleaxiscoord) +> class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类: [RadarCoord](#radarcoord),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[GridCoord3D](#gridcoord3d),[ParallelCoord](#parallelcoord),[PolarCoord](#polarcoord),[SingleAxisCoord](#singleaxiscoord) 坐标系系统。 +## DataHelper + +> class in XCharts.Runtime + + ## DataZoom > class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent),[IUpdateRuntimeData](#iupdateruntimedata) @@ -1332,6 +1357,7 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息 |GetDateTime()||public static DateTime GetDateTime(int timestamp)| |GetTimestamp()||public static int GetTimestamp()| |GetTimestamp()||public static int GetTimestamp(DateTime time)| +|GetTimestamp()||public static int GetTimestamp(string dateTime)| ## DebugInfo @@ -1429,6 +1455,7 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息 |ExpandNode()||public void ExpandNode(string nodeId, bool flag)| |GetDepthNodes()||public List<List<GraphNode>> GetDepthNodes()| |GetEdge()||public GraphEdge GetEdge(string nodeId1, string nodeId2)| +|GetExpandedNodesCount()||public static int GetExpandedNodesCount(List<GraphNode> nodes)| |GetMaxDepth()||public int GetMaxDepth()| |GetNode()||public GraphNode GetNode(string nodeId)| |GetNodeDepth()||// public int GetNodeDepth(GraphNode node)| @@ -1485,6 +1512,28 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart |NotAnyIntersect()|v3.10.0|public bool NotAnyIntersect(Vector3 sp, Vector3 ep)
判断给定的线段是否与Grid边界是否完全不会相交。 | |UpdateRuntimeData()||public void UpdateRuntimeData(BaseChart chart)| +## GridCoord3D + +> class in XCharts.Runtime / 继承自: [CoordSystem](#coordsystem),[IUpdateRuntimeData](#iupdateruntimedata),[ISerieContainer](#iseriecontainer) + +> 从 `v3.11.0` 开始支持 + +Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart can be drawn in grid. + +|API|版本|描述| +|--|--|--| +|Clamp()||public void Clamp(ref Vector3 pos)
将位置限制在网格内。 | +|Contains()||public bool Contains(Vector3 pos)
给定的位置是否在网格内。 | +|IsLeft()||public bool IsLeft()
The opening of the coordinate system faces to the left. 坐标系开口朝向左边。 | +|IsPointerEnter()||public bool IsPointerEnter()
指针是否在网格内。 | +|NotAnyIntersect()||public bool NotAnyIntersect(Vector3 sp, Vector3 ep)
判断给定的线段是否与Grid边界是否完全不会相交。 | +|UpdateRuntimeData()||public void UpdateRuntimeData(BaseChart chart)| + +## GridCoord3DContext + +> class in XCharts.Runtime / 继承自: [MainComponentContext](#maincomponentcontext) + + ## GridCoordContext > class in XCharts.Runtime / 继承自: [MainComponentContext](#maincomponentcontext) @@ -1635,7 +1684,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart ## ISerieContainer -> class in XCharts.Runtime / 子类: [RadarCoord](#radarcoord),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[ParallelCoord](#parallelcoord),[PolarCoord](#polarcoord) +> class in XCharts.Runtime / 子类: [RadarCoord](#radarcoord),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[GridCoord3D](#gridcoord3d),[ParallelCoord](#parallelcoord),[PolarCoord](#polarcoord) ## ISerieDataComponent @@ -1671,7 +1720,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart ## IUpdateRuntimeData -> class in XCharts.Runtime / 子类: [SingleAxis](#singleaxis),[DataZoom](#datazoom),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[GridLayout](#gridlayout),[ParallelCoord](#parallelcoord) +> class in XCharts.Runtime / 子类: [SingleAxis](#singleaxis),[DataZoom](#datazoom),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[GridLayout](#gridlayout),[GridCoord3D](#gridcoord3d),[ParallelCoord](#parallelcoord) ## LabelLine @@ -1870,6 +1919,16 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart |DefaultStepLineChart()||public void DefaultStepLineChart()
默认阶梯折线图。 | |DefaultTimeLineChart()||public void DefaultTimeLineChart()
默认时间折线图。 | +## LineHelper + +> class in XCharts.Runtime + + +|API|版本|描述| +|--|--|--| +|GetDataAverageRate()||public static int GetDataAverageRate(Serie serie, float axisLength, int maxCount, bool isYAxis)| +|GetLineWidth()||public static float GetLineWidth(ref bool interacting, Serie serie, float defaultWidth)| + ## LineStyle > class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent),[ISerieDataComponent](#iseriedatacomponent) @@ -1967,7 +2026,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart ## MainComponentContext -> class in XCharts.Runtime / 子类: [AxisContext](#axiscontext),[DataZoomContext](#datazoomcontext),[LegendContext](#legendcontext),[RadarCoordContext](#radarcoordcontext),[VisualMapContext](#visualmapcontext),[GridCoordContext](#gridcoordcontext),[GridLayoutContext](#gridlayoutcontext),[ParallelCoordContext](#parallelcoordcontext),[PolarCoordContext](#polarcoordcontext) +> class in XCharts.Runtime / 子类: [AxisContext](#axiscontext),[DataZoomContext](#datazoomcontext),[LegendContext](#legendcontext),[RadarCoordContext](#radarcoordcontext),[VisualMapContext](#visualmapcontext),[GridCoordContext](#gridcoordcontext),[GridLayoutContext](#gridlayoutcontext),[GridCoord3DContext](#gridcoord3dcontext),[ParallelCoordContext](#parallelcoordcontext),[PolarCoordContext](#polarcoordcontext) ## MainComponentHandler @@ -3220,6 +3279,7 @@ UGUI 图形库 |IsClearColor()||public static bool IsClearColor(Color32 color)| |IsPointInPolygon()||public static bool IsPointInPolygon(Vector3 p, List<Vector2> polyons)| |IsPointInPolygon()||public static bool IsPointInPolygon(Vector3 p, List<Vector3> polyons)| +|IsPointInPolygon()||public static bool IsPointInPolygon(Vector3 p, params Vector3[] polyons)| |IsPointInTriangle()||public static bool IsPointInTriangle(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 check)| |IsValueEqualsColor()||public static bool IsValueEqualsColor(Color color1, Color color2)| |IsValueEqualsColor()||public static bool IsValueEqualsColor(Color32 color1, Color32 color2)| @@ -3259,6 +3319,14 @@ UI组件基类。 UI帮助类。 +## ViewControl + +> class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) + +> 从 `v3.11.0` 开始支持 + +3D视角控制组件。 + ## VisualMap > class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) @@ -3272,6 +3340,7 @@ UI帮助类。 |ClearComponentDirty()||public override void ClearComponentDirty()| |ClearVerticesDirty()||public override void ClearVerticesDirty()| |GetColor()||public Color32 GetColor(double value)| +|GetColor()||public Color32 GetColor(double xValue, double yValue, double zValue, byte alpha = 255)| |GetIndex()||public int GetIndex(double value)| |GetValue()||public double GetValue(Vector3 pos, Rect chartRect)| |IsInRangeMaxRect()||public bool IsInRangeMaxRect(Vector3 local, Rect chartRect, float triangleLen)| @@ -3329,6 +3398,18 @@ UI帮助类。 |--|--|--| |SetDefaultValue()||public override void SetDefaultValue()
直角坐标系 grid 中的 x 轴。 | +## XAxis3D + +> class in XCharts.Runtime / 继承自: [Axis](#axis) + +> 从 `v3.11.0` 开始支持 + +直角坐标系 grid 中的 x 轴。 + +|API|版本|描述| +|--|--|--| +|SetDefaultValue()||public override void SetDefaultValue()
直角坐标系 grid 中的 x 轴。 | + ## XChartsMgr > class in XCharts.Runtime @@ -3434,3 +3515,27 @@ UI帮助类。 |--|--|--| |SetDefaultValue()||public override void SetDefaultValue()
直角坐标系 grid 中的 y 轴。 | +## YAxis3D + +> class in XCharts.Runtime / 继承自: [Axis](#axis) + +> 从 `v3.11.0` 开始支持 + +直角坐标系 grid 中的 y 轴。 + +|API|版本|描述| +|--|--|--| +|SetDefaultValue()||public override void SetDefaultValue()
直角坐标系 grid 中的 y 轴。 | + +## ZAxis3D + +> class in XCharts.Runtime / 继承自: [Axis](#axis) + +> 从 `v3.11.0` 开始支持 + +直角坐标系 grid 中的 y 轴。 + +|API|版本|描述| +|--|--|--| +|SetDefaultValue()||public override void SetDefaultValue()
直角坐标系 grid 中的 y 轴。 | + diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 7000dd0e..650b60aa 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,8 @@ slug: /changelog ## master +* (2024.04.22) 增加`GridCoord3D`3D坐标系 +* (2024.04.15) 优化`DateTimeUtil`时间戳转`DateTime`接口时区的问题 * (2024.04.15) 优化`GridCoord`在开启`GridLayout`时也显示`Left` `Right` `Top` `Bottom`参数 (#316) * (2024.04.14) 修复`Tooltip`的`Cross`在开启`DataZoom`的情况下`label`位置不正确的问题 (#315) * (2024.04.12) 修复`Candlesticks`效果不对的问题 (#313) diff --git a/Documentation~/zh/configuration.md b/Documentation~/zh/configuration.md index db80a6fe..4e51f47b 100644 --- a/Documentation~/zh/configuration.md +++ b/Documentation~/zh/configuration.md @@ -56,6 +56,7 @@ import APITable from '@site/src/components/APITable'; - [CoordSystem](#coordsystem) - [DataZoom](#datazoom) - [GridCoord](#gridcoord) +- [GridCoord3D](#gridcoord3d) - [GridLayout](#gridlayout) - [Legend](#legend) - [MarkArea](#markarea) @@ -72,7 +73,10 @@ import APITable from '@site/src/components/APITable'; - [Tooltip](#tooltip) - [VisualMap](#visualmap) - [XAxis](#xaxis) +- [XAxis3D](#xaxis3d) - [YAxis](#yaxis) +- [YAxis3D](#yaxis3d) +- [ZAxis3D](#zaxis3d) ## ChildComponent 子组件 @@ -137,6 +141,7 @@ import APITable from '@site/src/components/APITable'; - [TitleTheme](#titletheme) - [TooltipTheme](#tooltiptheme) - [UIComponentTheme](#uicomponenttheme) +- [ViewControl](#viewcontrol) - [VisualMapRange](#visualmaprange) - [VisualMapTheme](#visualmaptheme) @@ -379,7 +384,7 @@ import APITable from '@site/src/components/APITable'; ## Axis -> class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类: [AngleAxis](#angleaxis), [ParallelAxis](#parallelaxis), [RadiusAxis](#radiusaxis), [SingleAxis](#singleaxis), [XAxis](#xaxis), [YAxis](#yaxis) +> class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类: [AngleAxis](#angleaxis), [ParallelAxis](#parallelaxis), [RadiusAxis](#radiusaxis), [SingleAxis](#singleaxis), [XAxis](#xaxis), [XAxis3D](#xaxis3d), [YAxis](#yaxis), [YAxis3D](#yaxis3d), [ZAxis3D](#zaxis3d) 直角坐标系的坐标轴组件。 @@ -395,7 +400,7 @@ import APITable from '@site/src/components/APITable'; |gridIndex|||坐标轴所在的 grid 的索引,默认位于第一个 grid。 |polarIndex|||坐标轴所在的 ploar 的索引,默认位于第一个 polar。 |parallelIndex|||坐标轴所在的 parallel 的索引,默认位于第一个 parallel。 -|position|||坐标轴在Grid中的位置。
`Axis.AxisPosition`:
- `Left`: 坐标轴在Grid中的位置
- `Right`: 坐标轴在Grid中的位置
- `Bottom`: 坐标轴在Grid中的位置
- `Top`: 坐标轴在Grid中的位置
| +|position|||坐标轴在Grid中的位置。
`Axis.AxisPosition`:
- `Left`: 坐标轴在Grid中的位置
- `Right`: 坐标轴在Grid中的位置
- `Bottom`: 坐标轴在Grid中的位置
- `Top`: 坐标轴在Grid中的位置
- `Center`: 坐标轴在Grid中的位置
| |offset|||坐标轴相对默认位置的偏移。在相同position有多个坐标轴时有用。 |min|||设定的坐标轴刻度最小值,当minMaxType为Custom时有效。 |max|||设定的坐标轴刻度最大值,当minMaxType为Custom时有效。 @@ -591,6 +596,7 @@ import APITable from '@site/src/components/APITable'; |autoColor|||自动设置颜色。 |showStartLine|true|v3.3.0|是否显示第一条分割线。 |showEndLine|true|v3.3.0|是否显示最后一条分割线。 +|showZLine|true|v3.11.0|是否显示Z轴部分分割线。一般用于3D坐标系。 ```mdx-code-block @@ -754,7 +760,7 @@ import APITable from '@site/src/components/APITable'; ## ChildComponent -> class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle), [AxisAnimation](#axisanimation), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [BorderStyle](#borderstyle), [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) +> class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle), [AxisAnimation](#axisanimation), [AxisName](#axisname), [AxisSplitArea](#axissplitarea), [AreaStyle](#areastyle), [ArrowStyle](#arrowstyle), [BaseLine](#baseline), [BorderStyle](#borderstyle), [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), [ViewControl](#viewcontrol), [UIComponentTheme](#uicomponenttheme), [SerieData](#seriedata), [SerieDataLink](#seriedatalink), [ComponentTheme](#componenttheme), [SerieTheme](#serietheme), [ThemeStyle](#themestyle) ## Comment @@ -841,7 +847,7 @@ import APITable from '@site/src/components/APITable'; ## CoordSystem -> class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类: [RadarCoord](#radarcoord), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [ParallelCoord](#parallelcoord), [PolarCoord](#polarcoord), [SingleAxisCoord](#singleaxiscoord) +> class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类: [RadarCoord](#radarcoord), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [GridCoord3D](#gridcoord3d), [ParallelCoord](#parallelcoord), [PolarCoord](#polarcoord), [SingleAxisCoord](#singleaxiscoord) 坐标系系统。 @@ -993,6 +999,36 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart ``` +## GridCoord3D + +> class in XCharts.Runtime / 继承自: [CoordSystem](#coordsystem), [IUpdateRuntimeData](#iupdateruntimedata), [ISerieContainer](#iseriecontainer) + +> 从 `v3.11.0` 开始支持 + +Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart can be drawn in grid. + +```mdx-code-block + +``` + +|参数|默认|版本|描述| +|--|--|--|--| +|show|true||是否显示直角坐标系网格。 +|left|0.15f||grid 组件离容器左侧的距离。 +|right|0.2f||grid 组件离容器右侧的距离。 +|top|0.3f||grid 组件离容器上侧的距离。 +|bottom|0.15f||grid 组件离容器下侧的距离。 +|showBorder|false||是否显示网格边框。 +|boxWidth|0.55f||坐标系的宽度。 +|boxHeight|0.4f||坐标系的高度。 +|boxDepth|0.2f||坐标系的深度。 +|xYExchanged|false|| +|viewControl|||3D视角控制组件。 [ViewControl](#viewcontrol)| + +```mdx-code-block + +``` + ## GridLayout > class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent), [IUpdateRuntimeData](#iupdateruntimedata) @@ -1143,7 +1179,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart ## ISerieContainer -> class in XCharts.Runtime / 子类: [RadarCoord](#radarcoord), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [ParallelCoord](#parallelcoord), [PolarCoord](#polarcoord) +> class in XCharts.Runtime / 子类: [RadarCoord](#radarcoord), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [GridCoord3D](#gridcoord3d), [ParallelCoord](#parallelcoord), [PolarCoord](#polarcoord) ## ISerieDataComponent @@ -1194,7 +1230,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart ## IUpdateRuntimeData -> class in XCharts.Runtime / 子类: [SingleAxis](#singleaxis), [DataZoom](#datazoom), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [GridLayout](#gridlayout), [ParallelCoord](#parallelcoord) +> class in XCharts.Runtime / 子类: [SingleAxis](#singleaxis), [DataZoom](#datazoom), [CalendarCoord](#calendarcoord), [GridCoord](#gridcoord), [GridLayout](#gridlayout), [GridCoord3D](#gridcoord3d), [ParallelCoord](#parallelcoord) ## LabelLine @@ -2234,7 +2270,7 @@ Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种 |triggerOn||v3.11.0|触发条件。
`Tooltip.TriggerOn`:
- `MouseMove`: 鼠标移动时触发。
- `Click`: 鼠标点击时触发。
| |position||v3.3.0|显示位置类型。
`Tooltip.Position`:
- `Auto`: 自适应。移动平台靠顶部显示,非移动平台跟随鼠标位置。
- `Custom`: 自定义。完全自定义显示位置(x,y)。
- `FixedX`: 只固定坐标X。Y跟随鼠标位置。
- `FixedY`:
| |itemFormatter|||提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 换行。用|来表示多个列的分隔。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。
{i}或-表示忽略当前项。 {.}为当前所指示的serie或数据项的对应颜色的圆点。
{a}为当前所指示的serie或数据项的系列名name。
{b}为当前所指示的serie或数据项的数据项serieData的name,或者类目值(如折线图的X轴)。
{c}为当前所指示的serie或数据项的y维(dimesion为1)的数值。
{d}为当前所指示的serie或数据项的y维(dimesion为1)百分比值,注意不带%号。
{e}为当前所指示的serie或数据项的数据项serieData的name。
{f}为当前所指示的serie的默认维度的数据总和。
{g}为当前所指示的serie的数据总个数。
{h}为当前所指示的serie的十六进制颜色值。
{y}为当前所指示的serie的y轴的类目值。
{c0}表示当前数据项维度为0的数据。
{c1}表示当前数据项维度为1的数据。
{d3}表示维度3的数据的百分比。它的分母是默认维度(一般是1维度)数据。
|表示多个列的分隔。
示例:"{i}", "{.}|{a}|{c}", "{.}|{b}|{c2:f2}", "{.}|{b}|{y}" -|titleFormatter|||提示框标题内容的字符串模版格式器。支持用 \n 换行。可以单独设置占位符{i}表示忽略不显示title。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。
{.}为当前所指示或index为0的serie的对应颜色的圆点。
{a}为当前所指示或index为0的serie的系列名name。
{b}为当前所指示或index为0的serie的数据项serieData的name,或者类目值(如折线图的X轴)。
{c}为当前所指示或index为0的serie的y维(dimesion为1)的数值。
{d}为当前所指示或index为0的serie的y维(dimesion为1)百分比值,注意不带%号。
{e}为当前所指示或index为0的serie的数据项serieData的name。
{h}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。
{f}为数据总和。
{g}为数据总个数。
{f}为value所对应的y轴的类目值。
{.1}表示指定index为1的serie对应颜色的圆点。
{a1}、{b1}、{c1}中的1表示指定index为1的serie。
{c1:2}表示索引为1的serie的当前指示数据项的第3个数据(一个数据项有多个数据,index为2表示第3个数据)。
{c1:2-2}表示索引为1的serie的第3个数据项的第3个数据(也就是要指定第几个数据项时必须要指定第几个数据)。
{d1:2:f2}表示单独指定了数值的格式化字符串为f2(不指定时用numericFormatter)。
{d:0.##} 表示单独指定了数值的格式化字符串为 0.## (用于百分比,保留2位有效数同时又能避免使用 f2 而出现的类似于"100.00%"的情况 )。
示例:"{a}:{c}"、"{a1}:{c1:f1}"、"{a1}:{c1:0:f1}"、"{a1}:{c1:1-1:f1}" +|titleFormatter|||提示框标题内容的字符串模版格式器。支持用 \n 换行。可以单独设置占位符{i}表示忽略不显示title。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。
{.}为当前所指示或index为0的serie的对应颜色的圆点。
{a}为当前所指示或index为0的serie的系列名name。
{b}为当前所指示或index为0的serie的数据项serieData的name,或者类目值(如折线图的X轴)。
{c}为当前所指示或index为0的serie的y维(dimesion为1)的数值。
{d}为当前所指示或index为0的serie的y维(dimesion为1)百分比值,注意不带%号。
{e}为当前所指示或index为0的serie的数据项serieData的name。
{h}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。
{f}为数据总和。
{g}为数据总个数。
{y}为value所对应的y轴的类目值。
{.1}表示指定index为1的serie对应颜色的圆点。
{a1}、{b1}、{c1}中的1表示指定index为1的serie。
{c1:2}表示索引为1的serie的当前指示数据项的第3个数据(一个数据项有多个数据,index为2表示第3个数据)。
{c1:2-2}表示索引为1的serie的第3个数据项的第3个数据(也就是要指定第几个数据项时必须要指定第几个数据)。
{d1:2:f2}表示单独指定了数值的格式化字符串为f2(不指定时用numericFormatter)。
{d:0.##} 表示单独指定了数值的格式化字符串为 0.## (用于百分比,保留2位有效数同时又能避免使用 f2 而出现的类似于"100.00%"的情况 )。
示例:"{a}:{c}"、"{a1}:{c1:f1}"、"{a1}:{c1:0:f1}"、"{a1}:{c1:1-1:f1}" |marker|||serie的符号标志。 |fixedWidth|0||固定宽度。比 minWidth 优先。 |fixedHeight|0||固定高度。比 minHeight 优先。 @@ -2304,6 +2340,27 @@ Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种 ``` +## ViewControl + +> class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent) + +> 从 `v3.11.0` 开始支持 + +3D视角控制组件。 + +```mdx-code-block + +``` + +|参数|默认|版本|描述| +|--|--|--|--| +|alpha|90f||视角在x-z平面的角度。 +|beta|55f||视角在y-z平面的角度。 + +```mdx-code-block + +``` + ## VisualMap > class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) @@ -2391,6 +2448,14 @@ Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种 直角坐标系 grid 中的 x 轴。 +## XAxis3D + +> class in XCharts.Runtime / 继承自: [Axis](#axis) + +> 从 `v3.11.0` 开始支持 + +直角坐标系 grid 中的 x 轴。 + ## XCResourcesImporter > class in XCharts.Runtime @@ -2451,3 +2516,19 @@ Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种 直角坐标系 grid 中的 y 轴。 +## YAxis3D + +> class in XCharts.Runtime / 继承自: [Axis](#axis) + +> 从 `v3.11.0` 开始支持 + +直角坐标系 grid 中的 y 轴。 + +## ZAxis3D + +> class in XCharts.Runtime / 继承自: [Axis](#axis) + +> 从 `v3.11.0` 开始支持 + +直角坐标系 grid 中的 y 轴。 + diff --git a/Editor/ChildComponents/LineDrawer.cs b/Editor/ChildComponents/LineDrawer.cs index f3519bb1..dceb65c0 100644 --- a/Editor/ChildComponents/LineDrawer.cs +++ b/Editor/ChildComponents/LineDrawer.cs @@ -46,6 +46,7 @@ namespace XCharts.Editor PropertyField(prop, "m_AutoColor"); PropertyField(prop, "m_ShowStartLine"); PropertyField(prop, "m_ShowEndLine"); + PropertyField(prop, "m_ShowZLine"); } } diff --git a/Editor/ChildComponents/ViewControlDrawer.cs b/Editor/ChildComponents/ViewControlDrawer.cs new file mode 100644 index 00000000..74292abc --- /dev/null +++ b/Editor/ChildComponents/ViewControlDrawer.cs @@ -0,0 +1,23 @@ +using UnityEditor; +using UnityEngine; +using XCharts.Runtime; + +namespace XCharts.Editor +{ + [CustomPropertyDrawer(typeof(ViewControl), true)] + public class ViewControlDrawer : BasePropertyDrawer + { + public override string ClassName { get { return "ViewControl"; } } + public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) + { + base.OnGUI(pos, prop, label); + if (MakeComponentFoldout(prop, "", true)) + { + ++EditorGUI.indentLevel; + PropertyField(prop, "m_Alpha"); + PropertyField(prop, "m_Beta"); + --EditorGUI.indentLevel; + } + } + } +} \ No newline at end of file diff --git a/Editor/ChildComponents/ViewControlDrawer.cs.meta b/Editor/ChildComponents/ViewControlDrawer.cs.meta new file mode 100644 index 00000000..02ebcb2a --- /dev/null +++ b/Editor/ChildComponents/ViewControlDrawer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: faeb8611591ee4c038e88fdb5a67b5ae +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/MainComponents/AxisEditor.cs b/Editor/MainComponents/AxisEditor.cs index 2a1d6e8e..fdc840b6 100644 --- a/Editor/MainComponents/AxisEditor.cs +++ b/Editor/MainComponents/AxisEditor.cs @@ -106,6 +106,15 @@ namespace XCharts.Editor [ComponentEditor(typeof(YAxis))] public class YAxisEditor : AxisEditor { } + [ComponentEditor(typeof(XAxis3D))] + public class XAxis3DEditor : AxisEditor { } + + [ComponentEditor(typeof(YAxis3D))] + public class YAxis3DEditor : AxisEditor { } + + [ComponentEditor(typeof(ZAxis3D))] + public class ZAxis3DEditor : AxisEditor { } + [ComponentEditor(typeof(SingleAxis))] public class SingleAxisEditor : AxisEditor { diff --git a/Editor/MainComponents/GridCoord3DEditor.cs b/Editor/MainComponents/GridCoord3DEditor.cs new file mode 100644 index 00000000..4dd20aa8 --- /dev/null +++ b/Editor/MainComponents/GridCoord3DEditor.cs @@ -0,0 +1,23 @@ +using UnityEditor; +using XCharts.Runtime; + +namespace XCharts.Editor +{ + [ComponentEditor(typeof(GridCoord3D))] + public class GridCoord3DEditor : MainComponentEditor + { + public override void OnInspectorGUI() + { + ++EditorGUI.indentLevel; + PropertyField("m_Left"); + PropertyField("m_Bottom"); + PropertyField("m_BoxWidth"); + PropertyField("m_BoxHeight"); + PropertyField("m_BoxDepth"); + PropertyField("m_XYExchanged"); + PropertyField("m_ShowBorder"); + PropertyField("m_ViewControl"); + --EditorGUI.indentLevel; + } + } +} \ No newline at end of file diff --git a/Editor/MainComponents/GridCoord3DEditor.cs.meta b/Editor/MainComponents/GridCoord3DEditor.cs.meta new file mode 100644 index 00000000..32b3c336 --- /dev/null +++ b/Editor/MainComponents/GridCoord3DEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c9a4a8a30b1124c4e996e234d5717a07 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Series/SerieBaseEditor.cs b/Editor/Series/SerieBaseEditor.cs index 1022c1f0..48e59668 100644 --- a/Editor/Series/SerieBaseEditor.cs +++ b/Editor/Series/SerieBaseEditor.cs @@ -9,8 +9,8 @@ namespace XCharts.Editor { public class SerieBaseEditor { - internal BaseChart chart { get; private set; } - internal Serie serie { get; private set; } + public BaseChart chart { get; private set; } + public Serie serie { get; private set; } //Editor m_Inspector; internal SerializedProperty baseProperty; diff --git a/Runtime/Component/Axis/Axis.cs b/Runtime/Component/Axis/Axis.cs index 5ea81183..696f37de 100644 --- a/Runtime/Component/Axis/Axis.cs +++ b/Runtime/Component/Axis/Axis.cs @@ -75,7 +75,8 @@ namespace XCharts.Runtime Left, Right, Bottom, - Top + Top, + Center } [SerializeField] protected bool m_Show = true; @@ -729,10 +730,14 @@ namespace XCharts.Runtime /// /// /// - public float GetDistance(double value, float axisLength) + public float GetDistance(double value, float axisLength = 0) { if (context.minMaxRange == 0) return 0; + if (axisLength == 0) + { + axisLength = context.length; + } if (IsCategory() && boundaryGap) { diff --git a/Runtime/Component/Axis/Axis3DHelper.cs b/Runtime/Component/Axis/Axis3DHelper.cs new file mode 100644 index 00000000..bd3be5d1 --- /dev/null +++ b/Runtime/Component/Axis/Axis3DHelper.cs @@ -0,0 +1,160 @@ +using UnityEngine; +using UnityEngine.UI; +using XUGL; + +namespace XCharts.Runtime +{ + public static class Axis3DHelper + { + public static Vector3 Get3DGridPosition(GridCoord3D grid, XAxis3D xAxis, YAxis3D yAxis, ZAxis3D zAxis, double xValue, double yValue, double zValue) + { + var x = xAxis.GetDistance(xValue); + var y = yAxis.GetDistance(yValue); + var z = zAxis.GetDistance(zValue); + + var dest = grid.context.pointA; + dest += xAxis.context.dire * x; + dest += yAxis.context.dire * y; + dest += zAxis.context.dire * z; + return dest; + } + + public static Vector3 Get3DGridPosition(GridCoord3D grid, XAxis3D xAxis, YAxis3D yAxis, double xValue, double yValue) + { + var x = xAxis.GetDistance(xValue); + var y = yAxis.GetDistance(yValue); + + var dest = grid.context.pointA; + dest += xAxis.context.dire * x; + dest += yAxis.context.dire * y; + return dest; + } + + internal static void DrawAxisTick(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom, + Vector3 start, Vector3 end, Vector3 relativedDire) + { + var tickLength = axis.axisTick.GetLength(theme.tickLength); + var axisLength = Vector3.Distance(start, end); + var axisDire = (end - start).normalized; + + if (axis.position == Axis.AxisPosition.Right) + { + relativedDire = -relativedDire; + } + + if (AxisHelper.NeedShowSplit(axis)) + { + var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom); + if (axis.IsTime()) + { + size += 1; + if (!ChartHelper.IsEquals(axis.GetLastLabelValue(), axis.context.maxValue)) + size += 1; + } + var tickWidth = axis.axisTick.GetWidth(theme.tickWidth); + var tickColor = axis.axisTick.GetColor(theme.tickColor); + var current = start; + for (int i = 0; i < size; i++) + { + var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom); + var hideTick = (i == 0 && (!axis.axisTick.showStartTick || axis.axisTick.alignWithLabel)) || + (i == size - 1 && !axis.axisTick.showEndTick); + if (axis.axisTick.show && !hideTick) + { + UGL.DrawLine(vh, current, current + relativedDire * tickLength, tickWidth, tickColor); + } + current += axisDire * scaleWidth; + } + } + if (axis.show && axis.axisLine.show && axis.axisLine.showArrow) + { + + } + } + + public static void DrawAxisSplit(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom, + Vector3 start, Vector3 end, Axis relativedAxis) + { + if (relativedAxis == null) return; + var axisLength = Vector3.Distance(start, end); + var axisDire = (end - start).normalized; + var splitLength = relativedAxis.context.length; + var relativeDire = relativedAxis.context.dire; + var axisLineWidth = axis.axisLine.GetWidth(theme.lineWidth); + splitLength -= axisLineWidth; + var lineColor = axis.splitLine.GetColor(theme.splitLineColor); + var lineWidth = axis.splitLine.GetWidth(theme.lineWidth); + var lineType = axis.splitLine.GetType(theme.splitLineType); + + var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom); + if (axis.IsTime()) + { + size += 1; + if (!ChartHelper.IsEquals(axis.GetLastLabelValue(), axis.context.maxValue)) + size += 1; + } + + var current = start; + for (int i = 0; i < size; i++) + { + var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, axis.IsTime() ? i : i + 1, dataZoom); + if (axis.boundaryGap && axis.axisTick.alignWithLabel) + current -= axisDire * scaleWidth / 2; + + if (axis.splitArea.show && i <= size - 1) + { + var p1 = current; + var p2 = current + relativeDire * splitLength; + var p3 = p2 + axisDire * scaleWidth; + var p4 = p1 + axisDire * scaleWidth; + UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, axis.splitArea.GetColor(i, theme)); + } + if (axis.splitLine.show) + { + if (axis.splitLine.NeedShow(i, size)) + { + if (relativedAxis == null || !relativedAxis.axisLine.show + || (Vector3.Distance(current, relativedAxis.context.start) > 0.5f && Vector3.Distance(current, relativedAxis.context.end) > 0.5f)) + { + ChartDrawer.DrawLineStyle(vh, + lineType, + lineWidth, + current, + current + relativeDire * splitLength, + lineColor); + } + } + } + current += axisDire * scaleWidth; + } + } + + public static Vector3 GetLabelPosition(int i, Axis axis, Axis relativedAxis, AxisTheme theme, float scaleWid) + { + var axisStart = axis.context.start; + var axisEnd = axis.context.end; + var axisDire = axis.context.dire; + var relativedDire = relativedAxis != null ? relativedAxis.context.dire : Vector3.zero; + var axisLength = Vector3.Distance(axisStart, axisEnd); + var inside = axis.axisLabel.inside; + var fontSize = axis.axisLabel.textStyle.GetFontSize(theme); + var current = axis.offset; + + if (axis.position == Axis.AxisPosition.Right) + { + relativedDire = -relativedDire; + } + + if (axis.IsTime() || axis.IsValue()) + { + scaleWid = axis.context.minMaxRange != 0 ? + axis.GetDistance(axis.GetLabelValue(i), axisLength) : + 0; + } + + return axisStart + axisDire * scaleWid + axis.axisLabel.offset - relativedDire * (axis.axisLabel.distance + fontSize / 2); + } + + + } +} \ No newline at end of file diff --git a/Runtime/Component/Axis/Axis3DHelper.cs.meta b/Runtime/Component/Axis/Axis3DHelper.cs.meta new file mode 100644 index 00000000..5d5ac29b --- /dev/null +++ b/Runtime/Component/Axis/Axis3DHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 52469636872044a81a291bb00b71a140 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Component/Axis/AxisContext.cs b/Runtime/Component/Axis/AxisContext.cs index 7a84d3d7..6090feab 100644 --- a/Runtime/Component/Axis/AxisContext.cs +++ b/Runtime/Component/Axis/AxisContext.cs @@ -15,6 +15,9 @@ namespace XCharts.Runtime /// 坐标轴的起点Y ///
public float y; + public Vector3 start; + public Vector3 end; + public Vector3 dire; /// /// 坐标轴原点X /// @@ -25,6 +28,7 @@ namespace XCharts.Runtime public float zeroY; public float width; public float height; + public float length; public Vector3 position; public float left; public float right; diff --git a/Runtime/Component/Axis/AxisHandler.cs b/Runtime/Component/Axis/AxisHandler.cs index f79d2a86..1c476ed1 100644 --- a/Runtime/Component/Axis/AxisHandler.cs +++ b/Runtime/Component/Axis/AxisHandler.cs @@ -369,6 +369,116 @@ namespace XCharts } } + protected void InitAxis3D(Axis relativedAxis, Orient orient) + { + Axis axis = component; + var axisLength = (axis.context.end - axis.context.start).magnitude; + chart.InitAxisRuntimeData(axis); + + var objName = ChartCached.GetComponentObjectName(axis); + var axisObj = ChartHelper.AddObject(objName, + chart.transform, + chart.chartMinAnchor, + chart.chartMaxAnchor, + chart.chartPivot, + chart.chartSizeDelta); + + axisObj.SetActive(axis.show); + axisObj.hideFlags = chart.chartHideFlags; + ChartHelper.HideAllObject(axisObj); + + axis.gameObject = axisObj; + axis.context.labelObjectList.Clear(); + + if (!axis.show) + return; + + var axisLabelTextStyle = axis.axisLabel.textStyle; + var dataZoom = chart.GetDataZoomOfAxis(axis); + var splitNumber = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom); + var totalWidth = 0f; + var eachWidth = AxisHelper.GetEachWidth(axis, axisLength, dataZoom); + var gapWidth = axis.boundaryGap ? eachWidth / 2 : 0; + + var textWidth = axis.axisLabel.width > 0 ? + axis.axisLabel.width : + AxisHelper.GetScaleWidth(axis, axisLength, 0, dataZoom); + + var textHeight = axis.axisLabel.height > 0 ? + axis.axisLabel.height : + 20f; + + var isPercentStack = SeriesHelper.IsPercentStack(chart.series); + var inside = axis.axisLabel.inside; + var defaultAlignment = orient == Orient.Horizonal ? TextAnchor.MiddleCenter : + ((inside && axis.IsLeft()) || (!inside && axis.IsRight()) ? + TextAnchor.MiddleLeft : + TextAnchor.MiddleRight); + if (axis.IsCategory() && axis.boundaryGap) + splitNumber -= 1; + axis.context.aligment = defaultAlignment; + for (int i = 0; i < splitNumber; i++) + { + var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom); + var labelName = AxisHelper.GetLabelName(axis, axisLength, i, + axis.context.destMinValue, + axis.context.destMaxValue, + dataZoom, isPercentStack); + + var label = ChartHelper.AddAxisLabelObject(splitNumber, i, + ChartCached.GetAxisLabelName(i), + axisObj.transform, + new Vector2(textWidth, textHeight), + axis, chart.theme.axis, labelName, + Color.clear, + defaultAlignment, + chart.theme.GetColor(i)); + + if (i == 0) + axis.axisLabel.SetRelatedText(label.text, labelWidth); + + var pos = GetLabelPosition(totalWidth + gapWidth, i); + label.SetPosition(pos); + //CheckValueLabelActive(axis, i, label, pos); + + axis.context.labelObjectList.Add(label); + + totalWidth += labelWidth; + } + if (axis.axisName.show) + { + ChartLabel label = null; + var offset = axis.axisName.labelStyle.offset; + var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor); + switch (axis.axisName.labelStyle.position) + { + case LabelStyle.Position.Start: + + label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, + chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter); + label.SetActive(axis.axisName.labelStyle.show); + label.SetPosition(axis.context.start + offset); + break; + + case LabelStyle.Position.Middle: + + label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, + chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter); + label.SetActive(axis.axisName.labelStyle.show); + label.SetPosition((axis.context.start + axis.context.end) / 2 + offset); + break; + + default: + + label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle, + chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter); + label.SetActive(axis.axisName.labelStyle.show); + label.SetPosition(axis.context.end + offset); + break; + } + } + } + protected void InitAxis(Axis relativedAxis, Orient orient, float axisStartX, float axisStartY, float axisLength, float relativedLength) { diff --git a/Runtime/Component/Axis/AxisSplitLine.cs b/Runtime/Component/Axis/AxisSplitLine.cs index acebe148..3b2a1fe3 100644 --- a/Runtime/Component/Axis/AxisSplitLine.cs +++ b/Runtime/Component/Axis/AxisSplitLine.cs @@ -15,6 +15,7 @@ namespace XCharts.Runtime [SerializeField] private bool m_AutoColor; [SerializeField][Since("v3.3.0")] private bool m_ShowStartLine = true; [SerializeField][Since("v3.3.0")] private bool m_ShowEndLine = true; + [SerializeField][Since("v3.11.0")] private bool m_ShowZLine = true; /// /// The distance between the split line and axis line. @@ -53,6 +54,15 @@ namespace XCharts.Runtime get { return m_ShowEndLine; } set { if (PropertyUtil.SetStruct(ref m_ShowEndLine, value)) SetVerticesDirty(); } } + /// + /// Whether to show the Z axis part of the split line. Generally used for 3D coordinate systems. + /// ||是否显示Z轴部分分割线。一般用于3D坐标系。 + /// + public bool showZLine + { + get { return m_ShowZLine; } + set { if (PropertyUtil.SetStruct(ref m_ShowZLine, value)) SetVerticesDirty(); } + } public override bool vertsDirty { get { return m_VertsDirty || m_LineStyle.anyDirty; } } public override void ClearVerticesDirty() diff --git a/Runtime/Component/Axis/ParallelAxis/ParallelAxisHander.cs b/Runtime/Component/Axis/ParallelAxis/ParallelAxisHander.cs index f1e8d57a..be431133 100644 --- a/Runtime/Component/Axis/ParallelAxis/ParallelAxisHander.cs +++ b/Runtime/Component/Axis/ParallelAxis/ParallelAxisHander.cs @@ -45,6 +45,7 @@ namespace XCharts.Runtime axis.context.x = parallel.context.x; axis.context.y = parallel.context.y + (axis.index) * each; axis.context.width = parallel.context.width; + axis.context.length = parallel.context.width; } else { @@ -52,6 +53,7 @@ namespace XCharts.Runtime axis.context.x = parallel.context.x + (axis.index) * each; axis.context.y = parallel.context.y; axis.context.width = parallel.context.height; + axis.context.length = parallel.context.height; } axis.context.orient = m_Orient; axis.context.height = 0; diff --git a/Runtime/Component/Axis/SingleAxis/SingleAxis.cs b/Runtime/Component/Axis/SingleAxis/SingleAxis.cs index 5d3cd726..5b2e89e0 100644 --- a/Runtime/Component/Axis/SingleAxis/SingleAxis.cs +++ b/Runtime/Component/Axis/SingleAxis/SingleAxis.cs @@ -123,6 +123,12 @@ namespace XCharts.Runtime else context.y = chartY + context.bottom; + context.start = new Vector3(context.x, context.y); + if (m_Orient == Orient.Horizonal) + context.end = new Vector3(context.x + context.width, context.y); + else + context.end = new Vector3(context.x, context.y + context.height); + context.length = (context.end - context.start).magnitude; context.position = new Vector3(context.x, context.y); } diff --git a/Runtime/Component/Axis/XAxis/XAxisHander.cs b/Runtime/Component/Axis/XAxis/XAxisHander.cs index 04731658..eb30656d 100644 --- a/Runtime/Component/Axis/XAxis/XAxisHander.cs +++ b/Runtime/Component/Axis/XAxis/XAxisHander.cs @@ -57,6 +57,11 @@ namespace XCharts.Runtime var relativedAxis = chart.GetChartComponent(axis.gridIndex); axis.context.x = grid.context.x; axis.context.y = AxisHelper.GetXAxisXOrY(grid, axis, relativedAxis); + axis.context.start = new Vector3(grid.context.x, axis.context.y); + axis.context.end = new Vector3(grid.context.x + grid.context.width, axis.context.y); + var vec = axis.context.end - axis.context.start; + axis.context.dire = vec.normalized; + axis.context.length = vec.magnitude; axis.context.zeroY = grid.context.y; axis.context.zeroX = grid.context.x + axis.context.offset; } diff --git a/Runtime/Component/Axis/XAxis3D.meta b/Runtime/Component/Axis/XAxis3D.meta new file mode 100644 index 00000000..52962a44 --- /dev/null +++ b/Runtime/Component/Axis/XAxis3D.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6350e9983955e49c5b48704d3866cbfe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Component/Axis/XAxis3D/XAxis3D.cs b/Runtime/Component/Axis/XAxis3D/XAxis3D.cs new file mode 100644 index 00000000..e7f931c5 --- /dev/null +++ b/Runtime/Component/Axis/XAxis3D/XAxis3D.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace XCharts.Runtime +{ + /// + /// The x axis in cartesian(rectangular) coordinate. + /// ||直角坐标系 grid 中的 x 轴。 + /// + [Since("v3.11.0")] + [System.Serializable] + [RequireChartComponent(typeof(GridCoord3D))] + [ComponentHandler(typeof(XAxis3DHander), true)] + public class XAxis3D : Axis + { + public override void SetDefaultValue() + { + m_Show = true; + m_Type = AxisType.Category; + m_Min = 0; + m_Max = 0; + m_SplitNumber = 0; + m_BoundaryGap = true; + m_Position = AxisPosition.Bottom; + m_Offset = 0; + m_Data = new List() { "x1", "x2", "x3", "x4", "x5" }; + m_Icons = new List(5); + splitLine.show = false; + splitLine.lineStyle.type = LineStyle.Type.None; + axisLabel.textLimit.enable = true; + axisName.name = "X"; + axisName.labelStyle.position = LabelStyle.Position.Middle; + } + } +} \ No newline at end of file diff --git a/Runtime/Component/Axis/XAxis3D/XAxis3D.cs.meta b/Runtime/Component/Axis/XAxis3D/XAxis3D.cs.meta new file mode 100644 index 00000000..b4a328ee --- /dev/null +++ b/Runtime/Component/Axis/XAxis3D/XAxis3D.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9129bca9c2a864e1ea337d7eb74d1024 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs b/Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs new file mode 100644 index 00000000..2c53f601 --- /dev/null +++ b/Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs @@ -0,0 +1,190 @@ +using UnityEngine; +using UnityEngine.UI; +using UnityEngine.EventSystems; + +namespace XCharts.Runtime +{ + [UnityEngine.Scripting.Preserve] + internal sealed class XAxis3DHander : AxisHandler + { + protected override Orient orient { get { return Orient.Horizonal; } } + + public override void InitComponent() + { + InitXAxis(component); + } + + public override void Update() + { + UpdateAxisMinMaxValue(component.index, component); + if (!chart.isTriggerOnClick) + { + UpdatePointerValue(component); + } + } + + public override void OnPointerClick(PointerEventData eventData) + { + base.OnPointerClick(eventData); + if (chart.isTriggerOnClick) + { + UpdatePointerValue(component); + } + } + + public override void OnPointerExit(PointerEventData eventData) + { + base.OnPointerExit(eventData); + if (chart.isTriggerOnClick) + { + component.context.pointerValue = double.PositiveInfinity; + } + } + + public override void DrawBase(VertexHelper vh) + { + UpdatePosition(component); + DrawXAxisSplit(vh, component); + DrawXAxisLine(vh, component); + DrawXAxisTick(vh, component); + } + + private void UpdatePosition(XAxis3D axis) + { + var grid = chart.GetChartComponent(axis.gridIndex); + if (grid != null) + { + if (axis.position == Axis.AxisPosition.Right || axis.position == Axis.AxisPosition.Top) + { + axis.context.start = grid.xyExchanged ? grid.context.pointD : grid.context.pointB; + axis.context.end = grid.context.pointC; + } + else + { + axis.context.start = grid.context.pointA; + axis.context.end = grid.xyExchanged ? grid.context.pointB : grid.context.pointD; + } + var vect = axis.context.end - axis.context.start; + axis.context.x = axis.context.start.x; + axis.context.y = axis.context.start.y; + axis.context.dire = vect.normalized; + axis.context.length = vect.magnitude; + } + } + + private void InitXAxis(XAxis3D xAxis) + { + var theme = chart.theme; + var xAxisIndex = xAxis.index; + xAxis.painter = chart.painter; + xAxis.refreshComponent = delegate () + { + var yAxis = chart.GetChartComponent(xAxis.index); + InitAxis3D(yAxis, orient); + }; + xAxis.refreshComponent(); + } + + internal override void UpdateAxisLabelText(Axis axis) + { + base.UpdateAxisLabelText(axis); + if (axis.IsTime() || axis.IsValue()) + { + for (int i = 0; i < axis.context.labelObjectList.Count; i++) + { + var label = axis.context.labelObjectList[i]; + if (label != null) + { + var pos = GetLabelPosition(0, i); + label.SetPosition(pos); + CheckValueLabelActive(component, i, label, pos); + } + } + } + } + + protected override Vector3 GetLabelPosition(float scaleWid, int i) + { + var yAxis = chart.GetChartComponent(component.index); + return Axis3DHelper.GetLabelPosition(i, component, yAxis, chart.theme.axis, scaleWid); + } + + private void DrawXAxisSplit(VertexHelper vh, XAxis3D xAxis) + { + if (AxisHelper.NeedShowSplit(xAxis)) + { + var grid = chart.GetChartComponent(xAxis.gridIndex); + var relativedAxis = chart.GetChartComponent(xAxis.gridIndex); + var dataZoom = chart.GetDataZoomOfAxis(xAxis); + var isLeft = grid.IsLeft(); + if (grid.xyExchanged) + { + Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom, + grid.context.pointA, + grid.context.pointB, + relativedAxis); + if (xAxis.splitLine.showZLine) + { + var relativedAxis2 = chart.GetChartComponent(xAxis.gridIndex); + Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom, + isLeft ? grid.context.pointD : grid.context.pointA, + isLeft ? grid.context.pointC : grid.context.pointB, + relativedAxis2); + } + } + else + { + Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom, + grid.context.pointA, + grid.context.pointD, + relativedAxis); + if (xAxis.splitLine.showZLine) + { + var relativedAxis2 = chart.GetChartComponent(xAxis.gridIndex); + Axis3DHelper.DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom, + grid.context.pointB, + grid.context.pointC, + relativedAxis2); + } + } + } + } + + private void DrawXAxisTick(VertexHelper vh, XAxis3D xAxis) + { + if (AxisHelper.NeedShowSplit(xAxis)) + { + var grid = chart.GetChartComponent(xAxis.gridIndex); + if (grid == null) + return; + + var dataZoom = chart.GetDataZoomOfAxis(xAxis); + var relativedAxis = chart.GetChartComponent(xAxis.gridIndex); + Axis3DHelper.DrawAxisTick(vh, xAxis, chart.theme.axis, dataZoom, + xAxis.context.start, + xAxis.context.end, + -relativedAxis.context.dire); + } + } + + private void DrawXAxisLine(VertexHelper vh, XAxis3D axis) + { + if (axis.show && axis.axisLine.show) + { + var theme = chart.theme.axis; + var lineWidth = axis.axisLine.GetWidth(theme.lineWidth); + var lineType = axis.axisLine.GetType(theme.lineType); + var lineColor = axis.axisLine.GetColor(theme.lineColor); + + var start = axis.context.start; + var end = axis.context.end; + ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, start, end, lineColor); + } + } + + internal override float GetAxisLineXOrY() + { + return component.context.y; + } + } +} \ No newline at end of file diff --git a/Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs.meta b/Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs.meta new file mode 100644 index 00000000..20521e32 --- /dev/null +++ b/Runtime/Component/Axis/XAxis3D/XAxis3DHander.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fc1147481a423494d963df29b423f3a0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Component/Axis/YAxis/YAxisHander.cs b/Runtime/Component/Axis/YAxis/YAxisHander.cs index 82c54fdd..2474264d 100644 --- a/Runtime/Component/Axis/YAxis/YAxisHander.cs +++ b/Runtime/Component/Axis/YAxis/YAxisHander.cs @@ -35,6 +35,11 @@ namespace XCharts.Runtime var relativedAxis = chart.GetChartComponent(axis.gridIndex); axis.context.x = AxisHelper.GetYAxisXOrY(grid, axis, relativedAxis); axis.context.y = grid.context.y; + axis.context.start = new Vector3(axis.context.x, grid.context.y); + axis.context.end = new Vector3(axis.context.x, grid.context.y + grid.context.height); + var vect = axis.context.end - axis.context.start; + axis.context.dire = vect.normalized; + axis.context.length = vect.magnitude; axis.context.zeroX = axis.context.x; axis.context.zeroY = axis.context.y + axis.context.offset; } diff --git a/Runtime/Component/Axis/YAxis3D.meta b/Runtime/Component/Axis/YAxis3D.meta new file mode 100644 index 00000000..c3f19930 --- /dev/null +++ b/Runtime/Component/Axis/YAxis3D.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: aa26616789b6b4903aae479a4c552b89 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Component/Axis/YAxis3D/YAxis3D.cs b/Runtime/Component/Axis/YAxis3D/YAxis3D.cs new file mode 100644 index 00000000..d212c681 --- /dev/null +++ b/Runtime/Component/Axis/YAxis3D/YAxis3D.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; + +namespace XCharts.Runtime +{ + /// + /// The x axis in cartesian(rectangular) coordinate. + /// ||直角坐标系 grid 中的 y 轴。 + /// + [Since("v3.11.0")] + [System.Serializable] + [RequireChartComponent(typeof(GridCoord3D), typeof(XAxis3D))] + [ComponentHandler(typeof(YAxis3DHander), true)] + public class YAxis3D : Axis + { + public override void SetDefaultValue() + { + m_Show = true; + m_Type = AxisType.Value; + m_Min = 0; + m_Max = 0; + m_SplitNumber = 0; + m_BoundaryGap = false; + m_Position = AxisPosition.Left; + m_Data = new List(5); + splitLine.show = true; + splitLine.lineStyle.type = LineStyle.Type.None; + axisLabel.textLimit.enable = false; + axisTick.showStartTick = true; + axisName.name = "Y"; + axisName.labelStyle.position = LabelStyle.Position.Middle; + } + } +} \ No newline at end of file diff --git a/Runtime/Component/Axis/YAxis3D/YAxis3D.cs.meta b/Runtime/Component/Axis/YAxis3D/YAxis3D.cs.meta new file mode 100644 index 00000000..68c96812 --- /dev/null +++ b/Runtime/Component/Axis/YAxis3D/YAxis3D.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a3cb4a6657aaf473bbae7162eb189cc0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs b/Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs new file mode 100644 index 00000000..703a3d9f --- /dev/null +++ b/Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs @@ -0,0 +1,176 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace XCharts.Runtime +{ + [UnityEngine.Scripting.Preserve] + internal sealed class YAxis3DHander : AxisHandler + { + protected override Orient orient { get { return Orient.Vertical; } } + + public override void InitComponent() + { + InitYAxis(component); + } + + public override void Update() + { + UpdateAxisMinMaxValue(component.index, component); + UpdatePointerValue(component); + } + + public override void DrawBase(VertexHelper vh) + { + UpdatePosition(component); + DrawYAxisSplit(vh, component.index, component); + DrawYAxisLine(vh, component.index, component); + DrawYAxisTick(vh, component.index, component); + } + + private void UpdatePosition(YAxis3D axis) + { + var grid = chart.GetChartComponent(axis.gridIndex); + if (grid != null) + { + if (axis.position == Axis.AxisPosition.Right) + { + axis.context.start = grid.xyExchanged ? grid.context.pointB : grid.context.pointD; + axis.context.end = grid.context.pointC; + } + else + { + axis.context.start = grid.context.pointA; + axis.context.end = grid.xyExchanged ? grid.context.pointD : grid.context.pointB; + } + axis.context.x = axis.context.start.x; + axis.context.y = axis.context.start.y; + var vect = axis.context.end - axis.context.start; + axis.context.dire = vect.normalized; + axis.context.length = vect.magnitude; + } + } + + private void InitYAxis(YAxis3D yAxis) + { + var theme = chart.theme; + var yAxisIndex = yAxis.index; + yAxis.painter = chart.painter; + yAxis.refreshComponent = delegate () + { + var grid = chart.GetChartComponent(yAxis.gridIndex); + if (grid != null) + { + var xAxis = chart.GetChartComponent(yAxis.index); + InitAxis3D(xAxis, orient); + } + }; + yAxis.refreshComponent(); + } + + internal override void UpdateAxisLabelText(Axis axis) + { + base.UpdateAxisLabelText(axis); + if (axis.IsTime() || axis.IsValue()) + { + for (int i = 0; i < axis.context.labelObjectList.Count; i++) + { + var label = axis.context.labelObjectList[i]; + if (label != null) + { + var pos = GetLabelPosition(0, i); + label.SetPosition(pos); + CheckValueLabelActive(axis, i, label, pos); + } + } + } + } + + protected override Vector3 GetLabelPosition(float scaleWid, int i) + { + var xAxis = chart.GetChartComponent(component.index); + return Axis3DHelper.GetLabelPosition(i, component, xAxis, chart.theme.axis, scaleWid); + } + + private void DrawYAxisSplit(VertexHelper vh, int yAxisIndex, YAxis3D yAxis) + { + if (AxisHelper.NeedShowSplit(yAxis)) + { + var grid = chart.GetChartComponent(yAxis.gridIndex); + var relativedAxis = chart.GetChartComponent(yAxis.gridIndex); + var dataZoom = chart.GetDataZoomOfAxis(yAxis); + var isLeft = grid.IsLeft(); + if (grid.xyExchanged) + { + Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom, + grid.context.pointA, + grid.context.pointD, + relativedAxis); + if (yAxis.splitLine.showZLine) + { + var relativedAxis2 = chart.GetChartComponent(yAxis.gridIndex); + Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom, + grid.context.pointB, grid.context.pointC, relativedAxis2); + } + } + else + { + Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom, + grid.context.pointA, + grid.context.pointB, + relativedAxis); + if (yAxis.splitLine.showZLine) + { + var relativedAxis2 = chart.GetChartComponent(yAxis.gridIndex); + Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom, + isLeft ? grid.context.pointD : grid.context.pointA, + isLeft ? grid.context.pointC : grid.context.pointB, + relativedAxis2); + } + } + } + } + + private void DrawYAxisTick(VertexHelper vh, int yAxisIndex, YAxis3D yAxis) + { + if (AxisHelper.NeedShowSplit(yAxis)) + { + var grid = chart.GetChartComponent(yAxis.gridIndex); + if (grid == null) + return; + + var dataZoom = chart.GetDataZoomOfAxis(yAxis); + var relativedAxis = chart.GetChartComponent(yAxis.gridIndex); + + Axis3DHelper.DrawAxisTick(vh, yAxis, chart.theme.axis, dataZoom, + yAxis.context.start, + yAxis.context.end, + -relativedAxis.context.dire); + } + } + + private void DrawYAxisLine(VertexHelper vh, int axisIndex, YAxis3D axis) + { + if (axis.show && axis.axisLine.show) + { + var grid = chart.GetChartComponent(axis.gridIndex); + if (grid == null) + return; + + var theme = chart.theme.axis; + + var lineWidth = axis.axisLine.GetWidth(theme.lineWidth); + var lineType = axis.axisLine.GetType(theme.lineType); + var lineColor = axis.axisLine.GetColor(theme.lineColor); + + var start = axis.context.start; + var end = axis.context.end; + ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, start, end, lineColor); + } + } + + internal override float GetAxisLineXOrY() + { + return component.context.x; + } + } +} \ No newline at end of file diff --git a/Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs.meta b/Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs.meta new file mode 100644 index 00000000..04333262 --- /dev/null +++ b/Runtime/Component/Axis/YAxis3D/YAxis3DHander.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 56b4be734c61645e1bf91c22a6e3da6c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Component/Axis/ZAxis3D.meta b/Runtime/Component/Axis/ZAxis3D.meta new file mode 100644 index 00000000..a8fde686 --- /dev/null +++ b/Runtime/Component/Axis/ZAxis3D.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 378448672ed084b0798c7ad343314693 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs b/Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs new file mode 100644 index 00000000..e4f3e013 --- /dev/null +++ b/Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; + +namespace XCharts.Runtime +{ + /// + /// The x axis in cartesian(rectangular) coordinate. + /// ||直角坐标系 grid 中的 y 轴。 + /// + [Since("v3.11.0")] + [System.Serializable] + [RequireChartComponent(typeof(GridCoord3D), typeof(XAxis3D))] + [ComponentHandler(typeof(ZAxis3DHander), true)] + public class ZAxis3D : Axis + { + public override void SetDefaultValue() + { + m_Show = true; + m_Type = AxisType.Value; + m_Min = 0; + m_Max = 0; + m_SplitNumber = 0; + m_BoundaryGap = false; + m_Position = AxisPosition.Left; + m_Data = new List(5); + splitLine.show = true; + splitLine.lineStyle.type = LineStyle.Type.None; + axisLabel.textLimit.enable = false; + axisTick.showStartTick = true; + axisName.name = "Z"; + axisName.labelStyle.position = LabelStyle.Position.Middle; + } + } +} \ No newline at end of file diff --git a/Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs.meta b/Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs.meta new file mode 100644 index 00000000..428821da --- /dev/null +++ b/Runtime/Component/Axis/ZAxis3D/ZAxis3D.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 65aa8ae88610c431ebdab86935af2379 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs b/Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs new file mode 100644 index 00000000..e6e92574 --- /dev/null +++ b/Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs @@ -0,0 +1,198 @@ +using UnityEngine; +using UnityEngine.UI; + +namespace XCharts.Runtime +{ + [UnityEngine.Scripting.Preserve] + internal sealed class ZAxis3DHander : AxisHandler + { + protected override Orient orient { get { return Orient.Vertical; } } + + public override void InitComponent() + { + InitYAxis(component); + } + + public override void Update() + { + UpdateAxisMinMaxValue(component.index, component); + UpdatePointerValue(component); + } + + public override void DrawBase(VertexHelper vh) + { + UpdatePosition(component); + DrawZAxisSplit(vh, component.index, component); + DrawZAxisLine(vh, component.index, component); + DrawZAxisTick(vh, component.index, component); + } + + private void UpdatePosition(ZAxis3D axis) + { + var grid = chart.GetChartComponent(axis.gridIndex); + if (grid != null) + { + if (grid.context.pointB.x < grid.context.pointA.x) + { + axis.context.start = grid.context.pointD; + axis.context.end = grid.context.pointH; + } + else if (axis.position == Axis.AxisPosition.Center) + { + axis.context.start = grid.context.pointB; + axis.context.end = grid.context.pointF; + } + else if (axis.position == Axis.AxisPosition.Right) + { + axis.context.start = grid.context.pointC; + axis.context.end = grid.context.pointG; + } + else + { + axis.context.start = grid.context.pointA; + axis.context.end = grid.context.pointE; + } + axis.context.x = axis.context.start.x; + axis.context.y = axis.context.start.y; + var vect = axis.context.end - axis.context.start; + axis.context.dire = vect.normalized; + axis.context.length = vect.magnitude; + } + } + + private void InitYAxis(ZAxis3D yAxis) + { + var theme = chart.theme; + var yAxisIndex = yAxis.index; + yAxis.painter = chart.painter; + yAxis.refreshComponent = delegate () + { + var grid = chart.GetChartComponent(yAxis.gridIndex); + if (grid != null) + { + var relativedAxis = chart.GetChartComponent(yAxis.index); + InitAxis3D(relativedAxis, orient); + } + }; + yAxis.refreshComponent(); + } + + internal override void UpdateAxisLabelText(Axis axis) + { + base.UpdateAxisLabelText(axis); + if (axis.IsTime() || axis.IsValue()) + { + for (int i = 0; i < axis.context.labelObjectList.Count; i++) + { + var label = axis.context.labelObjectList[i]; + if (label != null) + { + var pos = GetLabelPosition(0, i); + label.SetPosition(pos); + CheckValueLabelActive(axis, i, label, pos); + } + } + } + } + + protected override Vector3 GetLabelPosition(float scaleWid, int i) + { + var grid = chart.GetChartComponent(component.gridIndex); + if (grid == null) + return Vector3.zero; + + var yAxis = chart.GetChartComponent(component.index); + return Axis3DHelper.GetLabelPosition(i, component, yAxis, + chart.theme.axis, + scaleWid); + } + + private void DrawZAxisSplit(VertexHelper vh, int yAxisIndex, ZAxis3D yAxis) + { + if (AxisHelper.NeedShowSplit(yAxis)) + { + var grid = chart.GetChartComponent(yAxis.gridIndex); + if (grid == null) + return; + + var isLeft = grid.IsLeft(); + if (grid.xyExchanged) + { + var relativedAxis = chart.GetChartComponent(yAxis.gridIndex); + var dataZoom = chart.GetDataZoomOfAxis(yAxis); + Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom, + isLeft ? grid.context.pointD : grid.context.pointA, + isLeft ? grid.context.pointH : grid.context.pointE, + relativedAxis); + if (yAxis.splitLine.showZLine) + { + var relativedAxis2 = chart.GetChartComponent(yAxis.gridIndex); + Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom, + grid.context.pointB, + grid.context.pointF, + relativedAxis2); + } + } + else + { + var relativedAxis = chart.GetChartComponent(yAxis.gridIndex); + var dataZoom = chart.GetDataZoomOfAxis(yAxis); + Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom, + isLeft ? grid.context.pointD : grid.context.pointA, + isLeft ? grid.context.pointH : grid.context.pointE, + relativedAxis); + if (yAxis.splitLine.showZLine) + { + var relativedAxis2 = chart.GetChartComponent(yAxis.gridIndex); + Axis3DHelper.DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom, + grid.context.pointB, + grid.context.pointF, + relativedAxis2); + } + } + } + } + + private void DrawZAxisTick(VertexHelper vh, int yAxisIndex, ZAxis3D zAxis) + { + if (AxisHelper.NeedShowSplit(zAxis)) + { + var grid = chart.GetChartComponent(zAxis.gridIndex); + if (grid == null) + return; + + var dataZoom = chart.GetDataZoomOfAxis(zAxis); + var relativedDire = grid.context.pointA - grid.context.pointB; + Axis3DHelper.DrawAxisTick(vh, zAxis, chart.theme.axis, dataZoom, + zAxis.context.start, + zAxis.context.end, + relativedDire.normalized); + } + } + + private void DrawZAxisLine(VertexHelper vh, int axisIndex, ZAxis3D axis) + { + if (axis.show && axis.axisLine.show) + { + var grid = chart.GetChartComponent(axis.gridIndex); + if (grid == null) + return; + + var theme = chart.theme.axis; + + var lineWidth = axis.axisLine.GetWidth(theme.lineWidth); + var lineType = axis.axisLine.GetType(theme.lineType); + var lineColor = axis.axisLine.GetColor(theme.lineColor); + + var start = axis.context.start; + var end = axis.context.end; + ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, start, end, lineColor); + } + } + + internal override float GetAxisLineXOrY() + { + return component.context.x; + } + } +} \ No newline at end of file diff --git a/Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs.meta b/Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs.meta new file mode 100644 index 00000000..3ea9afe0 --- /dev/null +++ b/Runtime/Component/Axis/ZAxis3D/ZAxis3DHander.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 67fb4be32885d4915979719c676aac5a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Component/VisualMap/VisualMap.cs b/Runtime/Component/VisualMap/VisualMap.cs index deee8550..756b8d96 100644 --- a/Runtime/Component/VisualMap/VisualMap.cs +++ b/Runtime/Component/VisualMap/VisualMap.cs @@ -386,8 +386,8 @@ namespace XCharts.Runtime } } - public float runtimeRangeMinHeight { get { return (float) ((rangeMin - min) / (max - min) * itemHeight); } } - public float runtimeRangeMaxHeight { get { return (float) ((rangeMax - min) / (max - min) * itemHeight); } } + public float runtimeRangeMinHeight { get { return (float)((rangeMin - min) / (max - min) * itemHeight); } } + public float runtimeRangeMaxHeight { get { return (float)((rangeMax - min) / (max - min) * itemHeight); } } public void AddColors(List colors) { @@ -413,6 +413,25 @@ namespace XCharts.Runtime } } + public Color32 GetColor(double xValue, double yValue, double zValue, byte alpha = 255) + { + Color32 color; + if (m_Dimension == 0) + { + color = GetColor(xValue); + } + else if (m_Dimension == 1) + { + color = GetColor(yValue); + } + else + { + color = GetColor(zValue); + } + color.a = alpha; + return color; + } + public Color32 GetColor(double value) { int index = GetIndex(value); @@ -437,7 +456,7 @@ namespace XCharts.Runtime if (index == splitNumber - 1) return m_InRange[index].color; else - return Color32.Lerp(m_InRange[index].color, m_InRange[index + 1].color, (float) rate); + return Color32.Lerp(m_InRange[index].color, m_InRange[index + 1].color, (float)rate); } } diff --git a/Runtime/Coord/Grid3D.meta b/Runtime/Coord/Grid3D.meta new file mode 100644 index 00000000..08f47467 --- /dev/null +++ b/Runtime/Coord/Grid3D.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 14f9081aa22ba4bcb9cdbfbb95c7221e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Coord/Grid3D/GridCoord3D.cs b/Runtime/Coord/Grid3D/GridCoord3D.cs new file mode 100644 index 00000000..04f24314 --- /dev/null +++ b/Runtime/Coord/Grid3D/GridCoord3D.cs @@ -0,0 +1,270 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using XUGL; + +namespace XCharts.Runtime +{ + /// + /// View control component in 3D coordinate system. + /// ||3D视角控制组件。 + /// + [Since("v3.11.0")] + [Serializable] + public class ViewControl : ChildComponent + { + [SerializeField][Range(-90, 180)] private float m_Alpha = 90f; + [SerializeField][Range(-90, 90)] private float m_Beta = 55f; + + /// + /// The angle of the view in the x-z plane. + /// ||视角在x-z平面的角度。 + /// + public float alpha + { + get { return m_Alpha; } + set { if (PropertyUtil.SetStruct(ref m_Alpha, value)) SetVerticesDirty(); } + } + + /// + /// The angle of the view in the y-z plane. + /// ||视角在y-z平面的角度。 + /// + public float beta + { + get { return m_Beta; } + set { if (PropertyUtil.SetStruct(ref m_Beta, value)) SetVerticesDirty(); } + } + } + + /// + /// Grid component. + /// ||Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart can be drawn in grid. + /// ||3D网格组件。 + /// 3D直角坐标系内绘图网格。可以在网格上绘制3D折线图,3D柱状图,3D散点图。 + /// + [Serializable] + [ComponentHandler(typeof(GridCoord3DHandler), true)] + public class GridCoord3D : CoordSystem, IUpdateRuntimeData, ISerieContainer + { + [SerializeField] private bool m_Show = true; + [SerializeField] private float m_Left = 0.15f; + [SerializeField] private float m_Right = 0.2f; + [SerializeField] private float m_Top = 0.3f; + [SerializeField] private float m_Bottom = 0.15f; + [SerializeField] private bool m_ShowBorder = false; + [SerializeField] private float m_BoxWidth = 0.55f; + [SerializeField] private float m_BoxHeight = 0.4f; + [SerializeField] private float m_BoxDepth = 0.2f; + [SerializeField] private bool m_XYExchanged = false; + [SerializeField] private ViewControl m_ViewControl = new ViewControl(); + + public GridCoord3DContext context = new GridCoord3DContext(); + + /// + /// Whether to show the grid in rectangular coordinate. + /// ||是否显示直角坐标系网格。 + /// + public bool show + { + get { return m_Show; } + set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); } + } + /// + /// Distance between grid component and the left side of the container. + /// ||grid 组件离容器左侧的距离。 + /// + public float left + { + get { return m_Left; } + set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetAllDirty(); } + } + /// + /// Distance between grid component and the right side of the container. + /// ||grid 组件离容器右侧的距离。 + /// + public float right + { + get { return m_Right; } + set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetAllDirty(); } + } + /// + /// Distance between grid component and the top side of the container. + /// ||grid 组件离容器上侧的距离。 + /// + public float top + { + get { return m_Top; } + set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetAllDirty(); } + } + /// + /// Distance between grid component and the bottom side of the container. + /// ||grid 组件离容器下侧的距离。 + /// + public float bottom + { + get { return m_Bottom; } + set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetAllDirty(); } + } + /// + /// Whether to show the grid border. + /// ||是否显示网格边框。 + /// + public bool showBorder + { + get { return m_ShowBorder; } + set { if (PropertyUtil.SetStruct(ref m_ShowBorder, value)) SetVerticesDirty(); } + } + /// + /// The width of the box in the coordinate system. + /// ||坐标系的宽度。 + /// + public float boxWidth + { + get { return m_BoxWidth; } + set { if (PropertyUtil.SetStruct(ref m_BoxWidth, value)) SetVerticesDirty(); } + } + /// + /// The height of the box in the coordinate system. + /// ||坐标系的高度。 + /// + public float boxHeight + { + get { return m_BoxHeight; } + set { if (PropertyUtil.SetStruct(ref m_BoxHeight, value)) SetVerticesDirty(); } + } + /// + /// The depth of the box in the coordinate system. + /// ||坐标系的深度。 + /// + public float boxDepth + { + get { return m_BoxDepth; } + set { if (PropertyUtil.SetStruct(ref m_BoxDepth, value)) SetVerticesDirty(); } + } + /// + /// Whether to exchange the x and y axes. + /// ||是否交换x和y轴。 + /// + public bool xyExchanged + { + get { return m_XYExchanged; } + set { if (PropertyUtil.SetStruct(ref m_XYExchanged, value)) SetVerticesDirty(); } + } + /// + /// View control component in 3D coordinate system. + /// ||3D视角控制组件。 + /// + public ViewControl viewControl + { + get { return m_ViewControl; } + //set { if (PropertyUtil.SetClass(ref m_ViewControl, value)) SetVerticesDirty(); } + } + + public void UpdateRuntimeData(BaseChart chart) + { + var chartX = chart.chartX; + var chartY = chart.chartY; + var chartWidth = chart.chartWidth; + var chartHeight = chart.chartHeight; + var actualLeft = left <= 1 ? left * chartWidth : left; + var actualBottom = bottom <= 1 ? bottom * chartHeight : bottom; + var actualBoxWidth = m_BoxWidth <= 1 ? m_BoxWidth * chartWidth : m_BoxWidth; + var actualBoxHeight = m_BoxHeight <= 1 ? m_BoxHeight * chartHeight : m_BoxHeight; + var actualBoxDepth = m_BoxDepth <= 1 ? m_BoxDepth * chartWidth : m_BoxDepth; + context.x = chartX + actualLeft; + context.y = chartY + actualBottom; + context.pointA.x = context.x; + context.pointA.y = context.y; + + var angle = m_ViewControl.alpha * Mathf.Deg2Rad; + context.pointD.x = context.x + actualBoxWidth * Mathf.Sin(angle); + context.pointD.y = context.y - actualBoxWidth * Mathf.Cos(angle); + + angle = (90 - m_ViewControl.beta) * Mathf.Deg2Rad; + context.pointB.x = context.x + actualBoxDepth * Mathf.Cos(angle); + context.pointB.y = context.y + actualBoxDepth * Mathf.Sin(angle); + + context.pointC = context.pointB + (context.pointD - context.pointA); + + context.pointE.x = context.pointA.x; + context.pointE.y = context.pointA.y + actualBoxHeight; + + var diff = context.pointE - context.pointA; + context.pointF = context.pointB + diff; + context.pointG = context.pointC + diff; + context.pointH = context.pointD + diff; + + var minX = Mathf.Min(context.pointA.x, context.pointB.x, context.pointC.x, context.pointD.x, context.pointE.x, context.pointF.x, context.pointG.x, context.pointH.x); + var minY = Mathf.Min(context.pointA.y, context.pointB.y, context.pointC.y, context.pointD.y, context.pointE.y, context.pointF.y, context.pointG.y, context.pointH.y); + var maxX = Mathf.Max(context.pointA.x, context.pointB.x, context.pointC.x, context.pointD.x, context.pointE.x, context.pointF.x, context.pointG.x, context.pointH.x); + var maxY = Mathf.Max(context.pointA.y, context.pointB.y, context.pointC.y, context.pointD.y, context.pointE.y, context.pointF.y, context.pointG.y, context.pointH.y); + + context.maxRect.x = minX; + context.maxRect.y = minY; + context.maxRect.width = maxX - minX; + context.maxRect.height = maxY - minY; + } + + /// + /// The opening of the coordinate system faces to the left. + /// 坐标系开口朝向左边。 + /// + /// + public bool IsLeft() + { + return context.pointB.x < context.pointA.x; + } + + /// + /// Whether the pointer is in the grid. + /// ||指针是否在网格内。 + /// + /// + public bool IsPointerEnter() + { + return context.isPointerEnter; + } + + /// + /// Whether the given position is in the grid. + /// ||给定的位置是否在网格内。 + /// + /// + /// + public bool Contains(Vector3 pos) + { + if (!context.maxRect.Contains(pos)) return false; + if (UGLHelper.IsPointInPolygon(pos, context.pointA, context.pointB, context.pointC, context.pointD)) return true; + if (UGLHelper.IsPointInPolygon(pos, context.pointB, context.pointF, context.pointG, context.pointC)) return true; + if (IsLeft()) + if (UGLHelper.IsPointInPolygon(pos, context.pointC, context.pointG, context.pointH, context.pointD)) return true; + else + if (UGLHelper.IsPointInPolygon(pos, context.pointA, context.pointE, context.pointF, context.pointB)) return true; + return false; + } + + /// + /// Clamp the position of pos to the grid. + /// ||将位置限制在网格内。 + /// + /// + public void Clamp(ref Vector3 pos) + { + //TODO: + } + + /// + /// Determines whether a given line segment will not intersect the Grid boundary at all. + /// ||判断给定的线段是否与Grid边界是否完全不会相交。 + /// + /// + /// + /// + public bool NotAnyIntersect(Vector3 sp, Vector3 ep) + { + //TODO: + return false; + } + } +} \ No newline at end of file diff --git a/Runtime/Coord/Grid3D/GridCoord3D.cs.meta b/Runtime/Coord/Grid3D/GridCoord3D.cs.meta new file mode 100644 index 00000000..9094e1ca --- /dev/null +++ b/Runtime/Coord/Grid3D/GridCoord3D.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 95f8c8c3492e54987af59175d94f8761 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Coord/Grid3D/GridCoord3DContext.cs b/Runtime/Coord/Grid3D/GridCoord3DContext.cs new file mode 100644 index 00000000..1b134f15 --- /dev/null +++ b/Runtime/Coord/Grid3D/GridCoord3DContext.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace XCharts.Runtime +{ + public class GridCoord3DContext : MainComponentContext + { + public float x; + public float y; + public Rect maxRect = new Rect(0, 0, 0, 0); + public bool isPointerEnter; + public List endLabelList = new List(); + //public Vector3 position = Vector3.zero; + public Vector3 pointA = Vector3.zero; + public Vector3 pointB = Vector3.zero; + public Vector3 pointC = Vector3.zero; + public Vector3 pointD = Vector3.zero; + public Vector3 pointE = Vector3.zero; + public Vector3 pointF = Vector3.zero; + public Vector3 pointG = Vector3.zero; + public Vector3 pointH = Vector3.zero; + } +} \ No newline at end of file diff --git a/Runtime/Coord/Grid3D/GridCoord3DContext.cs.meta b/Runtime/Coord/Grid3D/GridCoord3DContext.cs.meta new file mode 100644 index 00000000..7e53fdc3 --- /dev/null +++ b/Runtime/Coord/Grid3D/GridCoord3DContext.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a4a0f1dda078b4877bfabe3c16815498 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Coord/Grid3D/GridCoord3DHandler.cs b/Runtime/Coord/Grid3D/GridCoord3DHandler.cs new file mode 100644 index 00000000..4dcf685b --- /dev/null +++ b/Runtime/Coord/Grid3D/GridCoord3DHandler.cs @@ -0,0 +1,80 @@ +using System.Text; +using UnityEngine; +using UnityEngine.UI; +using XUGL; + +namespace XCharts.Runtime +{ + [UnityEngine.Scripting.Preserve] + internal sealed class GridCoord3DHandler : MainComponentHandler + { + public override void InitComponent() + { + var grid = component; + grid.painter = chart.painter; + grid.refreshComponent = delegate() + { + grid.UpdateRuntimeData(chart); + chart.OnCoordinateChanged(); + }; + grid.refreshComponent(); + } + + public override void CheckComponent(StringBuilder sb) + { + var grid = component; + if (grid.left >= chart.chartWidth) + sb.Append("warning:grid->left > chartWidth\n"); + if (grid.right >= chart.chartWidth) + sb.Append("warning:grid->right > chartWidth\n"); + if (grid.top >= chart.chartHeight) + sb.Append("warning:grid->top > chartHeight\n"); + if (grid.bottom >= chart.chartHeight) + sb.Append("warning:grid->bottom > chartHeight\n"); + if (grid.left + grid.right >= chart.chartWidth) + sb.Append("warning:grid.left + grid.right > chartWidth\n"); + if (grid.top + grid.bottom >= chart.chartHeight) + sb.Append("warning:grid.top + grid.bottom > chartHeight\n"); + } + + public override void Update() + { + if (chart.isPointerInChart) + { + component.context.isPointerEnter = component.Contains(chart.pointerPos); + } + else + { + component.context.isPointerEnter = false; + } + } + + public override void DrawBase(VertexHelper vh) + { + if (!SeriesHelper.IsAnyClipSerie(chart.series)) + { + DrawCoord(vh, component); + } + } + public override void DrawUpper(VertexHelper vh) + { + if (SeriesHelper.IsAnyClipSerie(chart.series)) + { + DrawCoord(vh, component); + } + } + + private void DrawCoord(VertexHelper vh, GridCoord3D grid) + { + if (!grid.show) return; + if (grid.showBorder) + { + var borderWidth = chart.theme.axis.lineWidth * 2; + var borderColor = chart.theme.axis.lineColor; + UGL.DrawBorder(vh, grid.context.maxRect, borderWidth, borderColor); + // UGL.DrawBorder(vh, grid.context.center, grid.context.width - borderWidth, + // grid.context.height - borderWidth, borderWidth, borderColor); + } + } + } +} \ No newline at end of file diff --git a/Runtime/Coord/Grid3D/GridCoord3DHandler.cs.meta b/Runtime/Coord/Grid3D/GridCoord3DHandler.cs.meta new file mode 100644 index 00000000..0fab114b --- /dev/null +++ b/Runtime/Coord/Grid3D/GridCoord3DHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 92481e92b90724f46b3a7e8c585e12e7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/Internal/BaseChart.Custom.cs b/Runtime/Internal/BaseChart.Custom.cs index 7c761e68..1159477d 100644 --- a/Runtime/Internal/BaseChart.Custom.cs +++ b/Runtime/Internal/BaseChart.Custom.cs @@ -13,10 +13,14 @@ namespace XCharts.Runtime var needAnimationData = !axis.context.needAnimation; if (IsAllAxisValue()) { - if (axis is XAxis) + if (axis is XAxis || axis is XAxis3D) { SeriesHelper.GetXMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData); } + else if (axis is ZAxis3D) + { + SeriesHelper.GetZMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData); + } else { SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData); diff --git a/Runtime/Internal/Data/GraphData.cs b/Runtime/Internal/Data/GraphData.cs index cc293751..ea0414c1 100644 --- a/Runtime/Internal/Data/GraphData.cs +++ b/Runtime/Internal/Data/GraphData.cs @@ -386,6 +386,11 @@ namespace XCharts.Runtime public int depth = -1; public bool expand = true; public int level = 0; + public Vector3 position; + public Vector3 delta; + public float weight; + public float repulsion; + public Vector3 pp; public GraphNode(string id, string name, int dataIndex) { @@ -472,6 +477,7 @@ namespace XCharts.Runtime public List points = new List(); public float width; + public float distance; public bool highlight; public bool expand = true; diff --git a/Runtime/Internal/Utilities/DataHelper.cs b/Runtime/Internal/Utilities/DataHelper.cs index c7c8db54..b0399248 100644 --- a/Runtime/Internal/Utilities/DataHelper.cs +++ b/Runtime/Internal/Utilities/DataHelper.cs @@ -3,7 +3,7 @@ using UnityEngine; namespace XCharts.Runtime { - internal static class DataHelper + public static class DataHelper { public static double DataAverage(ref List showData, SampleType sampleType, int minCount, int maxCount, int rate) diff --git a/Runtime/Serie/Candlestick/Candlestick.cs b/Runtime/Serie/Candlestick/Candlestick.cs index dcfbfddf..64ab8f80 100644 --- a/Runtime/Serie/Candlestick/Candlestick.cs +++ b/Runtime/Serie/Candlestick/Candlestick.cs @@ -16,7 +16,6 @@ namespace XCharts.Runtime public static Serie AddDefaultSerie(BaseChart chart, string serieName) { var serie = chart.AddSerie(serieName); - var defaultDataCount = 5; var lastValue = 50d; for (int i = 0; i < 5; i++) { diff --git a/Runtime/Serie/Line/LineHandler.GridCoord.cs b/Runtime/Serie/Line/LineHandler.GridCoord.cs index dd450e9d..c390ff7c 100644 --- a/Runtime/Serie/Line/LineHandler.GridCoord.cs +++ b/Runtime/Serie/Line/LineHandler.GridCoord.cs @@ -285,7 +285,7 @@ namespace XCharts.Runtime maxCount -= serie.context.dataZoomStartIndexOffset; var scaleWid = AxisHelper.GetDataWidth(axis, axisLength, maxCount, dataZoom); var scaleRelativedWid = AxisHelper.GetDataWidth(relativedAxis, axisRelativedLength, maxCount, dataZoom); - int rate = LineHelper.GetDataAverageRate(serie, m_SerieGrid, maxCount, false); + int rate = LineHelper.GetDataAverageRate(serie, axisLength, maxCount, false); var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage : DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate); diff --git a/Runtime/Serie/Line/LineHelper.cs b/Runtime/Serie/Line/LineHelper.cs index fb43eb6e..9ade9211 100644 --- a/Runtime/Serie/Line/LineHelper.cs +++ b/Runtime/Serie/Line/LineHelper.cs @@ -5,17 +5,16 @@ using XUGL; namespace XCharts.Runtime { - internal static class LineHelper + public static class LineHelper { private static List s_CurvesPosList = new List(); - public static int GetDataAverageRate(Serie serie, GridCoord grid, int maxCount, bool isYAxis) + public static int GetDataAverageRate(Serie serie, float axisLength, int maxCount, bool isYAxis) { var sampleDist = serie.sampleDist; var rate = 0; - var width = isYAxis ? grid.context.height : grid.context.width; if (sampleDist > 0) - rate = (int)((maxCount - serie.minShow) / (width / sampleDist)); + rate = (int)((maxCount - serie.minShow) / (axisLength / sampleDist)); if (rate < 1) rate = 1; return rate; diff --git a/Runtime/Serie/Line/SimplifiedLineHandler.cs b/Runtime/Serie/Line/SimplifiedLineHandler.cs index 069b9e0c..aedd02a6 100644 --- a/Runtime/Serie/Line/SimplifiedLineHandler.cs +++ b/Runtime/Serie/Line/SimplifiedLineHandler.cs @@ -169,7 +169,7 @@ namespace XCharts.Runtime var scaleWid = AxisHelper.GetDataWidth(axis, axisLength, maxCount, dataZoom); var scaleRelativedWid = AxisHelper.GetDataWidth(relativedAxis, axisRelativedLength, maxCount, dataZoom); - int rate = LineHelper.GetDataAverageRate(serie, m_SerieGrid, maxCount, false); + int rate = LineHelper.GetDataAverageRate(serie, axisLength, maxCount, false); var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage : DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate); diff --git a/Runtime/Serie/SerieContext.cs b/Runtime/Serie/SerieContext.cs index d3b3931a..e7ff4551 100644 --- a/Runtime/Serie/SerieContext.cs +++ b/Runtime/Serie/SerieContext.cs @@ -7,11 +7,23 @@ namespace XCharts.Runtime { public Vector3 position; public bool isIgnoreBreak; + public double xValue; + public double yValue; + public double zValue; - public PointInfo(Vector3 pos, bool ignore) + // public PointInfo(Vector3 pos, bool ignore) + // { + // this.position = pos; + // this.isIgnoreBreak = ignore; + // } + + public PointInfo(Vector3 pos, bool ignore, double x = 0, double y = 0, double z = 0) { this.position = pos; this.isIgnoreBreak = ignore; + this.xValue = x; + this.yValue = y; + this.zValue = z; } } diff --git a/Runtime/Serie/SeriesHelper.cs b/Runtime/Serie/SeriesHelper.cs index a8575bc2..fc65b45b 100644 --- a/Runtime/Serie/SeriesHelper.cs +++ b/Runtime/Serie/SeriesHelper.cs @@ -311,7 +311,7 @@ namespace XCharts.Runtime public static void GetXMinMaxValue(BaseChart chart, int axisIndex, bool inverse, out double minValue, out double maxValue, bool isPolar = false, bool filterByDataZoom = true, bool needAnimation = false) { - GetMinMaxValue(chart, axisIndex, inverse, false, out minValue, out maxValue, isPolar, filterByDataZoom, needAnimation); + GetMinMaxValue(chart, axisIndex, inverse, 0, out minValue, out maxValue, isPolar, filterByDataZoom, needAnimation); } /// @@ -324,13 +324,26 @@ namespace XCharts.Runtime public static void GetYMinMaxValue(BaseChart chart, int axisIndex, bool inverse, out double minValue, out double maxValue, bool isPolar = false, bool filterByDataZoom = true, bool needAnimation = false) { - GetMinMaxValue(chart, axisIndex, inverse, true, out minValue, out maxValue, isPolar, filterByDataZoom, needAnimation); + GetMinMaxValue(chart, axisIndex, inverse, 1, out minValue, out maxValue, isPolar, filterByDataZoom, needAnimation); + } + + /// + /// 获得维度Z的最大最小值 + /// + /// + /// + /// + /// + public static void GetZMinMaxValue(BaseChart chart, int axisIndex, bool inverse, out double minValue, + out double maxValue, bool isPolar = false, bool filterByDataZoom = true, bool needAnimation = false) + { + GetMinMaxValue(chart, axisIndex, inverse, 2, out minValue, out maxValue, isPolar, filterByDataZoom, needAnimation); } private static Dictionary> _stackSeriesForMinMax = new Dictionary>(); private static Dictionary _serieTotalValueForMinMax = new Dictionary(); public static void GetMinMaxValue(BaseChart chart, int axisIndex, - bool inverse, bool yValue, out double minValue, out double maxValue, bool isPolar = false, + bool inverse, int dimension, out double minValue, out double maxValue, bool isPolar = false, bool filterByDataZoom = true, bool needAnimation = false) { double min = double.MaxValue; @@ -371,8 +384,8 @@ namespace XCharts.Runtime var performanceMode = serie.IsPerformanceMode(); foreach (var data in showData) { - var currData = performanceMode ? data.GetData(yValue ? 1 : 0, inverse) : - data.GetCurrData(yValue ? 1 : 0, dataAddDuration, updateDuration, unscaledTime, inverse); + var currData = performanceMode ? data.GetData(dimension, inverse) : + data.GetCurrData(dimension, dataAddDuration, updateDuration, unscaledTime, inverse); if (!serie.IsIgnoreValue(data, currData)) { if (currData > max) max = currData; @@ -419,7 +432,7 @@ namespace XCharts.Runtime } else { - currData = showData[j].GetCurrData(yValue ? 1 : 0, dataAddDuration, updateDuration, unscaledTime, inverse); + currData = showData[j].GetCurrData(dimension, dataAddDuration, updateDuration, unscaledTime, inverse); } if (!serie.IsIgnoreValue(showData[j], currData)) _serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] + currData; diff --git a/Runtime/XUGL/UGLHelper.cs b/Runtime/XUGL/UGLHelper.cs index c695cb45..a4d54a0d 100644 --- a/Runtime/XUGL/UGLHelper.cs +++ b/Runtime/XUGL/UGLHelper.cs @@ -310,7 +310,7 @@ namespace XUGL /// 下一个点的下角点 /// 交汇点的上角点 /// 交汇点的下角点 - internal static void GetLinePoints(Vector3 lp, Vector3 cp, Vector3 np, float width, + public static void GetLinePoints(Vector3 lp, Vector3 cp, Vector3 np, float width, ref Vector3 ltp, ref Vector3 lbp, ref Vector3 ntp, ref Vector3 nbp, ref Vector3 itp, ref Vector3 ibp, @@ -397,6 +397,23 @@ namespace XUGL } return inside; } + + public static bool IsPointInPolygon(Vector3 p, params Vector3[] polyons) + { + if (polyons.Length == 0) return false; + var inside = false; + var j = polyons.Length - 1; + for (int i = 0; i < polyons.Length; j = i++) + { + var pi = polyons[i]; + var pj = polyons[j]; + if (((pi.y <= p.y && p.y < pj.y) || (pj.y <= p.y && p.y < pi.y)) && + (p.x < (pj.x - pi.x) * (p.y - pi.y) / (pj.y - pi.y) + pi.x)) + inside = !inside; + } + return inside; + } + public static bool IsPointInPolygon(Vector3 p, List polyons) { if (polyons.Count == 0) return false; From b1522a27d4120cb8c1b06042a8ac5cca0965d889 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 22 Apr 2024 22:35:39 +0800 Subject: [PATCH 11/37] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`DataZoom`=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=A4=9A=E4=B8=AA=E8=BD=B4=E6=97=B6=E7=9A=84`GridCoor?= =?UTF-8?q?d`=E8=8E=B7=E5=8F=96=E5=8F=AF=E8=83=BD=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98=20(#317)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Internal/BaseChart.Component.cs | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 650b60aa..97e89f85 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,7 @@ slug: /changelog ## master +* (2024.04.22) 修复`DataZoom`控制多个轴时的`GridCoord`获取可能不正确的问题 (#317) * (2024.04.22) 增加`GridCoord3D`3D坐标系 * (2024.04.15) 优化`DateTimeUtil`时间戳转`DateTime`接口时区的问题 * (2024.04.15) 优化`GridCoord`在开启`GridLayout`时也显示`Left` `Right` `Top` `Bottom`参数 (#316) diff --git a/Runtime/Internal/BaseChart.Component.cs b/Runtime/Internal/BaseChart.Component.cs index dee1a5d7..32de3739 100644 --- a/Runtime/Internal/BaseChart.Component.cs +++ b/Runtime/Internal/BaseChart.Component.cs @@ -317,13 +317,29 @@ namespace XCharts.Runtime GridCoord grid = null; if (dataZoom.xAxisIndexs != null && dataZoom.xAxisIndexs.Count > 0) { - var xAxis = GetChartComponent(dataZoom.xAxisIndexs[0]); - grid = GetChartComponent(xAxis.gridIndex); + for (int i = 0; i < dataZoom.xAxisIndexs.Count; i++) + { + var xAxis = GetChartComponent(dataZoom.xAxisIndexs[i]); + var tempGrid = GetChartComponent(xAxis.gridIndex); + if (tempGrid.IsPointerEnter()) + { + grid = tempGrid; + break; + } + } } else if (dataZoom.yAxisIndexs != null && dataZoom.yAxisIndexs.Count > 0) { - var yAxis = GetChartComponent(dataZoom.yAxisIndexs[0]); - grid = GetChartComponent(yAxis.gridIndex); + for (int i = 0; i < dataZoom.yAxisIndexs.Count; i++) + { + var yAxis = GetChartComponent(dataZoom.yAxisIndexs[i]); + var tempGrid = GetChartComponent(yAxis.gridIndex); + if (tempGrid.IsPointerEnter()) + { + grid = tempGrid; + break; + } + } } if (grid == null) return GetChartComponent(); else return grid; From 0c92d08f0d2836d07f2849bc4b21125aa3e4fcba Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 23 Apr 2024 22:16:28 +0800 Subject: [PATCH 12/37] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`ConvertXYAxis()`?= =?UTF-8?q?=E5=A4=9A=E6=AC=A1=E8=B0=83=E7=94=A8=E5=90=8E=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Component/Axis/Axis.cs | 11 +++++++++++ Runtime/Internal/BaseChart.API.cs | 2 ++ Runtime/Internal/Basic/MainComponent.cs | 4 +++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 97e89f85..82101a24 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,7 @@ slug: /changelog ## master +* (2024.04.23) 修复`ConvertXYAxis()`多次调用后图表异常的问题 * (2024.04.22) 修复`DataZoom`控制多个轴时的`GridCoord`获取可能不正确的问题 (#317) * (2024.04.22) 增加`GridCoord3D`3D坐标系 * (2024.04.15) 优化`DateTimeUtil`时间戳转`DateTime`接口时区的问题 diff --git a/Runtime/Component/Axis/Axis.cs b/Runtime/Component/Axis/Axis.cs index 696f37de..f9e6c4a9 100644 --- a/Runtime/Component/Axis/Axis.cs +++ b/Runtime/Component/Axis/Axis.cs @@ -459,6 +459,17 @@ namespace XCharts.Runtime base.SetComponentDirty(); } + /// + /// 重置状态。 + /// + public override void ResetStatus() + { + context.minValue = 0; + context.maxValue = 0; + context.destMinValue = 0; + context.destMaxValue = 0; + } + public Axis Clone() { var axis = new Axis(); diff --git a/Runtime/Internal/BaseChart.API.cs b/Runtime/Internal/BaseChart.API.cs index f61a647f..7383202d 100644 --- a/Runtime/Internal/BaseChart.API.cs +++ b/Runtime/Internal/BaseChart.API.cs @@ -532,6 +532,7 @@ namespace XCharts.Runtime xAxis.context.maxValue = 0; yAxis.context.minValue = 0; yAxis.context.maxValue = 0; + ResetChartStatus(); RefreshChart(); } } @@ -771,6 +772,7 @@ namespace XCharts.Runtime [Since("v3.10.0")] public void ResetChartStatus() { + foreach (var component in m_Components) component.ResetStatus(); foreach (var handler in m_SerieHandlers) handler.ForceUpdateSerieContext(); } } diff --git a/Runtime/Internal/Basic/MainComponent.cs b/Runtime/Internal/Basic/MainComponent.cs index 9bc4adca..ae7798b7 100644 --- a/Runtime/Internal/Basic/MainComponent.cs +++ b/Runtime/Internal/Basic/MainComponent.cs @@ -54,6 +54,8 @@ namespace XCharts.Runtime public virtual void Reset() { } + public virtual void ResetStatus() { } + public virtual void ClearData() { } public virtual void ClearDirty() @@ -120,7 +122,7 @@ namespace XCharts.Runtime internal override void SetComponent(MainComponent component) { - this.component = (T) component; + this.component = (T)component; } } } \ No newline at end of file From 4e3182edfc9f85ea97968955f10c8feba5af895b Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 9 May 2024 13:13:51 +0800 Subject: [PATCH 13/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`JsonUtil`=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/en/api.md | 29 ++++++++++-- Documentation~/en/configuration.md | 5 ++ Documentation~/zh/api.md | 29 ++++++++++-- Documentation~/zh/changelog.md | 1 + Documentation~/zh/configuration.md | 5 ++ Runtime/Internal/BaseChart.Serie.cs | 8 ++-- Runtime/Internal/Data/GraphData.cs | 12 ++--- Runtime/Serie/Serie.cs | 12 ++--- Runtime/Utilities/JsonUtil.cs | 73 +++++++++++++++++++++++++++++ Runtime/Utilities/JsonUtil.cs.meta | 11 +++++ 10 files changed, 161 insertions(+), 24 deletions(-) create mode 100644 Runtime/Utilities/JsonUtil.cs create mode 100644 Runtime/Utilities/JsonUtil.cs.meta diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index 92c6fdf5..b82960a8 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -107,6 +107,7 @@ slug: /api - [ISimplifiedSerie](#isimplifiedserie) - [ItemStyle](#itemstyle) - [IUpdateRuntimeData](#iupdateruntimedata) +- [JsonUtil](#jsonutil) - [LabelLine](#labelline) - [LabelStyle](#labelstyle) - [Lang](#lang) @@ -236,6 +237,7 @@ slug: /api - [VisualMapHelper](#visualmaphelper) - [VisualMapRange](#visualmaprange) - [VisualMapTheme](#visualmaptheme) +- [Wrapper<T>](#wrappert) - [XAxis](#xaxis) - [XAxis3D](#xaxis3d) - [XChartsMgr](#xchartsmgr) @@ -461,6 +463,7 @@ The axis in rectangular coordinate. |IsTop()||public bool IsTop()| |IsValue()||public bool IsValue()
是否为数值轴。 | |RemoveData()||public void RemoveData(int dataIndex)| +|ResetStatus()||public override void ResetStatus()
重置状态。 | |SetComponentDirty()||public override void SetComponentDirty()| |SetNeedUpdateFilterData()||public void SetNeedUpdateFilterData()| |UpdateData()||public void UpdateData(int index, string category)
更新类目数据 | @@ -730,7 +733,7 @@ Bar chart shows different data through the height of a bar, which is used in rec |AddData()||public SerieData AddData(string serieName, double xValue, double yValue, string dataName = null, string dataId = null)
Add a (x,y) data to serie. | |AddData()||public SerieData AddData(string serieName, List<double> multidimensionalData, string dataName = null, string dataId = null)
Add an arbitray dimension data to serie,such as (x,y,z,...). | |AddData()||public SerieData AddData(string serieName, params double[] multidimensionalData)
Add an arbitray dimension data to serie,such as (x,y,z,...). | -|AddLink()||public SerieDataLink AddLink(int serieIndex, string sourceName, string targetName, double value)
Add a link data to serie. | +|AddLink()||public SerieDataLink AddLink(int serieIndex, string sourceId, string targetId, double value = 0)
Add a link data to serie. | |AddSerie<T>()||public T AddSerie<T>(string serieName = null, bool show = true, bool addToHead = false) where T : Serie| |AddXAxisData()||public void AddXAxisData(string category, int xAxisIndex = 0)
Add a category data to xAxis. | |AddXAxisIcon()||public void AddXAxisIcon(Sprite icon, int xAxisIndex = 0)
Add an icon to xAxis. | @@ -1446,7 +1449,7 @@ 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)| +|AddNode()||public GraphNode AddNode(string nodeId, string nodeName, int dataIndex, double value)| |BreadthFirstTraverse()||public void BreadthFirstTraverse(GraphNode startNode, System.Action<GraphNode> onTraverse)| |Clear()||public void Clear()| |DeepFirstTraverse()||public void DeepFirstTraverse(GraphNode startNode, System.Action<GraphNode> onTraverse)| @@ -1723,6 +1726,18 @@ The interface for serie data component. > class in XCharts.Runtime / Subclasses: [SingleAxis](#singleaxis),[DataZoom](#datazoom),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[GridLayout](#gridlayout),[GridCoord3D](#gridcoord3d),[ParallelCoord](#parallelcoord) +## JsonUtil + +> class in XCharts.Runtime + + +|public method|since|description| +|--|--|--| +|GetJsonArray<T>()||public static T[] GetJsonArray<T>(string json)| +|GetJsonObject<T>()||public static T GetJsonObject<T>(string json)| +|GetWebJson<T>()||public static IEnumerator GetWebJson<T>(string url, Action<T[]> callback)| +|GetWebJson<T>()||public static IEnumerator GetWebJson<T>(string url, Action<T> callback)| + ## LabelLine > class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent),[ISerieComponent](#iseriecomponent),[ISerieDataComponent](#iseriedatacomponent) @@ -2019,6 +2034,7 @@ Location type. Quick to set the general location. |CompareTo()||public int CompareTo(object obj)| |OnRemove()||public virtual void OnRemove()| |Reset()||public virtual void Reset() { }| +|ResetStatus()||public virtual void ResetStatus() { }| |SetAllDirty()||public virtual void SetAllDirty()| |SetComponentDirty()||public virtual void SetComponentDirty()| |SetDefaultValue()||public virtual void SetDefaultValue() { }| @@ -2458,8 +2474,8 @@ Configurations of select state. |AddData()||public SerieData AddData(List<double> valueList, string dataName = null, string dataId = null)
将一组数据添加到系列中。 如果数据只有一个,默认添加到维度Y中。 | |AddData()||public SerieData AddData(params double[] values)
添加任意维数据到系列中。 | |AddExtraComponent<T>()||public T AddExtraComponent<T>() where T : ChildComponent, ISerieComponent| -|AddLink()||public SerieDataLink AddLink(string sourceName, string targetName, double value)
Add a link data. | -|AddSerieData()||public void AddSerieData(SerieData serieData)| +|AddLink()||public virtual SerieDataLink AddLink(string sourceId, string targetId, double value = 0)
Add a link data. | +|AddSerieData()||public virtual void AddSerieData(SerieData serieData)| |AddXYData()||public SerieData AddXYData(double xValue, double yValue, string dataName = null, string dataId = null)
添加(x,y)数据到维度X和维度Y | |AddYData()||public SerieData AddYData(double value, string dataName = null, string dataId = null)
添加一个数据到维度Y(此时维度X对应的数据是索引) | |AnimationEnable()||public void AnimationEnable(bool flag)
启用或取消初始动画 | @@ -3388,6 +3404,11 @@ VisualMap component. Mapping data to visual elements such as colors. |Copy()||public void Copy(VisualMapTheme theme)| |VisualMapTheme()||public VisualMapTheme(ThemeType theme) : base(theme)| +## Wrapper<T> + +> class in XCharts.Runtime + + ## XAxis > class in XCharts.Runtime / Inherits from: [Axis](#axis) diff --git a/Documentation~/en/configuration.md b/Documentation~/en/configuration.md index 3f87ec82..f225256a 100644 --- a/Documentation~/en/configuration.md +++ b/Documentation~/en/configuration.md @@ -199,6 +199,7 @@ import APITable from '@site/src/components/APITable'; - [LangCandlestick](#langcandlestick) - [LangTime](#langtime) - [MainComponent](#maincomponent) +- [Wrapper<T>](#wrappert) - [XCResourcesImporter](#xcresourcesimporter) - [XCSettings](#xcsettings) @@ -2520,6 +2521,10 @@ VisualMap component. Mapping data to visual elements such as colors. ``` +## Wrapper<T> + +> class in XCharts.Runtime + ## XAxis > class in XCharts.Runtime / Inherits from: [Axis](#axis) diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index c9c54379..bb453b2a 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -107,6 +107,7 @@ slug: /api - [ISimplifiedSerie](#isimplifiedserie) - [ItemStyle](#itemstyle) - [IUpdateRuntimeData](#iupdateruntimedata) +- [JsonUtil](#jsonutil) - [LabelLine](#labelline) - [LabelStyle](#labelstyle) - [Lang](#lang) @@ -236,6 +237,7 @@ slug: /api - [VisualMapHelper](#visualmaphelper) - [VisualMapRange](#visualmaprange) - [VisualMapTheme](#visualmaptheme) +- [Wrapper<T>](#wrappert) - [XAxis](#xaxis) - [XAxis3D](#xaxis3d) - [XChartsMgr](#xchartsmgr) @@ -461,6 +463,7 @@ slug: /api |IsTop()||public bool IsTop()| |IsValue()||public bool IsValue()
是否为数值轴。 | |RemoveData()||public void RemoveData(int dataIndex)| +|ResetStatus()||public override void ResetStatus()
重置状态。 | |SetComponentDirty()||public override void SetComponentDirty()| |SetNeedUpdateFilterData()||public void SetNeedUpdateFilterData()| |UpdateData()||public void UpdateData(int index, string category)
更新类目数据 | @@ -730,7 +733,7 @@ slug: /api |AddData()||public SerieData AddData(string serieName, double xValue, double yValue, string dataName = null, string dataId = null)
添加(x,y)数据到指定系列中。 | |AddData()||public SerieData AddData(string serieName, List<double> multidimensionalData, string dataName = null, string dataId = null)
添加多维数据(x,y,z...)到指定的系列中。 | |AddData()||public SerieData AddData(string serieName, params double[] multidimensionalData)
添加多维数据(x,y,z...)到指定的系列中。 | -|AddLink()||public SerieDataLink AddLink(int serieIndex, string sourceName, string targetName, double value)
添加一个关系图的关系数据。 | +|AddLink()||public SerieDataLink AddLink(int serieIndex, string sourceId, string targetId, double value = 0)
添加一个关系图的关系数据。 | |AddSerie<T>()||public T AddSerie<T>(string serieName = null, bool show = true, bool addToHead = false) where T : Serie| |AddXAxisData()||public void AddXAxisData(string category, int xAxisIndex = 0)
添加一个类目数据到指定的x轴。 | |AddXAxisIcon()||public void AddXAxisIcon(Sprite icon, int xAxisIndex = 0)
添加一个图标到指定的x轴。 | @@ -1446,7 +1449,7 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息 |API|版本|描述| |--|--|--| |AddEdge()||public GraphEdge AddEdge(string nodeId1, string nodeId2, double value)| -|AddNode()||public GraphNode AddNode(string nodeId, string nodeName, int dataIndex)| +|AddNode()||public GraphNode AddNode(string nodeId, string nodeName, int dataIndex, double value)| |BreadthFirstTraverse()||public void BreadthFirstTraverse(GraphNode startNode, System.Action<GraphNode> onTraverse)| |Clear()||public void Clear()| |DeepFirstTraverse()||public void DeepFirstTraverse(GraphNode startNode, System.Action<GraphNode> onTraverse)| @@ -1723,6 +1726,18 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart > class in XCharts.Runtime / 子类: [SingleAxis](#singleaxis),[DataZoom](#datazoom),[CalendarCoord](#calendarcoord),[GridCoord](#gridcoord),[GridLayout](#gridlayout),[GridCoord3D](#gridcoord3d),[ParallelCoord](#parallelcoord) +## JsonUtil + +> class in XCharts.Runtime + + +|API|版本|描述| +|--|--|--| +|GetJsonArray<T>()||public static T[] GetJsonArray<T>(string json)| +|GetJsonObject<T>()||public static T GetJsonObject<T>(string json)| +|GetWebJson<T>()||public static IEnumerator GetWebJson<T>(string url, Action<T[]> callback)| +|GetWebJson<T>()||public static IEnumerator GetWebJson<T>(string url, Action<T> callback)| + ## LabelLine > class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent),[ISerieComponent](#iseriecomponent),[ISerieDataComponent](#iseriedatacomponent) @@ -2019,6 +2034,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart |CompareTo()||public int CompareTo(object obj)| |OnRemove()||public virtual void OnRemove()| |Reset()||public virtual void Reset() { }| +|ResetStatus()||public virtual void ResetStatus() { }| |SetAllDirty()||public virtual void SetAllDirty()| |SetComponentDirty()||public virtual void SetComponentDirty()| |SetDefaultValue()||public virtual void SetDefaultValue() { }| @@ -2458,8 +2474,8 @@ Radar coordinate conponnet for radar charts. 雷达图坐标系组件,只适 |AddData()||public SerieData AddData(List<double> valueList, string dataName = null, string dataId = null)
将一组数据添加到系列中。 如果数据只有一个,默认添加到维度Y中。 | |AddData()||public SerieData AddData(params double[] values)
添加任意维数据到系列中。 | |AddExtraComponent<T>()||public T AddExtraComponent<T>() where T : ChildComponent, ISerieComponent| -|AddLink()||public SerieDataLink AddLink(string sourceName, string targetName, double value)
添加一个关系图的关系数据。 | -|AddSerieData()||public void AddSerieData(SerieData serieData)| +|AddLink()||public virtual SerieDataLink AddLink(string sourceId, string targetId, double value = 0)
添加一个关系图的关系数据。 | +|AddSerieData()||public virtual void AddSerieData(SerieData serieData)| |AddXYData()||public SerieData AddXYData(double xValue, double yValue, string dataName = null, string dataId = null)
添加(x,y)数据到维度X和维度Y | |AddYData()||public SerieData AddYData(double value, string dataName = null, string dataId = null)
添加一个数据到维度Y(此时维度X对应的数据是索引) | |AnimationEnable()||public void AnimationEnable(bool flag)
启用或取消初始动画 | @@ -3388,6 +3404,11 @@ UI帮助类。 |Copy()||public void Copy(VisualMapTheme theme)| |VisualMapTheme()||public VisualMapTheme(ThemeType theme) : base(theme)| +## Wrapper<T> + +> class in XCharts.Runtime + + ## XAxis > class in XCharts.Runtime / 继承自: [Axis](#axis) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 82101a24..ba966519 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,7 @@ slug: /changelog ## master +* (2024.05.09) 增加`JsonUtil`工具类 * (2024.04.23) 修复`ConvertXYAxis()`多次调用后图表异常的问题 * (2024.04.22) 修复`DataZoom`控制多个轴时的`GridCoord`获取可能不正确的问题 (#317) * (2024.04.22) 增加`GridCoord3D`3D坐标系 diff --git a/Documentation~/zh/configuration.md b/Documentation~/zh/configuration.md index 4e51f47b..633dc4cf 100644 --- a/Documentation~/zh/configuration.md +++ b/Documentation~/zh/configuration.md @@ -199,6 +199,7 @@ import APITable from '@site/src/components/APITable'; - [LangCandlestick](#langcandlestick) - [LangTime](#langtime) - [MainComponent](#maincomponent) +- [Wrapper<T>](#wrappert) - [XCResourcesImporter](#xcresourcesimporter) - [XCSettings](#xcsettings) @@ -2442,6 +2443,10 @@ Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种 ``` +## Wrapper<T> + +> class in XCharts.Runtime + ## XAxis > class in XCharts.Runtime / 继承自: [Axis](#axis) diff --git a/Runtime/Internal/BaseChart.Serie.cs b/Runtime/Internal/BaseChart.Serie.cs index e402ee4d..ce742f00 100644 --- a/Runtime/Internal/BaseChart.Serie.cs +++ b/Runtime/Internal/BaseChart.Serie.cs @@ -447,16 +447,16 @@ namespace XCharts.Runtime /// ||添加一个关系图的关系数据。 ///
/// the index of serie - /// the source name of link - /// the target name of link + /// the source id of link + /// the target id of link /// the value of link /// - 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; } diff --git a/Runtime/Internal/Data/GraphData.cs b/Runtime/Internal/Data/GraphData.cs index ea0414c1..2fbea247 100644 --- a/Runtime/Internal/Data/GraphData.cs +++ b/Runtime/Internal/Data/GraphData.cs @@ -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 edges = new List(); public List inEdges = new List(); public List outEdges = new List(); @@ -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) { diff --git a/Runtime/Serie/Serie.cs b/Runtime/Serie/Serie.cs index cbfe1f88..b3e6e706 100644 --- a/Runtime/Serie/Serie.cs +++ b/Runtime/Serie/Serie.cs @@ -1357,7 +1357,7 @@ namespace XCharts.Runtime return serieData; } - public void AddSerieData(SerieData serieData) + public virtual void AddSerieData(SerieData serieData) { if (m_InsertDataToHead) m_Data.Insert(0, serieData); @@ -1547,15 +1547,15 @@ namespace XCharts.Runtime /// Add a link data. /// ||添加一个关系图的关系数据。 ///
- /// - /// + /// + /// /// /// - public SerieDataLink AddLink(string sourceName, string targetName, double value) + public virtual SerieDataLink AddLink(string sourceId, string targetId, double value = 0) { var link = new SerieDataLink(); - link.source = sourceName; - link.target = targetName; + link.source = sourceId; + link.target = targetId; link.value = value; m_Links.Add(link); SetVerticesDirty(); diff --git a/Runtime/Utilities/JsonUtil.cs b/Runtime/Utilities/JsonUtil.cs new file mode 100644 index 00000000..b8b018a6 --- /dev/null +++ b/Runtime/Utilities/JsonUtil.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.Networking; + +namespace XCharts.Runtime +{ + public static class JsonUtil + { + + public static IEnumerator GetWebJson(string url, Action callback) + { + var www = UnityWebRequest.Get(url); + yield return www; +#if UNITY_2020_1_OR_NEWER + if (www.result != UnityWebRequest.Result.Success) +#else + if (www.isNetworkError || www.isHttpError) +#endif + { + Debug.LogError("GetWebJson Error: " + www.error); + } + + else + { + var json = www.downloadHandler.text.Trim(); + callback(GetJsonArray(json)); + www.Dispose(); + } + } + + public static IEnumerator GetWebJson(string url, Action callback) + { + var www = UnityWebRequest.Get(url); + yield return www; +#if UNITY_2020_1_OR_NEWER + if (www.result != UnityWebRequest.Result.Success) +#else + if (www.isNetworkError || www.isHttpError) +#endif + { + Debug.LogError("GetWebJson Error: " + www.error); + } + else + { + var json = www.downloadHandler.text.Trim(); + callback(GetJsonObject(json)); + www.Dispose(); + } + } + + public static T GetJsonObject(string json) + { + return JsonUtility.FromJson(json); + } + + public static T[] GetJsonArray(string json) + { + string newJson = "{ \"array\": " + json + "}"; + Wrapper wrapper = JsonUtility.FromJson>(newJson); + return wrapper.array; + } + + [Serializable] + private class Wrapper + { +#pragma warning disable 0649 + public T[] array; +#pragma warning restore 0649 + } + } +} \ No newline at end of file diff --git a/Runtime/Utilities/JsonUtil.cs.meta b/Runtime/Utilities/JsonUtil.cs.meta new file mode 100644 index 00000000..db138b1a --- /dev/null +++ b/Runtime/Utilities/JsonUtil.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 88e9115d32af34a3dae0d5c3e32de41c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 3e8bf7caeeeb1ba8d7d299f1e1d5f831ea18e434 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 15 May 2024 13:19:34 +0800 Subject: [PATCH 14/37] =?UTF-8?q?=E4=BC=98=E5=8C=96Line3D=E7=BB=98?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/en/api.md | 2 +- Documentation~/zh/api.md | 2 +- .../Component/Animation/AnimationStyleHelper.cs | 16 ++++++++++++---- Runtime/Serie/Line/LineHelper.cs | 7 ++++--- Runtime/Serie/SerieContext.cs | 4 +++- Runtime/Serie/SerieHandler.cs | 2 +- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index b82960a8..d2d5d46f 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -401,7 +401,7 @@ the animation of serie. support animation type: fadeIn, fadeOut, change, additio |public method|since|description| |--|--|--| |CheckDataAnimation()||public static float CheckDataAnimation(BaseChart chart, Serie serie, int dataIndex, float destProgress, float startPorgress = 0)| -|GetAnimationPosition()||public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip)| +|GetAnimationPosition()||public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip, ref float rate)| |UpdateAnimationType()||public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation)| |UpdateSerieAnimation()||public static void UpdateSerieAnimation(Serie serie)| diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index bb453b2a..378015c0 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -401,7 +401,7 @@ slug: /api |API|版本|描述| |--|--|--| |CheckDataAnimation()||public static float CheckDataAnimation(BaseChart chart, Serie serie, int dataIndex, float destProgress, float startPorgress = 0)| -|GetAnimationPosition()||public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip)| +|GetAnimationPosition()||public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip, ref float rate)| |UpdateAnimationType()||public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation)| |UpdateSerieAnimation()||public static void UpdateSerieAnimation(Serie serie)| diff --git a/Runtime/Component/Animation/AnimationStyleHelper.cs b/Runtime/Component/Animation/AnimationStyleHelper.cs index bc8a5bf5..568ab86a 100644 --- a/Runtime/Component/Animation/AnimationStyleHelper.cs +++ b/Runtime/Component/Animation/AnimationStyleHelper.cs @@ -37,7 +37,7 @@ namespace XCharts.Runtime animationType = attribute.type; enableSerieDataAnimation = attribute.enableSerieDataAddedAnimation; } - UpdateAnimationType(serie.animation, animationType,enableSerieDataAnimation); + UpdateAnimationType(serie.animation, animationType, enableSerieDataAnimation); } public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation) @@ -48,12 +48,12 @@ namespace XCharts.Runtime animation.context.enableSerieDataAddedAnimation = enableSerieDataAnimation; } - public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip) + public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip, ref float rate) { if (animation.context.type == AnimationType.AlongPath) { var dist = Vector3.Distance(lp, cp); - var rate = (dist - animation.context.currentPathDistance + animation.GetCurrDetail()) / dist; + rate = (dist - animation.context.currentPathDistance + animation.GetCurrDetail()) / dist; ip = Vector3.Lerp(lp, cp, rate); return true; } @@ -62,7 +62,15 @@ namespace XCharts.Runtime var startPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000); var endPos = isY ? new Vector3(10000, progress) : new Vector3(progress, 10000); - return UGLHelper.GetIntersection(lp, cp, startPos, endPos, ref ip); + if (UGLHelper.GetIntersection(lp, cp, startPos, endPos, ref ip)) + { + rate = Vector3.Distance(lp, ip) / Vector3.Distance(lp, cp); + return true; + } + else + { + return false; + } } } } diff --git a/Runtime/Serie/Line/LineHelper.cs b/Runtime/Serie/Line/LineHelper.cs index 9ade9211..25cd03ea 100644 --- a/Runtime/Serie/Line/LineHelper.cs +++ b/Runtime/Serie/Line/LineHelper.cs @@ -302,11 +302,12 @@ namespace XCharts.Runtime isBreak = true; var ip = Vector3.zero; var progress = serie.animation.GetCurrDetail(); - if (AnimationStyleHelper.GetAnimationPosition(serie.animation, isY, lp, cp, progress, ref ip)) + var rate = 0f; + if (AnimationStyleHelper.GetAnimationPosition(serie.animation, isY, lp, cp, progress, ref ip, ref rate)) cp = np = ip; } serie.context.lineEndPostion = cp; - serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp); + serie.context.lineEndValueY = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp); var handled = false; var isClip = false; if (serie.clip) @@ -382,7 +383,7 @@ namespace XCharts.Runtime AddLineVertToVertexHelper(vh, clp, crp, lineColor, isVisualMapGradient, isLineStyleGradient, visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore); serie.context.lineEndPostion = cp; - serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp); + serie.context.lineEndValueY = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp); break; } } diff --git a/Runtime/Serie/SerieContext.cs b/Runtime/Serie/SerieContext.cs index e7ff4551..cf67a6c6 100644 --- a/Runtime/Serie/SerieContext.cs +++ b/Runtime/Serie/SerieContext.cs @@ -57,7 +57,9 @@ namespace XCharts.Runtime /// 线段终点 ///
public Vector3 lineEndPostion; - public double lineEndValue; + public double lineEndValueX; + public double lineEndValueY; + public double lineEndValueZ; /// /// 内半径 /// diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs index fd232af3..fa08c07a 100644 --- a/Runtime/Serie/SerieHandler.cs +++ b/Runtime/Serie/SerieHandler.cs @@ -557,7 +557,7 @@ namespace XCharts.Runtime m_EndLabel.SetActive(active); if (active) { - var value = serie.context.lineEndValue; + var value = serie.context.lineEndValueY; var content = SerieLabelHelper.GetFormatterContent(serie, null, value, 0, endLabelStyle, Color.clear); m_EndLabel.SetText(content); From fc346d30fbe8af37d25cc3a5a939c84d19d81c4d Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 19 May 2024 11:01:46 +0800 Subject: [PATCH 15/37] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E6=95=B0=E6=8D=AE=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/Windows/PraseExternalDataEditor.cs | 32 +++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Editor/Windows/PraseExternalDataEditor.cs b/Editor/Windows/PraseExternalDataEditor.cs index 52b85f6f..d7e47f0d 100644 --- a/Editor/Windows/PraseExternalDataEditor.cs +++ b/Editor/Windows/PraseExternalDataEditor.cs @@ -8,6 +8,8 @@ namespace XCharts.Editor { public class PraseExternalDataEditor : UnityEditor.EditorWindow { + [SerializeField] private int m_DataDimension = 1; + [SerializeField] private double m_DefaultYValue = 0; private static BaseChart s_Chart; private static Serie s_Serie; private static Axis s_Axis; @@ -46,8 +48,13 @@ namespace XCharts.Editor return; } EditorGUILayout.LabelField("Input external data (echarts data):"); + m_DataDimension = EditorGUILayout.IntField("Data Dimension", m_DataDimension); + if (m_DataDimension < 1) + m_DataDimension = 1; + else if (m_DataDimension == 2) + m_DefaultYValue = EditorGUILayout.DoubleField("Default Y Value", m_DefaultYValue); inputJsonText = EditorGUILayout.TextArea(inputJsonText, GUILayout.Height(400)); - if (GUILayout.Button("Add")) + if (GUILayout.Button("Try Add")) { if (s_Serie != null) { @@ -76,7 +83,7 @@ namespace XCharts.Editor } } - private static bool ParseArrayData(Axis axis, string arrayData) + private bool ParseArrayData(Axis axis, string arrayData) { arrayData = arrayData.Trim(); if (!arrayData.StartsWith("data: Array")) return false; @@ -95,7 +102,7 @@ namespace XCharts.Editor return true; } - private static bool ParseArrayData(Serie serie, string arrayData) + private bool ParseArrayData(Serie serie, string arrayData) { arrayData = arrayData.Trim(); if (!arrayData.StartsWith("data: Array")) return false; @@ -120,7 +127,7 @@ namespace XCharts.Editor return true; } - private static bool ParseJsonData(Axis axis, string jsonData) + private bool ParseJsonData(Axis axis, string jsonData) { if (!CheckJsonData(ref jsonData)) return false; axis.data.Clear(); @@ -140,7 +147,7 @@ namespace XCharts.Editor /// 从json中导入数据 /// /// - private static bool ParseJsonData(Serie serie, string jsonData) + private bool ParseJsonData(Serie serie, string jsonData) { if (!CheckJsonData(ref jsonData)) return false; if (s_LinksData) serie.ClearLinks(); @@ -156,7 +163,10 @@ namespace XCharts.Editor if (data.Length == 2 && !double.TryParse(data[0], out value)) { double.TryParse(data[1], out value); - serieData.data = new List() { i, value }; + if (m_DataDimension == 2) + serieData.data = new List() { i, m_DefaultYValue, value }; + else + serieData.data = new List() { i, value }; serieData.name = data[0].Replace("\"", "").Trim(); } else @@ -187,7 +197,10 @@ namespace XCharts.Editor if (a.StartsWith("value:")) { double value = double.Parse(a.Substring(6, a.Length - 6)); - serieData.data = new List() { i, value }; + if (m_DataDimension == 2) + serieData.data = new List() { i, m_DefaultYValue, value }; + else + serieData.data = new List() { i, value }; } else if (a.StartsWith("name:")) { @@ -213,7 +226,10 @@ namespace XCharts.Editor if (flag) { var serieData = new SerieData(); - serieData.data = new List() { i, value }; + if (m_DataDimension == 2) + serieData.data = new List() { i, m_DefaultYValue, value }; + else + serieData.data = new List() { i, value }; serie.AddSerieData(serieData); } } From 86125c597edd460873e787358d3ae2f52ddf74c6 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 19 May 2024 11:02:03 +0800 Subject: [PATCH 16/37] =?UTF-8?q?=E4=BC=98=E5=8C=96Editor=E4=B8=8B?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/Series/SerieEditor.cs | 173 +++++++++++++++----------- Editor/Utilities/ChartEditorHelper.cs | 34 +++++ 2 files changed, 131 insertions(+), 76 deletions(-) diff --git a/Editor/Series/SerieEditor.cs b/Editor/Series/SerieEditor.cs index 6f3d330d..5fa47e9a 100644 --- a/Editor/Series/SerieEditor.cs +++ b/Editor/Series/SerieEditor.cs @@ -53,14 +53,18 @@ namespace XCharts.Editor } } + private HeaderMenuInfo headMenuInfo = new HeaderMenuInfo("Import ECharts Data", null); + + private void HeadMenuInfoCallback() + { + PraseExternalDataEditor.UpdateData(chart, serie, null, false); + PraseExternalDataEditor.ShowWindow(); + } + private void PropertyFieldData() { - m_DataFoldout = ChartEditorHelper.DrawHeader("Data", m_DataFoldout, false, null, null, - new HeaderMenuInfo("Import ECharts Data", () => - { - PraseExternalDataEditor.UpdateData(chart, serie, null, false); - PraseExternalDataEditor.ShowWindow(); - })); + headMenuInfo.action = HeadMenuInfoCallback; + m_DataFoldout = ChartEditorHelper.DrawHeader("Data", m_DataFoldout, false, null, null, headMenuInfo); if (!m_DataFoldout) return; EditorGUI.indentLevel++; var m_Datas = FindProperty("m_Data"); @@ -103,14 +107,18 @@ namespace XCharts.Editor EditorGUI.indentLevel--; } + private HeaderMenuInfo linkHeadMenuInfo = new HeaderMenuInfo("Import ECharts Link", null); + + private void LinkHeadMenuInfoCallback() + { + PraseExternalDataEditor.UpdateData(chart, serie, null, false); + PraseExternalDataEditor.ShowWindow(); + } + 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(); - })); + linkHeadMenuInfo.action = LinkHeadMenuInfoCallback; + m_LinksFoldout = ChartEditorHelper.DrawHeader("Links", m_LinksFoldout, false, null, null, linkHeadMenuInfo); if (!m_LinksFoldout) return; EditorGUI.indentLevel++; var m_Links = FindProperty("m_Links"); @@ -154,6 +162,75 @@ namespace XCharts.Editor } } + private void DrawSerieDataHeader(Rect drawRect,HeaderCallbackContext context) + { + var serieData = context.serieData; + var fieldCount = context.fieldCount; + var showName = context.showName; + var index = context.index; + var dimension = context.dimension; + + //drawRect.width -= 2f; + var maxX = drawRect.xMax; + var currentWidth = drawRect.width; + var lastX = drawRect.x; + var lastWid = drawRect.width; + var lastFieldWid = EditorGUIUtility.fieldWidth; + var lastLabelWid = EditorGUIUtility.labelWidth; + var sereName = serieData.FindPropertyRelative("m_Name"); + var data = serieData.FindPropertyRelative("m_Data"); +#if UNITY_2019_3_OR_NEWER + var gap = 2; + var namegap = 3; +#else + var gap = 0; + var namegap = 0; +#endif + if (fieldCount <= 1) + { + while (2 > data.arraySize) + { + var value = data.arraySize == 0 ? index : 0; + data.arraySize++; + data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value; + } + SerializedProperty element = data.GetArrayElementAtIndex(1); + var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap; + drawRect.x = startX; + drawRect.xMax = maxX; + EditorGUI.PropertyField(drawRect, element, GUIContent.none); + } + else + { + var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap; + var dataWidTotal = (currentWidth - (startX + 20.5f + 1)); + var dataWid = dataWidTotal / fieldCount; + var xWid = dataWid - 0; + for (int i = 0; i < dimension; i++) + { + var dataCount = i < 1 ? 2 : i + 1; + while (dataCount > data.arraySize) + { + var value = data.arraySize == 0 ? index : 0; + data.arraySize++; + data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value; + } + drawRect.x = startX + i * xWid; + drawRect.width = dataWid + 25; + SerializedProperty element = data.GetArrayElementAtIndex(dimension <= 1 ? 1 : i); + EditorGUI.PropertyField(drawRect, element, GUIContent.none); + } + if (showName) + { + drawRect.x = startX + (fieldCount - 1) * xWid; + drawRect.width = dataWid + 40 + dimension * namegap - 2.5f; + EditorGUI.PropertyField(drawRect, sereName, GUIContent.none); + } + EditorGUIUtility.fieldWidth = lastFieldWid; + EditorGUIUtility.labelWidth = lastLabelWid; + } + } + private void DrawSerieData(int dimension, SerializedProperty m_Datas, int index, bool showName) { bool flag; @@ -165,70 +242,14 @@ namespace XCharts.Editor var fieldCount = dimension + (showName ? 1 : 0); var serieData = m_Datas.GetArrayElementAtIndex(index); var dataIndex = serieData.FindPropertyRelative("m_Index").intValue; - m_DataElementFoldout[index] = ChartEditorHelper.DrawHeader("SerieData " + dataIndex, flag, false, null, - delegate (Rect drawRect) - { - //drawRect.width -= 2f; - var maxX = drawRect.xMax; - var currentWidth = drawRect.width; - var lastX = drawRect.x; - var lastWid = drawRect.width; - var lastFieldWid = EditorGUIUtility.fieldWidth; - var lastLabelWid = EditorGUIUtility.labelWidth; - //var serieData = m_Datas.GetArrayElementAtIndex(index); - var sereName = serieData.FindPropertyRelative("m_Name"); - var data = serieData.FindPropertyRelative("m_Data"); -#if UNITY_2019_3_OR_NEWER - var gap = 2; - var namegap = 3; -#else - var gap = 0; - var namegap = 0; -#endif - if (fieldCount <= 1) - { - while (2 > data.arraySize) - { - var value = data.arraySize == 0 ? index : 0; - data.arraySize++; - data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value; - } - SerializedProperty element = data.GetArrayElementAtIndex(1); - var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap; - drawRect.x = startX; - drawRect.xMax = maxX; - EditorGUI.PropertyField(drawRect, element, GUIContent.none); - } - else - { - var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap; - var dataWidTotal = (currentWidth - (startX + 20.5f + 1)); - var dataWid = dataWidTotal / fieldCount; - var xWid = dataWid - 0; - for (int i = 0; i < dimension; i++) - { - var dataCount = i < 1 ? 2 : i + 1; - while (dataCount > data.arraySize) - { - var value = data.arraySize == 0 ? index : 0; - data.arraySize++; - data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value; - } - drawRect.x = startX + i * xWid; - drawRect.width = dataWid + 25; - SerializedProperty element = data.GetArrayElementAtIndex(dimension <= 1 ? 1 : i); - EditorGUI.PropertyField(drawRect, element, GUIContent.none); - } - if (showName) - { - drawRect.x = startX + (fieldCount - 1) * xWid; - drawRect.width = dataWid + 40 + dimension * namegap - 2.5f; - EditorGUI.PropertyField(drawRect, sereName, GUIContent.none); - } - EditorGUIUtility.fieldWidth = lastFieldWid; - EditorGUIUtility.labelWidth = lastLabelWid; - } - }); + var callbackContext = new HeaderCallbackContext(){ + serieData = serieData, + fieldCount = fieldCount, + showName = showName, + index = index, + dimension = dimension + }; + m_DataElementFoldout[index] = ChartEditorHelper.DrawSerieDataHeader("SerieData " + dataIndex, flag, false, null, callbackContext, DrawSerieDataHeader); if (m_DataElementFoldout[index]) { if (!(serie is ISimplifiedSerie)) diff --git a/Editor/Utilities/ChartEditorHelper.cs b/Editor/Utilities/ChartEditorHelper.cs index b1fcc618..4737241f 100644 --- a/Editor/Utilities/ChartEditorHelper.cs +++ b/Editor/Utilities/ChartEditorHelper.cs @@ -6,6 +6,15 @@ using XCharts.Runtime; namespace XCharts.Editor { + public class HeaderCallbackContext + { + public int fieldCount = 0; + public SerializedProperty serieData; + public bool showName; + public int index; + public int dimension; + } + public class HeaderMenuInfo { public string name; @@ -586,6 +595,31 @@ namespace XCharts.Editor return state; } + public static bool DrawSerieDataHeader(string title, bool state, bool drawBackground, SerializedProperty activeField, + HeaderCallbackContext context, Action drawCallback, params HeaderMenuInfo[] menus) + { + var rect = GUILayoutUtility.GetRect(1f, HEADER_HEIGHT); + var labelRect = DrawHeaderInternal(rect, title, ref state, drawBackground, activeField); + DrawMenu(rect, menus); + if (drawCallback != null) + { + drawCallback(rect, context); + } + var e = Event.current; + if (e.type == EventType.MouseDown) + { + if (labelRect.Contains(e.mousePosition)) + { + if (e.button == 0) + { + state = !state; + e.Use(); + } + } + } + return state; + } + internal static bool DrawHeader(string title, bool state, bool drawBackground, SerializedProperty activeField, Action drawCallback, List menus) { From 1e6140a138671f88d7d5d65da0293ac955c4fcd5 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 20 May 2024 08:33:09 +0800 Subject: [PATCH 17/37] 3.11.0-preview1 --- Runtime/Internal/XChartsMgr.cs | 4 ++-- package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Runtime/Internal/XChartsMgr.cs b/Runtime/Internal/XChartsMgr.cs index b2f7677b..640dcafb 100644 --- a/Runtime/Internal/XChartsMgr.cs +++ b/Runtime/Internal/XChartsMgr.cs @@ -21,8 +21,8 @@ namespace XCharts.Runtime [ExecuteInEditMode] public static class XChartsMgr { - public static readonly string version = "3.10.2"; - public static readonly int versionDate = 20240311; + public static readonly string version = "3.11.0-preview1"; + public static readonly int versionDate = 20240520; public static string fullVersion { get { return version + "-" + versionDate; } } internal static List chartList = new List(); diff --git a/package.json b/package.json index 6425d8bc..cf335ea3 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "author": "monitor1394", "license": "MIT", "version": "3.11.0-preview1", - "date": "20240223", - "checkdate": "20240223", + "date": "20240520", + "checkdate": "20240520", "unity": "2018.3", "description": "A charting and data visualization library for Unity. Support line chart, bar chart, pie chart, radar chart, scatter chart, heatmap chart, ring chart, candlestick chart, polar chart and parallel coordinates.", "keywords": [ From 042f9d3c01d8fecf06288c0c9eafebbce057756e Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 29 May 2024 08:33:00 +0800 Subject: [PATCH 18/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`3D`=E5=9D=90=E6=A0=87?= =?UTF-8?q?=E7=B3=BB=E5=AF=B9=E7=B1=BB=E7=9B=AE=E8=BD=B4=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 4 +++- Runtime/Component/Axis/AxisHandler.cs | 5 ++--- Runtime/Component/Axis/AxisHelper.cs | 2 +- Runtime/Internal/BaseChart.Custom.cs | 20 ++++++++++++++------ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index ba966519..67df8f8c 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,10 +73,12 @@ slug: /changelog ## master +* (2024.05.29) 增加`3D`坐标系对类目轴的支持 +* (2024.05.19) 优化`Editor`下的编辑性能 * (2024.05.09) 增加`JsonUtil`工具类 * (2024.04.23) 修复`ConvertXYAxis()`多次调用后图表异常的问题 * (2024.04.22) 修复`DataZoom`控制多个轴时的`GridCoord`获取可能不正确的问题 (#317) -* (2024.04.22) 增加`GridCoord3D`3D坐标系 +* (2024.04.22) 增加`3D`坐标系 * (2024.04.15) 优化`DateTimeUtil`时间戳转`DateTime`接口时区的问题 * (2024.04.15) 优化`GridCoord`在开启`GridLayout`时也显示`Left` `Right` `Top` `Bottom`参数 (#316) * (2024.04.14) 修复`Tooltip`的`Cross`在开启`DataZoom`的情况下`label`位置不正确的问题 (#315) diff --git a/Runtime/Component/Axis/AxisHandler.cs b/Runtime/Component/Axis/AxisHandler.cs index 1c476ed1..a7a12556 100644 --- a/Runtime/Component/Axis/AxisHandler.cs +++ b/Runtime/Component/Axis/AxisHandler.cs @@ -147,7 +147,7 @@ namespace XCharts if (axis.IsCategory()) { axis.context.minValue = 0; - axis.context.maxValue = SeriesHelper.GetMaxSerieDataCount(chart.series) - 1; + axis.context.maxValue = axis.data.Count > 0 ? axis.data.Count - 1 : SeriesHelper.GetMaxSerieDataCount(chart.series) - 1; axis.context.minMaxRange = axis.context.maxValue; return; } @@ -373,6 +373,7 @@ namespace XCharts { Axis axis = component; var axisLength = (axis.context.end - axis.context.start).magnitude; + if (axisLength == 0) return; chart.InitAxisRuntimeData(axis); var objName = ChartCached.GetComponentObjectName(axis); @@ -439,8 +440,6 @@ namespace XCharts var pos = GetLabelPosition(totalWidth + gapWidth, i); label.SetPosition(pos); - //CheckValueLabelActive(axis, i, label, pos); - axis.context.labelObjectList.Add(label); totalWidth += labelWidth; diff --git a/Runtime/Component/Axis/AxisHelper.cs b/Runtime/Component/Axis/AxisHelper.cs index 42230ca7..365b98b3 100644 --- a/Runtime/Component/Axis/AxisHelper.cs +++ b/Runtime/Component/Axis/AxisHelper.cs @@ -65,7 +65,7 @@ namespace XCharts.Runtime if (axis.splitNumber <= 0) { var eachWid = coordinateWid / dataCount; - var min = axis is YAxis ? 20 : 80; + var min = ((axis is YAxis) || (axis is ZAxis3D)) ? 20 : 80; if (eachWid > min) return dataCount; var tick = Mathf.CeilToInt(min / eachWid); return tick <= 1 ? dataCount : (int)(dataCount / tick); diff --git a/Runtime/Internal/BaseChart.Custom.cs b/Runtime/Internal/BaseChart.Custom.cs index 1159477d..675cc0fa 100644 --- a/Runtime/Internal/BaseChart.Custom.cs +++ b/Runtime/Internal/BaseChart.Custom.cs @@ -11,16 +11,24 @@ namespace XCharts.Runtime public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double tempMinValue, out double tempMaxValue) { var needAnimationData = !axis.context.needAnimation; - if (IsAllAxisValue()) + if (axis is XAxis3D) { - if (axis is XAxis || axis is XAxis3D) + SeriesHelper.GetXMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData); + } + else if (axis is ZAxis3D) + { + SeriesHelper.GetZMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData); + } + else if (axis is YAxis3D) + { + SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData); + } + else if (IsAllAxisValue()) + { + if (axis is XAxis) { SeriesHelper.GetXMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData); } - else if (axis is ZAxis3D) - { - SeriesHelper.GetZMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData); - } else { SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData); From df66f5c7eef5fcb915531f0274c86909da4aa629 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 29 May 2024 13:14:21 +0800 Subject: [PATCH 19/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`3D`=E5=9D=90=E6=A0=87?= =?UTF-8?q?=E7=B3=BB=E6=98=BE=E7=A4=BA=E8=BE=B9=E6=A1=86=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Coord/Grid3D/GridCoord3DHandler.cs | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/Runtime/Coord/Grid3D/GridCoord3DHandler.cs b/Runtime/Coord/Grid3D/GridCoord3DHandler.cs index 4dcf685b..5168d368 100644 --- a/Runtime/Coord/Grid3D/GridCoord3DHandler.cs +++ b/Runtime/Coord/Grid3D/GridCoord3DHandler.cs @@ -12,7 +12,7 @@ namespace XCharts.Runtime { var grid = component; grid.painter = chart.painter; - grid.refreshComponent = delegate() + grid.refreshComponent = delegate () { grid.UpdateRuntimeData(chart); chart.OnCoordinateChanged(); @@ -49,19 +49,9 @@ namespace XCharts.Runtime } } - public override void DrawBase(VertexHelper vh) - { - if (!SeriesHelper.IsAnyClipSerie(chart.series)) - { - DrawCoord(vh, component); - } - } public override void DrawUpper(VertexHelper vh) { - if (SeriesHelper.IsAnyClipSerie(chart.series)) - { - DrawCoord(vh, component); - } + DrawCoord(vh, component); } private void DrawCoord(VertexHelper vh, GridCoord3D grid) @@ -69,11 +59,20 @@ namespace XCharts.Runtime if (!grid.show) return; if (grid.showBorder) { - var borderWidth = chart.theme.axis.lineWidth * 2; + var borderWidth = chart.theme.axis.lineWidth; var borderColor = chart.theme.axis.lineColor; - UGL.DrawBorder(vh, grid.context.maxRect, borderWidth, borderColor); - // UGL.DrawBorder(vh, grid.context.center, grid.context.width - borderWidth, - // grid.context.height - borderWidth, borderWidth, borderColor); + if (grid.IsLeft()) + { + UGL.DrawLine(vh, grid.context.pointA, grid.context.pointE, borderWidth, borderColor); + UGL.DrawLine(vh, grid.context.pointE, grid.context.pointF, borderWidth, borderColor); + UGL.DrawLine(vh, grid.context.pointE, grid.context.pointH, borderWidth, borderColor); + } + else + { + UGL.DrawLine(vh, grid.context.pointD, grid.context.pointH, borderWidth, borderColor); + UGL.DrawLine(vh, grid.context.pointE, grid.context.pointH, borderWidth, borderColor); + UGL.DrawLine(vh, grid.context.pointG, grid.context.pointH, borderWidth, borderColor); + } } } } From 6a6ab72ed86dd01206ef59831a3ba6e1bd48cf2b Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Wed, 29 May 2024 21:58:31 +0800 Subject: [PATCH 20/37] =?UTF-8?q?=E8=B0=83=E6=95=B4`XCharts`=E5=9C=A8`Hier?= =?UTF-8?q?archy`=E8=A7=86=E5=9B=BE=E4=B8=8B=E7=9A=84=E5=8F=B3=E9=94=AE?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E5=88=B0`UI/XCharts`=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Editor/Windows/XChartsEditor.BarChart.cs | 24 +++++++++---------- Editor/Windows/XChartsEditor.LineChart.cs | 20 ++++++++-------- Editor/Windows/XChartsEditor.PieChart.cs | 12 +++++----- Editor/Windows/XChartsEditor.PolarChart.cs | 8 +++---- Editor/Windows/XChartsEditor.cs | 28 +++++++++++----------- 6 files changed, 47 insertions(+), 46 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 67df8f8c..2fb6337f 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,7 @@ slug: /changelog ## master +* (2024.05.29) 调整`XCharts`在`Hierarchy`视图下的右键菜单到`UI/XCharts`下 * (2024.05.29) 增加`3D`坐标系对类目轴的支持 * (2024.05.19) 优化`Editor`下的编辑性能 * (2024.05.09) 增加`JsonUtil`工具类 diff --git a/Editor/Windows/XChartsEditor.BarChart.cs b/Editor/Windows/XChartsEditor.BarChart.cs index 6f35a93b..727fc011 100644 --- a/Editor/Windows/XChartsEditor.BarChart.cs +++ b/Editor/Windows/XChartsEditor.BarChart.cs @@ -14,14 +14,14 @@ namespace XCharts.Editor public partial class XChartsEditor { [MenuItem("XCharts/BarChart/Baisc Column", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Baisc Column", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Baisc Column", priority = 45)] public static void AddBarChart() { AddChart("BarChart"); } [MenuItem("XCharts/BarChart/Zebra Column", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Zebra Column", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Zebra Column", priority = 45)] public static void AddBarChart_ZebraColumn() { var chart = AddChart("BarChart", "Zebra Column"); @@ -29,7 +29,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/BarChart/Capsule Column", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Capsule Column", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Capsule Column", priority = 45)] public static void AddBarChart_CapsuleColumn() { var chart = AddChart("BarChart", "Capsule Column"); @@ -37,7 +37,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/BarChart/Grouped Column", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Grouped Column", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Grouped Column", priority = 45)] public static void AddBarChart_GroupedColumn() { var chart = AddChart("BarChart", "Grouped Column"); @@ -45,7 +45,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/BarChart/Stacked Column", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Stacked Column", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Stacked Column", priority = 45)] public static void AddBarChart_StackedColumn() { var chart = AddChart("BarChart", "Stacked Column"); @@ -53,7 +53,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/BarChart/Percent Column", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Percent Column", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Percent Column", priority = 45)] public static void AddBarChart_PercentColumn() { var chart = AddChart("BarChart", "Percent Column"); @@ -61,7 +61,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/BarChart/Baisc Bar", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Baisc Bar", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Baisc Bar", priority = 45)] public static void AddBarChart_BasicBar() { var chart = AddChart("BarChart"); @@ -69,7 +69,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/BarChart/Zebra Bar", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Zebra Bar", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Zebra Bar", priority = 45)] public static void AddBarChart_ZebraBar() { var chart = AddChart("BarChart", "Zebra Bar"); @@ -77,7 +77,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/BarChart/Capsule Bar", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Capsule Bar", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Capsule Bar", priority = 45)] public static void AddBarChart_CapsuleBar() { var chart = AddChart("BarChart", "Capsule Bar"); @@ -85,7 +85,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/BarChart/Grouped Bar", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Grouped Bar", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Grouped Bar", priority = 45)] public static void AddBarChart_GroupedBar() { var chart = AddChart("BarChart", "Grouped Bar"); @@ -93,7 +93,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/BarChart/Stacked Bar", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Stacked Bar", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Stacked Bar", priority = 45)] public static void AddBarChart_StackedBar() { var chart = AddChart("BarChart", "Stacked Bar"); @@ -101,7 +101,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/BarChart/Percent Bar", priority = 45)] - [MenuItem("GameObject/XCharts/BarChart/Percent Bar", priority = 45)] + [MenuItem("GameObject/UI/XCharts/BarChart/Percent Bar", priority = 45)] public static void AddBarChart_PercentBar() { var chart = AddChart("BarChart", "Percent Bar"); diff --git a/Editor/Windows/XChartsEditor.LineChart.cs b/Editor/Windows/XChartsEditor.LineChart.cs index d41cc4f7..4405df2f 100644 --- a/Editor/Windows/XChartsEditor.LineChart.cs +++ b/Editor/Windows/XChartsEditor.LineChart.cs @@ -14,14 +14,14 @@ namespace XCharts.Editor public partial class XChartsEditor { [MenuItem("XCharts/LineChart/Basic Line", priority = 44)] - [MenuItem("GameObject/XCharts/LineChart/Basic Line", priority = 44)] + [MenuItem("GameObject/UI/XCharts/LineChart/Basic Line", priority = 44)] public static void AddLineChart() { AddChart("LineChart"); } [MenuItem("XCharts/LineChart/Area Line", priority = 44)] - [MenuItem("GameObject/XCharts/LineChart/Area Line", priority = 44)] + [MenuItem("GameObject/UI/XCharts/LineChart/Area Line", priority = 44)] public static void AddLineChart_Area() { var chart = AddChart("LineChart_Area", "Area Line"); @@ -29,7 +29,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/LineChart/Smooth Line", priority = 44)] - [MenuItem("GameObject/XCharts/LineChart/Smooth Line", priority = 44)] + [MenuItem("GameObject/UI/XCharts/LineChart/Smooth Line", priority = 44)] public static void AddLineChart_Smooth() { var chart = AddChart("LineChart_Smooth", "Smooth Line"); @@ -37,7 +37,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/LineChart/Smooth Area", priority = 44)] - [MenuItem("GameObject/XCharts/LineChart/Smooth Area Line", priority = 44)] + [MenuItem("GameObject/UI/XCharts/LineChart/Smooth Area Line", priority = 44)] public static void AddLineChart_SmoothArea() { var chart = AddChart("LineChart_SmoothArea", "Smooth Area Line"); @@ -45,7 +45,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/LineChart/Stack Line", priority = 44)] - [MenuItem("GameObject/XCharts/LineChart/Stack Line", priority = 44)] + [MenuItem("GameObject/UI/XCharts/LineChart/Stack Line", priority = 44)] public static void AddLineChart_Stack() { var chart = AddChart("LineChart_Stack", "Stack Line"); @@ -53,7 +53,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/LineChart/Stack Area Line", priority = 44)] - [MenuItem("GameObject/XCharts/LineChart/Stack Area Line", priority = 44)] + [MenuItem("GameObject/UI/XCharts/LineChart/Stack Area Line", priority = 44)] public static void AddLineChart_StackArea() { var chart = AddChart("LineChart_StackArea", "Stack Area Line"); @@ -61,7 +61,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/LineChart/Step Line", priority = 44)] - [MenuItem("GameObject/XCharts/LineChart/Step Line", priority = 44)] + [MenuItem("GameObject/UI/XCharts/LineChart/Step Line", priority = 44)] public static void AddLineChart_Step() { var chart = AddChart("LineChart_Step", "Step Line"); @@ -69,7 +69,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/LineChart/Dashed Line", priority = 44)] - [MenuItem("GameObject/XCharts/LineChart/Dashed Line", priority = 44)] + [MenuItem("GameObject/UI/XCharts/LineChart/Dashed Line", priority = 44)] public static void AddLineChart_Dash() { var chart = AddChart("LineChart_Dashed", "Dashed Line"); @@ -77,7 +77,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/LineChart/Time Line", priority = 44)] - [MenuItem("GameObject/XCharts/LineChart/Time Line", priority = 44)] + [MenuItem("GameObject/UI/XCharts/LineChart/Time Line", priority = 44)] public static void AddLineChart_Time() { var chart = AddChart("LineChart_Time", "Time Line"); @@ -85,7 +85,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/LineChart/Log Line", priority = 44)] - [MenuItem("GameObject/XCharts/LineChart/Log Line", priority = 44)] + [MenuItem("GameObject/UI/XCharts/LineChart/Log Line", priority = 44)] public static void AddLineChart_Log() { var chart = AddChart("LineChart_Log", "Log Line"); diff --git a/Editor/Windows/XChartsEditor.PieChart.cs b/Editor/Windows/XChartsEditor.PieChart.cs index a6b7f9c3..b4c24034 100644 --- a/Editor/Windows/XChartsEditor.PieChart.cs +++ b/Editor/Windows/XChartsEditor.PieChart.cs @@ -14,14 +14,14 @@ namespace XCharts.Editor public partial class XChartsEditor { [MenuItem("XCharts/PieChart/Pie", priority = 46)] - [MenuItem("GameObject/XCharts/PieChart/Pie", priority = 46)] + [MenuItem("GameObject/UI/XCharts/PieChart/Pie", priority = 46)] public static void AddPieChart() { AddChart("PieChart"); } [MenuItem("XCharts/PieChart/Pie With Label", priority = 46)] - [MenuItem("GameObject/XCharts/PieChart/Pie With Label", priority = 46)] + [MenuItem("GameObject/UI/XCharts/PieChart/Pie With Label", priority = 46)] public static void AddPieChart_WithLabel() { var chart = AddChart("PieChart"); @@ -29,7 +29,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/PieChart/Donut", priority = 46)] - [MenuItem("GameObject/XCharts/PieChart/Donut", priority = 46)] + [MenuItem("GameObject/UI/XCharts/PieChart/Donut", priority = 46)] public static void AddPieChart_Donut() { var chart = AddChart("PieChart"); @@ -37,7 +37,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/PieChart/Donut With Label", priority = 46)] - [MenuItem("GameObject/XCharts/PieChart/Donut With Label", priority = 46)] + [MenuItem("GameObject/UI/XCharts/PieChart/Donut With Label", priority = 46)] public static void AddPieChart_DonutWithLabel() { var chart = AddChart("PieChart"); @@ -45,7 +45,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/PieChart/Radius Rose", priority = 46)] - [MenuItem("GameObject/XCharts/PieChart/Radius Rose", priority = 46)] + [MenuItem("GameObject/UI/XCharts/PieChart/Radius Rose", priority = 46)] public static void AddPieChart_RadiusRose() { var chart = AddChart("PieChart"); @@ -53,7 +53,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/PieChart/Area Rose", priority = 46)] - [MenuItem("GameObject/XCharts/PieChart/Area Rose", priority = 46)] + [MenuItem("GameObject/UI/XCharts/PieChart/Area Rose", priority = 46)] public static void AddPieChart_AreaRose() { var chart = AddChart("PieChart"); diff --git a/Editor/Windows/XChartsEditor.PolarChart.cs b/Editor/Windows/XChartsEditor.PolarChart.cs index 3d4487b1..70cb2284 100644 --- a/Editor/Windows/XChartsEditor.PolarChart.cs +++ b/Editor/Windows/XChartsEditor.PolarChart.cs @@ -14,14 +14,14 @@ namespace XCharts.Editor public partial class XChartsEditor { [MenuItem("XCharts/PolarChart/Line", priority = 54)] - [MenuItem("GameObject/XCharts/PolarChart/Line", priority = 54)] + [MenuItem("GameObject/UI/XCharts/PolarChart/Line", priority = 54)] public static void PolarChart() { AddChart("PolarChart"); } [MenuItem("XCharts/PolarChart/Radial Bar", priority = 54)] - [MenuItem("GameObject/XCharts/PolarChart/Radial Bar", priority = 54)] + [MenuItem("GameObject/UI/XCharts/PolarChart/Radial Bar", priority = 54)] public static void PolarChart_RadialBar() { var chart = AddChart("PolarChart"); @@ -29,7 +29,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/PolarChart/Tangential Bar", priority = 54)] - [MenuItem("GameObject/XCharts/PolarChart/Tangential Bar", priority = 54)] + [MenuItem("GameObject/UI/XCharts/PolarChart/Tangential Bar", priority = 54)] public static void PolarChart_TangentialBar() { var chart = AddChart("PolarChart"); @@ -37,7 +37,7 @@ namespace XCharts.Editor } [MenuItem("XCharts/PolarChart/Heatmap", priority = 54)] - [MenuItem("GameObject/XCharts/PolarChart/Heatmap", priority = 54)] + [MenuItem("GameObject/UI/XCharts/PolarChart/Heatmap", priority = 54)] public static void PolarChart_Heatmap() { var chart = AddChart("PolarChart"); diff --git a/Editor/Windows/XChartsEditor.cs b/Editor/Windows/XChartsEditor.cs index 0f1f4821..004baa43 100644 --- a/Editor/Windows/XChartsEditor.cs +++ b/Editor/Windows/XChartsEditor.cs @@ -96,21 +96,21 @@ namespace XCharts.Editor } [MenuItem("XCharts/EmptyChart", priority = 43)] - [MenuItem("GameObject/XCharts/EmptyChart", priority = 43)] + [MenuItem("GameObject/UI/XCharts/EmptyChart", priority = 43)] public static void AddBaseChart() { AddChart("EmptyChart"); } [MenuItem("XCharts/RadarChart/Polygon Radar", priority = 47)] - [MenuItem("GameObject/XCharts/RadarChart/Polygon Radar", priority = 47)] + [MenuItem("GameObject/UI/XCharts/RadarChart/Polygon Radar", priority = 47)] public static void AddRadarChart() { AddChart("RadarChart"); } [MenuItem("XCharts/RadarChart/Cirle Radar", priority = 47)] - [MenuItem("GameObject/XCharts/RadarChart/Cirle Radar", priority = 47)] + [MenuItem("GameObject/UI/XCharts/RadarChart/Cirle Radar", priority = 47)] public static void AddRadarChart_CirleRadar() { var chart = AddChart("RadarChart"); @@ -118,14 +118,14 @@ namespace XCharts.Editor } [MenuItem("XCharts/ScatterChart/Scatter", priority = 48)] - [MenuItem("GameObject/XCharts/ScatterChart/Scatter", priority = 48)] + [MenuItem("GameObject/UI/XCharts/ScatterChart/Scatter", priority = 48)] public static void AddScatterChart() { AddChart("ScatterChart"); } [MenuItem("XCharts/ScatterChart/Bubble", priority = 48)] - [MenuItem("GameObject/XCharts/ScatterChart/Bubble", priority = 48)] + [MenuItem("GameObject/UI/XCharts/ScatterChart/Bubble", priority = 48)] public static void AddScatterChart_Bubble() { var chart = AddChart("ScatterChart"); @@ -133,14 +133,14 @@ namespace XCharts.Editor } [MenuItem("XCharts/HeatmapChart/Heatmap", priority = 49)] - [MenuItem("GameObject/XCharts/HeatmapChart/Heatmap", priority = 49)] + [MenuItem("GameObject/UI/XCharts/HeatmapChart/Heatmap", priority = 49)] public static void AddHeatmapChart() { AddChart("HeatmapChart"); } [MenuItem("XCharts/HeatmapChart/Count Heatmap", priority = 49)] - [MenuItem("GameObject/XCharts/HeatmapChart/Count Heatmap", priority = 49)] + [MenuItem("GameObject/UI/XCharts/HeatmapChart/Count Heatmap", priority = 49)] public static void AddHeatmapChart_Count() { var chart = AddChart("HeatmapChart"); @@ -148,14 +148,14 @@ namespace XCharts.Editor } [MenuItem("XCharts/RingChart/Ring", priority = 51)] - [MenuItem("GameObject/XCharts/RingChart/Ring", priority = 51)] + [MenuItem("GameObject/UI/XCharts/RingChart/Ring", priority = 51)] public static void AddRingChart() { AddChart("RingChart"); } [MenuItem("XCharts/RingChart/Multiple Ring", priority = 51)] - [MenuItem("GameObject/XCharts/RingChart/Multiple Ring", priority = 51)] + [MenuItem("GameObject/UI/XCharts/RingChart/Multiple Ring", priority = 51)] public static void AddRingChart_MultiRing() { var chart = AddChart("RingChart"); @@ -163,35 +163,35 @@ namespace XCharts.Editor } [MenuItem("XCharts/CandlestickChart/Candlestick", priority = 54)] - [MenuItem("GameObject/XCharts/CandlestickChart/Candlestick", priority = 54)] + [MenuItem("GameObject/UI/XCharts/CandlestickChart/Candlestick", priority = 54)] public static void CandlestickChart() { AddChart("CandlestickChart"); } [MenuItem("XCharts/ParallelChart/Parallel", priority = 55)] - [MenuItem("GameObject/XCharts/ParallelChart/Parallel", priority = 55)] + [MenuItem("GameObject/UI/XCharts/ParallelChart/Parallel", priority = 55)] public static void ParallelChart() { AddChart("ParallelChart"); } [MenuItem("XCharts/SimplifiedChart/Line", priority = 56)] - [MenuItem("GameObject/XCharts/SimplifiedChart/Line", priority = 56)] + [MenuItem("GameObject/UI/XCharts/SimplifiedChart/Line", priority = 56)] public static void SimplifiedLineChart() { AddChart("SimplifiedLineChart"); } [MenuItem("XCharts/SimplifiedChart/Bar", priority = 57)] - [MenuItem("GameObject/XCharts/SimplifiedChart/Bar", priority = 57)] + [MenuItem("GameObject/UI/XCharts/SimplifiedChart/Bar", priority = 57)] public static void SimplifiedBarChart() { AddChart("SimplifiedBarChart"); } [MenuItem("XCharts/SimplifiedChart/Candlestick", priority = 58)] - [MenuItem("GameObject/XCharts/SimplifiedChart/Candlestick", priority = 58)] + [MenuItem("GameObject/UI/XCharts/SimplifiedChart/Candlestick", priority = 58)] public static void SimplifiedCandlestickChart() { AddChart("SimplifiedCandlestickChart"); From eb948f03d5ee059383acd546e4110c3ae6d5c62f Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 3 Jun 2024 08:12:32 +0800 Subject: [PATCH 21/37] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=85=B3=E7=B3=BB?= =?UTF-8?q?=E5=9B=BE=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Internal/Data/GraphData.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Runtime/Internal/Data/GraphData.cs b/Runtime/Internal/Data/GraphData.cs index 2fbea247..b5fe2e9f 100644 --- a/Runtime/Internal/Data/GraphData.cs +++ b/Runtime/Internal/Data/GraphData.cs @@ -367,6 +367,15 @@ namespace XCharts.Runtime } } } + + public bool IsAllNodeInZeroPosition() + { + foreach (var node in nodes) + { + if (node.position != Vector3.zero) return false; + } + return true; + } } /// From 74cf4fe4ceca7308fb09bfce9b12843c2edbe425 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 3 Jun 2024 08:13:17 +0800 Subject: [PATCH 22/37] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9D=90=E6=A0=87?= =?UTF-8?q?=E8=BD=B4Tick=E6=9C=80=E5=B0=8F=E9=97=B4=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Component/Axis/AxisHelper.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Runtime/Component/Axis/AxisHelper.cs b/Runtime/Component/Axis/AxisHelper.cs index 365b98b3..b020e981 100644 --- a/Runtime/Component/Axis/AxisHelper.cs +++ b/Runtime/Component/Axis/AxisHelper.cs @@ -65,7 +65,8 @@ namespace XCharts.Runtime if (axis.splitNumber <= 0) { var eachWid = coordinateWid / dataCount; - var min = ((axis is YAxis) || (axis is ZAxis3D)) ? 20 : 80; + //var min = ((axis is YAxis) || (axis is ZAxis3D)) ? 20 : 80; + var min = 20; if (eachWid > min) return dataCount; var tick = Mathf.CeilToInt(min / eachWid); return tick <= 1 ? dataCount : (int)(dataCount / tick); From 96cb7ffc7409cfeb43cea29194074d1f966f9978 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 4 Jun 2024 08:40:43 +0800 Subject: [PATCH 23/37] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Serie`=E7=9A=84`state`?= =?UTF-8?q?=E5=9C=A8=E4=BB=A3=E7=A0=81=E5=8A=A8=E6=80=81=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E5=88=B7=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/en/api.md | 1 + Documentation~/zh/api.md | 1 + Documentation~/zh/changelog.md | 1 + Runtime/Serie/SerieHandler.cs | 12 ++++++++++++ 4 files changed, 15 insertions(+) diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index d2d5d46f..1ab1902e 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -1467,6 +1467,7 @@ the data struct of graph. |GetNodesTotalValue()||public static double GetNodesTotalValue(List<GraphNode> nodes)| |GetRootNodes()||public List<GraphNode> GetRootNodes()| |GraphData()||public GraphData(bool directed)| +|IsAllNodeInZeroPosition()||public bool IsAllNodeInZeroPosition()| |Refresh()||public void Refresh()| ## GraphEdge diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index 378015c0..2036f211 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -1467,6 +1467,7 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息 |GetNodesTotalValue()||public static double GetNodesTotalValue(List<GraphNode> nodes)| |GetRootNodes()||public List<GraphNode> GetRootNodes()| |GraphData()||public GraphData(bool directed)| +|IsAllNodeInZeroPosition()||public bool IsAllNodeInZeroPosition()| |Refresh()||public void Refresh()| ## GraphEdge diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 2fb6337f..9d7e5555 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,7 @@ slug: /changelog ## master +* (2024.06.04) 修复`Serie`的`state`在代码动态设置时不刷新的问题 * (2024.05.29) 调整`XCharts`在`Hierarchy`视图下的右键菜单到`UI/XCharts`下 * (2024.05.29) 增加`3D`坐标系对类目轴的支持 * (2024.05.19) 优化`Editor`下的编辑性能 diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs index fa08c07a..b750ef6e 100644 --- a/Runtime/Serie/SerieHandler.cs +++ b/Runtime/Serie/SerieHandler.cs @@ -150,6 +150,18 @@ namespace XCharts.Runtime } if (serie.interactDirty) { + if (serie.animation.enable && serie.animation.interaction.enable) + { + Color32 color1, toColor1; + bool needInteract = false; + foreach (var serieData in serie.data) + { + var state = SerieHelper.GetSerieState(serie, serieData, true); + SerieHelper.GetItemColor(out color1, out toColor1, serie, serieData, chart.theme, state); + serieData.interact.SetColor(ref needInteract, color1, toColor1); + } + } + chart.RefreshChart(); serie.interactDirty = false; m_ForceUpdateSerieContext = true; } From 922901380e7204810f80b27a99938f07d6e2e584 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 6 Jun 2024 13:07:34 +0800 Subject: [PATCH 24/37] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Serie`=E5=9C=A8`Clone`?= =?UTF-8?q?=E6=97=B6=E5=8A=A8=E7=94=BB=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#320)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Serie/Serie.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 9d7e5555..e702171b 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,7 @@ slug: /changelog ## master +* (2024.06.06) 修复`Serie`在`Clone`时动画异常问题 (#320) * (2024.06.04) 修复`Serie`的`state`在代码动态设置时不刷新的问题 * (2024.05.29) 调整`XCharts`在`Hierarchy`视图下的右键菜单到`UI/XCharts`下 * (2024.05.29) 增加`3D`坐标系对类目轴的支持 diff --git a/Runtime/Serie/Serie.cs b/Runtime/Serie/Serie.cs index b3e6e706..c41ae4df 100644 --- a/Runtime/Serie/Serie.cs +++ b/Runtime/Serie/Serie.cs @@ -2083,6 +2083,7 @@ namespace XCharts.Runtime { var newSerie = Activator.CreateInstance(GetType()) as Serie; SerieHelper.CopySerie(this, newSerie); + newSerie.animation = new AnimationStyle(); return newSerie; } } From 86174758084951c604433514d73a1e5c3b342754 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sat, 8 Jun 2024 13:24:24 +0800 Subject: [PATCH 25/37] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=80=E4=B8=AAChart?= =?UTF-8?q?=E9=87=8C=E6=9C=89=E5=A4=9A=E4=B8=AASerie=E6=97=B6=E7=9A=84Tool?= =?UTF-8?q?tip=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Component/Tooltip/TooltipHandler.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Runtime/Component/Tooltip/TooltipHandler.cs b/Runtime/Component/Tooltip/TooltipHandler.cs index e0f7b4b4..21edcab8 100644 --- a/Runtime/Component/Tooltip/TooltipHandler.cs +++ b/Runtime/Component/Tooltip/TooltipHandler.cs @@ -169,6 +169,11 @@ namespace XCharts.Runtime } } } + if (!anyTrigger && m_ContainerSeries == null) + { + m_ContainerSeries = ListPool.Get(); + UpdatePointerContainerAndSeriesAndTooltip(tooltip, ref m_ContainerSeries); + } if (m_ContainerSeries != null) { if (!SetSerieTooltip(tooltip, m_ContainerSeries)) From a12c98b1a5ae3de1810cf9b5ca0da8586809bf57 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 9 Jun 2024 22:13:26 +0800 Subject: [PATCH 26/37] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Tooltip`=E7=9A=84`Cros?= =?UTF-8?q?s`=E5=9C=A8=E5=BC=80=E5=90=AF`DataZoom`=E6=97=B6=E6=8C=87?= =?UTF-8?q?=E7=A4=BA=E4=BD=8D=E7=BD=AE=E4=B8=8D=E5=87=86=E7=A1=AE=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Component/Axis/Axis.cs | 38 +++++++++++++++++++++ Runtime/Component/Axis/AxisHandler.cs | 4 +-- Runtime/Component/Tooltip/TooltipHandler.cs | 2 +- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index e702171b..0b83b196 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,7 @@ slug: /changelog ## master +* (2024.06.09) 修复`Tooltip`的`Cross`在`Axis`是类目轴并且开启`DataZoom`的情况下指示位置不准确的问题 * (2024.06.06) 修复`Serie`在`Clone`时动画异常问题 (#320) * (2024.06.04) 修复`Serie`的`state`在代码动态设置时不刷新的问题 * (2024.05.29) 调整`XCharts`在`Hierarchy`视图下的右键菜单到`UI/XCharts`下 diff --git a/Runtime/Component/Axis/Axis.cs b/Runtime/Component/Axis/Axis.cs index f9e6c4a9..3d22b302 100644 --- a/Runtime/Component/Axis/Axis.cs +++ b/Runtime/Component/Axis/Axis.cs @@ -935,5 +935,43 @@ namespace XCharts.Runtime (float)(Math.Abs(context.minValue) * (axisLength / (Math.Abs(context.minValue) + Math.Abs(context.maxValue)))) ); } + + public Vector3 GetCategoryPosition(int categoryIndex, int dataCount = 0) + { + if (dataCount <= 0) + { + dataCount = data.Count; + } + if (IsCategory() && dataCount > 0) + { + Vector3 pos; + if (boundaryGap) + { + var each = context.length / dataCount; + pos = context.start + context.dire * (each * (categoryIndex + 0.5f)); + } + else + { + var each = context.length / (dataCount - 1); + pos = context.start + context.dire * (each * categoryIndex); + } + if (axisLabel.distance != 0) + { + if (this is YAxis) + { + pos.x = GetLabelObjectPosition(0).x; + } + else + { + pos.y = GetLabelObjectPosition(0).y; + } + } + return pos; + } + else + { + return Vector3.zero; + } + } } } \ No newline at end of file diff --git a/Runtime/Component/Axis/AxisHandler.cs b/Runtime/Component/Axis/AxisHandler.cs index a7a12556..ef90913b 100644 --- a/Runtime/Component/Axis/AxisHandler.cs +++ b/Runtime/Component/Axis/AxisHandler.cs @@ -58,7 +58,7 @@ namespace XCharts (!axis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2))) { axis.context.pointerValue = j; - axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j); + axis.context.pointerLabelPosition = axis.GetCategoryPosition(j, dataCount); if (j != lastPointerValue) { if (chart.onAxisPointerValueChanged != null) @@ -78,7 +78,7 @@ namespace XCharts (!axis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2))) { axis.context.pointerValue = j; - axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j); + axis.context.pointerLabelPosition = axis.GetCategoryPosition(j, dataCount); if (j != lastPointerValue) { if (chart.onAxisPointerValueChanged != null) diff --git a/Runtime/Component/Tooltip/TooltipHandler.cs b/Runtime/Component/Tooltip/TooltipHandler.cs index 21edcab8..e9bb466b 100644 --- a/Runtime/Component/Tooltip/TooltipHandler.cs +++ b/Runtime/Component/Tooltip/TooltipHandler.cs @@ -701,7 +701,7 @@ namespace XCharts.Runtime case Tooltip.Type.Line: float pX = grid.context.x; pX += xAxis.IsCategory() ? - (float)(xAxis.context.axisTooltipValue * splitWidth + (xAxis.boundaryGap ? splitWidth / 2 : 0)) : + (float)(xAxis.context.pointerValue * splitWidth + (xAxis.boundaryGap ? splitWidth / 2 : 0)) : xAxis.GetDistance(xAxis.context.axisTooltipValue, grid.context.width); if (pX < grid.context.x) break; From caee79630b31b26699e34c5e823f6b3a3046f9de Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 9 Jun 2024 22:59:38 +0800 Subject: [PATCH 27/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`Axis`=E7=9A=84`m=5FMin?= =?UTF-8?q?CategorySpacing`=E8=AE=BE=E7=BD=AE=E7=B1=BB=E7=9B=AE=E8=BD=B4?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=9A=84=E6=9C=80=E5=B0=8F=E7=B1=BB=E7=9B=AE?= =?UTF-8?q?=E9=97=B4=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/en/api.md | 1 + Documentation~/en/configuration.md | 1 + Documentation~/zh/api.md | 1 + Documentation~/zh/changelog.md | 1 + Documentation~/zh/configuration.md | 1 + Editor/MainComponents/AxisEditor.cs | 1 + Runtime/Component/Axis/Axis.cs | 10 ++++++++++ Runtime/Component/Axis/AxisHelper.cs | 6 ++++-- 8 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index 1ab1902e..f7964d7a 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -443,6 +443,7 @@ The axis in rectangular coordinate. |Clone()||public Axis Clone()| |Copy()||public void Copy(Axis axis)| |GetAddedDataCount()||public int GetAddedDataCount()
get the history data count. | +|GetCategoryPosition()||public Vector3 GetCategoryPosition(int categoryIndex, int dataCount = 0)| |GetData()||public string GetData(int index)
获得指定索引的类目数据 | |GetData()||public string GetData(int index, DataZoom dataZoom)
获得在dataZoom范围内指定索引的类目数据 | |GetDistance()||public float GetDistance(double value, float axisLength = 0)
获得值在坐标轴上的距离 | diff --git a/Documentation~/en/configuration.md b/Documentation~/en/configuration.md index f225256a..e4adb2bf 100644 --- a/Documentation~/en/configuration.md +++ b/Documentation~/en/configuration.md @@ -422,6 +422,7 @@ The axis in rectangular coordinate. |inverse|false||Whether the axis are reversed or not. Invalid in `Category` axis. |clockwise|true||Whether the positive position of axis is in clockwise. True for clockwise by default. |insertDataToHead|||Whether to add new data at the head or at the end of the list. +|minCategorySpacing|0|v3.11.0|The minimum spacing between categories. |icons|||类目数据对应的图标。 |data|||Category data, available in type: 'Category' axis. |axisLine|||axis Line. [AxisLine](#axisline)| diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index 2036f211..111f3836 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -443,6 +443,7 @@ slug: /api |Clone()||public Axis Clone()| |Copy()||public void Copy(Axis axis)| |GetAddedDataCount()||public int GetAddedDataCount()
获得添加过的历史数据总数 | +|GetCategoryPosition()||public Vector3 GetCategoryPosition(int categoryIndex, int dataCount = 0)| |GetData()||public string GetData(int index)
获得指定索引的类目数据 | |GetData()||public string GetData(int index, DataZoom dataZoom)
获得在dataZoom范围内指定索引的类目数据 | |GetDistance()||public float GetDistance(double value, float axisLength = 0)
获得值在坐标轴上的距离 | diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 0b83b196..baaf95b6 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,7 @@ slug: /changelog ## master +* (2024.06.09) 增加`Axis`的`m_MinCategorySpacing`设置类目轴默认的最小类目间距 * (2024.06.09) 修复`Tooltip`的`Cross`在`Axis`是类目轴并且开启`DataZoom`的情况下指示位置不准确的问题 * (2024.06.06) 修复`Serie`在`Clone`时动画异常问题 (#320) * (2024.06.04) 修复`Serie`的`state`在代码动态设置时不刷新的问题 diff --git a/Documentation~/zh/configuration.md b/Documentation~/zh/configuration.md index 633dc4cf..25445c3f 100644 --- a/Documentation~/zh/configuration.md +++ b/Documentation~/zh/configuration.md @@ -415,6 +415,7 @@ import APITable from '@site/src/components/APITable'; |inverse|false||是否反向坐标轴。在类目轴中无效。 |clockwise|true||刻度增长是否按顺时针,默认顺时针。 |insertDataToHead|||添加新数据时是在列表的头部还是尾部加入。 +|minCategorySpacing|0|v3.11.0|类目之间的最小间距。 |icons|||类目数据对应的图标。 |data|||类目数据,在类目轴(type: 'category')中有效。 |axisLine|||坐标轴轴线。 [AxisLine](#axisline)| diff --git a/Editor/MainComponents/AxisEditor.cs b/Editor/MainComponents/AxisEditor.cs index fdc840b6..78199d65 100644 --- a/Editor/MainComponents/AxisEditor.cs +++ b/Editor/MainComponents/AxisEditor.cs @@ -64,6 +64,7 @@ namespace XCharts.Editor if (type == Axis.AxisType.Category) { PropertyField("m_MaxCache"); + PropertyField("m_MinCategorySpacing"); PropertyField("m_BoundaryGap"); } else diff --git a/Runtime/Component/Axis/Axis.cs b/Runtime/Component/Axis/Axis.cs index 3d22b302..83fc972a 100644 --- a/Runtime/Component/Axis/Axis.cs +++ b/Runtime/Component/Axis/Axis.cs @@ -99,6 +99,7 @@ namespace XCharts.Runtime [SerializeField] protected bool m_Inverse = false; [SerializeField] private bool m_Clockwise = true; [SerializeField] private bool m_InsertDataToHead; + [SerializeField][Since("v3.11.0")] private float m_MinCategorySpacing = 0; [SerializeField] protected List m_Icons = new List(); [SerializeField] protected List m_Data = new List(); [SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine; @@ -406,6 +407,15 @@ namespace XCharts.Runtime get { return m_InsertDataToHead; } set { if (PropertyUtil.SetStruct(ref m_InsertDataToHead, value)) SetAllDirty(); } } + /// + /// The minimum spacing between categories. + /// ||类目之间的最小间距。 + /// + public float minCategorySpacing + { + get { return m_MinCategorySpacing; } + set { if (PropertyUtil.SetStruct(ref m_MinCategorySpacing, value)) SetAllDirty(); } + } public override bool vertsDirty { diff --git a/Runtime/Component/Axis/AxisHelper.cs b/Runtime/Component/Axis/AxisHelper.cs index b020e981..5f2c12f9 100644 --- a/Runtime/Component/Axis/AxisHelper.cs +++ b/Runtime/Component/Axis/AxisHelper.cs @@ -65,8 +65,10 @@ namespace XCharts.Runtime if (axis.splitNumber <= 0) { var eachWid = coordinateWid / dataCount; - //var min = ((axis is YAxis) || (axis is ZAxis3D)) ? 20 : 80; - var min = 20; + + var min = axis.minCategorySpacing > 0 + ? axis.minCategorySpacing + : (Mathf.Abs(axis.context.dire.y) < 0.01 ? 80 : 20); if (eachWid > min) return dataCount; var tick = Mathf.CeilToInt(min / eachWid); return tick <= 1 ? dataCount : (int)(dataCount / tick); From 3b9af0f8ecb2a74842e5217db4d64320a25c72b4 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Mon, 10 Jun 2024 22:42:20 +0800 Subject: [PATCH 28/37] =?UTF-8?q?=E8=B0=83=E6=95=B4`Tooltip`=E7=9A=84`Cors?= =?UTF-8?q?s`=E9=87=8D=E5=91=BD=E5=90=8D=E4=B8=BA`Cross`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/en/configuration.md | 2 +- Documentation~/zh/changelog.md | 3 ++- Documentation~/zh/configuration.md | 2 +- Examples/Example80_Polar.cs | 2 +- Runtime/Chart/PolarChart.cs | 2 +- Runtime/Component/Tooltip/Tooltip.cs | 2 +- Runtime/Component/Tooltip/TooltipHandler.cs | 16 ++++++++-------- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Documentation~/en/configuration.md b/Documentation~/en/configuration.md index e4adb2bf..12ed0d9e 100644 --- a/Documentation~/en/configuration.md +++ b/Documentation~/en/configuration.md @@ -2339,7 +2339,7 @@ Tooltip component. |field|default|since|comment| |--|--|--|--| |show|true||Whether to show the tooltip component. -|type|||Indicator type.
`Tooltip.Type`:
- `Line`: line indicator.
- `Shadow`: shadow crosshair indicator.
- `None`: no indicator displayed.
- `Corss`: crosshair indicator, which is actually the shortcut of enable two axisPointers of two orthometric axes.
- `Auto`: Auto select indicator according to serie type.
| +|type|||Indicator type.
`Tooltip.Type`:
- `Line`: line indicator.
- `Shadow`: shadow crosshair indicator.
- `None`: no indicator displayed.
- `Cross`: crosshair indicator, which is actually the shortcut of enable two axisPointers of two orthometric axes.
- `Auto`: Auto select indicator according to serie type.
| |trigger|||Type of triggering.
`Tooltip.Trigger`:
- `Item`: Triggered by data item, which is mainly used for charts that don't have a category axis like scatter charts or pie charts.
- `Axis`: Triggered by axes, which is mainly used for charts that have category axes, like bar charts or line charts.
- `None`: Trigger nothing.
- `Auto`: Auto select trigger according to serie type.
| |triggerOn||v3.11.0|Condition of trigger tooltip.
`Tooltip.TriggerOn`:
- `MouseMove`: Trigger when mouse move.
- `Click`: Trigger when mouse click.
| |position||v3.3.0|Type of position.
`Tooltip.Position`:
- `Auto`: Auto. The mobile platform is displayed at the top, and the non-mobile platform follows the mouse position.
- `Custom`: Custom. Fully customize display position (x,y).
- `FixedX`: Just fix the coordinate X. Y follows the mouse position.
- `FixedY`:
| diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index baaf95b6..fba2d36d 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,7 +73,8 @@ slug: /changelog ## master -* (2024.06.09) 增加`Axis`的`m_MinCategorySpacing`设置类目轴默认的最小类目间距 +* (2024.06.09) 调整`Tooltip`的`Corss`重命名为`Cross` +* (2024.06.09) 增加`Axis`的`minCategorySpacing`设置类目轴默认的最小类目间距 * (2024.06.09) 修复`Tooltip`的`Cross`在`Axis`是类目轴并且开启`DataZoom`的情况下指示位置不准确的问题 * (2024.06.06) 修复`Serie`在`Clone`时动画异常问题 (#320) * (2024.06.04) 修复`Serie`的`state`在代码动态设置时不刷新的问题 diff --git a/Documentation~/zh/configuration.md b/Documentation~/zh/configuration.md index 25445c3f..396a2ef9 100644 --- a/Documentation~/zh/configuration.md +++ b/Documentation~/zh/configuration.md @@ -2267,7 +2267,7 @@ Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种 |参数|默认|版本|描述| |--|--|--|--| |show|true||是否显示提示框组件。 -|type|||提示框指示器类型。
`Tooltip.Type`:
- `Line`: 直线指示器
- `Shadow`: 阴影指示器
- `None`: 无指示器
- `Corss`: 十字准星指示器。坐标轴显示Label和交叉线。
- `Auto`: 根据serie的类型自动选择显示指示器。
| +|type|||提示框指示器类型。
`Tooltip.Type`:
- `Line`: 直线指示器
- `Shadow`: 阴影指示器
- `None`: 无指示器
- `Cross`: 十字准星指示器。坐标轴显示Label和交叉线。
- `Auto`: 根据serie的类型自动选择显示指示器。
| |trigger|||触发类型。
`Tooltip.Trigger`:
- `Item`: 数据项图形触发,主要在散点图,饼图等无类目轴的图表中使用。
- `Axis`: 坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用。
- `None`: 什么都不触发。
- `Auto`: 根据serie的类型自动选择触发类型。
| |triggerOn||v3.11.0|触发条件。
`Tooltip.TriggerOn`:
- `MouseMove`: 鼠标移动时触发。
- `Click`: 鼠标点击时触发。
| |position||v3.3.0|显示位置类型。
`Tooltip.Position`:
- `Auto`: 自适应。移动平台靠顶部显示,非移动平台跟随鼠标位置。
- `Custom`: 自定义。完全自定义显示位置(x,y)。
- `FixedX`: 只固定坐标X。Y跟随鼠标位置。
- `FixedY`:
| diff --git a/Examples/Example80_Polar.cs b/Examples/Example80_Polar.cs index cc6a99c0..3b9865ba 100644 --- a/Examples/Example80_Polar.cs +++ b/Examples/Example80_Polar.cs @@ -34,7 +34,7 @@ namespace XCharts.Example void AddData() { chart.RemoveData(); - chart.GetChartComponent().type = Tooltip.Type.Corss; + chart.GetChartComponent().type = Tooltip.Type.Cross; var angleAxis = chart.GetChartComponent(); angleAxis.type = Axis.AxisType.Value; angleAxis.minMaxType = Axis.AxisMinMaxType.Custom; diff --git a/Runtime/Chart/PolarChart.cs b/Runtime/Chart/PolarChart.cs index 500d0b81..0d93196d 100644 --- a/Runtime/Chart/PolarChart.cs +++ b/Runtime/Chart/PolarChart.cs @@ -22,7 +22,7 @@ namespace XCharts.Runtime radiusAxis.axisLabel.show = false; var tooltip = EnsureChartComponent(); - tooltip.type = Tooltip.Type.Corss; + tooltip.type = Tooltip.Type.Cross; tooltip.trigger = Tooltip.Trigger.Axis; RemoveData(); diff --git a/Runtime/Component/Tooltip/Tooltip.cs b/Runtime/Component/Tooltip/Tooltip.cs index 18149b85..7711fd9e 100644 --- a/Runtime/Component/Tooltip/Tooltip.cs +++ b/Runtime/Component/Tooltip/Tooltip.cs @@ -37,7 +37,7 @@ namespace XCharts.Runtime /// crosshair indicator, which is actually the shortcut of enable two axisPointers of two orthometric axes. /// ||十字准星指示器。坐标轴显示Label和交叉线。 ///
- Corss, + Cross, /// /// Auto select indicator according to serie type. /// ||根据serie的类型自动选择显示指示器。 diff --git a/Runtime/Component/Tooltip/TooltipHandler.cs b/Runtime/Component/Tooltip/TooltipHandler.cs index e9bb466b..3c5b0dca 100644 --- a/Runtime/Component/Tooltip/TooltipHandler.cs +++ b/Runtime/Component/Tooltip/TooltipHandler.cs @@ -185,7 +185,7 @@ namespace XCharts.Runtime } if (!m_ShowTooltip || !anyTrigger) { - if (tooltip.context.type == Tooltip.Type.Corss && m_PointerContainer != null && m_PointerContainer.IsPointerEnter()) + if (tooltip.context.type == Tooltip.Type.Cross && m_PointerContainer != null && m_PointerContainer.IsPointerEnter()) { m_ShowTooltip = true; tooltip.SetActive(true); @@ -210,7 +210,7 @@ namespace XCharts.Runtime if (tooltip.context.type == Tooltip.Type.None) return; if (m_PointerContainer != null) { - if (tooltip.context.type == Tooltip.Type.Corss) + if (tooltip.context.type == Tooltip.Type.Cross) { if (m_PointerContainer is GridCoord) { @@ -517,7 +517,7 @@ namespace XCharts.Runtime { axis.context.axisTooltipValue = serie.GetSerieData(serie.context.pointerItemDataIndex).GetData(dimension); } - else if (component.type == Tooltip.Type.Corss) + else if (component.type == Tooltip.Type.Cross) { axis.context.axisTooltipValue = axis.context.pointerValue; } @@ -697,7 +697,7 @@ namespace XCharts.Runtime float splitWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, dataCount, dataZoom); switch (tooltip.context.type) { - case Tooltip.Type.Corss: + case Tooltip.Type.Cross: case Tooltip.Type.Line: float pX = grid.context.x; pX += xAxis.IsCategory() ? @@ -709,7 +709,7 @@ namespace XCharts.Runtime Vector2 ep = new Vector2(pX, grid.context.y + grid.context.height); var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme.tooltip.lineColor); ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor); - if (tooltip.context.type == Tooltip.Type.Corss) + if (tooltip.context.type == Tooltip.Type.Cross) { sp = new Vector2(grid.context.x, chart.pointerPos.y); ep = new Vector2(grid.context.x + grid.context.width, chart.pointerPos.y); @@ -763,7 +763,7 @@ namespace XCharts.Runtime float splitWidth = AxisHelper.GetDataWidth(yAxis, grid.context.height, dataCount, dataZoom); switch (tooltip.context.type) { - case Tooltip.Type.Corss: + case Tooltip.Type.Cross: case Tooltip.Type.Line: float pY = (float)(grid.context.y + yAxis.context.pointerValue * splitWidth + (yAxis.boundaryGap ? splitWidth / 2 : 0)); @@ -773,7 +773,7 @@ namespace XCharts.Runtime Vector2 ep = new Vector2(grid.context.x + grid.context.width, pY); var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme.tooltip.lineColor); ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor); - if (tooltip.context.type == Tooltip.Type.Corss) + if (tooltip.context.type == Tooltip.Type.Cross) { sp = new Vector2(chart.pointerPos.x, grid.context.y); ep = new Vector2(chart.pointerPos.x, grid.context.y + grid.context.height); @@ -818,7 +818,7 @@ namespace XCharts.Runtime switch (tooltip.context.type) { - case Tooltip.Type.Corss: + case Tooltip.Type.Cross: ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor); var dist = Vector2.Distance(chart.pointerPos, cenPos); if (dist > radius) dist = radius; From 549ee43a37422f7f3f05dbfe93fa5640cd817f9f Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 11 Jun 2024 08:11:27 +0800 Subject: [PATCH 29/37] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Tooltip`=E5=9C=A8`Cros?= =?UTF-8?q?s`=E6=97=B6`Axis`=E7=9A=84`IndicatorLabel`=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98=20(#315)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 3 ++- Runtime/Internal/BaseChart.cs | 16 +++++++++++++++- Runtime/Internal/Basic/MainComponent.cs | 1 + Runtime/Serie/SerieHandler.cs | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index fba2d36d..68d6a564 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,7 +73,8 @@ slug: /changelog ## master -* (2024.06.09) 调整`Tooltip`的`Corss`重命名为`Cross` +* (2024.06.11) 修复`Tooltip`在`Cross`时`Axis`的`IndicatorLabel`可能不显示的问题 (#315) +* (2024.06.10) 调整`Tooltip`的`Corss`重命名为`Cross` * (2024.06.09) 增加`Axis`的`minCategorySpacing`设置类目轴默认的最小类目间距 * (2024.06.09) 修复`Tooltip`的`Cross`在`Axis`是类目轴并且开启`DataZoom`的情况下指示位置不准确的问题 * (2024.06.06) 修复`Serie`在`Clone`时动画异常问题 (#320) diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs index e8353ce5..a347d270 100644 --- a/Runtime/Internal/BaseChart.cs +++ b/Runtime/Internal/BaseChart.cs @@ -124,9 +124,15 @@ namespace XCharts.Runtime base.InitComponent(); SeriesHelper.UpdateSerieNameList(this, ref m_LegendRealShowName); foreach (var handler in m_ComponentHandlers) + { handler.InitComponent(); + handler.inited = true; + } foreach (var handler in m_SerieHandlers) + { handler.InitComponent(); + handler.inited = true; + } m_DebugInfo.Init(this); } @@ -216,7 +222,15 @@ namespace XCharts.Runtime foreach (var handler in m_SerieHandlers) handler.BeforeUpdate(); foreach (var handler in m_ComponentHandlers) handler.BeforceSerieUpdate(); foreach (var handler in m_SerieHandlers) handler.Update(); - foreach (var handler in m_ComponentHandlers) handler.Update(); + foreach (var handler in m_ComponentHandlers) + { + if (!handler.inited) + { + handler.InitComponent(); + handler.inited = true; + } + handler.Update(); + } foreach (var handler in m_SerieHandlers) handler.AfterUpdate(); m_DebugInfo.Update(); diff --git a/Runtime/Internal/Basic/MainComponent.cs b/Runtime/Internal/Basic/MainComponent.cs index ae7798b7..843b7049 100644 --- a/Runtime/Internal/Basic/MainComponent.cs +++ b/Runtime/Internal/Basic/MainComponent.cs @@ -93,6 +93,7 @@ namespace XCharts.Runtime public int order { get; internal set; } public BaseChart chart { get; internal set; } public ComponentHandlerAttribute attribute { get; internal set; } + public bool inited { get; internal set; } public virtual void InitComponent() { } public virtual void RemoveComponent() { } diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs index b750ef6e..e8983309 100644 --- a/Runtime/Serie/SerieHandler.cs +++ b/Runtime/Serie/SerieHandler.cs @@ -10,6 +10,7 @@ namespace XCharts.Runtime { public BaseChart chart { get; internal set; } public SerieHandlerAttribute attribute { get; internal set; } + public bool inited { get; internal set; } public virtual int defaultDimension { get; internal set; } public virtual void InitComponent() { } From ddbd82bebf8c4a49acf2e5c57ee293ab34b13a42 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 11 Jun 2024 08:14:34 +0800 Subject: [PATCH 30/37] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`Axis`=E7=9A=84`Indicat?= =?UTF-8?q?orLabel`=E5=8F=AF=E8=83=BD=E4=BC=9A=E9=81=AE=E6=8C=A1=E4=BD=8F`?= =?UTF-8?q?Tooltip`=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Runtime/Component/Tooltip/TooltipHandler.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 68d6a564..c53f7981 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,7 @@ slug: /changelog ## master +* (2024.06.11) 修复`Axis`的`IndicatorLabel`可能会遮挡住`Tooltip`的问题 * (2024.06.11) 修复`Tooltip`在`Cross`时`Axis`的`IndicatorLabel`可能不显示的问题 (#315) * (2024.06.10) 调整`Tooltip`的`Corss`重命名为`Cross` * (2024.06.09) 增加`Axis`的`minCategorySpacing`设置类目轴默认的最小类目间距 diff --git a/Runtime/Component/Tooltip/TooltipHandler.cs b/Runtime/Component/Tooltip/TooltipHandler.cs index 3c5b0dca..9636687c 100644 --- a/Runtime/Component/Tooltip/TooltipHandler.cs +++ b/Runtime/Component/Tooltip/TooltipHandler.cs @@ -65,6 +65,7 @@ namespace XCharts.Runtime m_LabelRoot = ChartHelper.AddObject("label", tooltip.gameObject.transform, chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta); + m_LabelRoot.transform.SetSiblingIndex(0); ChartHelper.HideAllObject(m_LabelRoot); m_IndicatorLabels.Clear(); foreach (var com in chart.components) From 2fe9a40f4257a25453dc0347008dd55eaafe1820 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Tue, 11 Jun 2024 08:28:46 +0800 Subject: [PATCH 31/37] 3.11.0-preview2 --- Runtime/Internal/XChartsMgr.cs | 4 ++-- package.json | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Runtime/Internal/XChartsMgr.cs b/Runtime/Internal/XChartsMgr.cs index 640dcafb..0e2f8b15 100644 --- a/Runtime/Internal/XChartsMgr.cs +++ b/Runtime/Internal/XChartsMgr.cs @@ -21,8 +21,8 @@ namespace XCharts.Runtime [ExecuteInEditMode] public static class XChartsMgr { - public static readonly string version = "3.11.0-preview1"; - public static readonly int versionDate = 20240520; + public static readonly string version = "3.11.0-preview2"; + public static readonly int versionDate = 20240611; public static string fullVersion { get { return version + "-" + versionDate; } } internal static List chartList = new List(); diff --git a/package.json b/package.json index cf335ea3..677fbe90 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "displayName": "XCharts", "author": "monitor1394", "license": "MIT", - "version": "3.11.0-preview1", - "date": "20240520", - "checkdate": "20240520", + "version": "3.11.0-preview2", + "date": "20240611", + "checkdate": "20240611", "unity": "2018.3", "description": "A charting and data visualization library for Unity. Support line chart, bar chart, pie chart, radar chart, scatter chart, heatmap chart, ring chart, candlestick chart, polar chart and parallel coordinates.", "keywords": [ From ee5efa9f8d75bbf979944141cc68ecb0195aa699 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 13 Jun 2024 22:59:37 +0800 Subject: [PATCH 32/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0DrawEdge=E7=BB=98?= =?UTF-8?q?=E5=88=B6=E7=94=B1=E4=B8=8A=E4=B8=8B=E5=9D=90=E6=A0=87=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=BB=84=E6=88=90=E7=9A=84=E8=BE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/XUGL/UGL.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Runtime/XUGL/UGL.cs b/Runtime/XUGL/UGL.cs index 4e901a88..a6e01052 100644 --- a/Runtime/XUGL/UGL.cs +++ b/Runtime/XUGL/UGL.cs @@ -1986,6 +1986,36 @@ namespace XUGL } } + public static void DrawEdge(VertexHelper vh, List topList, List bottomList, + Color32 lineColor, Color32 lineToColor, Direction dire, float currProgress = float.NaN) + { + if (topList.Count < 2 || bottomList.Count < 2) return; + var minCount = Mathf.Min(topList.Count, bottomList.Count); + var isGradient = !UGLHelper.IsValueEqualsColor(lineColor, lineToColor); + AddVertToVertexHelper(vh, topList[0], bottomList[0], lineColor, false); + for (int i = 1; i < minCount; i++) + { + var up = topList[i]; + var dn = bottomList[i]; + if (currProgress != float.NaN) + { + if (dire == Direction.YAxis && up.y > currProgress) + break; + if (dire == Direction.XAxis && up.x > currProgress) + break; + } + if (isGradient) + { + var tcolor = Color32.Lerp(lineColor, lineToColor, i * 1.0f / minCount); + AddVertToVertexHelper(vh, up, dn, tcolor); + } + else + { + AddVertToVertexHelper(vh, up, dn, lineColor); + } + } + } + public static void DrawSvgPath(VertexHelper vh, string path) { SVG.DrawPath(vh, path); From 89e7a09e648bf8cb01a8840ada47a3463d2b7abb Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Thu, 13 Jun 2024 23:04:35 +0800 Subject: [PATCH 33/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Edge=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Internal/Data/GraphData.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Runtime/Internal/Data/GraphData.cs b/Runtime/Internal/Data/GraphData.cs index b5fe2e9f..269f4ef8 100644 --- a/Runtime/Internal/Data/GraphData.cs +++ b/Runtime/Internal/Data/GraphData.cs @@ -484,7 +484,8 @@ namespace XCharts.Runtime public double value; public GraphData hostGraph; - public List points = new List(); + public List upPoints = new List(); + public List downPoints = new List(); public float width; public float distance; public bool highlight; @@ -496,5 +497,24 @@ namespace XCharts.Runtime this.node2 = node2; this.value = value; } + + public bool IsPointInEdge(Vector2 point) + { + if (upPoints.Count == 0 || downPoints.Count == 0) return false; + var lastCount = upPoints.Count - 1; + if (point.x < upPoints[0].x || point.x > upPoints[lastCount].x) return false; + if (point.y > upPoints[0].y && point.y > upPoints[lastCount].y) return false; + if (point.y < downPoints[0].y && point.y < downPoints[lastCount].y) return false; + + for (int i = 0; i < upPoints.Count - 1; i++) + { + var diff = point.x - upPoints[i].x; + if (diff <= 0) + { + return point.y < upPoints[i].y && point.y > downPoints[i].y; + } + } + return false; + } } } \ No newline at end of file From e3fb5685bfce8936fbea246cdcbca7fa53880bca Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sat, 15 Jun 2024 13:21:38 +0800 Subject: [PATCH 34/37] =?UTF-8?q?=E5=A2=9E=E5=8A=A0`Editor`=E4=B8=8B`Data`?= =?UTF-8?q?=E7=9A=84=E6=B7=BB=E5=8A=A0=E3=80=81=E5=88=A0=E9=99=A4=E3=80=81?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E7=A7=BB=E5=8A=A8=E6=93=8D=E4=BD=9C=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Documentation~/zh/changelog.md | 1 + Editor/Series/SerieEditor.cs | 30 +++++++--- Editor/Utilities/ChartEditorHelper.cs | 84 ++++++++++++++------------- 3 files changed, 67 insertions(+), 48 deletions(-) diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index c53f7981..acc046fa 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -73,6 +73,7 @@ slug: /changelog ## master +* (2024.06.15) 增加`Editor`下`Data`的添加、删除、上下移动操作按钮 * (2024.06.11) 修复`Axis`的`IndicatorLabel`可能会遮挡住`Tooltip`的问题 * (2024.06.11) 修复`Tooltip`在`Cross`时`Axis`的`IndicatorLabel`可能不显示的问题 (#315) * (2024.06.10) 调整`Tooltip`的`Corss`重命名为`Cross` diff --git a/Editor/Series/SerieEditor.cs b/Editor/Series/SerieEditor.cs index 5fa47e9a..3eee17fe 100644 --- a/Editor/Series/SerieEditor.cs +++ b/Editor/Series/SerieEditor.cs @@ -162,7 +162,7 @@ namespace XCharts.Editor } } - private void DrawSerieDataHeader(Rect drawRect,HeaderCallbackContext context) + private void DrawSerieDataHeader(Rect drawRect, HeaderCallbackContext context) { var serieData = context.serieData; var fieldCount = context.fieldCount; @@ -180,12 +180,18 @@ namespace XCharts.Editor var sereName = serieData.FindPropertyRelative("m_Name"); var data = serieData.FindPropertyRelative("m_Data"); #if UNITY_2019_3_OR_NEWER - var gap = 2; - var namegap = 3; + var gap = 2; + var namegap = 3; + var buttomLength = 30; #else var gap = 0; var namegap = 0; + var buttomLength = 30; #endif + if (showName) + { + buttomLength += 12; + } if (fieldCount <= 1) { while (2 > data.arraySize) @@ -197,13 +203,13 @@ namespace XCharts.Editor SerializedProperty element = data.GetArrayElementAtIndex(1); var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap; drawRect.x = startX; - drawRect.xMax = maxX; + drawRect.xMax = maxX - buttomLength; EditorGUI.PropertyField(drawRect, element, GUIContent.none); } else { var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap; - var dataWidTotal = (currentWidth - (startX + 20.5f + 1)); + var dataWidTotal = currentWidth - (startX + 20.5f + 1) - buttomLength; var dataWid = dataWidTotal / fieldCount; var xWid = dataWid - 0; for (int i = 0; i < dimension; i++) @@ -226,6 +232,9 @@ namespace XCharts.Editor drawRect.width = dataWid + 40 + dimension * namegap - 2.5f; EditorGUI.PropertyField(drawRect, sereName, GUIContent.none); } + drawRect.x = lastX; + drawRect.width = lastWid; + ChartEditorHelper.UpDownAddDeleteButton(drawRect, context.listProp, index); EditorGUIUtility.fieldWidth = lastFieldWid; EditorGUIUtility.labelWidth = lastLabelWid; } @@ -242,12 +251,14 @@ namespace XCharts.Editor var fieldCount = dimension + (showName ? 1 : 0); var serieData = m_Datas.GetArrayElementAtIndex(index); var dataIndex = serieData.FindPropertyRelative("m_Index").intValue; - var callbackContext = new HeaderCallbackContext(){ + var callbackContext = new HeaderCallbackContext() + { serieData = serieData, fieldCount = fieldCount, showName = showName, index = index, - dimension = dimension + dimension = dimension, + listProp = m_Datas }; m_DataElementFoldout[index] = ChartEditorHelper.DrawSerieDataHeader("SerieData " + dataIndex, flag, false, null, callbackContext, DrawSerieDataHeader); if (m_DataElementFoldout[index]) @@ -327,7 +338,10 @@ namespace XCharts.Editor 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, ""); + var hig = ChartEditorHelper.MakeThreeField(ref drawRect, drawRect.width, sourceIndex, targetIndex, value, ""); + var btnRect = drawRect; + btnRect.y -= hig; + ChartEditorHelper.UpDownAddDeleteButton(btnRect, m_Datas, index); }); if (m_LinksElementFoldout[index]) { diff --git a/Editor/Utilities/ChartEditorHelper.cs b/Editor/Utilities/ChartEditorHelper.cs index 4737241f..afe48c66 100644 --- a/Editor/Utilities/ChartEditorHelper.cs +++ b/Editor/Utilities/ChartEditorHelper.cs @@ -13,6 +13,7 @@ namespace XCharts.Editor public bool showName; public int index; public int dimension; + public SerializedProperty listProp; } public class HeaderMenuInfo @@ -52,6 +53,8 @@ namespace XCharts.Editor public const float GAP_WIDTH = 0; public const float DIFF_WIDTH = 1; #endif + public const float ICON_WIDHT = 10; + public const float ICON_GAP = 0; static Dictionary s_GUIContentCache; static ChartEditorHelper() @@ -115,21 +118,23 @@ namespace XCharts.Editor drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; } - public static void MakeThreeField(ref Rect drawRect, float rectWidth, SerializedProperty prop1, - SerializedProperty prop2, SerializedProperty prop3, string name) + public static float MakeThreeField(ref Rect drawRect, float rectWidth, SerializedProperty prop1, + SerializedProperty prop2, SerializedProperty prop3, string name, bool btnSpacing = true) { EditorGUI.LabelField(drawRect, name); var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + GAP_WIDTH; - var diff = 13 + EditorGUI.indentLevel * 14; + var diff = 13f + EditorGUI.indentLevel * 14; var offset = diff - INDENT_WIDTH; - var tempWidth = (rectWidth - startX + diff) / 3; + var tempWidth = (rectWidth - startX + diff - (btnSpacing ? (ICON_WIDHT + ICON_GAP) * 4 : 0)) / 3 + 8.5f; 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; + var hig = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + drawRect.y += hig; + return hig; } public static void MakeVector2(ref Rect drawRect, float rectWidth, SerializedProperty prop, string name) @@ -344,15 +349,12 @@ namespace XCharts.Editor { EditorGUI.indentLevel++; var listSize = listProp.arraySize; - var iconWidth = 10; - var iconGap = 0f; - if (showSize) { var headerHeight = DrawSplitterAndBackground(drawRect); if (showOrder) { - var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - iconWidth + 2, drawRect.height); + var elementRect = new Rect(drawRect.x, drawRect.y, drawRect.width - ICON_WIDHT + 2, drawRect.height); var oldColor = GUI.contentColor; GUI.contentColor = Color.black; GUI.contentColor = oldColor; @@ -405,40 +407,14 @@ namespace XCharts.Editor DrawSplitterAndBackground(drawRect); if (showOrder) { - var temp = INDENT_WIDTH + GAP_WIDTH + iconGap; var isSerie = "Serie".Equals(element.type); var elementRect = isSerie ? - new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH - 2 * iconGap, drawRect.height) : - new Rect(drawRect.x, drawRect.y, drawRect.width - 4 * iconWidth, drawRect.height); + new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH - 2 * ICON_GAP, drawRect.height) : + new Rect(drawRect.x, drawRect.y, drawRect.width - 4 * ICON_WIDHT, drawRect.height); EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i)); - var iconRect = new Rect(drawRect.width - 4 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); - var oldColor = GUI.contentColor; - GUI.contentColor = Color.black; - if (GUI.Button(iconRect, EditorCustomStyles.iconUp, EditorCustomStyles.invisibleButton)) - { - if (i > 0) listProp.MoveArrayElement(i, i - 1); - } - iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); - if (GUI.Button(iconRect, EditorCustomStyles.iconDown, EditorCustomStyles.invisibleButton)) - { - if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1); - } - iconRect = new Rect(drawRect.width - 2 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height); - if (GUI.Button(iconRect, EditorCustomStyles.iconAdd, EditorCustomStyles.invisibleButton)) - { - if (i < listProp.arraySize && i >= 0) listProp.InsertArrayElementAtIndex(i); - } - iconRect = new Rect(drawRect.width - iconWidth + temp, drawRect.y, iconWidth, drawRect.height); - if (GUI.Button(iconRect, EditorCustomStyles.iconRemove, EditorCustomStyles.invisibleButton)) - { - if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i); - } - else - { - drawRect.y += EditorGUI.GetPropertyHeight(element); - height += EditorGUI.GetPropertyHeight(element); - } - GUI.contentColor = oldColor; + UpDownAddDeleteButton(drawRect, listProp, i); + drawRect.y += EditorGUI.GetPropertyHeight(element); + height += EditorGUI.GetPropertyHeight(element); } else { @@ -451,6 +427,34 @@ namespace XCharts.Editor EditorGUI.indentLevel--; } + public static void UpDownAddDeleteButton(Rect drawRect, SerializedProperty listProp, int i) + { + var temp = INDENT_WIDTH + GAP_WIDTH + ICON_GAP; + var iconRect = new Rect(drawRect.width - 4 * ICON_WIDHT + temp, drawRect.y, ICON_WIDHT, drawRect.height); + var oldColor = GUI.contentColor; + GUI.contentColor = Color.black; + if (GUI.Button(iconRect, EditorCustomStyles.iconUp, EditorCustomStyles.invisibleButton)) + { + if (i > 0) listProp.MoveArrayElement(i, i - 1); + } + iconRect = new Rect(drawRect.width - 3 * ICON_WIDHT + temp, drawRect.y, ICON_WIDHT, drawRect.height); + if (GUI.Button(iconRect, EditorCustomStyles.iconDown, EditorCustomStyles.invisibleButton)) + { + if (i < listProp.arraySize - 1) listProp.MoveArrayElement(i, i + 1); + } + iconRect = new Rect(drawRect.width - 2 * ICON_WIDHT + temp, drawRect.y, ICON_WIDHT, drawRect.height); + if (GUI.Button(iconRect, EditorCustomStyles.iconAdd, EditorCustomStyles.invisibleButton)) + { + if (i < listProp.arraySize && i >= 0) listProp.InsertArrayElementAtIndex(i); + } + iconRect = new Rect(drawRect.width - ICON_WIDHT + temp, drawRect.y, ICON_WIDHT, drawRect.height); + if (GUI.Button(iconRect, EditorCustomStyles.iconRemove, EditorCustomStyles.invisibleButton)) + { + if (i < listProp.arraySize && i >= 0) listProp.DeleteArrayElementAtIndex(i); + } + GUI.contentColor = oldColor; + } + public static bool PropertyField(ref Rect drawRect, Dictionary heights, string key, SerializedProperty prop) { From 24270e5c6933f1d1671dfa6150c47e9a4a27f0cb Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 16 Jun 2024 19:05:40 +0800 Subject: [PATCH 35/37] 3.11.0 --- Documentation~/en/api.md | 1 + Documentation~/en/changelog.md | 36 ++++++++++ Documentation~/zh/api.md | 1 + Documentation~/zh/changelog.md | 14 ++++ Documentation~/zh/support.md | 3 + Documentation~/zh/tutorial01.md | 2 +- README-en.md | 113 ++++++++++++++------------------ README.md | 88 ++++++++++++------------- Runtime/Internal/XChartsMgr.cs | 4 +- package.json | 6 +- 10 files changed, 153 insertions(+), 115 deletions(-) diff --git a/Documentation~/en/api.md b/Documentation~/en/api.md index f7964d7a..30e48d6a 100644 --- a/Documentation~/en/api.md +++ b/Documentation~/en/api.md @@ -1480,6 +1480,7 @@ The edge of graph. |public method|since|description| |--|--|--| |GraphEdge()||public GraphEdge(GraphNode node1, GraphNode node2, double value)| +|IsPointInEdge()||public bool IsPointInEdge(Vector2 point)| ## GraphNode diff --git a/Documentation~/en/changelog.md b/Documentation~/en/changelog.md index ea0198da..f4f3f44c 100644 --- a/Documentation~/en/changelog.md +++ b/Documentation~/en/changelog.md @@ -2,6 +2,7 @@ # 更新日志 [master](#master) +[v3.11.0](#v3110) [v3.10.2](#v3102) [v3.10.1](#v3101) [v3.10.0](#v3100) @@ -68,6 +69,41 @@ ## master +## v3.11.0 + +Release Highlights: + +* Added `Line3DChart` for 3D line charts +* Added `GraphChart` for relationship graphs +* Added support for 3D coordinate systems +* Added `triggerOn` setting for `Tooltip` to define trigger conditions +* Various bug fixes and optimizations + +Changelog Details: + +* (2024.06.16) Released version `v3.11.0` +* (2024.06.15) Added buttons for adding, deleting, and moving data up and down under `Editor` +* (2024.06.11) Fixed issue where `Axis`'s `IndicatorLabel` might overlap with `Tooltip` +* (2024.06.11) Fixed issue where `Tooltip`'s `Axis` `IndicatorLabel` might not display when in `Cross` mode (#315) +* (2024.06.10) Renamed `Tooltip`'s `Corss` to `Cross` +* (2024.06.09) Added `minCategorySpacing` setting for `Axis` to define the default minimum category spacing +* (2024.06.09) Fixed inaccurate indicator position of `Tooltip`'s `Cross` when `Axis` is a category axis and `DataZoom` is enabled +* (2024.06.06) Fixed animation issue when `Serie` is cloned (#320) +* (2024.06.04) Fixed issue where `Serie`'s `state` does not refresh when set dynamically via code +* (2024.05.29) Adjusted the right-click menu of `XCharts` in the `Hierarchy` view to `UI/XCharts` +* (2024.05.29) Added support for 3D coordinate systems to category axes +* (2024.05.19) Optimized editing performance in `Editor` +* (2024.05.09) Added utility class `JsonUtil` +* (2024.04.23) Fixed chart exception issue after multiple calls to `ConvertXYAxis()` +* (2024.04.22) Fixed potential incorrect retrieval of `GridCoord` when `DataZoom` controls multiple axes (#317) +* (2024.04.22) Added 3D coordinate system +* (2024.04.15) Optimized `DateTimeUtil` for timezone issues when converting timestamps to `DateTime` +* (2024.04.15) Optimized `GridCoord` to display `Left` `Right` `Top` `Bottom` parameters even when `GridLayout` is enabled (#316) +* (2024.04.14) Fixed incorrect label position of `Tooltip`'s `Cross` when `DataZoom` is enabled (#315) +* (2024.04.12) Fixed incorrect effect of `Candlesticks` (#313) +* (2024.03.20) Added `triggerOn` setting for `Tooltip` to define trigger conditions +* (2024.03.19) Fixed color issue when setting `opacity` in `Pie`'s `ItemStyle` (#309) + ## v3.10.2 * (2024.03.11) Release `v3.10.2` diff --git a/Documentation~/zh/api.md b/Documentation~/zh/api.md index 111f3836..7c2352d4 100644 --- a/Documentation~/zh/api.md +++ b/Documentation~/zh/api.md @@ -1480,6 +1480,7 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息 |API|版本|描述| |--|--|--| |GraphEdge()||public GraphEdge(GraphNode node1, GraphNode node2, double value)| +|IsPointInEdge()||public bool IsPointInEdge(Vector2 point)| ## GraphNode diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index acc046fa..5e4132a5 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -6,6 +6,7 @@ slug: /changelog # 更新日志 [master](#master) +[v3.11.0](#v3110) [v3.10.2](#v3102) [v3.10.1](#v3101) [v3.10.0](#v3100) @@ -73,6 +74,19 @@ slug: /changelog ## master +## v3.11.0 + +版本要点: + +* 增加`Line3DChart`3D折线图 +* 增加`GraphChart`关系图 +* 增加`3D`坐标系支持 +* 增加`Tooltip`的`triggerOn`设置触发条件 +* 其他问题修复和优化 + +日志详情: + +* (2024.06.16) 发布`v3.11.0`版本 * (2024.06.15) 增加`Editor`下`Data`的添加、删除、上下移动操作按钮 * (2024.06.11) 修复`Axis`的`IndicatorLabel`可能会遮挡住`Tooltip`的问题 * (2024.06.11) 修复`Tooltip`在`Cross`时`Axis`的`IndicatorLabel`可能不显示的问题 (#315) diff --git a/Documentation~/zh/support.md b/Documentation~/zh/support.md index 1133eff1..4297f4e7 100644 --- a/Documentation~/zh/support.md +++ b/Documentation~/zh/support.md @@ -79,11 +79,14 @@ slug: /support | 102 | [漏斗图](https://xcharts-team.github.io/docs/funnel) |FunnelChart | 98¥ | | 103 | [3D金字塔](https://xcharts-team.github.io/docs/pyramid) |PyramidChart | 98¥ | | 104 | [树形矩图](https://xcharts-team.github.io/docs/treemap) |TreemapChart | 98¥ | +| 105 | [桑基图](https://xcharts-team.github.io/docs/sankey) |SankeyChart | 98¥ | | 201 | [3D柱图](https://xcharts-team.github.io/docs/bar3d) |Bar3DChart | 198¥ | | 202 | [3D饼图](https://xcharts-team.github.io/docs/pie3d) |Pie3DChart | 198¥ | | 203 | [甘特图](https://xcharts-team.github.io/docs/gantt) |GanttChart | 198¥ | | 204 | [仪表盘](https://xcharts-team.github.io/docs/gauge) |GaugeChart | 198¥ | | 205 | [水位图](https://xcharts-team.github.io/docs/liquid) |LiquidChart | 198¥ | +| 206 | [3D折线图](https://xcharts-team.github.io/docs/line3d) |Line3DChart | 198¥ | +| 207 | [关系图](https://xcharts-team.github.io/docs/graph) |GraphChart | 198¥ | 扩展图表的在线效果图也可以查看[WebGL在线Demo](https://xcharts-team.github.io/examples/) diff --git a/Documentation~/zh/tutorial01.md b/Documentation~/zh/tutorial01.md index 4cdd5105..0c2b382e 100644 --- a/Documentation~/zh/tutorial01.md +++ b/Documentation~/zh/tutorial01.md @@ -44,7 +44,7 @@ XCharts可通过以下任意一种方式导入到项目: ## 添加一个简单图表 -在`Hierarchy`视图下右键或菜单栏`GameObject`下拉选择`XCharts->LineChart`,即可快速创建一个默认的折线图出来: +在`Hierarchy`视图下右键`UI->XCharts->LineChart`或菜单栏`GameObject`下拉选择`XCharts->LineChart`,即可快速创建一个默认的折线图出来: ![linechart1](img/tutorial01_linechart1.png) diff --git a/README-en.md b/README-en.md index bf6ac6cb..6149b131 100644 --- a/README-en.md +++ b/README-en.md @@ -45,38 +45,35 @@ ![XCharts](Documentation~/zh/img/xcharts.png) -A powerful and easy-to-use data visualization library for Unity. It supports more than ten built-in charts, including line, bar, pie, radar, scatter, heatmap, ring, candlestick, polar, parallel coordinates, as well as extended charts such as 3d pie, 3d bar, 3d pyramid, funnel, gauge, liquid, pictorialbar, gantt, and treemap. +## Overview -[XCharts3.0 Homepage](https://xcharts-team.github.io) +A powerful and easy-to-use data visualization library for Unity. It supports more than ten built-in charts, including line, bar, pie, radar, scatter, heatmap, ring, candlestick, polar, parallel coordinates, as well as extended charts such as 3d pie, 3d bar, 3d pyramid, funnel, gauge, liquid, pictorialbar, gantt, treemap, sankey, line3d and graph chart. -[XCharts3.0 Tutorial](Documentation~/en/tutorial01.md) -[XCharts3.0 API](Documentation~/en/api.md) -[XCharts3.0 FAQ](Documentation~/en/faq.md) -[XCharts3.0 Configurate](Documentation~/en/configuration.md) -[XCharts3.0 Changelog](Documentation~/en/changelog.md) -[XCharts3.0 Support](Documentation~/en/support.md) +## Key Features -## Features +- __Pure Code Rendering__: Charts are rendered with pure code, eliminating the need for extra texture or shader resources. +- __Visual Configuration__: Configure parameters visually with real-time preview and support for dynamic configuration and data adjustments at runtime. +- __High Customizability__: Themes and configuration parameters can be adjusted as needed, with support for custom drawing and callbacks. +- __Built-in and Extended Charts__: Supports a variety of chart types, including 3D charts and special chart types like gauges and treemaps. +- __Multiple Chart Combinations__: Combine multiple charts of the same or different types within a single instance. +- __Various Coordinate Systems__: Supports different coordinate systems such as Cartesian, polar, and single axes. +- __Rich Components__: Includes titles, legends, tooltips, and more. +- __Custom Drawing__: Utilize a powerful API for custom drawing of points, lines, and other graphics. +- __Large Data Rendering__: Capable of rendering tens of thousands of data points with support for sampling rendering. +- __Custom Themes__: Customize themes and use the included light and dark default themes. +- __Animations and Interactions__: Supports various animations and interactions for a dynamic user experience. +- __Third-Party Extensions__: Integrates with TextMeshPro and the New Input System. +- __Version and Compatibility__: Compatible with all Unity versions above 5.6 and runs on all platforms. -* __Pure code rendering__: The chart is completely rendered with pure code, without the need for additional texture or shader resources. -* __Visual configuration__: Visual configuration of parameters with real-time preview of the effect, and support for dynamic modification of configuration and data during runtime. -* __High customizability__: Supports arbitrary adjustments from theme and configuration parameters; supports custom drawing, callback functions, and custom implementations of charts. -* __Multiple built-in charts__: Supports various built-in charts such as line charts, bar charts, pie charts, radar charts, scatter plots, heat maps, polar charts, K-line charts, parallel coordinates, etc. -* __Multiple extended charts__: Supports extended charts such as 3D column charts, 3D pie charts, funnel charts, pyramids, dashboards, water level charts, iconic bar charts, Gantt charts, and tree maps. -* __Multiple extended features__: Supports extended UI components such as tables and statistical values. -* __Multiple chart combinations__: Supports arbitrary combinations of built-in charts, with multiple same or different types of charts displayed simultaneously in the same chart. -* __Various coordinate systems__: Supports coordinate systems such as Cartesian coordinates, polar coordinates, and single axes. -* __Rich components__: Supports common components such as titles, legends, tooltips, markings, marking areas, data area zooming, and visual mapping. -* __Rich line charts__: Supports various line charts such as straight line charts, curved line charts, dashed line charts, area charts, step line charts, etc. -* __Rich bar charts__: Supports various bar charts such as stacked bar charts, stacked percentage bar charts, zebra bar charts, and capsule bar charts. -* __Rich pie charts__: Supports various pie charts such as ring charts, rose charts, ring rose charts, etc. -* __Rich lines__: Supports various lines such as solid lines, curves, step lines, dashed lines, dot lines, dotted lines, and double dot-dashed lines. -* __Custom drawing__: Supports custom chart content drawing with powerful drawing APIs for drawing points, lines, and other graphics. -* __Large data rendering__: Supports rendering of tens of thousands of data points; supports sampling rendering; special simplified charts support better performance. -* __Custom themes__: Supports theme customization and import/export; includes both light and dark default themes. -* __Animations and interactions__: Supports various animations such as fade-in animation, fade-out animation, change animation, addition animation, and * interactive animation; supports interactive operations such as data filtering, view zooming, and detailed display on multiple platforms. -* __Third-party extensions__: Supports integration with TexMeshPro and New Input System. -* __Version and compatibility__: Supports all Unity versions above 5.6 and runs on all platforms. +## Documentation + +- [XCharts3.0 Homepage](https://xcharts-team.github.io) +- [XCharts3.0 Tutorial](Documentation~/en/tutorial01.md) +- [XCharts3.0 API](Documentation~/en/api.md) +- [XCharts3.0 FAQ](Documentation~/en/faq.md) +- [XCharts3.0 Configurate](Documentation~/en/configuration.md) +- [XCharts3.0 Changelog](Documentation~/en/changelog.md) +- [XCharts3.0 Support](Documentation~/en/support.md) ## Screenshots @@ -84,55 +81,43 @@ A powerful and easy-to-use data visualization library for Unity. It supports mo ![extendchart](Documentation~/en/img/readme_extendchart.png) -## Attention +## Important Notes -* `XCharts3.0` is not fully compatible with `XCharts2.0` version, upgrading `3.0` may require some code adjustments, and some chart configurations need to be readjusting. It is recommended that old projects can continue to use `XCharts2.0`, and new projects are recommended to use `XCharts3.0`. -* `XCharts2.0` enters the maintenance phase, and only serious `bugs` will be fixed later, in principle, no more new features will be added. -* `XCharts` theoretically supports `Unity 5.6` and above, but due to limited version testing, it is inevitable to slip up, and version compatibility issues can be raised. -* This repository only contains `XCharts` source code, does not contain `Demo` sample section. Need to look at ` Demo ` please go to the sample source code [XCharts - Demo](https://github.com/XCharts-Team/XCharts-Demo) repo. You can also view the running effect of `WebGL` in your browser [Online Demo](https://xcharts-team.github.io/examples/). +- `XCharts3.0` is not fully compatible with `XCharts2.0`. Upgrading to 3.0 may require code adjustments and reconfiguration of some charts. +- `XCharts2.0` is in the maintenance phase with only critical bug fixes applied. +- While XCharts supports Unity 5.6 and above, compatibility issues may arise due to limited testing. +- This repository contains only the `XCharts` source code. For demos, visit the [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) repo or the [Online Demo](https://xcharts-team.github.io/examples/). -## Use +## Getting Started -* Import `XCharts` unitypackage or source code into the project. -* Right-click `Hierarchy` view and choose `XCharts->LineChart` to create a default LineChart. -* You can adjust the parameters of each component in `Inspector` and see the real-time effects in `Game` view. -* For more details, see [[XCharts Tutorial: 5-minute tutorial]](Documentation~/en/tutorial01.md) -* For the first time, it is recommended to read the tutorial carefully. +1. Import the `XCharts` unitypackage or source code into your Unity project. +2. Create a chart by right-clicking in the `Hierarchy` view and selecting `UI->XCharts->LineChart`. +3. Adjust component parameters in the `Inspector` to see real-time effects in the `Game` view. +4. For more details, refer to the [5-minute tutorial](Documentation~/en/tutorial01.md). -## Branch +## Branch Information -* `master` : indicates the development branch. The latest changes and new features are first committed to the `master` branch, and after some time from the `master` branch `merge` to the `3.0` branch, and the `release` version. -* `3.0` : Stable branch of XCharts 3.0. It is generally updated once a month, with the latest changes from the `master` branch `merge`, and the `release` version is released. -* `2.0` : A stable branch of XCharts 2.0. With Demo, currently no longer maintenance, only to modify serious bugs. -* `2.0-upm` : Stable UMP branch of XCharts 2.0. Only the Package part is included without Demo. It is dedicated to the UMP and is not maintained. -* `1.0` : Stable branch of XCharts 1.0. With Demo, no maintenance. -* `1.0-upm` : stable UMP branch of XCharts 1.0. No Demo, no maintenance. +- __master__ indicates the development branch. The latest changes and new features are first committed to the `master` branch, and after some time from the `master` branch `merge` to the `3.0` branch, and the `release` version. +- __3.0__ Stable branch of XCharts 3.0. It is generally updated once a month, with the latest changes from the `master` branch `merge`, and the `release` version is released. +- __2.0__ A stable branch of XCharts 2.0. With Demo, currently no longer maintenance, only to modify serious bugs. +- __2.0-upm__ Stable UMP branch of XCharts 2.0. Only the Package part is included without Demo. It is dedicated to the UMP and is not maintained. +- __1.0__ Stable branch of XCharts 1.0. With Demo, no maintenance. +- __1.0-upm__ stable UMP branch of XCharts 1.0. No Demo, no maintenance. ## FAQ -* Is `XCharts` free to use? -A: `XCharts` uses the `MIT` licence and is free to use. You can also subscribe to `VIP` to enjoy more value-added services. - -* Does `XCharts` support code to dynamically add and modify data? Does it support getting data from `Excel` or a database? -A: Support code to dynamically add and modify data, but data needs to be parsed or retrieved by itself, and then added to `XCharts` by calling the public interface of `XCharts`. - -* Does this plugin work on other platforms (e.g. Winform or WPF) besides Unity? -A: It is currently only supported on Unity. Theoretically any version of Unity that supports `UGUI` can run `XCharts`. - -* What about the jags? What magnitude of data is supported? -A: XCharts is based on UGUI implementation, so the problems encountered in UGUI will also exist in XCharts. For example, the sawtooth problem, such as the number of vertices in `Mesh` exceeds `65535`. Solutions to these two problems can be found in [Q&A 16](Documentation~/en/faq.md) and [Q&A 27](Documentation~/en/faq.md). -Due to the `Mesh` of the `65535` vertex limit, the current `XCharts` single `Line` supports about `20,000` of data, of course, open sampling can support more data to draw, but at the same time it will consume more CPU. +- __Is XCharts free to use?__ Yes, XCharts is free under the MIT license and includes value-added VIP services. +- __Does XCharts support dynamic data addition and modification?__ Yes, but data must be parsed or retrieved by the user. +- __Does this plugin work on platforms other than Unity?__ No, it is designed for Unity only. ## Changelog -* [Changelog](Documentation~/en/changelog.md) +- [Changelog](Documentation~/en/changelog.md) ## Licenses -* [MIT License](https://github.com/XCharts-Team/XCharts/blob/master/LICENSE.md) -* Free commercial, secondary development -* The extended charts and advanced features sections require a separate purchase license +- XCharts is released under the [MIT License](https://github.com/XCharts-Team/XCharts/blob/master/LICENSE.md). -## Other +## Contact -email: `monitor1394@gmail.com` +- For more information or support, contact us at `monitor1394@gmail.com`. diff --git a/README.md b/README.md index d308a27d..b5c6d50f 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ ![XCharts](Documentation~/zh/img/xcharts.png) -一款基于`UGUI`的功能强大、简单易用的数据可视化图表插件。支持`折线图`、`柱状图`、`饼图`、`雷达图`、`散点图`、`热力图`、`环形图`、`K线图`、`极坐标`、`平行坐标`等十多种内置图表,以及`3D饼图`、`3D柱图`、`3D金字塔`、`漏斗图`、`仪表盘`、`水位图`、`象形柱图`、`甘特图`、`矩形树图`、`桑基图`等多种扩展图表。 +一款基于`UGUI`的功能强大的简单易用的`Unity`数据可视化图表插件。支持`折线图`、`柱状图`、`饼图`、`雷达图`、`散点图`、`热力图`、`环形图`、`K线图`、`极坐标`、`平行坐标`等十几种内置图表,以及`3D饼图`、`3D柱图`、`3D金字塔`、`漏斗图`、`仪表盘`、`水位图`、`象形柱图`、`甘特图`、`矩形树图`、`桑基图`、`3D折线图`、`关系图`等十几种扩展图表。 [XCharts 官方主页](https://xcharts-team.github.io) [XCharts 在线示例](https://xcharts-team.github.io/examples) @@ -63,7 +63,7 @@ - __可视化配置__:参数可视化配置,效果实时预览,支持运行时代码动态修改配置和数据。 - __高自由定制__:支持从主题和配置参数上任意调整;支持代码自定义绘制,自定义回调以及自定义实现图表。 - __多内置图表__:支持线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等多种内置图表。 -- __多扩展图表__:支持3D柱图、3D饼图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图等多种扩展图表。 +- __多扩展图表__:支持3D柱图、3D饼图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图、3D折线图、关系图等多种扩展图表。 - __多扩展组件__:支持表格、统计数值等多种扩展UI组件。 - __多图表组合__:支持内置图表的任意组合,同一图中可同时显示多个相同或不同类型的图表。 - __多种坐标系__:支持直角坐标系、极坐标系、单轴等多种坐标系。 @@ -87,42 +87,33 @@ ## 仓库 -| 相关仓库 | 仓库介绍 | -| -- | --| -| [XCharts](https://github.com/XCharts-Team/XCharts) | XCharts核心功能,完全免费。 | -| [XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon) | XCharts的守护程序,用于确保XCharts更新时的编译正常。非必须,但建议使用。 | -| [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) | XCharts的官方示例,不包含扩展图表部分。订阅VIP的用户购买扩展图表后,可加入对应图表的示例。 | -| [XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro) | XCharts完全版,包含所有扩展图表和扩展组件。订阅SVIP后可访问使用。 | -| [XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo) | XCharts完全版官方示例,包含所有扩展图表和扩展组件的示例。订阅SVIP后可访问使用。 | -| [XCharts-UI](https://github.com/XCharts-Team/XCharts-UI) | XCharts的扩展UI组件。订阅VIP后可访问使用。 | -| [XCharts-Bar3DChart](https://github.com/XCharts-Team/XCharts-Bar3DChart) | XCharts扩展图表:3D柱图。订阅购买后可访问使用。 | -| [XCharts-FunnelChart](https://github.com/XCharts-Team/XCharts-FunnelChart) | XCharts扩展图表:漏斗图。订阅购买后可访问使用。 | -| [XCharts-GanttChart](https://github.com/XCharts-Team/XCharts-GanttChart) | XCharts扩展图表:甘特图。订阅购买后可访问使用。 | -| [XCharts-GaugeChart](https://github.com/XCharts-Team/XCharts-GaugeChart) | XCharts扩展图表:仪表盘。订阅购买后可访问使用。 | -| [XCharts-LiquidChart](https://github.com/XCharts-Team/XCharts-LiquidChart) | XCharts扩展图表:水位图。订阅购买后可访问使用。 | -| [XCharts-PictorialBarChart](https://github.com/XCharts-Team/XCharts-PictorialBarChart) | XCharts扩展图表:象形住图。订阅购买后可访问使用。 | -| [XCharts-Pie3DChart](https://github.com/XCharts-Team/XCharts-Pie3DChart) | XCharts扩展图表:3D饼图。订阅购买后可访问使用。 | -| [XCharts-PyramidChart](https://github.com/XCharts-Team/XCharts-PyramidChart) | XCharts扩展图表:3D金字塔。订阅购买后可访问使用。 | -| [XCharts-TreemapChart](https://github.com/XCharts-Team/XCharts-TreemapChart) | XCharts扩展图表:矩形树图。订阅购买后可访问使用。 | -| [XCharts-SankeyChart](https://github.com/XCharts-Team/XCharts-SankeyChart) | XCharts扩展图表:桑基图。订阅购买后可访问使用。 | +- __[XCharts](https://github.com/XCharts-Team/XCharts)__ XCharts核心功能,完全免费。 +- __[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)__ XCharts守护程序,用于确保XCharts更新时的编译正常。非必须,但建议使用。 +- __[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)__ XCharts官方示例,不包含扩展图表部分。订阅购买扩展图表后可导入示例。 +- __[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)__ XCharts专业版,包含所有扩展图表和扩展组件。订阅SVIP后可访问使用。 +- __[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo)__ XCharts专业版官方示例,包含所有扩展图表和扩展组件的示例。订阅SVIP后可访问使用。 +- __[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)__ XCharts的扩展UI组件。订阅VIP后可访问使用。 +- __[XCharts-Bar3DChart](https://github.com/XCharts-Team/XCharts-Bar3DChart)__ XCharts扩展图表:3D柱图。订阅购买后可访问使用。 +- __[XCharts-FunnelChart](https://github.com/XCharts-Team/XCharts-FunnelChart)__ XCharts扩展图表:漏斗图。订阅购买后可访问使用。 +- __[XCharts-GanttChart](https://github.com/XCharts-Team/XCharts-GanttChart)__ XCharts扩展图表:甘特图。订阅购买后可访问使用。 +- __[XCharts-GaugeChart](https://github.com/XCharts-Team/XCharts-GaugeChart)__ XCharts扩展图表:仪表盘。订阅购买后可访问使用。 +- __[XCharts-LiquidChart](https://github.com/XCharts-Team/XCharts-LiquidChart)__ XCharts扩展图表:水位图。订阅购买后可访问使用。 +- __[XCharts-PictorialBarChart](https://github.com/XCharts-Team/XCharts-PictorialBarChart)__ XCharts扩展图表:象形住图。订阅购买后可访问使用。 +- __[XCharts-Pie3DChart](https://github.com/XCharts-Team/XCharts-Pie3DChart)__ XCharts扩展图表:3D饼图。订阅购买后可访问使用。 +- __[XCharts-PyramidChart](https://github.com/XCharts-Team/XCharts-PyramidChart)__ XCharts扩展图表:3D金字塔。订阅购买后可访问使用。 +- __[XCharts-TreemapChart](https://github.com/XCharts-Team/XCharts-TreemapChart)__ XCharts扩展图表:矩形树图。订阅购买后可访问使用。 +- __[XCharts-SankeyChart](https://github.com/XCharts-Team/XCharts-SankeyChart)__ XCharts扩展图表:桑基图。订阅购买后可访问使用。 +- __[XCharts-Line3DChart](https://github.com/XCharts-Team/XCharts-Line3DChart)__ XCharts扩展图表:3D折线图。订阅购买后可访问使用。 +- __[XCharts-GraphChart](https://github.com/XCharts-Team/XCharts-GraphChart)__ XCharts扩展图表:关系图。订阅购买后可访问使用。 ## 分支 -| 分支 | 分支介绍 | -|--|--| -| [master](https://github.com/XCharts-Team/XCharts/tree/master) | XCharts3.0的开发分支。最新的修改和功能都先提交到`master`分支,稳定后后再从`master`分支`merge`到`3.0`分支,并发布`release`版本。| -| [3.0](https://github.com/XCharts-Team/XCharts/tree/3.0) | XCharts3.0的稳定分支。一般一个月一发布,`master`分支稳定后,`merge`到`3.0`分支,并发布`release`版本。| -| [2.0](https://github.com/XCharts-Team/XCharts/tree/2.0) | XCharts2.0的稳定分支。带Demo,目前基本不再维护,仅修改严重bug。| -| [2.0-upm](https://github.com/XCharts-Team/XCharts/tree/2.0-upm) | XCharts2.0的稳定UMP分支。不带Demo,只包含Package部分,不再维护。| -| [1.0](https://github.com/XCharts-Team/XCharts/tree/1.0) | XCharts1.0的稳定分支。带Demo,不再维护。| -| [1.0-upm](https://github.com/XCharts-Team/XCharts/tree/1.0-upm) | XCharts1.0的稳定UMP分支。不带Demo,不再维护。| - -## 注意 - -- `XCharts3.0` 不完全兼容 `XCharts2.0` 版本,升级`3.0`时,部分代码和配置可能需要重新调整。建议旧项目可以继续使用`XCharts2.0`,新项目推荐使用`XCharts3.0`。 -- `XCharts2.0` 进入维护阶段,后续只修复严重`bug`,原则上不再加新功能。 -- `XCharts` 理论上支持`Unity 5.6`及以上版本,但由于版本测试有限难免疏漏,发现问题可提`Issue`。 -- 本仓库只包含`XCharts`源码,不包含`Demo`示例部分。需要查看`Demo`示例源码请到[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)仓库。也可以在浏览器查看`WebGL`下的运行效果 [在线Demo](https://xcharts-team.github.io/examples/) 。 +- __[master](https://github.com/XCharts-Team/XCharts/tree/master)__ XCharts3.0的开发分支。最新的修改和功能都先提交到`master`分支,稳定后再发布`release`版本。 +- __[3.0](https://github.com/XCharts-Team/XCharts/tree/3.0)__ XCharts3.0的稳定分支。一般一个月一发布,`master`分支稳定后,`merge`到`3.0`分支,并发布`release`版本。 +- __[2.0](https://github.com/XCharts-Team/XCharts/tree/2.0)__ XCharts2.0的稳定分支。带Demo,目前基本不再维护,仅修改严重bug。 +- __[2.0-upm](https://github.com/XCharts-Team/XCharts/tree/2.0-upm)__ XCharts2.0的稳定UMP分支。不带Demo,只包含Package部分,不再维护。 +- __[1.0](https://github.com/XCharts-Team/XCharts/tree/1.0)__ XCharts1.0的稳定分支。带Demo,不再维护。 +- __[1.0-upm](https://github.com/XCharts-Team/XCharts/tree/1.0-upm)__ XCharts1.0的稳定UMP分支。不带Demo,不再维护。 ## 使用 @@ -133,24 +124,31 @@ - 更多细节,请看[【XCharts教程:5分钟上手教程】](Documentation~/zh/tutorial01.md)。 - 首次使用,建议先认真看一遍教程。 +## 注意 + +- __XCharts3.0不完全兼容XCharts2.0版本。__ 升级`3.0`时,部分代码和配置可能需要重新调整。建议旧项目可以继续使用`XCharts2.0`,新项目推荐使用`XCharts3.0`。 +- __XCharts2.0只维护不加新功能。__ `2.0`只修复严重`bug`,原则上不再加新功能。 +- __XCharts支持Unity 5.6及以上版本。__ 但由于版本测试有限难免疏漏,发现问题可提`Issue`。 +- __本仓库只包含XCharts源码,不包含Demo示例部分。__ 需要查看`Demo`示例源码请到[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)仓库。也可以在浏览器查看运行效果 [在线Demo](https://xcharts-team.github.io/examples/) 。 + ## FAQ -- `XCharts`可以免费使用吗? - 答:`XCharts`使用`MIT`协议,可以免费使用。也可以订阅`VIP`享受更多增值服务。 +- __XCharts可以免费使用吗?__ +`XCharts`使用`MIT`协议,可以免费使用。也可以订阅`VIP`享受更多增值服务。 -- `XCharts`支持代码动态添加和修改数据吗?支持从`Excel`或数据库中获取数据吗? - 答:`XCharts`提供了各种数据操作的接口,支持代码动态修改配置,添加和修改数据,但数据来源需要自己解析和获取,再调用`XCharts`的接口添加到图表。 +- __XCharts支持代码动态添加和修改数据吗?支持从`Excel`或数据库中获取数据吗?__ +`XCharts`提供了各种数据操作的接口,支持代码动态修改配置,添加和修改数据,但数据来源需要自己解析和获取,再调用`XCharts`的接口添加到图表。 -- `XCharts`除了用在`Unity`平台,还能用在`Winform`或`WPF`等平台吗? - 答:`XCharts`只支持在`Unity`平台使用。理论上任何支持`UGUI`的`Unity`版本都能运行`XCharts`。 +- __XCharts除了用在Unity平台,还能用在Winform或WPF等平台吗?__ +`XCharts`只支持在`Unity`平台使用。理论上任何支持`UGUI`的`Unity`版本都能运行`XCharts`。 -- 锯齿怎么解决?支持多大量级的数据? - 答:`XCharts`是基于`UGUI`实现的,所以`UGUI`中碰到的问题,在`XCharts`中也会存在。比如锯齿问题,比如`Mesh`顶点数超`65535`的问题。这两个问题的解决可参考[问答16](Documentation~/zh/faq.md)和[问答27](Documentation~/zh/faq.md)。 - 由于`Mesh`的`65535`顶点数的限制,目前`XCharts`的单条`Line`支持约`2万`的数据量,当然开启采样可以支持更多数据的绘制,但同时也会更消耗CPU。 +- __锯齿怎么解决?支持多大量级的数据?__ +`XCharts`是基于`UGUI`实现的,所以`UGUI`中碰到的问题,在`XCharts`中也会存在。比如锯齿问题,比如`Mesh`顶点数超`65535`的问题。这两个问题的解决可参考[问答16](Documentation~/zh/faq.md)和[问答27](Documentation~/zh/faq.md)。 +由于`Mesh`的`65535`顶点数的限制,目前`XCharts`的单条`Line`支持约`2万`的数据量,当然开启采样可以支持更多数据的绘制,但同时也会更消耗CPU。 ## 日志 -- [更新日志](Documentation~/zh/changelog.md) +- 各版本的详细更新日志请查看 [更新日志](Documentation~/zh/changelog.md) ## Licenses diff --git a/Runtime/Internal/XChartsMgr.cs b/Runtime/Internal/XChartsMgr.cs index 0e2f8b15..5fccb8ae 100644 --- a/Runtime/Internal/XChartsMgr.cs +++ b/Runtime/Internal/XChartsMgr.cs @@ -21,8 +21,8 @@ namespace XCharts.Runtime [ExecuteInEditMode] public static class XChartsMgr { - public static readonly string version = "3.11.0-preview2"; - public static readonly int versionDate = 20240611; + public static readonly string version = "3.11.0"; + public static readonly int versionDate = 20240616; public static string fullVersion { get { return version + "-" + versionDate; } } internal static List chartList = new List(); diff --git a/package.json b/package.json index 677fbe90..b71ac975 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "displayName": "XCharts", "author": "monitor1394", "license": "MIT", - "version": "3.11.0-preview2", - "date": "20240611", - "checkdate": "20240611", + "version": "3.11.0", + "date": "20240616", + "checkdate": "20240616", "unity": "2018.3", "description": "A charting and data visualization library for Unity. Support line chart, bar chart, pie chart, radar chart, scatter chart, heatmap chart, ring chart, candlestick chart, polar chart and parallel coordinates.", "keywords": [ From 33b7e5c1a4a11b29bb9e06e511112acb801c50a1 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 16 Jun 2024 19:21:25 +0800 Subject: [PATCH 36/37] 3.11.0 --- Runtime/Utilities/DateTimeUtil.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Runtime/Utilities/DateTimeUtil.cs b/Runtime/Utilities/DateTimeUtil.cs index c47ae94d..82e5b441 100644 --- a/Runtime/Utilities/DateTimeUtil.cs +++ b/Runtime/Utilities/DateTimeUtil.cs @@ -6,7 +6,11 @@ namespace XCharts.Runtime { public static class DateTimeUtil { +#if UNITY_2018_3_OR_NEWER + private static readonly DateTime k_DateTime1970 = TimeZoneInfo.ConvertTimeFromUtc(new DateTime(1970, 1, 1), TimeZoneInfo.Local); +#else private static readonly DateTime k_DateTime1970 = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); +#endif public static readonly int ONE_SECOND = 1; public static readonly int ONE_MINUTE = ONE_SECOND * 60; public static readonly int ONE_HOUR = ONE_MINUTE * 60; From 3b7e8184b080d231e98e9e93d17aca3e0c3b01c0 Mon Sep 17 00:00:00 2001 From: monitor1394 Date: Sun, 16 Jun 2024 21:59:31 +0800 Subject: [PATCH 37/37] 3.11.0 --- Documentation~/en/changelog.md | 11 ++++++----- Documentation~/zh/changelog.md | 17 +++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Documentation~/en/changelog.md b/Documentation~/en/changelog.md index f4f3f44c..c1591083 100644 --- a/Documentation~/en/changelog.md +++ b/Documentation~/en/changelog.md @@ -94,6 +94,7 @@ Changelog Details: * (2024.05.29) Added support for 3D coordinate systems to category axes * (2024.05.19) Optimized editing performance in `Editor` * (2024.05.09) Added utility class `JsonUtil` +* (2024.05.01) Fixed the issue where `Tooltip` caused garbage collection (GC) on every frame (#311) (by @stefanbursuc) * (2024.04.23) Fixed chart exception issue after multiple calls to `ConvertXYAxis()` * (2024.04.22) Fixed potential incorrect retrieval of `GridCoord` when `DataZoom` controls multiple axes (#317) * (2024.04.22) Added 3D coordinate system @@ -236,7 +237,7 @@ Log details: * (2023.08.22) Fixed `Bar` display hidden drawing performance exception * (2023.08.22) Improved Zebra histogram rendering performance (#276) * (2023.08.16) Added Daemon daemon to resolve an error after TMP is enabled locally -* (2023.08.15) Fixed `Data` displaying axes incorrectly when data is between -1 and 1 (#273) (by **Ambitroc**) +* (2023.08.15) Fixed `Data` displaying axes incorrectly when data is between -1 and 1 (#273) (b y@Ambitroc) * (2023.08.14) Fixed `XCharts` updating error after` TextMeshPro `and` NewInputSystem `are enabled locally (#272) * (2023.08.12) Fixed `Chart` error when deleted at runtime (#269) * (2023.08.11) Fixed an issue where data could not be added when DataZoom was enabled @@ -277,7 +278,7 @@ Log details: * (2022.06.08) Release v3.7.0 * (2023.06.04) Added `HelpDoc` help document skip -* (2023.05.30) Fixed Serie name with `_` line causing `Legend` to not fire (#252) (by **svr2kos2**) +* (2023.05.30) Fixed Serie name with `_` line causing `Legend` to not fire (#252) (by @svr2kos2) * (2023.05.10) Added `MinMaxAuto` range type for `Axis` * (2023.05.10) Added support for `Clip` for `Line` * (2023.05.04) Fixed `Axis` setting` CeilRate `not taking effect in range -1 to 1 @@ -296,9 +297,9 @@ Log details: * (2023.04.01) Release `v3.6.0` version * (2023.03.14) Fix for Tooltip's `titleFormater` setting `{b}` may not take effect -* (2023.03.14) Fix for `BarChart` not drawing bar background when data is 0 (#250) (by **Ambitroc**) +* (2023.03.14) Fix for `BarChart` not drawing bar background when data is 0 (#250) (by @Ambitroc) * (2023.03.12) Added `LabelStyle` `autoRotate` to set automatic rotation of angled vertical text -* (2023.03.10) Added `VR` and other non-mouse input for Point location acquisition (#248) (by **Ambitroc**) +* (2023.03.10) Added `VR` and other non-mouse input for Point location acquisition (#248) (by @Ambitroc) * (2023.03.09) Adds callbacks to Chart's `onSerieClick`, `onSerieDown`, `onSerieEnter` and `onSerieExit` * (2023.03.09) Fixed click-check offset for `Pie` not taking effect * (2023.03.04) Added Positions for Legend to customize legend positions @@ -312,7 +313,7 @@ Log details: * (2023.02.02) Fixed bug where datazoom xaxis label could be displayed off-chart when datazoom is turned on * (2023.02.02) Optimizes the `ignore` setting of `SerieData` to ignore data * (2023.02.01) Fix `XChartsMgr.ContainsChart()` interface exception -* (2023.01.31) Added support for `InputSystem` (#242) (by **Bian-Sh**) +* (2023.01.31) Added support for `InputSystem` (#242) (by @Bian-Sh) * (2023.01.11) Fixed chart not refreshing after removing Component from Inspector (#241) * (2023.01.06) Fixed bug with `Pie` displaying abnormal Label when the last few values are 0 (#240) * (2023.01.03) deletes serie `MarkColor` and adds ItemStyle `MarkColor` diff --git a/Documentation~/zh/changelog.md b/Documentation~/zh/changelog.md index 5e4132a5..238bc2c0 100644 --- a/Documentation~/zh/changelog.md +++ b/Documentation~/zh/changelog.md @@ -99,6 +99,7 @@ slug: /changelog * (2024.05.29) 增加`3D`坐标系对类目轴的支持 * (2024.05.19) 优化`Editor`下的编辑性能 * (2024.05.09) 增加`JsonUtil`工具类 +* (2024.05.01) 修复`Tooltip`每帧产生GC的问题 (#311) (by @stefanbursuc) * (2024.04.23) 修复`ConvertXYAxis()`多次调用后图表异常的问题 * (2024.04.22) 修复`DataZoom`控制多个轴时的`GridCoord`获取可能不正确的问题 (#317) * (2024.04.22) 增加`3D`坐标系 @@ -241,7 +242,7 @@ slug: /changelog * (2023.08.22) 修复`Bar`显示隐藏时绘制表现异常的问题 * (2023.08.22) 优化`Zebra`斑马柱图的绘制表现 (#276) * (2023.08.16) 增加`Daemon`守护程序,解决本地开启TMP后更新版本报错问题 -* (2023.08.15) 修复`Data`数据在-1到1之间时坐标轴显示错误的问题 (#273) (by **Ambitroc**) +* (2023.08.15) 修复`Data`数据在-1到1之间时坐标轴显示错误的问题 (#273) (by @Ambitroc) * (2023.08.14) 修复`XCharts`本地开启`TextMeshPro`和 `NewInputSystem`后更新版本会报错的问题 (#272) * (2023.08.12) 修复`Chart`在运行时被删除时会异常报错的问题 (#269) * (2023.08.11) 修复`DataZoom`开启时可能会导致无法添加数据的问题 @@ -282,7 +283,7 @@ slug: /changelog * (2023.06.08) 发布`v3.7.0`版本 * (2023.06.04) 增加`HelpDoc`帮助文档跳转 -* (2023.05.30) 修复`Serie`的名字带`_`线导致`Legend`无法触发的问题 (#259) (by **svr2kos2**) +* (2023.05.30) 修复`Serie`的名字带`_`线导致`Legend`无法触发的问题 (#259) (by @svr2kos2) * (2023.05.10) 增加`Axis`的`MinMaxAuto`范围类型 * (2023.05.10) 增加`Line`对`Clip`的支持 * (2023.05.04) 优化`Axis`在-1到1范围时设置`CeilRate`不生效的问题 @@ -301,9 +302,9 @@ slug: /changelog 版本要点: -* 增加`InputSystem`支持 (by **Bian-Sh**) -* 增加官网[在线示例](https://xcharts-team.github.io/examples/)多版本支持 (by **SHL-COOL**) -* 完善对`VR`的支持 (by **Ambitroc**) +* 增加`InputSystem`支持 (by @Bian-Sh) +* 增加官网[在线示例](https://xcharts-team.github.io/examples/)多版本支持 (by @SHL-COOL) +* 完善对`VR`的支持 (by @Ambitroc) * 增加`UITable`,`UIStatistic`等[扩展UI组件](https://xcharts-team.github.io/docs/ui) * 增加`ItemStyle`的`MarkColor` * 增加通配符`{h}`的支持 @@ -319,9 +320,9 @@ slug: /changelog * (2023.04.01) 发布`v3.6.0`版本 * (2023.03.14) 修复`Tooltip`的`titleFormater`设置`{b}`可能不生效的问题 -* (2023.03.14) 修复`BarChart`在数据为0时不绘制柱条背景的问题 (#250) (by **Ambitroc**) +* (2023.03.14) 修复`BarChart`在数据为0时不绘制柱条背景的问题 (#250) (by @Ambitroc) * (2023.03.12) 增加`LabelStyle`的`autoRotate`可设置有角度的竖版文本的自动旋转 -* (2023.03.10) 增加`VR`等其他非鼠标输入方式的Point位置获取 (#248) (by **Ambitroc**) +* (2023.03.10) 增加`VR`等其他非鼠标输入方式的Point位置获取 (#248) (by @Ambitroc) * (2023.03.09) 增加`Chart`的`onSerieClick`,`onSerieDown`,`onSerieEnter`和`onSerieExit`回调 * (2023.03.09) 修复`Pie`的点击选中偏移不生效的问题 * (2023.03.04) 增加`Legend`的`Positions`可自定义图例的位置 @@ -335,7 +336,7 @@ slug: /changelog * (2023.02.02) 修复`DataZoom`开启时`X轴`的`Label`可能会显示在图表外的问题 * (2023.02.02) 优化`SerieData`的`ignore`设置时的忽略数据判断 * (2023.02.01) 修复`XChartsMgr.ContainsChart()`接口异常 -* (2023.01.31) 增加`InputSystem`的支持 (#242) (by **Bian-Sh**) +* (2023.01.31) 增加`InputSystem`的支持 (#242) (by @Bian-Sh) * (2023.01.11) 修复`Inspector`上移除`Component`后图表没有及时刷新的问题 (#241) * (2023.01.06) 修复`Pie`在最后的几个数据都为0时`Label`显示不正常的问题 (#240) * (2023.01.03) 删除`Serie`的`MarkColor`,增加`ItemStyle`的`MarkColor`