Compare commits

..

11 Commits

Author SHA1 Message Date
monitor1394
d77e1c3d91 v3.0.0-preivew9 2022-05-06 08:14:49 +08:00
monitor1394
d4b3f5eaa8 3.0.0-preview9 2022-05-06 08:12:15 +08:00
monitor1394
8a78867961 [doc] update doc 2022-05-05 13:23:33 +08:00
monitor1394
d9266b3c9c [refactor][optimize] item color 2022-05-05 13:10:04 +08:00
monitor1394
0801069f72 [add][line] line support dash (#197) 2022-05-04 20:47:02 +08:00
monitor1394
e92afac0de [add][legend] add the delegate callback for legend 2022-05-04 09:19:45 +08:00
monitor1394
d1fd4dcf44 [refactor] refactor symbol and label 2022-05-04 08:45:19 +08:00
monitor1394
43c31405b8 [bug][ring] fix ring label formatter (#195) 2022-05-01 10:54:14 +08:00
monitor1394
4e4d0bc85d [optimize][bar] bar support clip and min-max (#196) 2022-05-01 10:30:58 +08:00
monitor1394
96b0ec45d2 [optimize][tooltip] support background image 2022-04-29 15:54:47 +08:00
monitor1394
8c02ce14ac [bug] fix change color in runtime did not refresh 2022-04-27 08:26:05 +08:00
62 changed files with 1063 additions and 491 deletions

View File

@@ -2,6 +2,7 @@
# 更新日志
[master](#master)
[v3.0.0-preivew9](#v3.0.0-preivew9)
[v3.0.0-preivew8](#v3.0.0-preivew8)
[v3.0.0-preivew7](#v3.0.0-preivew7)
[v3.0.0-preivew6](#v3.0.0-preivew6)
@@ -51,6 +52,18 @@
## master
## v3.0.0-preivew9
* (2022.05.06) 发布`v3.0.0-preivew9`版本
* (2022.05.05) 优化`ItemStyle`设置`color`时的一致性
* (2022.05.05) 增加`Line``Dash`,`Dot`等的支持 (#197)
* (2022.05.04) 增加`Legend`的委托回调
* (2022.05.04) 优化`Symbol``Label`
* (2022.05.01) 增加`Bar``clip`的支持 (#196)
* (2022.05.01) 修复`RingChart``Label`不刷新的问题 (#195)
* (2022.04.29) 增加`Tooltip`支持自定义背景图
* (2022.04.27) 修复`ItemStyle`代码修改`color`不刷新的问题
## v3.0.0-preivew8
* (2022.04.26) 发布`v3.0.0-preivew8`版本

View File

@@ -46,6 +46,7 @@
- [MainComponentHandler](#MainComponentHandler)
- [MainComponentHandler<T>](#MainComponentHandler<T>)
- [MathUtil](#MathUtil)
- [ObjectPool<T> where T](#ObjectPool<T> where T)
- [Painter](#Painter)
- [ParallelChart](#ParallelChart)
- [ParallelCoordContext](#ParallelCoordContext)
@@ -123,7 +124,7 @@ Inherits or Implemented: [MainComponentHandler](#MainComponentHandler)
| `GetAxisPositionValue()` |public static double GetAxisPositionValue(float xy, float axisLength, double axisRange, float axisStart, float axisOffset)</br> |
| `GetAxisPositionValue()` |public static double GetAxisPositionValue(GridCoord grid, Axis axis, Vector3 pos)</br> |
| `GetAxisValueDistance()` |public static float GetAxisValueDistance(GridCoord grid, Axis axis, float scaleWidth, double value)</br>获得数值value在坐标轴上相对起点的距离 |
| `GetAxisValueLength()` |public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)</br>获得数值value在坐标轴上对的长度 |
| `GetAxisValueLength()` |public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)</br>获得数值value在坐标轴上对的长度 |
| `GetAxisValuePosition()` |public static float GetAxisValuePosition(GridCoord grid, Axis axis, float scaleWidth, double value)</br>获得数值value在坐标轴上的坐标位置 |
| `GetDataWidth()` |public static float GetDataWidth(Axis axis, float coordinateWidth, int dataCount, DataZoom dataZoom)</br>获得一个类目数据在坐标系中代表的宽度 |
| `GetEachWidth()` |public static float GetEachWidth(Axis axis, float coordinateWidth, DataZoom dataZoom = null)</br> |
@@ -180,6 +181,8 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver
| `GetDataZoomOfSerie()` |public void GetDataZoomOfSerie(Serie serie, out DataZoom xDataZoom, out DataZoom yDataZoom)</br> |
| `GetGrid()` |public GridCoord GetGrid(Vector2 local)</br> |
| `GetGridOfDataZoom()` |public GridCoord GetGridOfDataZoom(DataZoom dataZoom)</br> |
| `GetItemColor()` |public Color32 GetItemColor(Serie serie, bool highlight = false)</br> |
| `GetItemColor()` |public Color32 GetItemColor(Serie serie, SerieData serieData, bool highlight = false)</br> |
| `GetLegendRealShowNameColor()` |public Color32 GetLegendRealShowNameColor(string name)</br> |
| `GetLegendRealShowNameIndex()` |public int GetLegendRealShowNameIndex(string name)</br> |
| `GetPainter()` |public Painter GetPainter(int index)</br> |
@@ -223,6 +226,8 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver
| `OnScroll()` |public override void OnScroll(PointerEventData eventData)</br> |
| `RefreshBasePainter()` |public void RefreshBasePainter()</br> |
| `RefreshChart()` |public void RefreshChart()</br>Redraw chart in next frame. |
| `RefreshChart()` |public void RefreshChart(int serieIndex)</br>Redraw chart serie in next frame. |
| `RefreshChart()` |public void RefreshChart(Serie serie)</br>Redraw chart serie in next frame. |
| `RefreshDataZoom()` |public void RefreshDataZoom()</br>在下一帧刷新DataZoom |
| `RefreshPainter()` |public void RefreshPainter(int index)</br> |
| `RefreshPainter()` |public void RefreshPainter(Serie serie)</br> |
@@ -371,9 +376,11 @@ Inherits or Implemented: [Image](#Image)
|public method|description|
|--|--|
| `GetHeight()` |public float GetHeight()</br> |
| `GetPosition()` |public Vector3 GetPosition()</br> |
| `GetTextHeight()` |public float GetTextHeight()</br> |
| `GetTextWidth()` |public float GetTextWidth()</br> |
| `GetWidth()` |public float GetWidth()</br> |
| `SetActive()` |public void SetActive(bool flag)</br> |
| `SetIcon()` |public void SetIcon(Image image)</br> |
| `SetIconActive()` |public void SetIconActive(bool flag)</br> |
@@ -594,6 +601,18 @@ Inherits or Implemented: [MainComponentHandler](#MainComponentHandler)
| `Clamp01()` |public static double Clamp01(double value)</br> |
| `Lerp()` |public static double Lerp(double a, double b, double t)</br> |
## `ObjectPool<T> where T`
Inherits or Implemented: [new()](#new())
|public method|description|
|--|--|
| `ClearAll()` |public void ClearAll()</br> |
| `Get()` |public T Get()</br> |
| `new()` |public class ObjectPool<T> where T : new()</br> |
| `ObjectPool()` |public ObjectPool(UnityAction<T> actionOnGet, UnityAction<T> actionOnRelease, bool newIfEmpty = true)</br> |
| `Release()` |public void Release(T element)</br> |
## `Painter`
Inherits or Implemented: [MaskableGraphic](#MaskableGraphic)
@@ -726,6 +745,7 @@ Inherits or Implemented: [SerieHandler where T](#SerieHandler where T),[Serie](#
|public method|description|
|--|--|
| `GetSerieDataLabelOffset()` |public virtual Vector3 GetSerieDataLabelOffset(SerieData serieData, LabelStyle label)</br> |
| `GetSerieDataLabelPosition()` |public virtual Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label)</br> |
| `GetSerieDataTitlePosition()` |public virtual Vector3 GetSerieDataTitlePosition(SerieData serieData, TitleStyle titleStyle)</br> |
| `InitComponent()` |public override void InitComponent()</br> |
@@ -776,7 +796,7 @@ Inherits or Implemented: [Attribute](#Attribute)
| `GetSerieEmphasisLabel()` |public static LabelStyle GetSerieEmphasisLabel(Serie serie, SerieData serieData)</br> |
| `GetSerieLabel()` |public static LabelStyle GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false)</br> |
| `GetSerieLabelLine()` |public static LabelLine GetSerieLabelLine(Serie serie, SerieData serieData, bool highlight = false)</br> |
| `GetSerieSymbol()` |public static SymbolStyle GetSerieSymbol(Serie serie, SerieData serieData)</br> |
| `GetSerieSymbol()` |public static SerieSymbol GetSerieSymbol(Serie serie, SerieData serieData)</br> |
| `GetSymbolBorder()` |public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight)</br> |
| `GetSymbolBorder()` |public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, float defaultWidth)</br> |
| `GetSymbolBorderColor()` |public static Color32 GetSymbolBorderColor(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight)</br> |
@@ -930,6 +950,8 @@ Inherits or Implemented: [MaskableGraphic](#MaskableGraphic)
| `GetVertialDire()` |public static Vector3 GetVertialDire(Vector3 dire)</br> |
| `IsClearColor()` |public static bool IsClearColor(Color color)</br> |
| `IsClearColor()` |public static bool IsClearColor(Color32 color)</br> |
| `IsPointInPolygon()` |public static bool IsPointInPolygon(Vector3 p, List<Vector2> polyons)</br> |
| `IsPointInPolygon()` |public static bool IsPointInPolygon(Vector3 p, List<Vector3> polyons)</br> |
| `IsPointInTriangle()` |public static bool IsPointInTriangle(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 check)</br> |
| `IsValueEqualsColor()` |public static bool IsValueEqualsColor(Color color1, Color color2)</br> |
| `IsValueEqualsColor()` |public static bool IsValueEqualsColor(Color32 color1, Color32 color2)</br> |

View File

@@ -46,6 +46,7 @@
- [MainComponentHandler](#MainComponentHandler)
- [MainComponentHandler<T>](#MainComponentHandler<T>)
- [MathUtil](#MathUtil)
- [ObjectPool<T> where T](#ObjectPool<T> where T)
- [Painter](#Painter)
- [ParallelChart](#ParallelChart)
- [ParallelCoordContext](#ParallelCoordContext)
@@ -123,7 +124,7 @@ Inherits or Implemented: [MainComponentHandler](#MainComponentHandler)
| `GetAxisPositionValue()` |public static double GetAxisPositionValue(float xy, float axisLength, double axisRange, float axisStart, float axisOffset)</br> |
| `GetAxisPositionValue()` |public static double GetAxisPositionValue(GridCoord grid, Axis axis, Vector3 pos)</br> |
| `GetAxisValueDistance()` |public static float GetAxisValueDistance(GridCoord grid, Axis axis, float scaleWidth, double value)</br>获得数值value在坐标轴上相对起点的距离 |
| `GetAxisValueLength()` |public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)</br>获得数值value在坐标轴上对的长度 |
| `GetAxisValueLength()` |public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)</br>获得数值value在坐标轴上对的长度 |
| `GetAxisValuePosition()` |public static float GetAxisValuePosition(GridCoord grid, Axis axis, float scaleWidth, double value)</br>获得数值value在坐标轴上的坐标位置 |
| `GetDataWidth()` |public static float GetDataWidth(Axis axis, float coordinateWidth, int dataCount, DataZoom dataZoom)</br>获得一个类目数据在坐标系中代表的宽度 |
| `GetEachWidth()` |public static float GetEachWidth(Axis axis, float coordinateWidth, DataZoom dataZoom = null)</br> |
@@ -180,6 +181,8 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver
| `GetDataZoomOfSerie()` |public void GetDataZoomOfSerie(Serie serie, out DataZoom xDataZoom, out DataZoom yDataZoom)</br> |
| `GetGrid()` |public GridCoord GetGrid(Vector2 local)</br> |
| `GetGridOfDataZoom()` |public GridCoord GetGridOfDataZoom(DataZoom dataZoom)</br> |
| `GetItemColor()` |public Color32 GetItemColor(Serie serie, bool highlight = false)</br> |
| `GetItemColor()` |public Color32 GetItemColor(Serie serie, SerieData serieData, bool highlight = false)</br> |
| `GetLegendRealShowNameColor()` |public Color32 GetLegendRealShowNameColor(string name)</br> |
| `GetLegendRealShowNameIndex()` |public int GetLegendRealShowNameIndex(string name)</br> |
| `GetPainter()` |public Painter GetPainter(int index)</br> |
@@ -222,7 +225,9 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver
| `OnPointerUp()` |public override void OnPointerUp(PointerEventData eventData)</br> |
| `OnScroll()` |public override void OnScroll(PointerEventData eventData)</br> |
| `RefreshBasePainter()` |public void RefreshBasePainter()</br> |
| `RefreshChart()` |public void RefreshChart()</br>在下一帧刷新图表。 |
| `RefreshChart()` |public void RefreshChart()</br>在下一帧刷新整个图表。 |
| `RefreshChart()` |public void RefreshChart(int serieIndex)</br>在下一帧刷新图表的指定serie。 |
| `RefreshChart()` |public void RefreshChart(Serie serie)</br>在下一帧刷新图表的指定serie。 |
| `RefreshDataZoom()` |public void RefreshDataZoom()</br>在下一帧刷新DataZoom |
| `RefreshPainter()` |public void RefreshPainter(int index)</br> |
| `RefreshPainter()` |public void RefreshPainter(Serie serie)</br> |
@@ -371,9 +376,11 @@ Inherits or Implemented: [Image](#Image)
|public method|description|
|--|--|
| `GetHeight()` |public float GetHeight()</br> |
| `GetPosition()` |public Vector3 GetPosition()</br> |
| `GetTextHeight()` |public float GetTextHeight()</br> |
| `GetTextWidth()` |public float GetTextWidth()</br> |
| `GetWidth()` |public float GetWidth()</br> |
| `SetActive()` |public void SetActive(bool flag)</br> |
| `SetIcon()` |public void SetIcon(Image image)</br> |
| `SetIconActive()` |public void SetIconActive(bool flag)</br> |
@@ -594,6 +601,18 @@ Inherits or Implemented: [MainComponentHandler](#MainComponentHandler)
| `Clamp01()` |public static double Clamp01(double value)</br> |
| `Lerp()` |public static double Lerp(double a, double b, double t)</br> |
## `ObjectPool<T> where T`
Inherits or Implemented: [new()](#new())
|public method|description|
|--|--|
| `ClearAll()` |public void ClearAll()</br> |
| `Get()` |public T Get()</br> |
| `new()` |public class ObjectPool<T> where T : new()</br> |
| `ObjectPool()` |public ObjectPool(UnityAction<T> actionOnGet, UnityAction<T> actionOnRelease, bool newIfEmpty = true)</br> |
| `Release()` |public void Release(T element)</br> |
## `Painter`
Inherits or Implemented: [MaskableGraphic](#MaskableGraphic)
@@ -726,6 +745,7 @@ Inherits or Implemented: [SerieHandler where T](#SerieHandler where T),[Serie](#
|public method|description|
|--|--|
| `GetSerieDataLabelOffset()` |public virtual Vector3 GetSerieDataLabelOffset(SerieData serieData, LabelStyle label)</br> |
| `GetSerieDataLabelPosition()` |public virtual Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label)</br> |
| `GetSerieDataTitlePosition()` |public virtual Vector3 GetSerieDataTitlePosition(SerieData serieData, TitleStyle titleStyle)</br> |
| `InitComponent()` |public override void InitComponent()</br> |
@@ -776,7 +796,7 @@ Inherits or Implemented: [Attribute](#Attribute)
| `GetSerieEmphasisLabel()` |public static LabelStyle GetSerieEmphasisLabel(Serie serie, SerieData serieData)</br> |
| `GetSerieLabel()` |public static LabelStyle GetSerieLabel(Serie serie, SerieData serieData, bool highlight = false)</br> |
| `GetSerieLabelLine()` |public static LabelLine GetSerieLabelLine(Serie serie, SerieData serieData, bool highlight = false)</br> |
| `GetSerieSymbol()` |public static SymbolStyle GetSerieSymbol(Serie serie, SerieData serieData)</br> |
| `GetSerieSymbol()` |public static SerieSymbol GetSerieSymbol(Serie serie, SerieData serieData)</br> |
| `GetSymbolBorder()` |public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight)</br> |
| `GetSymbolBorder()` |public static float GetSymbolBorder(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, float defaultWidth)</br> |
| `GetSymbolBorderColor()` |public static Color32 GetSymbolBorderColor(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight)</br> |
@@ -930,6 +950,8 @@ Inherits or Implemented: [MaskableGraphic](#MaskableGraphic)
| `GetVertialDire()` |public static Vector3 GetVertialDire(Vector3 dire)</br> |
| `IsClearColor()` |public static bool IsClearColor(Color color)</br> |
| `IsClearColor()` |public static bool IsClearColor(Color32 color)</br> |
| `IsPointInPolygon()` |public static bool IsPointInPolygon(Vector3 p, List<Vector2> polyons)</br> |
| `IsPointInPolygon()` |public static bool IsPointInPolygon(Vector3 p, List<Vector3> polyons)</br> |
| `IsPointInTriangle()` |public static bool IsPointInTriangle(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 check)</br> |
| `IsValueEqualsColor()` |public static bool IsValueEqualsColor(Color color1, Color color2)</br> |
| `IsValueEqualsColor()` |public static bool IsValueEqualsColor(Color32 color1, Color32 color2)</br> |

View File

@@ -103,6 +103,8 @@
- [RadarAxisTheme](#RadarAxisTheme)
- [RadiusAxisTheme](#RadiusAxisTheme)
- [SerieData](#SerieData)
- [SerieDataBaseInfo](#SerieDataBaseInfo)
- [SerieSymbol](#SerieSymbol)
- [SerieTheme](#SerieTheme)
- [StageColor](#StageColor)
- [SubTitleTheme](#SubTitleTheme)
@@ -136,7 +138,8 @@
- [LabelLine](#LabelLine)
- [LabelStyle](#LabelStyle)
- [LineStyle](#LineStyle)
- [SymbolStyle](#SymbolStyle)
- [SerieDataBaseInfo](#SerieDataBaseInfo)
- [SerieSymbol](#SerieSymbol)
- [TitleStyle](#TitleStyle)
## Other
@@ -633,15 +636,20 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieDataComponent]
Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent)
标签的引导线
|field|default|comment|
|--|--|--|
| `show` |true | Whether the label line is showed. |
| `lineType` | | the type of visual guide line.</br>`LineType`:</br>- `Normal`: the normal line chart 普通折线图。</br>- `Smooth`: the smooth line chart 平滑曲线。</br>- `StepStart`: step line.</br>- `StepMiddle`: step line.</br>- `StepEnd`: step line.</br>|
| `lineColor` |ChartConst.clearColor32 | the color of visual guild line. |
| `lineAngle` |0 | the angle of visual guild line. |
| `lineWidth` |1.0f | the width of visual guild line. |
| `lineGap` |1.0f | the gap of container and guild line. |
| `lineLength1` |25f | The length of the first segment of visual guide line. |
| `lineLength2` |15f | The length of the second segment of visual guide line. |
| `startSymbol` | | The symbol of the start point of labelline. [SymbolStyle](SymbolStyle)|
| `endSymbol` | | The symbol of the end point of labelline. [SymbolStyle](SymbolStyle)|
## `LabelStyle`
@@ -1010,7 +1018,7 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
| `bottom` | | Distance between component and the bottom side of the container. |
| `insertDataToHead` | | Whether to add new data at the head or at the end of the list. |
| `lineStyle` | | The style of line. [LineStyle](LineStyle)|
| `symbol` | | the symbol of serie data item. [SymbolStyle](SymbolStyle)|
| `symbol` | | the symbol of serie data item. [SerieSymbol](SerieSymbol)|
| `animation` | | The start animation. [AnimationStyle](AnimationStyle)|
| `itemStyle` | | The style of data item. [ItemStyle](ItemStyle)|
| `data` | | 系列中的数据内容数组。SerieData可以设置1到n维数据。 |
@@ -1027,6 +1035,7 @@ A data item of serie.
| `name` | | the name of data item. |
| `id` | | 数据项的唯一id。唯一id不是必须设置的。 |
| `parentId` | | |
| `baseInfos` | | |
| `itemStyles` | | |
| `labels` | | |
| `labelLines` | | |
@@ -1037,6 +1046,38 @@ A data item of serie.
| `titleStyles` | | |
| `data` | | An arbitrary dimension data list of data item. |
## `SerieDataBaseInfo`
Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieDataComponent](#ISerieDataComponent)
数据项的其他基础数据。
|field|default|comment|
|--|--|--|
| `ignore` |false | 是否忽略数据。当为 true 时,数据不进行绘制。 |
| `selected` | | Whether the data item is selected. |
| `radius` | | 自定义半径。可用在饼图中自定义某个数据项的半径。 |
## `SerieSymbol`
Inherits or Implemented: [SymbolStyle](#SymbolStyle),[ISerieDataComponent](#ISerieDataComponent)
系列数据项的标记的图形
|field|default|comment|
|--|--|--|
| `sizeType` | | the type of symbol size.</br>`SymbolSizeType`:</br>- `Custom`: Specify constant for symbol size.</br>- `FromData`: Specify the dataIndex and dataScale to calculate symbol size.</br>- `Function`: Specify function for symbol size.</br>|
| `selectedSize` |0f | the size of selected symbol. |
| `dataIndex` |1 | whitch data index is when the sizeType assined as FromData. |
| `dataScale` |1 | the scale of data when sizeType assined as FromData. |
| `selectedDataScale` |1.5f | the scale of selected data when sizeType assined as FromData. |
| `sizeFunction` | | the function of size when sizeType assined as Function. |
| `selectedSizeFunction` | | the function of size when sizeType assined as Function. |
| `startIndex` | | the index start to show symbol. |
| `interval` | | the interval of show symbol. |
| `forceShowLast` |false | whether to show the last symbol. |
| `repeat` |false | 图形是否重复。 |
## `SerieTheme`
Inherits or Implemented: [ChildComponent](#ChildComponent)
@@ -1128,7 +1169,7 @@ Inherits or Implemented: [ComponentTheme](#ComponentTheme)
## `SymbolStyle`
Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieDataComponent](#ISerieDataComponent)
Inherits or Implemented: [ChildComponent](#ChildComponent)
系列数据项的标记的图形
@@ -1136,24 +1177,14 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieDataComponent]
|--|--|--|
| `show` |true | Whether the symbol is showed. |
| `type` | | the type of symbol.</br>`SymbolType`:</br>- `None`: 不显示标记。</br>- `Custom`: 自定义标记。</br>- `Circle`: 圆形。</br>- `EmptyCircle`: 空心圆。</br>- `Rect`: 正方形。可通过设置`itemStyle``cornerRadius`变成圆角矩形。</br>- `EmptyRect`: 空心正方形。</br>- `Triangle`: 三角形。</br>- `EmptyTriangle`: 空心三角形。</br>- `Diamond`: 菱形。</br>- `EmptyDiamond`: 空心菱形。</br>- `Arrow`: 箭头。</br>- `EmptyArrow`: 空心箭头。</br>|
| `sizeType` | | the type of symbol size.</br>`SymbolSizeType`:</br>- `Custom`: Specify constant for symbol size.</br>- `FromData`: Specify the dataIndex and dataScale to calculate symbol size.</br>- `Function`: Specify function for symbol size.</br>|
| `size` |0f | the size of symbol. |
| `selectedSize` |0f | the size of selected symbol. |
| `dataIndex` |1 | whitch data index is when the sizeType assined as FromData. |
| `dataScale` |1 | the scale of data when sizeType assined as FromData. |
| `selectedDataScale` |1.5f | the scale of selected data when sizeType assined as FromData. |
| `sizeFunction` | | the function of size when sizeType assined as Function. |
| `selectedSizeFunction` | | the function of size when sizeType assined as Function. |
| `startIndex` | | the index start to show symbol. |
| `interval` | | the interval of show symbol. |
| `forceShowLast` |false | whether to show the last symbol. |
| `gap` |0 | the gap of symbol and line segment. |
| `width` |0f | 图形的宽。 |
| `height` |0f | 图形的高。 |
| `repeat` |false | 图形是否重复。 |
| `offset` |Vector2.zero | 图形的偏移。 |
| `image` | | 自定义的标记图形。 |
| `imageType` | | |
| `color` | | 图形的颜色。 |
## `TextLimit`
@@ -1301,6 +1332,7 @@ Tooltip component.
| `alwayShowContent` |false | Whether to trigger after always display. |
| `offset` |Vector2(18f, -25f) | The position offset of tooltip relative to the mouse position. |
| `backgroundImage` | | The background image of tooltip. |
| `backgroundType` | | The background type of tooltip. |
| `backgroundColor` | | The background color of tooltip. |
| `borderWidth` |2f | the width of tooltip border. |
| `fixedXEnable` |false | |

View File

@@ -103,6 +103,8 @@
- [RadarAxisTheme](#RadarAxisTheme)
- [RadiusAxisTheme](#RadiusAxisTheme)
- [SerieData](#SerieData)
- [SerieDataBaseInfo](#SerieDataBaseInfo)
- [SerieSymbol](#SerieSymbol)
- [SerieTheme](#SerieTheme)
- [StageColor](#StageColor)
- [SubTitleTheme](#SubTitleTheme)
@@ -136,7 +138,8 @@
- [LabelLine](#LabelLine)
- [LabelStyle](#LabelStyle)
- [LineStyle](#LineStyle)
- [SymbolStyle](#SymbolStyle)
- [SerieDataBaseInfo](#SerieDataBaseInfo)
- [SerieSymbol](#SerieSymbol)
- [TitleStyle](#TitleStyle)
## Other 其他
@@ -633,15 +636,20 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieDataComponent]
Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent)
标签的引导线
|field|default|comment|
|--|--|--|
| `show` |true | 是否显示视觉引导线。 |
| `lineType` | | 视觉引导线类型。</br>`LineType`:</br>- `Normal`: the normal line chart 普通折线图。</br>- `Smooth`: the smooth line chart 平滑曲线。</br>- `StepStart`: 阶梯线图:当前点。</br>- `StepMiddle`: 阶梯线图:当前点和下一个点的中间。</br>- `StepEnd`: 阶梯线图:下一个拐点。</br>|
| `lineColor` |ChartConst.clearColor32 | 视觉引导线颜色。默认和serie一致取自调色板。 |
| `lineAngle` |0 | 视觉引导线的固定角度。对折线和曲线有效。 |
| `lineWidth` |1.0f | 视觉引导线的宽度。 |
| `lineGap` |1.0f | 视觉引导线和容器的间距。 |
| `lineLength1` |25f | 视觉引导线第一段的长度。 |
| `lineLength2` |15f | 视觉引导线第二段的长度。 |
| `startSymbol` | | 起始点的图形标记。 [SymbolStyle](SymbolStyle)|
| `endSymbol` | | 结束点的图形标记。 [SymbolStyle](SymbolStyle)|
## `LabelStyle`
@@ -1010,7 +1018,7 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
| `bottom` | | 组件离容器下侧的距离。 |
| `insertDataToHead` | | 添加新数据时是在列表的头部还是尾部加入。 |
| `lineStyle` | | 线条样式。 [LineStyle](LineStyle)|
| `symbol` | | 标记的图形。 [SymbolStyle](SymbolStyle)|
| `symbol` | | 标记的图形。 [SerieSymbol](SerieSymbol)|
| `animation` | | 起始动画。 [AnimationStyle](AnimationStyle)|
| `itemStyle` | | 图形样式。 [ItemStyle](ItemStyle)|
| `data` | | 系列中的数据内容数组。SerieData可以设置1到n维数据。 |
@@ -1027,6 +1035,7 @@ Inherits or Implemented: [ChildComponent](#ChildComponent)
| `name` | | 数据项名称。 |
| `id` | | 数据项的唯一id。唯一id不是必须设置的。 |
| `parentId` | | |
| `baseInfos` | | |
| `itemStyles` | | |
| `labels` | | |
| `labelLines` | | |
@@ -1037,6 +1046,38 @@ Inherits or Implemented: [ChildComponent](#ChildComponent)
| `titleStyles` | | |
| `data` | | 可指定任意维数的数值列表。 |
## `SerieDataBaseInfo`
Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieDataComponent](#ISerieDataComponent)
数据项的其他基础数据。
|field|default|comment|
|--|--|--|
| `ignore` |false | 是否忽略数据。当为 true 时,数据不进行绘制。 |
| `selected` | | 该数据项是否被选中。 |
| `radius` | | 自定义半径。可用在饼图中自定义某个数据项的半径。 |
## `SerieSymbol`
Inherits or Implemented: [SymbolStyle](#SymbolStyle),[ISerieDataComponent](#ISerieDataComponent)
系列数据项的标记的图形
|field|default|comment|
|--|--|--|
| `sizeType` | | 标记图形的大小获取方式。</br>`SymbolSizeType`:</br>- `Custom`: 自定义大小。</br>- `FromData`: 通过 dataIndex 从数据中获取,再乘以一个比例系数 dataScale 。</br>- `Function`: 通过委托函数获取。</br>|
| `selectedSize` |0f | 被选中的标记的大小。 |
| `dataIndex` |1 | 当sizeType指定为FromData时指定的数据源索引。 |
| `dataScale` |1 | 当sizeType指定为FromData时指定的倍数系数。 |
| `selectedDataScale` |1.5f | 当sizeType指定为FromData时指定的高亮倍数系数。 |
| `sizeFunction` | | 当sizeType指定为Function时指定的委托函数。 |
| `selectedSizeFunction` | | 当sizeType指定为Function时指定的高亮委托函数。 |
| `startIndex` | | 开始显示图形标记的索引。 |
| `interval` | | 显示图形标记的间隔。0表示显示所有标签1表示隔一个隔显示一个标签以此类推。 |
| `forceShowLast` |false | 是否强制显示最后一个图形标记。 |
| `repeat` |false | 图形是否重复。 |
## `SerieTheme`
Inherits or Implemented: [ChildComponent](#ChildComponent)
@@ -1128,7 +1169,7 @@ Inherits or Implemented: [ComponentTheme](#ComponentTheme)
## `SymbolStyle`
Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieDataComponent](#ISerieDataComponent)
Inherits or Implemented: [ChildComponent](#ChildComponent)
系列数据项的标记的图形
@@ -1136,24 +1177,14 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieDataComponent]
|--|--|--|
| `show` |true | 是否显示标记。 |
| `type` | | 标记类型。</br>`SymbolType`:</br>- `None`: 不显示标记。</br>- `Custom`: 自定义标记。</br>- `Circle`: 圆形。</br>- `EmptyCircle`: 空心圆。</br>- `Rect`: 正方形。可通过设置`itemStyle``cornerRadius`变成圆角矩形。</br>- `EmptyRect`: 空心正方形。</br>- `Triangle`: 三角形。</br>- `EmptyTriangle`: 空心三角形。</br>- `Diamond`: 菱形。</br>- `EmptyDiamond`: 空心菱形。</br>- `Arrow`: 箭头。</br>- `EmptyArrow`: 空心箭头。</br>|
| `sizeType` | | 标记图形的大小获取方式。</br>`SymbolSizeType`:</br>- `Custom`: 自定义大小。</br>- `FromData`: 通过 dataIndex 从数据中获取,再乘以一个比例系数 dataScale 。</br>- `Function`: 通过委托函数获取。</br>|
| `size` |0f | 标记的大小。 |
| `selectedSize` |0f | 被选中的标记的大小。 |
| `dataIndex` |1 | 当sizeType指定为FromData时指定的数据源索引。 |
| `dataScale` |1 | 当sizeType指定为FromData时指定的倍数系数。 |
| `selectedDataScale` |1.5f | 当sizeType指定为FromData时指定的高亮倍数系数。 |
| `sizeFunction` | | 当sizeType指定为Function时指定的委托函数。 |
| `selectedSizeFunction` | | 当sizeType指定为Function时指定的高亮委托函数。 |
| `startIndex` | | 开始显示图形标记的索引。 |
| `interval` | | 显示图形标记的间隔。0表示显示所有标签1表示隔一个隔显示一个标签以此类推。 |
| `forceShowLast` |false | 是否强制显示最后一个图形标记。 |
| `gap` |0 | 图形标记和线条的间隙距离。 |
| `width` |0f | 图形的宽。 |
| `height` |0f | 图形的高。 |
| `repeat` |false | 图形是否重复。 |
| `offset` |Vector2.zero | 图形的偏移。 |
| `image` | | 自定义的标记图形。 |
| `imageType` | | |
| `color` | | 图形的颜色。 |
## `TextLimit`
@@ -1301,6 +1332,7 @@ Inherits or Implemented: [MainComponent](#MainComponent)
| `alwayShowContent` |false | 是否触发后一直显示提示框浮层。 |
| `offset` |Vector2(18f, -25f) | 提示框相对于鼠标位置的偏移。 |
| `backgroundImage` | | 提示框的背景图片。 |
| `backgroundType` | | 提示框的背景图片显示类型。 |
| `backgroundColor` | | 提示框的背景颜色。 |
| `borderWidth` |2f | 边框线宽。 |
| `fixedXEnable` |false | |

View File

@@ -17,10 +17,13 @@ namespace XCharts.Editor
++EditorGUI.indentLevel;
PropertyField(prop, "m_LineType");
PropertyField(prop, "m_LineColor");
PropertyField(prop, "m_LineAngle");
PropertyField(prop, "m_LineWidth");
PropertyField(prop, "m_LineGap");
PropertyField(prop, "m_LineLength1");
PropertyField(prop, "m_LineLength2");
PropertyField(prop, "m_StartSymbol");
PropertyField(prop, "m_EndSymbol");
--EditorGUI.indentLevel;
}
}

View File

@@ -0,0 +1,25 @@

using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
namespace XCharts.Editor
{
[CustomPropertyDrawer(typeof(SerieDataBaseInfo), true)]
public class SerieDataBaseInfoDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "BaseInfo"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeComponentFoldout(prop, "m_Show", false))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Ignore");
PropertyField(prop, "m_Selected");
PropertyField(prop, "m_Radius");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -0,0 +1,53 @@

using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
namespace XCharts.Editor
{
[CustomPropertyDrawer(typeof(SerieSymbol), true)]
public class SerieSymbolDrawer : BasePropertyDrawer
{
public override string ClassName { get { return "Symbol"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
if (MakeComponentFoldout(prop, "m_Show", true))
{
++EditorGUI.indentLevel;
var type = (SymbolType)prop.FindPropertyRelative("m_Type").enumValueIndex;
PropertyField(prop, "m_Type");
if (type == SymbolType.Custom)
{
PropertyField(prop, "m_Image");
PropertyField(prop, "m_ImageType");
PropertyField(prop, "m_Width");
// PropertyField(prop, "m_Height");
// PropertyField(prop, "m_Offset");
}
PropertyField(prop, "m_Gap");
PropertyField(prop, "m_SizeType");
switch ((SymbolSizeType)prop.FindPropertyRelative("m_SizeType").enumValueIndex)
{
case SymbolSizeType.Custom:
PropertyField(prop, "m_Size");
PropertyField(prop, "m_SelectedSize");
break;
case SymbolSizeType.FromData:
PropertyField(prop, "m_DataIndex");
PropertyField(prop, "m_DataScale");
PropertyField(prop, "m_SelectedDataScale");
break;
case SymbolSizeType.Function:
break;
}
PropertyField(prop, "m_StartIndex");
PropertyField(prop, "m_Interval");
PropertyField(prop, "m_ForceShowLast");
PropertyField(prop, "m_Repeat");
--EditorGUI.indentLevel;
}
}
}
}

View File

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

View File

@@ -23,29 +23,12 @@ namespace XCharts.Editor
PropertyField(prop, "m_Image");
PropertyField(prop, "m_ImageType");
PropertyField(prop, "m_Width");
// PropertyField(prop, "m_Height");
PropertyField(prop, "m_Height");
// PropertyField(prop, "m_Offset");
}
PropertyField(prop, "m_Color");
PropertyField(prop, "m_Size");
PropertyField(prop, "m_Gap");
PropertyField(prop, "m_SizeType");
switch ((SymbolSizeType)prop.FindPropertyRelative("m_SizeType").enumValueIndex)
{
case SymbolSizeType.Custom:
PropertyField(prop, "m_Size");
PropertyField(prop, "m_SelectedSize");
break;
case SymbolSizeType.FromData:
PropertyField(prop, "m_DataIndex");
PropertyField(prop, "m_DataScale");
PropertyField(prop, "m_SelectedDataScale");
break;
case SymbolSizeType.Function:
break;
}
PropertyField(prop, "m_StartIndex");
PropertyField(prop, "m_Interval");
PropertyField(prop, "m_ForceShowLast");
PropertyField(prop, "m_Repeat");
--EditorGUI.indentLevel;
}
}

View File

@@ -27,6 +27,7 @@ namespace XCharts.Editor
PropertyField("m_PaddingLeftRight");
PropertyField("m_PaddingTopBottom");
PropertyField("m_BackgroundImage");
PropertyField("m_BackgroundType");
PropertyField("m_BackgroundColor");
PropertyField("m_FixedWidth");
PropertyField("m_FixedHeight");

View File

@@ -26,7 +26,7 @@ namespace XCharts.Editor
PropertyField("m_BarZebraWidth");
PropertyField("m_BarZebraGap");
}
PropertyField("m_Clip");
PropertyFiledMore(() =>
{
PropertyFieldLimitMin("m_MinShow", 0);
@@ -38,7 +38,6 @@ namespace XCharts.Editor
PropertyField("m_ShowAsPositiveNumber");
PropertyField("m_Large");
PropertyField("m_LargeThreshold");
PropertyField("m_Clip");
PropertyField("m_PlaceHolder");
});
PropertyField("m_ItemStyle");

View File

@@ -18,6 +18,7 @@ namespace XCharts.Editor
PropertyField("m_YAxisIndex");
}
PropertyField("m_LineType");
//PropertyField("m_Clip");
PropertyFiledMore(() =>
{
PropertyFieldLimitMin("m_MinShow", 0);
@@ -32,7 +33,6 @@ namespace XCharts.Editor
PropertyField("m_ShowAsPositiveNumber");
PropertyField("m_Large");
PropertyField("m_LargeThreshold");
PropertyField("m_Clip");
});
PropertyField("m_Symbol");
PropertyField("m_LineStyle");

View File

@@ -195,6 +195,7 @@ namespace XCharts.Editor
var m_Id = serieData.FindPropertyRelative("m_Id");
var m_ParentId = serieData.FindPropertyRelative("m_ParentId");
var m_BaseInfo = serieData.FindPropertyRelative("m_BaseInfos");
var m_Label = serieData.FindPropertyRelative("m_Labels");
var m_ItemStyle = serieData.FindPropertyRelative("m_ItemStyles");
var m_Emphasis = serieData.FindPropertyRelative("m_Emphases");
@@ -207,11 +208,15 @@ namespace XCharts.Editor
PropertyField(m_Id);
PropertyField(m_ParentId);
var componentNum = m_Label.arraySize + m_ItemStyle.arraySize + m_Emphasis.arraySize
var componentNum = m_BaseInfo.arraySize + m_Label.arraySize + m_ItemStyle.arraySize + m_Emphasis.arraySize
+ m_Symbol.arraySize + m_LineStyle.arraySize + m_AreaStyle.arraySize;
var title = "Component";
if (componentNum == 0) title += " (None)";
m_DataComponentFoldout = ChartEditorHelper.DrawHeader(title, m_DataComponentFoldout, false, null, null,
new HeaderMenuInfo("Add BaseInfo", () =>
{
serie.GetSerieData(index).GetOrAddComponent<SerieDataBaseInfo>();
}, m_BaseInfo.arraySize == 0),
new HeaderMenuInfo("Add ItemStyle", () =>
{
serie.GetSerieData(index).GetOrAddComponent<ItemStyle>();
@@ -226,7 +231,7 @@ namespace XCharts.Editor
}, m_Emphasis.arraySize == 0),
new HeaderMenuInfo("Add Symbol", () =>
{
serie.GetSerieData(index).GetOrAddComponent<SymbolStyle>();
serie.GetSerieData(index).GetOrAddComponent<SerieSymbol>();
}, m_Symbol.arraySize == 0),
new HeaderMenuInfo("Add LineStyle", () =>
{
@@ -240,6 +245,10 @@ namespace XCharts.Editor
{
serie.GetSerieData(index).GetOrAddComponent<TitleStyle>();
}, m_TitleStyle.arraySize == 0),
new HeaderMenuInfo("Remove BaseInfo", () =>
{
serie.GetSerieData(index).RemoveComponent<SerieDataBaseInfo>();
}, m_BaseInfo.arraySize > 0),
new HeaderMenuInfo("Remove ItemStyle", () =>
{
serie.GetSerieData(index).RemoveComponent<ItemStyle>();
@@ -254,7 +263,7 @@ namespace XCharts.Editor
}, m_Emphasis.arraySize > 0),
new HeaderMenuInfo("Remove Symbol", () =>
{
serie.GetSerieData(index).RemoveComponent<SymbolStyle>();
serie.GetSerieData(index).RemoveComponent<SerieSymbol>();
}, m_Symbol.arraySize > 0),
new HeaderMenuInfo("Remove LineStyle", () =>
{
@@ -274,6 +283,8 @@ namespace XCharts.Editor
}, componentNum > 0));
if (m_DataComponentFoldout)
{
if (m_BaseInfo.arraySize > 0)
PropertyField(m_BaseInfo.GetArrayElementAtIndex(0));
if (m_Label.arraySize > 0)
PropertyField(m_Label.GetArrayElementAtIndex(0));
if (m_ItemStyle.arraySize > 0)

View File

@@ -12,6 +12,7 @@ namespace XCharts.Editor
PropertyField("m_YAxisIndex");
PropertyField("m_BarWidth");
PropertyField("m_BarGap");
PropertyField("m_Clip");
PropertyField("m_ItemStyle");
PropertyField("m_Animation");
}

View File

@@ -10,6 +10,7 @@ namespace XCharts.Editor
PropertyField("m_XAxisIndex");
PropertyField("m_YAxisIndex");
PropertyField("m_LineType");
//PropertyField("m_Clip");
PropertyField("m_LineStyle");
PropertyField("m_ItemStyle");
PropertyField("m_Animation");

View File

@@ -194,7 +194,8 @@ namespace XCharts.Editor
else if (a.StartsWith("selected:"))
{
string selected = a.Substring(9, a.Length - 9);
serieData.selected = bool.Parse(selected);
var baseInfo = serieData.GetOrAddComponent<SerieDataBaseInfo>();
baseInfo.selected = bool.Parse(selected);
}
}
serie.AddSerieData(serieData);

View File

@@ -62,7 +62,7 @@ namespace XCharts.Example
legend.orient = Orient.Vertical;
chart.RemoveData();
serie = chart.AddSerie<Bar>( "访问来源");
serie = chart.AddSerie<Bar>("访问来源");
serie.radius[0] = 0;
serie.radius[1] = 110;
serie.center[0] = 0.5f;
@@ -118,12 +118,12 @@ namespace XCharts.Example
chart.RefreshChart();
yield return new WaitForSeconds(1);
serie.data[0].selected = true;
serie.data[0].GetOrAddComponent<SerieDataBaseInfo>().selected = true;
chart.RefreshChart();
yield return new WaitForSeconds(1);
serie.gap = 0f;
serie.data[0].selected = false;
serie.data[0].GetOrAddComponent<SerieDataBaseInfo>().selected = false;
chart.RefreshChart();
yield return new WaitForSeconds(1);
}
@@ -132,7 +132,7 @@ namespace XCharts.Example
{
chart.GetChartComponent<Title>().subText = "多图组合";
serie1 = chart.AddSerie<Pie>( "访问来源2");
serie1 = chart.AddSerie<Pie>("访问来源2");
chart.AddData(1, 335, "直达");
chart.AddData(1, 679, "营销广告");
chart.AddData(1, 1548, "搜索引擎");

View File

@@ -29,7 +29,8 @@ namespace XCharts.Example
var serieData = chart.AddData(0, 20);
//var serieData = serie1.GetSerieData(0);
serieData.radius = 10;
var baseInfo = serieData.GetOrAddComponent<SerieDataBaseInfo>();
baseInfo.radius = 10;
var itemStyle = serieData.GetOrAddComponent<ItemStyle>();
itemStyle.color = Color.blue;
}

View File

@@ -10,6 +10,8 @@ namespace XCharts.Runtime
public Orient orient;
public float x;
public float y;
public float zeroX;
public float zeroY;
public float width;
public float height;
public Vector3 position;

View File

@@ -166,6 +166,10 @@ namespace XCharts
: (float)(Math.Abs(axis.context.minValue) * (grid.context.width
/ (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
);
axis.context.x = grid.context.x;
axis.context.y = grid.context.y;
axis.context.zeroY = grid.context.y;
axis.context.zeroX = grid.context.x - (float)(axis.context.minValue * grid.context.width / axis.context.minMaxRange);
}
if (grid != null && axis is YAxis && axis.IsValue())
{
@@ -176,6 +180,10 @@ namespace XCharts
: (float)(Math.Abs(axis.context.minValue) * (grid.context.height
/ (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
);
axis.context.x = grid.context.x;
axis.context.y = grid.context.y;
axis.context.zeroX = grid.context.x;
axis.context.zeroY = grid.context.y - (float)(axis.context.minValue * grid.context.height / axis.context.minMaxRange);
}
}
var dataZoom = chart.GetDataZoomOfAxis(axis);

View File

@@ -511,7 +511,7 @@ namespace XCharts.Runtime
}
/// <summary>
/// 获得数值value在坐标轴上对的长度
/// 获得数值value在坐标轴上对的长度
/// </summary>
/// <param name="grid"></param>
/// <param name="axis"></param>
@@ -549,10 +549,10 @@ namespace XCharts.Runtime
var yDataHig = 0f;
if (axis.context.minMaxRange != 0)
{
if (!realLength || (realLength && axis.context.minValue > 0))
yDataHig = (float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
if (realLength)
yDataHig = (float)(value * gridHeight / axis.context.minMaxRange);
else
yDataHig = (float)(value / axis.context.minMaxRange * gridHeight);
yDataHig = (float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
}
return includeGridXY
? gridXY + yDataHig

View File

@@ -110,6 +110,14 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 数据项背景宽度。
/// </summary>
public float backgroundWidth
{
get { return m_BackgroundWidth; }
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 中心区域颜色。
/// </summary>
public Color32 centerColor
@@ -126,14 +134,6 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_CenterGap, value)) SetVerticesDirty(); }
}
/// <summary>
/// 数据项背景宽度。
/// </summary>
public float backgroundWidth
{
get { return m_BackgroundWidth; }
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 边框的颜色。
/// </summary>
public Color32 borderColor

View File

@@ -4,6 +4,9 @@ using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// 标签的引导线
/// </summary>
[System.Serializable]
public class LabelLine : ChildComponent, ISerieExtraComponent, ISerieDataComponent
{
@@ -29,16 +32,20 @@ namespace XCharts.Runtime
[SerializeField] private bool m_Show = true;
[SerializeField] private LineType m_LineType = LineType.BrokenLine;
[SerializeField] private Color32 m_LineColor = ChartConst.clearColor32;
[SerializeField] private float m_LineAngle = 0;
[SerializeField] private float m_LineWidth = 1.0f;
[SerializeField] private float m_LineGap = 1.0f;
[SerializeField] private float m_LineLength1 = 25f;
[SerializeField] private float m_LineLength2 = 15f;
[SerializeField] private SymbolStyle m_StartSymbol = new SymbolStyle() { type = SymbolType.Circle, size = 3 };
[SerializeField] private SymbolStyle m_EndSymbol = new SymbolStyle() { type = SymbolType.Circle, size = 3 };
public void Reset()
{
m_Show = false;
m_LineType = LineType.BrokenLine;
m_LineColor = Color.clear;
m_LineAngle = 0;
m_LineWidth = 1.0f;
m_LineGap = 1.0f;
m_LineLength1 = 25f;
@@ -73,6 +80,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_LineColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// the angle of visual guild line.
/// |视觉引导线的固定角度。对折线和曲线有效。
/// </summary>
public float lineAngle
{
get { return m_LineAngle; }
set { if (PropertyUtil.SetStruct(ref m_LineAngle, value)) SetVerticesDirty(); }
}
/// <summary>
/// the width of visual guild line.
/// |视觉引导线的宽度。
/// </summary>
@@ -108,5 +124,23 @@ namespace XCharts.Runtime
get { return m_LineLength2; }
set { if (PropertyUtil.SetStruct(ref m_LineLength2, value)) SetVerticesDirty(); }
}
/// <summary>
/// The symbol of the start point of labelline.
/// |起始点的图形标记。
/// </summary>
public SymbolStyle startSymbol
{
get { return m_StartSymbol; }
set { if (PropertyUtil.SetClass(ref m_StartSymbol, value)) SetVerticesDirty(); }
}
/// <summary>
/// The symbol of the end point of labelline.
/// |结束点的图形标记。
/// </summary>
public SymbolStyle endSymbol
{
get { return m_EndSymbol; }
set { if (PropertyUtil.SetClass(ref m_EndSymbol, value)) SetVerticesDirty(); }
}
}
}

View File

@@ -244,7 +244,12 @@ namespace XCharts.Runtime
public bool IsInside()
{
return position == Position.Inside || position == Position.Center;
return m_Position == Position.Inside || m_Position == Position.Center;
}
public bool IsDefaultPosition(Position position)
{
return m_Position == Position.Default || m_Position == position;
}
public bool IsAutoSize()

View File

@@ -0,0 +1,33 @@
using UnityEngine;
namespace XCharts.Runtime
{
/// <summary>
/// 数据项的其他基础数据。
/// </summary>
[System.Serializable]
public class SerieDataBaseInfo : ChildComponent, ISerieDataComponent
{
[SerializeField] private bool m_Ignore = false;
[SerializeField] private bool m_Selected;
[SerializeField] private float m_Radius;
/// <summary>
/// 是否忽略数据。当为 true 时,数据不进行绘制。
/// </summary>
public bool ignore
{
get { return m_Ignore; }
set { if (PropertyUtil.SetStruct(ref m_Ignore, value)) SetVerticesDirty(); }
}
/// <summary>
/// 自定义半径。可用在饼图中自定义某个数据项的半径。
/// </summary>
public float radius { get { return m_Radius; } set { m_Radius = value; } }
/// <summary>
/// Whether the data item is selected.
/// |该数据项是否被选中。
/// </summary>
public bool selected { get { return m_Selected; } set { m_Selected = value; } }
}
}

View File

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

View File

@@ -0,0 +1,242 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace XCharts.Runtime
{
/// <summary>
/// The way to get serie symbol size.
/// |获取标记图形大小的方式。
/// </summary>
public enum SymbolSizeType
{
/// <summary>
/// Specify constant for symbol size.
/// |自定义大小。
/// </summary>
Custom,
/// <summary>
/// Specify the dataIndex and dataScale to calculate symbol size.
/// |通过 dataIndex 从数据中获取,再乘以一个比例系数 dataScale 。
/// </summary>
FromData,
/// <summary>
/// Specify function for symbol size.
/// |通过委托函数获取。
/// </summary>
Function,
}
/// <summary>
/// 系列数据项的标记的图形
/// </summary>
[System.Serializable]
public class SerieSymbol : SymbolStyle, ISerieDataComponent
{
[SerializeField] private SymbolSizeType m_SizeType = SymbolSizeType.Custom;
[SerializeField] private float m_SelectedSize = 0f;
[SerializeField] private int m_DataIndex = 1;
[SerializeField] private float m_DataScale = 1;
[SerializeField] private float m_SelectedDataScale = 1.5f;
[SerializeField] private SymbolSizeFunction m_SizeFunction;
[SerializeField] private SymbolSizeFunction m_SelectedSizeFunction;
[SerializeField] private int m_StartIndex;
[SerializeField] private int m_Interval;
[SerializeField] private bool m_ForceShowLast = false;
[SerializeField] private bool m_Repeat = false;
public override void Reset()
{
base.Reset();
m_SizeType = SymbolSizeType.Custom;
m_SelectedSize = 0f;
m_DataIndex = 1;
m_DataScale = 1;
m_SelectedDataScale = 1.5f;
m_SizeFunction = null;
m_SelectedSizeFunction = null;
m_StartIndex = 0;
m_Interval = 0;
m_ForceShowLast = false;
m_Repeat = false;
}
/// <summary>
/// the type of symbol size.
/// |标记图形的大小获取方式。
/// </summary>
public SymbolSizeType sizeType
{
get { return m_SizeType; }
set { if (PropertyUtil.SetStruct(ref m_SizeType, value)) SetVerticesDirty(); }
}
/// <summary>
/// the size of selected symbol.
/// |被选中的标记的大小。
/// </summary>
public float selectedSize
{
get { return m_SelectedSize; }
set { if (PropertyUtil.SetStruct(ref m_SelectedSize, value)) SetVerticesDirty(); }
}
/// <summary>
/// whitch data index is when the sizeType assined as FromData.
/// |当sizeType指定为FromData时指定的数据源索引。
/// </summary>
public int dataIndex
{
get { return m_DataIndex; }
set { if (PropertyUtil.SetStruct(ref m_DataIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// the scale of data when sizeType assined as FromData.
/// |当sizeType指定为FromData时指定的倍数系数。
/// </summary>
public float dataScale
{
get { return m_DataScale; }
set { if (PropertyUtil.SetStruct(ref m_DataScale, value)) SetVerticesDirty(); }
}
/// <summary>
/// the scale of selected data when sizeType assined as FromData.
/// |当sizeType指定为FromData时指定的高亮倍数系数。
/// </summary>
public float selectedDataScale
{
get { return m_SelectedDataScale; }
set { if (PropertyUtil.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
}
/// <summary>
/// the function of size when sizeType assined as Function.
/// |当sizeType指定为Function时指定的委托函数。
/// </summary>
public SymbolSizeFunction sizeFunction
{
get { return m_SizeFunction; }
set { if (PropertyUtil.SetClass(ref m_SizeFunction, value)) SetVerticesDirty(); }
}
/// <summary>
/// the function of size when sizeType assined as Function.
/// |当sizeType指定为Function时指定的高亮委托函数。
/// </summary>
public SymbolSizeFunction selectedSizeFunction
{
get { return m_SelectedSizeFunction; }
set { if (PropertyUtil.SetClass(ref m_SelectedSizeFunction, value)) SetVerticesDirty(); }
}
/// <summary>
/// the index start to show symbol.
/// |开始显示图形标记的索引。
/// </summary>
public int startIndex
{
get { return m_StartIndex; }
set { if (PropertyUtil.SetStruct(ref m_StartIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// the interval of show symbol.
/// |显示图形标记的间隔。0表示显示所有标签1表示隔一个隔显示一个标签以此类推。
/// </summary>
public int interval
{
get { return m_Interval; }
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
}
/// <summary>
/// whether to show the last symbol.
/// |是否强制显示最后一个图形标记。
/// </summary>
public bool forceShowLast
{
get { return m_ForceShowLast; }
set { if (PropertyUtil.SetStruct(ref m_ForceShowLast, value)) SetVerticesDirty(); }
}
/// <summary>
/// 图形是否重复。
/// </summary>
public bool repeat
{
get { return m_Repeat; }
set { if (PropertyUtil.SetStruct(ref m_Repeat, value)) SetAllDirty(); }
}
/// <summary>
/// 根据指定的sizeType获得标记的大小
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public float GetSize(List<double> data, float themeSize)
{
switch (m_SizeType)
{
case SymbolSizeType.Custom:
return size == 0 ? themeSize : size;
case SymbolSizeType.FromData:
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
{
return (float)data[dataIndex] * m_DataScale;
}
else
{
return size == 0 ? themeSize : size;
}
case SymbolSizeType.Function:
if (data != null && sizeFunction != null) return sizeFunction(data);
else return size == 0 ? themeSize : size;
default: return size == 0 ? themeSize : size;
}
}
/// <summary>
/// 根据sizeType获得高亮时的标记大小
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public float GetSelectedSize(List<double> data, float themeSelectedSize)
{
switch (m_SizeType)
{
case SymbolSizeType.Custom:
return selectedSize == 0 ? themeSelectedSize : selectedSize;
case SymbolSizeType.FromData:
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
{
return (float)data[dataIndex] * m_SelectedDataScale;
}
else
{
return selectedSize == 0 ? themeSelectedSize : selectedSize;
}
case SymbolSizeType.Function:
if (data != null && selectedSizeFunction != null)
return selectedSizeFunction(data);
else
return selectedSize == 0 ? themeSelectedSize : selectedSize;
default: return selectedSize == 0 ? themeSelectedSize : selectedSize;
}
}
public bool ShowSymbol(int dataIndex, int dataCount)
{
if (!show)
return false;
if (dataIndex < startIndex)
return false;
if (m_Interval <= 0)
return true;
if (m_ForceShowLast && dataIndex == dataCount - 1)
return true;
return (dataIndex - startIndex) % (m_Interval + 1) == 0;
}
}
}

View File

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

View File

@@ -61,75 +61,31 @@ namespace XCharts.Runtime
EmptyArrow
}
/// <summary>
/// The way to get serie symbol size.
/// |获取标记图形大小的方式。
/// </summary>
public enum SymbolSizeType
{
/// <summary>
/// Specify constant for symbol size.
/// |自定义大小。
/// </summary>
Custom,
/// <summary>
/// Specify the dataIndex and dataScale to calculate symbol size.
/// |通过 dataIndex 从数据中获取,再乘以一个比例系数 dataScale 。
/// </summary>
FromData,
/// <summary>
/// Specify function for symbol size.
/// |通过委托函数获取。
/// </summary>
Function,
}
/// <summary>
/// 系列数据项的标记的图形
/// </summary>
[System.Serializable]
public class SymbolStyle : ChildComponent, ISerieDataComponent
public class SymbolStyle : ChildComponent
{
[SerializeField] private bool m_Show = true;
[SerializeField] private SymbolType m_Type = SymbolType.EmptyCircle;
[SerializeField] private SymbolSizeType m_SizeType = SymbolSizeType.Custom;
[SerializeField] private float m_Size = 0f;
[SerializeField] private float m_SelectedSize = 0f;
[SerializeField] private int m_DataIndex = 1;
[SerializeField] private float m_DataScale = 1;
[SerializeField] private float m_SelectedDataScale = 1.5f;
[SerializeField] private SymbolSizeFunction m_SizeFunction;
[SerializeField] private SymbolSizeFunction m_SelectedSizeFunction;
[SerializeField] private int m_StartIndex;
[SerializeField] private int m_Interval;
[SerializeField] private bool m_ForceShowLast = false;
[SerializeField] private float m_Gap = 0;
[SerializeField] private float m_Width = 0f;
[SerializeField] private float m_Height = 0f;
[SerializeField] private bool m_Repeat = false;
[SerializeField] private Vector2 m_Offset = Vector2.zero;
[SerializeField] private Sprite m_Image;
[SerializeField] private Image.Type m_ImageType;
[SerializeField] protected bool m_Show = true;
[SerializeField] protected SymbolType m_Type = SymbolType.EmptyCircle;
[SerializeField] protected float m_Size = 0f;
[SerializeField] protected float m_Gap = 0;
[SerializeField] protected float m_Width = 0f;
[SerializeField] protected float m_Height = 0f;
[SerializeField] protected Vector2 m_Offset = Vector2.zero;
[SerializeField] protected Sprite m_Image;
[SerializeField] protected Image.Type m_ImageType;
[SerializeField] protected Color32 m_Color;
public void Reset()
public virtual void Reset()
{
m_Show = false;
m_Type = SymbolType.EmptyCircle;
m_SizeType = SymbolSizeType.Custom;
m_Size = 0f;
m_SelectedSize = 0f;
m_DataIndex = 1;
m_DataScale = 1;
m_SelectedDataScale = 1.5f;
m_SizeFunction = null;
m_SelectedSizeFunction = null;
m_StartIndex = 0;
m_Interval = 0;
m_ForceShowLast = false;
m_Gap = 0;
m_Width = 0f;
m_Height = 0f;
m_Repeat = false;
m_Offset = Vector2.zero;
m_Image = null;
m_ImageType = Image.Type.Simple;
@@ -154,15 +110,6 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
}
/// <summary>
/// the type of symbol size.
/// |标记图形的大小获取方式。
/// </summary>
public SymbolSizeType sizeType
{
get { return m_SizeType; }
set { if (PropertyUtil.SetStruct(ref m_SizeType, value)) SetVerticesDirty(); }
}
/// <summary>
/// the size of symbol.
/// |标记的大小。
/// </summary>
@@ -172,87 +119,6 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
}
/// <summary>
/// the size of selected symbol.
/// |被选中的标记的大小。
/// </summary>
public float selectedSize
{
get { return m_SelectedSize; }
set { if (PropertyUtil.SetStruct(ref m_SelectedSize, value)) SetVerticesDirty(); }
}
/// <summary>
/// whitch data index is when the sizeType assined as FromData.
/// |当sizeType指定为FromData时指定的数据源索引。
/// </summary>
public int dataIndex
{
get { return m_DataIndex; }
set { if (PropertyUtil.SetStruct(ref m_DataIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// the scale of data when sizeType assined as FromData.
/// |当sizeType指定为FromData时指定的倍数系数。
/// </summary>
public float dataScale
{
get { return m_DataScale; }
set { if (PropertyUtil.SetStruct(ref m_DataScale, value)) SetVerticesDirty(); }
}
/// <summary>
/// the scale of selected data when sizeType assined as FromData.
/// |当sizeType指定为FromData时指定的高亮倍数系数。
/// </summary>
public float selectedDataScale
{
get { return m_SelectedDataScale; }
set { if (PropertyUtil.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
}
/// <summary>
/// the function of size when sizeType assined as Function.
/// |当sizeType指定为Function时指定的委托函数。
/// </summary>
public SymbolSizeFunction sizeFunction
{
get { return m_SizeFunction; }
set { if (PropertyUtil.SetClass(ref m_SizeFunction, value)) SetVerticesDirty(); }
}
/// <summary>
/// the function of size when sizeType assined as Function.
/// |当sizeType指定为Function时指定的高亮委托函数。
/// </summary>
public SymbolSizeFunction selectedSizeFunction
{
get { return m_SelectedSizeFunction; }
set { if (PropertyUtil.SetClass(ref m_SelectedSizeFunction, value)) SetVerticesDirty(); }
}
/// <summary>
/// the index start to show symbol.
/// |开始显示图形标记的索引。
/// </summary>
public int startIndex
{
get { return m_StartIndex; }
set { if (PropertyUtil.SetStruct(ref m_StartIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// the interval of show symbol.
/// |显示图形标记的间隔。0表示显示所有标签1表示隔一个隔显示一个标签以此类推。
/// </summary>
public int interval
{
get { return m_Interval; }
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
}
/// <summary>
/// whether to show the last symbol.
/// |是否强制显示最后一个图形标记。
/// </summary>
public bool forceShowLast
{
get { return m_ForceShowLast; }
set { if (PropertyUtil.SetStruct(ref m_ForceShowLast, value)) SetVerticesDirty(); }
}
/// <summary>
/// the gap of symbol and line segment.
/// |图形标记和线条的间隙距离。
/// </summary>
@@ -278,14 +144,6 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetAllDirty(); }
}
/// <summary>
/// 图形是否重复。
/// </summary>
public bool repeat
{
get { return m_Repeat; }
set { if (PropertyUtil.SetStruct(ref m_Repeat, value)) SetAllDirty(); }
}
/// <summary>
/// 自定义的标记图形。
/// </summary>
public Sprite image
@@ -306,6 +164,14 @@ namespace XCharts.Runtime
get { return m_Offset; }
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetAllDirty(); }
}
/// <summary>
/// 图形的颜色。
/// </summary>
public Color32 color
{
get { return m_Color; }
set { if (PropertyUtil.SetStruct(ref m_Color, value)) SetAllDirty(); }
}
public Vector3 offset3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
/// <summary>
@@ -313,84 +179,11 @@ namespace XCharts.Runtime
/// |带有涟漪特效动画的散点图的动画参数。
/// </summary>
public List<float> animationSize { get { return m_AnimationSize; } }
/// <summary>
/// 根据指定的sizeType获得标记的大小
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public float GetSize(List<double> data, float themeSize)
public Color32 GetColor(Color32 defaultColor)
{
switch (m_SizeType)
{
case SymbolSizeType.Custom:
return size == 0 ? themeSize : size;
case SymbolSizeType.FromData:
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
{
return (float)data[dataIndex] * m_DataScale;
}
else
{
return size == 0 ? themeSize : size;
}
case SymbolSizeType.Function:
if (data != null && sizeFunction != null) return sizeFunction(data);
else return size == 0 ? themeSize : size;
default: return size == 0 ? themeSize : size;
}
}
/// <summary>
/// 根据sizeType获得高亮时的标记大小
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public float GetSelectedSize(List<double> data, float themeSelectedSize)
{
switch (m_SizeType)
{
case SymbolSizeType.Custom:
return selectedSize == 0 ? themeSelectedSize : selectedSize;
case SymbolSizeType.FromData:
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
{
return (float)data[dataIndex] * m_SelectedDataScale;
}
else
{
return selectedSize == 0 ? themeSelectedSize : selectedSize;
}
case SymbolSizeType.Function:
if (data != null && selectedSizeFunction != null)
return selectedSizeFunction(data);
else
return selectedSize == 0 ? themeSelectedSize : selectedSize;
default: return selectedSize == 0 ? themeSelectedSize : selectedSize;
}
}
public bool ShowSymbol(int dataIndex, int dataCount)
{
if (!show)
return false;
if (dataIndex < startIndex)
return false;
if (m_Interval <= 0)
return true;
if (m_ForceShowLast && dataIndex == dataCount - 1)
return true;
return (dataIndex - startIndex) % (m_Interval + 1) == 0;
return ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
}
}
}

View File

@@ -41,7 +41,7 @@ namespace XCharts.Runtime
private ChartLabel m_Label;
private List<float> m_FpsList = new List<float>();
public bool showAllChartObject { get { return m_ShowAllChartObject; } }
public bool showAllChartObject { get { return m_ShowAllChartObject; } set { m_ShowAllChartObject = value; } }
public bool foldSeries { get { return m_FoldSeries; } set { m_FoldSeries = value; } }
public float fps { get; private set; }
public float avgFps { get; private set; }

View File

@@ -93,14 +93,14 @@ namespace XCharts.Runtime
int clickedIndex = int.Parse(temp[0]);
if (legend.selectedMode == Legend.SelectedMode.Multiple)
{
chart.OnLegendButtonClick(clickedIndex, selectedName, !chart.IsActiveByLegend(selectedName));
OnLegendButtonClick(legend, clickedIndex, selectedName, !chart.IsActiveByLegend(selectedName));
}
else
{
var btnList = legend.context.buttonList.Values.ToArray();
if (btnList.Length == 1)
{
chart.OnLegendButtonClick(0, selectedName, !chart.IsActiveByLegend(selectedName));
OnLegendButtonClick(legend, 0, selectedName, !chart.IsActiveByLegend(selectedName));
}
else
{
@@ -109,7 +109,7 @@ namespace XCharts.Runtime
temp = btnList[n].name.Split('_');
selectedName = btnList[n].legendName;
var index = btnList[n].index;
chart.OnLegendButtonClick(n, selectedName, index == clickedIndex ? true : false);
OnLegendButtonClick(legend, n, selectedName, index == clickedIndex ? true : false);
}
}
}
@@ -120,7 +120,7 @@ namespace XCharts.Runtime
var temp = item.button.name.Split('_');
string selectedName = temp[1];
int index = int.Parse(temp[0]);
chart.OnLegendButtonEnter(index, selectedName);
OnLegendButtonEnter(legend, index, selectedName);
});
ChartHelper.AddEventListener(item.button.gameObject, EventTriggerType.PointerExit, (data) =>
{
@@ -128,7 +128,7 @@ namespace XCharts.Runtime
var temp = item.button.name.Split('_');
string selectedName = temp[1];
int index = int.Parse(temp[0]);
chart.OnLegendButtonExit(index, selectedName);
OnLegendButtonExit(legend, index, selectedName);
});
}
LegendHelper.ResetItemPosition(legend, chart.chartPosition, chart.chartWidth, chart.chartHeight);
@@ -136,6 +136,27 @@ namespace XCharts.Runtime
legend.refreshComponent();
}
private void OnLegendButtonClick(Legend legend, int index, string legendName, bool show)
{
chart.OnLegendButtonClick(index, legendName, show);
if (chart.onLegendClick != null)
chart.onLegendClick(legend, index, legendName, show);
}
private void OnLegendButtonEnter(Legend legend, int index, string legendName)
{
chart.OnLegendButtonEnter(index, legendName);
if (chart.onLegendEnter != null)
chart.onLegendEnter(legend, index, legendName);
}
private void OnLegendButtonExit(Legend legend, int index, string legendName)
{
chart.OnLegendButtonExit(index, legendName);
if (chart.onLegendExit != null)
chart.onLegendExit(legend, index, legendName);
}
private void DrawLegend(VertexHelper vh)
{
if (chart.series.Count == 0) return;

View File

@@ -62,7 +62,7 @@ namespace XCharts.Runtime
UpdateRuntimeData(markArea);
var colorIndex = chart.GetLegendRealShowNameIndex(serie.serieName);
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
var serieColor = SerieHelper.GetLineColor(serie, null, chart.theme, colorIndex, false);
var areaColor = markArea.itemStyle.GetColor(serieColor);
UGL.DrawRectangle(vh, markArea.runtimeRect, areaColor, areaColor);

View File

@@ -48,7 +48,7 @@ namespace XCharts.Runtime
var serie = chart.GetSerie(markLine.serieIndex);
if (!serie.show || !markLine.show) return;
ResetTempMarkLineGroupData(markLine);
var serieColor = (Color)chart.theme.GetColor(chart.GetLegendRealShowNameIndex(serie.serieName));
var serieColor = (Color) chart.GetItemColor(serie);
if (m_TempGroupData.Count > 0)
{
foreach (var kv in m_TempGroupData)
@@ -242,11 +242,10 @@ namespace XCharts.Runtime
private void DrawMarkLineSymbol(VertexHelper vh, SymbolStyle symbol, Serie serie, GridCoord grid, ThemeStyle theme,
Vector3 pos, Vector3 startPos, Color32 lineColor)
{
var symbolSize = symbol.GetSize(null, theme.serie.lineSymbolSize);
var tickness = SerieHelper.GetSymbolBorder(serie, null, theme, false);
var borderColor = SerieHelper.GetSymbolBorderColor(serie, null, theme, false);
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, null, false);
chart.DrawClipSymbol(vh, symbol.type, symbolSize, tickness, pos, lineColor, lineColor,
chart.DrawClipSymbol(vh, symbol.type, symbol.size, tickness, pos, lineColor, lineColor,
ColorUtil.clearColor32, borderColor, symbol.gap, true, cornerRadius, grid, startPos);
}

View File

@@ -81,6 +81,7 @@ namespace XCharts.Runtime
[SerializeField] private bool m_AlwayShowContent = false;
[SerializeField] private Vector2 m_Offset = new Vector2(18f, -25f);
[SerializeField] private Sprite m_BackgroundImage;
[SerializeField] private Image.Type m_BackgroundType = Image.Type.Simple;
[SerializeField] private Color m_BackgroundColor;
[SerializeField] private float m_BorderWidth = 2f;
[SerializeField] private bool m_FixedXEnable = false;
@@ -241,6 +242,11 @@ namespace XCharts.Runtime
/// </summary>
public Sprite backgroundImage { get { return m_BackgroundImage; } set { m_BackgroundImage = value; SetComponentDirty(); } }
/// <summary>
/// The background type of tooltip.
/// |提示框的背景图片显示类型。
/// </summary>
public Image.Type backgroundType { get { return m_BackgroundType; } set { m_BackgroundType = value; SetComponentDirty(); } }
/// <summary>
/// The background color of tooltip.
/// |提示框的背景颜色。
/// </summary>

View File

@@ -218,11 +218,14 @@ namespace XCharts.Runtime
view.transform = view.gameObject.transform;
view.background = ChartHelper.GetOrAddComponent<Image>(view.gameObject);
view.background.sprite = tooltip.backgroundImage;
view.background.type = tooltip.backgroundType;
view.background.color = ChartHelper.IsClearColor(tooltip.backgroundColor)
? Color.white : tooltip.backgroundColor;
view.border = ChartHelper.GetOrAddComponent<Outline>(view.gameObject);
view.border.enabled = tooltip.borderWidth > 0;
view.border.useGraphicAlpha = false;
view.border.effectColor = tooltip.borderColor;
view.border.effectDistance = new Vector2(tooltip.borderWidth, -tooltip.borderWidth);

View File

@@ -138,7 +138,7 @@ namespace XCharts.Runtime
var value = serie.GetData(bIndex, dimensionIndex, dataZoom);
if (isPercent)
{
var total = serie.GetDataTotal(dimensionIndex);
var total = serie.GetDataTotal(dimensionIndex, serie.GetSerieData(bIndex));
var percent = total == 0 ? 0 : value / serie.yTotal * 100;
content = content.Replace(old, ChartCached.FloatToStr(percent, numericFormatter));
}

View File

@@ -432,7 +432,7 @@ namespace XCharts.Runtime
}
}
public static SymbolStyle GetSerieSymbol(Serie serie, SerieData serieData)
public static SerieSymbol GetSerieSymbol(Serie serie, SerieData serieData)
{
if (!serie.IsPerformanceMode() && serieData.symbol != null) return serieData.symbol;
else return serie.symbol;

View File

@@ -105,7 +105,21 @@ namespace XCharts.Runtime
/// 坐标轴变更数据索引时回调。参数axis, dataIndex/dataValue
/// </summary>
public Action<Axis, double> onAxisPointerValueChanged { set { m_OnAxisPointerValueChanged = value; } get { return m_OnAxisPointerValueChanged; } }
/// <summary>
/// the callback function of click legend.
/// |点击图例按钮回调。参数legendIndex, legendName, show
/// </summary>
public Action<Legend, int, string, bool> onLegendClick { set { m_OnLegendClick = value; } internal get { return m_OnLegendClick; } }
/// <summary>
/// the callback function of enter legend.
/// |鼠标进入图例回调。参数legendIndex, legendName
/// </summary>
public Action<Legend, int, string> onLegendEnter { set { m_OnLegendEnter = value; } internal get { return m_OnLegendEnter; } }
/// <summary>
/// the callback function of exit legend.
/// |鼠标退出图例回调。参数legendIndex, legendName
/// </summary>
public Action<Legend, int, string> onLegendExit { set { m_OnLegendExit = value; } internal get { return m_OnLegendExit; } }
public void Init(bool defaultChart = true)
{
if (defaultChart)
@@ -120,14 +134,37 @@ namespace XCharts.Runtime
}
/// <summary>
/// Redraw chart in next frame.
/// |在下一帧刷新图表。
/// |在下一帧刷新整个图表。
/// </summary>
public void RefreshChart()
{
foreach (var serie in m_Series)
serie.ResetInteract();
m_RefreshChart = true;
if (m_Painter) m_Painter.Refresh();
}
/// <summary>
/// Redraw chart serie in next frame.
/// |在下一帧刷新图表的指定serie。
/// </summary>
public void RefreshChart(int serieIndex)
{
RefreshPainter(GetSerie(serieIndex));
}
/// <summary>
/// Redraw chart serie in next frame.
/// |在下一帧刷新图表的指定serie。
/// </summary>
public void RefreshChart(Serie serie)
{
if (serie == null) return;
serie.ResetInteract();
RefreshPainter(serie);
}
/// <summary>
/// Remove all series and legend data.
/// |It just emptying all of serie's data without emptying the list of series.
@@ -487,5 +524,18 @@ namespace XCharts.Runtime
var background = GetChartComponent<Background>();
return theme.GetBackgroundColor(background);
}
public Color32 GetItemColor(Serie serie, SerieData serieData, bool highlight = false)
{
var colorIndex = serieData == null || !serie.useDataNameForColor
? GetLegendRealShowNameIndex(serie.legendName)
: GetLegendRealShowNameIndex(serieData.legendName);
return SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
}
public Color32 GetItemColor(Serie serie, bool highlight = false)
{
return SerieHelper.GetItemColor(serie, null, m_Theme, serie.context.colorIndex, highlight);
}
}
}

View File

@@ -88,6 +88,9 @@ namespace XCharts.Runtime
protected Action<PointerEventData, int, int> m_OnPointerClickPie;
protected Action<PointerEventData, int> m_OnPointerClickBar;
protected Action<Axis, double> m_OnAxisPointerValueChanged;
protected Action<Legend, int, string, bool> m_OnLegendClick;
protected Action<Legend, int, string> m_OnLegendEnter;
protected Action<Legend, int, string> m_OnLegendExit;
protected CustomDrawGaugePointerFunction m_CustomDrawGaugePointerFunction;
@@ -211,6 +214,7 @@ namespace XCharts.Runtime
public void RefreshPainter(Serie serie)
{
if (serie == null) return;
RefreshPainter(GetPainterIndexBySerie(serie));
}
@@ -363,9 +367,7 @@ namespace XCharts.Runtime
if (m_Painter == null) return;
if (m_RefreshChart)
{
m_Painter.Refresh();
foreach (var painter in m_PainterList) painter.Refresh();
if (m_PainterTop != null) m_PainterTop.Refresh();
CheckRefreshPainter();
m_RefreshChart = false;
}
}
@@ -400,7 +402,6 @@ namespace XCharts.Runtime
m_ChartPivot = m_GraphPivot;
m_ChartSizeDelta = m_GraphSizeDelta;
m_ChartRect = m_GraphRect;
SetAllComponentDirty();
OnCoordinateChanged();
RefreshChart();
@@ -553,6 +554,8 @@ namespace XCharts.Runtime
serie.context.dataPoints.Clear();
serie.context.dataIgnores.Clear();
serie.animation.context.isAllItemAnimationEnd = true;
if (!serie.context.pointerEnter)
serie.ResetInteract();
if (m_OnDrawSerieBefore != null)
{

View File

@@ -5,7 +5,7 @@ using UnityEngine.Events;
namespace XCharts.Runtime
{
internal class ObjectPool<T> where T : new()
public class ObjectPool<T> where T : new()
{
private readonly bool m_NewIfEmpty = true;
private readonly Stack<T> m_Stack = new Stack<T>();

View File

@@ -20,8 +20,8 @@ namespace XCharts.Runtime
[ExecuteInEditMode]
public static class XChartsMgr
{
public static readonly string version = "3.0.0-preview8";
public static readonly int versionDate = 20220426;
public static readonly string version = "3.0.0-preview9";
public static readonly int versionDate = 20220506;
public static string fullVersion { get { return version + "-" + versionDate; } }
internal static List<BaseChart> chartList = new List<BaseChart>();

View File

@@ -63,14 +63,10 @@ namespace XCharts.Runtime
serie.context.pointerEnter = false;
foreach (var serieData in serie.data)
{
var barColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false);
var barToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serie.context.colorIndex, false);
serieData.interact.SetColor(ref needInteract, barColor, barToColor);
}
if (needInteract)
{
chart.RefreshPainter(serie);
serieData.context.highlight = false;
serieData.interact.Reset();
}
chart.RefreshPainter(serie);
}
return;
}

View File

@@ -190,7 +190,7 @@ namespace XCharts.Runtime
var pY = 0f;
UpdateXYPosition(m_SerieGrid, isY, axis, relativedAxis, i, categoryWidth, barWidth, value, ref pX, ref pY);
var barHig = AxisHelper.GetAxisValueDistance(m_SerieGrid, relativedAxis, categoryWidth, relativedValue);
var barHig = AxisHelper.GetAxisValueLength(m_SerieGrid, relativedAxis, categoryWidth, relativedValue);
var currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
Vector3 plb, plt, prt, prb, top;

View File

@@ -11,8 +11,7 @@ namespace XCharts.Runtime
{
public override void DrawSerie(VertexHelper vh)
{
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
DrawCandlestickSerie(vh, colorIndex, serie);
DrawCandlestickSerie(vh, serie);
}
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
@@ -31,7 +30,7 @@ namespace XCharts.Runtime
title = category;
var color = chart.GetLegendRealShowNameColor(serie.serieName);
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false);
var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker);
var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
@@ -78,7 +77,7 @@ namespace XCharts.Runtime
}
}
private void DrawCandlestickSerie(VertexHelper vh, int colorIndex, Candlestick serie)
private void DrawCandlestickSerie(VertexHelper vh, Candlestick serie)
{
if (!serie.show) return;
if (serie.animation.HasFadeOut()) return;

View File

@@ -11,8 +11,7 @@ namespace XCharts.Runtime
{
public override void DrawSerie(VertexHelper vh)
{
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
DrawCandlestickSerie(vh, colorIndex, serie);
DrawCandlestickSerie(vh, serie);
}
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
@@ -31,7 +30,7 @@ namespace XCharts.Runtime
title = category;
var color = chart.GetLegendRealShowNameColor(serie.serieName);
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false);
var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker);
var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
@@ -78,7 +77,7 @@ namespace XCharts.Runtime
}
}
private void DrawCandlestickSerie(VertexHelper vh, int colorIndex, SimplifiedCandlestick serie)
private void DrawCandlestickSerie(VertexHelper vh, SimplifiedCandlestick serie)
{
if (!serie.show) return;
if (serie.animation.HasFadeOut()) return;

View File

@@ -21,8 +21,7 @@ namespace XCharts.Runtime
public override void DrawSerie(VertexHelper vh)
{
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
DrawHeatmapSerie(vh, colorIndex, serie);
DrawHeatmapSerie(vh, serie);
}
public override void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category,
@@ -120,7 +119,7 @@ namespace XCharts.Runtime
}
}
private void DrawHeatmapSerie(VertexHelper vh, int colorIndex, Heatmap serie)
private void DrawHeatmapSerie(VertexHelper vh, Heatmap serie)
{
if (serie.animation.HasFadeOut()) return;
XAxis xAxis;

View File

@@ -16,6 +16,22 @@ namespace XCharts.Runtime
private GridCoord m_SerieGrid;
private float m_LastLineWidth = 0f;
public override Vector3 GetSerieDataLabelOffset(SerieData serieData, LabelStyle label)
{
var invert = label.autoOffset
&& SerieHelper.IsDownPoint(serie, serieData.index)
&& (serie.areaStyle == null || !serie.areaStyle.show);
if (invert)
{
var offset = label.GetOffset(serie.context.insideRadius);
return new Vector3(offset.x, -offset.y, offset.z);
}
else
{
return label.GetOffset(serie.context.insideRadius);
}
}
private void UpdateSerieGridContext()
{
if (m_SerieGrid == null)
@@ -26,25 +42,17 @@ namespace XCharts.Runtime
{
if (m_LastCheckContextFlag != needCheck)
{
var needAnimation1 = false;
m_LastCheckContextFlag = needCheck;
serie.context.pointerItemDataIndex = -1;
serie.context.pointerEnter = false;
serie.interact.SetValue(ref needAnimation1, lineWidth, false);
foreach (var serieData in serie.data)
{
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
serieData.context.highlight = false;
serieData.interact.SetValue(ref needAnimation1, symbolSize);
}
if (needAnimation1)
{
if (SeriesHelper.IsStack(chart.series))
chart.RefreshTopPainter();
else
chart.RefreshPainter(serie);
serieData.interact.Reset();
}
if (SeriesHelper.IsStack(chart.series))
chart.RefreshTopPainter();
else
chart.RefreshPainter(serie);
}
return;
}

View File

@@ -240,6 +240,9 @@ namespace XCharts.Runtime
internal static void DrawSerieLine(VertexHelper vh, ThemeStyle theme, Serie serie, VisualMap visualMap,
GridCoord grid, Axis axis, Axis relativedAxis, float lineWidth)
{
if (!serie.lineStyle.show || serie.lineStyle.type == LineStyle.Type.None)
return;
var datas = serie.context.drawPoints;
var dataCount = datas.Count;
@@ -264,6 +267,7 @@ namespace XCharts.Runtime
var lineColor = SerieHelper.GetLineColor(serie, null, theme, serie.context.colorIndex, false);
var lastDataIsIgnore = datas[0].isIgnoreBreak;
var smooth = serie.lineType == LineType.Smooth;
for (int i = 1; i < dataCount; i++)
{
var cdata = datas[i];
@@ -281,6 +285,42 @@ namespace XCharts.Runtime
if (AnimationStyleHelper.GetAnimationPosition(serie.animation, isY, lp, cp, progress, ref ip))
cp = np = ip;
}
serie.context.lineEndPostion = cp;
serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
lastDataIsIgnore = isIgnore;
var handled = false;
if (!smooth)
{
switch (serie.lineStyle.type)
{
case LineStyle.Type.Dashed:
UGL.DrawDashLine(vh, lp, cp, lineWidth, lineColor, lineColor, 0, 0);
handled = true;
break;
case LineStyle.Type.Dotted:
UGL.DrawDotLine(vh, lp, cp, lineWidth, lineColor, lineColor, 0, 0);
handled = true;
break;
case LineStyle.Type.DashDot:
UGL.DrawDashDotLine(vh, lp, cp, lineWidth, lineColor, 0, 0, 0);
handled = true;
break;
case LineStyle.Type.DashDotDot:
UGL.DrawDashDotDotLine(vh, lp, cp, lineWidth, lineColor, 0, 0, 0);
handled = true;
break;
case LineStyle.Type.None:
handled = true;
break;
}
}
if (handled)
{
if (isBreak)
break;
else
continue;
}
bool bitp = true, bibp = true;
UGLHelper.GetLinePoints(lp, cp, np, lineWidth,
ref ltp, ref lbp,
@@ -288,7 +328,6 @@ namespace XCharts.Runtime
ref itp, ref ibp,
ref clp, ref crp,
ref bitp, ref bibp, i);
if (i == 1)
{
AddLineVertToVertexHelper(vh, ltp, lbp, lineColor, isVisualMapGradient, isLineStyleGradient,
@@ -333,9 +372,7 @@ namespace XCharts.Runtime
visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
}
}
serie.context.lineEndPostion = cp;
serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
lastDataIsIgnore = isIgnore;
if (isBreak)
break;
}

View File

@@ -19,15 +19,14 @@ namespace XCharts.Runtime
public override void DrawSerie(VertexHelper vh)
{
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
DrawParallelSerie(vh, colorIndex, serie);
DrawParallelSerie(vh, serie);
}
private void UpdateSerieContext()
{
}
private void DrawParallelSerie(VertexHelper vh, int colorIndex, Parallel serie)
private void DrawParallelSerie(VertexHelper vh, Parallel serie)
{
if (!serie.show) return;
if (serie.animation.HasFadeOut()) return;
@@ -42,7 +41,7 @@ namespace XCharts.Runtime
var animationIndex = serie.animation.GetCurrIndex();
var isHorizonal = parallel.orient == Orient.Horizonal;
var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, colorIndex, false);
var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex, false);
var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
float currDetailProgress = !isHorizonal

View File

@@ -77,8 +77,8 @@ namespace XCharts.Runtime
refresh = true;
for (int j = 0; j < serie.data.Count; j++)
{
if (j == index) serie.data[j].selected = !serie.data[j].selected;
else serie.data[j].selected = false;
if (j == index) serie.data[j].context.selected = !serie.data[j].context.selected;
else serie.data[j].context.selected = false;
}
if (chart.onPointerClickPie != null)
{
@@ -406,8 +406,7 @@ namespace XCharts.Runtime
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
if (serieLabel != null && serieLabel.show
&& labelLine != null && labelLine.show
&& (serieLabel.position == LabelStyle.Position.Outside
|| serieLabel.position == LabelStyle.Position.Default))
&& (serieLabel.IsDefaultPosition(LabelStyle.Position.Outside)))
{
var insideRadius = serieData.context.insideRadius;
var outSideRadius = serieData.context.outsideRadius;

View File

@@ -55,7 +55,7 @@ namespace XCharts.Runtime
if (serieData == null)
return;
var color = chart.theme.GetColor(dataIndex);
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, dataIndex, false);;
title = serieData.name;
for (int i = 0; i < serieData.data.Count; i++)
{
@@ -221,7 +221,7 @@ namespace XCharts.Runtime
var areaStyle = SerieHelper.GetAreaStyle(serie, serieData);
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
var isHighlight = serieData.context.highlight;
var colorIndex = chart.GetLegendRealShowNameIndex(serieData.name);
var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName);
var areaColor = SerieHelper.GetAreaColor(serie, serieData, chart.theme, colorIndex, isHighlight);
var areaToColor = SerieHelper.GetAreaToColor(serie, serieData, chart.theme, colorIndex, isHighlight);
var lineColor = SerieHelper.GetLineColor(serie, serieData, chart.theme, colorIndex, isHighlight);

View File

@@ -32,5 +32,12 @@ namespace XCharts.Runtime
chart.AddData(serie.index, value, max, "data1");
return serie;
}
public override double GetDataTotal(int dimension, SerieData serieData = null)
{
if (serieData == null || serieData.data.Count <= 1)
return base.GetDataTotal(dimension, serieData);
return serieData.GetData(1);
}
}
}

View File

@@ -96,7 +96,7 @@ namespace XCharts.Runtime
param.serieData = serieData;
param.value = serieData.GetData(0);
param.total = serieData.GetData(1);
param.color = chart.theme.GetColor(dataIndex);
param.color = SerieHelper.GetItemColor(serie, serieData, chart.theme, dataIndex, false);
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); ;
@@ -116,22 +116,24 @@ namespace XCharts.Runtime
var toAngle = serieData.context.toAngle;
switch (label.position)
{
case LabelStyle.Position.Center:
serieData.context.labelPosition = serie.context.center + label.offset;
break;
case LabelStyle.Position.Bottom:
case LabelStyle.Position.Start:
var px1 = Mathf.Sin(startAngle * Mathf.Deg2Rad) * centerRadius;
var py1 = Mathf.Cos(startAngle * Mathf.Deg2Rad) * centerRadius;
var xDiff = serie.clockwise ? -label.distance : label.distance;
serieData.context.labelPosition = serie.context.center + new Vector3(px1 + xDiff, py1);
break;
case LabelStyle.Position.Top:
case LabelStyle.Position.End:
startAngle += serie.clockwise ? -label.distance : label.distance;
toAngle += serie.clockwise ? label.distance : -label.distance;
var px2 = Mathf.Sin(toAngle * Mathf.Deg2Rad) * centerRadius;
var py2 = Mathf.Cos(toAngle * Mathf.Deg2Rad) * centerRadius;
serieData.context.labelPosition = serie.context.center + new Vector3(px2, py2);
break;
default: //LabelStyle.Position.Center
serieData.context.labelPosition = serie.context.center + label.offset;
break;
}
return serieData.context.labelPosition;
}
@@ -157,8 +159,9 @@ namespace XCharts.Runtime
var startDegree = GetStartAngle(serie);
var toDegree = GetToAngle(serie, degree);
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight);
var itemColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, serieData.context.highlight);
var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, serieData.context.highlight);
var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName);
var itemColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, serieData.context.highlight);
var itemToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, serieData.context.highlight);
var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.gap);
var insideRadius = outsideRadius - ringWidth;
var borderWidth = itemStyle.borderWidth;
@@ -169,12 +172,7 @@ namespace XCharts.Runtime
serieData.context.toAngle = serie.clockwise ? toDegree : startDegree;
serieData.context.insideRadius = insideRadius;
serieData.context.outsideRadius = serieData.radius > 0 ? serieData.radius : outsideRadius;
if (itemStyle.backgroundColor.a != 0)
{
UGL.DrawDoughnut(vh, serie.context.center, insideRadius, outsideRadius, itemStyle.backgroundColor,
itemStyle.backgroundColor, Color.clear, 0, 360, borderWidth, borderColor, 0,
chart.settings.cicleSmoothness, false, serie.clockwise);
}
DrawBackground(vh, serie, serieData, j, insideRadius, outsideRadius);
UGL.DrawDoughnut(vh, serie.context.center, insideRadius, outsideRadius, itemColor, itemToColor,
Color.clear, startDegree, toDegree, borderWidth, borderColor, 0, chart.settings.cicleSmoothness,
roundCap, serie.clockwise);

View File

@@ -36,7 +36,7 @@ namespace XCharts.Runtime
param.category = category;
param.dimension = 1;
param.serieData = serieData;
param.color = chart.theme.GetColor(serie.index);
param.color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false);
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
@@ -52,15 +52,13 @@ namespace XCharts.Runtime
public override void DrawSerie(VertexHelper vh)
{
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
if (serie.IsUseCoord<SingleAxisCoord>())
{
DrawSingAxisScatterSerie(vh, colorIndex, serie);
DrawSingAxisScatterSerie(vh, serie);
}
else if (serie.IsUseCoord<GridCoord>())
{
DrawScatterSerie(vh, colorIndex, serie);
DrawScatterSerie(vh, serie);
}
}
@@ -107,7 +105,7 @@ namespace XCharts.Runtime
}
}
protected virtual void DrawScatterSerie(VertexHelper vh, int colorIndex, BaseScatter serie)
protected virtual void DrawScatterSerie(VertexHelper vh, BaseScatter serie)
{
if (serie.animation.HasFadeOut())
return;
@@ -141,6 +139,7 @@ namespace XCharts.Runtime
var interacting = false;
var dataList = serie.GetDataList(xDataZoom);
var isEffectScatter = serie is EffectScatter;
var colorIndex = serie.context.colorIndex;
serie.containerIndex = m_Grid.index;
serie.containterInstanceId = m_Grid.instanceId;
@@ -218,7 +217,7 @@ namespace XCharts.Runtime
}
}
protected virtual void DrawSingAxisScatterSerie(VertexHelper vh, int colorIndex, BaseScatter serie)
protected virtual void DrawSingAxisScatterSerie(VertexHelper vh, BaseScatter serie)
{
if (serie.animation.HasFadeOut())
return;
@@ -245,6 +244,7 @@ namespace XCharts.Runtime
var dataChanging = false;
var dataList = serie.GetDataList(xDataZoom);
var isEffectScatter = serie is EffectScatter;
var colorIndex = serie.context.colorIndex;
serie.containerIndex = axis.index;
serie.containterInstanceId = axis.instanceId;

View File

@@ -230,7 +230,7 @@ namespace XCharts.Runtime
[SerializeField] private bool m_InsertDataToHead;
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
[SerializeField] private SymbolStyle m_Symbol = new SymbolStyle();
[SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
[SerializeField] private AnimationStyle m_Animation = new AnimationStyle();
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
@@ -396,7 +396,7 @@ namespace XCharts.Runtime
/// the symbol of serie data item.
/// |标记的图形。
/// </summary>
public SymbolStyle symbol
public SerieSymbol symbol
{
get { return m_Symbol; }
set { if (PropertyUtil.SetClass(ref m_Symbol, value, true)) SetVerticesDirty(); }
@@ -821,12 +821,14 @@ namespace XCharts.Runtime
return m_VertsDirty ||
symbol.vertsDirty ||
lineStyle.vertsDirty ||
(lineArrow != null && lineArrow.vertsDirty) ||
itemStyle.vertsDirty ||
(lineArrow != null && lineArrow.vertsDirty) ||
(areaStyle != null && areaStyle.vertsDirty) ||
(label != null && label.vertsDirty) ||
(labelLine != null && labelLine.vertsDirty) ||
(emphasis != null && emphasis.vertsDirty) ||
(titleStyle != null && titleStyle.vertsDirty);
(titleStyle != null && titleStyle.vertsDirty) ||
AnySerieDataVerticesDirty();
}
}
@@ -835,12 +837,17 @@ namespace XCharts.Runtime
get
{
return m_ComponentDirty
|| (titleStyle != null && titleStyle.componentDirty);
|| symbol.componentDirty
|| (titleStyle != null && titleStyle.componentDirty)
|| (label != null && label.componentDirty)
|| (labelLine != null && labelLine.componentDirty);
}
}
public override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
foreach (var serieData in m_Data)
serieData.ClearVerticesDirty();
symbol.ClearVerticesDirty();
lineStyle.ClearVerticesDirty();
itemStyle.ClearVerticesDirty();
@@ -859,6 +866,8 @@ namespace XCharts.Runtime
public override void ClearComponentDirty()
{
base.ClearComponentDirty();
foreach (var serieData in m_Data)
serieData.ClearComponentDirty();
symbol.ClearComponentDirty();
lineStyle.ClearComponentDirty();
itemStyle.ClearComponentDirty();
@@ -880,6 +889,24 @@ namespace XCharts.Runtime
labelDirty = true;
titleDirty = true;
}
private bool AnySerieDataVerticesDirty()
{
if (this is ISimplifiedSerie)
return false;
foreach (var serieData in m_Data)
if (serieData.vertsDirty) return true;
return false;
}
private bool AnySerieDataComponentDirty()
{
if (this is ISimplifiedSerie)
return false;
foreach (var serieData in m_Data)
if (serieData.componentDirty) return true;
return false;
}
/// <summary>
/// Whether the serie is highlighted.
/// |该系列是否高亮,一般由图例悬停触发。
@@ -1032,6 +1059,12 @@ namespace XCharts.Runtime
}
}
public void ResetInteract()
{
foreach (var serieData in m_Data)
serieData.interact.Reset();
}
/// <summary>
/// 清空所有数据
/// </summary>
@@ -1398,7 +1431,7 @@ namespace XCharts.Runtime
}
}
public virtual double GetDataTotal(int dimension)
public virtual double GetDataTotal(int dimension, SerieData serieData = null)
{
if (m_Max > 0) return m_Max;
@@ -1553,7 +1586,8 @@ namespace XCharts.Runtime
public bool IsIgnoreValue(SerieData serieData, int dimension = 1)
{
if (serieData.ignore) return true;
if (serieData.baseInfo != null && serieData.baseInfo.ignore)
return true;
return IsIgnoreValue(serieData.GetData(dimension));
}

View File

@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using XUGL;
namespace XCharts.Runtime
{
@@ -16,11 +17,12 @@ namespace XCharts.Runtime
[SerializeField] private string m_Name;
[SerializeField] private string m_Id;
[SerializeField] private string m_ParentId;
[SerializeField] private List<SerieDataBaseInfo> m_BaseInfos = new List<SerieDataBaseInfo>();
[SerializeField] private List<ItemStyle> m_ItemStyles = new List<ItemStyle>();
[SerializeField] private List<LabelStyle> m_Labels = new List<LabelStyle>();
[SerializeField] private List<LabelLine> m_LabelLines = new List<LabelLine>();
[SerializeField] private List<Emphasis> m_Emphases = new List<Emphasis>();
[SerializeField] private List<SymbolStyle> m_Symbols = new List<SymbolStyle>();
[SerializeField] private List<SerieSymbol> m_Symbols = new List<SerieSymbol>();
[SerializeField] private List<LineStyle> m_LineStyles = new List<LineStyle>();
[SerializeField] private List<AreaStyle> m_AreaStyles = new List<AreaStyle>();
[SerializeField] private List<TitleStyle> m_TitleStyles = new List<TitleStyle>();
@@ -28,9 +30,7 @@ namespace XCharts.Runtime
[NonSerialized] public SerieDataContext context = new SerieDataContext();
[NonSerialized] public InteractData interact = new InteractData();
[NonSerialized] private bool m_Ignore = false;
[NonSerialized] private bool m_Selected;
[NonSerialized] private float m_Radius;
public ChartLabel labelObject { get; set; }
public ChartLabel titleObject { get; set; }
@@ -52,15 +52,8 @@ namespace XCharts.Runtime
/// </summary>
/// <value></value>
public string legendName { get { return string.IsNullOrEmpty(name) ? ChartCached.IntToStr(index) : name; } }
/// <summary>
/// 自定义半径。可用在饼图中自定义某个数据项的半径。
/// </summary>
public float radius { get { return m_Radius; } set { m_Radius = value; } }
/// <summary>
/// Whether the data item is selected.
/// |该数据项是否被选中。
/// </summary>
public bool selected { get { return m_Selected; } set { m_Selected = value; } }
public SerieDataBaseInfo baseInfo { get { return m_BaseInfos.Count > 0 ? m_BaseInfos[0] : null; } }
/// <summary>
/// 单个数据项的标签设置。
/// </summary>
@@ -77,18 +70,11 @@ namespace XCharts.Runtime
/// <summary>
/// 单个数据项的标记设置。
/// </summary>
public SymbolStyle symbol { get { return m_Symbols.Count > 0 ? m_Symbols[0] : null; } }
public SerieSymbol symbol { get { return m_Symbols.Count > 0 ? m_Symbols[0] : null; } }
public LineStyle lineStyle { get { return m_LineStyles.Count > 0 ? m_LineStyles[0] : null; } }
public AreaStyle areaStyle { get { return m_AreaStyles.Count > 0 ? m_AreaStyles[0] : null; } }
public TitleStyle titleStyle { get { return m_TitleStyles.Count > 0 ? m_TitleStyles[0] : null; } }
/// <summary>
/// 是否忽略数据。当为 true 时,数据不进行绘制。
/// </summary>
public bool ignore
{
get { return m_Ignore; }
set { if (PropertyUtil.SetStruct(ref m_Ignore, value)) SetVerticesDirty(); }
}
/// <summary>
/// An arbitrary dimension data list of data item.
/// |可指定任意维数的数值列表。
@@ -99,12 +85,64 @@ namespace XCharts.Runtime
/// |该数据项是否要显示。
/// </summary>
public bool show { get { return m_Show; } set { m_Show = value; } }
public float radius { get { return baseInfo != null ? baseInfo.radius : 0; } }
public bool selected { get { return (baseInfo != null && baseInfo.selected) || context.selected; } }
private List<double> m_PreviousData = new List<double>();
private List<float> m_DataUpdateTime = new List<float>();
private List<bool> m_DataUpdateFlag = new List<bool>();
private List<Vector2> m_PolygonPoints = new List<Vector2>();
public override bool vertsDirty
{
get
{
return m_VertsDirty
|| (baseInfo != null && baseInfo.vertsDirty)
|| (labelLine != null && labelLine.vertsDirty)
|| (itemStyle != null && itemStyle.vertsDirty)
|| (symbol != null && symbol.vertsDirty)
|| (lineStyle != null && lineStyle.vertsDirty)
|| (areaStyle != null && areaStyle.vertsDirty);
}
}
public override bool componentDirty
{
get
{
return m_ComponentDirty
|| (baseInfo != null && baseInfo.componentDirty)
|| (labelStyle != null && labelStyle.componentDirty)
|| (labelLine != null && labelLine.componentDirty)
|| (titleStyle != null && titleStyle.componentDirty)
|| (emphasis != null && emphasis.componentDirty);
}
}
public override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
if (baseInfo != null) baseInfo.ClearVerticesDirty();
if (labelLine != null) labelLine.ClearVerticesDirty();
if (itemStyle != null) itemStyle.ClearVerticesDirty();
if (lineStyle != null) lineStyle.ClearVerticesDirty();
if (areaStyle != null) areaStyle.ClearVerticesDirty();
if (symbol != null) symbol.ClearVerticesDirty();
if (emphasis != null) emphasis.ClearVerticesDirty();
}
public override void ClearComponentDirty()
{
base.ClearComponentDirty();
if (baseInfo != null) baseInfo.ClearComponentDirty();
if (labelLine != null) labelLine.ClearComponentDirty();
if (itemStyle != null) itemStyle.ClearComponentDirty();
if (lineStyle != null) lineStyle.ClearComponentDirty();
if (areaStyle != null) areaStyle.ClearComponentDirty();
if (symbol != null) symbol.ClearComponentDirty();
if (emphasis != null) emphasis.ClearComponentDirty();
}
public void Reset()
{
index = 0;
@@ -113,14 +151,13 @@ namespace XCharts.Runtime
labelObject = null;
m_Name = string.Empty;
m_Show = true;
m_Selected = false;
m_Radius = 0;
context.Reset();
interact.Reset();
m_Data.Clear();
m_PreviousData.Clear();
m_DataUpdateTime.Clear();
m_DataUpdateFlag.Clear();
m_BaseInfos.Clear();
m_Labels.Clear();
m_LabelLines.Clear();
m_ItemStyles.Clear();
@@ -140,6 +177,12 @@ namespace XCharts.Runtime
m_ItemStyles.Add(new ItemStyle() { show = true });
return m_ItemStyles[0] as T;
}
else if (type == typeof(SerieDataBaseInfo))
{
if (m_BaseInfos.Count == 0)
m_BaseInfos.Add(new SerieDataBaseInfo() { });
return m_BaseInfos[0] as T;
}
else if (type == typeof(LabelStyle))
{
if (m_Labels.Count == 0)
@@ -158,10 +201,10 @@ namespace XCharts.Runtime
m_Emphases.Add(new Emphasis() { show = true });
return m_Emphases[0] as T;
}
else if (type == typeof(SymbolStyle))
else if (type == typeof(SerieSymbol))
{
if (m_Symbols.Count == 0)
m_Symbols.Add(new SymbolStyle() { show = true });
m_Symbols.Add(new SerieSymbol() { show = true });
return m_Symbols[0] as T;
}
else if (type == typeof(LineStyle))
@@ -190,6 +233,7 @@ namespace XCharts.Runtime
public void RemoveAllComponent()
{
m_BaseInfos.Clear();
m_ItemStyles.Clear();
m_Labels.Clear();
m_LabelLines.Clear();
@@ -205,13 +249,15 @@ namespace XCharts.Runtime
var type = typeof(T);
if (type == typeof(ItemStyle))
m_ItemStyles.Clear();
else if (type == typeof(SerieDataBaseInfo))
m_BaseInfos.Clear();
else if (type == typeof(LabelStyle))
m_Labels.Clear();
else if (type == typeof(LabelLine))
m_LabelLines.Clear();
else if (type == typeof(Emphasis))
m_Emphases.Clear();
else if (type == typeof(SymbolStyle))
else if (type == typeof(SerieSymbol))
m_Symbols.Clear();
else if (type == typeof(LineStyle))
m_LineStyles.Clear();
@@ -434,18 +480,7 @@ namespace XCharts.Runtime
public bool IsInPolygon(Vector2 p)
{
if (m_PolygonPoints.Count == 0) return false;
var inside = false;
var j = m_PolygonPoints.Count - 1;
for (int i = 0; i < m_PolygonPoints.Count; j = i++)
{
var pi = m_PolygonPoints[i];
var pj = m_PolygonPoints[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;
return UGLHelper.IsPointInPolygon(p, m_PolygonPoints);
}
}
}

View File

@@ -48,6 +48,7 @@ namespace XCharts.Runtime
public double area;
public float angle;
public Vector3 offsetCenter;
public Vector3 areaCenter;
public float stackHeight;
public bool isClip;
public bool canShowLabel = true;
@@ -57,6 +58,7 @@ namespace XCharts.Runtime
/// |该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。
/// </summary>
public bool highlight;
public bool selected;
public void Reset()
{

View File

@@ -187,7 +187,16 @@ namespace XCharts.Runtime
private void InitRoot()
{
if (m_SerieRoot != null) return;
if (m_SerieRoot != null)
{
var rect = ChartHelper.GetOrAddComponent<RectTransform>(m_SerieRoot);
rect.localPosition = Vector3.zero;
rect.sizeDelta = chart.chartSizeDelta;
rect.anchorMin = chart.chartMinAnchor;
rect.anchorMax = chart.chartMaxAnchor;
rect.pivot = chart.chartPivot;
return;
}
var objName = s_SerieRootObjectName + "_" + serie.index;
m_SerieRoot = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
@@ -198,8 +207,7 @@ namespace XCharts.Runtime
private void InitSerieLabel()
{
if (m_SerieRoot == null)
InitRoot();
InitRoot();
m_SerieLabelRoot = ChartHelper.AddObject(s_SerieLabelObjectName, m_SerieRoot.transform,
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
m_SerieLabelRoot.hideFlags = chart.chartHideFlags;
@@ -241,7 +249,8 @@ namespace XCharts.Runtime
&& (serieEmphasisLabel == null || !serieEmphasisLabel.show))
return false;
var dataAutoColor = (Color)chart.theme.GetColor(serie.useDataNameForColor ? serieData.index : serie.index);
var colorIndex = serie.useDataNameForColor ? serieData.index : serie.index;
var dataAutoColor = (Color)SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false);
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index);
var label = ChartHelper.AddChartLabel(textName, serieLabelRoot.transform, serieLabel, chart.theme.common,
"", dataAutoColor, TextAnchor.MiddleCenter);
@@ -270,9 +279,8 @@ namespace XCharts.Runtime
}
return;
}
if (m_SerieRoot == null)
InitRoot();
var dataAutoColor = (Color)chart.theme.GetColor(serie.index);
InitRoot();
var dataAutoColor = (Color)chart.GetLegendRealShowNameColor(serie.legendName);
m_EndLabel = ChartHelper.AddChartLabel(s_SerieEndLabelObjectName, m_SerieRoot.transform, serie.endLabel,
chart.theme.common, "", dataAutoColor, TextAnchor.MiddleLeft);
m_EndLabel.SetActive(serie.endLabel.show);
@@ -281,8 +289,7 @@ namespace XCharts.Runtime
private void InitSerieTitle()
{
if (m_SerieRoot == null)
InitRoot();
InitRoot();
var serieTitleRoot = ChartHelper.AddObject(s_SerieTitleObjectName, m_SerieRoot.transform,
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
serieTitleRoot.hideFlags = chart.chartHideFlags;
@@ -295,8 +302,7 @@ namespace XCharts.Runtime
var serieData = serie.data[i];
var titleStyle = SerieHelper.GetTitleStyle(serie, serieData);
if (titleStyle == null) continue;
var color = chart.GetLegendRealShowNameColor(serieData.name);
var color = chart.GetItemColor(serie, serieData);
var label = ChartHelper.AddChartLabel("title_" + i, serieTitleRoot.transform, titleStyle, chart.theme.common,
serieData.name, color, TextAnchor.MiddleCenter);
serieData.titleObject = label;
@@ -312,8 +318,6 @@ namespace XCharts.Runtime
if (!m_InitedLabel)
return;
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
var total = serie.GetDataTotal(defaultDimension);
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
foreach (var serieData in serie.data)
@@ -331,34 +335,13 @@ namespace XCharts.Runtime
&& serieData.context.canShowLabel
&& !isIgnore)
{
//var value = serieData.GetData(defaultDimension);
var value = serieData.GetCurrData(defaultDimension, dataChangeDuration);
var total = serie.GetDataTotal(defaultDimension, serieData);
var color = chart.GetItemColor(serie, serieData);
var content = string.IsNullOrEmpty(currLabel.formatter)
? ChartCached.NumberToStr(value, serieLabel.numericFormatter)
: SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
currLabel, chart.theme.GetColor(colorIndex));
// var isInsidePosition = currLabel.position == LabelStyle.Position.Inside;
// //text color
// var textColor = chart.theme.common.textColor;
// if (!ChartHelper.IsClearColor(currLabel.textStyle.color))
// textColor = currLabel.textStyle.color;
// else if (isInsidePosition)
// textColor = Color.white;
// if (currLabel.textStyle.autoColor && serie.useDataNameForColor)
// textColor = chart.theme.GetColor(serieData.index);
// //text rotate
// var rotate = currLabel.textStyle.rotate;
// if (currLabel.textStyle.rotate > 0 && isInsidePosition)
// {
// var currAngle = serieData.context.halfAngle;
// if (currAngle > 0)
// {
// if (currAngle > 180) rotate += 270 - currAngle;
// else rotate += -(currAngle - 90);
// }
// }
// SerieLabelHelper.ResetLabel(serieData.labelObject.text, currLabel, chart.theme, textColor, rotate);
currLabel, color);
serieData.SetLabelActive(!isIgnore);
serieData.labelObject.SetText(content);
@@ -394,20 +377,21 @@ namespace XCharts.Runtime
private void UpdateLabelPosition(SerieData serieData, LabelStyle currLabel)
{
var isNeedInvertPositionSerie = serie is Line;
var invert = currLabel.autoOffset
&& isNeedInvertPositionSerie
&& SerieHelper.IsDownPoint(serie, serieData.index)
&& (serie.areaStyle == null || !serie.areaStyle.show);
var labelPosition = GetSerieDataLabelPosition(serieData, currLabel);
var offset = currLabel.GetOffset(serie.context.insideRadius);
serieData.labelObject.SetPosition(labelPosition
+ (invert ? -offset : offset));
var offset = GetSerieDataLabelOffset(serieData, currLabel);
serieData.labelObject.SetPosition(labelPosition + offset);
}
public virtual Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label)
{
return serieData.context.position;
return ChartHelper.IsZeroVector(serieData.context.labelPosition)
? serieData.context.position
: serieData.context.labelPosition;
}
public virtual Vector3 GetSerieDataLabelOffset(SerieData serieData, LabelStyle label)
{
return label.GetOffset(serie.context.insideRadius);
}
public virtual Vector3 GetSerieDataTitlePosition(SerieData serieData, TitleStyle titleStyle)
@@ -441,7 +425,7 @@ namespace XCharts.Runtime
param.serieData = serieData;
param.value = serieData.GetData(1);
param.total = serie.yTotal;
param.color = chart.GetLegendRealShowNameColor(serie.serieName);
param.color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false);
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
param.itemFormatter = itemFormatter;
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
@@ -472,6 +456,8 @@ namespace XCharts.Runtime
if (TooltipHelper.IsIgnoreItemFormatter(itemFormatter))
return;
var colorIndex = chart.GetLegendRealShowNameIndex(serieData.name);
var param = serie.context.param;
param.serieName = serie.serieName;
param.serieIndex = serie.index;
@@ -480,7 +466,7 @@ namespace XCharts.Runtime
param.serieData = serieData;
param.value = serieData.GetData(param.dimension);
param.total = SerieHelper.GetMaxData(serie, dimension);
param.color = chart.GetLegendRealShowNameColor(serieData.name);
param.color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false);
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
param.itemFormatter = itemFormatter;
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);

View File

@@ -355,5 +355,36 @@ namespace XUGL
var c3 = dire3.x * dire1.y - dire3.y * dire1.x;
return c1 * c2 >= 0 && c1 * c3 >= 0;
}
public static bool IsPointInPolygon(Vector3 p, List<Vector3> polyons)
{
if (polyons.Count == 0) return false;
var inside = false;
var j = polyons.Count - 1;
for (int i = 0; i < polyons.Count; 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<Vector2> polyons)
{
if (polyons.Count == 0) return false;
var inside = false;
var j = polyons.Count - 1;
for (int i = 0; i < polyons.Count; 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;
}
}
}

View File

@@ -1,9 +1,9 @@
{
"name": "com.monitor1394.xcharts",
"displayName": "XCharts",
"version": "3.0.0-preview8",
"date": "20220426",
"checkdate": "20220426",
"version": "3.0.0-preview9",
"date": "20220506",
"checkdate": "20220506",
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
"unity": "2018.3",
"description": "A charting and data visualization library for Unity.",