mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 21:38:49 +00:00
增加Tooltip的triggerOn指定触发条件
This commit is contained in:
@@ -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()<br/>reset chart status. When some parameters are set, due to the animation effect, the chart status may not be correct. |
|
|ResetChartStatus()|v3.10.0|public void ResetChartStatus()<br/>reset chart status. When some parameters are set, due to the animation effect, the chart status may not be correct. |
|
||||||
|ResetDataIndex()||public bool ResetDataIndex(int serieIndex)<br/>重置serie的数据项索引。避免数据项索引异常。 |
|
|ResetDataIndex()||public bool ResetDataIndex(int serieIndex)<br/>重置serie的数据项索引。避免数据项索引异常。 |
|
||||||
|SetBasePainterMaterial()||public void SetBasePainterMaterial(Material material)<br/>设置Base Painter的材质球 |
|
|SetBasePainterMaterial()||public void SetBasePainterMaterial(Material material)<br/>设置Base Painter的材质球 |
|
||||||
|
|SetInsertDataToHead()|v3.11.0|public void SetInsertDataToHead(bool insertDataToHead)<br/>set insert data to head. |
|
||||||
|SetMaxCache()||public void SetMaxCache(int maxCache)<br/>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 |
|
|SetMaxCache()||public void SetMaxCache(int maxCache)<br/>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 |
|
||||||
|SetPainterActive()||public void SetPainterActive(int index, bool flag)|
|
|SetPainterActive()||public void SetPainterActive(int index, bool flag)|
|
||||||
|SetSerieActive()||public void SetSerieActive(int serieIndex, bool active)<br/>Whether to show serie. |
|
|SetSerieActive()||public void SetSerieActive(int serieIndex, bool active)<br/>Whether to show serie. |
|
||||||
@@ -3093,6 +3094,7 @@ Tooltip component.
|
|||||||
|
|
||||||
|public method|since|description|
|
|public method|since|description|
|
||||||
|--|--|--|
|
|--|--|--|
|
||||||
|
|onClickIndex||public System.Action<int> onClickIndex<br/>the callback of tooltip click index. |
|
||||||
|AddSerieDataIndex()||public void AddSerieDataIndex(int serieIndex, int dataIndex)|
|
|AddSerieDataIndex()||public void AddSerieDataIndex(int serieIndex, int dataIndex)|
|
||||||
|ClearComponentDirty()||public override void ClearComponentDirty()|
|
|ClearComponentDirty()||public override void ClearComponentDirty()|
|
||||||
|ClearData()||public override void ClearData()|
|
|ClearData()||public override void ClearData()|
|
||||||
|
|||||||
@@ -2302,6 +2302,7 @@ Tooltip component.
|
|||||||
|show|true||Whether to show the tooltip component.
|
|show|true||Whether to show the tooltip component.
|
||||||
|type|||Indicator type.<br/>`Tooltip.Type`:<br/>- `Line`: line indicator.<br/>- `Shadow`: shadow crosshair indicator.<br/>- `None`: no indicator displayed.<br/>- `Corss`: crosshair indicator, which is actually the shortcut of enable two axisPointers of two orthometric axes.<br/>- `Auto`: Auto select indicator according to serie type.<br/>|
|
|type|||Indicator type.<br/>`Tooltip.Type`:<br/>- `Line`: line indicator.<br/>- `Shadow`: shadow crosshair indicator.<br/>- `None`: no indicator displayed.<br/>- `Corss`: crosshair indicator, which is actually the shortcut of enable two axisPointers of two orthometric axes.<br/>- `Auto`: Auto select indicator according to serie type.<br/>|
|
||||||
|trigger|||Type of triggering.<br/>`Tooltip.Trigger`:<br/>- `Item`: Triggered by data item, which is mainly used for charts that don't have a category axis like scatter charts or pie charts.<br/>- `Axis`: Triggered by axes, which is mainly used for charts that have category axes, like bar charts or line charts.<br/>- `None`: Trigger nothing.<br/>- `Auto`: Auto select trigger according to serie type.<br/>|
|
|trigger|||Type of triggering.<br/>`Tooltip.Trigger`:<br/>- `Item`: Triggered by data item, which is mainly used for charts that don't have a category axis like scatter charts or pie charts.<br/>- `Axis`: Triggered by axes, which is mainly used for charts that have category axes, like bar charts or line charts.<br/>- `None`: Trigger nothing.<br/>- `Auto`: Auto select trigger according to serie type.<br/>|
|
||||||
|
|triggerOn||v3.11.0|Condition of trigger tooltip.<br/>`Tooltip.TriggerOn`:<br/>- `MouseMove`: Trigger when mouse move.<br/>- `Click`: Trigger when mouse click.<br/>|
|
||||||
|position||v3.3.0|Type of position.<br/>`Tooltip.Position`:<br/>- `Auto`: Auto. The mobile platform is displayed at the top, and the non-mobile platform follows the mouse position.<br/>- `Custom`: Custom. Fully customize display position (x,y).<br/>- `FixedX`: Just fix the coordinate X. Y follows the mouse position.<br/>- `FixedY`: <br/>|
|
|position||v3.3.0|Type of position.<br/>`Tooltip.Position`:<br/>- `Auto`: Auto. The mobile platform is displayed at the top, and the non-mobile platform follows the mouse position.<br/>- `Custom`: Custom. Fully customize display position (x,y).<br/>- `FixedX`: Just fix the coordinate X. Y follows the mouse position.<br/>- `FixedY`: <br/>|
|
||||||
|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}.<br/> {.} is the dot of the corresponding color of a Serie that is currently indicated or whose index is 0.<br/> {a} is the series name of the serie that is currently indicated or whose index is 0.<br/> {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).<br/> {c} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0.<br/> {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.<br/> {e} is the name of the data item serieData that is currently indicated or whose index is 0.<br/> {f} is sum of data.<br/> {y} is category value of y axis.<br/> {.1} represents a dot from serie corresponding color that specifies index as 1.<br/> 1 in {a1}, {b1}, {c1} represents a serie that specifies an index of 1.<br/> {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).<br/> {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).<br/> {d1:2: F2} indicates that a formatted string with a value specified separately is F2 (numericFormatter is used when numericFormatter is not specified).<br/> {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 ).<br/> Example: "{a}, {c}", "{a1}, {c1: f1}", "{a1}, {c1:0: f1}", "{a1} : {c1:1-1: f1}"<br/>
|
|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}.<br/> {.} is the dot of the corresponding color of a Serie that is currently indicated or whose index is 0.<br/> {a} is the series name of the serie that is currently indicated or whose index is 0.<br/> {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).<br/> {c} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0.<br/> {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.<br/> {e} is the name of the data item serieData that is currently indicated or whose index is 0.<br/> {f} is sum of data.<br/> {y} is category value of y axis.<br/> {.1} represents a dot from serie corresponding color that specifies index as 1.<br/> 1 in {a1}, {b1}, {c1} represents a serie that specifies an index of 1.<br/> {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).<br/> {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).<br/> {d1:2: F2} indicates that a formatted string with a value specified separately is F2 (numericFormatter is used when numericFormatter is not specified).<br/> {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 ).<br/> Example: "{a}, {c}", "{a1}, {c1: f1}", "{a1}, {c1:0: f1}", "{a1} : {c1:1-1: f1}"<br/>
|
||||||
|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}. <br /> {.} is the dot of the corresponding color of serie currently indicated or index 0. <br /> {a} is the series name name of serie currently indicated or index 0. <br /> {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). <br /> {c} is the value of the serie y-dimension (dimesion is 1) currently indicated or index is 0. <br /> {d} is the serie y-dimensional (dimesion 1) percentage value of the currently indicated or index 0, note without the % sign. <br /> {e} is the name of the serie data item serieData currently indicated or whose index is 0. <br /> {h} is the hexadecimal color value of serieData for the serie data item currently indicated or index 0. <br /> {f} is the sum of data. <br /> {g} indicates the total number of data. <br /> {y} is category value of y axis. <br /> {.1} represents a dot of the corresponding color with serie specified as index 1. <br /> The 1 in {a1}, {b1}, {c1} represents serie where index is specified as 1. <br /> {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). <br /> {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). <br /> {d1:2:f2} indicates that a format string with a single value is f2 (numericFormatter is used if no value is specified). <br /> {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). <br /> 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}. <br /> {.} is the dot of the corresponding color of serie currently indicated or index 0. <br /> {a} is the series name name of serie currently indicated or index 0. <br /> {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). <br /> {c} is the value of the serie y-dimension (dimesion is 1) currently indicated or index is 0. <br /> {d} is the serie y-dimensional (dimesion 1) percentage value of the currently indicated or index 0, note without the % sign. <br /> {e} is the name of the serie data item serieData currently indicated or whose index is 0. <br /> {h} is the hexadecimal color value of serieData for the serie data item currently indicated or index 0. <br /> {f} is the sum of data. <br /> {g} indicates the total number of data. <br /> {y} is category value of y axis. <br /> {.1} represents a dot of the corresponding color with serie specified as index 1. <br /> The 1 in {a1}, {b1}, {c1} represents serie where index is specified as 1. <br /> {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). <br /> {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). <br /> {d1:2:f2} indicates that a format string with a single value is f2 (numericFormatter is used if no value is specified). <br /> {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). <br /> example: "{a}, {c}", "{a1}, {c1: f1}", "{a1}, {c1:0: f1}", "{a1}, {c1:1-1: f1}"
|
||||||
|
|||||||
@@ -835,6 +835,7 @@ slug: /api
|
|||||||
|ResetChartStatus()|v3.10.0|public void ResetChartStatus()<br/>重置图表状态。当设置某些参数后,由于动画影响,可能导致图表状态不正确,此时可以调用该接口重置图表状态。 |
|
|ResetChartStatus()|v3.10.0|public void ResetChartStatus()<br/>重置图表状态。当设置某些参数后,由于动画影响,可能导致图表状态不正确,此时可以调用该接口重置图表状态。 |
|
||||||
|ResetDataIndex()||public bool ResetDataIndex(int serieIndex)<br/>重置serie的数据项索引。避免数据项索引异常。 |
|
|ResetDataIndex()||public bool ResetDataIndex(int serieIndex)<br/>重置serie的数据项索引。避免数据项索引异常。 |
|
||||||
|SetBasePainterMaterial()||public void SetBasePainterMaterial(Material material)<br/>设置Base Painter的材质球 |
|
|SetBasePainterMaterial()||public void SetBasePainterMaterial(Material material)<br/>设置Base Painter的材质球 |
|
||||||
|
|SetInsertDataToHead()|v3.11.0|public void SetInsertDataToHead(bool insertDataToHead)<br/>设置数据插入到头部。 |
|
||||||
|SetMaxCache()||public void SetMaxCache(int maxCache)<br/>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 |
|
|SetMaxCache()||public void SetMaxCache(int maxCache)<br/>设置可缓存的最大数据量。当数据量超过该值时,会自动删除第一个值再加入最新值。 |
|
||||||
|SetPainterActive()||public void SetPainterActive(int index, bool flag)|
|
|SetPainterActive()||public void SetPainterActive(int index, bool flag)|
|
||||||
|SetSerieActive()||public void SetSerieActive(int serieIndex, bool active)<br/>设置指定系列是否显示。 |
|
|SetSerieActive()||public void SetSerieActive(int serieIndex, bool active)<br/>设置指定系列是否显示。 |
|
||||||
@@ -3093,6 +3094,7 @@ Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种
|
|||||||
|
|
||||||
|API|版本|描述|
|
|API|版本|描述|
|
||||||
|--|--|--|
|
|--|--|--|
|
||||||
|
|onClickIndex||public System.Action<int> onClickIndex<br/>Tooltip为Click触发时,点击的X轴索引的回调。 |
|
||||||
|AddSerieDataIndex()||public void AddSerieDataIndex(int serieIndex, int dataIndex)|
|
|AddSerieDataIndex()||public void AddSerieDataIndex(int serieIndex, int dataIndex)|
|
||||||
|ClearComponentDirty()||public override void ClearComponentDirty()|
|
|ClearComponentDirty()||public override void ClearComponentDirty()|
|
||||||
|ClearData()||public override void ClearData()|
|
|ClearData()||public override void ClearData()|
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ slug: /changelog
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2024.03.20) 增加`Tooltip`的`triggerOn`设置触发条件
|
||||||
|
|
||||||
## v3.10.2
|
## v3.10.2
|
||||||
|
|
||||||
* (2024.03.11) 发布`v3.10.2`版本
|
* (2024.03.11) 发布`v3.10.2`版本
|
||||||
|
|||||||
@@ -2231,6 +2231,7 @@ Serie的状态样式。Serie的状态有正常,高亮,淡出,选中四种
|
|||||||
|show|true||是否显示提示框组件。
|
|show|true||是否显示提示框组件。
|
||||||
|type|||提示框指示器类型。<br/>`Tooltip.Type`:<br/>- `Line`: 直线指示器<br/>- `Shadow`: 阴影指示器<br/>- `None`: 无指示器<br/>- `Corss`: 十字准星指示器。坐标轴显示Label和交叉线。<br/>- `Auto`: 根据serie的类型自动选择显示指示器。<br/>|
|
|type|||提示框指示器类型。<br/>`Tooltip.Type`:<br/>- `Line`: 直线指示器<br/>- `Shadow`: 阴影指示器<br/>- `None`: 无指示器<br/>- `Corss`: 十字准星指示器。坐标轴显示Label和交叉线。<br/>- `Auto`: 根据serie的类型自动选择显示指示器。<br/>|
|
||||||
|trigger|||触发类型。<br/>`Tooltip.Trigger`:<br/>- `Item`: 数据项图形触发,主要在散点图,饼图等无类目轴的图表中使用。<br/>- `Axis`: 坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用。<br/>- `None`: 什么都不触发。<br/>- `Auto`: 根据serie的类型自动选择触发类型。<br/>|
|
|trigger|||触发类型。<br/>`Tooltip.Trigger`:<br/>- `Item`: 数据项图形触发,主要在散点图,饼图等无类目轴的图表中使用。<br/>- `Axis`: 坐标轴触发,主要在柱状图,折线图等会使用类目轴的图表中使用。<br/>- `None`: 什么都不触发。<br/>- `Auto`: 根据serie的类型自动选择触发类型。<br/>|
|
||||||
|
|triggerOn||v3.11.0|触发条件。<br/>`Tooltip.TriggerOn`:<br/>- `MouseMove`: 鼠标移动时触发。<br/>- `Click`: 鼠标点击时触发。<br/>|
|
||||||
|position||v3.3.0|显示位置类型。<br/>`Tooltip.Position`:<br/>- `Auto`: 自适应。移动平台靠顶部显示,非移动平台跟随鼠标位置。<br/>- `Custom`: 自定义。完全自定义显示位置(x,y)。<br/>- `FixedX`: 只固定坐标X。Y跟随鼠标位置。<br/>- `FixedY`: <br/>|
|
|position||v3.3.0|显示位置类型。<br/>`Tooltip.Position`:<br/>- `Auto`: 自适应。移动平台靠顶部显示,非移动平台跟随鼠标位置。<br/>- `Custom`: 自定义。完全自定义显示位置(x,y)。<br/>- `FixedX`: 只固定坐标X。Y跟随鼠标位置。<br/>- `FixedY`: <br/>|
|
||||||
|itemFormatter|||提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 换行。用|来表示多个列的分隔。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。<br/> {i}或-表示忽略当前项。 {.}为当前所指示的serie或数据项的对应颜色的圆点。<br/> {a}为当前所指示的serie或数据项的系列名name。<br/> {b}为当前所指示的serie或数据项的数据项serieData的name,或者类目值(如折线图的X轴)。<br/> {c}为当前所指示的serie或数据项的y维(dimesion为1)的数值。<br/> {d}为当前所指示的serie或数据项的y维(dimesion为1)百分比值,注意不带%号。<br/> {e}为当前所指示的serie或数据项的数据项serieData的name。<br/> {f}为当前所指示的serie的默认维度的数据总和。<br/> {g}为当前所指示的serie的数据总个数。<br/> {h}为当前所指示的serie的十六进制颜色值。<br/> {y}为当前所指示的serie的y轴的类目值。<br/> {c0}表示当前数据项维度为0的数据。<br/> {c1}表示当前数据项维度为1的数据。<br/> {d3}表示维度3的数据的百分比。它的分母是默认维度(一般是1维度)数据。<br/> |表示多个列的分隔。<br/> 示例:"{i}", "{.}|{a}|{c}", "{.}|{b}|{c2:f2}", "{.}|{b}|{y}"
|
|itemFormatter|||提示框单个serie或数据项内容的字符串模版格式器。支持用 \n 换行。用|来表示多个列的分隔。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。<br/> {i}或-表示忽略当前项。 {.}为当前所指示的serie或数据项的对应颜色的圆点。<br/> {a}为当前所指示的serie或数据项的系列名name。<br/> {b}为当前所指示的serie或数据项的数据项serieData的name,或者类目值(如折线图的X轴)。<br/> {c}为当前所指示的serie或数据项的y维(dimesion为1)的数值。<br/> {d}为当前所指示的serie或数据项的y维(dimesion为1)百分比值,注意不带%号。<br/> {e}为当前所指示的serie或数据项的数据项serieData的name。<br/> {f}为当前所指示的serie的默认维度的数据总和。<br/> {g}为当前所指示的serie的数据总个数。<br/> {h}为当前所指示的serie的十六进制颜色值。<br/> {y}为当前所指示的serie的y轴的类目值。<br/> {c0}表示当前数据项维度为0的数据。<br/> {c1}表示当前数据项维度为1的数据。<br/> {d3}表示维度3的数据的百分比。它的分母是默认维度(一般是1维度)数据。<br/> |表示多个列的分隔。<br/> 示例:"{i}", "{.}|{a}|{c}", "{.}|{b}|{c2:f2}", "{.}|{b}|{y}"
|
||||||
|titleFormatter|||提示框标题内容的字符串模版格式器。支持用 \n 换行。可以单独设置占位符{i}表示忽略不显示title。 模板变量有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。<br/> {.}为当前所指示或index为0的serie的对应颜色的圆点。<br/> {a}为当前所指示或index为0的serie的系列名name。<br/> {b}为当前所指示或index为0的serie的数据项serieData的name,或者类目值(如折线图的X轴)。<br/> {c}为当前所指示或index为0的serie的y维(dimesion为1)的数值。<br/> {d}为当前所指示或index为0的serie的y维(dimesion为1)百分比值,注意不带%号。<br/> {e}为当前所指示或index为0的serie的数据项serieData的name。<br/> {h}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。<br/> {f}为数据总和。<br/> {g}为数据总个数。<br/> {f}为value所对应的y轴的类目值。<br/> {.1}表示指定index为1的serie对应颜色的圆点。<br/> {a1}、{b1}、{c1}中的1表示指定index为1的serie。<br/> {c1:2}表示索引为1的serie的当前指示数据项的第3个数据(一个数据项有多个数据,index为2表示第3个数据)。<br/> {c1:2-2}表示索引为1的serie的第3个数据项的第3个数据(也就是要指定第几个数据项时必须要指定第几个数据)。<br/> {d1:2:f2}表示单独指定了数值的格式化字符串为f2(不指定时用numericFormatter)。<br/> {d:0.##} 表示单独指定了数值的格式化字符串为 0.## (用于百分比,保留2位有效数同时又能避免使用 f2 而出现的类似于"100.00%"的情况 )。<br/> 示例:"{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}。<br/> {.}为当前所指示或index为0的serie的对应颜色的圆点。<br/> {a}为当前所指示或index为0的serie的系列名name。<br/> {b}为当前所指示或index为0的serie的数据项serieData的name,或者类目值(如折线图的X轴)。<br/> {c}为当前所指示或index为0的serie的y维(dimesion为1)的数值。<br/> {d}为当前所指示或index为0的serie的y维(dimesion为1)百分比值,注意不带%号。<br/> {e}为当前所指示或index为0的serie的数据项serieData的name。<br/> {h}为当前所指示或index为0的serie的数据项serieData的十六进制颜色值。<br/> {f}为数据总和。<br/> {g}为数据总个数。<br/> {f}为value所对应的y轴的类目值。<br/> {.1}表示指定index为1的serie对应颜色的圆点。<br/> {a1}、{b1}、{c1}中的1表示指定index为1的serie。<br/> {c1:2}表示索引为1的serie的当前指示数据项的第3个数据(一个数据项有多个数据,index为2表示第3个数据)。<br/> {c1:2-2}表示索引为1的serie的第3个数据项的第3个数据(也就是要指定第几个数据项时必须要指定第几个数据)。<br/> {d1:2:f2}表示单独指定了数值的格式化字符串为f2(不指定时用numericFormatter)。<br/> {d:0.##} 表示单独指定了数值的格式化字符串为 0.## (用于百分比,保留2位有效数同时又能避免使用 f2 而出现的类似于"100.00%"的情况 )。<br/> 示例:"{a}:{c}"、"{a1}:{c1:f1}"、"{a1}:{c1:0:f1}"、"{a1}:{c1:1-1:f1}"
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace XCharts.Editor
|
|||||||
++EditorGUI.indentLevel;
|
++EditorGUI.indentLevel;
|
||||||
PropertyField("m_Type");
|
PropertyField("m_Type");
|
||||||
PropertyField("m_Trigger");
|
PropertyField("m_Trigger");
|
||||||
|
PropertyField("m_TriggerOn");
|
||||||
PropertyField("m_Position");
|
PropertyField("m_Position");
|
||||||
PropertyField("m_FixedX");
|
PropertyField("m_FixedX");
|
||||||
PropertyField("m_FixedY");
|
PropertyField("m_FixedY");
|
||||||
|
|||||||
@@ -17,24 +17,52 @@ namespace XCharts.Example
|
|||||||
public bool loopUpdate = false;
|
public bool loopUpdate = false;
|
||||||
public float loopUpadteTime = 1f;
|
public float loopUpadteTime = 1f;
|
||||||
public int maxCache = 0;
|
public int maxCache = 0;
|
||||||
|
public bool insertDataToHead = false;
|
||||||
|
|
||||||
BaseChart chart;
|
BaseChart chart;
|
||||||
float lastAddTime;
|
float lastAddTime;
|
||||||
float lastUpdateTime;
|
float lastUpdateTime;
|
||||||
int dataCount;
|
int dataCount;
|
||||||
|
|
||||||
|
int lastMaxCache = 0;
|
||||||
|
bool lastInsertDataToHead = false;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
chart = gameObject.GetComponent<BaseChart>();
|
chart = gameObject.GetComponent<BaseChart>();
|
||||||
|
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);
|
chart.SetMaxCache(maxCache);
|
||||||
}
|
}
|
||||||
dataCount = chart.GetSerie(0).dataCount;
|
|
||||||
|
void SetInsertDataToHead(bool insertDataToHead)
|
||||||
|
{
|
||||||
|
foreach (var serie in chart.series)
|
||||||
|
serie.insertDataToHead = insertDataToHead;
|
||||||
|
|
||||||
|
var coms = chart.GetChartComponents<XAxis>();
|
||||||
|
if (coms != null)
|
||||||
|
{
|
||||||
|
foreach (var com in coms)
|
||||||
|
{
|
||||||
|
var axis = com as XAxis;
|
||||||
|
if (axis.type == Axis.AxisType.Category)
|
||||||
|
{
|
||||||
|
axis.insertDataToHead = insertDataToHead;
|
||||||
|
Debug.LogError("axis:" + axis + "," + insertDataToHead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
@@ -51,6 +79,16 @@ namespace XCharts.Example
|
|||||||
{
|
{
|
||||||
chart.ClearData();
|
chart.ClearData();
|
||||||
}
|
}
|
||||||
|
if (lastMaxCache != maxCache)
|
||||||
|
{
|
||||||
|
lastMaxCache = maxCache;
|
||||||
|
SetMaxCache(maxCache);
|
||||||
|
}
|
||||||
|
if (lastInsertDataToHead != insertDataToHead)
|
||||||
|
{
|
||||||
|
lastInsertDataToHead = insertDataToHead;
|
||||||
|
SetInsertDataToHead(insertDataToHead);
|
||||||
|
}
|
||||||
lastAddTime += Time.deltaTime;
|
lastAddTime += Time.deltaTime;
|
||||||
if (loopAdd && lastAddTime >= loopAddTime)
|
if (loopAdd && lastAddTime >= loopAddTime)
|
||||||
{
|
{
|
||||||
@@ -84,14 +122,8 @@ namespace XCharts.Example
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
AddXAxisData();
|
||||||
var xAxis = chart.GetChartComponent<XAxis>();
|
var xAxis = chart.GetChartComponent<XAxis>();
|
||||||
if (xAxis != null)
|
|
||||||
{
|
|
||||||
if (xAxis.type == Axis.AxisType.Category)
|
|
||||||
{
|
|
||||||
chart.AddXAxisData("x" + (xAxis.GetAddedDataCount() + 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (var serie in chart.series)
|
foreach (var serie in chart.series)
|
||||||
{
|
{
|
||||||
AddSerieRandomData(serie, xAxis);
|
AddSerieRandomData(serie, xAxis);
|
||||||
@@ -99,6 +131,19 @@ namespace XCharts.Example
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddXAxisData()
|
||||||
|
{
|
||||||
|
var xAxes = chart.GetChartComponents<XAxis>();
|
||||||
|
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()
|
void UpdateData()
|
||||||
{
|
{
|
||||||
foreach (var serie in chart.series)
|
foreach (var serie in chart.series)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
namespace XCharts.Runtime
|
namespace XCharts.Runtime
|
||||||
{
|
{
|
||||||
@@ -16,8 +17,29 @@ namespace XCharts.Runtime
|
|||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
UpdateAxisMinMaxValue(component.index, component);
|
UpdateAxisMinMaxValue(component.index, component);
|
||||||
|
if (!chart.isTriggerOnClick)
|
||||||
|
{
|
||||||
UpdatePointerValue(component);
|
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)
|
public override void DrawBase(VertexHelper vh)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,6 +73,23 @@ namespace XCharts.Runtime
|
|||||||
Auto
|
Auto
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// the condition of trigger tooltip.
|
||||||
|
/// ||触发条件。
|
||||||
|
/// </summary>
|
||||||
|
public enum TriggerOn
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Trigger when mouse move.
|
||||||
|
/// ||鼠标移动时触发。
|
||||||
|
/// </summary>
|
||||||
|
MouseMove,
|
||||||
|
/// <summary>
|
||||||
|
/// Trigger when mouse click.
|
||||||
|
/// ||鼠标点击时触发。
|
||||||
|
/// </summary>
|
||||||
|
Click,
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// Position type.
|
/// Position type.
|
||||||
/// ||坐标类型。
|
/// ||坐标类型。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -102,6 +119,7 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] private bool m_Show = true;
|
[SerializeField] private bool m_Show = true;
|
||||||
[SerializeField] private Type m_Type = Type.Auto;
|
[SerializeField] private Type m_Type = Type.Auto;
|
||||||
[SerializeField] private Trigger m_Trigger = Trigger.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][Since("v3.3.0")] private Position m_Position = Position.Auto;
|
||||||
[SerializeField] private string m_ItemFormatter;
|
[SerializeField] private string m_ItemFormatter;
|
||||||
[SerializeField] private string m_TitleFormatter;
|
[SerializeField] private string m_TitleFormatter;
|
||||||
@@ -144,6 +162,12 @@ namespace XCharts.Runtime
|
|||||||
public TooltipContext context = new TooltipContext();
|
public TooltipContext context = new TooltipContext();
|
||||||
public TooltipView view;
|
public TooltipView view;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// the callback of tooltip click index.
|
||||||
|
/// ||Tooltip为Click触发时,点击的X轴索引的回调。
|
||||||
|
/// </summary>
|
||||||
|
public System.Action<int> onClickIndex { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether to show the tooltip component.
|
/// Whether to show the tooltip component.
|
||||||
/// ||是否显示提示框组件。
|
/// ||是否显示提示框组件。
|
||||||
@@ -172,6 +196,15 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetStruct(ref m_Trigger, value)) SetAllDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_Trigger, value)) SetAllDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Condition of trigger tooltip.
|
||||||
|
/// ||触发条件。
|
||||||
|
/// </summary>
|
||||||
|
public TriggerOn triggerOn
|
||||||
|
{
|
||||||
|
get { return m_TriggerOn; }
|
||||||
|
set { if (PropertyUtil.SetStruct(ref m_TriggerOn, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// Type of position.
|
/// Type of position.
|
||||||
/// ||显示位置类型。
|
/// ||显示位置类型。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace XCharts.Runtime
|
|||||||
public float width;
|
public float width;
|
||||||
public float height;
|
public float height;
|
||||||
public float angle;
|
public float angle;
|
||||||
|
public int xAxisClickIndex = -1;
|
||||||
public Tooltip.Type type;
|
public Tooltip.Type type;
|
||||||
public Tooltip.Trigger trigger;
|
public Tooltip.Trigger trigger;
|
||||||
public TooltipData data = new TooltipData();
|
public TooltipData data = new TooltipData();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using XUGL;
|
using XUGL;
|
||||||
|
|
||||||
@@ -36,6 +37,15 @@ namespace XCharts.Runtime
|
|||||||
DrawTooltipIndicator(vh, component);
|
DrawTooltipIndicator(vh, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnPointerExit(PointerEventData eventData)
|
||||||
|
{
|
||||||
|
base.OnPointerExit(eventData);
|
||||||
|
if (chart.isTriggerOnClick)
|
||||||
|
{
|
||||||
|
component.context.xAxisClickIndex = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void InitTooltip(Tooltip tooltip)
|
private void InitTooltip(Tooltip tooltip)
|
||||||
{
|
{
|
||||||
tooltip.painter = chart.m_PainterUpper;
|
tooltip.painter = chart.m_PainterUpper;
|
||||||
@@ -70,6 +80,7 @@ namespace XCharts.Runtime
|
|||||||
m_IndicatorLabels[labelName] = item;
|
m_IndicatorLabels[labelName] = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
chart.isTriggerOnClick = tooltip.triggerOn == Tooltip.TriggerOn.Click;
|
||||||
};
|
};
|
||||||
tooltip.refreshComponent();
|
tooltip.refreshComponent();
|
||||||
}
|
}
|
||||||
@@ -93,39 +104,54 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
private void UpdateTooltipData(Tooltip tooltip)
|
private void UpdateTooltipData(Tooltip tooltip)
|
||||||
{
|
{
|
||||||
showTooltip = false;
|
m_ShowTooltip = false;
|
||||||
if (tooltip.trigger == Tooltip.Trigger.None) return;
|
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--)
|
for (int i = chart.series.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
var serie = chart.series[i];
|
var serie = chart.series[i];
|
||||||
if (!(serie is INeedSerieContainer))
|
if (!(serie is INeedSerieContainer))
|
||||||
{
|
{
|
||||||
showTooltip = true;
|
m_ShowTooltip = true;
|
||||||
containerSeries = null;
|
m_ContainerSeries = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
containerSeries = ListPool<Serie>.Get();
|
m_ContainerSeries = ListPool<Serie>.Get();
|
||||||
UpdatePointerContainerAndSeriesAndTooltip(tooltip, ref containerSeries);
|
UpdatePointerContainerAndSeriesAndTooltip(tooltip, ref m_ContainerSeries);
|
||||||
if (containerSeries.Count > 0)
|
if (m_ContainerSeries.Count > 0)
|
||||||
{
|
{
|
||||||
showTooltip = true;
|
m_ShowTooltip = true;
|
||||||
|
m_ContainerSeries = null;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!showTooltip && tooltip.IsActive())
|
m_ContainerSeries = ListPool<Serie>.Get();
|
||||||
|
UpdatePointerContainerAndSeriesAndTooltip(tooltip, ref m_ContainerSeries);
|
||||||
|
if (m_ContainerSeries.Count > 0)
|
||||||
|
{
|
||||||
|
m_ShowTooltip = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ShowTooltip = false;
|
||||||
|
if (tooltip.IsActive())
|
||||||
{
|
{
|
||||||
tooltip.ClearValue();
|
tooltip.ClearValue();
|
||||||
tooltip.SetActive(false);
|
tooltip.SetActive(false);
|
||||||
|
component.context.xAxisClickIndex = -1;
|
||||||
|
chart.pointerClickEventData = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool showTooltip;
|
private bool m_ShowTooltip;
|
||||||
private List<Serie> containerSeries;
|
private List<Serie> m_ContainerSeries;
|
||||||
private void UpdateTooltip(Tooltip tooltip)
|
private void UpdateTooltip(Tooltip tooltip)
|
||||||
{
|
{
|
||||||
if (!showTooltip) return;
|
if (!m_ShowTooltip) return;
|
||||||
var anyTrigger = false;
|
var anyTrigger = false;
|
||||||
for (int i = chart.series.Count - 1; i >= 0; i--)
|
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))
|
if (!SetSerieTooltip(tooltip, m_ContainerSeries))
|
||||||
showTooltip = false;
|
m_ShowTooltip = false;
|
||||||
else
|
else
|
||||||
anyTrigger = true;
|
anyTrigger = true;
|
||||||
ListPool<Serie>.Release(containerSeries);
|
ListPool<Serie>.Release(m_ContainerSeries);
|
||||||
}
|
}
|
||||||
if (!showTooltip || !anyTrigger)
|
if (!m_ShowTooltip || !anyTrigger)
|
||||||
{
|
{
|
||||||
if (tooltip.context.type == Tooltip.Type.Corss && m_PointerContainer != null && m_PointerContainer.IsPointerEnter())
|
if (tooltip.context.type == Tooltip.Type.Corss && m_PointerContainer != null && m_PointerContainer.IsPointerEnter())
|
||||||
{
|
{
|
||||||
|
m_ShowTooltip = true;
|
||||||
tooltip.SetActive(true);
|
tooltip.SetActive(true);
|
||||||
tooltip.SetContentActive(false);
|
tooltip.SetContentActive(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
m_ShowTooltip = false;
|
||||||
tooltip.SetActive(false);
|
tooltip.SetActive(false);
|
||||||
|
chart.pointerClickEventData = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -274,32 +303,39 @@ namespace XCharts.Runtime
|
|||||||
serie.context.tooltipTrigger : tooltip.trigger;
|
serie.context.tooltipTrigger : tooltip.trigger;
|
||||||
}
|
}
|
||||||
var isTriggerAxis = tooltip.IsTriggerAxis();
|
var isTriggerAxis = tooltip.IsTriggerAxis();
|
||||||
|
var inchart = true;
|
||||||
if (container is GridCoord)
|
if (container is GridCoord)
|
||||||
{
|
{
|
||||||
var xAxis = chart.GetChartComponent<XAxis>(serie.xAxisIndex);
|
var xAxis = chart.GetChartComponent<XAxis>(serie.xAxisIndex);
|
||||||
var yAxis = chart.GetChartComponent<YAxis>(serie.yAxisIndex);
|
var yAxis = chart.GetChartComponent<YAxis>(serie.yAxisIndex);
|
||||||
UpdateAxisPointerDataIndex(serie, xAxis, yAxis, container as GridCoord, isTriggerAxis);
|
inchart = UpdateAxisPointerDataIndex(serie, xAxis, yAxis, container as GridCoord, isTriggerAxis);
|
||||||
}
|
}
|
||||||
else if (container is PolarCoord)
|
else if (container is PolarCoord)
|
||||||
{
|
{
|
||||||
var m_AngleAxis = ComponentHelper.GetAngleAxis(chart.components, container.index);
|
var m_AngleAxis = ComponentHelper.GetAngleAxis(chart.components, container.index);
|
||||||
tooltip.context.angle = (float)m_AngleAxis.context.pointerValue;
|
tooltip.context.angle = (float)m_AngleAxis.context.pointerValue;
|
||||||
}
|
}
|
||||||
|
if (inchart)
|
||||||
|
{
|
||||||
list.Add(serie);
|
list.Add(serie);
|
||||||
if (!isTriggerAxis)
|
if (!isTriggerAxis)
|
||||||
|
{
|
||||||
chart.RefreshTopPainter();
|
chart.RefreshTopPainter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
m_PointerContainer = container;
|
m_PointerContainer = container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
serie.context.pointerAxisDataIndexs.Clear();
|
||||||
if (xAxis == null || yAxis == null) return;
|
if (xAxis == null || yAxis == null) return false;
|
||||||
|
var flag = true;
|
||||||
if (serie is Heatmap)
|
if (serie is Heatmap)
|
||||||
{
|
{
|
||||||
GetSerieDataByXYAxis(serie, xAxis, yAxis);
|
GetSerieDataByXYAxis(serie, xAxis, yAxis);
|
||||||
@@ -328,21 +364,46 @@ namespace XCharts.Runtime
|
|||||||
if (isTriggerAxis)
|
if (isTriggerAxis)
|
||||||
{
|
{
|
||||||
var index = serie.context.dataZoomStartIndex + (int)xAxis.context.pointerValue;
|
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.pointerEnter = true;
|
||||||
serie.context.pointerAxisDataIndexs.Add(index);
|
serie.context.pointerAxisDataIndexs.Add(index);
|
||||||
serie.context.pointerItemDataIndex = index;
|
serie.context.pointerItemDataIndex = index;
|
||||||
xAxis.context.axisTooltipValue = xAxis.context.pointerValue;
|
xAxis.context.axisTooltipValue = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
serie.context.pointerEnter = true;
|
|
||||||
if (isTriggerAxis)
|
if (isTriggerAxis)
|
||||||
|
{
|
||||||
|
serie.context.pointerEnter = true;
|
||||||
GetSerieDataIndexByAxis(serie, xAxis, grid);
|
GetSerieDataIndexByAxis(serie, xAxis, grid);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
GetSerieDataIndexByItem(serie, xAxis, grid);
|
GetSerieDataIndexByItem(serie, xAxis, grid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
private void GetSerieDataByXYAxis(Serie serie, Axis xAxis, Axis yAxis)
|
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;
|
if (tooltip.context.trigger == Tooltip.Trigger.None) return false;
|
||||||
tooltip.context.data.param.Clear();
|
tooltip.context.data.param.Clear();
|
||||||
tooltip.context.data.title = serie.serieName;
|
tooltip.context.data.title = serie.serieName;
|
||||||
tooltip.context.pointer = chart.pointerPos;
|
tooltip.context.pointer = GetTooltipPointerPos();
|
||||||
|
|
||||||
serie.handler.UpdateTooltipSerieParams(serie.context.pointerItemDataIndex, false, null,
|
serie.handler.UpdateTooltipSerieParams(serie.context.pointerItemDataIndex, false, null,
|
||||||
tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter, tooltip.ignoreDataDefaultContent,
|
tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter, tooltip.ignoreDataDefaultContent,
|
||||||
@@ -472,12 +533,20 @@ namespace XCharts.Runtime
|
|||||||
ref tooltip.context.data.title);
|
ref tooltip.context.data.title);
|
||||||
TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart);
|
TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart);
|
||||||
|
|
||||||
tooltip.SetActive(true);
|
tooltip.SetActive(m_ShowTooltip);
|
||||||
tooltip.view.Refresh();
|
tooltip.view.Refresh();
|
||||||
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
|
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector2 GetTooltipPointerPos()
|
||||||
|
{
|
||||||
|
if (chart.isTriggerOnClick && chart.isPointerClick)
|
||||||
|
return chart.clickPos;
|
||||||
|
else
|
||||||
|
return chart.pointerPos;
|
||||||
|
}
|
||||||
|
|
||||||
private bool SetSerieTooltip(Tooltip tooltip, List<Serie> series)
|
private bool SetSerieTooltip(Tooltip tooltip, List<Serie> series)
|
||||||
{
|
{
|
||||||
if (tooltip.context.trigger == Tooltip.Trigger.None)
|
if (tooltip.context.trigger == Tooltip.Trigger.None)
|
||||||
@@ -489,10 +558,10 @@ namespace XCharts.Runtime
|
|||||||
string category = null;
|
string category = null;
|
||||||
var showCategory = false;
|
var showCategory = false;
|
||||||
var isTriggerByAxis = false;
|
var isTriggerByAxis = false;
|
||||||
var isTriggerByItem = false;
|
var isTriggerByItem = tooltip.context.trigger == Tooltip.Trigger.Item;
|
||||||
var dataIndex = -1;
|
var dataIndex = -1;
|
||||||
tooltip.context.data.param.Clear();
|
tooltip.context.data.param.Clear();
|
||||||
tooltip.context.pointer = chart.pointerPos;
|
tooltip.context.pointer = GetTooltipPointerPos();
|
||||||
if (m_PointerContainer is GridCoord)
|
if (m_PointerContainer is GridCoord)
|
||||||
{
|
{
|
||||||
GetAxisCategory(m_PointerContainer.index, ref dataIndex, ref category);
|
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++)
|
for (int i = 0; i < series.Count; i++)
|
||||||
{
|
{
|
||||||
var serie = series[i];
|
var serie = series[i];
|
||||||
if (!serie.show) continue;
|
if (!serie.show) continue;
|
||||||
if (isTriggerByItem && serie.context.pointerItemDataIndex < 0) continue;
|
if (isTriggerByItem && serie.context.pointerItemDataIndex < 0) continue;
|
||||||
|
triggerSerieCount++;
|
||||||
serie.context.isTriggerByAxis = isTriggerByAxis;
|
serie.context.isTriggerByAxis = isTriggerByAxis;
|
||||||
if (isTriggerByAxis && dataIndex >= 0 && serie.context.pointerItemDataIndex < 0)
|
if (isTriggerByAxis && dataIndex >= 0 && serie.context.pointerItemDataIndex < 0)
|
||||||
serie.context.pointerItemDataIndex = dataIndex;
|
serie.context.pointerItemDataIndex = dataIndex;
|
||||||
@@ -528,10 +599,14 @@ namespace XCharts.Runtime
|
|||||||
ref tooltip.context.data.param,
|
ref tooltip.context.data.param,
|
||||||
ref tooltip.context.data.title);
|
ref tooltip.context.data.title);
|
||||||
}
|
}
|
||||||
|
if (triggerSerieCount <= 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart);
|
TooltipHelper.ResetTooltipParamsByItemFormatter(tooltip, chart);
|
||||||
if (tooltip.context.data.param.Count > 0 || !string.IsNullOrEmpty(tooltip.context.data.title))
|
if (tooltip.context.data.param.Count > 0 || !string.IsNullOrEmpty(tooltip.context.data.title))
|
||||||
{
|
{
|
||||||
tooltip.SetActive(true);
|
tooltip.SetActive(m_ShowTooltip);
|
||||||
if (tooltip.view != null)
|
if (tooltip.view != null)
|
||||||
tooltip.view.Refresh();
|
tooltip.view.Refresh();
|
||||||
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
|
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
|
||||||
@@ -551,7 +626,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
dataIndex = double.IsNaN(axis.context.pointerValue)
|
dataIndex = double.IsNaN(axis.context.pointerValue)
|
||||||
? axis.context.dataZoomStartIndex
|
? axis.context.dataZoomStartIndex
|
||||||
: axis.context.dataZoomStartIndex + (int)axis.context.pointerValue;
|
: axis.context.dataZoomStartIndex + (int)axis.context.axisTooltipValue;
|
||||||
category = axis.GetData(dataIndex);
|
category = axis.GetData(dataIndex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -616,7 +691,7 @@ namespace XCharts.Runtime
|
|||||||
case Tooltip.Type.Line:
|
case Tooltip.Type.Line:
|
||||||
float pX = grid.context.x;
|
float pX = grid.context.x;
|
||||||
pX += xAxis.IsCategory() ?
|
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);
|
xAxis.GetDistance(xAxis.context.axisTooltipValue, grid.context.width);
|
||||||
if (pX < grid.context.x)
|
if (pX < grid.context.x)
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -566,6 +566,26 @@ namespace XCharts.Runtime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// set insert data to head.
|
||||||
|
/// ||设置数据插入到头部。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="insertDataToHead"></param>
|
||||||
|
[Since("v3.11.0")]
|
||||||
|
public void SetInsertDataToHead(bool insertDataToHead)
|
||||||
|
{
|
||||||
|
foreach (var serie in m_Series)
|
||||||
|
serie.insertDataToHead = insertDataToHead;
|
||||||
|
|
||||||
|
var coms = GetChartComponents<XAxis>();
|
||||||
|
foreach (var com in coms)
|
||||||
|
{
|
||||||
|
var axis = com as XAxis;
|
||||||
|
if (axis.type == Axis.AxisType.Category)
|
||||||
|
axis.insertDataToHead = insertDataToHead;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Vector3 GetTitlePosition(Title title)
|
public Vector3 GetTitlePosition(Title title)
|
||||||
{
|
{
|
||||||
return chartPosition + title.location.GetPosition(chartWidth, chartHeight);
|
return chartPosition + title.location.GetPosition(chartWidth, chartHeight);
|
||||||
@@ -735,7 +755,8 @@ namespace XCharts.Runtime
|
|||||||
[Since("v3.7.0")]
|
[Since("v3.7.0")]
|
||||||
public void CancelTooltip()
|
public void CancelTooltip()
|
||||||
{
|
{
|
||||||
m_PointerEventData = null;
|
pointerMoveEventData = null;
|
||||||
|
pointerClickEventData = null;
|
||||||
var tooltip = GetChartComponent<Tooltip>();
|
var tooltip = GetChartComponent<Tooltip>();
|
||||||
if (tooltip != null)
|
if (tooltip != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,16 +43,21 @@ namespace XCharts.Runtime
|
|||||||
public Vector2 graphMaxAnchor { get { return m_GraphMaxAnchor; } }
|
public Vector2 graphMaxAnchor { get { return m_GraphMaxAnchor; } }
|
||||||
public Vector2 graphAnchoredPosition { get { return m_GraphAnchoredPosition; } }
|
public Vector2 graphAnchoredPosition { get { return m_GraphAnchoredPosition; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The postion of pointer.
|
/// The postion of pointer move.
|
||||||
/// ||鼠标位置。
|
/// ||鼠标位置。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Vector2 pointerPos { get; protected set; }
|
public Vector2 pointerPos { get; protected set; }
|
||||||
|
public Vector2 clickPos { get; protected set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the mouse pointer is in the chart.
|
/// Whether the mouse pointer is in the chart.
|
||||||
/// ||鼠标是否在图表内。
|
/// ||鼠标是否在图表内。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool isPointerInChart
|
public bool isPointerInChart { get { return pointerMoveEventData != null; } }
|
||||||
{ get { return m_PointerEventData != null; } }
|
/// <summary>
|
||||||
|
/// Whether the mouse click the chart.
|
||||||
|
/// ||鼠标是否点击了图表。
|
||||||
|
/// </summary>
|
||||||
|
public bool isPointerClick { get { return pointerClickEventData != null; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 警告信息。
|
/// 警告信息。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ namespace XCharts.Runtime
|
|||||||
protected bool m_PainerDirty = false;
|
protected bool m_PainerDirty = false;
|
||||||
protected bool m_IsOnValidate = false;
|
protected bool m_IsOnValidate = false;
|
||||||
protected Vector3 m_LastLocalPosition;
|
protected Vector3 m_LastLocalPosition;
|
||||||
protected PointerEventData m_PointerEventData;
|
internal PointerEventData pointerMoveEventData;
|
||||||
|
internal PointerEventData pointerClickEventData;
|
||||||
|
internal bool isTriggerOnClick = false;
|
||||||
|
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnPointerClick;
|
protected Action<PointerEventData, BaseGraph> m_OnPointerClick;
|
||||||
protected Action<PointerEventData, BaseGraph> m_OnPointerDown;
|
protected Action<PointerEventData, BaseGraph> m_OnPointerDown;
|
||||||
@@ -213,17 +215,23 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
private void CheckPointerPos()
|
private void CheckPointerPos()
|
||||||
{
|
{
|
||||||
if (!isPointerInChart) return;
|
|
||||||
if (canvas == null) return;
|
if (canvas == null) return;
|
||||||
Vector2 mousePos = m_PointerEventData.position;
|
if (pointerMoveEventData != null)
|
||||||
|
{
|
||||||
|
pointerPos = MousePos2ChartPos(pointerMoveEventData.position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector2 MousePos2ChartPos(Vector2 mousePos)
|
||||||
|
{
|
||||||
Vector2 local;
|
Vector2 local;
|
||||||
if (!ScreenPointToChartPoint(mousePos, out local))
|
if (!ScreenPointToChartPoint(mousePos, out local))
|
||||||
{
|
{
|
||||||
pointerPos = Vector2.zero;
|
return Vector2.zero;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pointerPos = local;
|
return local;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,6 +277,8 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public virtual void OnPointerClick(PointerEventData eventData)
|
public virtual void OnPointerClick(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
|
pointerClickEventData = eventData;
|
||||||
|
clickPos = MousePos2ChartPos(pointerClickEventData.position);
|
||||||
if (m_OnPointerClick != null) m_OnPointerClick(eventData, this);
|
if (m_OnPointerClick != null) m_OnPointerClick(eventData, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,13 +294,14 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public virtual void OnPointerEnter(PointerEventData eventData)
|
public virtual void OnPointerEnter(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
m_PointerEventData = eventData;
|
pointerMoveEventData = eventData;
|
||||||
if (m_OnPointerEnter != null) m_OnPointerEnter(eventData, this);
|
if (m_OnPointerEnter != null) m_OnPointerEnter(eventData, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnPointerExit(PointerEventData eventData)
|
public virtual void OnPointerExit(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
m_PointerEventData = null;
|
pointerMoveEventData = null;
|
||||||
|
pointerClickEventData = null;
|
||||||
if (m_OnPointerExit != null) m_OnPointerExit(eventData, this);
|
if (m_OnPointerExit != null) m_OnPointerExit(eventData, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ namespace XCharts.Runtime
|
|||||||
public Tooltip.Type tooltipType;
|
public Tooltip.Type tooltipType;
|
||||||
public Tooltip.Trigger tooltipTrigger;
|
public Tooltip.Trigger tooltipTrigger;
|
||||||
public int totalDataIndex;
|
public int totalDataIndex;
|
||||||
|
public int clickTotalDataIndex;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 水平方向的
|
/// 水平方向的
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -741,6 +741,7 @@ namespace XCharts.Runtime
|
|||||||
|
|
||||||
public override void OnPointerClick(PointerEventData eventData)
|
public override void OnPointerClick(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
|
serie.context.clickTotalDataIndex = serie.context.totalDataIndex;
|
||||||
if (serie.onClick == null && chart.onSerieClick == null) return;
|
if (serie.onClick == null && chart.onSerieClick == null) return;
|
||||||
if (!serie.context.pointerEnter) return;
|
if (!serie.context.pointerEnter) return;
|
||||||
var dataIndex = GetPointerItemDataIndex();
|
var dataIndex = GetPointerItemDataIndex();
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
"displayName": "XCharts",
|
"displayName": "XCharts",
|
||||||
"author": "monitor1394",
|
"author": "monitor1394",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "3.10.2",
|
"version": "3.11.0-preview1",
|
||||||
"date": "20240311",
|
"date": "20240223",
|
||||||
"checkdate": "20240311",
|
"checkdate": "20240223",
|
||||||
"unity": "2018.3",
|
"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.",
|
"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": [
|
"keywords": [
|
||||||
|
|||||||
Reference in New Issue
Block a user