Compare commits
88 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3deda8d9cc | ||
|
|
7d4ba652ec | ||
|
|
619246bee2 | ||
|
|
52b9b0a03a | ||
|
|
3301d5fd36 | ||
|
|
92abee1a6c | ||
|
|
90e9187808 | ||
|
|
b311d17d94 | ||
|
|
880a6b1885 | ||
|
|
fb841a3498 | ||
|
|
ac41dd1d07 | ||
|
|
39cee1bd52 | ||
|
|
f1c9a3ac4b | ||
|
|
2cb82526bc | ||
|
|
0499126e55 | ||
|
|
c2bafb8aa8 | ||
|
|
c83fe89a31 | ||
|
|
dd473b7d29 | ||
|
|
d1f424f3a1 | ||
|
|
efbe16b804 | ||
|
|
2d2e45da80 | ||
|
|
06bd26dc5f | ||
|
|
a0dba26318 | ||
|
|
e124d38d3e | ||
|
|
21ffcba0c0 | ||
|
|
ccf815c853 | ||
|
|
fc0451e535 | ||
|
|
b23c581b63 | ||
|
|
eafd7276c0 | ||
|
|
3818d1213e | ||
|
|
85b92ca2cc | ||
|
|
546ff1f61a | ||
|
|
da360693e6 | ||
|
|
ad3bc75d7c | ||
|
|
0b218f6dfe | ||
|
|
9e07617cc4 | ||
|
|
8bc66ca30a | ||
|
|
20da9dbe94 | ||
|
|
62f071e5a9 | ||
|
|
4c001c8130 | ||
|
|
4ad4505720 | ||
|
|
47caaa2113 | ||
|
|
2f8a1300d3 | ||
|
|
e4e1a69e76 | ||
|
|
a1c7e1a64b | ||
|
|
1c3afc0255 | ||
|
|
42059d9ab9 | ||
|
|
24d13a36d3 | ||
|
|
247abb2e3f | ||
|
|
e8ea30a9fb | ||
|
|
a1ba6b095d | ||
|
|
e4923ea598 | ||
|
|
ffd2521360 | ||
|
|
e7aae593bf | ||
|
|
aea4aa7c8d | ||
|
|
f9f2428142 | ||
|
|
ffed67d8ee | ||
|
|
063b5529d7 | ||
|
|
a54c50d947 | ||
|
|
9ddc543ed7 | ||
|
|
214b84c71d | ||
|
|
9fc75c78d7 | ||
|
|
ec3d012f08 | ||
|
|
c6896677b8 | ||
|
|
29b1f8a8c2 | ||
|
|
ddbfd9b7ef | ||
|
|
b9c72c8cb9 | ||
|
|
d76b474a61 | ||
|
|
2acb841d2e | ||
|
|
8af1796ff8 | ||
|
|
78a07aa2ae | ||
|
|
fe867d18e6 | ||
|
|
757ccb04fb | ||
|
|
b4cb62241f | ||
|
|
0fb1cab302 | ||
|
|
ead9034870 | ||
|
|
20c87265a5 | ||
|
|
1e31cf3010 | ||
|
|
d33e2f66ef | ||
|
|
ff4fbb2176 | ||
|
|
9fc3ff862f | ||
|
|
bc31f86fcf | ||
|
|
c6412f5d78 | ||
|
|
0e60a26333 | ||
|
|
59bb60950b | ||
|
|
b3320bd2cd | ||
|
|
71cfbc15f3 | ||
|
|
8fbda1fa73 |
@@ -13,6 +13,7 @@ slug: /api
|
||||
- [AnimationAddition](#animationaddition)
|
||||
- [AnimationChange](#animationchange)
|
||||
- [AnimationEasing](#animationeasing)
|
||||
- [AnimationExchange](#animationexchange)
|
||||
- [AnimationFadeIn](#animationfadein)
|
||||
- [AnimationFadeOut](#animationfadeout)
|
||||
- [AnimationHiding](#animationhiding)
|
||||
@@ -70,6 +71,7 @@ slug: /api
|
||||
- [ColorUtil](#colorutil)
|
||||
- [Comment](#comment)
|
||||
- [CommentItem](#commentitem)
|
||||
- [CommentLayer](#commentlayer)
|
||||
- [CommentMarkStyle](#commentmarkstyle)
|
||||
- [ComponentHandlerAttribute](#componenthandlerattribute)
|
||||
- [ComponentHelper](#componenthelper)
|
||||
@@ -157,6 +159,7 @@ slug: /api
|
||||
- [MainComponentContext](#maincomponentcontext)
|
||||
- [MainComponentHandler](#maincomponenthandler)
|
||||
- [MainComponentHandler<T>](#maincomponenthandlert)
|
||||
- [MainComponentHandler<Title>](#maincomponenthandlertitle)
|
||||
- [MarkArea](#markarea)
|
||||
- [MarkAreaData](#markareadata)
|
||||
- [MarkAreaType](#markareatype)
|
||||
@@ -179,6 +182,7 @@ slug: /api
|
||||
- [ParallelCoordContext](#parallelcoordcontext)
|
||||
- [Pie](#pie)
|
||||
- [PieChart](#piechart)
|
||||
- [PieType](#pietype)
|
||||
- [PolarAxisTheme](#polaraxistheme)
|
||||
- [PolarChart](#polarchart)
|
||||
- [PolarCoord](#polarcoord)
|
||||
@@ -255,6 +259,7 @@ slug: /api
|
||||
- [ThemeStyle](#themestyle)
|
||||
- [ThemeType](#themetype)
|
||||
- [Title](#title)
|
||||
- [TitleHandler](#titlehandler)
|
||||
- [TitleStyle](#titlestyle)
|
||||
- [TitleTheme](#titletheme)
|
||||
- [Tooltip](#tooltip)
|
||||
@@ -360,6 +365,14 @@ Options:
|
||||
|
||||
- `Linear`:
|
||||
|
||||
## AnimationExchange
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
|
||||
|
||||
> Since `v3.15.0`
|
||||
|
||||
Data exchange animation. Generally used for animation of data sorting.
|
||||
|
||||
## AnimationFadeIn
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
|
||||
@@ -386,7 +399,7 @@ Data hiding animation.
|
||||
|
||||
## AnimationInfo
|
||||
|
||||
class in XCharts.Runtime / Subclasses: [AnimationFadeIn](#animationfadein),[AnimationFadeOut](#animationfadeout),[AnimationChange](#animationchange),[AnimationAddition](#animationaddition),[AnimationHiding](#animationhiding),[AnimationInteraction](#animationinteraction)
|
||||
class in XCharts.Runtime / Subclasses: [AnimationFadeIn](#animationfadein),[AnimationFadeOut](#animationfadeout),[AnimationChange](#animationchange),[AnimationAddition](#animationaddition),[AnimationHiding](#animationhiding),[AnimationInteraction](#animationinteraction),[AnimationExchange](#animationexchange)
|
||||
|
||||
> Since `v3.8.0`
|
||||
|
||||
@@ -405,7 +418,7 @@ the delegate function of animation delay.
|
||||
### AnimationInfo.duration
|
||||
|
||||
public float duration
|
||||
the duration of animation.
|
||||
the duration of animation. Default is used to calculate the speed of animation. It can also be specified by speed.
|
||||
|
||||
### AnimationInfo.durationFunction
|
||||
|
||||
@@ -432,6 +445,11 @@ the callback function of animation start.
|
||||
public bool reverse
|
||||
whether enable reverse animation.
|
||||
|
||||
### AnimationInfo.speed
|
||||
|
||||
public float speed
|
||||
the speed of animation. When speed is specified, duration will be invalid. Default is 0, which means no speed specified.
|
||||
|
||||
### AnimationInfo.End
|
||||
|
||||
public void End()
|
||||
@@ -526,7 +544,7 @@ public float GetWidth(float width)
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
|
||||
|
||||
the animation of serie. support animation type: fadeIn, fadeOut, change, addition.
|
||||
the animation of serie. support animation type: fadeIn, fadeOut, change, addition, exchange.
|
||||
|
||||
### AnimationStyle.addition
|
||||
|
||||
@@ -543,6 +561,11 @@ Update data animation configuration.
|
||||
public bool enable
|
||||
Whether to enable animation.
|
||||
|
||||
### AnimationStyle.exchange
|
||||
|
||||
public AnimationExchange exchange
|
||||
Exchange animation configuration. Valid in sort bar chart.
|
||||
|
||||
### AnimationStyle.fadeIn
|
||||
|
||||
public AnimationFadeIn fadeIn
|
||||
@@ -634,6 +657,10 @@ public int GetCurrIndex()
|
||||
|
||||
public float GetCurrRate()
|
||||
|
||||
### AnimationStyle.GetExchangeDuration
|
||||
|
||||
public float GetExchangeDuration()
|
||||
|
||||
### AnimationStyle.GetInteractionDuration
|
||||
|
||||
public float GetInteractionDuration()
|
||||
@@ -784,6 +811,14 @@ class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent) / Subc
|
||||
|
||||
The axis in rectangular coordinate.
|
||||
|
||||
### Axis.onLabelClick
|
||||
|
||||
public Action<int, string> onLabelClick
|
||||
|
||||
> Since `v3.15.0`
|
||||
|
||||
Callback function when click on the label. Parameters: labelIndex, labelName.
|
||||
|
||||
### Axis.AddData
|
||||
|
||||
public void AddData(string category)
|
||||
@@ -883,7 +918,7 @@ public bool IsLog()
|
||||
|
||||
### Axis.IsNeedShowLabel
|
||||
|
||||
public bool IsNeedShowLabel(int index, int total = 0)
|
||||
public bool IsNeedShowLabel(int index, int total = 0, string content = null)
|
||||
|
||||
### Axis.IsRight
|
||||
|
||||
@@ -1042,6 +1077,10 @@ public bool needAnimation
|
||||
public List<string> runtimeData
|
||||
the tick value of value axis.
|
||||
|
||||
### AxisContext.sortedDataIndices
|
||||
|
||||
public List<int> sortedDataIndices
|
||||
|
||||
## AxisHandler<T>
|
||||
|
||||
class in XCharts / Inherits from: [MainComponentHandler](#maincomponenthandler)
|
||||
@@ -1050,6 +1089,14 @@ class in XCharts / Inherits from: [MainComponentHandler](#maincomponenthandler)
|
||||
|
||||
public T component
|
||||
|
||||
### AxisHandler<T>.DrawTop
|
||||
|
||||
// public override void DrawTop(VertexHelper vh)
|
||||
|
||||
### AxisHandler<T>.OnPointerClick
|
||||
|
||||
public override void OnPointerClick(PointerEventData eventData)
|
||||
|
||||
## AxisHelper
|
||||
|
||||
class in XCharts.Runtime
|
||||
@@ -1088,7 +1135,7 @@ public static float GetAxisValueDistance(GridCoord grid, Axis axis, float scaleW
|
||||
|
||||
### AxisHelper.GetAxisValueLength
|
||||
|
||||
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)
|
||||
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value, float gap = 0)
|
||||
获得数值value在坐标轴上对应的长度
|
||||
|
||||
### AxisHelper.GetAxisValuePosition
|
||||
@@ -1170,12 +1217,12 @@ public void Copy(AxisLabel axisLabel)
|
||||
|
||||
### AxisLabel.GetFormatterContent
|
||||
|
||||
public override string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
public override string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
|
||||
|
||||
### AxisLabel.IsNeedShowLabel
|
||||
|
||||
public bool IsNeedShowLabel(int index, int total)
|
||||
public bool IsNeedShowLabel(int index, int total, string content = null)
|
||||
|
||||
### AxisLabel.SetRelatedText
|
||||
|
||||
@@ -1383,6 +1430,10 @@ public int containerIndex
|
||||
|
||||
public int containterInstanceId
|
||||
|
||||
### Bar.useSortData
|
||||
|
||||
public override bool useSortData
|
||||
|
||||
### Bar.AddDefaultSerie
|
||||
|
||||
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
|
||||
@@ -1661,6 +1712,10 @@ Global parameter setting component.
|
||||
|
||||
public ThemeStyle theme
|
||||
|
||||
### BaseChart.topPainter
|
||||
|
||||
public Painter topPainter
|
||||
|
||||
### BaseChart.typeListForComponent
|
||||
|
||||
public Dictionary<Type, FieldInfo> typeListForComponent
|
||||
@@ -1669,6 +1724,11 @@ public Dictionary<Type, FieldInfo> typeListForComponent
|
||||
|
||||
public Dictionary<Type, FieldInfo> typeListForSerie
|
||||
|
||||
### BaseChart.useUtc
|
||||
|
||||
public bool useUtc
|
||||
Whether to use UTC time for the chart.
|
||||
|
||||
### BaseChart.AddChartComponent
|
||||
|
||||
public MainComponent AddChartComponent(Type type)
|
||||
@@ -1925,6 +1985,10 @@ public Color32 GetLegendRealShowNameColor(string name)
|
||||
|
||||
public int GetLegendRealShowNameIndex(string name)
|
||||
|
||||
### BaseChart.GetMainAxis
|
||||
|
||||
public Axis GetMainAxis()
|
||||
|
||||
### BaseChart.GetMarkColor
|
||||
|
||||
public Color32 GetMarkColor(Serie serie, SerieData serieData)
|
||||
@@ -1941,6 +2005,10 @@ public T GetOrAddChartComponent<T>() where T : MainComponent
|
||||
|
||||
public Painter GetPainter(int index)
|
||||
|
||||
### BaseChart.GetRealtimeSortSerie
|
||||
|
||||
public Serie GetRealtimeSortSerie(int gridIndex)
|
||||
|
||||
### BaseChart.GetSerie
|
||||
|
||||
public Serie GetSerie(int serieIndex)
|
||||
@@ -1953,19 +2021,19 @@ public T GetSerie<T>(int serieIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSerieBarGap<T>
|
||||
|
||||
public float GetSerieBarGap<T>() where T : Serie
|
||||
public float GetSerieBarGap<T>(int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSerieBarRealCount<T>
|
||||
|
||||
public int GetSerieBarRealCount<T>() where T : Serie
|
||||
public int GetSerieBarRealCount<T>(int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSerieIndexIfStack<T>
|
||||
|
||||
public int GetSerieIndexIfStack<T>(Serie currSerie) where T : Serie
|
||||
public int GetSerieIndexIfStack<T>(Serie currSerie, int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSerieSameStackTotalValue<T>
|
||||
|
||||
public double GetSerieSameStackTotalValue<T>(string stack, int dataIndex) where T : Serie
|
||||
public double GetSerieSameStackTotalValue<T>(string stack, int dataIndex, int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSeriesMinMaxValue
|
||||
|
||||
@@ -1973,15 +2041,11 @@ public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double te
|
||||
|
||||
### BaseChart.GetSerieTotalGap<T>
|
||||
|
||||
public float GetSerieTotalGap<T>(float categoryWidth, float gap, int index) where T : Serie
|
||||
public float GetSerieTotalGap<T>(float categoryWidth, float gap, int index, int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSerieTotalWidth<T>
|
||||
|
||||
public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount) where T : Serie
|
||||
|
||||
### BaseChart.GetTitlePosition
|
||||
|
||||
public Vector3 GetTitlePosition(Title title)
|
||||
public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount, int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetVisualMapOfSerie
|
||||
|
||||
@@ -2007,6 +2071,10 @@ public bool HasChartComponent(Type type)
|
||||
|
||||
public bool HasChartComponent<T>()
|
||||
|
||||
### BaseChart.HasRealtimeSortSerie
|
||||
|
||||
public bool HasRealtimeSortSerie(int gridIndex)
|
||||
|
||||
### BaseChart.HasSerie
|
||||
|
||||
public bool HasSerie(Type type)
|
||||
@@ -2498,6 +2566,10 @@ public string warningInfo
|
||||
public string CheckWarning()
|
||||
检测警告信息。
|
||||
|
||||
### BaseGraph.GetTitlePosition
|
||||
|
||||
public Vector3 GetTitlePosition(Title title)
|
||||
|
||||
### BaseGraph.LocalPointToScreenPoint
|
||||
|
||||
public Vector2 LocalPointToScreenPoint(Vector2 localPoint)
|
||||
@@ -2564,11 +2636,6 @@ public void RefreshAllComponent()
|
||||
public virtual void RefreshGraph()
|
||||
Redraw graph in next frame.
|
||||
|
||||
### BaseGraph.SaveAsImage
|
||||
|
||||
public void SaveAsImage(string imageType = "png", string savePath = "")
|
||||
保存图表为图片。
|
||||
|
||||
### BaseGraph.ScreenPointToChartPoint
|
||||
|
||||
public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint)
|
||||
@@ -2826,6 +2893,14 @@ public static string ColorToStr(Color color)
|
||||
|
||||
public static string FloatToStr(double value, string numericFormatter = "F", int precision = 0)
|
||||
|
||||
### ChartCached.GetAxisLabelName
|
||||
|
||||
public static string GetAxisLabelName(int index)
|
||||
|
||||
### ChartCached.GetComponentObjectName
|
||||
|
||||
public static string GetComponentObjectName(MainComponent component)
|
||||
|
||||
### ChartCached.GetSerieLabelName
|
||||
|
||||
public static string GetSerieLabelName(string prefix, int i, int j)
|
||||
@@ -2834,17 +2909,25 @@ public static string GetSerieLabelName(string prefix, int i, int j)
|
||||
|
||||
public static string GetString(string prefix, int suffix)
|
||||
|
||||
### ChartCached.GetTypeName
|
||||
|
||||
public static string GetTypeName(Type type)
|
||||
|
||||
### ChartCached.GetTypeName<T>
|
||||
|
||||
public static string GetTypeName<T>()
|
||||
|
||||
### ChartCached.IntToStr
|
||||
|
||||
public static string IntToStr(int value, string numericFormatter = "")
|
||||
|
||||
### ChartCached.NumberToDateStr
|
||||
|
||||
public static string NumberToDateStr(double timestamp, string formatter)
|
||||
public static string NumberToDateStr(double timestamp, string formatter, bool local = false)
|
||||
|
||||
### ChartCached.NumberToDateTime
|
||||
|
||||
public static DateTime NumberToDateTime(double timestamp)
|
||||
public static DateTime NumberToDateTime(double timestamp, bool local = false)
|
||||
|
||||
### ChartCached.NumberToStr
|
||||
|
||||
@@ -3082,14 +3165,14 @@ public static List<string> ParseStringFromString(string jsonData)
|
||||
|
||||
public static void RemoveComponent<T>(GameObject gameObject)
|
||||
|
||||
### ChartHelper.RemoveTMPComponents
|
||||
|
||||
public static void RemoveTMPComponents(GameObject gameObject)
|
||||
|
||||
### ChartHelper.RotateRound
|
||||
|
||||
public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle)
|
||||
|
||||
### ChartHelper.SaveAsImage
|
||||
|
||||
public static Texture2D SaveAsImage(RectTransform rectTransform, Canvas canvas, string imageType = "png", string path = "")
|
||||
|
||||
### ChartHelper.SetActive
|
||||
|
||||
public static bool SetActive(Image image, bool active)
|
||||
@@ -3149,6 +3232,10 @@ public float GetTextWidth()
|
||||
|
||||
public float GetWidth()
|
||||
|
||||
### ChartLabel.InRect
|
||||
|
||||
public bool InRect(Vector2 local)
|
||||
|
||||
### ChartLabel.IsActiveByScale
|
||||
|
||||
public bool IsActiveByScale()
|
||||
@@ -3403,13 +3490,20 @@ Convert the html string to color.
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent),[IPropertyChanged](#ipropertychanged)
|
||||
|
||||
comment of chart.
|
||||
> Since `v3.15.0`
|
||||
|
||||
comment of chart. Used to annotate special information in the chart.
|
||||
|
||||
### Comment.items
|
||||
|
||||
public List<CommentItem> items
|
||||
The items of comment.
|
||||
|
||||
### Comment.layer
|
||||
|
||||
public CommentLayer layer
|
||||
The layer of comment.
|
||||
|
||||
### Comment.show
|
||||
|
||||
public bool show
|
||||
@@ -3418,10 +3512,12 @@ Set this to false to prevent the comment from showing.
|
||||
### Comment.GetLabelStyle
|
||||
|
||||
public LabelStyle GetLabelStyle(int index)
|
||||
Get the label style of comment item.
|
||||
|
||||
### Comment.GetMarkStyle
|
||||
|
||||
public CommentMarkStyle GetMarkStyle(int index)
|
||||
Get the mark style of comment item.
|
||||
|
||||
### Comment.OnChanged
|
||||
|
||||
@@ -3434,10 +3530,9 @@ class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
|
||||
|
||||
comment of chart.
|
||||
|
||||
### CommentItem.content
|
||||
### CommentItem.labelObject
|
||||
|
||||
public string content
|
||||
content of comment.
|
||||
public ChartLabel labelObject
|
||||
|
||||
### CommentItem.markRect
|
||||
|
||||
@@ -3454,6 +3549,17 @@ the mark rect style.
|
||||
public bool show
|
||||
Set this to false to prevent this comment item from showing.
|
||||
|
||||
## CommentLayer
|
||||
|
||||
class in XCharts.Runtime
|
||||
|
||||
The layer of comment.
|
||||
|
||||
Options:
|
||||
|
||||
- `Lower`: The comment is display under the serie.
|
||||
- `Upper`: The comment is display above the serie.
|
||||
|
||||
## CommentMarkStyle
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
|
||||
@@ -3739,17 +3845,17 @@ class in XCharts.Runtime
|
||||
|
||||
### DateTimeUtil.GetDateTime
|
||||
|
||||
public static DateTime GetDateTime(double timestamp, bool local = true)
|
||||
public static DateTime GetDateTime(double timestamp, bool local = false)
|
||||
|
||||
### DateTimeUtil.GetDefaultDateTimeString
|
||||
|
||||
public static string GetDefaultDateTimeString(int timestamp, double range = 0)
|
||||
public static string GetDefaultDateTimeString(double timestamp, double range = 0, bool local = false)
|
||||
|
||||
### DateTimeUtil.GetTimestamp
|
||||
|
||||
public static int GetTimestamp(DateTime time, bool local = false)
|
||||
public static double GetTimestamp(DateTime time, bool local = false)
|
||||
|
||||
public static int GetTimestamp(string dateTime, bool local = false)
|
||||
public static double GetTimestamp(string dateTime, bool local = false)
|
||||
|
||||
|
||||
### DateTimeUtil.IsDateOrTimeRegex
|
||||
@@ -3886,9 +3992,13 @@ public static bool NeedFormat(string content)
|
||||
|
||||
### FormatterHelper.ReplaceAxisLabelContent
|
||||
|
||||
public static void ReplaceAxisLabelContent(ref string content, string value)
|
||||
public static void ReplaceAxisLabelContent(ref string content, string value, int index, int totalIndex)
|
||||
|
||||
|
||||
### FormatterHelper.ReplaceIndexContent
|
||||
|
||||
public static void ReplaceIndexContent(ref string content, int currIndex, int totalIndex)
|
||||
|
||||
### FormatterHelper.TrimAndReplaceLine
|
||||
|
||||
public static string TrimAndReplaceLine(string content)
|
||||
@@ -4399,7 +4509,7 @@ public override void ClearData()
|
||||
|
||||
### Indicator.GetFormatterIndicatorContent
|
||||
|
||||
public string GetFormatterIndicatorContent(string indicatorName)
|
||||
public string GetFormatterIndicatorContent(string indicatorName, int index, int totalIndex)
|
||||
|
||||
|
||||
### Indicator.GetIndicator
|
||||
@@ -4650,12 +4760,12 @@ public Color GetColor(Color defaultColor)
|
||||
|
||||
### LabelStyle.GetFormatterContent
|
||||
|
||||
public virtual string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
public virtual string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
|
||||
|
||||
### LabelStyle.GetFormatterDateTime
|
||||
|
||||
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue)
|
||||
public string GetFormatterDateTime(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool local)
|
||||
|
||||
### LabelStyle.GetOffset
|
||||
|
||||
@@ -5659,6 +5769,10 @@ class in XCharts.Runtime / Inherits from: [MainComponentHandler](#maincomponenth
|
||||
|
||||
public T component
|
||||
|
||||
## MainComponentHandler<Title>
|
||||
|
||||
class in / Subclasses: [TitleHandler](#titlehandler)
|
||||
|
||||
## MarkArea
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent)
|
||||
@@ -5753,15 +5867,15 @@ public double runtimeValue
|
||||
|
||||
class in XCharts.Runtime
|
||||
|
||||
标线类型
|
||||
Mark line type.
|
||||
|
||||
Options:
|
||||
|
||||
- `None`: 标线类型
|
||||
- `Min`: 最小值。
|
||||
- `Max`: 最大值。
|
||||
- `Average`: 平均值。
|
||||
- `Median`: 中位数。
|
||||
- `Custom`: Custom. You can customize the xy coordinates or values.
|
||||
- `Min`: Minimum value.
|
||||
- `Max`: Maximum value.
|
||||
- `Average`: Average value.
|
||||
- `Median`: Median.
|
||||
|
||||
## MarqueeStyle
|
||||
|
||||
@@ -5954,10 +6068,6 @@ class in XCharts.Runtime / Inherits from: [MaskableGraphic](https://docs.unity3d
|
||||
|
||||
public int index
|
||||
|
||||
### Painter.onPopulateMesh
|
||||
|
||||
public Action<VertexHelper, Painter> onPopulateMesh
|
||||
|
||||
### Painter.type
|
||||
|
||||
public Type type
|
||||
@@ -6092,6 +6202,15 @@ default label pie chart.
|
||||
public void DefaultRadiusRosePieChart()
|
||||
default rose pie chart.
|
||||
|
||||
## PieType
|
||||
|
||||
class in XCharts.Runtime
|
||||
|
||||
Options:
|
||||
|
||||
- `Solid`: solid pie chart - default fill style.
|
||||
- `Wireframe`: wireframe pie chart - only show the outline wireframe.
|
||||
|
||||
## PolarAxisTheme
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [BaseAxisTheme](#baseaxistheme)
|
||||
@@ -6719,7 +6838,7 @@ public double GetData(int index, int dimension, DataZoom dataZoom = null)
|
||||
|
||||
### Serie.GetDataList
|
||||
|
||||
public List<SerieData> GetDataList(DataZoom dataZoom = null)
|
||||
public List<SerieData> GetDataList(DataZoom dataZoom = null, bool sorted = false)
|
||||
获得系列的数据列表
|
||||
|
||||
### Serie.GetDataTotal
|
||||
@@ -7026,6 +7145,10 @@ public SelectStyle selectStyle
|
||||
public bool show
|
||||
[default:true] Whether the data item is showed.
|
||||
|
||||
### SerieData.sortIndex
|
||||
|
||||
public int sortIndex
|
||||
|
||||
### SerieData.state
|
||||
|
||||
public SerieState state
|
||||
@@ -7109,12 +7232,12 @@ public double GetLastData()
|
||||
|
||||
### SerieData.GetMaxData
|
||||
|
||||
public double GetMaxData(bool inverse = false)
|
||||
public double GetMaxData(bool inverse = false, int startDimensionIndex = 0)
|
||||
the maxinum value.
|
||||
|
||||
### SerieData.GetMinData
|
||||
|
||||
public double GetMinData(bool inverse = false)
|
||||
public double GetMinData(bool inverse = false, int startDimensionIndex = 0)
|
||||
the mininum value.
|
||||
|
||||
### SerieData.GetMinMaxData
|
||||
@@ -7172,7 +7295,7 @@ public void SetIconActive(bool flag)
|
||||
|
||||
### SerieData.SetLabelActive
|
||||
|
||||
public void SetLabelActive(bool flag)
|
||||
public void SetLabelActive(bool flag, bool force = false)
|
||||
|
||||
### SerieData.SetPolygon
|
||||
|
||||
@@ -7225,6 +7348,10 @@ class in XCharts.Runtime
|
||||
|
||||
public void Reset()
|
||||
|
||||
### SerieDataContext.UpdateExchangePosition
|
||||
|
||||
public void UpdateExchangePosition(ref float x, ref float y, float totalTime)
|
||||
|
||||
## SerieDataExtraFieldAttribute
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [Attribute](https://docs.unity3d.com/ScriptReference/30_search.html?q=attribute)
|
||||
@@ -7653,6 +7780,10 @@ public override void RefreshLabelInternal()
|
||||
|
||||
public override void RefreshLabelNextFrame()
|
||||
|
||||
### SerieHandler<T>.RefreshTitleLabelInternal
|
||||
|
||||
public void RefreshTitleLabelInternal()
|
||||
|
||||
### SerieHandler<T>.RemoveComponent
|
||||
|
||||
public override void RemoveComponent()
|
||||
@@ -7949,7 +8080,7 @@ class in XCharts.Runtime / Inherits from: [SymbolStyle](#symbolstyle),[ISerieDat
|
||||
|
||||
### SerieSymbol.GetSize
|
||||
|
||||
public float GetSize(List<double> data, float themeSize)
|
||||
public float GetSize(SerieData serieData, float themeSize)
|
||||
根据指定的sizeType获得标记的大小
|
||||
|
||||
### SerieSymbol.Reset
|
||||
@@ -8573,6 +8704,30 @@ public override void ClearComponentDirty()
|
||||
|
||||
public void OnChanged()
|
||||
|
||||
## TitleHandler
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [MainComponentHandler<Title>](#maincomponenthandlertitle)
|
||||
|
||||
### TitleHandler.AddSubTitleLabel
|
||||
|
||||
public static ChartLabel AddSubTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
|
||||
|
||||
### TitleHandler.AddTitleLabel
|
||||
|
||||
public static ChartLabel AddTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
|
||||
|
||||
### TitleHandler.AddTitleObject
|
||||
|
||||
public static GameObject AddTitleObject(BaseGraph graph, Title title, ComponentTheme componentTheme, int titleSiblingIndex, string objectName = null)
|
||||
|
||||
### TitleHandler.InitComponent
|
||||
|
||||
public override void InitComponent()
|
||||
|
||||
### TitleHandler.OnSerieDataUpdate
|
||||
|
||||
public override void OnSerieDataUpdate(int serieIndex)
|
||||
|
||||
## TitleStyle
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [LabelStyle](#labelstyle),[ISerieDataComponent](#iseriedatacomponent),[ISerieComponent](#iseriecomponent)
|
||||
|
||||
@@ -6,6 +6,8 @@ slug: /changelog
|
||||
# Changelog
|
||||
|
||||
[master](#master)
|
||||
[v3.15.0](#v3150)
|
||||
[v3.14.0](#v3140)
|
||||
[v3.13.0](#v3130)
|
||||
[v3.12.1](#v3121)
|
||||
[v3.12.0](#v3120)
|
||||
@@ -78,9 +80,92 @@ slug: /changelog
|
||||
|
||||
## master
|
||||
|
||||
## v3.15.0
|
||||
|
||||
Version Highlights:
|
||||
|
||||
* __Enhanced Timeline & Zoom Capabilities__: Added `DataZoom.minZoomRatio` (replacing `minShowNum`), `Chart.useUtc`, and continuous optimization of `Axis Time` performance during zooming and handling of large year ranges.
|
||||
* __More Flexible Bar Charts & Axis Configuration__: Added `Axis.mainAxis` to control bar chart orientation, `Serie.ignoreZeroOccupy` to control whether zero-value bars occupy space, and `AxisLine` extension line configurations.
|
||||
* __Improved Chart Styling & Interactivity__: Added `Pie.pieType`, `Legend.itemInactiveOpacity`, `Axis.onLabelClick`, `Animation.Exchange`, `LabelStyle.fixedX/fixedY`, and more.
|
||||
* __Ongoing Enhancement of Extended UI Components__: Added `Title` and `Viewport` configurations for `UITable`, enhanced `UIStatistic.desc`, and optimized `Comment.layer` and coordinate refresh experience.
|
||||
* __Focused Stability & Compatibility Fixes__: Resolved critical issues including `SaveAsImage` being blocked by other components, `Pie` click failures, `TMP` compatibility, `Gantt` time range and year 2038 problem, `MarkArea/GridCoord/Axis` and more.
|
||||
|
||||
Changelog Details:
|
||||
|
||||
* (2026.03.01) Released version `v3.15.0`
|
||||
* (2026.02.26) Added `ignoreZeroOccupy` to `Serie` to set whether zero-value Bars occupy space (#286)
|
||||
* (2026.02.26) Fixed `SaveAsImage` not saving correctly when blocked by other components (#337)
|
||||
* (2026.02.26) Added `mainAxis` parameter to `Axis` to set the main axis for controlling bar chart orientation (#331)
|
||||
* (2026.02.03) Fixed `UITable` `viewport` potentially drawing incorrectly under different anchor points
|
||||
* (2026.01.15) Fixed `Pie` click sometimes not responding (#357)
|
||||
* (2026.01.08) Added `minZoomRatio` to `DataZoom` to replace the old `minShowNum` (#350)
|
||||
* (2025.11.05) Fixed `Axis` `indicatorLabel` not being hideable
|
||||
* (2025.11.03) Added `Tooltip` `Title` time formatting via `TitleLabelStyle` `numericFormatter` (#353)
|
||||
* (2025.10.30) Added `useUtc` parameter to `Chart` to set whether displayed time uses UTC
|
||||
* (2025.10.30) Optimized `Candlestick` support for time axis
|
||||
* (2025.10.30) Added support for `ignore` in `Scatter` to skip data points
|
||||
* (2025.10.24) Optimized line drawing order for `Sankey`
|
||||
* (2025.10.22) Added `pieType` to `Pie` supporting solid pie charts and wireframe handle charts (#349)
|
||||
* (2025.09.05) Optimized `MarkLine` performance
|
||||
* (2025.09.01) Added `startExtendLength` and `endExtendLength` to `AxisLine` for setting axis line extensions
|
||||
* (2025.08.27) Fixed `Serie` `TitleStyle` not refreshing promptly when data changed
|
||||
* (2025.05.19) Fixed `Axis` runtime error when `TMP` is enabled
|
||||
* (2025.04.25) Fixed `MarkArea` drawing inaccurately when specifying `yValue` or `xValue`
|
||||
* (2025.04.17) Added `Title` support for `UITable` to set headers
|
||||
* (2025.04.17) Added `Viewport` support for `UITable` to set table viewport margins and borders
|
||||
* (2025.04.15) Added `Bar` support for color settings via `VisualMap`
|
||||
* (2025.04.14) Added `showZeroLabel` to `AxisLabel` to set whether to display zero tick
|
||||
* (2025.04.08) Added `desc` description text setting support for `UIStatistic`
|
||||
* (2025.04.07) Fixed `Gantt` chart calculating inaccurate time ranges with multi-dimensional data
|
||||
* (2025.04.07) Optimized `Axis` `Time` axis support for Custom and ceilRate settings
|
||||
* (2025.04.07) Fixed `GridCoord` covering charts when background color set and Serie Clip enabled
|
||||
* (2025.04.07) Fixed `Gantt` chart display errors when year exceeds 2038
|
||||
* (2025.04.07) Fixed `Axis` `Time` axis not displaying years beyond 2038
|
||||
* (2025.04.06) Fixed `Axis` `Time` axis text display errors when zoomed with `DataZoom`
|
||||
* (2025.03.28) Fixed `Pie3D` `avoidLabelOverlap` not working
|
||||
* (2025.03.27) Added `itemInactiveOpacity` to `Legend` to set color transparency for inactive states (#343)
|
||||
* (2025.03.27) Added `onLabelClick` callback event to `Axis`
|
||||
* (2025.03.26) Added `Exchange` sort swap animation to `Animation`
|
||||
* (2025.03.22) Added `layer` setting to `Comment`
|
||||
* (2025.03.21) Optimized coordinate refresh for `Comment`
|
||||
* (2025.03.19) Added `{index}` wildcard support for `Serie` `Label` `formatter`
|
||||
* (2025.03.18) Added `TitleStyle` component support for `Bar`
|
||||
* (2025.03.18) Added `fixedX` and `fixedY` to `LabelStyle` to fix label coordinates
|
||||
* (2025.03.17) Added `backgroundGap` to `ItemStyle` to set data item background gap
|
||||
|
||||
## v3.14.0
|
||||
|
||||
Version Highlights:
|
||||
|
||||
* Added real-time sorting functionality for `Bar`
|
||||
* Added support for `\n` line breaks in `itemFormatter` for `Tooltip`
|
||||
* Added support for `{index}` formatting in `AxisLabel`
|
||||
* Added `speed` to `Animation` to specify animation speed
|
||||
* Optimized column alignment in `Tooltip`
|
||||
|
||||
Changelog Details:
|
||||
|
||||
* (2025.03.15) Released version `v3.14.0`
|
||||
* (2025.03.09) Fixed an issue where `Bar` displayed abnormally when placed in different `Grids` within the same `Chart`
|
||||
* (2025.03.07) Added `speed` to `Animation` to specify animation speed
|
||||
* (2025.03.06) Optimized the performance of newly added animations in `Animation`
|
||||
* (2025.03.04) Fixed an issue where `label` in `Treemap` displayed abnormally
|
||||
* (2025.03.02) Added `columnGapWidths` parameter to `Tooltip` to set the gap distance between column texts
|
||||
* (2025.03.01) Optimized the refresh of `Comment` component
|
||||
* (2025.02.23) Added support for `{index}`, `{index-1}`, `{-index}`, and `{-index-1}` wildcards in `formatter` for `Label` in `Axis`
|
||||
* (2025.02.23) Added `realtimeSort` to `Bar` to support real-time sorting
|
||||
* (2025.02.19) Added support for `\n` line breaks in `itemFormatter` for `Tooltip`
|
||||
* (2025.02.18) Optimized the alignment of `Tooltip`
|
||||
* (2025.02.09) Fixed an issue where `SaveAsImage` did not support transparency when saving images (#337)
|
||||
* (2025.02.05) Added support for setting `data` styles separately in `GraphChart`
|
||||
* (2025.02.05) Refactored the `sizeFunction` parameter in `SerieSymbol`
|
||||
* (2025.01.23) Fixed an issue where `Label` in `Treemap` was not displayed
|
||||
* (2025.01.15) Fixed an issue where dynamically adding `Component` to `Chart` at runtime caused exceptions (#339)
|
||||
* (2025.01.08) Fixed an issue where residual components affected `Text` initialization when `TextMeshPro` was turned off
|
||||
|
||||
## v3.13.0
|
||||
|
||||
Key Features:
|
||||
Version Highlights:
|
||||
|
||||
* Added the `UIText` extension component
|
||||
* Added the `UIToggle` extension component
|
||||
@@ -90,7 +175,7 @@ Key Features:
|
||||
* Added the `size2` parameter to `SymbolStyle` to support rectangular markers
|
||||
* Other optimizations and bug fixes
|
||||
|
||||
Detailed Changelog:
|
||||
Changelog Details:
|
||||
|
||||
* (2025.01.01) Released `v3.13.0`
|
||||
* (2024.12.27) Added the `size2` parameter to `SymbolStyle` to support rectangular markers
|
||||
@@ -137,7 +222,7 @@ Version Highlights:
|
||||
* Adjusted and perfected the documentation
|
||||
* Other optimizations and fixes
|
||||
|
||||
Log Details:
|
||||
Changelog Details:
|
||||
|
||||
* (2024.09.30) Released version `v3.12.0`
|
||||
* (2024.09.27) Improved the `5-minute tutorial`
|
||||
@@ -148,7 +233,6 @@ Log Details:
|
||||
* (2024.09.01) Added `radiusGradient` parameter for `Ring` to set the gradient direction
|
||||
* (2024.09.01) Optimized the position of the first Label when `Axis` is used as a time axis
|
||||
|
||||
|
||||
## v3.11.2
|
||||
|
||||
* (2024.08.01) Release `v3.11.2`
|
||||
@@ -171,7 +255,7 @@ Log Details:
|
||||
|
||||
## v3.11.0
|
||||
|
||||
Release Highlights:
|
||||
Version Highlights:
|
||||
|
||||
* Added `Line3DChart` for 3D line charts
|
||||
* Added `GraphChart` for relationship graphs
|
||||
|
||||
@@ -176,6 +176,7 @@ slug: /configuration
|
||||
|
||||
- [AnimationAddition](#animationaddition)
|
||||
- [AnimationChange](#animationchange)
|
||||
- [AnimationExchange](#animationexchange)
|
||||
- [AnimationFadeIn](#animationfadein)
|
||||
- [AnimationFadeOut](#animationfadeout)
|
||||
- [AnimationHiding](#animationhiding)
|
||||
@@ -234,6 +235,14 @@ class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
|
||||
|
||||
Data change animation.
|
||||
|
||||
## AnimationExchange
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
|
||||
|
||||
> Since `v3.15.0`
|
||||
|
||||
Data exchange animation. Generally used for animation of data sorting.
|
||||
|
||||
## AnimationFadeIn
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
|
||||
@@ -260,7 +269,7 @@ Data hiding animation.
|
||||
|
||||
## AnimationInfo
|
||||
|
||||
class in XCharts.Runtime / Subclasses: [AnimationFadeIn](#animationfadein), [AnimationFadeOut](#animationfadeout), [AnimationChange](#animationchange), [AnimationAddition](#animationaddition), [AnimationHiding](#animationhiding), [AnimationInteraction](#animationinteraction)
|
||||
class in XCharts.Runtime / Subclasses: [AnimationFadeIn](#animationfadein), [AnimationFadeOut](#animationfadeout), [AnimationChange](#animationchange), [AnimationAddition](#animationaddition), [AnimationHiding](#animationhiding), [AnimationInteraction](#animationinteraction), [AnimationExchange](#animationexchange)
|
||||
|
||||
> Since `v3.8.0`
|
||||
|
||||
@@ -276,7 +285,7 @@ the delay time before animation start.
|
||||
|
||||
`float` `1000` `v3.8.0`
|
||||
|
||||
the duration of animation.
|
||||
the duration of animation. Default is used to calculate the speed of animation. It can also be specified by speed.
|
||||
|
||||
### AnimationInfo.enable
|
||||
|
||||
@@ -290,6 +299,12 @@ whether enable animation.
|
||||
|
||||
whether enable reverse animation.
|
||||
|
||||
### AnimationInfo.speed
|
||||
|
||||
`float` `0` `v3.14.0`
|
||||
|
||||
the speed of animation. When speed is specified, duration will be invalid. Default is 0, which means no speed specified.
|
||||
|
||||
## AnimationInteraction
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [AnimationInfo](#animationinfo)
|
||||
@@ -320,7 +335,7 @@ the mlvalue of width.
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent)
|
||||
|
||||
the animation of serie. support animation type: fadeIn, fadeOut, change, addition.
|
||||
the animation of serie. support animation type: fadeIn, fadeOut, change, addition, exchange.
|
||||
|
||||
### AnimationStyle.addition
|
||||
|
||||
@@ -350,6 +365,12 @@ Options:
|
||||
|
||||
Whether to enable animation.
|
||||
|
||||
### AnimationStyle.exchange
|
||||
|
||||
[AnimationExchange](#animationexchange) `v3.15.0`
|
||||
|
||||
Exchange animation configuration. Valid in sort bar chart.
|
||||
|
||||
### AnimationStyle.fadeIn
|
||||
|
||||
[AnimationFadeIn](#animationfadein) `v3.8.0`
|
||||
@@ -597,6 +618,12 @@ Base of logarithm, which is valid only for numeric axes with type: 'Log'.
|
||||
|
||||
On the log axis, if base e is the natural number, and is true, logBase fails.
|
||||
|
||||
### Axis.mainAxis
|
||||
|
||||
`bool` `false` `v3.15.0`
|
||||
|
||||
Whether it is the main axis. When both X and Y axes are of the same type, the axis set to main axis will determine the orientation, such as horizontal bar chart and vertical bar chart.
|
||||
|
||||
### Axis.max
|
||||
|
||||
`double`
|
||||
@@ -783,6 +810,12 @@ Whether to display the last label.
|
||||
|
||||
Whether to display the first label.
|
||||
|
||||
### AxisLabel.showZeroLabel
|
||||
|
||||
`bool` `true` `v3.15.0`
|
||||
|
||||
Whether to display the zero label.
|
||||
|
||||
### AxisLabel.textLimit
|
||||
|
||||
[TextLimit](#textlimit)
|
||||
@@ -801,6 +834,12 @@ Settings related to axis line.
|
||||
|
||||
the arrow of line.
|
||||
|
||||
### AxisLine.endExtendLength
|
||||
|
||||
`float`
|
||||
|
||||
Extend length of the axis line at the end.
|
||||
|
||||
### AxisLine.onZero
|
||||
|
||||
`bool`
|
||||
@@ -813,6 +852,12 @@ When mutiple axes exists, this option can be used to specify which axis can be "
|
||||
|
||||
Whether to show the arrow symbol of axis.
|
||||
|
||||
### AxisLine.startExtendLength
|
||||
|
||||
`float`
|
||||
|
||||
Extend length of the axis line at the start.
|
||||
|
||||
## AxisMinorSplitLine
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [BaseLine](#baseline)
|
||||
@@ -1241,7 +1286,9 @@ class in XCharts.Runtime / Subclasses: [AnimationStyle](#animationstyle), [AxisA
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [MainComponent](#maincomponent), [IPropertyChanged](#ipropertychanged)
|
||||
|
||||
comment of chart.
|
||||
> Since `v3.15.0`
|
||||
|
||||
comment of chart. Used to annotate special information in the chart.
|
||||
|
||||
### Comment.items
|
||||
|
||||
@@ -1255,6 +1302,17 @@ The items of comment.
|
||||
|
||||
The text style of all comments.
|
||||
|
||||
### Comment.layer
|
||||
|
||||
[CommentLayer](#commentlayer) `v3.15.0`
|
||||
|
||||
The layer of comment.
|
||||
|
||||
Options:
|
||||
|
||||
- `Lower`: The comment is display under the serie.
|
||||
- `Upper`: The comment is display above the serie.
|
||||
|
||||
### Comment.markStyle
|
||||
|
||||
[CommentMarkStyle](#commentmarkstyle)
|
||||
@@ -1464,11 +1522,11 @@ Distance between dataZoom component and the left side of the container. left val
|
||||
|
||||
选取框样式。
|
||||
|
||||
### DataZoom.minShowNum
|
||||
### DataZoom.minZoomRatio
|
||||
|
||||
`int` `2`
|
||||
`float` `0.2f`
|
||||
|
||||
Minimum number of display data. Minimum number of data displayed when DataZoom is enlarged to maximum.
|
||||
The minimum zoom ratio of dataZoom. Range 0f-1f.
|
||||
|
||||
### DataZoom.orient
|
||||
|
||||
@@ -2232,6 +2290,12 @@ class in XCharts.Runtime / Inherits from: [ChildComponent](#childcomponent), [IS
|
||||
|
||||
数据项背景颜色。
|
||||
|
||||
### ItemStyle.backgroundGap
|
||||
|
||||
`float` `v3.15.0`
|
||||
|
||||
the gap between background and data item.
|
||||
|
||||
### ItemStyle.backgroundWidth
|
||||
|
||||
`float`
|
||||
@@ -2458,11 +2522,23 @@ the sytle of background.
|
||||
|
||||
the distance of label to axis line.
|
||||
|
||||
### LabelStyle.fixedX
|
||||
|
||||
`float` `0` `v3.15.0`
|
||||
|
||||
the fixed x of label. When not 0, it will be fixed on the specified x value.
|
||||
|
||||
### LabelStyle.fixedY
|
||||
|
||||
`float` `0` `v3.15.0`
|
||||
|
||||
the fixed y of label. When not 0, it will be fixed on the specified y value.
|
||||
|
||||
### LabelStyle.formatter
|
||||
|
||||
`string`
|
||||
|
||||
label content string template formatter. \n line wrapping is supported. Formatters for some components will not take effect. <br /> Template placeholder have the following, some of which apply only to fixed components: <br /> `\{.\}` : indicates the dot mark. <br /> `\{a\}` : indicates the series name. <br /> `\{b\}` : category value of x axis or data name. <br /> `\{c\}` : data value. <br /> `\{d\}` : percentage. <br /> `\{e\}` : indicates the data name. <br /> `\{f\}` : data sum. <br /> `\{g\}` : indicates the total number of data. <br /> `\{h\}` : hexadecimal color value. <br /> `\{y\}` : category value of y axis. <br /> `\{value\}` : The value of the axis or legend. <br /> The following placeholder apply to `UITable` components: <br /> `\{name\}` : indicates the row name of the table. <br /> `\{index\}` : indicates the row number of the table. <br /> The following placeholder apply to `UIStatistc` components: <br /> `\{title\}` : title text. <br /> `\{dd\}` : day. <br /> `\{hh\}` : hours. <br /> `\{mm\}` : minutes. <br /> `\{ss\}` : second. <br /> `\{fff\}` : milliseconds. <br /> `\{d\}` : day. <br /> `\{h\}` : hours. <br /> `\{m\}` : minutes. <br /> `\{s\}` : second. <br /> `\{f\}` : milliseconds. <br /> Example :\{b\}:\{c\}<br />
|
||||
label content string template formatter. \n line wrapping is supported. Formatters for some components will not take effect. <br /> Template placeholder have the following, some of which apply only to fixed components: <br /> `\{.\}` : indicates the dot mark. <br /> `\{a\}` : indicates the series name. <br /> `\{b\}` : category value of x axis or data name. <br /> `\{c\}` : data value. <br /> `\{d\}` : percentage. <br /> `\{e\}` : indicates the data name. <br /> `\{f\}` : data sum. <br /> `\{g\}` : indicates the total number of data. <br /> `\{h\}` : hexadecimal color value. <br /> `\{y\}` : category value of y axis. <br /> `\{value\}` : the value of the axis or legend. <br /> `\{index\}` : the index of the axis. <br /> The following placeholder apply to `UITable` components: <br /> `\{name\}` : indicates the row name of the table. <br /> `\{index\}` : indicates the row number of the table. <br /> The following placeholder apply to `UIStatistc` components: <br /> `\{title\}` : title text. <br /> `\{dd\}` : day. <br /> `\{hh\}` : hours. <br /> `\{mm\}` : minutes. <br /> `\{ss\}` : second. <br /> `\{fff\}` : milliseconds. <br /> `\{d\}` : day. <br /> `\{h\}` : hours. <br /> `\{m\}` : minutes. <br /> `\{s\}` : second. <br /> `\{f\}` : milliseconds. <br /> Example :\{b\}:\{c\}<br />
|
||||
|
||||
### LabelStyle.height
|
||||
|
||||
@@ -2609,6 +2685,12 @@ The distance between each legend, horizontal distance in horizontal layout, and
|
||||
|
||||
Image height of legend symbol.
|
||||
|
||||
### Legend.itemInactiveOpacity
|
||||
|
||||
`float` `1` `v3.15.0`
|
||||
|
||||
the opacity of item color when item is inactive.
|
||||
|
||||
### Legend.itemOpacity
|
||||
|
||||
`float` `1`
|
||||
@@ -2684,11 +2766,11 @@ the limit of text.
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [ComponentTheme](#componenttheme)
|
||||
|
||||
### LegendTheme.unableColor
|
||||
### LegendTheme.inactiveColor
|
||||
|
||||
`Color`
|
||||
|
||||
the color of text.
|
||||
the color when the component is inactive.
|
||||
|
||||
## Level
|
||||
|
||||
@@ -3104,11 +3186,11 @@ Special label types, are used to label maximum value, minimum value and so on.
|
||||
|
||||
Options:
|
||||
|
||||
- `None`: 标线类型
|
||||
- `Min`: 最小值。
|
||||
- `Max`: 最大值。
|
||||
- `Average`: 平均值。
|
||||
- `Median`: 中位数。
|
||||
- `Custom`: Custom. You can customize the xy coordinates or values.
|
||||
- `Min`: Minimum value.
|
||||
- `Max`: Maximum value.
|
||||
- `Average`: Average value.
|
||||
- `Median`: Median.
|
||||
|
||||
### MarkLineData.xPosition
|
||||
|
||||
@@ -3297,6 +3379,17 @@ Distance between grid component and the top side of the container.
|
||||
|
||||
class in XCharts.Runtime / Inherits from: [Serie](#serie)
|
||||
|
||||
### Pie.pieType
|
||||
|
||||
[PieType](#pietype) `v3.15.0`
|
||||
|
||||
Pie chart type.
|
||||
|
||||
Options:
|
||||
|
||||
- `Solid`: solid pie chart - default fill style.
|
||||
- `Wireframe`: wireframe pie chart - only show the outline wireframe.
|
||||
|
||||
### Pie.radiusGradient
|
||||
|
||||
`bool` `false` `v3.8.1`
|
||||
@@ -3465,13 +3558,13 @@ The width of the bar. Adaptive when default 0.
|
||||
|
||||
`float` `2f`
|
||||
|
||||
斑马线的间距。
|
||||
The gap of zebra bar. It is the distance between two zebra stripes. When the value is 0, there is no gap between stripes.
|
||||
|
||||
### Serie.barZebraWidth
|
||||
|
||||
`float` `4f`
|
||||
|
||||
斑马线的粗细。
|
||||
The width of zebra bar. It is the width of each zebra stripe. When the value is 0, there is no zebra stripe.
|
||||
|
||||
### Serie.bottom
|
||||
|
||||
@@ -3575,6 +3668,12 @@ Index of layout component that serie uses. Default is -1 means not use layout, o
|
||||
|
||||
忽略数据的默认值。当ignore为true才有效。
|
||||
|
||||
### Serie.ignoreZeroOccupy
|
||||
|
||||
`bool` `false` `v3.15.0`
|
||||
|
||||
Whether to ignore the zero value bar occupy. When enabled, the bar with zero value will not occupy space, and the gap between bars will be automatically adjusted according to the actual displayed bars. Generally used in bar chart.
|
||||
|
||||
### Serie.index
|
||||
|
||||
`int`
|
||||
@@ -3755,6 +3854,12 @@ Options:
|
||||
|
||||
the radius of chart.
|
||||
|
||||
### Serie.realtimeSort
|
||||
|
||||
`bool` `false` `v3.14.0`
|
||||
|
||||
Whether to enable realtime sorting, which is used for bar-racing effect. Currently only available in Bar.
|
||||
|
||||
### Serie.right
|
||||
|
||||
`float`
|
||||
@@ -4816,11 +4921,17 @@ the color of tooltip border.
|
||||
|
||||
the width of tooltip border.
|
||||
|
||||
### Tooltip.columnGapWidths
|
||||
|
||||
`List<float>` `v3.14.0`
|
||||
|
||||
the column gap width of content. When there is only one column, it only represents the gap width of the second column.
|
||||
|
||||
### Tooltip.contentLabelStyles
|
||||
|
||||
`List<LabelStyle>`
|
||||
|
||||
the textstyle list of content.
|
||||
the column text style list of content. The first represents the text style of the first column, and so on.
|
||||
|
||||
### Tooltip.fixedHeight
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 293 KiB After Width: | Height: | Size: 704 KiB |
|
Before Width: | Height: | Size: 225 KiB After Width: | Height: | Size: 660 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 153 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 86 KiB |
@@ -13,6 +13,7 @@ slug: /api
|
||||
- [AnimationAddition](#animationaddition)
|
||||
- [AnimationChange](#animationchange)
|
||||
- [AnimationEasing](#animationeasing)
|
||||
- [AnimationExchange](#animationexchange)
|
||||
- [AnimationFadeIn](#animationfadein)
|
||||
- [AnimationFadeOut](#animationfadeout)
|
||||
- [AnimationHiding](#animationhiding)
|
||||
@@ -70,6 +71,7 @@ slug: /api
|
||||
- [ColorUtil](#colorutil)
|
||||
- [Comment](#comment)
|
||||
- [CommentItem](#commentitem)
|
||||
- [CommentLayer](#commentlayer)
|
||||
- [CommentMarkStyle](#commentmarkstyle)
|
||||
- [ComponentHandlerAttribute](#componenthandlerattribute)
|
||||
- [ComponentHelper](#componenthelper)
|
||||
@@ -157,6 +159,7 @@ slug: /api
|
||||
- [MainComponentContext](#maincomponentcontext)
|
||||
- [MainComponentHandler](#maincomponenthandler)
|
||||
- [MainComponentHandler<T>](#maincomponenthandlert)
|
||||
- [MainComponentHandler<Title>](#maincomponenthandlertitle)
|
||||
- [MarkArea](#markarea)
|
||||
- [MarkAreaData](#markareadata)
|
||||
- [MarkAreaType](#markareatype)
|
||||
@@ -179,6 +182,7 @@ slug: /api
|
||||
- [ParallelCoordContext](#parallelcoordcontext)
|
||||
- [Pie](#pie)
|
||||
- [PieChart](#piechart)
|
||||
- [PieType](#pietype)
|
||||
- [PolarAxisTheme](#polaraxistheme)
|
||||
- [PolarChart](#polarchart)
|
||||
- [PolarCoord](#polarcoord)
|
||||
@@ -255,6 +259,7 @@ slug: /api
|
||||
- [ThemeStyle](#themestyle)
|
||||
- [ThemeType](#themetype)
|
||||
- [Title](#title)
|
||||
- [TitleHandler](#titlehandler)
|
||||
- [TitleStyle](#titlestyle)
|
||||
- [TitleTheme](#titletheme)
|
||||
- [Tooltip](#tooltip)
|
||||
@@ -360,6 +365,14 @@ class in XCharts.Runtime
|
||||
|
||||
- `Linear`:
|
||||
|
||||
## AnimationExchange
|
||||
|
||||
class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
|
||||
|
||||
> 从 `v3.15.0` 开始支持
|
||||
|
||||
数据交换动画。一般用于图表数据排序时顺序变化的动画。
|
||||
|
||||
## AnimationFadeIn
|
||||
|
||||
class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
|
||||
@@ -386,7 +399,7 @@ class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
|
||||
|
||||
## AnimationInfo
|
||||
|
||||
class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein),[AnimationFadeOut](#animationfadeout),[AnimationChange](#animationchange),[AnimationAddition](#animationaddition),[AnimationHiding](#animationhiding),[AnimationInteraction](#animationinteraction)
|
||||
class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein),[AnimationFadeOut](#animationfadeout),[AnimationChange](#animationchange),[AnimationAddition](#animationaddition),[AnimationHiding](#animationhiding),[AnimationInteraction](#animationinteraction),[AnimationExchange](#animationexchange)
|
||||
|
||||
> 从 `v3.8.0` 开始支持
|
||||
|
||||
@@ -405,7 +418,7 @@ public AnimationDelayFunction delayFunction
|
||||
### AnimationInfo.duration
|
||||
|
||||
public float duration
|
||||
动画的时长。
|
||||
动画的时长。默认用于计算动画的速度。也可以通过speed指定速度。
|
||||
|
||||
### AnimationInfo.durationFunction
|
||||
|
||||
@@ -432,6 +445,11 @@ public Action OnAnimationStart
|
||||
public bool reverse
|
||||
是否开启反向动画效果。
|
||||
|
||||
### AnimationInfo.speed
|
||||
|
||||
public float speed
|
||||
动画的速度。当指定speed时,duration将失效。默认为0,表示不指定速度。
|
||||
|
||||
### AnimationInfo.End
|
||||
|
||||
public void End()
|
||||
@@ -526,7 +544,7 @@ public float GetWidth(float width)
|
||||
|
||||
class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
|
||||
|
||||
动画组件,用于控制图表的动画播放。支持配置五种动画表现:FadeIn(渐入动画),FadeOut(渐出动画),Change(变更动画),Addition(新增动画),Interaction(交互动画)。 按作用的对象可以分为两类:SerieAnimation(系列动画)和DataAnimation(数据动画)。
|
||||
动画组件,用于控制图表的动画播放。支持配置五种动画表现:FadeIn(渐入动画),FadeOut(渐出动画),Change(变更动画),Addition(新增动画),Interaction(交互动画),Exchange(交换动画)。 按作用的对象可以分为两类:SerieAnimation(系列动画)和DataAnimation(数据动画)。
|
||||
|
||||
### AnimationStyle.addition
|
||||
|
||||
@@ -543,6 +561,11 @@ public AnimationChange change
|
||||
public bool enable
|
||||
是否开启动画效果。
|
||||
|
||||
### AnimationStyle.exchange
|
||||
|
||||
public AnimationExchange exchange
|
||||
交换动画配置。如在排序柱图中有效。
|
||||
|
||||
### AnimationStyle.fadeIn
|
||||
|
||||
public AnimationFadeIn fadeIn
|
||||
@@ -634,6 +657,10 @@ public int GetCurrIndex()
|
||||
|
||||
public float GetCurrRate()
|
||||
|
||||
### AnimationStyle.GetExchangeDuration
|
||||
|
||||
public float GetExchangeDuration()
|
||||
|
||||
### AnimationStyle.GetInteractionDuration
|
||||
|
||||
public float GetInteractionDuration()
|
||||
@@ -784,6 +811,14 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类:
|
||||
|
||||
直角坐标系的坐标轴组件。
|
||||
|
||||
### Axis.onLabelClick
|
||||
|
||||
public Action<int, string> onLabelClick
|
||||
|
||||
> 从 `v3.15.0` 开始支持
|
||||
|
||||
点击文本标签回调函数。参数:labelIndex, labelName。
|
||||
|
||||
### Axis.AddData
|
||||
|
||||
public void AddData(string category)
|
||||
@@ -883,7 +918,7 @@ public bool IsLog()
|
||||
|
||||
### Axis.IsNeedShowLabel
|
||||
|
||||
public bool IsNeedShowLabel(int index, int total = 0)
|
||||
public bool IsNeedShowLabel(int index, int total = 0, string content = null)
|
||||
|
||||
### Axis.IsRight
|
||||
|
||||
@@ -1042,6 +1077,10 @@ public bool needAnimation
|
||||
public List<string> runtimeData
|
||||
数值轴时每个tick的数值。
|
||||
|
||||
### AxisContext.sortedDataIndices
|
||||
|
||||
public List<int> sortedDataIndices
|
||||
|
||||
## AxisHandler<T>
|
||||
|
||||
class in XCharts / 继承自: [MainComponentHandler](#maincomponenthandler)
|
||||
@@ -1050,6 +1089,14 @@ class in XCharts / 继承自: [MainComponentHandler](#maincomponenthandler)
|
||||
|
||||
public T component
|
||||
|
||||
### AxisHandler<T>.DrawTop
|
||||
|
||||
// public override void DrawTop(VertexHelper vh)
|
||||
|
||||
### AxisHandler<T>.OnPointerClick
|
||||
|
||||
public override void OnPointerClick(PointerEventData eventData)
|
||||
|
||||
## AxisHelper
|
||||
|
||||
class in XCharts.Runtime
|
||||
@@ -1088,7 +1135,7 @@ public static float GetAxisValueDistance(GridCoord grid, Axis axis, float scaleW
|
||||
|
||||
### AxisHelper.GetAxisValueLength
|
||||
|
||||
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)
|
||||
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value, float gap = 0)
|
||||
获得数值value在坐标轴上对应的长度
|
||||
|
||||
### AxisHelper.GetAxisValuePosition
|
||||
@@ -1170,12 +1217,12 @@ public void Copy(AxisLabel axisLabel)
|
||||
|
||||
### AxisLabel.GetFormatterContent
|
||||
|
||||
public override string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
public override string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
|
||||
|
||||
### AxisLabel.IsNeedShowLabel
|
||||
|
||||
public bool IsNeedShowLabel(int index, int total)
|
||||
public bool IsNeedShowLabel(int index, int total, string content = null)
|
||||
|
||||
### AxisLabel.SetRelatedText
|
||||
|
||||
@@ -1383,6 +1430,10 @@ public int containerIndex
|
||||
|
||||
public int containterInstanceId
|
||||
|
||||
### Bar.useSortData
|
||||
|
||||
public override bool useSortData
|
||||
|
||||
### Bar.AddDefaultSerie
|
||||
|
||||
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
|
||||
@@ -1661,6 +1712,10 @@ public Settings settings
|
||||
|
||||
public ThemeStyle theme
|
||||
|
||||
### BaseChart.topPainter
|
||||
|
||||
public Painter topPainter
|
||||
|
||||
### BaseChart.typeListForComponent
|
||||
|
||||
public Dictionary<Type, FieldInfo> typeListForComponent
|
||||
@@ -1669,6 +1724,11 @@ public Dictionary<Type, FieldInfo> typeListForComponent
|
||||
|
||||
public Dictionary<Type, FieldInfo> typeListForSerie
|
||||
|
||||
### BaseChart.useUtc
|
||||
|
||||
public bool useUtc
|
||||
图表的时间是否都显示为UTC时间。
|
||||
|
||||
### BaseChart.AddChartComponent
|
||||
|
||||
public MainComponent AddChartComponent(Type type)
|
||||
@@ -1925,6 +1985,10 @@ public Color32 GetLegendRealShowNameColor(string name)
|
||||
|
||||
public int GetLegendRealShowNameIndex(string name)
|
||||
|
||||
### BaseChart.GetMainAxis
|
||||
|
||||
public Axis GetMainAxis()
|
||||
|
||||
### BaseChart.GetMarkColor
|
||||
|
||||
public Color32 GetMarkColor(Serie serie, SerieData serieData)
|
||||
@@ -1941,6 +2005,10 @@ public T GetOrAddChartComponent<T>() where T : MainComponent
|
||||
|
||||
public Painter GetPainter(int index)
|
||||
|
||||
### BaseChart.GetRealtimeSortSerie
|
||||
|
||||
public Serie GetRealtimeSortSerie(int gridIndex)
|
||||
|
||||
### BaseChart.GetSerie
|
||||
|
||||
public Serie GetSerie(int serieIndex)
|
||||
@@ -1953,19 +2021,19 @@ public T GetSerie<T>(int serieIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSerieBarGap<T>
|
||||
|
||||
public float GetSerieBarGap<T>() where T : Serie
|
||||
public float GetSerieBarGap<T>(int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSerieBarRealCount<T>
|
||||
|
||||
public int GetSerieBarRealCount<T>() where T : Serie
|
||||
public int GetSerieBarRealCount<T>(int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSerieIndexIfStack<T>
|
||||
|
||||
public int GetSerieIndexIfStack<T>(Serie currSerie) where T : Serie
|
||||
public int GetSerieIndexIfStack<T>(Serie currSerie, int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSerieSameStackTotalValue<T>
|
||||
|
||||
public double GetSerieSameStackTotalValue<T>(string stack, int dataIndex) where T : Serie
|
||||
public double GetSerieSameStackTotalValue<T>(string stack, int dataIndex, int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSeriesMinMaxValue
|
||||
|
||||
@@ -1973,15 +2041,11 @@ public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double te
|
||||
|
||||
### BaseChart.GetSerieTotalGap<T>
|
||||
|
||||
public float GetSerieTotalGap<T>(float categoryWidth, float gap, int index) where T : Serie
|
||||
public float GetSerieTotalGap<T>(float categoryWidth, float gap, int index, int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetSerieTotalWidth<T>
|
||||
|
||||
public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount) where T : Serie
|
||||
|
||||
### BaseChart.GetTitlePosition
|
||||
|
||||
public Vector3 GetTitlePosition(Title title)
|
||||
public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount, int gridIndex) where T : Serie
|
||||
|
||||
### BaseChart.GetVisualMapOfSerie
|
||||
|
||||
@@ -2007,6 +2071,10 @@ public bool HasChartComponent(Type type)
|
||||
|
||||
public bool HasChartComponent<T>()
|
||||
|
||||
### BaseChart.HasRealtimeSortSerie
|
||||
|
||||
public bool HasRealtimeSortSerie(int gridIndex)
|
||||
|
||||
### BaseChart.HasSerie
|
||||
|
||||
public bool HasSerie(Type type)
|
||||
@@ -2498,6 +2566,10 @@ public string warningInfo
|
||||
public string CheckWarning()
|
||||
检测警告信息。
|
||||
|
||||
### BaseGraph.GetTitlePosition
|
||||
|
||||
public Vector3 GetTitlePosition(Title title)
|
||||
|
||||
### BaseGraph.LocalPointToScreenPoint
|
||||
|
||||
public Vector2 LocalPointToScreenPoint(Vector2 localPoint)
|
||||
@@ -2564,11 +2636,6 @@ public void RefreshAllComponent()
|
||||
public virtual void RefreshGraph()
|
||||
在下一帧刷新图形。
|
||||
|
||||
### BaseGraph.SaveAsImage
|
||||
|
||||
public void SaveAsImage(string imageType = "png", string savePath = "")
|
||||
保存图表为图片。
|
||||
|
||||
### BaseGraph.ScreenPointToChartPoint
|
||||
|
||||
public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint)
|
||||
@@ -2826,6 +2893,14 @@ public static string ColorToStr(Color color)
|
||||
|
||||
public static string FloatToStr(double value, string numericFormatter = "F", int precision = 0)
|
||||
|
||||
### ChartCached.GetAxisLabelName
|
||||
|
||||
public static string GetAxisLabelName(int index)
|
||||
|
||||
### ChartCached.GetComponentObjectName
|
||||
|
||||
public static string GetComponentObjectName(MainComponent component)
|
||||
|
||||
### ChartCached.GetSerieLabelName
|
||||
|
||||
public static string GetSerieLabelName(string prefix, int i, int j)
|
||||
@@ -2834,17 +2909,25 @@ public static string GetSerieLabelName(string prefix, int i, int j)
|
||||
|
||||
public static string GetString(string prefix, int suffix)
|
||||
|
||||
### ChartCached.GetTypeName
|
||||
|
||||
public static string GetTypeName(Type type)
|
||||
|
||||
### ChartCached.GetTypeName<T>
|
||||
|
||||
public static string GetTypeName<T>()
|
||||
|
||||
### ChartCached.IntToStr
|
||||
|
||||
public static string IntToStr(int value, string numericFormatter = "")
|
||||
|
||||
### ChartCached.NumberToDateStr
|
||||
|
||||
public static string NumberToDateStr(double timestamp, string formatter)
|
||||
public static string NumberToDateStr(double timestamp, string formatter, bool local = false)
|
||||
|
||||
### ChartCached.NumberToDateTime
|
||||
|
||||
public static DateTime NumberToDateTime(double timestamp)
|
||||
public static DateTime NumberToDateTime(double timestamp, bool local = false)
|
||||
|
||||
### ChartCached.NumberToStr
|
||||
|
||||
@@ -3082,14 +3165,14 @@ public static List<string> ParseStringFromString(string jsonData)
|
||||
|
||||
public static void RemoveComponent<T>(GameObject gameObject)
|
||||
|
||||
### ChartHelper.RemoveTMPComponents
|
||||
|
||||
public static void RemoveTMPComponents(GameObject gameObject)
|
||||
|
||||
### ChartHelper.RotateRound
|
||||
|
||||
public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle)
|
||||
|
||||
### ChartHelper.SaveAsImage
|
||||
|
||||
public static Texture2D SaveAsImage(RectTransform rectTransform, Canvas canvas, string imageType = "png", string path = "")
|
||||
|
||||
### ChartHelper.SetActive
|
||||
|
||||
public static bool SetActive(Image image, bool active)
|
||||
@@ -3149,6 +3232,10 @@ public float GetTextWidth()
|
||||
|
||||
public float GetWidth()
|
||||
|
||||
### ChartLabel.InRect
|
||||
|
||||
public bool InRect(Vector2 local)
|
||||
|
||||
### ChartLabel.IsActiveByScale
|
||||
|
||||
public bool IsActiveByScale()
|
||||
@@ -3403,13 +3490,20 @@ public static Color32 GetColor(string hexColorStr)
|
||||
|
||||
class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent),[IPropertyChanged](#ipropertychanged)
|
||||
|
||||
图表注解组件。
|
||||
> 从 `v3.15.0` 开始支持
|
||||
|
||||
图表注解组件。用于标注图表中的特殊信息。
|
||||
|
||||
### Comment.items
|
||||
|
||||
public List<CommentItem> items
|
||||
注解项。每个注解组件可以设置多个注解项。
|
||||
|
||||
### Comment.layer
|
||||
|
||||
public CommentLayer layer
|
||||
注解的显示层级。
|
||||
|
||||
### Comment.show
|
||||
|
||||
public bool show
|
||||
@@ -3418,10 +3512,12 @@ public bool show
|
||||
### Comment.GetLabelStyle
|
||||
|
||||
public LabelStyle GetLabelStyle(int index)
|
||||
获取注解项的文本样式。
|
||||
|
||||
### Comment.GetMarkStyle
|
||||
|
||||
public CommentMarkStyle GetMarkStyle(int index)
|
||||
获取注解项的标记样式。
|
||||
|
||||
### Comment.OnChanged
|
||||
|
||||
@@ -3434,10 +3530,9 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
|
||||
|
||||
注解项。
|
||||
|
||||
### CommentItem.content
|
||||
### CommentItem.labelObject
|
||||
|
||||
public string content
|
||||
注解的文本内容。支持模板参数,可以参考Tooltip的itemFormatter。
|
||||
public ChartLabel labelObject
|
||||
|
||||
### CommentItem.markRect
|
||||
|
||||
@@ -3454,6 +3549,17 @@ public CommentMarkStyle markStyle
|
||||
public bool show
|
||||
是否显示当前注解项。
|
||||
|
||||
## CommentLayer
|
||||
|
||||
class in XCharts.Runtime
|
||||
|
||||
注解的显示层级。
|
||||
|
||||
可选:
|
||||
|
||||
- `Lower`: 注解在系列下方。
|
||||
- `Upper`: 注解在系列上方。
|
||||
|
||||
## CommentMarkStyle
|
||||
|
||||
class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
|
||||
@@ -3739,17 +3845,17 @@ class in XCharts.Runtime
|
||||
|
||||
### DateTimeUtil.GetDateTime
|
||||
|
||||
public static DateTime GetDateTime(double timestamp, bool local = true)
|
||||
public static DateTime GetDateTime(double timestamp, bool local = false)
|
||||
|
||||
### DateTimeUtil.GetDefaultDateTimeString
|
||||
|
||||
public static string GetDefaultDateTimeString(int timestamp, double range = 0)
|
||||
public static string GetDefaultDateTimeString(double timestamp, double range = 0, bool local = false)
|
||||
|
||||
### DateTimeUtil.GetTimestamp
|
||||
|
||||
public static int GetTimestamp(DateTime time, bool local = false)
|
||||
public static double GetTimestamp(DateTime time, bool local = false)
|
||||
|
||||
public static int GetTimestamp(string dateTime, bool local = false)
|
||||
public static double GetTimestamp(string dateTime, bool local = false)
|
||||
|
||||
|
||||
### DateTimeUtil.IsDateOrTimeRegex
|
||||
@@ -3886,9 +3992,13 @@ public static bool NeedFormat(string content)
|
||||
|
||||
### FormatterHelper.ReplaceAxisLabelContent
|
||||
|
||||
public static void ReplaceAxisLabelContent(ref string content, string value)
|
||||
public static void ReplaceAxisLabelContent(ref string content, string value, int index, int totalIndex)
|
||||
|
||||
|
||||
### FormatterHelper.ReplaceIndexContent
|
||||
|
||||
public static void ReplaceIndexContent(ref string content, int currIndex, int totalIndex)
|
||||
|
||||
### FormatterHelper.TrimAndReplaceLine
|
||||
|
||||
public static string TrimAndReplaceLine(string content)
|
||||
@@ -4399,7 +4509,7 @@ public override void ClearData()
|
||||
|
||||
### Indicator.GetFormatterIndicatorContent
|
||||
|
||||
public string GetFormatterIndicatorContent(string indicatorName)
|
||||
public string GetFormatterIndicatorContent(string indicatorName, int index, int totalIndex)
|
||||
|
||||
|
||||
### Indicator.GetIndicator
|
||||
@@ -4650,12 +4760,12 @@ public Color GetColor(Color defaultColor)
|
||||
|
||||
### LabelStyle.GetFormatterContent
|
||||
|
||||
public virtual string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
public virtual string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
|
||||
|
||||
### LabelStyle.GetFormatterDateTime
|
||||
|
||||
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue)
|
||||
public string GetFormatterDateTime(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool local)
|
||||
|
||||
### LabelStyle.GetOffset
|
||||
|
||||
@@ -5659,6 +5769,10 @@ class in XCharts.Runtime / 继承自: [MainComponentHandler](#maincomponenthandl
|
||||
|
||||
public T component
|
||||
|
||||
## MainComponentHandler<Title>
|
||||
|
||||
class in / 子类: [TitleHandler](#titlehandler)
|
||||
|
||||
## MarkArea
|
||||
|
||||
class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent)
|
||||
@@ -5757,7 +5871,7 @@ class in XCharts.Runtime
|
||||
|
||||
可选:
|
||||
|
||||
- `None`: 标线类型
|
||||
- `Custom`: 自定义。可自定义xy坐标或数值。
|
||||
- `Min`: 最小值。
|
||||
- `Max`: 最大值。
|
||||
- `Average`: 平均值。
|
||||
@@ -5954,10 +6068,6 @@ class in XCharts.Runtime / 继承自: [MaskableGraphic](https://docs.unity3d.com
|
||||
|
||||
public int index
|
||||
|
||||
### Painter.onPopulateMesh
|
||||
|
||||
public Action<VertexHelper, Painter> onPopulateMesh
|
||||
|
||||
### Painter.type
|
||||
|
||||
public Type type
|
||||
@@ -6092,6 +6202,15 @@ public void DefaultLabelPieChart()
|
||||
public void DefaultRadiusRosePieChart()
|
||||
默认玫瑰饼图。
|
||||
|
||||
## PieType
|
||||
|
||||
class in XCharts.Runtime
|
||||
|
||||
可选:
|
||||
|
||||
- `Solid`: 实心饼图 - 默认填充样式
|
||||
- `Wireframe`: 线框饼图 - 仅显示轮廓线框
|
||||
|
||||
## PolarAxisTheme
|
||||
|
||||
class in XCharts.Runtime / 继承自: [BaseAxisTheme](#baseaxistheme)
|
||||
@@ -6719,7 +6838,7 @@ public double GetData(int index, int dimension, DataZoom dataZoom = null)
|
||||
|
||||
### Serie.GetDataList
|
||||
|
||||
public List<SerieData> GetDataList(DataZoom dataZoom = null)
|
||||
public List<SerieData> GetDataList(DataZoom dataZoom = null, bool sorted = false)
|
||||
获得系列的数据列表
|
||||
|
||||
### Serie.GetDataTotal
|
||||
@@ -7026,6 +7145,10 @@ public SelectStyle selectStyle
|
||||
public bool show
|
||||
该数据项是否要显示。
|
||||
|
||||
### SerieData.sortIndex
|
||||
|
||||
public int sortIndex
|
||||
|
||||
### SerieData.state
|
||||
|
||||
public SerieState state
|
||||
@@ -7109,12 +7232,12 @@ public double GetLastData()
|
||||
|
||||
### SerieData.GetMaxData
|
||||
|
||||
public double GetMaxData(bool inverse = false)
|
||||
public double GetMaxData(bool inverse = false, int startDimensionIndex = 0)
|
||||
最大值。
|
||||
|
||||
### SerieData.GetMinData
|
||||
|
||||
public double GetMinData(bool inverse = false)
|
||||
public double GetMinData(bool inverse = false, int startDimensionIndex = 0)
|
||||
最小值。
|
||||
|
||||
### SerieData.GetMinMaxData
|
||||
@@ -7172,7 +7295,7 @@ public void SetIconActive(bool flag)
|
||||
|
||||
### SerieData.SetLabelActive
|
||||
|
||||
public void SetLabelActive(bool flag)
|
||||
public void SetLabelActive(bool flag, bool force = false)
|
||||
|
||||
### SerieData.SetPolygon
|
||||
|
||||
@@ -7225,6 +7348,10 @@ class in XCharts.Runtime
|
||||
|
||||
public void Reset()
|
||||
|
||||
### SerieDataContext.UpdateExchangePosition
|
||||
|
||||
public void UpdateExchangePosition(ref float x, ref float y, float totalTime)
|
||||
|
||||
## SerieDataExtraFieldAttribute
|
||||
|
||||
class in XCharts.Runtime / 继承自: [Attribute](https://docs.unity3d.com/ScriptReference/30_search.html?q=attribute)
|
||||
@@ -7653,6 +7780,10 @@ public override void RefreshLabelInternal()
|
||||
|
||||
public override void RefreshLabelNextFrame()
|
||||
|
||||
### SerieHandler<T>.RefreshTitleLabelInternal
|
||||
|
||||
public void RefreshTitleLabelInternal()
|
||||
|
||||
### SerieHandler<T>.RemoveComponent
|
||||
|
||||
public override void RemoveComponent()
|
||||
@@ -7949,7 +8080,7 @@ class in XCharts.Runtime / 继承自: [SymbolStyle](#symbolstyle),[ISerieDataCom
|
||||
|
||||
### SerieSymbol.GetSize
|
||||
|
||||
public float GetSize(List<double> data, float themeSize)
|
||||
public float GetSize(SerieData serieData, float themeSize)
|
||||
根据指定的sizeType获得标记的大小
|
||||
|
||||
### SerieSymbol.Reset
|
||||
@@ -8573,6 +8704,30 @@ public override void ClearComponentDirty()
|
||||
|
||||
public void OnChanged()
|
||||
|
||||
## TitleHandler
|
||||
|
||||
class in XCharts.Runtime / 继承自: [MainComponentHandler<Title>](#maincomponenthandlertitle)
|
||||
|
||||
### TitleHandler.AddSubTitleLabel
|
||||
|
||||
public static ChartLabel AddSubTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
|
||||
|
||||
### TitleHandler.AddTitleLabel
|
||||
|
||||
public static ChartLabel AddTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
|
||||
|
||||
### TitleHandler.AddTitleObject
|
||||
|
||||
public static GameObject AddTitleObject(BaseGraph graph, Title title, ComponentTheme componentTheme, int titleSiblingIndex, string objectName = null)
|
||||
|
||||
### TitleHandler.InitComponent
|
||||
|
||||
public override void InitComponent()
|
||||
|
||||
### TitleHandler.OnSerieDataUpdate
|
||||
|
||||
public override void OnSerieDataUpdate(int serieIndex)
|
||||
|
||||
## TitleStyle
|
||||
|
||||
class in XCharts.Runtime / 继承自: [LabelStyle](#labelstyle),[ISerieDataComponent](#iseriedatacomponent),[ISerieComponent](#iseriecomponent)
|
||||
|
||||
@@ -6,6 +6,8 @@ slug: /changelog
|
||||
# 更新日志
|
||||
|
||||
[master](#master)
|
||||
[v3.15.0](#v3150)
|
||||
[v3.14.0](#v3140)
|
||||
[v3.13.0](#v3130)
|
||||
[v3.12.1](#v3121)
|
||||
[v3.12.0](#v3120)
|
||||
@@ -79,6 +81,89 @@ slug: /changelog
|
||||
|
||||
## master
|
||||
|
||||
## v3.15.0
|
||||
|
||||
版本要点:
|
||||
|
||||
* __时间轴与缩放能力增强__:新增 `DataZoom.minZoomRatio`(替代 `minShowNum`)、`Chart.useUtc`,并持续优化 `Axis Time` 在缩放与大年份场景下的表现。
|
||||
* __柱图与坐标轴配置更灵活__:新增 `Axis.mainAxis` 控制柱图朝向、`Serie.ignoreZeroOccupy` 控制 0 值柱是否占位、`AxisLine` 延长线配置等。
|
||||
* __图表样式与交互能力提升__:新增 `Pie.pieType`、`Legend.itemInactiveOpacity`、`Axis.onLabelClick`、`Animation.Exchange`、`LabelStyle.fixedX/fixedY` 等。
|
||||
* __扩展 UI 组件持续完善__:`UITable` 新增 `Title` 与 `Viewport` 配置,`UIStatistic.desc` 增强,`Comment.layer` 与坐标刷新体验优化。
|
||||
* __稳定性与兼容性修复集中推进__:修复 `SaveAsImage` 遮挡保存、`Pie` 点击失效、`TMP` 兼容、`Gantt` 时间区间与 2038 年问题、`MarkArea/GridCoord/Axis` 等多项关键问题。
|
||||
|
||||
日志详情:
|
||||
|
||||
* (2026.03.01) 发布`v3.15.0`版本
|
||||
* (2026.02.26) 增加`Serie`的`ignoreZeroOccupy`可设置0数据的Bar是否占位 (#286)
|
||||
* (2026.02.26) 修复`SaveAsImage`被其他组件遮挡时无法正常保存的问题 (#337)
|
||||
* (2026.02.26) 增加`Axis`的`mainAxis`参数设置主轴可控制柱图的朝向 (#331)
|
||||
* (2026.02.03) 修复`UITable`的`viewport`在不同的锚点下可能会绘制异常的问题
|
||||
* (2026.01.15) 修复`Pie`的点击有时候不响应的问题 (#357)
|
||||
* (2026.01.08) 增加`DataZoom`的`minZoomRatio`替换旧的`minShowNum` (#350)
|
||||
* (2025.11.05) 修复`Axis`的`indicatorLabel`无法隐藏的问题
|
||||
* (2025.11.03) 增加`Tooltip`的`Title`可通过`TitleLabelStyle`的`numericFormatter`格式化时间显示 (#353)
|
||||
* (2025.10.30) 增加`Chart`的`useUtc`参数设置显示时间是否用UTC时间
|
||||
* (2025.10.30) 优化`Candlestick`对时间轴的支持
|
||||
* (2025.10.30) 增加`Scatter`的`ignore`支持设置忽略数据
|
||||
* (2025.10.24) 优化`Sankey`的线条绘制排序
|
||||
* (2025.10.22) 增加`Pie`的`pieType`支持实心饼图和线框柄图 (#349)
|
||||
* (2025.09.05) 优化`MarkLine`的表现
|
||||
* (2025.09.01) 增加`AxisLine`的`startExtendLength`和`endExtendLength`设置轴线的延长线
|
||||
* (2025.08.27) 修复`Serie`的`TitleStyle`在数据变更时不及时刷新的问题
|
||||
* (2025.05.19) 修复`TMP`开启时`Axis`运行报错
|
||||
* (2025.04.25) 修复`MarkArea`指定`yValue`或`xValue`时绘制区域不准确的问题
|
||||
* (2025.04.17) 增加`UITable`的`Title`支持设置标题
|
||||
* (2025.04.17) 增加`UITable`的`Viewport`支持设置表格视口边距边框
|
||||
* (2025.04.15) 增加`Bar`支持通过`VisualMap`设置颜色
|
||||
* (2025.04.14) 增加`AxisLabel`的`showZeroLabel`设置是否显示0刻度
|
||||
* (2025.04.08) 增加`UIStatistic`的`desc`描述文本设置支持
|
||||
* (2025.04.07) 修复`Gantt`甘特图在有多维数据时计算的时间区间不准确的问题
|
||||
* (2025.04.07) 优化`Axis`的`Time`时间轴支持设置Custom和ceilRate
|
||||
* (2025.04.07) 修复`GridCoord`在设置背景色且Serie开启Clip时会覆盖图表的问题
|
||||
* (2025.04.07) 修复`Gantt`甘特图年份大于2038时显示异常的问题
|
||||
* (2025.04.07) 修复`Axis`的`Time`时间轴无法显示大于2038的年份的问题
|
||||
* (2025.04.06) 修复`Axis`的`Time`时间轴在有`DataZoom`缩放时文本显示异常的问题
|
||||
* (2025.03.28) 修复`Pie3D`的`avoidLabelOverlap`不生效的问题
|
||||
* (2025.03.27) 增加`Legend`的`itemInactiveOpacity`可设置非激活状态时的颜色透明度 (#343)
|
||||
* (2025.03.27) 增加`Axis`的`onLabelClick`回调事件
|
||||
* (2025.03.26) 增加`Animation`的`Exchange`排序交换动画
|
||||
* (2025.03.22) 增加`Comment`的`layer`设置层级
|
||||
* (2025.03.21) 优化`Comment`的坐标刷新
|
||||
* (2025.03.19) 增加`Serie`的`Label`的`formatter`支持`{index}`通配符
|
||||
* (2025.03.18) 增加`Bar`可添加`TitleStyle`组件支持
|
||||
* (2025.03.18) 增加`LabelStyle`的`fixedX`和`fixedY`可固定label的坐标
|
||||
* (2025.03.17) 增加`ItemStyle`的`backgroundGap`可设置数据项背景间隙
|
||||
|
||||
## v3.14.0
|
||||
|
||||
版本要点:
|
||||
|
||||
* 新增`Bar`的实时排序功能
|
||||
* 新增`Tooltip`的`itemFormatter`支持`\n`换行
|
||||
* 新增`AxisLabel`的格式化支持`{index}`
|
||||
* 新增`Animation`的`speed`可指定动画速度
|
||||
* 优化`Tooltip`的列对齐方式
|
||||
|
||||
日志详情:
|
||||
|
||||
* (2025.03.15) 发布`v3.14.0`版本
|
||||
* (2025.03.09) 修复`Bar`在同一个`Chart`不同`Grid`里时绘制有些异常的问题
|
||||
* (2025.03.07) 增加`Animation`的`speed`可指定动画速度
|
||||
* (2025.03.06) 优化`Animation`的新增动画表现
|
||||
* (2025.03.04) 修复`Treemap`的`label`显示异常的问题
|
||||
* (2025.03.02) 增加`Tooltip`的`columnGapWidths`参数设置列文本间隙距离
|
||||
* (2025.03.01) 优化`Comment`的组件刷新
|
||||
* (2025.02.23) 增加`Axis`的`Label`的`formatter`支持`{index}``{index-1}``{-index}``{-index-1}`通配符
|
||||
* (2025.02.23) 增加`Bar`的`realtimeSort`支持实时排序
|
||||
* (2025.02.19) 增加`Tooltip`的`itemFormatter`对`\n`换行的支持
|
||||
* (2025.02.18) 优化`Tooltip`的对齐方式
|
||||
* (2025.02.09) 修复`SaveAsImage`保存图片时不支持透明度的问题 (#337)
|
||||
* (2025.02.05) 增加`GraphChart`可单独设置`data`样式的支持
|
||||
* (2025.02.05) 重构`SerieSymbol`的`sizeFunction`参数
|
||||
* (2025.01.23) 修复`Treemap`的`Label`不显示的问题
|
||||
* (2025.01.15) 修复`Chart`在运行时动态添加`Component`异常的问题 (#339)
|
||||
* (2025.01.08) 修复`TextMeshPro`关闭时残留组件影响`Text`初始化的问题
|
||||
|
||||
## v3.13.0
|
||||
|
||||
版本要点:
|
||||
|
||||
@@ -176,6 +176,7 @@ slug: /configuration
|
||||
|
||||
- [AnimationAddition](#animationaddition)
|
||||
- [AnimationChange](#animationchange)
|
||||
- [AnimationExchange](#animationexchange)
|
||||
- [AnimationFadeIn](#animationfadein)
|
||||
- [AnimationFadeOut](#animationfadeout)
|
||||
- [AnimationHiding](#animationhiding)
|
||||
@@ -234,6 +235,14 @@ class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
|
||||
|
||||
数据变更动画。
|
||||
|
||||
## AnimationExchange
|
||||
|
||||
class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
|
||||
|
||||
> 从 `v3.15.0` 开始支持
|
||||
|
||||
数据交换动画。一般用于图表数据排序时顺序变化的动画。
|
||||
|
||||
## AnimationFadeIn
|
||||
|
||||
class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
|
||||
@@ -260,7 +269,7 @@ class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
|
||||
|
||||
## AnimationInfo
|
||||
|
||||
class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein), [AnimationFadeOut](#animationfadeout), [AnimationChange](#animationchange), [AnimationAddition](#animationaddition), [AnimationHiding](#animationhiding), [AnimationInteraction](#animationinteraction)
|
||||
class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein), [AnimationFadeOut](#animationfadeout), [AnimationChange](#animationchange), [AnimationAddition](#animationaddition), [AnimationHiding](#animationhiding), [AnimationInteraction](#animationinteraction), [AnimationExchange](#animationexchange)
|
||||
|
||||
> 从 `v3.8.0` 开始支持
|
||||
|
||||
@@ -276,7 +285,7 @@ class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein), [Animati
|
||||
|
||||
`float` `1000` `v3.8.0`
|
||||
|
||||
动画的时长。
|
||||
动画的时长。默认用于计算动画的速度。也可以通过speed指定速度。
|
||||
|
||||
### AnimationInfo.enable
|
||||
|
||||
@@ -290,6 +299,12 @@ class in XCharts.Runtime / 子类: [AnimationFadeIn](#animationfadein), [Animati
|
||||
|
||||
是否开启反向动画效果。
|
||||
|
||||
### AnimationInfo.speed
|
||||
|
||||
`float` `0` `v3.14.0`
|
||||
|
||||
动画的速度。当指定speed时,duration将失效。默认为0,表示不指定速度。
|
||||
|
||||
## AnimationInteraction
|
||||
|
||||
class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
|
||||
@@ -320,7 +335,7 @@ class in XCharts.Runtime / 继承自: [AnimationInfo](#animationinfo)
|
||||
|
||||
class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
|
||||
|
||||
动画组件,用于控制图表的动画播放。支持配置五种动画表现:FadeIn(渐入动画),FadeOut(渐出动画),Change(变更动画),Addition(新增动画),Interaction(交互动画)。 按作用的对象可以分为两类:SerieAnimation(系列动画)和DataAnimation(数据动画)。
|
||||
动画组件,用于控制图表的动画播放。支持配置五种动画表现:FadeIn(渐入动画),FadeOut(渐出动画),Change(变更动画),Addition(新增动画),Interaction(交互动画),Exchange(交换动画)。 按作用的对象可以分为两类:SerieAnimation(系列动画)和DataAnimation(数据动画)。
|
||||
|
||||
### AnimationStyle.addition
|
||||
|
||||
@@ -350,6 +365,12 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
|
||||
|
||||
是否开启动画效果。
|
||||
|
||||
### AnimationStyle.exchange
|
||||
|
||||
[AnimationExchange](#animationexchange) `v3.15.0`
|
||||
|
||||
交换动画配置。如在排序柱图中有效。
|
||||
|
||||
### AnimationStyle.fadeIn
|
||||
|
||||
[AnimationFadeIn](#animationfadein) `v3.8.0`
|
||||
@@ -597,6 +618,12 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent) / 子类:
|
||||
|
||||
对数轴是否以自然数 e 为底数,为 true 时 logBase 失效。
|
||||
|
||||
### Axis.mainAxis
|
||||
|
||||
`bool` `false` `v3.15.0`
|
||||
|
||||
是否为主轴。当XY轴类型都相同时,设置为主轴的轴会决定朝向,如横向柱图和纵向柱图。
|
||||
|
||||
### Axis.max
|
||||
|
||||
`double`
|
||||
@@ -783,6 +810,12 @@ class in XCharts.Runtime / 继承自: [LabelStyle](#labelstyle)
|
||||
|
||||
是否显示第一个文本。
|
||||
|
||||
### AxisLabel.showZeroLabel
|
||||
|
||||
`bool` `true` `v3.15.0`
|
||||
|
||||
是否显示0刻度文本。
|
||||
|
||||
### AxisLabel.textLimit
|
||||
|
||||
[TextLimit](#textlimit)
|
||||
@@ -801,6 +834,12 @@ class in XCharts.Runtime / 继承自: [BaseLine](#baseline)
|
||||
|
||||
轴线箭头。
|
||||
|
||||
### AxisLine.endExtendLength
|
||||
|
||||
`float`
|
||||
|
||||
轴线终点延长线长度。
|
||||
|
||||
### AxisLine.onZero
|
||||
|
||||
`bool`
|
||||
@@ -813,6 +852,12 @@ X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一
|
||||
|
||||
是否显示箭头。
|
||||
|
||||
### AxisLine.startExtendLength
|
||||
|
||||
`float`
|
||||
|
||||
轴线起点延长线长度。
|
||||
|
||||
## AxisMinorSplitLine
|
||||
|
||||
class in XCharts.Runtime / 继承自: [BaseLine](#baseline)
|
||||
@@ -1241,7 +1286,9 @@ class in XCharts.Runtime / 子类: [AnimationStyle](#animationstyle), [AxisAnima
|
||||
|
||||
class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent), [IPropertyChanged](#ipropertychanged)
|
||||
|
||||
图表注解组件。
|
||||
> 从 `v3.15.0` 开始支持
|
||||
|
||||
图表注解组件。用于标注图表中的特殊信息。
|
||||
|
||||
### Comment.items
|
||||
|
||||
@@ -1255,6 +1302,17 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent), [IPropert
|
||||
|
||||
所有组件的文本样式。
|
||||
|
||||
### Comment.layer
|
||||
|
||||
[CommentLayer](#commentlayer) `v3.15.0`
|
||||
|
||||
注解的显示层级。
|
||||
|
||||
可选:
|
||||
|
||||
- `Lower`: 注解在系列下方。
|
||||
- `Upper`: 注解在系列上方。
|
||||
|
||||
### Comment.markStyle
|
||||
|
||||
[CommentMarkStyle](#commentmarkstyle)
|
||||
@@ -1464,11 +1522,11 @@ DataZoom 组件 用于区域缩放,从而能自由关注细节的数据信息
|
||||
|
||||
选取框样式。
|
||||
|
||||
### DataZoom.minShowNum
|
||||
### DataZoom.minZoomRatio
|
||||
|
||||
`int` `2`
|
||||
`float` `0.2f`
|
||||
|
||||
最小显示数据个数。当DataZoom放大到最大时,最小显示的数据个数。
|
||||
缩放区域组件的最小缩放比例,范围0f-1f。
|
||||
|
||||
### DataZoom.orient
|
||||
|
||||
@@ -2232,6 +2290,12 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent), [ISerie
|
||||
|
||||
数据项背景颜色。
|
||||
|
||||
### ItemStyle.backgroundGap
|
||||
|
||||
`float` `v3.15.0`
|
||||
|
||||
数据项背景间隙。
|
||||
|
||||
### ItemStyle.backgroundWidth
|
||||
|
||||
`float`
|
||||
@@ -2458,11 +2522,23 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent), [ISerie
|
||||
|
||||
距离轴线的距离。
|
||||
|
||||
### LabelStyle.fixedX
|
||||
|
||||
`float` `0` `v3.15.0`
|
||||
|
||||
固定的X值。不为0时,会固定在指定的X值上。
|
||||
|
||||
### LabelStyle.fixedY
|
||||
|
||||
`float` `0` `v3.15.0`
|
||||
|
||||
固定的Y值。不为0时,会固定在指定的Y值上。
|
||||
|
||||
### LabelStyle.formatter
|
||||
|
||||
`string`
|
||||
|
||||
标签内容字符串模版格式器。支持用 \n 换行。部分组件的格式器会不生效。<br/> 模板通配符有以下这些,部分只适用于固定的组件:<br/> `\{.\}`:圆点标记。<br/> `\{a\}`:系列名。<br/> `\{b\}`:X轴类目名或数据名。<br/> `\{c\}`:数据值。<br/> `\{d\}`:百分比。<br/> `\{e\}`:数据名。<br/> `\{f\}`:数据和。<br/> `\{g\}`:数据总个数。<br/> `\{h\}`:十六进制颜色值。<br/> `\{y\}`:Y轴的类目名。<br/> `\{value\}`:坐标轴或图例的值。<br/> 以下通配符适用UITable组件:<br/> `\{name\}`: 表格的行名。<br/> `\{index\}`:表格的行号。<br/> 以下通配符适用UIStatistc组件:<br/> `\{title\}`:标题文本。<br/> `\{dd\}`:天。<br/> `\{hh\}`:小时。<br/> `\{mm\}`:分钟。<br/> `\{ss\}`:秒。<br/> `\{fff\}`:毫秒。<br/> `\{d\}`:天。<br/> `\{h\}`:小时。<br/> `\{m\}`:分钟。<br/> `\{s\}`:秒。<br/> `\{f\}`:毫秒。<br/> 示例:“\{b\}:\{c\}”
|
||||
标签内容字符串模版格式器。支持用 \n 换行。部分组件的格式器会不生效。<br/> 模板通配符有以下这些,部分只适用于固定的组件:<br/> `\{.\}`:圆点标记。<br/> `\{a\}`:系列名。<br/> `\{b\}`:X轴类目名或数据名。<br/> `\{c\}`:数据值。<br/> `\{d\}`:百分比。<br/> `\{e\}`:数据名。<br/> `\{f\}`:数据和。<br/> `\{g\}`:数据总个数。<br/> `\{h\}`:十六进制颜色值。<br/> `\{y\}`:Y轴的类目名。<br/> `\{value\}`:坐标轴或图例的值。<br/> `\{index\}`:坐标轴编号。<br/> 以下通配符适用UITable组件:<br/> `\{name\}`: 表格的行名。<br/> `\{index\}`:表格的行号。<br/> 以下通配符适用UIStatistc组件:<br/> `\{title\}`:标题文本。<br/> `\{dd\}`:天。<br/> `\{hh\}`:小时。<br/> `\{mm\}`:分钟。<br/> `\{ss\}`:秒。<br/> `\{fff\}`:毫秒。<br/> `\{d\}`:天。<br/> `\{h\}`:小时。<br/> `\{m\}`:分钟。<br/> `\{s\}`:秒。<br/> `\{f\}`:毫秒。<br/> 示例:“\{b\}:\{c\}”
|
||||
|
||||
### LabelStyle.height
|
||||
|
||||
@@ -2609,6 +2685,12 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent), [IPropert
|
||||
|
||||
图例标记的图形高度。
|
||||
|
||||
### Legend.itemInactiveOpacity
|
||||
|
||||
`float` `1` `v3.15.0`
|
||||
|
||||
图例标记的图形在非激活状态下的颜色透明度。
|
||||
|
||||
### Legend.itemOpacity
|
||||
|
||||
`float` `1`
|
||||
@@ -2684,11 +2766,11 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent), [IPropert
|
||||
|
||||
class in XCharts.Runtime / 继承自: [ComponentTheme](#componenttheme)
|
||||
|
||||
### LegendTheme.unableColor
|
||||
### LegendTheme.inactiveColor
|
||||
|
||||
`Color`
|
||||
|
||||
文本颜色。
|
||||
非激活状态时的颜色。
|
||||
|
||||
## Level
|
||||
|
||||
@@ -3104,7 +3186,7 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
|
||||
|
||||
可选:
|
||||
|
||||
- `None`: 标线类型
|
||||
- `Custom`: 自定义。可自定义xy坐标或数值。
|
||||
- `Min`: 最小值。
|
||||
- `Max`: 最大值。
|
||||
- `Average`: 平均值。
|
||||
@@ -3114,25 +3196,25 @@ class in XCharts.Runtime / 继承自: [ChildComponent](#childcomponent)
|
||||
|
||||
`float`
|
||||
|
||||
相对原点的 x 坐标,单位像素。当type为None时有效。
|
||||
相对原点的 x 坐标,单位像素。当type为Custom时有效。
|
||||
|
||||
### MarkLineData.xValue
|
||||
|
||||
`double`
|
||||
|
||||
X轴上的指定值。当X轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为None时有效。
|
||||
X轴上的指定值。当X轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为Custom时有效。
|
||||
|
||||
### MarkLineData.yPosition
|
||||
|
||||
`float`
|
||||
|
||||
相对原点的 y 坐标,单位像素。当type为None时有效。
|
||||
相对原点的 y 坐标,单位像素。当type为Custom时有效。
|
||||
|
||||
### MarkLineData.yValue
|
||||
|
||||
`double`
|
||||
|
||||
Y轴上的指定值。当Y轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为None时有效。
|
||||
Y轴上的指定值。当Y轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为Custom时有效。
|
||||
|
||||
### MarkLineData.zeroPosition
|
||||
|
||||
@@ -3297,6 +3379,17 @@ grid 组件离容器上侧的距离。
|
||||
|
||||
class in XCharts.Runtime / 继承自: [Serie](#serie)
|
||||
|
||||
### Pie.pieType
|
||||
|
||||
[PieType](#pietype) `v3.15.0`
|
||||
|
||||
饼图类型。
|
||||
|
||||
可选:
|
||||
|
||||
- `Solid`: 实心饼图 - 默认填充样式
|
||||
- `Wireframe`: 线框饼图 - 仅显示轮廓线框
|
||||
|
||||
### Pie.radiusGradient
|
||||
|
||||
`bool` `false` `v3.8.1`
|
||||
@@ -3575,6 +3668,12 @@ class in XCharts.Runtime / 继承自: [BaseSerie](#baseserie), [IComparable](htt
|
||||
|
||||
忽略数据的默认值。当ignore为true才有效。
|
||||
|
||||
### Serie.ignoreZeroOccupy
|
||||
|
||||
`bool` `false` `v3.15.0`
|
||||
|
||||
柱图是否忽略值为0的柱子占位。开启后,值为0的柱子将不会占用空间,柱子之间的间距会根据实际显示的柱子自动调整。一般用在柱状图中。
|
||||
|
||||
### Serie.index
|
||||
|
||||
`int`
|
||||
@@ -3755,6 +3854,12 @@ class in XCharts.Runtime / 继承自: [BaseSerie](#baseserie), [IComparable](htt
|
||||
|
||||
半径。radius[0]表示内径,radius[1]表示外径。
|
||||
|
||||
### Serie.realtimeSort
|
||||
|
||||
`bool` `false` `v3.14.0`
|
||||
|
||||
是否开启实时排序,用来实现动态排序图效果。目前仅在Bar中生效。
|
||||
|
||||
### Serie.right
|
||||
|
||||
`float`
|
||||
@@ -4816,11 +4921,17 @@ class in XCharts.Runtime / 继承自: [MainComponent](#maincomponent)
|
||||
|
||||
边框线宽。
|
||||
|
||||
### Tooltip.columnGapWidths
|
||||
|
||||
`List<float>` `v3.14.0`
|
||||
|
||||
内容部分的列间距。当只有一列时,只表示第二列的间距。
|
||||
|
||||
### Tooltip.contentLabelStyles
|
||||
|
||||
`List<LabelStyle>`
|
||||
|
||||
内容部分的文本样式列表。和列一一对应。
|
||||
内容部分的列文本样式列表。第一个表示第一列的文本样式,以此类推。
|
||||
|
||||
### Tooltip.fixedHeight
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 293 KiB After Width: | Height: | Size: 704 KiB |
|
Before Width: | Height: | Size: 225 KiB After Width: | Height: | Size: 660 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 153 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 86 KiB |
@@ -6,74 +6,64 @@ slug: /support
|
||||
|
||||
# 订阅服务
|
||||
|
||||
如需技术支持和购买扩展图表,可订阅`VIP`服务。详情可查看以下内容,也可以加QQ`3525422251(XCharts技术支持)`或发邮件到`monitor1394@gmail.com`进行咨询。
|
||||
如需技术支持和扩展图表购买,可通过订阅 VIP 服务获取专属权益。企业商务合作请联系 QQ `3525422251` 或邮件至 `monitor1394@gmail.com`。
|
||||
|
||||
企业商务合作可QQ和邮件咨询。
|
||||
## 订阅计划
|
||||
|
||||
## 订阅VIP服务
|
||||
### 订阅类型
|
||||
|
||||
订阅服务分`个人订阅`和`企业订阅`:
|
||||
- **个人订阅**
|
||||
- 归属个人,不可转让,服务仅限订阅者本人使用。
|
||||
- **企业订阅**
|
||||
- 归属企业,席位可分配给指定员工,支持席位变更(如员工离职后重新分配)。
|
||||
- 通过企业专属群组提供技术支持。
|
||||
|
||||
- __个人订阅__:`个人VIP`属于个人,不可转让,`XCharts`团队只服务于订阅当事人。
|
||||
- __企业订阅__:`企业VIP`属于企业,席位内可安排固定职员,职员离职后席位可重新安排,`XCharts`团队通过专属企业群为企业服务。
|
||||
### 订阅优势
|
||||
|
||||
订阅服务有哪些优势?
|
||||
- **高效支持**:快速定位技术问题,节省开发时间。
|
||||
- **深度交流**:与 XCharts 核心团队及开发者社区直接互动,获取行业经验。
|
||||
- **扩展功能**:解锁高级图表和 UI 组件,持续获得更新支持。
|
||||
- **社区共建**:加入 GitHub 组织,访问私有仓库,参与项目生态建设。
|
||||
- **专属标识**:在交流群中享有 VIP 身份标识,优先响应需求。
|
||||
|
||||
- __提高工作效率,节省时间成本__。`XCharts`功能强大,配置项众多,`VIP`服务可快速帮您定位,节省查找和核对的时间;`VIP`的即时回答服务可快速为您答疑解惑,快速上手,提高工作效率。
|
||||
- __更多技术交流,更多经验交流__。`XCharts`团队成员从业多年,有丰富的技术和工作经验。`VIP`服务不仅可以交流`XCharts`相关的内容,也可以咨询其他方面内容。`VIP`群也有更多的交流碰撞。
|
||||
- __订阅扩展图表,获得更新支持__。扩展图表需要订阅`VIP`服务后才能购买,扩展图表超过1年后的更新支持也需要持续订阅`VIP`服务。
|
||||
- __加入团队组织,参与社区建设__。订阅`VIP`后可加入`GitHub`组织,参与社区建设,访问专有仓库,扩展图表仓库等其他私有仓库。
|
||||
- __专属高级功能,专属身份标识__。订阅`VIP`后可以享有扩展UI组件,扩展图表等其他高级功能,XCharts后续也会陆续推出更多高级功能。在`XCharts交流群`里拥有`专属头衔`,方便快速识别,优先响应,第一时间回复VIP用户的各种问题。
|
||||
## 服务详情
|
||||
|
||||
| |免费用户|付费咨询|个人`VIP` | 个人`SVIP` | 企业`VIP` | 企业`SVIP` |
|
||||
| ----- |--|--|--|--|--|--|
|
||||
| 订阅费用 | -- | `98`¥ | `298`¥ | 首年`1298`¥<br/>后续`298¥`* | 首年`1698`¥<br/>后续`298¥`* | `联系我们` |
|
||||
| 订阅时长 | -- | `7`天* | `1`年 | `1`年 | `1`年 | `1`年 |
|
||||
| 拥有席位 | -- | `1`个席位 | `1`个席位 |`1`个席位|`1`个席位|`5`个以上席位|
|
||||
| 增加席位 | -- | -- | -- | -- |支持|支持|
|
||||
| __`服务方式:`__|
|
||||
| 官方QQ群交流 | √ | √ | √ | √ | √ | √ |
|
||||
| QQ一对一交流 | | √ | √ | √ | √ | √ |
|
||||
| 专属VIP群交流 | | | √ | √ | √ | √ |
|
||||
| 微信交流 | | | | | √ | √(企业专属群) |
|
||||
| 电话交流 | | | | | | √ |
|
||||
| __`服务内容:`__|
|
||||
| 可商用可二次开发 | √ | √ | √ | √ | √ | √ |
|
||||
| 有问即答 | | √ | √ | √ | √ | √ |
|
||||
| 新手入门指导 | | √ | √ | √ | √ | √ |
|
||||
| 开发优化指导 | | √ | √ | √ | √ | √ |
|
||||
| 其他技术支持 | | | √ | √ | √ | √ |
|
||||
| 问题及时处理 | | | √ | √ | √ | √ |
|
||||
| 需求优先考虑 | | | √ | √ | √ | √ |
|
||||
| 可另付费定制 | | | √ | √ | √ | √ |
|
||||
| 可另付费加急 | | | √ | √ | √ | √ |
|
||||
| 扩展UI组件 | | | √ | √ | √ | √ |
|
||||
| 首页赞助展示 | | | | | | √ |
|
||||
| 付费方式 | | | 二维码 | 二维码 | __公对公转账__* | __公对公转账__* |
|
||||
| 支持开发票 | | | 普票 | 普票 | __可开专票__ | __可开专票__ |
|
||||
| 扩展图表购买 | | | 按需购买 | __全部免费__* | __全部免费__* | __全部免费__* |
|
||||
| 扩展图表源码 | | | 永久持有 | 永久持有 | 永久持有 | 永久持有 |
|
||||
| 扩展图表更新 | | | 1年更新支持 | 1年更新支持 | 1年更新支持 | 1年更新支持 |
|
||||
| Github仓库 | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)<br/>[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI) | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)<br/>[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)<br/>[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)<br/>[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo) | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)<br/>[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)<br/>[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)<br/>[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo) | XCharts<br/>[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)<br/>[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)<br/>[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)<br/>[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo) |
|
||||
| 权益/服务 | 免费用户 | 个人 VIP | 个人 SVIP | 企业 VIP | 企业 SVIP |
|
||||
|-------------------|----------|----------|-----------------|-----------------|----------------|
|
||||
| **订阅费用** | — | 298¥/年 | 首年 1298¥<br/>续费 298¥/年 | 首年 1698¥<br/>续费 298¥/年 | 定制报价 |
|
||||
| **服务时长** | — | 1 年 | 1 年 | 1 年 | 1 年 |
|
||||
| **服务席位** | — | 1 个 | 1 个 | 1 个 | ≥5 个 |
|
||||
| **增加席位** | — | — | — | 支持(298¥/席位/年) | 支持(定制报价)|
|
||||
| **支持方式** | | | | | |
|
||||
| - Github Issues | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - 官方 QQ 群 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - QQ 一对一支持 | — | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - 专属 VIP 群 | — | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - 微信支持 | — | — | — | ✔️ | ✔️ |
|
||||
| - 电话支持 | — | — | — | — | ✔️ |
|
||||
| - 专属企业群 | — | — | — | — | ✔️ |
|
||||
| **核心权益** | | | | | |
|
||||
| - 商用与二次开发 | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - 即时技术支持 | — | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - 开发优化指导 | — | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - 需求优先处理 | — | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - 付费定制 | — | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - 扩展 UI 组件 | — | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - 扩展图表免费使用 | — | 按需购买 | ✔️(全量) | ✔️(全量) | ✔️(全量) |
|
||||
| **企业专属权益** | | | | | |
|
||||
| - 电子发票 | — | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - 专用发票 | — | — | — | ✔️ | ✔️ |
|
||||
| - 首页赞助展示 | — | — | — | — | ✔️ |
|
||||
| **源码与更新** | | | | | |
|
||||
| - 永久持有源码 | — | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| - 1 年更新支持 | — | ✔️ | ✔️ | ✔️ | ✔️ |
|
||||
| **GitHub 仓库权限**| 公开仓库 | +UI 扩展组件 | +Pro 扩展图表 | +Pro 扩展图表 | +Pro 扩展图表 |
|
||||
|
||||
>备注:
|
||||
>*__`付费定制`__ 用户可根据自己的需求可付费定制不同的图表或新功能,只有`VIP`用户才享有`付费定制`权利。
|
||||
>*__`付费加急`__ 用户可对已在开发计划中或正在开发中的功能进行付费加急,将开发优先级提到最高,并可要求在指定`截止日期`内交付,只有`VIP`用户才享有`付费加急`权利。
|
||||
>*__`付费咨询`__ 付费咨询有效期`7`天,且总咨询时长不超过`7`个小时。
|
||||
>*__`扩展图表`__ 购买后代码可永久持有和商用,1年的更新和技术支持。可继续订阅VIP延长服务时间。
|
||||
>*__`全部免费`__ 是指在订阅期间的`个人SVIP`和`企业VIP`的订阅用户,可免费使用全部的扩展图表。
|
||||
>*__`次年付费`__ 个人SVIP和企业VIP的首年和次年付费不一样,次年付费都是`298¥`。
|
||||
>*__`增加席位`__ 企业VIP支持增加席位,每个席位`298¥`一年。
|
||||
>*__`对公转账`__ 有开专票需求时,可用企业银行帐号进行公对公转账支付。二维码支付不支持开专票,只能开普票。发票默认都是电子发票。
|
||||
>*__`登记资料`__ 订阅成功后,需提供手机号和Github帐号进行登记,手机号用于确认归属,Github帐号用于加入Github的Team组织,下载源码。
|
||||
## 扩展图表
|
||||
|
||||
## 购买扩展图表
|
||||
以下扩展图表需订阅 VIP 后购买(个人SVIP 及企业 VIP 用户可免费使用全量图表):
|
||||
|
||||
扩展图表为另付费购买图表,只对订阅了`VIP`服务的用户开放购买。对于`个人SVIP`和`企业VIP`的订阅用户,所有扩展图表仓库在订阅期间可全部免费使用,不用再单独购买。
|
||||
|
||||
对所有已购买的扩展图表,源码可永久持有但不能传播,并获得持续一年的更新支持和技术服务,一年后如需更新支持等服务,可再继续订阅`VIP`服务。
|
||||
|
||||
|编号|扩展图表|扩展图表|价格|
|
||||
|编号|扩展图表|图表类名|价格|
|
||||
|--|--|--|--|
|
||||
| 101 | [象形柱图](https://xcharts-team.github.io/docs/pictorialbar) |PictorialBarChart | 98¥ |
|
||||
| 102 | [漏斗图](https://xcharts-team.github.io/docs/funnel) |FunnelChart | 98¥ |
|
||||
@@ -88,15 +78,15 @@ slug: /support
|
||||
| 206 | [3D折线图](https://xcharts-team.github.io/docs/line3d) |Line3DChart | 198¥ |
|
||||
| 207 | [关系图](https://xcharts-team.github.io/docs/graph) |GraphChart | 198¥ |
|
||||
|
||||
扩展图表的在线效果图也可以查看[WebGL在线Demo](https://xcharts-team.github.io/examples/)
|
||||
## 附注说明
|
||||
|
||||
## 捐助支持
|
||||
1. **扩展图表更新**:购买后享 1 年免费更新,续订 VIP 可延长服务周期。
|
||||
2. **企业订阅**:支持公对公转账与专用发票,席位可灵活调整。
|
||||
3. **定制服务**:VIP 用户可额外付费定制功能或加急需求开发。
|
||||
|
||||
如果这个项目对您有帮助,请右上方点 `Star` 予以支持!也欢迎扫后面的二维码进行任意金额的捐助,XCharts需要您的支持和帮助。
|
||||
## 支持我们
|
||||
|
||||
## 二维码
|
||||
|
||||
如果看不到二维码图片,可以加Q联系`XCharts技术支持:3525422251`或邮件`monitor1394@gmail.com`咨询。
|
||||
|
||||

|
||||

|
||||
- **社区支持**:欢迎在 GitHub 为 XCharts 点 ⭐️ [Star 支持](https://github.com/XCharts-Team/XCharts)
|
||||
- **扫码捐助**:
|
||||

|
||||

|
||||
|
||||
@@ -26,6 +26,7 @@ namespace XCharts.Editor
|
||||
protected SerializedProperty m_Settings;
|
||||
protected SerializedProperty m_Theme;
|
||||
protected SerializedProperty m_ChartName;
|
||||
protected SerializedProperty m_UseUtc;
|
||||
protected SerializedProperty m_DebugInfo;
|
||||
protected SerializedProperty m_RaycastTarget;
|
||||
|
||||
@@ -49,6 +50,7 @@ namespace XCharts.Editor
|
||||
m_Script = serializedObject.FindProperty("m_Script");
|
||||
m_EnableTextMeshPro = serializedObject.FindProperty("m_EnableTextMeshPro");
|
||||
m_ChartName = serializedObject.FindProperty("m_ChartName");
|
||||
m_UseUtc = serializedObject.FindProperty("m_UseUtc");
|
||||
m_Theme = serializedObject.FindProperty("m_Theme");
|
||||
m_Settings = serializedObject.FindProperty("m_Settings");
|
||||
m_DebugInfo = serializedObject.FindProperty("m_DebugInfo");
|
||||
@@ -124,6 +126,7 @@ namespace XCharts.Editor
|
||||
{
|
||||
EditorGUILayout.PropertyField(m_Script);
|
||||
EditorGUILayout.PropertyField(m_ChartName);
|
||||
EditorGUILayout.PropertyField(m_UseUtc);
|
||||
EditorGUILayout.PropertyField(m_RaycastTarget);
|
||||
if (XChartsMgr.IsRepeatChartName(m_Chart, m_ChartName.stringValue))
|
||||
{
|
||||
@@ -282,7 +285,7 @@ namespace XCharts.Editor
|
||||
}
|
||||
if (GUILayout.Button(Styles.btnSaveAsImage))
|
||||
{
|
||||
m_Chart.SaveAsImage();
|
||||
m_Chart.SaveAsImage("png", "", 4f);
|
||||
}
|
||||
if (m_CheckWarning)
|
||||
{
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace XCharts.Editor
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_Delay");
|
||||
PropertyField(prop, "m_Duration");
|
||||
PropertyField(prop, "m_Speed");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +31,7 @@ namespace XCharts.Editor
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_Duration");
|
||||
PropertyField(prop, "m_Speed");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
@@ -45,6 +47,7 @@ namespace XCharts.Editor
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_Duration");
|
||||
PropertyField(prop, "m_Speed");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
@@ -68,6 +71,21 @@ namespace XCharts.Editor
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(XCharts.Runtime.AnimationExchange), true)]
|
||||
public class AnimationExchangeDrawer : BasePropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
base.OnGUI(pos, prop, label);
|
||||
if (MakeComponentFoldout(prop, "m_Enable", true))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_Duration");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(AnimationStyle), true)]
|
||||
public class AnimationDrawer : BasePropertyDrawer
|
||||
{
|
||||
@@ -85,6 +103,7 @@ namespace XCharts.Editor
|
||||
PropertyField(prop, "m_Change");
|
||||
PropertyField(prop, "m_Addition");
|
||||
PropertyField(prop, "m_Interaction");
|
||||
PropertyField(prop, "m_Exchange");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace XCharts.Editor
|
||||
protected override void DrawExtendeds(SerializedProperty prop)
|
||||
{
|
||||
base.DrawExtendeds(prop);
|
||||
PropertyField(prop, "m_UnableColor");
|
||||
PropertyField(prop, "m_InactiveColor");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace XCharts.Editor
|
||||
PropertyField(prop, "m_MarkColor");
|
||||
PropertyField(prop, "m_BackgroundColor");
|
||||
PropertyField(prop, "m_BackgroundWidth");
|
||||
PropertyField(prop, "m_BackgroundGap");
|
||||
PropertyField(prop, "m_CenterColor");
|
||||
PropertyField(prop, "m_CenterGap");
|
||||
PropertyField(prop, "m_BorderWidth");
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace XCharts.Editor
|
||||
PropertyField(prop, "m_Rotate");
|
||||
PropertyField(prop, "m_Width");
|
||||
PropertyField(prop, "m_Height");
|
||||
PropertyField(prop, "m_FixedX");
|
||||
PropertyField(prop, "m_FixedY");
|
||||
PropertyField(prop, "m_Icon");
|
||||
PropertyField(prop, "m_Background");
|
||||
PropertyField(prop, "m_TextStyle");
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace XCharts.Editor
|
||||
{
|
||||
base.DrawExtendeds(prop);
|
||||
PropertyField(prop, "m_OnZero");
|
||||
PropertyField(prop, "m_StartExtendLength");
|
||||
PropertyField(prop, "m_EndExtendLength");
|
||||
PropertyField(prop, "m_ShowArrow");
|
||||
PropertyField(prop, "m_Arrow");
|
||||
}
|
||||
|
||||
@@ -102,10 +102,24 @@ namespace XCharts.Editor
|
||||
}
|
||||
|
||||
[ComponentEditor(typeof(XAxis))]
|
||||
public class XAxisEditor : AxisEditor { }
|
||||
public class XAxisEditor : AxisEditor
|
||||
{
|
||||
protected override void DrawExtendeds()
|
||||
{
|
||||
base.DrawExtendeds();
|
||||
PropertyField("m_MainAxis");
|
||||
}
|
||||
}
|
||||
|
||||
[ComponentEditor(typeof(YAxis))]
|
||||
public class YAxisEditor : AxisEditor { }
|
||||
public class YAxisEditor : AxisEditor
|
||||
{
|
||||
protected override void DrawExtendeds()
|
||||
{
|
||||
base.DrawExtendeds();
|
||||
PropertyField("m_MainAxis");
|
||||
}
|
||||
}
|
||||
|
||||
[ComponentEditor(typeof(XAxis3D))]
|
||||
public class XAxis3DEditor : AxisEditor { }
|
||||
@@ -164,6 +178,7 @@ namespace XCharts.Editor
|
||||
|
||||
PropertyField(prop, "m_ShowAsPositiveNumber");
|
||||
PropertyField(prop, "m_OnZero");
|
||||
PropertyField(prop, "m_ShowZeroLabel");
|
||||
PropertyField(prop, "m_ShowStartLabel");
|
||||
PropertyField(prop, "m_ShowEndLabel");
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace XCharts.Editor
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField("m_Layer");
|
||||
PropertyField("m_LabelStyle");
|
||||
//PropertyField("m_MarkStyle");
|
||||
PropertyListField("m_Items", true);
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace XCharts.Editor
|
||||
var m_SupportMarquee = baseProperty.FindPropertyRelative("m_SupportMarquee");
|
||||
var m_Start = baseProperty.FindPropertyRelative("m_Start");
|
||||
var m_End = baseProperty.FindPropertyRelative("m_End");
|
||||
var m_MinShowNum = baseProperty.FindPropertyRelative("m_MinShowNum");
|
||||
var m_MinZoomRatio = baseProperty.FindPropertyRelative("m_MinZoomRatio");
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField("m_Orient");
|
||||
PropertyField("m_SupportInside");
|
||||
@@ -31,10 +31,11 @@ namespace XCharts.Editor
|
||||
PropertyField(m_End);
|
||||
PropertyField("m_StartLock");
|
||||
PropertyField("m_EndLock");
|
||||
PropertyField(m_MinShowNum);
|
||||
PropertyField(m_MinZoomRatio);
|
||||
if (m_Start.floatValue < 0) m_Start.floatValue = 0;
|
||||
if (m_End.floatValue > 100) m_End.floatValue = 100;
|
||||
if (m_MinShowNum.intValue < 0) m_MinShowNum.intValue = 0;
|
||||
if (m_MinZoomRatio.floatValue < 0) m_MinZoomRatio.floatValue = 0;
|
||||
if (m_MinZoomRatio.floatValue > 1) m_MinZoomRatio.floatValue = 1;
|
||||
if (m_SupportSlider.boolValue)
|
||||
{
|
||||
PropertyField("m_ShowDataShadow");
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace XCharts.Editor
|
||||
PropertyField("m_ItemGap");
|
||||
PropertyField("m_ItemAutoColor");
|
||||
PropertyField("m_ItemOpacity");
|
||||
PropertyField("m_ItemInactiveOpacity");
|
||||
PropertyField("m_SelectedMode");
|
||||
PropertyField("m_Orient");
|
||||
PropertyField("m_Location");
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace XCharts.Editor
|
||||
PropertyField(prop, "m_Name");
|
||||
switch (type)
|
||||
{
|
||||
case MarkLineType.None:
|
||||
case MarkLineType.Custom:
|
||||
PropertyField(prop, "m_XPosition");
|
||||
PropertyField(prop, "m_YPosition");
|
||||
PropertyField(prop, "m_XValue");
|
||||
@@ -48,7 +48,7 @@ namespace XCharts.Editor
|
||||
break;
|
||||
}
|
||||
PropertyField(prop, "m_Group");
|
||||
if (group > 0 && type == MarkLineType.None) PropertyField(prop, "m_ZeroPosition");
|
||||
if (group > 0 && type == MarkLineType.Custom) PropertyField(prop, "m_ZeroPosition");
|
||||
PropertyField(prop, "m_LineStyle");
|
||||
PropertyField(prop, "m_StartSymbol");
|
||||
PropertyField(prop, "m_EndSymbol");
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace XCharts.Editor
|
||||
});
|
||||
PropertyField("m_LineStyle");
|
||||
PropertyField("m_TitleLabelStyle");
|
||||
PropertyListField("m_ColumnGapWidths");
|
||||
PropertyListField("m_ContentLabelStyles");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace XCharts.Editor
|
||||
}
|
||||
if (GUILayout.Button(Styles.btnSaveAsImage))
|
||||
{
|
||||
m_UIComponent.SaveAsImage();
|
||||
m_UIComponent.SaveAsImage("png", "", 4f);
|
||||
}
|
||||
OnDebugEndInspectorGUI();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,12 @@ namespace XCharts.Editor
|
||||
PropertyField("m_BarWidth");
|
||||
PropertyField("m_BarGap");
|
||||
PropertyField("m_BarMaxWidth");
|
||||
PropertyField("m_IgnoreZeroOccupy");
|
||||
PropertyField("m_RealtimeSort");
|
||||
if(serie.useSortData)
|
||||
{
|
||||
PropertyField("m_DataSortType");
|
||||
}
|
||||
if (serie.IsUseCoord<PolarCoord>())
|
||||
{
|
||||
PropertyField("m_RoundCap");
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace XCharts.Editor
|
||||
public override void OnCustomInspectorGUI()
|
||||
{
|
||||
PropertyField("m_GridIndex");
|
||||
PropertyField("m_PieType");
|
||||
PropertyField("m_RoseType");
|
||||
PropertyField("m_Gap");
|
||||
PropertyTwoFiled("m_Center");
|
||||
|
||||
@@ -18,6 +18,8 @@ namespace XCharts.Editor
|
||||
}
|
||||
PropertyField("m_MaxCache");
|
||||
PropertyField("m_Clip");
|
||||
PropertyField("m_Ignore");
|
||||
PropertyField("m_IgnoreValue");
|
||||
|
||||
PropertyField("m_Symbol");
|
||||
PropertyField("m_ItemStyle");
|
||||
|
||||
@@ -21,9 +21,9 @@ namespace XCharts.Example
|
||||
}
|
||||
}
|
||||
|
||||
float SymbolSize(List<double> data)
|
||||
float SymbolSize(float defaultSize, SerieData serieData)
|
||||
{
|
||||
return (float) (Math.Sqrt(data[2]) / 6e2);
|
||||
return defaultSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
137
README.md
@@ -38,7 +38,7 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
|
||||
|
||||

|
||||
|
||||
一款基于`UGUI`的功能强大的简单易用的`Unity`数据可视化图表插件。支持`折线图`、`柱状图`、`饼图`、`雷达图`、`散点图`、`热力图`、`环形图`、`K线图`、`极坐标`、`平行坐标`等十几种内置图表,以及`3D饼图`、`3D柱图`、`3D金字塔`、`漏斗图`、`仪表盘`、`水位图`、`象形柱图`、`甘特图`、`矩形树图`、`桑基图`、`3D折线图`、`关系图`等十几种扩展图表。
|
||||
XCharts 是一款基于 UGUI 的功能强大、简单易用的 Unity 数据可视化图表插件。它提供了丰富的图表类型和灵活的配置选项,帮助开发者快速实现专业级的数据可视化效果。支持折线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等十多种常用的内置图表。提供3D饼图、3D柱图、3D金字塔、漏斗图、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图、3D折线图、关系图等十多种高级扩展图表。
|
||||
|
||||
[XCharts 官方主页](https://xcharts-team.github.io)
|
||||
[XCharts 在线示例](https://xcharts-team.github.io/examples)
|
||||
@@ -52,25 +52,24 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
|
||||
|
||||
## 特性
|
||||
|
||||
- __纯代码绘制__:图表纯代码绘制,无需额外的贴图和Shader资源。
|
||||
- __可视化配置__:参数可视化配置,效果实时预览,支持运行时代码动态修改配置和数据。
|
||||
- __高自由定制__:支持从主题和配置参数上任意调整;支持代码自定义绘制,自定义回调以及自定义实现图表。
|
||||
- __多内置图表__:支持线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等多种内置图表。
|
||||
- __多扩展图表__:支持3D柱图、3D饼图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图、3D折线图、关系图等多种扩展图表。
|
||||
- __多扩展组件__:支持表格、统计数值等多种扩展UI组件。
|
||||
- __多图表组合__:支持内置图表的任意组合,同一图中可同时显示多个相同或不同类型的图表。
|
||||
- __多种坐标系__:支持直角坐标系、极坐标系、单轴等多种坐标系。
|
||||
- __丰富的组件__:支持标题、图例、提示框、标线、标域、数据区域缩放、视觉映射等常用组件。
|
||||
- __多样式线图__:支持直线图、曲线图、虚线图、面积图、阶梯线图等多种线图。
|
||||
- __多样式柱图__:支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图、胶囊柱图等多种柱状图。
|
||||
- __多样式饼图__:支持环形图、玫瑰图、环形玫瑰图等多种饼图。
|
||||
- __丰富的线条__:支持实线、曲线、阶梯线、虚线、点线、点划线、双点划线等线条。
|
||||
- __自定义绘制__:支持自定义图表内容绘制,提供绘制点、线、面等其他图形的强大的绘图API。
|
||||
- __大数据绘制__:支持万级大数据量绘制;支持采样绘制;特殊的简化图表支持更优的性能。
|
||||
- __自定义主题__:支持主题定制、导入和导出,内置明暗两种默认主题。
|
||||
- __动画和交互__:支持渐入动画、渐出动画、变更动画、新增动画、交互动画等多种动画;支持多平台的数据筛选、视图缩放、细节展示等交互操作。
|
||||
- __第三方扩展__:支持无缝接入`TexMeshPro`和`New Input System`。
|
||||
- __版本和兼容__:支持所有`5.6`以上的`Unity`版本;支持全平台运行。
|
||||
- __纯代码绘制__:图表完全通过代码生成,无需额外贴图或 Shader 资源,轻量高效。
|
||||
- __可视化配置__:提供直观的参数配置界面,支持实时预览效果,并可在运行时动态修改配置和数据。
|
||||
- __高度定制化__:支持从主题、组件到数据项的全面参数设置,同时允许通过代码自定义绘制逻辑、回调函数及图表实现。
|
||||
- __多内置图表__:支持线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等多种常用的内置图表。
|
||||
- __多扩展图表__:支持3D柱图、3D饼图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图、桑基图、3D折线图、关系图等多种高级扩展图表,满足复杂数据可视化需求。
|
||||
- __多扩展组件__:支持多种实用 UI 组件,如表格、统计数值、滑动条、进度条等,增强图表交互性。
|
||||
- __多图表组合__:支持在同一图表中组合显示多个相同或不同类型的图表,满足复杂场景需求。
|
||||
- __多种坐标系__:支持直角坐标系、极坐标系、单轴等多种坐标系,适应不同数据展示需求。
|
||||
- __丰富的组件__:提供标题、图例、提示框、标线、标域、数据区域缩放、视觉映射等常用组件,提升图表可读性。
|
||||
- __多样式线图__:支持直线、曲线、虚线、面积图、阶梯线图等多种线图样式,满足不同数据趋势展示需求。
|
||||
- __多样式柱图__:支持并列柱图、堆叠柱图、堆积百分比柱图、斑马柱图、胶囊柱图等多种柱状图样式。
|
||||
- __多样式饼图__:支持环形图、玫瑰图、环形玫瑰图等多种饼图样式,直观展示数据占比。
|
||||
- __自定义绘制__:提供强大的绘图 API,支持自定义绘制点、线、面等图形,满足个性化需求。
|
||||
- __大数据绘制__:支持万级数据量绘制,优化性能表现;支持采样绘制,进一步提升大数据场景下的性能。
|
||||
- __自定义主题__:支持主题定制、导入和导出,内置明暗两种默认主题,轻松适配不同应用场景。
|
||||
- __动画和交互__:支持渐入、渐出、变更、新增等多种动画效果,以及数据筛选、视图缩放、细节展示等交互操作,提升用户体验。
|
||||
- __第三方扩展__:无缝集成TexMeshPro和New Input System,扩展功能兼容性。
|
||||
- __版本和兼容__:支持 Unity 5.6 及以上版本,兼容全平台运行。
|
||||
|
||||
## 截图
|
||||
|
||||
@@ -78,36 +77,6 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
|
||||
|
||||

|
||||
|
||||
## 仓库
|
||||
|
||||
- __[XCharts](https://github.com/XCharts-Team/XCharts)__ XCharts核心功能,完全免费。
|
||||
- __[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)__ XCharts守护程序,用于确保XCharts更新时的编译正常。非必须,但建议使用。
|
||||
- __[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)__ XCharts官方示例,不包含扩展图表部分。订阅购买扩展图表后可导入示例。
|
||||
- __[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)__ XCharts专业版,包含所有扩展图表和扩展组件。订阅SVIP后可访问使用。
|
||||
- __[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo)__ XCharts专业版官方示例,包含所有扩展图表和扩展组件的示例。订阅SVIP后可访问使用。
|
||||
- __[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)__ XCharts的扩展UI组件。订阅VIP后可访问使用。
|
||||
- __[XCharts-Bar3DChart](https://github.com/XCharts-Team/XCharts-Bar3DChart)__ XCharts扩展图表:3D柱图。订阅购买后可访问使用。
|
||||
- __[XCharts-FunnelChart](https://github.com/XCharts-Team/XCharts-FunnelChart)__ XCharts扩展图表:漏斗图。订阅购买后可访问使用。
|
||||
- __[XCharts-GanttChart](https://github.com/XCharts-Team/XCharts-GanttChart)__ XCharts扩展图表:甘特图。订阅购买后可访问使用。
|
||||
- __[XCharts-GaugeChart](https://github.com/XCharts-Team/XCharts-GaugeChart)__ XCharts扩展图表:仪表盘。订阅购买后可访问使用。
|
||||
- __[XCharts-LiquidChart](https://github.com/XCharts-Team/XCharts-LiquidChart)__ XCharts扩展图表:水位图。订阅购买后可访问使用。
|
||||
- __[XCharts-PictorialBarChart](https://github.com/XCharts-Team/XCharts-PictorialBarChart)__ XCharts扩展图表:象形住图。订阅购买后可访问使用。
|
||||
- __[XCharts-Pie3DChart](https://github.com/XCharts-Team/XCharts-Pie3DChart)__ XCharts扩展图表:3D饼图。订阅购买后可访问使用。
|
||||
- __[XCharts-PyramidChart](https://github.com/XCharts-Team/XCharts-PyramidChart)__ XCharts扩展图表:3D金字塔。订阅购买后可访问使用。
|
||||
- __[XCharts-TreemapChart](https://github.com/XCharts-Team/XCharts-TreemapChart)__ XCharts扩展图表:矩形树图。订阅购买后可访问使用。
|
||||
- __[XCharts-SankeyChart](https://github.com/XCharts-Team/XCharts-SankeyChart)__ XCharts扩展图表:桑基图。订阅购买后可访问使用。
|
||||
- __[XCharts-Line3DChart](https://github.com/XCharts-Team/XCharts-Line3DChart)__ XCharts扩展图表:3D折线图。订阅购买后可访问使用。
|
||||
- __[XCharts-GraphChart](https://github.com/XCharts-Team/XCharts-GraphChart)__ XCharts扩展图表:关系图。订阅购买后可访问使用。
|
||||
|
||||
## 分支
|
||||
|
||||
- __[master](https://github.com/XCharts-Team/XCharts/tree/master)__ XCharts3.0的开发分支。最新的修改和功能都先提交到`master`分支,稳定后再发布`release`版本。
|
||||
- __[3.0](https://github.com/XCharts-Team/XCharts/tree/3.0)__ XCharts3.0的稳定分支。一般一个月一发布,`master`分支稳定后,`merge`到`3.0`分支,并发布`release`版本。
|
||||
- __[2.0](https://github.com/XCharts-Team/XCharts/tree/2.0)__ XCharts2.0的稳定分支。带Demo,目前基本不再维护,仅修改严重bug。
|
||||
- __[2.0-upm](https://github.com/XCharts-Team/XCharts/tree/2.0-upm)__ XCharts2.0的稳定UMP分支。不带Demo,只包含Package部分,不再维护。
|
||||
- __[1.0](https://github.com/XCharts-Team/XCharts/tree/1.0)__ XCharts1.0的稳定分支。带Demo,不再维护。
|
||||
- __[1.0-upm](https://github.com/XCharts-Team/XCharts/tree/1.0-upm)__ XCharts1.0的稳定UMP分支。不带Demo,不再维护。
|
||||
|
||||
## 使用
|
||||
|
||||
- 导入`XCharts`的`unitypackage`或者源码到项目。建议也导入`XCharts`守护程序 [XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)。
|
||||
@@ -117,47 +86,67 @@ A powerful, easy-to-use, configurable charting and data visualization library fo
|
||||
- 更多细节,请看[【XCharts教程:5分钟上手教程】](Documentation~/zh/tutorial01.md)。
|
||||
- 首次使用,建议先认真看一遍教程。
|
||||
|
||||
## 注意
|
||||
## 常见问题 (FAQ)
|
||||
|
||||
- __XCharts3.0不完全兼容XCharts2.0版本。__ 升级`3.0`时,部分代码和配置可能需要重新调整。建议旧项目可以继续使用`XCharts2.0`,新项目推荐使用`XCharts3.0`。
|
||||
- __XCharts2.0只维护不加新功能。__ `2.0`只修复严重`bug`,原则上不再加新功能。
|
||||
- __XCharts支持Unity 5.6及以上版本。__ 但由于版本测试有限难免疏漏,发现问题可提`Issue`。
|
||||
- __本仓库只包含XCharts源码,不包含Demo示例部分。__ 需要查看`Demo`示例源码请到[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)仓库。也可以在浏览器查看运行效果 [在线Demo](https://xcharts-team.github.io/examples/) 。
|
||||
- __XCharts 可以免费使用吗?__
|
||||
XCharts 基于 MIT 协议,核心功能完全免费。您也可以订阅 VIP 服务,享受更多高级功能和专属技术支持。
|
||||
|
||||
## FAQ
|
||||
- __XCharts 支持代码动态添加和修改数据吗?__
|
||||
是的,XCharts 提供了丰富的数据操作接口,支持代码动态修改配置和数据。但数据来源(如 Excel 或数据库)需要您自行解析后调用 XCharts 接口添加到图表中。
|
||||
|
||||
- __XCharts可以免费使用吗?__
|
||||
`XCharts`使用`MIT`协议,可以免费使用。也可以订阅`VIP`享受更多增值服务。
|
||||
- __XCharts 支持哪些平台?__
|
||||
XCharts 专为 Unity 平台设计,支持 Unity 5.6 及以上版本。理论上,任何支持 UGUI 的 Unity 版本均可运行 XCharts。目前不支持 Winform 或 WPF 等其他平台。
|
||||
|
||||
- __XCharts支持代码动态添加和修改数据吗?支持从`Excel`或数据库中获取数据吗?__
|
||||
`XCharts`提供了各种数据操作的接口,支持代码动态修改配置,添加和修改数据,但数据来源需要自己解析和获取,再调用`XCharts`的接口添加到图表。
|
||||
- __如何解决锯齿问题?XCharts 支持多大的数据量?__
|
||||
XCharts 基于 UGUI 实现,因此 UGUI 的常见问题(如锯齿、Mesh 顶点数限制)在 XCharts 中也会存在。
|
||||
- __锯齿问题__:可通过调整抗锯齿设置或使用更高分辨率解决。
|
||||
- __数据量限制__:单条折线图(Line)支持约 2 万数据点,开启采样后可支持更多数据,但会消耗更多 CPU 资源。
|
||||
更多解决方案请参考 [问答 16](Documentation~/zh/faq.md) 和 [问答 27](Documentation~/zh/faq.md)。
|
||||
|
||||
- __XCharts除了用在Unity平台,还能用在Winform或WPF等平台吗?__
|
||||
`XCharts`只支持在`Unity`平台使用。理论上任何支持`UGUI`的`Unity`版本都能运行`XCharts`。
|
||||
|
||||
- __锯齿怎么解决?支持多大量级的数据?__
|
||||
`XCharts`是基于`UGUI`实现的,所以`UGUI`中碰到的问题,在`XCharts`中也会存在。比如锯齿问题,比如`Mesh`顶点数超`65535`的问题。这两个问题的解决可参考[问答16](Documentation~/zh/faq.md)和[问答27](Documentation~/zh/faq.md)。
|
||||
由于`Mesh`的`65535`顶点数的限制,目前`XCharts`的单条`Line`支持约`2万`的数据量,当然开启采样可以支持更多数据的绘制,但同时也会更消耗CPU。
|
||||
- __哪里可以查看 Demo?__
|
||||
本仓库仅包含 XCharts 源码,Demo 示例请访问 [XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo) 仓库。您也可以在浏览器中查看 [在线 Demo](https://xcharts-team.github.io/examples/)。
|
||||
|
||||
## 日志
|
||||
|
||||
- 各版本的详细更新日志请查看 [更新日志](Documentation~/zh/changelog.md)
|
||||
|
||||
## Licenses
|
||||
## 扩展
|
||||
|
||||
- [MIT License](https://github.com/XCharts-Team/XCharts/blob/master/LICENSE.md)
|
||||
- 可免费商用,可二次开发。
|
||||
- 扩展图表和高级功能部分需购买使用授权。
|
||||
- __[XCharts](https://github.com/XCharts-Team/XCharts)__ 核心功能,完全开源免费
|
||||
- __[XCharts-Daemon](https://github.com/XCharts-Team/XCharts-Daemon)__ 守护程序,确保XCharts更新时的编译正常
|
||||
- __[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)__ 官方示例(不包含扩展图表的示例)
|
||||
- __[XCharts-Pro](https://github.com/XCharts-Team/XCharts-Pro)__ 专业版,包含所有扩展图表和扩展组件(需订阅 SVIP)
|
||||
- __[XCharts-Pro-Demo](https://github.com/XCharts-Team/XCharts-Pro-Demo)__ 专业版官方示例(需订阅 SVIP)
|
||||
- __[XCharts-UI](https://github.com/XCharts-Team/XCharts-UI)__ 扩展UI组件(需订阅 VIP)
|
||||
- __[XCharts-Bar3DChart](https://github.com/XCharts-Team/XCharts-Bar3DChart)__ 3D柱图(需订阅 VIP)
|
||||
- __[XCharts-FunnelChart](https://github.com/XCharts-Team/XCharts-FunnelChart)__ 漏斗图(需订阅 VIP)
|
||||
- __[XCharts-GanttChart](https://github.com/XCharts-Team/XCharts-GanttChart)__ 甘特图(需订阅 VIP)
|
||||
- __[XCharts-GaugeChart](https://github.com/XCharts-Team/XCharts-GaugeChart)__ 仪表盘(需订阅 VIP)
|
||||
- __[XCharts-LiquidChart](https://github.com/XCharts-Team/XCharts-LiquidChart)__ 水位图(需订阅 VIP)
|
||||
- __[XCharts-PictorialBarChart](https://github.com/XCharts-Team/XCharts-PictorialBarChart)__ 象形住图(需订阅 VIP)
|
||||
- __[XCharts-Pie3DChart](https://github.com/XCharts-Team/XCharts-Pie3DChart)__ 3D饼图(需订阅 VIP)
|
||||
- __[XCharts-PyramidChart](https://github.com/XCharts-Team/XCharts-PyramidChart)__ 3D金字塔(需订阅 VIP)
|
||||
- __[XCharts-TreemapChart](https://github.com/XCharts-Team/XCharts-TreemapChart)__ 矩形树图(需订阅 VIP)
|
||||
- __[XCharts-SankeyChart](https://github.com/XCharts-Team/XCharts-SankeyChart)__ 桑基图(需订阅 VIP)
|
||||
- __[XCharts-Line3DChart](https://github.com/XCharts-Team/XCharts-Line3DChart)__ 3D折线图(需订阅 VIP)
|
||||
- __[XCharts-GraphChart](https://github.com/XCharts-Team/XCharts-GraphChart)__ 关系图(需订阅 VIP)
|
||||
|
||||
## 许可
|
||||
|
||||
- __[MIT License](https://github.com/XCharts-Team/XCharts/blob/master/LICENSE.md)__:XCharts 核心库基于 MIT 协议,允许免费商用和二次开发。
|
||||
|
||||
- __扩展功能授权__:扩展图表和高级功能需订阅 VIP 或 SVIP 服务获得使用许可。
|
||||
|
||||
## 订阅
|
||||
|
||||
- `XCharts`核心库是开源的,可免费使用的。在此基础上,我们也提供多种订阅服务以满足不同用户的需求,订阅详情[☞ 请看这里](Documentation~/zh/support.md)。
|
||||
- 订阅不是必须的,不影响`XCharts`的核心功能使用。
|
||||
- 订阅是按年付费,订阅到期后,不要求必须续订,但中断订阅期间无法享受技术更新和支持等服务。
|
||||
- __核心功能免费__:XCharts 核心库基于 MIT 协议完全开源,可免费使用。
|
||||
- __增值服务__:为满足多样化需求,我们提供多种订阅服务,详情请查看 [订阅详情](Documentation~/zh/support.md)。
|
||||
- __灵活选择__:订阅非强制,不影响核心功能使用。
|
||||
- __按年付费__:订阅服务按年计费,到期后可选择续订。中断订阅后,将无法享受更新和技术支持服务。
|
||||
|
||||
## 其他
|
||||
|
||||
- 邮箱:`monitor1394@gmail.com`
|
||||
- QQ群:XCharts交流群(`202030963`)
|
||||
- VIP群:XCharts VIP群(`867291970`)
|
||||
- 捐助、合作、订阅和技术支持:[☞ 请看这里](Documentation~/zh/support.md)
|
||||
- 支持与合作:[订阅与支持](Documentation~/zh/support.md)
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField][Since("v3.8.0")] private bool m_Reverse = false;
|
||||
[SerializeField][Since("v3.8.0")] private float m_Delay = 0;
|
||||
[SerializeField][Since("v3.8.0")] private float m_Duration = 1000;
|
||||
[SerializeField][Since("v3.14.0")] private float m_Speed = 0;
|
||||
public AnimationInfoContext context = new AnimationInfoContext();
|
||||
|
||||
/// <summary>
|
||||
@@ -34,11 +35,15 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public float delay { get { return m_Delay; } set { m_Delay = value; } }
|
||||
/// <summary>
|
||||
/// the duration of animation.
|
||||
/// ||动画的时长。
|
||||
/// the duration of animation. Default is used to calculate the speed of animation. It can also be specified by speed.
|
||||
/// ||动画的时长。默认用于计算动画的速度。也可以通过speed指定速度。
|
||||
/// </summary>
|
||||
public float duration { get { return m_Duration; } set { m_Duration = value; } }
|
||||
|
||||
/// <summary>
|
||||
/// the speed of animation. When speed is specified, duration will be invalid. Default is 0, which means no speed specified.
|
||||
/// ||动画的速度。当指定speed时,duration将失效。默认为0,表示不指定速度。
|
||||
/// </summary>
|
||||
public float speed { get { return m_Speed; } set { m_Speed = value; } }
|
||||
/// <summary>
|
||||
/// the callback function of animation start.
|
||||
/// ||动画开始的回调。
|
||||
@@ -147,6 +152,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (!enable) return;
|
||||
if (!context.start || context.end) return;
|
||||
context.init = false;
|
||||
context.start = false;
|
||||
context.end = true;
|
||||
context.currPointIndex = context.destPointIndex;
|
||||
@@ -168,20 +174,19 @@ namespace XCharts.Runtime
|
||||
public bool Init(float curr, float dest, int totalPointIndex)
|
||||
{
|
||||
if (!enable || !context.start) return false;
|
||||
if (context.init || context.end) return false;
|
||||
context.init = true;
|
||||
context.totalProgress = dest - curr;
|
||||
context.destPointIndex = totalPointIndex;
|
||||
if (reverse)
|
||||
{
|
||||
context.currProgress = dest;
|
||||
if (!context.init) context.currProgress = dest;
|
||||
context.destProgress = curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.currProgress = curr;
|
||||
if (!context.init) context.currProgress = curr;
|
||||
context.destProgress = dest;
|
||||
}
|
||||
context.init = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -208,7 +213,7 @@ namespace XCharts.Runtime
|
||||
if (!context.start)
|
||||
return false;
|
||||
else
|
||||
return (m_Delay > 0 && Time.time - context.startTime < m_Delay / 1000);
|
||||
return m_Delay > 0 && Time.time - context.startTime < m_Delay / 1000;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -285,8 +290,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (!context.start || !context.init || context.pause) return;
|
||||
if (IsInDelay()) return;
|
||||
var duration = GetCurrAnimationDuration();
|
||||
var delta = (float)(total / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
|
||||
var delta = GetDelta(total, m_UnscaledTime);
|
||||
if (reverse)
|
||||
{
|
||||
context.currProgress -= delta;
|
||||
@@ -330,8 +334,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
var duration = GetCurrAnimationDuration(dataIndex);
|
||||
var delta = (destProgress - startProgress) / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
|
||||
var delta = GetDelta(destProgress - startProgress, m_UnscaledTime);
|
||||
currHig += delta;
|
||||
if (reverse)
|
||||
{
|
||||
@@ -362,8 +365,7 @@ namespace XCharts.Runtime
|
||||
if (IsInDelay())
|
||||
return;
|
||||
|
||||
var duration = GetCurrAnimationDuration();
|
||||
var delta = dest / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
|
||||
var delta = GetDelta(dest, m_UnscaledTime);
|
||||
if (reverse)
|
||||
{
|
||||
context.sizeProgress -= delta;
|
||||
@@ -377,6 +379,20 @@ namespace XCharts.Runtime
|
||||
context.sizeProgress = dest;
|
||||
}
|
||||
}
|
||||
|
||||
private float GetDelta(double total, bool unscaledTime)
|
||||
{
|
||||
if (m_Speed > 0)
|
||||
{
|
||||
context.currDuration = (float)total / m_Speed;
|
||||
return (float)(m_Speed * (unscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
|
||||
}
|
||||
else
|
||||
{
|
||||
context.currDuration = 0;
|
||||
return (float)(total / GetCurrAnimationDuration() * (unscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -477,4 +493,14 @@ namespace XCharts.Runtime
|
||||
return m_Offset.value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data exchange animation. Generally used for animation of data sorting.
|
||||
/// ||数据交换动画。一般用于图表数据排序时顺序变化的动画。
|
||||
/// </summary>
|
||||
[Since("v3.15.0")]
|
||||
[System.Serializable]
|
||||
public class AnimationExchange : AnimationInfo
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ namespace XCharts.Runtime
|
||||
public float sizeProgress;
|
||||
public int currPointIndex;
|
||||
public int destPointIndex;
|
||||
public float currDuration;
|
||||
public Vector3 currPoint;
|
||||
public Vector3 destPoint;
|
||||
public Dictionary<int, float> dataCurrProgress = new Dictionary<int, float>();
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the animation of serie. support animation type: fadeIn, fadeOut, change, addition.
|
||||
/// ||动画组件,用于控制图表的动画播放。支持配置五种动画表现:FadeIn(渐入动画),FadeOut(渐出动画),Change(变更动画),Addition(新增动画),Interaction(交互动画)。
|
||||
/// the animation of serie. support animation type: fadeIn, fadeOut, change, addition, exchange.
|
||||
/// ||动画组件,用于控制图表的动画播放。支持配置五种动画表现:FadeIn(渐入动画),FadeOut(渐出动画),Change(变更动画),Addition(新增动画),Interaction(交互动画),Exchange(交换动画)。
|
||||
/// 按作用的对象可以分为两类:SerieAnimation(系列动画)和DataAnimation(数据动画)。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
@@ -62,6 +62,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField][Since("v3.8.0")] private AnimationAddition m_Addition = new AnimationAddition() { duration = 500 };
|
||||
[SerializeField][Since("v3.8.0")] private AnimationHiding m_Hiding = new AnimationHiding() { duration = 500 };
|
||||
[SerializeField][Since("v3.8.0")] private AnimationInteraction m_Interaction = new AnimationInteraction() { duration = 250 };
|
||||
[SerializeField][Since("v3.15.0")] private AnimationExchange m_Exchange = new AnimationExchange() { duration = 250 };
|
||||
|
||||
[Obsolete("Use animation.fadeIn.delayFunction instead.", true)]
|
||||
public AnimationDelayFunction fadeInDelayFunction;
|
||||
@@ -138,6 +139,11 @@ namespace XCharts.Runtime
|
||||
/// ||交互动画配置。
|
||||
/// </summary>
|
||||
public AnimationInteraction interaction { get { return m_Interaction; } }
|
||||
/// <summary>
|
||||
/// Exchange animation configuration. Valid in sort bar chart.
|
||||
/// ||交换动画配置。如在排序柱图中有效。
|
||||
/// </summary>
|
||||
public AnimationExchange exchange { get { return m_Exchange; } }
|
||||
|
||||
private Vector3 m_LinePathLastPos;
|
||||
private List<AnimationInfo> m_Animations;
|
||||
@@ -147,12 +153,15 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (m_Animations == null)
|
||||
{
|
||||
m_Animations = new List<AnimationInfo>();
|
||||
m_Animations.Add(m_FadeIn);
|
||||
m_Animations.Add(m_FadeOut);
|
||||
m_Animations.Add(m_Change);
|
||||
m_Animations.Add(m_Addition);
|
||||
m_Animations.Add(m_Hiding);
|
||||
m_Animations = new List<AnimationInfo>
|
||||
{
|
||||
m_FadeIn,
|
||||
m_FadeOut,
|
||||
m_Change,
|
||||
m_Addition,
|
||||
m_Hiding,
|
||||
m_Exchange
|
||||
};
|
||||
}
|
||||
return m_Animations;
|
||||
}
|
||||
@@ -306,7 +315,7 @@ namespace XCharts.Runtime
|
||||
startIndex = anim.context.currPointIndex == paths.Count - 1 ?
|
||||
paths.Count - 2 :
|
||||
anim.context.currPointIndex;
|
||||
if (startIndex < 0 || startIndex > paths.Count - 2) startIndex = 0;
|
||||
if (startIndex < 0 || startIndex >= paths.Count - 1) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -336,9 +345,12 @@ namespace XCharts.Runtime
|
||||
{
|
||||
return;
|
||||
}
|
||||
anim.context.currPoint = sp;
|
||||
anim.context.destPoint = ep;
|
||||
anim.Init(currDetailProgress, totalDetailProgress, paths.Count - 1);
|
||||
|
||||
if (anim.Init(currDetailProgress, totalDetailProgress, paths.Count - 1))
|
||||
{
|
||||
anim.context.currPoint = sp;
|
||||
anim.context.destPoint = ep;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEnd()
|
||||
@@ -362,12 +374,23 @@ namespace XCharts.Runtime
|
||||
return true;
|
||||
var animation = activedAnimation;
|
||||
if (animation != null && animation.context.end)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (IsSerieAnimation())
|
||||
{
|
||||
if (m_FadeOut.context.start) return m_FadeOut.context.currProgress <= m_FadeOut.context.destProgress;
|
||||
else if (m_Addition.context.start) return m_Addition.context.currProgress >= m_Addition.context.destProgress;
|
||||
else return m_FadeIn.context.currProgress >= m_FadeIn.context.destProgress;
|
||||
if (m_FadeOut.context.start)
|
||||
{
|
||||
return m_FadeOut.context.currProgress <= m_FadeOut.context.destProgress;
|
||||
}
|
||||
else if (m_Addition.context.start)
|
||||
{
|
||||
return m_Addition.context.currProgress >= m_Addition.context.destProgress;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_FadeIn.context.currProgress >= m_FadeIn.context.destProgress;
|
||||
}
|
||||
}
|
||||
else if (IsDataAnimation())
|
||||
{
|
||||
@@ -546,7 +569,15 @@ namespace XCharts.Runtime
|
||||
public float GetChangeDuration()
|
||||
{
|
||||
if (m_Enable && m_Change.enable)
|
||||
return m_Change.duration;
|
||||
return m_Change.context.currDuration > 0 ? m_Change.context.currDuration : m_Change.duration;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float GetExchangeDuration()
|
||||
{
|
||||
if (m_Enable && m_Exchange.enable)
|
||||
return m_Exchange.context.currDuration > 0 ? m_Exchange.context.currDuration : m_Exchange.duration;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -554,7 +585,7 @@ namespace XCharts.Runtime
|
||||
public float GetAdditionDuration()
|
||||
{
|
||||
if (m_Enable && m_Addition.enable)
|
||||
return m_Addition.duration;
|
||||
return m_Addition.context.currDuration > 0 ? m_Addition.context.currDuration : m_Addition.duration;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -562,7 +593,7 @@ namespace XCharts.Runtime
|
||||
public float GetInteractionDuration()
|
||||
{
|
||||
if (m_Enable && m_Interaction.enable)
|
||||
return m_Interaction.duration;
|
||||
return m_Interaction.context.currDuration > 0 ? m_Interaction.context.currDuration : m_Interaction.duration;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace XCharts.Runtime
|
||||
if (axis.context.labelObjectList.Count <= 0)
|
||||
InitAngleAxis(axis);
|
||||
else
|
||||
axis.UpdateLabelText(runtimeWidth, null, false);
|
||||
UpdateLabelText(axis, runtimeWidth, null, false);
|
||||
}
|
||||
|
||||
private void InitAngleAxis(AngleAxis axis)
|
||||
@@ -85,7 +85,7 @@ namespace XCharts.Runtime
|
||||
float scaleAngle = AxisHelper.GetScaleWidth(axis, total, i + 1, null);
|
||||
bool inside = axis.axisLabel.inside;
|
||||
var labelName = AxisHelper.GetLabelName(axis, total, i, axis.context.minValue, axis.context.maxValue,
|
||||
null, isPercentStack);
|
||||
null, isPercentStack, chart.useUtc);
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
|
||||
new Vector2(scaleAngle, txtHig), axis,
|
||||
chart.theme.axis, labelName, Color.clear);
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private bool m_Clockwise = true;
|
||||
[SerializeField] private bool m_InsertDataToHead;
|
||||
[SerializeField][Since("v3.11.0")] private float m_MinCategorySpacing = 0;
|
||||
[SerializeField][Since("v3.15.0")] private bool m_MainAxis = false;
|
||||
[SerializeField] protected List<Sprite> m_Icons = new List<Sprite>();
|
||||
[SerializeField] protected List<string> m_Data = new List<string>();
|
||||
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
||||
@@ -115,6 +116,13 @@ namespace XCharts.Runtime
|
||||
|
||||
public AxisContext context = new AxisContext();
|
||||
|
||||
private Action<int, string> m_OnLabelClick;
|
||||
/// <summary>
|
||||
/// Callback function when click on the label. Parameters: labelIndex, labelName.
|
||||
/// ||点击文本标签回调函数。参数:labelIndex, labelName。
|
||||
/// </summary>
|
||||
[Since("v3.15.0")]
|
||||
public Action<int, string> onLabelClick { internal get { return m_OnLabelClick; } set { m_OnLabelClick = value; } }
|
||||
/// <summary>
|
||||
/// Whether to show axis.
|
||||
/// ||是否显示坐标轴。
|
||||
@@ -292,6 +300,17 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_Clockwise, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether it is the main axis. When both X and Y axes are of the same type, the axis set to main axis will determine the orientation,
|
||||
/// such as horizontal bar chart and vertical bar chart.
|
||||
/// ||是否为主轴。当XY轴类型都相同时,设置为主轴的轴会决定朝向,如横向柱图和纵向柱图。
|
||||
/// </summary>
|
||||
[Since("v3.15.0")]
|
||||
public bool mainAxis
|
||||
{
|
||||
get { return m_MainAxis; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MainAxis, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Category data, available in type: 'Category' axis.
|
||||
/// ||类目数据,在类目轴(type: 'category')中有效。
|
||||
/// </summary>
|
||||
@@ -478,6 +497,7 @@ namespace XCharts.Runtime
|
||||
context.maxValue = 0;
|
||||
context.destMinValue = 0;
|
||||
context.destMaxValue = 0;
|
||||
context.labelValueList.Clear();
|
||||
}
|
||||
|
||||
public Axis Clone()
|
||||
@@ -609,13 +629,13 @@ namespace XCharts.Runtime
|
||||
return m_Position == AxisPosition.Bottom;
|
||||
}
|
||||
|
||||
public bool IsNeedShowLabel(int index, int total = 0)
|
||||
public bool IsNeedShowLabel(int index, int total = 0, string content = null)
|
||||
{
|
||||
if (total == 0)
|
||||
{
|
||||
total = context.labelValueList.Count;
|
||||
}
|
||||
return axisLabel.IsNeedShowLabel(index, total);
|
||||
return axisLabel.IsNeedShowLabel(index, total, content);
|
||||
}
|
||||
|
||||
public void SetNeedUpdateFilterData()
|
||||
@@ -836,22 +856,6 @@ namespace XCharts.Runtime
|
||||
return IsCategory() ? GetDataList(dataZoom).Count : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新刻度标签文字
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
internal void UpdateLabelText(float coordinateWidth, DataZoom dataZoom, bool forcePercent)
|
||||
{
|
||||
for (int i = 0; i < context.labelObjectList.Count; i++)
|
||||
{
|
||||
if (context.labelObjectList[i] != null)
|
||||
{
|
||||
var text = AxisHelper.GetLabelName(this, coordinateWidth, i, context.destMinValue, context.destMaxValue, dataZoom, forcePercent);
|
||||
context.labelObjectList[i].SetText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal Vector3 GetLabelObjectPosition(int index)
|
||||
{
|
||||
if (context.labelObjectList != null && index < context.labelObjectList.Count)
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace XCharts.Runtime
|
||||
public List<string> runtimeData { get { return m_RuntimeData; } }
|
||||
public List<double> labelValueList { get { return m_LabelValueList; } }
|
||||
public List<ChartLabel> labelObjectList { get { return m_AxisLabelList; } }
|
||||
public List<int> sortedDataIndices { get { return m_SortedDataIndices; } }
|
||||
public int dataZoomStartIndex;
|
||||
/// <summary>
|
||||
/// 添加过的历史数据总数
|
||||
@@ -86,6 +87,7 @@ namespace XCharts.Runtime
|
||||
private List<ChartLabel> m_AxisLabelList = new List<ChartLabel>();
|
||||
private List<double> m_LabelValueList = new List<double>();
|
||||
private List<string> m_RuntimeData = new List<string>();
|
||||
private List<int> m_SortedDataIndices = new List<int>();
|
||||
|
||||
internal void Clear()
|
||||
{
|
||||
@@ -118,24 +120,25 @@ namespace XCharts.Runtime
|
||||
if (end > data.Count) end = data.Count;
|
||||
}
|
||||
|
||||
var minZoomRatio = (int)(data.Count * dataZoom.minZoomRatio);
|
||||
if (start != filterStart ||
|
||||
end != filterEnd ||
|
||||
dataZoom.minShowNum != filterMinShow ||
|
||||
minZoomRatio != filterMinShow ||
|
||||
isNeedUpdateFilterData)
|
||||
{
|
||||
filterStart = start;
|
||||
filterEnd = end;
|
||||
filterMinShow = dataZoom.minShowNum;
|
||||
filterMinShow = minZoomRatio;
|
||||
isNeedUpdateFilterData = false;
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
if (range < dataZoom.minShowNum)
|
||||
if (range < minZoomRatio)
|
||||
{
|
||||
if (dataZoom.minShowNum > data.Count)
|
||||
if (dataZoom.minZoomRatio > data.Count)
|
||||
range = data.Count;
|
||||
else
|
||||
range = dataZoom.minShowNum;
|
||||
range = minZoomRatio;
|
||||
}
|
||||
if (range > data.Count - start)
|
||||
start = data.Count - range;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using XCharts.Runtime;
|
||||
using XUGL;
|
||||
@@ -31,6 +33,33 @@ namespace XCharts
|
||||
|
||||
protected virtual Orient orient { get; set; }
|
||||
|
||||
public override void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (component.onLabelClick == null) return;
|
||||
var labelObjects = component.context.labelObjectList;
|
||||
for (int i = 0; i < labelObjects.Count; i++)
|
||||
{
|
||||
var label = labelObjects[i];
|
||||
if (label == null) continue;
|
||||
if (label.InRect(chart.pointerPos))
|
||||
{
|
||||
component.onLabelClick.Invoke(i, label.text.GetText());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public override void DrawTop(VertexHelper vh)
|
||||
// {
|
||||
// var color = Color.red;
|
||||
// color.a = 0.5f;
|
||||
// foreach (var label in component.context.labelObjectList)
|
||||
// {
|
||||
// if (label == null) continue;
|
||||
// UGL.DrawRectangle(vh, label.rect, color);
|
||||
// }
|
||||
// }
|
||||
|
||||
protected virtual void UpdatePointerValue(Axis axis)
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
|
||||
@@ -149,6 +178,10 @@ namespace XCharts
|
||||
axis.context.minValue = 0;
|
||||
axis.context.maxValue = axis.data.Count > 0 ? axis.data.Count - 1 : SeriesHelper.GetMaxSerieDataCount(chart.series) - 1;
|
||||
axis.context.minMaxRange = axis.context.maxValue;
|
||||
if (chart.HasRealtimeSortSerie(axis.gridIndex))
|
||||
{
|
||||
UpdateAxisLabelText(axis);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -236,7 +269,93 @@ namespace XCharts
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
|
||||
var dataZoom = chart.GetDataZoomOfAxis(axis);
|
||||
|
||||
axis.UpdateLabelText(runtimeWidth, dataZoom, isPercentStack);
|
||||
UpdateLabelText(axis, runtimeWidth, dataZoom, isPercentStack);
|
||||
}
|
||||
|
||||
internal void UpdateLabelText(Axis axis, float coordinateWidth, DataZoom dataZoom, bool forcePercent)
|
||||
{
|
||||
var context = axis.context;
|
||||
var destMaxValue = context.destMaxValue;
|
||||
var destMinValue = context.destMinValue;
|
||||
var isCategory = axis.IsCategory();
|
||||
var serie = chart.GetSerie(0);
|
||||
if (isCategory && serie != null && serie.useSortData)
|
||||
{
|
||||
var isY = axis is YAxis;
|
||||
var showData = serie.GetDataList(dataZoom, true);
|
||||
if (CheckSortedDataChanged(axis, showData))
|
||||
{
|
||||
for (int i = 0; i < context.labelObjectList.Count; i++)
|
||||
{
|
||||
if (context.labelObjectList[i] != null)
|
||||
{
|
||||
var index = i < showData.Count ? showData[i].index : i;
|
||||
var text = AxisHelper.GetLabelName(axis, coordinateWidth, index, destMinValue, destMaxValue, dataZoom, forcePercent, chart.useUtc, i);
|
||||
context.labelObjectList[i].SetText(text);
|
||||
}
|
||||
}
|
||||
SaveSortedDataIndex(axis, showData);
|
||||
}
|
||||
if (CheckSortedDataAnimation(axis, showData))
|
||||
{
|
||||
float diff = axis.context.scaleWidth / 2;
|
||||
for (int i = 0; i < context.labelObjectList.Count; i++)
|
||||
{
|
||||
var labelObject = context.labelObjectList[i];
|
||||
if (labelObject != null)
|
||||
{
|
||||
if (i < showData.Count)
|
||||
{
|
||||
var serieData = showData[i];
|
||||
var pos = serieData.context.exchangePosition;
|
||||
if (ChartHelper.IsZeroVector(pos)) continue;
|
||||
var sourPos = labelObject.GetPosition();
|
||||
labelObject.SetPosition(isY ? new Vector3(sourPos.x, pos.y + diff) : new Vector3(pos.x + diff, sourPos.y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < context.labelObjectList.Count; i++)
|
||||
{
|
||||
if (context.labelObjectList[i] != null)
|
||||
{
|
||||
var text = AxisHelper.GetLabelName(axis, coordinateWidth, i, destMinValue, destMaxValue, dataZoom, forcePercent, chart.useUtc);
|
||||
context.labelObjectList[i].SetText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckSortedDataChanged(Axis axis, List<SerieData> dataList)
|
||||
{
|
||||
if (dataList.Count != axis.context.sortedDataIndices.Count) return true;
|
||||
for (int i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
if (dataList[i].index != axis.context.sortedDataIndices[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool CheckSortedDataAnimation(Axis axis, List<SerieData> dataList)
|
||||
{
|
||||
if (!axis.IsCategory()) return false;
|
||||
foreach (var data in dataList)
|
||||
{
|
||||
if (!data.context.exchangeEnd) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void SaveSortedDataIndex(Axis axis, List<SerieData> dataList)
|
||||
{
|
||||
axis.context.sortedDataIndices.Clear();
|
||||
for (int i = 0; i < dataList.Count; i++)
|
||||
{
|
||||
axis.context.sortedDataIndices.Add(dataList[i].index);
|
||||
}
|
||||
}
|
||||
|
||||
internal void UpdateAxisTickValueList(Axis axis)
|
||||
@@ -245,7 +364,7 @@ namespace XCharts
|
||||
{
|
||||
var lastCount = axis.context.labelValueList.Count;
|
||||
axis.context.tickValue = DateTimeUtil.UpdateTimeAxisDateTimeList(axis.context.labelValueList,
|
||||
(int)axis.context.minValue, (int)axis.context.maxValue, axis.splitNumber);
|
||||
axis.context.minValue, axis.context.maxValue, axis.splitNumber, axis.ceilRate, !chart.useUtc);
|
||||
|
||||
if (axis.context.labelValueList.Count != lastCount)
|
||||
axis.SetAllDirty();
|
||||
@@ -328,13 +447,17 @@ namespace XCharts
|
||||
return Math.Pow(10, n);
|
||||
}
|
||||
|
||||
internal void CheckValueLabelActive(Axis axis, int i, ChartLabel label, Vector3 pos)
|
||||
internal void CheckValueLabelActive(Axis axis, int i, ChartLabel label, Vector3 pos, string content = null)
|
||||
{
|
||||
if (!axis.show || !axis.axisLabel.show)
|
||||
{
|
||||
label.SetTextActive(false);
|
||||
return;
|
||||
}
|
||||
if (content == null)
|
||||
{
|
||||
content = label.text.GetText();
|
||||
}
|
||||
if (axis.IsValue())
|
||||
{
|
||||
if (orient == Orient.Horizonal)
|
||||
@@ -342,12 +465,12 @@ namespace XCharts
|
||||
if (i == 0)
|
||||
{
|
||||
var dist = GetLabelPosition(0, 1).x - pos.x;
|
||||
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredWidth());
|
||||
label.SetTextActive(axis.IsNeedShowLabel(i, 0, content) && dist > label.text.GetPreferredWidth());
|
||||
}
|
||||
else if (i == axis.context.labelValueList.Count - 1)
|
||||
{
|
||||
var dist = pos.x - GetLabelPosition(0, i - 1).x;
|
||||
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredWidth());
|
||||
label.SetTextActive(axis.IsNeedShowLabel(i, 0, content) && dist > label.text.GetPreferredWidth());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -355,12 +478,12 @@ namespace XCharts
|
||||
if (i == 0)
|
||||
{
|
||||
var dist = GetLabelPosition(0, 1).y - pos.y;
|
||||
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredHeight());
|
||||
label.SetTextActive(axis.IsNeedShowLabel(i, 0, content) && dist > label.text.GetPreferredHeight());
|
||||
}
|
||||
else if (i == axis.context.labelValueList.Count - 1)
|
||||
{
|
||||
var dist = pos.y - GetLabelPosition(0, i - 1).y;
|
||||
label.SetTextActive(axis.IsNeedShowLabel(i) && dist > label.text.GetPreferredHeight());
|
||||
label.SetTextActive(axis.IsNeedShowLabel(i, 0, content) && dist > label.text.GetPreferredHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -416,13 +539,20 @@ namespace XCharts
|
||||
if (axis.IsCategory() && axis.boundaryGap)
|
||||
splitNumber -= 1;
|
||||
axis.context.aligment = defaultAlignment;
|
||||
var sortSerie = chart.GetRealtimeSortSerie(axis.gridIndex);
|
||||
if (sortSerie != null)
|
||||
{
|
||||
SerieHelper.UpdateSerieRuntimeFilterData(sortSerie);
|
||||
}
|
||||
var showData = sortSerie != null ? sortSerie.GetDataList(dataZoom, true) : null;
|
||||
for (int i = 0; i < splitNumber; i++)
|
||||
{
|
||||
var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
|
||||
var labelName = AxisHelper.GetLabelName(axis, axisLength, i,
|
||||
var sortIndex = sortSerie != null ? (i < showData.Count ? showData[i].index : i) : i;
|
||||
var labelName = AxisHelper.GetLabelName(axis, axisLength, sortIndex,
|
||||
axis.context.destMinValue,
|
||||
axis.context.destMaxValue,
|
||||
dataZoom, isPercentStack);
|
||||
dataZoom, isPercentStack, chart.useUtc, i);
|
||||
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i,
|
||||
ChartCached.GetAxisLabelName(i),
|
||||
@@ -528,13 +658,20 @@ namespace XCharts
|
||||
if (axis.IsCategory() && axis.boundaryGap)
|
||||
splitNumber -= 1;
|
||||
axis.context.aligment = defaultAlignment;
|
||||
var sortSerie = chart.GetRealtimeSortSerie(axis.gridIndex);
|
||||
if (sortSerie != null)
|
||||
{
|
||||
SerieHelper.UpdateSerieRuntimeFilterData(sortSerie);
|
||||
}
|
||||
var showData = sortSerie != null ? sortSerie.GetDataList(dataZoom, true) : null;
|
||||
for (int i = 0; i < splitNumber; i++)
|
||||
{
|
||||
var labelWidth = AxisHelper.GetScaleWidth(axis, axisLength, i + 1, dataZoom);
|
||||
var labelName = AxisHelper.GetLabelName(axis, axisLength, i,
|
||||
var sortIndex = sortSerie != null ? (i < showData.Count ? showData[i].index : i) : i;
|
||||
var labelName = AxisHelper.GetLabelName(axis, axisLength, sortIndex,
|
||||
axis.context.destMinValue,
|
||||
axis.context.destMaxValue,
|
||||
dataZoom, isPercentStack);
|
||||
dataZoom, isPercentStack, chart.useUtc, i);
|
||||
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i,
|
||||
ChartCached.GetAxisLabelName(i),
|
||||
@@ -550,7 +687,7 @@ namespace XCharts
|
||||
|
||||
var pos = GetLabelPosition(totalWidth + gapWidth, i);
|
||||
label.SetPosition(pos);
|
||||
CheckValueLabelActive(axis, i, label, pos);
|
||||
CheckValueLabelActive(axis, i, label, pos, labelName);
|
||||
|
||||
axis.context.labelObjectList.Add(label);
|
||||
|
||||
@@ -558,8 +695,8 @@ namespace XCharts
|
||||
}
|
||||
if (axis.axisName.show)
|
||||
{
|
||||
ChartLabel label = null;
|
||||
var relativedDist = (relativedAxis == null ? 0 : relativedAxis.context.offset);
|
||||
ChartLabel label;
|
||||
var relativedDist = relativedAxis == null ? 0 : relativedAxis.context.offset;
|
||||
var zeroPos = new Vector3(axisStartX, axisStartY + relativedDist);
|
||||
var offset = axis.axisName.labelStyle.offset;
|
||||
var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor);
|
||||
@@ -695,17 +832,19 @@ namespace XCharts
|
||||
var lineWidth = axis.axisLine.GetWidth(theme.lineWidth);
|
||||
var lineType = axis.axisLine.GetType(theme.lineType);
|
||||
var lineColor = axis.axisLine.GetColor(theme.lineColor);
|
||||
var sExtendLength = axis.axisLine.startExtendLength;
|
||||
var eExtendLength = axis.axisLine.endExtendLength;
|
||||
|
||||
if (orient == Orient.Horizonal)
|
||||
{
|
||||
var left = new Vector3(startX - lineWidth - (inverse ? offset : 0), startY);
|
||||
var right = new Vector3(startX + axisLength + lineWidth + (!inverse ? offset : 0), startY);
|
||||
var left = new Vector3(startX - lineWidth - (inverse ? offset : 0) - sExtendLength, startY);
|
||||
var right = new Vector3(startX + axisLength + lineWidth + (!inverse ? offset : 0) + eExtendLength, startY);
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, left, right, lineColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
var bottom = new Vector3(startX, startY - lineWidth - (inverse ? offset : 0));
|
||||
var top = new Vector3(startX, startY + axisLength + lineWidth + (!inverse ? offset : 0));
|
||||
var bottom = new Vector3(startX, startY - lineWidth - (inverse ? offset : 0) - sExtendLength);
|
||||
var top = new Vector3(startX, startY + axisLength + lineWidth + (!inverse ? offset : 0) + eExtendLength);
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, bottom, top, lineColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,9 +116,10 @@ namespace XCharts.Runtime
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetLabelName(Axis axis, float coordinateWidth, int index, double minValue, double maxValue,
|
||||
DataZoom dataZoom, bool forcePercent)
|
||||
DataZoom dataZoom, bool forcePercent, bool useUtc, int sortIndex = -1)
|
||||
{
|
||||
int split = GetSplitNumber(axis, coordinateWidth, dataZoom);
|
||||
if (sortIndex == -1) sortIndex = index;
|
||||
if (axis.type == Axis.AxisType.Value)
|
||||
{
|
||||
if (minValue == 0 && maxValue == 0)
|
||||
@@ -137,7 +138,7 @@ namespace XCharts.Runtime
|
||||
if (forcePercent)
|
||||
return string.Format("{0}%", (int)value);
|
||||
else
|
||||
return axis.axisLabel.GetFormatterContent(index, value, minValue, maxValue);
|
||||
return axis.axisLabel.GetFormatterContent(sortIndex, axis.context.labelValueList.Count, value, minValue, maxValue);
|
||||
}
|
||||
else if (axis.type == Axis.AxisType.Log)
|
||||
{
|
||||
@@ -150,7 +151,7 @@ namespace XCharts.Runtime
|
||||
minValue = -minValue;
|
||||
maxValue = -maxValue;
|
||||
}
|
||||
return axis.axisLabel.GetFormatterContent(index, value, minValue, maxValue, true);
|
||||
return axis.axisLabel.GetFormatterContent(sortIndex, 0, value, minValue, maxValue, true);
|
||||
}
|
||||
else if (axis.type == Axis.AxisType.Time)
|
||||
{
|
||||
@@ -160,7 +161,7 @@ namespace XCharts.Runtime
|
||||
return string.Empty;
|
||||
|
||||
var value = axis.GetLabelValue(index);
|
||||
return axis.axisLabel.GetFormatterDateTime(index, value, minValue, maxValue);
|
||||
return axis.axisLabel.GetFormatterDateTime(sortIndex, axis.context.labelValueList.Count, value, minValue, maxValue, !useUtc);
|
||||
}
|
||||
var showData = axis.GetDataList(dataZoom);
|
||||
int dataCount = showData.Count;
|
||||
@@ -172,18 +173,18 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (index > 0)
|
||||
{
|
||||
var residue = (dataCount - 1) - split * rate;
|
||||
var residue = dataCount - 1 - split * rate;
|
||||
var newIndex = residue + (index - 1) * rate;
|
||||
if (newIndex < 0)
|
||||
newIndex = 0;
|
||||
return axis.axisLabel.GetFormatterContent(newIndex, showData[newIndex]);
|
||||
return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[newIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (axis.boundaryGap && coordinateWidth / dataCount > 5)
|
||||
return string.Empty;
|
||||
else
|
||||
return axis.axisLabel.GetFormatterContent(0, showData[0]);
|
||||
return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -191,7 +192,7 @@ namespace XCharts.Runtime
|
||||
int newIndex = index * rate;
|
||||
if (newIndex < dataCount)
|
||||
{
|
||||
return axis.axisLabel.GetFormatterContent(newIndex, showData[newIndex]);
|
||||
return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[newIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -199,7 +200,7 @@ namespace XCharts.Runtime
|
||||
if (axis.boundaryGap && ((diff > 0 && diff / rate < 0.4f) || dataCount >= axis.data.Count))
|
||||
return string.Empty;
|
||||
else
|
||||
return axis.axisLabel.GetFormatterContent(dataCount - 1, showData[dataCount - 1]);
|
||||
return axis.axisLabel.GetFormatterContent(sortIndex, dataCount, showData[dataCount - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -353,8 +354,8 @@ namespace XCharts.Runtime
|
||||
axis.splitNumber = splitNumber;
|
||||
return;
|
||||
}
|
||||
if (axis.type == Axis.AxisType.Time) { }
|
||||
else if (axis.minMaxType == Axis.AxisMinMaxType.Custom)
|
||||
if (ceilRate == 0) ceilRate = axis.ceilRate;
|
||||
if (axis.minMaxType == Axis.AxisMinMaxType.Custom)
|
||||
{
|
||||
if (axis.min != 0 || axis.max != 0)
|
||||
{
|
||||
@@ -370,13 +371,19 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (axis.type == Axis.AxisType.Time)
|
||||
{
|
||||
if (ceilRate != 0)
|
||||
{
|
||||
minValue = ChartHelper.GetMinCeilRate(minValue, ceilRate);
|
||||
maxValue = ChartHelper.GetMaxCeilRate(maxValue, ceilRate);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ceilRate == 0) ceilRate = axis.ceilRate;
|
||||
switch (axis.minMaxType)
|
||||
{
|
||||
case Axis.AxisMinMaxType.Default:
|
||||
|
||||
if (minValue == 0 && maxValue == 0) { }
|
||||
else if (minValue > 0 && maxValue > 0)
|
||||
{
|
||||
@@ -535,9 +542,9 @@ namespace XCharts.Runtime
|
||||
/// <param name="scaleWidth"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)
|
||||
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value, float gap = 0)
|
||||
{
|
||||
return GetAxisPositionInternal(grid, axis, scaleWidth, value, false, true);
|
||||
return GetAxisPositionInternal(grid, axis, scaleWidth, value, false, true, gap);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -571,10 +578,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetAxisPositionInternal(GridCoord grid, Axis axis, float scaleWidth, double value, bool includeGridXY, bool realLength)
|
||||
private static float GetAxisPositionInternal(GridCoord grid, Axis axis, float scaleWidth, double value, bool includeGridXY, bool realLength, float gap = 0)
|
||||
{
|
||||
var isY = axis is YAxis;
|
||||
var gridHeight = isY ? grid.context.height : grid.context.width;
|
||||
gridHeight -= gap;
|
||||
var gridXY = isY ? grid.context.y : grid.context.x;
|
||||
|
||||
if (axis.IsLog())
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private bool m_OnZero = false;
|
||||
[SerializeField] private bool m_ShowStartLabel = true;
|
||||
[SerializeField] private bool m_ShowEndLabel = true;
|
||||
[SerializeField][Since("v3.15.0")] private bool m_ShowZeroLabel = true;
|
||||
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
|
||||
|
||||
/// <summary>
|
||||
@@ -74,6 +75,15 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowEndLabel, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to display the zero label.
|
||||
/// ||是否显示0刻度文本。
|
||||
/// </summary>
|
||||
public bool showZeroLabel
|
||||
{
|
||||
get { return m_ShowZeroLabel; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowZeroLabel, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 文本限制。
|
||||
/// </summary>
|
||||
public TextLimit textLimit
|
||||
@@ -118,6 +128,7 @@ namespace XCharts.Runtime
|
||||
height = height,
|
||||
showStartLabel = showStartLabel,
|
||||
showEndLabel = showEndLabel,
|
||||
showZeroLabel = showZeroLabel,
|
||||
textLimit = textLimit.Clone()
|
||||
};
|
||||
axisLabel.textStyle.Copy(textStyle);
|
||||
@@ -136,6 +147,7 @@ namespace XCharts.Runtime
|
||||
height = axisLabel.height;
|
||||
showStartLabel = axisLabel.showStartLabel;
|
||||
showEndLabel = axisLabel.showEndLabel;
|
||||
showZeroLabel = axisLabel.showZeroLabel;
|
||||
textLimit.Copy(axisLabel.textLimit);
|
||||
textStyle.Copy(axisLabel.textStyle);
|
||||
}
|
||||
@@ -145,7 +157,7 @@ namespace XCharts.Runtime
|
||||
m_TextLimit.SetRelatedText(txt, labelWidth);
|
||||
}
|
||||
|
||||
public override string GetFormatterContent(int labelIndex, string category)
|
||||
public override string GetFormatterContent(int labelIndex, int totalIndex, string category)
|
||||
{
|
||||
if (string.IsNullOrEmpty(category))
|
||||
return GetFormatterFunctionContent(labelIndex, category, category);
|
||||
@@ -157,27 +169,28 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
var content = m_Formatter;
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, category);
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, category, labelIndex, totalIndex);
|
||||
return GetFormatterFunctionContent(labelIndex, category, m_TextLimit.GetLimitContent(content));
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
public override string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
{
|
||||
if (showAsPositiveNumber && value < 0)
|
||||
{
|
||||
value = Math.Abs(value);
|
||||
}
|
||||
return base.GetFormatterContent(labelIndex, value, minValue, maxValue, isLog);
|
||||
return base.GetFormatterContent(labelIndex, totalIndex, value, minValue, maxValue, isLog);
|
||||
}
|
||||
|
||||
public bool IsNeedShowLabel(int index, int total)
|
||||
public bool IsNeedShowLabel(int index, int total, string content = null)
|
||||
{
|
||||
var labelShow = show && (interval == 0 || index % (interval + 1) == 0);
|
||||
if (labelShow)
|
||||
{
|
||||
if (!showStartLabel && index == 0) labelShow = false;
|
||||
else if (!showEndLabel && index == total - 1) labelShow = false;
|
||||
if (labelShow && content == "0") labelShow = showZeroLabel;
|
||||
}
|
||||
return labelShow;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace XCharts.Runtime
|
||||
public class AxisLine : BaseLine
|
||||
{
|
||||
[SerializeField] private bool m_OnZero;
|
||||
[SerializeField] private float m_StartExtendLength;
|
||||
[SerializeField] private float m_EndExtendLength;
|
||||
[SerializeField] private bool m_ShowArrow;
|
||||
[SerializeField] private ArrowStyle m_Arrow = new ArrowStyle();
|
||||
|
||||
@@ -23,6 +25,24 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_OnZero, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Extend length of the axis line at the start.
|
||||
/// ||轴线起点延长线长度。
|
||||
/// </summary>
|
||||
public float startExtendLength
|
||||
{
|
||||
get { return m_StartExtendLength; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_StartExtendLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Extend length of the axis line at the end.
|
||||
/// ||轴线终点延长线长度。
|
||||
/// </summary>
|
||||
public float endExtendLength
|
||||
{
|
||||
get { return m_EndExtendLength; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_EndExtendLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show the arrow symbol of axis.
|
||||
/// ||是否显示箭头。
|
||||
/// </summary>
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace XCharts.Runtime
|
||||
InitRadiusAxis(axis);
|
||||
else
|
||||
{
|
||||
axis.UpdateLabelText(polar.context.radius, null, false);
|
||||
UpdateLabelText(axis, polar.context.radius, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace XCharts.Runtime
|
||||
var inside = axis.axisLabel.inside;
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
|
||||
var labelName = AxisHelper.GetLabelName(axis, radius, i, axis.context.minValue, axis.context.maxValue,
|
||||
null, isPercentStack);
|
||||
null, isPercentStack, chart.useUtc);
|
||||
var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
|
||||
new Vector2(labelWidth, txtHig), axis, chart.theme.axis, labelName, Color.clear);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField][Since("v3.6.0")] private Color32 m_MarkColor;
|
||||
[SerializeField] private Color32 m_BackgroundColor;
|
||||
[SerializeField] private float m_BackgroundWidth;
|
||||
[SerializeField][Since("v3.15.0")] private float m_BackgroundGap;
|
||||
[SerializeField] private Color32 m_CenterColor;
|
||||
[SerializeField] private float m_CenterGap;
|
||||
[SerializeField] private float m_BorderWidth = 0;
|
||||
@@ -129,6 +130,15 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the gap between background and data item.
|
||||
/// ||数据项背景间隙。
|
||||
/// </summary>
|
||||
public float backgroundGap
|
||||
{
|
||||
get { return m_BackgroundGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BackgroundGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 中心区域颜色。
|
||||
/// </summary>
|
||||
public Color32 centerColor
|
||||
|
||||
@@ -152,18 +152,16 @@ namespace XCharts.Runtime
|
||||
/// <summary>
|
||||
/// 根据指定的sizeType获得标记的大小
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSize(List<double> data, float themeSize)
|
||||
public float GetSize(SerieData serieData, float themeSize)
|
||||
{
|
||||
switch (m_SizeType)
|
||||
{
|
||||
case SymbolSizeType.Custom:
|
||||
return size == 0 ? themeSize : size;
|
||||
case SymbolSizeType.FromData:
|
||||
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
|
||||
if (serieData != null && dataIndex >= 0 && dataIndex < serieData.data.Count)
|
||||
{
|
||||
var value = (float) data[dataIndex] * m_DataScale;
|
||||
var value = (float) serieData.data[dataIndex] * m_DataScale;
|
||||
if (m_MinSize != 0 && value < m_MinSize) value = m_MinSize;
|
||||
if (m_MaxSize != 0 && value > m_MaxSize) value = m_MaxSize;
|
||||
return value;
|
||||
@@ -173,7 +171,7 @@ namespace XCharts.Runtime
|
||||
return size == 0 ? themeSize : size;
|
||||
}
|
||||
case SymbolSizeType.Function:
|
||||
if (data != null && sizeFunction != null) return sizeFunction(data);
|
||||
if (sizeFunction != null) return sizeFunction(themeSize, serieData);
|
||||
else return size == 0 ? themeSize : size;
|
||||
default:
|
||||
return size == 0 ? themeSize : size;
|
||||
|
||||
@@ -5,14 +5,33 @@ using UnityEngine;
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// comment of chart.
|
||||
/// ||图表注解组件。
|
||||
/// The layer of comment.
|
||||
/// ||注解的显示层级。
|
||||
/// </summary>
|
||||
[Since("v3.15.0")]
|
||||
public enum CommentLayer
|
||||
{
|
||||
/// <summary>
|
||||
/// The comment is display under the serie.
|
||||
/// ||注解在系列下方。
|
||||
/// </summary>
|
||||
Lower,
|
||||
/// <summary>
|
||||
/// The comment is display above the serie.
|
||||
/// ||注解在系列上方。
|
||||
/// </summary>
|
||||
Upper
|
||||
}
|
||||
/// <summary>
|
||||
/// comment of chart. Used to annotate special information in the chart.
|
||||
/// ||图表注解组件。用于标注图表中的特殊信息。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[ComponentHandler(typeof(CommentHander), true)]
|
||||
public class Comment : MainComponent, IPropertyChanged
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField][Since("v3.15.0")] private CommentLayer m_Layer = CommentLayer.Lower;
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
|
||||
[SerializeField] private CommentMarkStyle m_MarkStyle;
|
||||
[SerializeField] private List<CommentItem> m_Items = new List<CommentItem>() { new CommentItem() };
|
||||
@@ -23,6 +42,11 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The layer of comment.
|
||||
/// ||注解的显示层级。
|
||||
/// </summary>
|
||||
public CommentLayer layer { get { return m_Layer; } set { if (PropertyUtil.SetStruct(ref m_Layer, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The items of comment.
|
||||
/// ||注解项。每个注解组件可以设置多个注解项。
|
||||
/// </summary>
|
||||
@@ -45,7 +69,12 @@ namespace XCharts.Runtime
|
||||
get { return m_MarkStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_MarkStyle, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the label style of comment item.
|
||||
/// ||获取注解项的文本样式。
|
||||
/// </summary>
|
||||
/// <param name="index">the index of item</param>
|
||||
/// <returns></returns>
|
||||
public LabelStyle GetLabelStyle(int index)
|
||||
{
|
||||
if (index >= 0 && index < items.Count)
|
||||
@@ -55,7 +84,12 @@ namespace XCharts.Runtime
|
||||
}
|
||||
return m_LabelStyle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the mark style of comment item.
|
||||
/// ||获取注解项的标记样式。
|
||||
/// </summary>
|
||||
/// <param name="index">the index of item</param>
|
||||
/// <returns></returns>
|
||||
public CommentMarkStyle GetMarkStyle(int index)
|
||||
{
|
||||
if (index >= 0 && index < items.Count)
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace XCharts.Runtime
|
||||
var comment = component;
|
||||
comment.OnChanged();
|
||||
comment.painter = null;
|
||||
comment.refreshComponent = delegate()
|
||||
comment.refreshComponent = delegate ()
|
||||
{
|
||||
var objName = ChartCached.GetComponentObjectName(comment);
|
||||
var commentObj = ChartHelper.AddObject(objName,
|
||||
@@ -23,20 +23,25 @@ namespace XCharts.Runtime
|
||||
chart.chartMaxAnchor,
|
||||
chart.chartPivot,
|
||||
chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||
var siblingIndex = comment.layer == CommentLayer.Upper
|
||||
? chart.topPainter.transform.GetSiblingIndex() - 1
|
||||
: chart.painter.transform.GetSiblingIndex() + 1;
|
||||
|
||||
commentObj.SetActive(comment.show);
|
||||
commentObj.transform.SetSiblingIndex(siblingIndex);
|
||||
commentObj.hideFlags = chart.chartHideFlags;
|
||||
ChartHelper.HideAllObject(commentObj);
|
||||
for (int i = 0; i < comment.items.Count; i++)
|
||||
{
|
||||
var item = comment.items[i];
|
||||
var labelStyle = comment.GetLabelStyle(i);
|
||||
item.location.OnChanged();
|
||||
var labelPos = chart.chartPosition + item.location.GetPosition(chart.chartWidth, chart.chartHeight);
|
||||
var label = ChartHelper.AddChartLabel(s_CommentObjectName + i, commentObj.transform, labelStyle, chart.theme.common,
|
||||
GetContent(item), Color.clear, TextAnchor.MiddleCenter);
|
||||
label.SetActive(comment.show && item.show, true);
|
||||
label.SetPosition(labelPos);
|
||||
label.text.SetLocalPosition(labelStyle.offset);
|
||||
label.SetPosition(labelPos + labelStyle.offset);
|
||||
item.labelObject = label;
|
||||
}
|
||||
};
|
||||
comment.refreshComponent();
|
||||
|
||||
@@ -11,11 +11,13 @@ namespace XCharts.Runtime
|
||||
public class CommentItem : ChildComponent
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private string m_Content = "comment";
|
||||
[SerializeField] private string m_Content = "xcharts";
|
||||
[SerializeField] private Rect m_MarkRect;
|
||||
[SerializeField] private CommentMarkStyle m_MarkStyle = new CommentMarkStyle() { show = false };
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle() { show = false };
|
||||
[SerializeField] [Since("v3.5.0")]private Location m_Location = new Location() { align = Location.Align.TopLeft, top = 0.125f };
|
||||
[SerializeField][Since("v3.5.0")] private Location m_Location = new Location() { align = Location.Align.BottomRight, right = 0.1f, bottom = 0.05f };
|
||||
|
||||
public ChartLabel labelObject { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -27,7 +29,18 @@ namespace XCharts.Runtime
|
||||
/// content of comment.
|
||||
/// ||注解的文本内容。支持模板参数,可以参考Tooltip的itemFormatter。
|
||||
/// </summary>
|
||||
public string content { get { return m_Content; } set { if (PropertyUtil.SetClass(ref m_Content, value)) SetComponentDirty(); } }
|
||||
public string content
|
||||
{
|
||||
get { return m_Content; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtil.SetClass(ref m_Content, value))
|
||||
{
|
||||
if (labelObject != null) labelObject.SetText(value);
|
||||
else SetComponentDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// the mark rect of comment.
|
||||
/// ||注解区域。
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -81,7 +82,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private RangeMode m_RangeMode;
|
||||
[SerializeField] private float m_Start;
|
||||
[SerializeField] private float m_End;
|
||||
[SerializeField] private int m_MinShowNum = 2;
|
||||
[SerializeField] private float m_MinZoomRatio = 0.2f;
|
||||
[Range(1f, 20f)]
|
||||
[SerializeField] private float m_ScrollSensitivity = 1.1f;
|
||||
[SerializeField] private Orient m_Orient = Orient.Horizonal;
|
||||
@@ -336,10 +337,19 @@ namespace XCharts.Runtime
|
||||
/// Minimum number of display data. Minimum number of data displayed when DataZoom is enlarged to maximum.
|
||||
/// ||最小显示数据个数。当DataZoom放大到最大时,最小显示的数据个数。
|
||||
/// </summary>
|
||||
public int minShowNum
|
||||
[Obsolete("Use \"minZoomRatio\" instead", true)]
|
||||
public float minShowNum
|
||||
{
|
||||
get { return m_MinShowNum; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MinShowNum, value)) SetVerticesDirty(); }
|
||||
set;get;
|
||||
}
|
||||
/// <summary>
|
||||
/// The minimum zoom ratio of dataZoom. Range 0f-1f.
|
||||
/// ||缩放区域组件的最小缩放比例,范围0f-1f。
|
||||
/// </summary>
|
||||
public float minZoomRatio
|
||||
{
|
||||
get { return m_MinZoomRatio; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MinZoomRatio, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The sensitivity of dataZoom scroll.
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace XCharts.Runtime
|
||||
var grid = chart.GetGridOfDataZoom(dataZoom);
|
||||
var start = (dataZoom.context.marqueeRect.x - grid.context.x) / grid.context.width * 100;
|
||||
var end = (dataZoom.context.marqueeRect.x - grid.context.x + dataZoom.context.marqueeRect.width) / grid.context.width * 100;
|
||||
UpdateDataZoomRange(dataZoom, start, end);
|
||||
UpdateDataZoomRange(dataZoom, start, end, grid);
|
||||
}
|
||||
if (dataZoom.marqueeStyle.onEnd != null)
|
||||
{
|
||||
@@ -271,7 +271,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
var start = (startX - grid.context.x) / grid.context.width * 100;
|
||||
var end = (endX - grid.context.x) / grid.context.width * 100;
|
||||
UpdateDataZoomRange(dataZoom, start, end);
|
||||
UpdateDataZoomRange(dataZoom, start, end, grid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ namespace XCharts.Runtime
|
||||
if ((dataZoom.supportInside && dataZoom.supportInsideScroll && grid.Contains(pos)) ||
|
||||
dataZoom.IsInZoom(pos))
|
||||
{
|
||||
ScaleDataZoom(dataZoom, eventData.scrollDelta.y * dataZoom.scrollSensitivity);
|
||||
ScaleDataZoom(dataZoom, eventData.scrollDelta.y * dataZoom.scrollSensitivity, grid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,25 +375,27 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
private void ScaleDataZoom(DataZoom dataZoom, float delta)
|
||||
private void ScaleDataZoom(DataZoom dataZoom, float delta, GridCoord grid = null)
|
||||
{
|
||||
var grid = chart.GetGridOfDataZoom(dataZoom);
|
||||
var deltaPercent = dataZoom.orient == Orient.Horizonal ?
|
||||
Mathf.Abs(delta / grid.context.width * 100) :
|
||||
Mathf.Abs(delta / grid.context.height * 100);
|
||||
if (grid == null) grid = chart.GetGridOfDataZoom(dataZoom);
|
||||
var range = dataZoom.orient == Orient.Horizonal ? grid.context.width : grid.context.height;
|
||||
var deltaPercent = Mathf.Abs(delta / range * 100);
|
||||
float start, end;
|
||||
if (delta > 0)
|
||||
{
|
||||
if (dataZoom.end <= dataZoom.start)
|
||||
return;
|
||||
UpdateDataZoomRange(dataZoom, dataZoom.start + deltaPercent, dataZoom.end - deltaPercent);
|
||||
if (dataZoom.end <= dataZoom.start) return;
|
||||
start = dataZoom.start + deltaPercent;
|
||||
end = dataZoom.end - deltaPercent;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateDataZoomRange(dataZoom, dataZoom.start - deltaPercent, dataZoom.end + deltaPercent);
|
||||
start = dataZoom.start - deltaPercent;
|
||||
end = dataZoom.end + deltaPercent;
|
||||
}
|
||||
UpdateDataZoomRange(dataZoom, start, end, grid);
|
||||
}
|
||||
|
||||
public void UpdateDataZoomRange(DataZoom dataZoom, float start, float end)
|
||||
public void UpdateDataZoomRange(DataZoom dataZoom, float start, float end, GridCoord grid = null)
|
||||
{
|
||||
if (end > 100)
|
||||
end = 100;
|
||||
@@ -403,13 +405,26 @@ namespace XCharts.Runtime
|
||||
|
||||
if (end < start)
|
||||
end = start;
|
||||
if (dataZoom.startEndFunction != null)
|
||||
dataZoom.startEndFunction(ref start, ref end);
|
||||
|
||||
if(dataZoom.minZoomRatio > 0)
|
||||
{
|
||||
if(grid == null) grid = chart.GetGridOfDataZoom(dataZoom);
|
||||
var range = dataZoom.orient == Orient.Horizonal ? grid.context.width : grid.context.height;
|
||||
var minRange = dataZoom.minZoomRatio * range;
|
||||
if (end - start < minRange / range * 100)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dataZoom.startLock)
|
||||
dataZoom.start = start;
|
||||
if (!dataZoom.endLock)
|
||||
dataZoom.end = end;
|
||||
|
||||
if (dataZoom.startEndFunction != null)
|
||||
dataZoom.startEndFunction(ref start, ref end);
|
||||
|
||||
m_LastStart = dataZoom.start;
|
||||
m_LastEnd = dataZoom.end;
|
||||
if (dataZoom.realtime)
|
||||
@@ -444,7 +459,7 @@ namespace XCharts.Runtime
|
||||
var tempPos1 = touch1.position;
|
||||
var currDist = Vector2.Distance(tempPos0, tempPos1);
|
||||
var lastDist = Vector2.Distance(m_LastTouchPos0, m_LastTouchPos1);
|
||||
var delta = (currDist - lastDist);
|
||||
var delta = currDist - lastDist;
|
||||
ScaleDataZoom(dataZoom, delta / dataZoom.scrollSensitivity);
|
||||
m_LastTouchPos0 = tempPos0;
|
||||
m_LastTouchPos1 = tempPos1;
|
||||
@@ -492,7 +507,6 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else if (xAxis.IsTime())
|
||||
{
|
||||
//TODO:
|
||||
dataZoom.SetStartLabelText("");
|
||||
dataZoom.SetEndLabelText("");
|
||||
}
|
||||
|
||||
@@ -80,6 +80,8 @@ namespace XCharts.Runtime
|
||||
[SerializeField] protected string m_NumericFormatter = "";
|
||||
[SerializeField] protected float m_Width = 0;
|
||||
[SerializeField] protected float m_Height = 0;
|
||||
[SerializeField][Since("v3.15.0")] protected float m_FixedX = 0;
|
||||
[SerializeField][Since("v3.15.0")] protected float m_FixedY = 0;
|
||||
|
||||
[SerializeField] protected IconStyle m_Icon = new IconStyle();
|
||||
[SerializeField] protected ImageStyle m_Background = new ImageStyle();
|
||||
@@ -131,7 +133,8 @@ namespace XCharts.Runtime
|
||||
/// `{g}` : indicates the total number of data. <br />
|
||||
/// `{h}` : hexadecimal color value. <br />
|
||||
/// `{y}` : category value of y axis. <br />
|
||||
/// `{value}` : The value of the axis or legend. <br />
|
||||
/// `{value}` : the value of the axis or legend. <br />
|
||||
/// `{index}` : the index of the axis. <br />
|
||||
/// The following placeholder apply to `UITable` components: <br />
|
||||
/// `{name}` : indicates the row name of the table. <br />
|
||||
/// `{index}` : indicates the row number of the table. <br />
|
||||
@@ -161,6 +164,7 @@ namespace XCharts.Runtime
|
||||
/// `{h}`:十六进制颜色值。<br/>
|
||||
/// `{y}`:Y轴的类目名。<br/>
|
||||
/// `{value}`:坐标轴或图例的值。<br/>
|
||||
/// `{index}`:坐标轴编号。<br/>
|
||||
/// 以下通配符适用UITable组件:<br/>
|
||||
/// `{name}`: 表格的行名。<br/>
|
||||
/// `{index}`:表格的行号。<br/>
|
||||
@@ -286,6 +290,24 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoOffset, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the fixed x of label. When not 0, it will be fixed on the specified x value.
|
||||
/// ||固定的X值。不为0时,会固定在指定的X值上。
|
||||
/// </summary>
|
||||
public float fixedX
|
||||
{
|
||||
get { return m_FixedX; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FixedX, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the fixed y of label. When not 0, it will be fixed on the specified y value.
|
||||
/// ||固定的Y值。不为0时,会固定在指定的Y值上。
|
||||
/// </summary>
|
||||
public float fixedY
|
||||
{
|
||||
get { return m_FixedY; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FixedY, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the sytle of background.
|
||||
/// ||背景图样式。
|
||||
/// </summary>
|
||||
@@ -373,6 +395,8 @@ namespace XCharts.Runtime
|
||||
label.m_Height = m_Height;
|
||||
label.m_NumericFormatter = m_NumericFormatter;
|
||||
label.m_AutoOffset = m_AutoOffset;
|
||||
label.m_FixedX = m_FixedX;
|
||||
label.m_FixedY = m_FixedY;
|
||||
label.m_Icon.Copy(m_Icon);
|
||||
label.m_Background.Copy(m_Background);
|
||||
label.m_TextPadding = m_TextPadding;
|
||||
@@ -392,13 +416,15 @@ namespace XCharts.Runtime
|
||||
m_Height = label.m_Height;
|
||||
m_NumericFormatter = label.m_NumericFormatter;
|
||||
m_AutoOffset = label.m_AutoOffset;
|
||||
m_FixedX = label.m_FixedX;
|
||||
m_FixedY = label.m_FixedY;
|
||||
m_Icon.Copy(label.m_Icon);
|
||||
m_Background.Copy(label.m_Background);
|
||||
m_TextPadding = label.m_TextPadding;
|
||||
m_TextStyle.Copy(label.m_TextStyle);
|
||||
}
|
||||
|
||||
public virtual string GetFormatterContent(int labelIndex, string category)
|
||||
public virtual string GetFormatterContent(int labelIndex, int totalIndex, string category)
|
||||
{
|
||||
if (string.IsNullOrEmpty(category))
|
||||
return GetFormatterFunctionContent(labelIndex, category, category);
|
||||
@@ -410,12 +436,12 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
var content = m_Formatter;
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, category);
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, category, labelIndex, totalIndex);
|
||||
return GetFormatterFunctionContent(labelIndex, category, category);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string GetFormatterContent(int labelIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
public virtual string GetFormatterContent(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool isLog = false)
|
||||
{
|
||||
var newNumericFormatter = numericFormatter;
|
||||
if (value == 0 && !DateTimeUtil.IsDateOrTimeRegex(newNumericFormatter))
|
||||
@@ -452,17 +478,17 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
var content = m_Formatter;
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, newNumericFormatter, value);
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, newNumericFormatter, value, labelIndex, totalIndex);
|
||||
return GetFormatterFunctionContent(labelIndex, value, content);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool isDateFormatter = false;
|
||||
private static string newFormatter = null;
|
||||
public string GetFormatterDateTime(int labelIndex, double value, double minValue, double maxValue)
|
||||
public string GetFormatterDateTime(int labelIndex, int totalIndex, double value, double minValue, double maxValue, bool local)
|
||||
{
|
||||
var timestamp = (int)value;
|
||||
var dateTime = DateTimeUtil.GetDateTime(timestamp);
|
||||
var timestamp = value;
|
||||
var dateTime = DateTimeUtil.GetDateTime(timestamp, local);
|
||||
var dateString = string.Empty;
|
||||
if (string.IsNullOrEmpty(numericFormatter) || numericFormatter.Equals("f2"))
|
||||
{
|
||||
@@ -472,10 +498,10 @@ namespace XCharts.Runtime
|
||||
{
|
||||
try
|
||||
{
|
||||
if(DateTimeUtil.IsDateOrTimeRegex(numericFormatter, ref isDateFormatter, ref newFormatter))
|
||||
if (DateTimeUtil.IsDateOrTimeRegex(numericFormatter, ref isDateFormatter, ref newFormatter))
|
||||
{
|
||||
if(isDateFormatter)
|
||||
dateString = ChartCached.NumberToDateStr(timestamp, newFormatter);
|
||||
if (isDateFormatter)
|
||||
dateString = ChartCached.NumberToDateStr(timestamp, newFormatter, local);
|
||||
else
|
||||
dateString = ChartCached.NumberToTimeStr(timestamp, newFormatter);
|
||||
}
|
||||
@@ -492,7 +518,7 @@ namespace XCharts.Runtime
|
||||
if (!string.IsNullOrEmpty(m_Formatter))
|
||||
{
|
||||
var content = m_Formatter;
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, dateString);
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, dateString, labelIndex, totalIndex);
|
||||
return GetFormatterFunctionContent(labelIndex, value, content);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var content = serieLabel.formatter;
|
||||
FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue,
|
||||
dataTotal, serieName, dataName, dataName, color, serieData, chart, serie.index);
|
||||
dataTotal, serieName, dataName, dataName, color, serieData, chart, serie.index, serie.useSortData);
|
||||
if (serieLabel.formatterFunction == null)
|
||||
return content;
|
||||
else
|
||||
@@ -53,6 +53,22 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetTitleFormatterContent(Serie serie, SerieData serieData,
|
||||
int dataIndex, LabelStyle titleStyle, BaseChart chart)
|
||||
{
|
||||
string content;
|
||||
if (string.IsNullOrEmpty(titleStyle.formatter))
|
||||
{
|
||||
content = serieData.name;
|
||||
}
|
||||
else
|
||||
{
|
||||
content = titleStyle.formatter;
|
||||
FormatterHelper.ReplaceContent(ref content, dataIndex, titleStyle.numericFormatter, serie, chart, null, serieData);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
public static void SetGaugeLabelText(Serie serie)
|
||||
{
|
||||
var serieData = serie.GetSerieData(0);
|
||||
|
||||
@@ -79,6 +79,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private float m_ItemGap = 10f;
|
||||
[SerializeField] private bool m_ItemAutoColor = true;
|
||||
[SerializeField] private float m_ItemOpacity = 1;
|
||||
[SerializeField][Since("v3.15.0")] private float m_ItemInactiveOpacity = 1;
|
||||
[SerializeField] private string m_Formatter;
|
||||
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
|
||||
[SerializeField][Since("v3.10.0")] private TextLimit m_TextLimit = new TextLimit();
|
||||
@@ -182,6 +183,15 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemOpacity, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the opacity of item color when item is inactive.
|
||||
/// ||图例标记的图形在非激活状态下的颜色透明度。
|
||||
/// </summary>
|
||||
public float itemInactiveOpacity
|
||||
{
|
||||
get { return m_ItemInactiveOpacity; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemInactiveOpacity, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// No longer used, the use of LabelStyle.formatter instead.
|
||||
/// ||不再使用,使用LabelStyle.formatter代替。
|
||||
/// </summary>
|
||||
|
||||
@@ -92,15 +92,15 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (!SeriesHelper.IsLegalLegendName(datas[i])) continue;
|
||||
string legendName = datas[i];
|
||||
var serieIndex = isAnySerieColorByData ? 0 : i;
|
||||
var dataIndex = isAnySerieColorByData ? i : 0;
|
||||
var serieIndex = isAnySerieColorByData ? 0 : i;
|
||||
var dataIndex = isAnySerieColorByData ? i : 0;
|
||||
var legendContent = GetFormatterContent(legend, dataIndex, datas[i], serieIndex);
|
||||
if (legend.textLimit.enable)
|
||||
legendContent = legend.textLimit.GetLimitContent(legendContent);
|
||||
var readIndex = chart.m_LegendRealShowName.IndexOf(datas[i]);
|
||||
var active = chart.IsActiveByLegend(datas[i]);
|
||||
var bgColor = LegendHelper.GetIconColor(chart, legend, readIndex, datas[i], active);
|
||||
bgColor.a = legend.itemOpacity;
|
||||
bgColor.a = active ? legend.itemOpacity : legend.itemInactiveOpacity;
|
||||
var item = LegendHelper.AddLegendItem(chart, legend, i, legendName, legendObject.transform, chart.theme,
|
||||
legendContent, bgColor, active, readIndex);
|
||||
legend.SetButton(legendName, item, totalLegend);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace XCharts.Runtime
|
||||
else
|
||||
return !ChartHelper.IsClearColor(textStyle.color) ? textStyle.color : theme.legend.textColor;
|
||||
}
|
||||
else return theme.legend.unableColor;
|
||||
else return theme.legend.inactiveColor;
|
||||
}
|
||||
|
||||
public static Color GetIconColor(BaseChart chart, Legend legend, int readIndex, string legendName, bool active)
|
||||
@@ -30,7 +30,7 @@ namespace XCharts.Runtime
|
||||
else
|
||||
return legend.GetColor(readIndex);
|
||||
}
|
||||
else return chart.theme.legend.unableColor;
|
||||
else return chart.theme.legend.inactiveColor;
|
||||
}
|
||||
|
||||
public static LegendItem AddLegendItem(BaseChart chart, Legend legend, int i, string legendName, Transform parent,
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace XCharts.Runtime
|
||||
private void InitMarkArea(MarkArea markArea)
|
||||
{
|
||||
markArea.painter = chart.m_PainterUpper;
|
||||
markArea.refreshComponent = delegate()
|
||||
markArea.refreshComponent = delegate ()
|
||||
{
|
||||
var label = ChartHelper.AddChartLabel("label", m_MarkLineLabelRoot.transform, markArea.label, chart.theme.axis,
|
||||
component.text, Color.clear, TextAnchor.MiddleCenter);
|
||||
@@ -142,31 +142,12 @@ namespace XCharts.Runtime
|
||||
else if (data.yValue != 0)
|
||||
{
|
||||
data.runtimeValue = data.yValue;
|
||||
if (yAxis.IsCategory())
|
||||
{
|
||||
var pY = AxisHelper.GetAxisPosition(grid, yAxis, data.yValue, showData.Count, dataZoom);
|
||||
return start ?
|
||||
new Vector3(grid.context.x, pY) :
|
||||
new Vector3(grid.context.x + grid.context.width, pY);
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetPosition(xAxis, yAxis, grid, data.runtimeValue, start);
|
||||
}
|
||||
return GetPosition(yAxis, grid, data.runtimeValue, start);
|
||||
}
|
||||
else
|
||||
{
|
||||
data.runtimeValue = data.xValue;
|
||||
if (xAxis.IsCategory())
|
||||
{
|
||||
var pX = AxisHelper.GetAxisPosition(grid, xAxis, data.xValue, showData.Count, dataZoom);
|
||||
return start ? new Vector3(pX, grid.context.y + grid.context.height) :
|
||||
new Vector3(pX, grid.context.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetPosition(xAxis, yAxis, grid, data.xValue, start);
|
||||
}
|
||||
return GetPosition(xAxis, grid, data.xValue, start);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
@@ -178,16 +159,28 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (yAxis.IsCategory())
|
||||
{
|
||||
var pX = AxisHelper.GetAxisPosition(grid, xAxis, value);
|
||||
return GetPosition(xAxis, grid, value, start);
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetPosition(yAxis, grid, value, start);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 GetPosition(Axis axis, GridCoord grid, double value, bool start)
|
||||
{
|
||||
if (axis is XAxis)
|
||||
{
|
||||
var pX = AxisHelper.GetAxisPosition(grid, axis, value);
|
||||
return start ?
|
||||
new Vector3(pX, grid.context.y + grid.context.height) :
|
||||
new Vector3(pX, grid.context.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
var pY = AxisHelper.GetAxisPosition(grid, yAxis, value);
|
||||
var pY = AxisHelper.GetAxisPosition(grid, axis, value);
|
||||
return start ?
|
||||
new Vector3(grid.context.x, pY + grid.context.height) :
|
||||
new Vector3(grid.context.x, pY) :
|
||||
new Vector3(grid.context.x + grid.context.width, pY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,25 +4,34 @@ using UnityEngine;
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 标线类型
|
||||
/// Mark line type.
|
||||
/// ||标线类型
|
||||
/// </summary>
|
||||
public enum MarkLineType
|
||||
{
|
||||
None,
|
||||
/// <summary>
|
||||
/// 最小值。
|
||||
/// Custom. You can customize the xy coordinates or values.
|
||||
/// ||自定义。可自定义xy坐标或数值。
|
||||
/// </summary>
|
||||
Custom,
|
||||
/// <summary>
|
||||
/// Minimum value.
|
||||
/// ||最小值。
|
||||
/// </summary>
|
||||
Min,
|
||||
/// <summary>
|
||||
/// 最大值。
|
||||
/// Maximum value.
|
||||
/// ||最大值。
|
||||
/// </summary>
|
||||
Max,
|
||||
/// <summary>
|
||||
/// 平均值。
|
||||
/// Average value.
|
||||
/// ||平均值。
|
||||
/// </summary>
|
||||
Average,
|
||||
/// <summary>
|
||||
/// 中位数。
|
||||
/// Median.
|
||||
/// ||中位数。
|
||||
/// </summary>
|
||||
Median
|
||||
}
|
||||
@@ -118,7 +127,7 @@ namespace XCharts.Runtime
|
||||
[System.Serializable]
|
||||
public class MarkLineData : ChildComponent
|
||||
{
|
||||
[SerializeField] private MarkLineType m_Type = MarkLineType.None;
|
||||
[SerializeField] private MarkLineType m_Type = MarkLineType.Custom;
|
||||
[SerializeField] private string m_Name;
|
||||
[SerializeField] private int m_Dimension = 1;
|
||||
[SerializeField] private float m_XPosition;
|
||||
@@ -170,7 +179,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
/// <summary>
|
||||
/// The x coordinate relative to the origin, in pixels.
|
||||
/// ||相对原点的 x 坐标,单位像素。当type为None时有效。
|
||||
/// ||相对原点的 x 坐标,单位像素。当type为Custom时有效。
|
||||
/// </summary>
|
||||
public float xPosition
|
||||
{
|
||||
@@ -179,7 +188,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
/// <summary>
|
||||
/// The y coordinate relative to the origin, in pixels.
|
||||
/// ||相对原点的 y 坐标,单位像素。当type为None时有效。
|
||||
/// ||相对原点的 y 坐标,单位像素。当type为Custom时有效。
|
||||
/// </summary>
|
||||
public float yPosition
|
||||
{
|
||||
@@ -188,7 +197,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
/// <summary>
|
||||
/// The value specified on the X-axis. A value specified when the X-axis is the category axis represents the index of the category axis data, otherwise a specific value.
|
||||
/// ||X轴上的指定值。当X轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为None时有效。
|
||||
/// ||X轴上的指定值。当X轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为Custom时有效。
|
||||
/// </summary>
|
||||
public double xValue
|
||||
{
|
||||
@@ -197,7 +206,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
/// <summary>
|
||||
/// That's the value on the Y-axis. The value specified when the Y axis is the category axis represents the index of the category axis data, otherwise the specific value.
|
||||
/// ||Y轴上的指定值。当Y轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为None时有效。
|
||||
/// ||Y轴上的指定值。当Y轴为类目轴时指定值表示类目轴数据的索引,否则为具体的值。当type为Custom时有效。
|
||||
/// </summary>
|
||||
public double yValue
|
||||
{
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace XCharts.Runtime
|
||||
data.runtimeValue = SerieHelper.GetMedianData(serie, data.dimension, dataZoom);
|
||||
GetStartEndPos(yAxis, grid, data.runtimeValue, ref sp, ref ep);
|
||||
break;
|
||||
case MarkLineType.None:
|
||||
case MarkLineType.Custom:
|
||||
if (data.xPosition != 0)
|
||||
{
|
||||
data.runtimeValue = data.xPosition;
|
||||
@@ -292,18 +292,20 @@ namespace XCharts.Runtime
|
||||
switch (data.type)
|
||||
{
|
||||
case MarkLineType.Min:
|
||||
var serieData = SerieHelper.GetMinSerieData(serie, data.dimension, dataZoom);
|
||||
var serieData = SerieHelper.GetMinSerieData(serie, data.dimension, null);
|
||||
data.runtimeValue = serieData.GetData(data.dimension);
|
||||
var pX = GetAxisPosition(grid, xAxis, dataZoom, serieDataCount, serieData.index);
|
||||
var pY = GetAxisPosition(grid, yAxis, dataZoom, serieDataCount, data.runtimeValue);
|
||||
return new Vector3(pX, pY);
|
||||
//return new Vector3(pX, pY);
|
||||
return serieData.context.position;
|
||||
case MarkLineType.Max:
|
||||
serieData = SerieHelper.GetMaxSerieData(serie, data.dimension, dataZoom);
|
||||
serieData = SerieHelper.GetMaxSerieData(serie, data.dimension, null);
|
||||
data.runtimeValue = serieData.GetData(data.dimension);
|
||||
pX = GetAxisPosition(grid, xAxis, dataZoom, serieDataCount, serieData.index);
|
||||
pY = GetAxisPosition(grid, yAxis, dataZoom, serieDataCount, data.runtimeValue);
|
||||
return new Vector3(pX, pY);
|
||||
case MarkLineType.None:
|
||||
//return new Vector3(pX, pY);
|
||||
return serieData.context.position;
|
||||
case MarkLineType.Custom:
|
||||
if (data.zeroPosition)
|
||||
{
|
||||
data.runtimeValue = 0;
|
||||
|
||||
@@ -464,16 +464,16 @@ namespace XCharts.Runtime
|
||||
indicatorList.Clear();
|
||||
}
|
||||
|
||||
public string GetFormatterIndicatorContent(int indicatorIndex)
|
||||
public string GetFormatterIndicatorContent(int indicatorIndex, int totalIndex)
|
||||
{
|
||||
var indicator = GetIndicator(indicatorIndex);
|
||||
if (indicator == null)
|
||||
return string.Empty;
|
||||
else
|
||||
return GetFormatterIndicatorContent(indicator.name);
|
||||
return GetFormatterIndicatorContent(indicator.name, indicatorIndex, totalIndex);
|
||||
}
|
||||
|
||||
public string GetFormatterIndicatorContent(string indicatorName)
|
||||
public string GetFormatterIndicatorContent(string indicatorName, int index, int totalIndex)
|
||||
{
|
||||
if (string.IsNullOrEmpty(indicatorName))
|
||||
return indicatorName;
|
||||
@@ -485,7 +485,7 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
var content = m_AxisName.labelStyle.formatter;
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, indicatorName);
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, indicatorName, index, totalIndex);
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,9 +50,9 @@ namespace XCharts.Runtime
|
||||
var indicator = radar.indicatorList[i];
|
||||
var pos = radar.GetIndicatorPosition(i);
|
||||
var objName = INDICATOR_TEXT + "_" + i;
|
||||
|
||||
var content = radar.GetFormatterIndicatorContent(i, radar.indicatorList.Count);
|
||||
var label = ChartHelper.AddChartLabel(objName, radarObject.transform, radar.axisName.labelStyle,
|
||||
chart.theme.common, radar.GetFormatterIndicatorContent(i), Color.clear, TextAnchor.MiddleCenter);
|
||||
chart.theme.common, content, Color.clear, TextAnchor.MiddleCenter);
|
||||
label.SetActive(radar.axisName.show && radar.indicator && radar.axisName.labelStyle.show, true);
|
||||
AxisHelper.AdjustCircleLabelPos(label, pos, radar.context.center, txtHig, radar.axisName.labelStyle.offset);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace XCharts.Runtime
|
||||
/// ||标题组件,包含主标题和副标题。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[ComponentHandler(typeof(TitleHander), true)]
|
||||
[ComponentHandler(typeof(TitleHandler), true)]
|
||||
public class Title : MainComponent, IPropertyChanged
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
|
||||
@@ -3,7 +3,7 @@ using UnityEngine;
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class TitleHander : MainComponentHandler<Title>
|
||||
public sealed class TitleHandler : MainComponentHandler<Title>
|
||||
{
|
||||
private static readonly string s_TitleObjectName = "title";
|
||||
private static readonly string s_SubTitleObjectName = "title_sub";
|
||||
@@ -14,50 +14,68 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var title = component;
|
||||
title.painter = null;
|
||||
title.refreshComponent = delegate()
|
||||
title.refreshComponent = delegate ()
|
||||
{
|
||||
title.OnChanged();
|
||||
var anchorMin = title.location.runtimeAnchorMin;
|
||||
var anchorMax = title.location.runtimeAnchorMax;
|
||||
var pivot = title.location.runtimePivot;
|
||||
var objName = ChartCached.GetComponentObjectName(title);
|
||||
var titleObject = ChartHelper.AddObject(objName, chart.transform, anchorMin, anchorMax,
|
||||
pivot, chart.chartSizeDelta, -1, chart.childrenNodeNames);
|
||||
title.gameObject = titleObject;
|
||||
title.gameObject.transform.SetSiblingIndex(chart.m_PainterUpper.transform.GetSiblingIndex() + 1);
|
||||
anchorMin = title.location.runtimeAnchorMin;
|
||||
anchorMax = title.location.runtimeAnchorMax;
|
||||
pivot = title.location.runtimePivot;
|
||||
var fontSize = title.labelStyle.textStyle.GetFontSize(chart.theme.title);
|
||||
ChartHelper.UpdateRectTransform(titleObject, anchorMin, anchorMax, pivot, new Vector2(chart.chartWidth, chart.chartHeight));
|
||||
var titlePosition = chart.GetTitlePosition(title);
|
||||
var subTitlePosition = -new Vector3(0, fontSize + title.itemGap, 0);
|
||||
var titleObject = AddTitleObject(chart, title, chart.theme.title, chart.m_PainterUpper.transform.GetSiblingIndex() + 1);
|
||||
|
||||
titleObject.transform.localPosition = titlePosition;
|
||||
titleObject.hideFlags = chart.chartHideFlags;
|
||||
ChartHelper.HideAllObject(titleObject);
|
||||
m_LabelObject = AddTitleLabel(titleObject.transform, title, chart.theme.title, chart);
|
||||
m_SubLabelObject = AddSubTitleLabel(titleObject.transform, title, chart.theme.subTitle, chart);
|
||||
|
||||
m_LabelObject = ChartHelper.AddChartLabel(s_TitleObjectName, titleObject.transform, title.labelStyle, chart.theme.title,
|
||||
GetTitleText(title), Color.clear, title.location.runtimeTextAlignment);
|
||||
m_LabelObject.SetActive(title.show && title.labelStyle.show, true);
|
||||
|
||||
m_SubLabelObject = ChartHelper.AddChartLabel(s_SubTitleObjectName, titleObject.transform, title.subLabelStyle, chart.theme.subTitle,
|
||||
GetSubTitleText(title), Color.clear, title.location.runtimeTextAlignment);
|
||||
m_SubLabelObject.SetActive(title.show && title.subLabelStyle.show, true);
|
||||
m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
|
||||
};
|
||||
title.refreshComponent();
|
||||
}
|
||||
|
||||
public static GameObject AddTitleObject(BaseGraph graph, Title title, ComponentTheme componentTheme, int titleSiblingIndex, string objectName = null)
|
||||
{
|
||||
var anchorMin = title.location.runtimeAnchorMin;
|
||||
var anchorMax = title.location.runtimeAnchorMax;
|
||||
var pivot = title.location.runtimePivot;
|
||||
var objName = objectName == null ? ChartCached.GetComponentObjectName(title) : objectName;
|
||||
var titleObject = ChartHelper.AddObject(objName, graph.transform, anchorMin, anchorMax,
|
||||
pivot, graph.graphSizeDelta, -1, graph.childrenNodeNames);
|
||||
title.gameObject = titleObject;
|
||||
title.gameObject.transform.SetSiblingIndex(titleSiblingIndex);
|
||||
anchorMin = title.location.runtimeAnchorMin;
|
||||
anchorMax = title.location.runtimeAnchorMax;
|
||||
pivot = title.location.runtimePivot;
|
||||
|
||||
ChartHelper.UpdateRectTransform(titleObject, anchorMin, anchorMax, pivot, new Vector2(graph.graphWidth, graph.graphHeight));
|
||||
var titlePosition = graph.GetTitlePosition(title);
|
||||
titleObject.transform.localPosition = titlePosition;
|
||||
titleObject.hideFlags = graph.chartHideFlags;
|
||||
ChartHelper.HideAllObject(titleObject);
|
||||
return titleObject;
|
||||
}
|
||||
|
||||
public static ChartLabel AddTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
|
||||
{
|
||||
var m_LabelObject = ChartHelper.AddChartLabel(s_TitleObjectName, parent, title.labelStyle, componentTheme,
|
||||
GetTitleText(title, chart), Color.clear, title.location.runtimeTextAlignment);
|
||||
m_LabelObject.SetActive(title.show && title.labelStyle.show, true);
|
||||
return m_LabelObject;
|
||||
}
|
||||
|
||||
public static ChartLabel AddSubTitleLabel(Transform parent, Title title, ComponentTheme componentTheme, BaseChart chart = null)
|
||||
{
|
||||
var fontSize = title.labelStyle.textStyle.GetFontSize(componentTheme);
|
||||
var subTitlePosition = -new Vector3(0, fontSize + title.itemGap, 0);
|
||||
var m_SubLabelObject = ChartHelper.AddChartLabel(s_SubTitleObjectName, parent, title.subLabelStyle, componentTheme,
|
||||
GetSubTitleText(title, chart), Color.clear, title.location.runtimeTextAlignment);
|
||||
m_SubLabelObject.SetActive(title.show && title.subLabelStyle.show, true);
|
||||
m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
|
||||
return m_SubLabelObject;
|
||||
}
|
||||
|
||||
public override void OnSerieDataUpdate(int serieIndex)
|
||||
{
|
||||
if (m_LabelObject != null && FormatterHelper.NeedFormat(component.text))
|
||||
m_LabelObject.SetText(GetTitleText(component));
|
||||
m_LabelObject.SetText(GetTitleText(component, chart));
|
||||
if (m_SubLabelObject != null && FormatterHelper.NeedFormat(component.subText))
|
||||
m_SubLabelObject.SetText(GetSubTitleText(component));
|
||||
m_SubLabelObject.SetText(GetSubTitleText(component, chart));
|
||||
}
|
||||
|
||||
private string GetTitleText(Title title)
|
||||
private static string GetTitleText(Title title, BaseChart chart)
|
||||
{
|
||||
if (FormatterHelper.NeedFormat(title.text))
|
||||
{
|
||||
@@ -71,7 +89,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
private string GetSubTitleText(Title title)
|
||||
private static string GetSubTitleText(Title title, BaseChart chart)
|
||||
{
|
||||
if (FormatterHelper.NeedFormat(title.subText))
|
||||
{
|
||||
|
||||
@@ -145,6 +145,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private float m_TitleHeight = 25f;
|
||||
[SerializeField] private float m_ItemHeight = 25f;
|
||||
[SerializeField] private Color32 m_BorderColor = new Color32(230, 230, 230, 255);
|
||||
[SerializeField][Since("v3.14.0")] private List<float> m_ColumnGapWidths = new List<float>{15};
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None);
|
||||
[SerializeField]
|
||||
private LabelStyle m_TitleLabelStyle = new LabelStyle()
|
||||
@@ -154,7 +155,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField]
|
||||
private List<LabelStyle> m_ContentLabelStyles = new List<LabelStyle>()
|
||||
{
|
||||
new LabelStyle() { textPadding = new TextPadding(0, 5, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft } },
|
||||
new LabelStyle() { textPadding = new TextPadding(0, 5, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleCenter } },
|
||||
new LabelStyle() { textPadding = new TextPadding(0, 20, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft } },
|
||||
new LabelStyle() { textPadding = new TextPadding(0, 0, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleRight } }
|
||||
};
|
||||
@@ -453,6 +454,15 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the column gap width of content. When there is only one column, it only represents the gap width of the second column.
|
||||
/// ||内容部分的列间距。当只有一列时,只表示第二列的间距。
|
||||
/// </summary>
|
||||
public List<float> columnGapWidths
|
||||
{
|
||||
get { return m_ColumnGapWidths; }
|
||||
set { if (value != null) { m_ColumnGapWidths = value; SetComponentDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// the textstyle of title.
|
||||
/// ||标题的文本样式。
|
||||
/// </summary>
|
||||
@@ -462,8 +472,8 @@ namespace XCharts.Runtime
|
||||
set { if (value != null) { m_TitleLabelStyle = value; SetComponentDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// the textstyle list of content.
|
||||
/// ||内容部分的文本样式列表。和列一一对应。
|
||||
/// the column text style list of content. The first represents the text style of the first column, and so on.
|
||||
/// ||内容部分的列文本样式列表。第一个表示第一列的文本样式,以此类推。
|
||||
/// </summary>
|
||||
public List<LabelStyle> contentLabelStyles
|
||||
{
|
||||
|
||||
@@ -255,6 +255,11 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (label == null) return;
|
||||
if (double.IsNaN(axis.context.pointerValue)) return;
|
||||
if (!axis.show || !axis.indicatorLabel.show)
|
||||
{
|
||||
label.SetActive(false, false);
|
||||
return;
|
||||
}
|
||||
label.SetActive(true, true);
|
||||
label.SetTextActive(true);
|
||||
label.SetPosition(axis.context.pointerLabelPosition + axis.indicatorLabel.offset);
|
||||
@@ -264,15 +269,15 @@ namespace XCharts.Runtime
|
||||
var index = (int)axis.context.pointerValue;
|
||||
var dataZoom = chart.GetDataZoomOfAxis(axis);
|
||||
var category = axis.GetData(index, dataZoom);
|
||||
label.SetText(axis.indicatorLabel.GetFormatterContent(index, category));
|
||||
label.SetText(axis.indicatorLabel.GetFormatterContent(index, 0, category));
|
||||
}
|
||||
else if (axis.IsTime())
|
||||
{
|
||||
label.SetText(axis.indicatorLabel.GetFormatterDateTime(0, axis.context.pointerValue, axis.context.minValue, axis.context.maxValue));
|
||||
label.SetText(axis.indicatorLabel.GetFormatterDateTime(0, 0, axis.context.pointerValue, axis.context.minValue, axis.context.maxValue, !chart.useUtc));
|
||||
}
|
||||
else
|
||||
{
|
||||
label.SetText(axis.indicatorLabel.GetFormatterContent(0, axis.context.pointerValue, axis.context.minValue, axis.context.maxValue, axis.IsLog()));
|
||||
label.SetText(axis.indicatorLabel.GetFormatterContent(0, 0, axis.context.pointerValue, axis.context.minValue, axis.context.maxValue, axis.IsLog()));
|
||||
}
|
||||
var textColor = axis.axisLabel.textStyle.GetColor(chart.theme.axis.textColor);
|
||||
if (ChartHelper.IsClearColor(axis.indicatorLabel.background.color))
|
||||
@@ -356,6 +361,7 @@ namespace XCharts.Runtime
|
||||
if (isTriggerAxis)
|
||||
{
|
||||
var index = serie.context.dataZoomStartIndex + (int)yAxis.context.pointerValue;
|
||||
if (serie.useSortData) index = yAxis.context.sortedDataIndices[index];
|
||||
serie.context.pointerEnter = true;
|
||||
serie.context.pointerAxisDataIndexs.Add(index);
|
||||
serie.context.pointerItemDataIndex = index;
|
||||
@@ -375,6 +381,7 @@ namespace XCharts.Runtime
|
||||
if (isTriggerAxis)
|
||||
{
|
||||
var index = serie.context.dataZoomStartIndex + (int)xAxis.context.pointerValue;
|
||||
if (serie.useSortData) index = xAxis.context.sortedDataIndices[index];
|
||||
if (chart.isTriggerOnClick)
|
||||
{
|
||||
if (serie.insertDataToHead)
|
||||
@@ -452,7 +459,7 @@ namespace XCharts.Runtime
|
||||
var dataCount = serie.dataCount;
|
||||
var themeSymbolSize = chart.theme.serie.scatterSymbolSize;
|
||||
var data = serie.data;
|
||||
if (!isTimeAxis)
|
||||
if (!isTimeAxis)// || serie.useSortData)
|
||||
{
|
||||
serie.context.sortedData.Clear();
|
||||
for (int i = 0; i < dataCount; i++)
|
||||
@@ -471,13 +478,25 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var serieData = data[i];
|
||||
currValue = serieData.GetData(dimension);
|
||||
if (i == 0 && i + 1 < dataCount)
|
||||
if (i == 0)
|
||||
{
|
||||
nextValue = data[i + 1].GetData(dimension);
|
||||
if (axisValue <= currValue + (nextValue - currValue) / 2)
|
||||
if (i + 1 < dataCount)
|
||||
{
|
||||
serie.context.pointerAxisDataIndexs.Add(serieData.index);
|
||||
break;
|
||||
nextValue = data[i + 1].GetData(dimension);
|
||||
if (axisValue <= currValue + (nextValue - currValue) / 2)
|
||||
{
|
||||
serie.context.pointerAxisDataIndexs.Add(serieData.index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var diff = axis.context.tickValue * 0.5f;
|
||||
if (axisValue >= currValue - diff && axisValue <= currValue + diff)
|
||||
{
|
||||
serie.context.pointerAxisDataIndexs.Add(serieData.index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (i == dataCount - 1)
|
||||
@@ -614,7 +633,21 @@ namespace XCharts.Runtime
|
||||
var serieData = serie.GetSerieData(serie.context.pointerItemDataIndex);
|
||||
if (serieData != null)
|
||||
{
|
||||
tooltip.context.data.title = DateTimeUtil.GetDefaultDateTimeString((int)serieData.GetData(0), axisRange);
|
||||
var value = (int)serieData.GetData(0);
|
||||
if (string.IsNullOrEmpty(tooltip.titleLabelStyle.numericFormatter))
|
||||
tooltip.context.data.title = DateTimeUtil.GetDefaultDateTimeString(value, axisRange, !chart.useUtc);
|
||||
else
|
||||
{
|
||||
var dateTime = DateTimeUtil.GetDateTime(value, !chart.useUtc);
|
||||
try
|
||||
{
|
||||
tooltip.context.data.title = dateTime.ToString(tooltip.titleLabelStyle.numericFormatter);
|
||||
}
|
||||
catch
|
||||
{
|
||||
tooltip.context.data.title = DateTimeUtil.GetDefaultDateTimeString(value, axisRange, !chart.useUtc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
serie.handler.UpdateTooltipSerieParams(dataIndex, showCategory, category,
|
||||
@@ -704,6 +737,7 @@ namespace XCharts.Runtime
|
||||
|
||||
private void DrawXAxisIndicator(VertexHelper vh, Tooltip tooltip, GridCoord grid)
|
||||
{
|
||||
if (!tooltip.lineStyle.show) return;
|
||||
var xAxes = chart.GetChartComponents<XAxis>();
|
||||
var lineType = tooltip.lineStyle.GetType(chart.theme.tooltip.lineType);
|
||||
var lineWidth = tooltip.lineStyle.GetWidth(chart.theme.tooltip.lineWidth);
|
||||
|
||||
@@ -16,8 +16,9 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
tooltip.context.data.title = tooltip.titleFormatter;
|
||||
FormatterHelper.ReplaceContent(ref tooltip.context.data.title, -1,
|
||||
tooltip.numericFormatter, null, chart);
|
||||
var numericFormatter = string.IsNullOrEmpty(tooltip.titleLabelStyle.numericFormatter)
|
||||
? tooltip.numericFormatter : tooltip.titleLabelStyle.numericFormatter;
|
||||
FormatterHelper.ReplaceContent(ref tooltip.context.data.title, -1, numericFormatter, null, chart);
|
||||
}
|
||||
}
|
||||
for (int i = tooltip.context.data.param.Count - 1; i >= 0; i--)
|
||||
@@ -56,7 +57,7 @@ namespace XCharts.Runtime
|
||||
|
||||
public static bool IsIgnoreFormatter(string itemFormatter)
|
||||
{
|
||||
return "-".Equals(itemFormatter) ||"{i}".Equals(itemFormatter, StringComparison.CurrentCultureIgnoreCase);
|
||||
return "-".Equals(itemFormatter) || "{i}".Equals(itemFormatter, StringComparison.CurrentCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public static void LimitInRect(BaseChart chart, Tooltip tooltip, Rect chartRect)
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace XCharts.Runtime
|
||||
ChartHelper.SetActive(gameObject, m_Active);
|
||||
if (!flag)
|
||||
{
|
||||
m_ColumnMaxWidth.Clear();
|
||||
foreach (var item in m_Items)
|
||||
item.gameObject.SetActive(false);
|
||||
}
|
||||
@@ -75,8 +76,6 @@ namespace XCharts.Runtime
|
||||
ChartHelper.SetActive(title, titleActive);
|
||||
title.SetText(data.title);
|
||||
|
||||
m_ColumnMaxWidth.Clear();
|
||||
var contentLabelStyle0 = tooltip.GetContentLabelStyle(0);
|
||||
for (int i = 0; i < data.param.Count; i++)
|
||||
{
|
||||
var item = GetItem(i);
|
||||
@@ -89,17 +88,21 @@ namespace XCharts.Runtime
|
||||
item.gameObject.SetActive(true);
|
||||
for (int j = 0; j < param.columns.Count; j++)
|
||||
{
|
||||
var column = GetItemColumn(item, j);
|
||||
var column = GetItemColumn(item, j, j == 0 && IsSecondaryMark(param, param.columns[j]));
|
||||
column.SetActive(true);
|
||||
column.SetText(param.columns[j]);
|
||||
|
||||
if (j == 0 && contentLabelStyle0 != null && ChartHelper.IsClearColor(contentLabelStyle0.textStyle.color))
|
||||
column.text.SetColor(param.color);
|
||||
if (j == 0)
|
||||
{
|
||||
var labelStyle = tooltip.GetContentLabelStyle(j);
|
||||
if (labelStyle != null && ChartHelper.IsClearColor(labelStyle.textStyle.color))
|
||||
column.text.SetColor(param.color);
|
||||
}
|
||||
|
||||
if (j >= m_ColumnMaxWidth.Count)
|
||||
m_ColumnMaxWidth.Add(0);
|
||||
|
||||
var columnWidth = column.GetWidth();
|
||||
var columnWidth = column.text.GetPreferredWidth() + GetTooltipColumnGapWidth(tooltip, j);
|
||||
if (m_ColumnMaxWidth[j] < columnWidth)
|
||||
m_ColumnMaxWidth[j] = columnWidth;
|
||||
}
|
||||
@@ -117,6 +120,22 @@ namespace XCharts.Runtime
|
||||
tooltip.gameObject.transform.SetAsLastSibling();
|
||||
}
|
||||
|
||||
private static float GetTooltipColumnGapWidth(Tooltip tooltip, int index)
|
||||
{
|
||||
if (tooltip == null || tooltip.columnGapWidths.Count == 0) return 0;
|
||||
if (tooltip.columnGapWidths.Count == 1) return index == 1 ? tooltip.columnGapWidths[0] : 0;
|
||||
if (index < tooltip.columnGapWidths.Count)
|
||||
{
|
||||
return tooltip.columnGapWidths[index];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static bool IsSecondaryMark(SerieParams sp, string mark)
|
||||
{
|
||||
return sp.isSecondaryMark && mark == sp.marker;
|
||||
}
|
||||
|
||||
private void ResetSize()
|
||||
{
|
||||
var maxHig = 0f;
|
||||
@@ -158,8 +177,10 @@ namespace XCharts.Runtime
|
||||
var xPos = 0f;
|
||||
for (int j = 0; j < m_ColumnMaxWidth.Count; j++)
|
||||
{
|
||||
if (j >= item.columns.Count) break;
|
||||
var deltaX = j == m_ColumnMaxWidth.Count - 1 ? maxWid - xPos : m_ColumnMaxWidth[j];
|
||||
item.columns[j].text.SetSizeDelta(new Vector2(deltaX, tooltip.itemHeight));
|
||||
item.columns[j].SetSize(deltaX, tooltip.itemHeight);
|
||||
item.columns[j].SetRectPosition(new Vector3(xPos, 0));
|
||||
xPos += m_ColumnMaxWidth[j];
|
||||
}
|
||||
@@ -192,19 +213,24 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
private ChartLabel GetItemColumn(TooltipViewItem item, int i)
|
||||
private ChartLabel GetItemColumn(TooltipViewItem item, int i, bool isSecondaryMark = false)
|
||||
{
|
||||
if (i < 0) i = 0;
|
||||
ChartLabel column;
|
||||
if (i < item.columns.Count)
|
||||
{
|
||||
return item.columns[i];
|
||||
column = item.columns[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
var column = CreateViewItemColumn(i, item.gameObject.transform, tooltip, theme);
|
||||
column = CreateViewItemColumn(i, item.gameObject.transform, tooltip, theme);
|
||||
item.columns.Add(column);
|
||||
return column;
|
||||
}
|
||||
if (isSecondaryMark)
|
||||
{
|
||||
column.text.text.fontSize = (int)(tooltip.GetContentLabelStyle(i).textStyle.fontSize * 0.6f);
|
||||
}
|
||||
return column;
|
||||
}
|
||||
|
||||
public static TooltipView CreateView(Tooltip tooltip, ThemeStyle theme, Transform parent)
|
||||
@@ -266,8 +292,9 @@ namespace XCharts.Runtime
|
||||
private static ChartLabel CreateViewItemColumn(int i, Transform parent, Tooltip tooltip, ComponentTheme theme)
|
||||
{
|
||||
var labelStyle = tooltip.GetContentLabelStyle(i);
|
||||
labelStyle.textStyle.autoAlign = false;
|
||||
var label = ChartHelper.AddChartLabel("column" + i, parent, labelStyle, theme,
|
||||
"", Color.clear, TextAnchor.MiddleLeft);
|
||||
"", Color.clear, TextAnchor.MiddleLeft, true);
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var grid = component;
|
||||
grid.painter = chart.painter;
|
||||
grid.refreshComponent = delegate()
|
||||
grid.refreshComponent = delegate ()
|
||||
{
|
||||
grid.UpdateRuntimeData(chart);
|
||||
chart.OnCoordinateChanged();
|
||||
@@ -51,6 +51,7 @@ namespace XCharts.Runtime
|
||||
|
||||
public override void DrawBase(VertexHelper vh)
|
||||
{
|
||||
DrawBackground(vh, component);
|
||||
if (!SeriesHelper.IsAnyClipSerie(chart.series))
|
||||
{
|
||||
DrawCoord(vh, component);
|
||||
@@ -64,7 +65,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCoord(VertexHelper vh, GridCoord grid)
|
||||
private void DrawBackground(VertexHelper vh, GridCoord grid)
|
||||
{
|
||||
if (!grid.show) return;
|
||||
if (!ChartHelper.IsClearColor(grid.backgroundColor))
|
||||
@@ -75,6 +76,11 @@ namespace XCharts.Runtime
|
||||
var p4 = new Vector2(grid.context.x + grid.context.width, grid.context.y);
|
||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, grid.backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCoord(VertexHelper vh, GridCoord grid)
|
||||
{
|
||||
if (!grid.show) return;
|
||||
if (grid.showBorder)
|
||||
{
|
||||
var borderWidth = grid.borderWidth == 0 ? chart.theme.axis.lineWidth * 2 : grid.borderWidth;
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace XCharts.Runtime
|
||||
private static Regex s_RegexSubForAxisLabel = new Regex(@"(value)|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexForSerieLabel = new Regex(@"{[a-h|\.|y]\d*(:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexSubForSerieLabel = new Regex(@"(\.)|([a-h|y]\d*)|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
|
||||
private static Regex s_RegexForAxisIndex = new Regex(@"\{(-?)index([+-]\d+)?\}", RegexOptions.IgnoreCase);
|
||||
|
||||
public static bool NeedFormat(string content)
|
||||
{
|
||||
@@ -36,7 +37,7 @@ namespace XCharts.Runtime
|
||||
/// <param name="category">选中的类目,一般用在折线图和柱状图</param>
|
||||
/// <returns></returns>
|
||||
public static bool ReplaceContent(ref string content, int dataIndex, string numericFormatter, Serie serie,
|
||||
BaseChart chart, string colorName = null)
|
||||
BaseChart chart, string colorName = null, SerieData serieData = null)
|
||||
{
|
||||
var foundDot = false;
|
||||
var mc = s_Regex.Matches(content);
|
||||
@@ -111,7 +112,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
var serieData = serie.GetSerieData(bIndex);
|
||||
serieData = serie.GetSerieData(bIndex);
|
||||
content = content.Replace(old, serieData.name);
|
||||
}
|
||||
}
|
||||
@@ -206,12 +207,17 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
if (serieData != null)
|
||||
{
|
||||
ReplaceIndexContent(ref content, serie.useSortData ? serieData.sortIndex : serieData.index, serie.dataCount);
|
||||
}
|
||||
content = s_RegexNewLine.Replace(content, PH_NN);
|
||||
return foundDot;
|
||||
}
|
||||
|
||||
public static void ReplaceSerieLabelContent(ref string content, string numericFormatter, int dataCount, double value, double total,
|
||||
string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null, int serieIndex = 0)
|
||||
string serieName, string category, string dataName, Color color, SerieData serieData, BaseChart chart = null, int serieIndex = 0,
|
||||
bool sortData = false)
|
||||
{
|
||||
var mc = s_RegexForSerieLabel.Matches(content);
|
||||
foreach (var m in mc)
|
||||
@@ -308,6 +314,10 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
}
|
||||
if (serieData != null)
|
||||
{
|
||||
ReplaceIndexContent(ref content, sortData ? serieData.sortIndex : serieData.index, dataCount);
|
||||
}
|
||||
content = TrimAndReplaceLine(content);
|
||||
}
|
||||
|
||||
@@ -334,7 +344,7 @@ namespace XCharts.Runtime
|
||||
return s_RegexNewLine.Replace(content.Trim(), PH_NN);
|
||||
}
|
||||
|
||||
public static void ReplaceAxisLabelContent(ref string content, string numericFormatter, double value)
|
||||
public static void ReplaceAxisLabelContent(ref string content, string numericFormatter, double value, int index, int totalIndex)
|
||||
{
|
||||
var mc = s_RegexForAxisLabel.Matches(content);
|
||||
foreach (var m in mc)
|
||||
@@ -349,10 +359,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
content = content.Replace(old, ChartCached.FloatToStr(value, numericFormatter));
|
||||
}
|
||||
ReplaceIndexContent(ref content, index, totalIndex);
|
||||
content = TrimAndReplaceLine(content);
|
||||
}
|
||||
|
||||
public static void ReplaceAxisLabelContent(ref string content, string value)
|
||||
public static void ReplaceAxisLabelContent(ref string content, string value, int index, int totalIndex)
|
||||
{
|
||||
var mc = s_RegexForAxisLabel.Matches(content);
|
||||
foreach (var m in mc)
|
||||
@@ -363,8 +374,26 @@ namespace XCharts.Runtime
|
||||
if (argsCount <= 0) continue;
|
||||
content = content.Replace(old, value);
|
||||
}
|
||||
ReplaceIndexContent(ref content, index, totalIndex);
|
||||
content = TrimAndReplaceLine(content);
|
||||
}
|
||||
|
||||
public static void ReplaceIndexContent(ref string content, int currIndex, int totalIndex)
|
||||
{
|
||||
if (totalIndex <= 0) return;
|
||||
content = s_RegexForAxisIndex.Replace(content, (match) =>
|
||||
{
|
||||
bool isNegative = match.Groups[1].Value == "-";
|
||||
int offset = 0;
|
||||
int parsedOffset = 0;
|
||||
if (match.Groups[2].Success &&
|
||||
int.TryParse(match.Groups[2].Value, out parsedOffset))
|
||||
{
|
||||
offset = parsedOffset;
|
||||
}
|
||||
int baseValue = isNegative ? totalIndex - currIndex : currIndex + 1;
|
||||
return (baseValue + offset).ToString();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to use UTC time for the chart.
|
||||
/// ||图表的时间是否都显示为UTC时间。
|
||||
/// </summary>
|
||||
public bool useUtc { get { return m_UseUtc; } set { m_UseUtc = value; } }
|
||||
/// <summary>
|
||||
/// The theme.
|
||||
/// ||</summary>
|
||||
public ThemeStyle theme { get { return m_Theme; } set { m_Theme = value; } }
|
||||
@@ -69,6 +74,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public Vector3 chartPosition { get { return m_ChartPosition; } }
|
||||
public Rect chartRect { get { return m_ChartRect; } }
|
||||
public Painter topPainter { get { return m_PainterTop; } }
|
||||
/// <summary>
|
||||
/// The callback function of chart init.
|
||||
/// ||图表的初始化完成回调。
|
||||
@@ -587,11 +593,6 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 GetTitlePosition(Title title)
|
||||
{
|
||||
return chartPosition + title.location.GetPosition(chartWidth, chartHeight);
|
||||
}
|
||||
|
||||
public int GetLegendRealShowNameIndex(string name)
|
||||
{
|
||||
return m_LegendRealShowName.IndexOf(name);
|
||||
|
||||
@@ -52,6 +52,7 @@ namespace XCharts.Runtime
|
||||
|
||||
public MainComponent AddChartComponent(Type type)
|
||||
{
|
||||
InitListForFieldInfos();
|
||||
if (!CanAddChartComponent(type))
|
||||
{
|
||||
Debug.LogError("XCharts ERROR: CanAddChartComponent:" + type.Name);
|
||||
@@ -428,6 +429,19 @@ namespace XCharts.Runtime
|
||||
return true;
|
||||
}
|
||||
|
||||
public Axis GetMainAxis()
|
||||
{
|
||||
foreach (var component in m_Components)
|
||||
{
|
||||
if (component is Axis)
|
||||
{
|
||||
var axis = component as Axis;
|
||||
if (axis.show && axis.mainAxis) return axis;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 纯类目轴。
|
||||
/// </summary>
|
||||
@@ -482,7 +496,15 @@ namespace XCharts.Runtime
|
||||
relativedAxis = null;
|
||||
return false;
|
||||
}
|
||||
var isY = yAxis.IsCategory() && !xAxis.IsCategory();
|
||||
bool isY;
|
||||
if (xAxis.type == yAxis.type)
|
||||
{
|
||||
isY = yAxis.mainAxis;
|
||||
}
|
||||
else
|
||||
{
|
||||
isY = yAxis.IsCategory() && !xAxis.IsCategory();
|
||||
}
|
||||
if (isY)
|
||||
{
|
||||
axis = yAxis;
|
||||
|
||||
@@ -11,33 +11,61 @@ namespace XCharts.Runtime
|
||||
public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double tempMinValue, out double tempMaxValue)
|
||||
{
|
||||
var needAnimationData = !axis.context.needAnimation;
|
||||
bool isX = false, isY = false, isZ = false;
|
||||
tempMinValue = 0;
|
||||
tempMaxValue = 0;
|
||||
if (axis is XAxis3D)
|
||||
{
|
||||
SeriesHelper.GetXMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
|
||||
}
|
||||
isX = true;
|
||||
else if (axis is ZAxis3D)
|
||||
{
|
||||
SeriesHelper.GetZMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
|
||||
isZ = true;
|
||||
}
|
||||
else if (axis is YAxis3D)
|
||||
{
|
||||
SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
|
||||
isY = true;
|
||||
}
|
||||
else if (IsAllAxisValue())
|
||||
{
|
||||
if (axis is XAxis)
|
||||
var mainAxis = GetMainAxis();
|
||||
if (mainAxis == null)
|
||||
{
|
||||
SeriesHelper.GetXMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
|
||||
if (axis is XAxis)
|
||||
{
|
||||
isX = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isY = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
|
||||
if (axis == mainAxis)
|
||||
{
|
||||
isX = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isY = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isY = true;
|
||||
}
|
||||
if (isX)
|
||||
{
|
||||
SeriesHelper.GetXMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
|
||||
}
|
||||
else if (isY)
|
||||
{
|
||||
SeriesHelper.GetYMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
|
||||
}
|
||||
else if(isZ)
|
||||
{
|
||||
SeriesHelper.GetZMinMaxValue(this, axisIndex, axis.inverse, out tempMinValue, out tempMaxValue, false, false, needAnimationData);
|
||||
}
|
||||
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,28 @@ namespace XCharts.Runtime
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasRealtimeSortSerie(int gridIndex)
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
{
|
||||
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
|
||||
if (serie.useSortData)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Serie GetRealtimeSortSerie(int gridIndex)
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
{
|
||||
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
|
||||
if (serie.useSortData)
|
||||
return serie;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public T GetSerie<T>() where T : Serie
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
@@ -831,7 +853,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public float GetSerieBarGap<T>() where T : Serie
|
||||
public float GetSerieBarGap<T>(int gridIndex) where T : Serie
|
||||
{
|
||||
float gap = 0f;
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
@@ -839,6 +861,7 @@ namespace XCharts.Runtime
|
||||
var serie = m_Series[i];
|
||||
if (serie.show && serie is T)
|
||||
{
|
||||
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
|
||||
if (serie.barGap != 0)
|
||||
{
|
||||
gap = serie.barGap;
|
||||
@@ -848,7 +871,7 @@ namespace XCharts.Runtime
|
||||
return gap;
|
||||
}
|
||||
|
||||
public double GetSerieSameStackTotalValue<T>(string stack, int dataIndex) where T : Serie
|
||||
public double GetSerieSameStackTotalValue<T>(string stack, int dataIndex, int gridIndex) where T : Serie
|
||||
{
|
||||
if (string.IsNullOrEmpty(stack)) return 0;
|
||||
double total = 0;
|
||||
@@ -856,6 +879,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (serie is T)
|
||||
{
|
||||
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
|
||||
if (stack.Equals(serie.stack))
|
||||
{
|
||||
total += serie.data[dataIndex].data[1];
|
||||
@@ -865,7 +889,7 @@ namespace XCharts.Runtime
|
||||
return total;
|
||||
}
|
||||
|
||||
public int GetSerieBarRealCount<T>() where T : Serie
|
||||
public int GetSerieBarRealCount<T>(int gridIndex) where T : Serie
|
||||
{
|
||||
var count = 0;
|
||||
barStackSet.Clear();
|
||||
@@ -875,6 +899,7 @@ namespace XCharts.Runtime
|
||||
if (!serie.show) continue;
|
||||
if (serie is T)
|
||||
{
|
||||
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
|
||||
if (!string.IsNullOrEmpty(serie.stack))
|
||||
{
|
||||
if (barStackSet.Contains(serie.stack)) continue;
|
||||
@@ -887,8 +912,26 @@ namespace XCharts.Runtime
|
||||
return count;
|
||||
}
|
||||
|
||||
private bool CheckSerieGridIndex(Serie serie, int gridIndex)
|
||||
{
|
||||
if (gridIndex >= 0)
|
||||
{
|
||||
if (serie.xAxisIndex >= 0 && serie.xAxisIndex < m_XAxes.Count)
|
||||
{
|
||||
var xAxis = m_XAxes[serie.xAxisIndex];
|
||||
if (xAxis.gridIndex != gridIndex) return false;
|
||||
}
|
||||
if (serie.yAxisIndex >= 0 && serie.yAxisIndex < m_YAxes.Count)
|
||||
{
|
||||
var yAxis = m_YAxes[serie.yAxisIndex];
|
||||
if (yAxis.gridIndex != gridIndex) return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private HashSet<string> barStackSet = new HashSet<string>();
|
||||
public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount) where T : Serie
|
||||
public float GetSerieTotalWidth<T>(float categoryWidth, float gap, int realBarCount, int gridIndex) where T : Serie
|
||||
{
|
||||
float total = 0;
|
||||
float lastGap = 0;
|
||||
@@ -899,6 +942,7 @@ namespace XCharts.Runtime
|
||||
if (!serie.show) continue;
|
||||
if (serie is T)
|
||||
{
|
||||
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
|
||||
if (!string.IsNullOrEmpty(serie.stack))
|
||||
{
|
||||
if (barStackSet.Contains(serie.stack)) continue;
|
||||
@@ -921,12 +965,12 @@ namespace XCharts.Runtime
|
||||
return total;
|
||||
}
|
||||
|
||||
public float GetSerieTotalGap<T>(float categoryWidth, float gap, int index) where T : Serie
|
||||
public float GetSerieTotalGap<T>(float categoryWidth, float gap, int index, int gridIndex) where T : Serie
|
||||
{
|
||||
if (index <= 0) return 0;
|
||||
var total = 0f;
|
||||
var count = 0;
|
||||
var totalRealBarCount = GetSerieBarRealCount<T>();
|
||||
var totalRealBarCount = GetSerieBarRealCount<T>(gridIndex);
|
||||
barStackSet.Clear();
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
@@ -934,6 +978,7 @@ namespace XCharts.Runtime
|
||||
if (!serie.show) continue;
|
||||
if (serie is T)
|
||||
{
|
||||
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
|
||||
if (!string.IsNullOrEmpty(serie.stack))
|
||||
{
|
||||
if (barStackSet.Contains(serie.stack)) continue;
|
||||
@@ -983,7 +1028,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
private List<string> tempList = new List<string>();
|
||||
public int GetSerieIndexIfStack<T>(Serie currSerie) where T : Serie
|
||||
public int GetSerieIndexIfStack<T>(Serie currSerie, int gridIndex) where T : Serie
|
||||
{
|
||||
tempList.Clear();
|
||||
int index = 0;
|
||||
@@ -992,6 +1037,7 @@ namespace XCharts.Runtime
|
||||
var serie = m_Series[i];
|
||||
if (!serie.show) continue;
|
||||
if (!(serie is T)) continue;
|
||||
if (!CheckSerieGridIndex(serie, gridIndex)) continue;
|
||||
if (string.IsNullOrEmpty(serie.stack))
|
||||
{
|
||||
if (serie.index == currSerie.index) return index;
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace XCharts.Runtime
|
||||
public partial class BaseChart : BaseGraph, ISerializationCallbackReceiver
|
||||
{
|
||||
[SerializeField] protected string m_ChartName;
|
||||
[SerializeField] protected bool m_UseUtc = true;
|
||||
[SerializeField] protected ThemeStyle m_Theme = new ThemeStyle();
|
||||
[SerializeField] protected Settings m_Settings;
|
||||
[SerializeField] protected DebugInfo m_DebugInfo = new DebugInfo();
|
||||
@@ -204,7 +205,7 @@ namespace XCharts.Runtime
|
||||
protected override void OnValidate()
|
||||
{
|
||||
base.OnValidate();
|
||||
foreach (var handler in m_SerieHandlers) handler.ForceUpdateSerieContext();
|
||||
ResetChartStatus();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -377,7 +378,7 @@ namespace XCharts.Runtime
|
||||
serie.index = i;
|
||||
SetPainterActive(i, true);
|
||||
}
|
||||
if (transform.childCount - 3 != m_PainterTop.transform.GetSiblingIndex())
|
||||
if (m_PainterTop != null && transform.childCount - 3 != m_PainterTop.transform.GetSiblingIndex())
|
||||
{
|
||||
m_PainterTop.transform.SetSiblingIndex(transform.childCount - 3);
|
||||
}
|
||||
@@ -626,6 +627,8 @@ namespace XCharts.Runtime
|
||||
vh.Clear();
|
||||
var maxPainter = settings.maxPainter;
|
||||
var maxSeries = m_Series.Count;
|
||||
if (painter == null || painter.index < 0 || painter.index >= maxPainter)
|
||||
return;
|
||||
var rate = Mathf.CeilToInt(maxSeries * 1.0f / maxPainter);
|
||||
m_PainterUpper.Refresh();
|
||||
m_PainterTop.Refresh();
|
||||
@@ -724,7 +727,7 @@ namespace XCharts.Runtime
|
||||
|
||||
private void InitListForFieldInfos()
|
||||
{
|
||||
if (m_TypeListForSerie.Count != 0) return;
|
||||
if (m_TypeListForSerie.Count != 0 || m_TypeListForComponent.Count != 0) return;
|
||||
m_TypeListForComponent.Clear();
|
||||
m_TypeListForSerie.Clear();
|
||||
var fileds1 = GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
@@ -209,15 +209,25 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
/// <param name="imageType">type of image: png, jpg, exr</param>
|
||||
/// <param name="savePath">save path</param>
|
||||
public void SaveAsImage(string imageType = "png", string savePath = "")
|
||||
/// <param name="exportScale">export resolution scale. 1 means original size</param>
|
||||
/// <param name="useRecursiveBackgroundColor">whether to recursively use lower-level UI background color</param>
|
||||
public void SaveAsImage(string imageType = "png", string savePath = "", float exportScale = 1f,
|
||||
bool useRecursiveBackgroundColor = false)
|
||||
{
|
||||
StartCoroutine(SaveAsImageSync(imageType, savePath));
|
||||
StartCoroutine(SaveAsImageSync(imageType, savePath, exportScale, useRecursiveBackgroundColor));
|
||||
}
|
||||
|
||||
private IEnumerator SaveAsImageSync(string imageType, string path)
|
||||
private IEnumerator SaveAsImageSync(string imageType, string path, float exportScale,
|
||||
bool useRecursiveBackgroundColor)
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
ChartHelper.SaveAsImage(rectTransform, canvas, imageType, path);
|
||||
ChartHelper.SaveAsImage(rectTransform, canvas, imageType, path, exportScale,
|
||||
useRecursiveBackgroundColor);
|
||||
}
|
||||
|
||||
public Vector3 GetTitlePosition(Title title)
|
||||
{
|
||||
return graphPosition + title.location.GetPosition(graphWidth, graphHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,7 @@ namespace XCharts.Runtime
|
||||
/// <summary>
|
||||
/// 获取标记大小的回调。
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public delegate float SymbolSizeFunction(List<double> data);
|
||||
public delegate float SymbolSizeFunction(float defaultSize, SerieData serieData);
|
||||
public delegate void CustomDrawGaugePointerFunction(VertexHelper vh, int serieIndex, int dataIndex, float currentAngle);
|
||||
/// <summary>
|
||||
/// DataZoom的start和end变更时的委托方法。
|
||||
|
||||
@@ -53,6 +53,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public bool InRect(Vector2 local)
|
||||
{
|
||||
return rect.Contains(local);
|
||||
}
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
raycastTarget = false;
|
||||
@@ -183,6 +188,7 @@ namespace XCharts.Runtime
|
||||
public void SetPosition(Vector3 position)
|
||||
{
|
||||
transform.localPosition = position;
|
||||
UpdateRect();
|
||||
}
|
||||
|
||||
public void SetRectPosition(Vector3 position)
|
||||
@@ -264,6 +270,45 @@ namespace XCharts.Runtime
|
||||
m_Width = sizeDelta.x + m_PaddingLeft + m_PaddingRight;
|
||||
m_Height = sizeDelta.y + m_PaddingTop + m_PaddingBottom;
|
||||
objectRect.sizeDelta = new Vector2(m_Width, m_Height);
|
||||
UpdateRect();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRect()
|
||||
{
|
||||
if (m_TextRect == null) return;
|
||||
switch (text.alignment)
|
||||
{
|
||||
case TextAnchor.LowerLeft:
|
||||
rect = new Rect(transform.localPosition.x, transform.localPosition.y, m_Width, m_Height);
|
||||
break;
|
||||
case TextAnchor.UpperLeft:
|
||||
rect = new Rect(transform.localPosition.x, transform.localPosition.y - m_Height, m_Width, m_Height);
|
||||
break;
|
||||
case TextAnchor.MiddleLeft:
|
||||
rect = new Rect(transform.localPosition.x, transform.localPosition.y - m_Height / 2, m_Width, m_Height);
|
||||
break;
|
||||
case TextAnchor.LowerRight:
|
||||
rect = new Rect(transform.localPosition.x - m_Width, transform.localPosition.y, m_Width, m_Height);
|
||||
break;
|
||||
case TextAnchor.UpperRight:
|
||||
rect = new Rect(transform.localPosition.x - m_Width, transform.localPosition.y - m_Height, m_Width, m_Height);
|
||||
break;
|
||||
case TextAnchor.MiddleRight:
|
||||
rect = new Rect(transform.localPosition.x - m_Width, transform.localPosition.y - m_Height / 2, m_Width, m_Height);
|
||||
break;
|
||||
case TextAnchor.LowerCenter:
|
||||
rect = new Rect(transform.localPosition.x - m_Width / 2, transform.localPosition.y, m_Width, m_Height);
|
||||
break;
|
||||
case TextAnchor.UpperCenter:
|
||||
rect = new Rect(transform.localPosition.x - m_Width / 2, transform.localPosition.y - m_Height, m_Width, m_Height);
|
||||
break;
|
||||
case TextAnchor.MiddleCenter:
|
||||
rect = new Rect(transform.localPosition.x - m_Width / 2, transform.localPosition.y - m_Height / 2, m_Width, m_Height);
|
||||
break;
|
||||
default:
|
||||
rect = new Rect(transform.localPosition.x - m_Width / 2, transform.localPosition.y - m_Height / 2, m_Width, m_Height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,11 @@ namespace XCharts.Runtime
|
||||
protected bool m_Refresh;
|
||||
protected Action<VertexHelper, Painter> m_OnPopulateMesh;
|
||||
|
||||
public Action<VertexHelper, Painter> onPopulateMesh { set { m_OnPopulateMesh = value; } }
|
||||
public Action<VertexHelper, Painter> onPopulateMesh
|
||||
{
|
||||
get { return m_OnPopulateMesh; }
|
||||
set { m_OnPopulateMesh = value; }
|
||||
}
|
||||
public int index { get { return m_Index; } set { m_Index = value; } }
|
||||
public Type type { get { return m_Type; } set { m_Type = value; } }
|
||||
public void Refresh()
|
||||
|
||||
@@ -100,9 +100,9 @@ namespace XCharts.Runtime
|
||||
return NumberToStr(value, numericFormatter);
|
||||
}
|
||||
|
||||
public static string NumberToDateStr(double timestamp, string formatter)
|
||||
public static string NumberToDateStr(double timestamp, string formatter, bool local = false)
|
||||
{
|
||||
var dt = NumberToDateTime(timestamp);
|
||||
var dt = NumberToDateTime(timestamp, local);
|
||||
try
|
||||
{
|
||||
return dt.ToString(formatter, ci);
|
||||
@@ -132,11 +132,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public static DateTime NumberToDateTime(double timestamp)
|
||||
public static DateTime NumberToDateTime(double timestamp, bool local = false)
|
||||
{
|
||||
if (!s_TimestampToDateTimeDict.ContainsKey(timestamp))
|
||||
{
|
||||
s_TimestampToDateTimeDict[timestamp] = DateTimeUtil.GetDateTime(timestamp);
|
||||
s_TimestampToDateTimeDict[timestamp] = DateTimeUtil.GetDateTime(timestamp, local);
|
||||
}
|
||||
return s_TimestampToDateTimeDict[timestamp];
|
||||
}
|
||||
@@ -167,7 +167,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (!s_ColorDotStr.ContainsKey(color))
|
||||
{
|
||||
s_ColorDotStr[color] = "<color=#" + ColorToStr(color) + ">● </color>";
|
||||
s_ColorDotStr[color] = "<color=#" + ColorToStr(color) + ">●</color>";
|
||||
}
|
||||
return s_ColorDotStr[color];
|
||||
}
|
||||
@@ -200,7 +200,7 @@ namespace XCharts.Runtime
|
||||
return s_StringIntDict[prefix][suffix];
|
||||
}
|
||||
|
||||
internal static string GetComponentObjectName(MainComponent component)
|
||||
public static string GetComponentObjectName(MainComponent component)
|
||||
{
|
||||
Dictionary<int, string> dict;
|
||||
var type = component.GetType();
|
||||
@@ -224,7 +224,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetAxisLabelName(int index)
|
||||
public static string GetAxisLabelName(int index)
|
||||
{
|
||||
string name;
|
||||
if (!s_AxisLabelName.TryGetValue(index, out name))
|
||||
@@ -239,12 +239,12 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
internal static string GetTypeName<T>()
|
||||
public static string GetTypeName<T>()
|
||||
{
|
||||
return GetTypeName(typeof(T));
|
||||
}
|
||||
|
||||
internal static string GetTypeName(Type type)
|
||||
public static string GetTypeName(Type type)
|
||||
{
|
||||
if (s_TypeName.ContainsKey(type)) return s_TypeName[type];
|
||||
else
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
@@ -204,6 +205,25 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveTMPComponents(GameObject gameObject)
|
||||
{
|
||||
var coms = gameObject.GetComponents<Component>();
|
||||
foreach (var com in coms)
|
||||
{
|
||||
if (com.GetType().FullName.Contains("TMPro"))
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
GameObject.DestroyImmediate(com as UnityEngine.Object);
|
||||
else
|
||||
GameObject.Destroy(com as UnityEngine.Object);
|
||||
#else
|
||||
GameObject.Destroy(com as UnityEngine.Object);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Obsolete("Use EnsureComponent instead")]
|
||||
public static T GetOrAddComponent<T>(Transform transform) where T : Component
|
||||
{
|
||||
@@ -239,7 +259,13 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (gameObject.GetComponent<T>() == null)
|
||||
{
|
||||
return gameObject.AddComponent<T>();
|
||||
var com = gameObject.AddComponent<T>();
|
||||
if (com == null)
|
||||
{
|
||||
RemoveTMPComponents(gameObject);
|
||||
return gameObject.AddComponent<T>();
|
||||
}
|
||||
return com;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -436,23 +462,28 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var textStyle = axis.axisLabel.textStyle;
|
||||
var label = AddChartLabel(name, parent, axis.axisLabel, theme, content, autoColor, autoAlignment);
|
||||
var labelShow = axis.IsNeedShowLabel(index, total);
|
||||
var labelShow = axis.IsNeedShowLabel(index, total, content);
|
||||
label.UpdateIcon(axis.axisLabel.icon, axis.GetIcon(index), iconDefaultColor);
|
||||
label.text.SetActive(labelShow);
|
||||
return label;
|
||||
}
|
||||
|
||||
public static ChartLabel AddChartLabel(string name, Transform parent, LabelStyle labelStyle,
|
||||
ComponentTheme theme, string content, Color autoColor, TextAnchor autoAlignment = TextAnchor.MiddleCenter)
|
||||
ComponentTheme theme, string content, Color autoColor, TextAnchor autoAlignment = TextAnchor.MiddleCenter,
|
||||
bool isObjectAnchor = false)
|
||||
{
|
||||
Vector2 anchorMin, anchorMax, pivot;
|
||||
var sizeDelta = new Vector2(labelStyle.width, labelStyle.height);
|
||||
var textStyle = labelStyle.textStyle;
|
||||
var alignment = textStyle.GetAlignment(autoAlignment);
|
||||
var alignment = isObjectAnchor ? autoAlignment : textStyle.GetAlignment(autoAlignment);
|
||||
UpdateAnchorAndPivotByTextAlignment(alignment, out anchorMin, out anchorMax, out pivot);
|
||||
var labelObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
||||
//ChartHelper.RemoveComponent<Text>(labelObj);
|
||||
var label = EnsureComponent<ChartLabel>(labelObj);
|
||||
if(isObjectAnchor)
|
||||
{
|
||||
UpdateAnchorAndPivotByTextAlignment(textStyle.GetAlignment(autoAlignment), out anchorMin, out anchorMax, out pivot);
|
||||
}
|
||||
label.text = AddTextObject("Text", label.gameObject.transform, anchorMin, anchorMax, pivot,
|
||||
sizeDelta, textStyle, theme, autoColor, autoAlignment, label.text);
|
||||
label.icon = ChartHelper.AddIcon("Icon", label.gameObject.transform, labelStyle.icon);
|
||||
@@ -1030,34 +1061,383 @@ namespace XCharts.Runtime
|
||||
private static extern void Download(string base64str, string fileName);
|
||||
#endif
|
||||
|
||||
public static Texture2D SaveAsImage(RectTransform rectTransform, Canvas canvas, string imageType = "png", string path = "")
|
||||
private static void SetLayerRecursively(GameObject obj, int layer)
|
||||
{
|
||||
if (obj == null) return;
|
||||
obj.layer = layer;
|
||||
var trans = obj.transform;
|
||||
for (int i = 0; i < trans.childCount; i++)
|
||||
{
|
||||
SetLayerRecursively(trans.GetChild(i).gameObject, layer);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CloneChildrenRecursively(Transform source, Transform targetParent, int layer)
|
||||
{
|
||||
if (source == null || targetParent == null) return;
|
||||
for (int i = 0; i < source.childCount; i++)
|
||||
{
|
||||
var child = source.GetChild(i);
|
||||
var childClone = GameObject.Instantiate(child.gameObject, targetParent, false);
|
||||
SetLayerRecursively(childClone, layer);
|
||||
SyncPainterCallbacks(child, childClone.transform);
|
||||
}
|
||||
}
|
||||
|
||||
private static void SyncPainterCallbacks(Transform source, Transform clone)
|
||||
{
|
||||
if (source == null || clone == null) return;
|
||||
var sourcePainter = source.GetComponent<Painter>();
|
||||
var clonePainter = clone.GetComponent<Painter>();
|
||||
if (sourcePainter != null && clonePainter != null)
|
||||
{
|
||||
clonePainter.onPopulateMesh = sourcePainter.onPopulateMesh;
|
||||
clonePainter.index = sourcePainter.index;
|
||||
clonePainter.type = sourcePainter.type;
|
||||
clonePainter.material = sourcePainter.material;
|
||||
clonePainter.Refresh();
|
||||
}
|
||||
var count = Mathf.Min(source.childCount, clone.childCount);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
SyncPainterCallbacks(source.GetChild(i), clone.GetChild(i));
|
||||
}
|
||||
}
|
||||
|
||||
private static void DestroyObject(GameObject obj)
|
||||
{
|
||||
if (obj == null) return;
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
GameObject.DestroyImmediate(obj, true);
|
||||
else
|
||||
GameObject.Destroy(obj);
|
||||
#else
|
||||
GameObject.Destroy(obj);
|
||||
#endif
|
||||
}
|
||||
|
||||
private static byte[] EncodeImage(Texture2D tex, string imageType)
|
||||
{
|
||||
var cam = canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : canvas.worldCamera;
|
||||
var pos = RectTransformUtility.WorldToScreenPoint(cam, rectTransform.position);
|
||||
var width = rectTransform.rect.width * canvas.scaleFactor;
|
||||
var height = rectTransform.rect.height * canvas.scaleFactor;
|
||||
var posX = pos.x + rectTransform.rect.xMin * canvas.scaleFactor;
|
||||
var posY = pos.y + rectTransform.rect.yMin * canvas.scaleFactor;
|
||||
var rect = new Rect(posX, posY, width, height);
|
||||
var tex = new Texture2D((int)width, (int)height, TextureFormat.RGBA32, false);
|
||||
tex.ReadPixels(rect, 0, 0);
|
||||
tex.Apply();
|
||||
byte[] bytes;
|
||||
switch (imageType)
|
||||
{
|
||||
case "png":
|
||||
bytes = tex.EncodeToPNG();
|
||||
break;
|
||||
return tex.EncodeToPNG();
|
||||
case "jpg":
|
||||
bytes = tex.EncodeToJPG();
|
||||
break;
|
||||
return tex.EncodeToJPG();
|
||||
case "exr":
|
||||
bytes = tex.EncodeToEXR();
|
||||
break;
|
||||
return tex.EncodeToEXR();
|
||||
default:
|
||||
Debug.LogError("SaveAsImage ERROR: not support image type:" + imageType);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static float[] GetChartCornerRadius(BaseChart chart, float chartWidth, float chartHeight, float scaleFactor)
|
||||
{
|
||||
if (chart == null || chartWidth <= 0 || chartHeight <= 0)
|
||||
return null;
|
||||
|
||||
var background = chart.GetChartComponent<Background>();
|
||||
if (background == null || background.borderStyle == null || !background.borderStyle.roundedCorner)
|
||||
return null;
|
||||
|
||||
var cornerRadius = background.borderStyle.cornerRadius;
|
||||
if (cornerRadius == null || cornerRadius.Length == 0)
|
||||
return null;
|
||||
|
||||
float brLt = 0, brRt = 0, brRb = 0, brLb = 0;
|
||||
bool needRound = false;
|
||||
UGL.InitCornerRadius(cornerRadius, chartWidth, chartHeight, false, false,
|
||||
ref brLt, ref brRt, ref brRb, ref brLb, ref needRound);
|
||||
|
||||
if (!needRound)
|
||||
return null;
|
||||
|
||||
return new float[]
|
||||
{
|
||||
brLt * scaleFactor,
|
||||
brRt * scaleFactor,
|
||||
brRb * scaleFactor,
|
||||
brLb * scaleFactor
|
||||
};
|
||||
}
|
||||
|
||||
private static float GetRoundedRectCoverage(float x, float y, float width, float height,
|
||||
float radiusLt, float radiusRt, float radiusRb, float radiusLb, float aaWidth = 1f)
|
||||
{
|
||||
if (radiusLb > 0 && x < radiusLb && y < radiusLb)
|
||||
{
|
||||
var dx = x - radiusLb;
|
||||
var dy = y - radiusLb;
|
||||
var dist = Mathf.Sqrt(dx * dx + dy * dy);
|
||||
var delta = radiusLb - dist;
|
||||
if (delta >= aaWidth) return 1f;
|
||||
if (delta <= -aaWidth) return 0f;
|
||||
return Mathf.Clamp01((delta + aaWidth) / (2f * aaWidth));
|
||||
}
|
||||
if (radiusLt > 0 && x < radiusLt && y > height - radiusLt)
|
||||
{
|
||||
var dx = x - radiusLt;
|
||||
var dy = y - (height - radiusLt);
|
||||
var dist = Mathf.Sqrt(dx * dx + dy * dy);
|
||||
var delta = radiusLt - dist;
|
||||
if (delta >= aaWidth) return 1f;
|
||||
if (delta <= -aaWidth) return 0f;
|
||||
return Mathf.Clamp01((delta + aaWidth) / (2f * aaWidth));
|
||||
}
|
||||
if (radiusRt > 0 && x > width - radiusRt && y > height - radiusRt)
|
||||
{
|
||||
var dx = x - (width - radiusRt);
|
||||
var dy = y - (height - radiusRt);
|
||||
var dist = Mathf.Sqrt(dx * dx + dy * dy);
|
||||
var delta = radiusRt - dist;
|
||||
if (delta >= aaWidth) return 1f;
|
||||
if (delta <= -aaWidth) return 0f;
|
||||
return Mathf.Clamp01((delta + aaWidth) / (2f * aaWidth));
|
||||
}
|
||||
if (radiusRb > 0 && x > width - radiusRb && y < radiusRb)
|
||||
{
|
||||
var dx = x - (width - radiusRb);
|
||||
var dy = y - radiusRb;
|
||||
var dist = Mathf.Sqrt(dx * dx + dy * dy);
|
||||
var delta = radiusRb - dist;
|
||||
if (delta >= aaWidth) return 1f;
|
||||
if (delta <= -aaWidth) return 0f;
|
||||
return Mathf.Clamp01((delta + aaWidth) / (2f * aaWidth));
|
||||
}
|
||||
return 1f;
|
||||
}
|
||||
|
||||
private static void ApplyRoundedCornerClip(Texture2D tex, float[] cornerRadii)
|
||||
{
|
||||
if (tex == null || cornerRadii == null || cornerRadii.Length < 4)
|
||||
return;
|
||||
|
||||
var width = tex.width;
|
||||
var height = tex.height;
|
||||
if (width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
var radiusLt = Mathf.Max(0, cornerRadii[0]);
|
||||
var radiusRt = Mathf.Max(0, cornerRadii[1]);
|
||||
var radiusRb = Mathf.Max(0, cornerRadii[2]);
|
||||
var radiusLb = Mathf.Max(0, cornerRadii[3]);
|
||||
if (radiusLt <= 0 && radiusRt <= 0 && radiusRb <= 0 && radiusLb <= 0)
|
||||
return;
|
||||
|
||||
var colors = tex.GetPixels32();
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
var px = x + 0.5f;
|
||||
var py = y + 0.5f;
|
||||
var coverage = GetRoundedRectCoverage(px, py, width, height,
|
||||
radiusLt, radiusRt, radiusRb, radiusLb, 1f);
|
||||
if (coverage <= 0f)
|
||||
{
|
||||
var index = y * width + x;
|
||||
var color = colors[index];
|
||||
color.a = 0;
|
||||
colors[index] = color;
|
||||
}
|
||||
else if (coverage < 1f)
|
||||
{
|
||||
var index = y * width + x;
|
||||
var color = colors[index];
|
||||
color.a = (byte)Mathf.Clamp(Mathf.RoundToInt(color.a * coverage), 0, 255);
|
||||
colors[index] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
tex.SetPixels32(colors);
|
||||
tex.Apply();
|
||||
}
|
||||
|
||||
private static Color32 GetBackgroundColorRecursive(Transform parent)
|
||||
{
|
||||
if (parent == null) return new Color32(255, 255, 255, 255);
|
||||
|
||||
// Try to find Image components with colors in child nodes
|
||||
for (int i = 0; i < parent.childCount; i++)
|
||||
{
|
||||
var child = parent.GetChild(i);
|
||||
var image = child.GetComponent<Image>();
|
||||
if (image != null && image.enabled && child.gameObject.activeInHierarchy)
|
||||
{
|
||||
var color = image.color;
|
||||
if (color.a > 0)
|
||||
{
|
||||
// Found a visible background image
|
||||
color.a = 1f; // Make it fully opaque for proper blending
|
||||
return color;
|
||||
}
|
||||
}
|
||||
// Recursively search child nodes
|
||||
var foundColor = GetBackgroundColorRecursive(child);
|
||||
if (foundColor.a > 0)
|
||||
return foundColor;
|
||||
}
|
||||
|
||||
return Color.white;
|
||||
}
|
||||
|
||||
public static Texture2D SaveAsImage(RectTransform rectTransform, Canvas canvas, string imageType = "png",
|
||||
string path = "", float exportScale = 1f, bool useRecursiveBackgroundColor = false)
|
||||
{
|
||||
if (rectTransform == null || canvas == null)
|
||||
return null;
|
||||
|
||||
var clampedExportScale = Mathf.Max(1f, exportScale);
|
||||
var scaleFactor = canvas.scaleFactor <= 0 ? 1f : canvas.scaleFactor;
|
||||
var outputScaleFactor = scaleFactor * clampedExportScale;
|
||||
var width = Mathf.Max(1, Mathf.CeilToInt(rectTransform.rect.width * outputScaleFactor));
|
||||
var height = Mathf.Max(1, Mathf.CeilToInt(rectTransform.rect.height * outputScaleFactor));
|
||||
var chart = rectTransform.GetComponent<BaseChart>();
|
||||
var cornerRadii = GetChartCornerRadius(chart, rectTransform.rect.width, rectTransform.rect.height, outputScaleFactor);
|
||||
|
||||
Texture2D tex = null;
|
||||
var rt = RenderTexture.GetTemporary(width, height, 24, RenderTextureFormat.ARGB32);
|
||||
var antiAliasing = QualitySettings.antiAliasing > 0 ? QualitySettings.antiAliasing : 4;
|
||||
rt.antiAliasing = Mathf.Clamp(antiAliasing, 1, 8);
|
||||
|
||||
var oldActive = RenderTexture.active;
|
||||
var captureLayer = 31;
|
||||
var rootObj = new GameObject("xcharts_save_image_root");
|
||||
var camObj = new GameObject("xcharts_save_image_camera");
|
||||
var canvasObj = new GameObject("xcharts_save_image_canvas");
|
||||
var contentObj = new GameObject("xcharts_save_image_content", typeof(RectTransform));
|
||||
|
||||
try
|
||||
{
|
||||
SetLayerRecursively(rootObj, captureLayer);
|
||||
SetLayerRecursively(camObj, captureLayer);
|
||||
SetLayerRecursively(canvasObj, captureLayer);
|
||||
SetLayerRecursively(contentObj, captureLayer);
|
||||
|
||||
camObj.transform.SetParent(rootObj.transform, false);
|
||||
var camera = camObj.AddComponent<Camera>();
|
||||
camera.clearFlags = CameraClearFlags.SolidColor;
|
||||
|
||||
// Get background color - try multiple sources for better results
|
||||
Color32 bgColor = new Color32(255, 255, 255, 255);
|
||||
var chartParent = rectTransform.parent;
|
||||
|
||||
// First, try to get from chart's Background component
|
||||
if (chart != null)
|
||||
{
|
||||
bgColor = chart.GetChartBackgroundColor();
|
||||
//bgColor.a = 255;
|
||||
}
|
||||
|
||||
// If enabled, find background color recursively from sibling nodes
|
||||
if (useRecursiveBackgroundColor && (bgColor.a < 255 ||
|
||||
(bgColor.r == 255 && bgColor.g == 255 && bgColor.b == 255)))
|
||||
{
|
||||
var siblingBgColor = GetBackgroundColorRecursive(chartParent);
|
||||
if (siblingBgColor.a > 0)
|
||||
bgColor = siblingBgColor;
|
||||
}
|
||||
|
||||
camera.backgroundColor = bgColor;
|
||||
|
||||
camera.cullingMask = 1 << captureLayer;
|
||||
camera.orthographic = true;
|
||||
camera.orthographicSize = height / 2f;
|
||||
camera.nearClipPlane = -100;
|
||||
camera.farClipPlane = 100;
|
||||
camera.allowHDR = false;
|
||||
camera.allowMSAA = rt.antiAliasing > 1;
|
||||
camera.targetTexture = rt;
|
||||
|
||||
canvasObj.transform.SetParent(rootObj.transform, false);
|
||||
var captureCanvas = canvasObj.AddComponent<Canvas>();
|
||||
captureCanvas.renderMode = RenderMode.ScreenSpaceCamera;
|
||||
captureCanvas.worldCamera = camera;
|
||||
captureCanvas.planeDistance = 1;
|
||||
captureCanvas.pixelPerfect = canvas.pixelPerfect;
|
||||
captureCanvas.sortingOrder = 0;
|
||||
canvasObj.AddComponent<GraphicRaycaster>();
|
||||
|
||||
var canvasRect = canvasObj.GetComponent<RectTransform>();
|
||||
canvasRect.anchorMin = Vector2.zero;
|
||||
canvasRect.anchorMax = Vector2.one;
|
||||
canvasRect.pivot = new Vector2(0.5f, 0.5f);
|
||||
canvasRect.anchoredPosition = Vector2.zero;
|
||||
canvasRect.sizeDelta = new Vector2(width, height);
|
||||
|
||||
contentObj.transform.SetParent(canvasObj.transform, false);
|
||||
var contentRect = contentObj.GetComponent<RectTransform>();
|
||||
contentRect.anchorMin = new Vector2(0.5f, 0.5f);
|
||||
contentRect.anchorMax = new Vector2(0.5f, 0.5f);
|
||||
contentRect.pivot = rectTransform.pivot;
|
||||
contentRect.anchoredPosition = Vector2.zero;
|
||||
contentRect.sizeDelta = rectTransform.rect.size;
|
||||
contentRect.localScale = new Vector3(clampedExportScale, clampedExportScale, 1f);
|
||||
|
||||
// Clone sibling nodes (including background layers below chart)
|
||||
var chartSiblingIndex = rectTransform.GetSiblingIndex();
|
||||
if (chartParent != null)
|
||||
{
|
||||
for (int i = 0; i < chartParent.childCount; i++)
|
||||
{
|
||||
var sibling = chartParent.GetChild(i);
|
||||
// Only clone siblings below the chart (smaller sibling index)
|
||||
if (i < chartSiblingIndex)
|
||||
{
|
||||
var siblingClone = GameObject.Instantiate(sibling.gameObject, contentObj.transform, false);
|
||||
SetLayerRecursively(siblingClone, captureLayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloneChildrenRecursively(rectTransform, contentObj.transform, captureLayer);
|
||||
|
||||
Canvas.ForceUpdateCanvases();
|
||||
camera.Render();
|
||||
|
||||
RenderTexture.active = rt;
|
||||
|
||||
// If exportScale > 1 we want to save the image back to the original logical
|
||||
// size (option B): render at higher density, then downscale to target pixels
|
||||
// so the saved image has original width/height but higher quality.
|
||||
if (clampedExportScale > 1f)
|
||||
{
|
||||
var targetWidth = Mathf.Max(1, Mathf.CeilToInt(rectTransform.rect.width * scaleFactor));
|
||||
var targetHeight = Mathf.Max(1, Mathf.CeilToInt(rectTransform.rect.height * scaleFactor));
|
||||
|
||||
var smallRT = RenderTexture.GetTemporary(targetWidth, targetHeight, 0, rt.format);
|
||||
Graphics.Blit(rt, smallRT);
|
||||
|
||||
RenderTexture.active = smallRT;
|
||||
tex = new Texture2D(targetWidth, targetHeight, TextureFormat.ARGB32, false);
|
||||
tex.ReadPixels(new Rect(0, 0, targetWidth, targetHeight), 0, 0);
|
||||
tex.Apply();
|
||||
RenderTexture.ReleaseTemporary(smallRT);
|
||||
|
||||
var cornerRadiiFinal = GetChartCornerRadius(chart, rectTransform.rect.width, rectTransform.rect.height, scaleFactor);
|
||||
ApplyRoundedCornerClip(tex, cornerRadiiFinal);
|
||||
}
|
||||
else
|
||||
{
|
||||
tex = new Texture2D(width, height, TextureFormat.ARGB32, false);
|
||||
tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
|
||||
tex.Apply();
|
||||
ApplyRoundedCornerClip(tex, cornerRadii);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
RenderTexture.active = oldActive;
|
||||
RenderTexture.ReleaseTemporary(rt);
|
||||
DestroyObject(rootObj);
|
||||
}
|
||||
|
||||
var bytes = EncodeImage(tex, imageType);
|
||||
if (bytes == null)
|
||||
return null;
|
||||
|
||||
var fileName = rectTransform.name + "." + imageType;
|
||||
#if UNITY_WEBGL
|
||||
string base64str = Convert.ToBase64String(bytes);
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace XCharts.Runtime
|
||||
[ExecuteInEditMode]
|
||||
public static class XChartsMgr
|
||||
{
|
||||
public static readonly string version = "3.13.0";
|
||||
public static readonly int versionDate = 20250101;
|
||||
public static readonly string version = "3.15.0";
|
||||
public static readonly int versionDate = 20260301;
|
||||
public static string fullVersion { get { return version + "-" + versionDate; } }
|
||||
|
||||
internal static List<BaseChart> chartList = new List<BaseChart>();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
@@ -6,11 +8,13 @@ namespace XCharts.Runtime
|
||||
[CoordOptions(typeof(GridCoord), typeof(PolarCoord))]
|
||||
[DefaultAnimation(AnimationType.BottomToTop)]
|
||||
[DefaultTooltip(Tooltip.Type.Shadow, Tooltip.Trigger.Axis)]
|
||||
[SerieComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieComponent(typeof(TitleStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataComponent(typeof(ItemStyle), typeof(TitleStyle), typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraField("m_Ignore")]
|
||||
public class Bar : Serie, INeedSerieContainer
|
||||
{
|
||||
public override bool useSortData { get { return realtimeSort; } }
|
||||
|
||||
public int containerIndex { get; internal set; }
|
||||
public int containterInstanceId { get; internal set; }
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace XCharts.Runtime
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
|
||||
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
|
||||
var symbolSize = symbol.GetSize(serieData, chart.theme.serie.lineSymbolSize);
|
||||
serieData.context.highlight = false;
|
||||
serieData.interact.SetValue(ref needAnimation1, symbolSize);
|
||||
}
|
||||
@@ -125,16 +125,17 @@ namespace XCharts.Runtime
|
||||
if (isStack)
|
||||
SeriesHelper.UpdateStackDataList(chart.series, serie, null, m_StackSerieData);
|
||||
|
||||
var barCount = chart.GetSerieBarRealCount<Bar>();
|
||||
var barCount = chart.GetSerieBarRealCount<Bar>(-1);
|
||||
var categoryWidth = m_AngleAxis.IsCategory() ?
|
||||
AxisHelper.GetDataWidth(m_AngleAxis, 360, datas.Count, null) :
|
||||
AxisHelper.GetDataWidth(m_RadiusAxis, m_SeriePolar.context.radius, datas.Count, null);
|
||||
var barGap = chart.GetSerieBarGap<Bar>();
|
||||
var totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap, barCount);
|
||||
var barGap = chart.GetSerieBarGap<Bar>(-1);
|
||||
var totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap, barCount, -1);
|
||||
var barWidth = serie.GetBarWidth(categoryWidth, barCount);
|
||||
var offset = (categoryWidth - totalBarWidth) * 0.5f;
|
||||
var serieReadIndex = chart.GetSerieIndexIfStack<Bar>(serie);
|
||||
float gap = serie.barGap == -1 ? offset : offset + chart.GetSerieTotalGap<Bar>(categoryWidth, barGap, serieReadIndex);
|
||||
var serieReadIndex = chart.GetSerieIndexIfStack<Bar>(serie, -1);
|
||||
float gap = serie.barGap == -1 ? offset :
|
||||
offset + chart.GetSerieTotalGap<Bar>(categoryWidth, barGap, serieReadIndex, -1);
|
||||
|
||||
var areaColor = ColorUtil.clearColor32;
|
||||
var areaToColor = ColorUtil.clearColor32;
|
||||
@@ -157,7 +158,7 @@ namespace XCharts.Runtime
|
||||
angleValue = serieData.GetData(1);
|
||||
if (m_AngleAxis.IsCategory())
|
||||
{
|
||||
start = (float) (startAngle + categoryWidth * angleValue + gap);
|
||||
start = (float)(startAngle + categoryWidth * angleValue + gap);
|
||||
end = start + barWidth;
|
||||
inside = m_SeriePolar.context.insideRadius;
|
||||
if (isStack)
|
||||
@@ -178,7 +179,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
end = start + m_AngleAxis.GetValueLength(angleValue, 360);
|
||||
serieData.context.stackHeight = end - start;
|
||||
inside = m_SeriePolar.context.insideRadius + categoryWidth * (float) radiusValue + gap;
|
||||
inside = m_SeriePolar.context.insideRadius + categoryWidth * (float)radiusValue + gap;
|
||||
outside = inside + barWidth;
|
||||
}
|
||||
serieData.context.startAngle = start;
|
||||
|
||||
@@ -47,12 +47,14 @@ namespace XCharts.Runtime
|
||||
{
|
||||
switch (label.position)
|
||||
{
|
||||
case LabelStyle.Position.Start:
|
||||
case LabelStyle.Position.Bottom:
|
||||
var center = serieData.context.areaCenter;
|
||||
var angle = serieData.context.halfAngle;
|
||||
var radius = serieData.context.insideRadius;
|
||||
return ChartHelper.GetPosition(center, angle, radius);
|
||||
case LabelStyle.Position.Top:
|
||||
case LabelStyle.Position.End:
|
||||
center = serieData.context.areaCenter;
|
||||
angle = serieData.context.halfAngle;
|
||||
radius = serieData.context.outsideRadius;
|
||||
@@ -65,6 +67,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
switch (label.position)
|
||||
{
|
||||
case LabelStyle.Position.Start:
|
||||
case LabelStyle.Position.Bottom:
|
||||
var center = serieData.context.rect.center;
|
||||
if (serie.context.isHorizontal)
|
||||
@@ -73,6 +76,7 @@ namespace XCharts.Runtime
|
||||
return new Vector3(center.x, center.y - serieData.context.rect.height / 2);
|
||||
case LabelStyle.Position.Center:
|
||||
case LabelStyle.Position.Inside:
|
||||
case LabelStyle.Position.Middle:
|
||||
return serieData.context.rect.center;
|
||||
default:
|
||||
return serieData.context.position;
|
||||
@@ -80,6 +84,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
public override Vector3 GetSerieDataTitlePosition(SerieData serieData, TitleStyle titleStyle)
|
||||
{
|
||||
return GetSerieDataLabelPosition(serieData, titleStyle);
|
||||
}
|
||||
|
||||
private void UpdateSerieGridContext()
|
||||
{
|
||||
if (m_SerieGrid == null)
|
||||
@@ -161,13 +170,17 @@ namespace XCharts.Runtime
|
||||
m_SerieGrid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
|
||||
if (m_SerieGrid == null)
|
||||
return;
|
||||
if (serie.useSortData)
|
||||
{
|
||||
SerieHelper.UpdateSerieRuntimeFilterData(serie);
|
||||
}
|
||||
|
||||
var dataZoom = chart.GetDataZoomOfAxis(axis);
|
||||
var showData = serie.GetDataList(dataZoom);
|
||||
var showData = serie.GetDataList(dataZoom, true);
|
||||
|
||||
if (showData.Count <= 0)
|
||||
return;
|
||||
|
||||
var visualMap = chart.GetVisualMapOfSerie(serie);
|
||||
var axisLength = isY ? m_SerieGrid.context.height : m_SerieGrid.context.width;
|
||||
var relativedAxisLength = isY ? m_SerieGrid.context.width : m_SerieGrid.context.height;
|
||||
var axisXY = isY ? m_SerieGrid.context.y : m_SerieGrid.context.x;
|
||||
@@ -176,15 +189,16 @@ namespace XCharts.Runtime
|
||||
if (isStack)
|
||||
SeriesHelper.UpdateStackDataList(chart.series, serie, dataZoom, m_StackSerieData);
|
||||
|
||||
var barCount = chart.GetSerieBarRealCount<Bar>();
|
||||
var barCount = chart.GetSerieBarRealCount<Bar>(m_SerieGrid.index);
|
||||
float categoryWidth = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
|
||||
float relativedCategoryWidth = AxisHelper.GetDataWidth(relativedAxis, relativedAxisLength, showData.Count, dataZoom);
|
||||
float barGap = chart.GetSerieBarGap<Bar>();
|
||||
float totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap, barCount);
|
||||
float barGap = chart.GetSerieBarGap<Bar>(m_SerieGrid.index);
|
||||
float totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap, barCount, m_SerieGrid.index);
|
||||
float barWidth = serie.GetBarWidth(categoryWidth, barCount);
|
||||
float offset = (categoryWidth - totalBarWidth) * 0.5f;
|
||||
var serieReadIndex = chart.GetSerieIndexIfStack<Bar>(serie);
|
||||
float gap = serie.barGap == -1 ? offset : offset + chart.GetSerieTotalGap<Bar>(categoryWidth, barGap, serieReadIndex);
|
||||
var serieReadIndex = chart.GetSerieIndexIfStack<Bar>(serie, m_SerieGrid.index);
|
||||
float gap = serie.barGap == -1 ? offset :
|
||||
offset + chart.GetSerieTotalGap<Bar>(categoryWidth, barGap, serieReadIndex, m_SerieGrid.index);
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow) :
|
||||
showData.Count;
|
||||
@@ -193,15 +207,24 @@ namespace XCharts.Runtime
|
||||
var dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var interactDuration = serie.animation.GetInteractionDuration();
|
||||
var exchangeDuration = serie.animation.GetExchangeDuration();
|
||||
|
||||
var areaColor = ColorUtil.clearColor32;
|
||||
var areaToColor = ColorUtil.clearColor32;
|
||||
var interacting = false;
|
||||
|
||||
axis.context.scaleWidth = categoryWidth;
|
||||
serie.context.isHorizontal = isY;
|
||||
serie.containerIndex = m_SerieGrid.index;
|
||||
serie.containterInstanceId = m_SerieGrid.instanceId;
|
||||
serie.animation.InitProgress(axisXY, axisXY + axisLength);
|
||||
var visualMapDimension = VisualMapHelper.GetDimension(visualMap, defaultDimension);
|
||||
if (visualMap != null && visualMap.show && visualMap.autoMinMax)
|
||||
{
|
||||
double maxValue, minValue;
|
||||
SerieHelper.GetMinMaxData(serie, visualMapDimension, out minValue, out maxValue);
|
||||
VisualMapHelper.SetMinMax(visualMap, minValue, maxValue);
|
||||
}
|
||||
for (int i = serie.minShow; i < maxCount; i++)
|
||||
{
|
||||
var serieData = showData[i];
|
||||
@@ -223,37 +246,55 @@ namespace XCharts.Runtime
|
||||
var borderGap = relativedValue == 0 ? 0 : itemStyle.borderGap;
|
||||
var borderGapAndWidth = borderWidth + borderGap;
|
||||
var backgroundColor = itemStyle.backgroundColor;
|
||||
var backgroundGap = itemStyle.backgroundGap;
|
||||
|
||||
if (!serieData.interact.TryGetColor(ref areaColor, ref areaToColor, ref interacting, interactDuration))
|
||||
{
|
||||
SerieHelper.GetItemColor(out areaColor, out areaToColor, serie, serieData, chart.theme);
|
||||
if (visualMap != null && visualMap.show)
|
||||
{
|
||||
var visualValue = serieData.GetData(visualMapDimension, relativedAxis.inverse);
|
||||
areaColor = visualMap.GetColor(visualValue);
|
||||
areaToColor = areaColor;
|
||||
}
|
||||
serieData.interact.SetColor(ref interacting, areaColor, areaToColor);
|
||||
}
|
||||
|
||||
var pX = 0f;
|
||||
var pY = 0f;
|
||||
UpdateXYPosition(m_SerieGrid, isY, axis, relativedAxis, i, categoryWidth, relativedCategoryWidth, barWidth, isStack, value, ref pX, ref pY);
|
||||
var barHig = 0f;
|
||||
var runtimeBarWidth = barWidth;
|
||||
var runtimeGap = gap;
|
||||
if (serie.ignoreZeroOccupy)
|
||||
{
|
||||
UpdateActiveBarLayout(serie, dataZoom, i, categoryWidth, barGap, runtimeBarWidth, ref runtimeGap);
|
||||
}
|
||||
UpdateXYPosition(m_SerieGrid, isY, axis, relativedAxis, i, categoryWidth, relativedCategoryWidth,
|
||||
runtimeBarWidth, isStack, value, backgroundGap, ref pX, ref pY);
|
||||
if (serie.useSortData)
|
||||
{
|
||||
serieData.context.UpdateExchangePosition(ref pX, ref pY, exchangeDuration);
|
||||
}
|
||||
float barHig;
|
||||
if (isPercentStack)
|
||||
{
|
||||
var valueTotal = chart.GetSerieSameStackTotalValue<Bar>(serie.stack, i);
|
||||
barHig = valueTotal != 0 ? (float)(relativedValue / valueTotal * relativedAxisLength) : 0;
|
||||
var valueTotal = chart.GetSerieSameStackTotalValue<Bar>(serie.stack, i, m_SerieGrid.index);
|
||||
barHig = valueTotal != 0 ? (float)(relativedValue / valueTotal * (relativedAxisLength - 2 * backgroundGap)) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
barHig = AxisHelper.GetAxisValueLength(m_SerieGrid, relativedAxis, relativedCategoryWidth, relativedValue);
|
||||
barHig = AxisHelper.GetAxisValueLength(m_SerieGrid, relativedAxis, relativedCategoryWidth, relativedValue, 2 * backgroundGap);
|
||||
}
|
||||
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||
Vector3 plb, plt, prt, prb, top;
|
||||
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, gap, borderWidth, barWidth, currHig,
|
||||
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, runtimeGap, borderWidth, runtimeBarWidth, currHig,
|
||||
out plb, out plt, out prt, out prb, out top);
|
||||
serieData.context.stackHeight = barHig;
|
||||
serieData.context.position = top;
|
||||
serieData.context.rect = Rect.MinMaxRect(plb.x + borderGapAndWidth, plb.y + borderGapAndWidth,
|
||||
prt.x - borderGapAndWidth, prt.y - borderGapAndWidth);
|
||||
serieData.context.backgroundRect = isY ?
|
||||
Rect.MinMaxRect(m_SerieGrid.context.x, plb.y, m_SerieGrid.context.x + relativedAxisLength, prt.y) :
|
||||
Rect.MinMaxRect(plb.x, m_SerieGrid.context.y, prb.x, m_SerieGrid.context.y + relativedAxisLength);
|
||||
Rect.MinMaxRect(m_SerieGrid.context.x, plb.y - backgroundGap, m_SerieGrid.context.x + relativedAxisLength, prt.y + backgroundGap) :
|
||||
Rect.MinMaxRect(plb.x - backgroundGap, m_SerieGrid.context.y, prb.x + backgroundGap, m_SerieGrid.context.y + relativedAxisLength);
|
||||
|
||||
if (!serie.clip || (serie.clip && m_SerieGrid.Contains(top)))
|
||||
{
|
||||
@@ -271,11 +312,11 @@ namespace XCharts.Runtime
|
||||
{
|
||||
case BarType.Normal:
|
||||
case BarType.Capsule:
|
||||
DrawNormalBar(vh, serie, serieData, itemStyle, backgroundColor, gap, barWidth,
|
||||
DrawNormalBar(vh, serie, serieData, itemStyle, backgroundColor, runtimeGap, runtimeBarWidth,
|
||||
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor, relativedValue);
|
||||
break;
|
||||
case BarType.Zebra:
|
||||
DrawZebraBar(vh, serie, serieData, itemStyle, backgroundColor, gap, barWidth,
|
||||
DrawZebraBar(vh, serie, serieData, itemStyle, backgroundColor, runtimeGap, runtimeBarWidth,
|
||||
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
||||
break;
|
||||
}
|
||||
@@ -296,9 +337,106 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
|
||||
List<string> m_SlotOrder = new List<string>();
|
||||
Dictionary<string, bool> m_ActiveSlot = new Dictionary<string, bool>();
|
||||
private void UpdateActiveBarLayout(Bar currentSerie, DataZoom dataZoom, int dataIndex,
|
||||
float categoryWidth, float barGap, float barWidth, ref float gap)
|
||||
{
|
||||
m_SlotOrder.Clear();
|
||||
m_ActiveSlot.Clear();
|
||||
for (int n = 0; n < chart.series.Count; n++)
|
||||
{
|
||||
var serie = chart.series[n] as Bar;
|
||||
if (serie == null || !serie.show || serie.placeHolder)
|
||||
continue;
|
||||
if (!IsSerieInGrid(serie, m_SerieGrid.index))
|
||||
continue;
|
||||
|
||||
var slotKey = GetBarSlotKey(serie);
|
||||
if (!m_ActiveSlot.ContainsKey(slotKey))
|
||||
{
|
||||
m_ActiveSlot[slotKey] = false;
|
||||
m_SlotOrder.Add(slotKey);
|
||||
}
|
||||
|
||||
if (IsSerieDataActiveForLayout(serie, dataZoom, dataIndex))
|
||||
{
|
||||
m_ActiveSlot[slotKey] = true;
|
||||
}
|
||||
}
|
||||
|
||||
var currentSlotKey = GetBarSlotKey(currentSerie);
|
||||
if (!m_ActiveSlot.ContainsKey(currentSlotKey) || !m_ActiveSlot[currentSlotKey])
|
||||
return;
|
||||
|
||||
var activeCount = 0;
|
||||
var activeSlotIndex = -1;
|
||||
for (int n = 0; n < m_SlotOrder.Count; n++)
|
||||
{
|
||||
var slotKey = m_SlotOrder[n];
|
||||
if (!m_ActiveSlot[slotKey])
|
||||
continue;
|
||||
|
||||
if (slotKey == currentSlotKey)
|
||||
activeSlotIndex = activeCount;
|
||||
|
||||
activeCount++;
|
||||
}
|
||||
|
||||
if (activeCount <= 0 || activeSlotIndex < 0)
|
||||
return;
|
||||
|
||||
var actualGap = ChartHelper.GetActualValue(barGap, barWidth);
|
||||
var totalBarWidth = barGap == -1
|
||||
? barWidth
|
||||
: activeCount * barWidth + (activeCount - 1) * actualGap;
|
||||
var offset = (categoryWidth - totalBarWidth) * 0.5f;
|
||||
gap = barGap == -1
|
||||
? offset
|
||||
: offset + activeSlotIndex * (barWidth + actualGap);
|
||||
}
|
||||
|
||||
private string GetBarSlotKey(Bar serie)
|
||||
{
|
||||
return string.IsNullOrEmpty(serie.stack) ? "s_" + serie.index : "k_" + serie.stack;
|
||||
}
|
||||
|
||||
private bool IsSerieDataActiveForLayout(Bar serie, DataZoom dataZoom, int dataIndex)
|
||||
{
|
||||
var dataList = serie.GetDataList(dataZoom, true);
|
||||
if (dataList == null || dataIndex < 0 || dataIndex >= dataList.Count)
|
||||
return false;
|
||||
|
||||
var serieData = dataList[dataIndex];
|
||||
if (serieData == null || !serieData.show || serie.IsIgnoreValue(serieData))
|
||||
return false;
|
||||
|
||||
if (!serie.ignoreZeroOccupy)
|
||||
return true;
|
||||
|
||||
return !MathUtil.Approximately(serieData.GetData(1), 0);
|
||||
}
|
||||
|
||||
private bool IsSerieInGrid(Bar serie, int gridIndex)
|
||||
{
|
||||
XAxis xAxis;
|
||||
if (chart.TryGetChartComponent<XAxis>(out xAxis, serie.xAxisIndex))
|
||||
{
|
||||
if (xAxis.gridIndex != gridIndex)
|
||||
return false;
|
||||
}
|
||||
YAxis yAxis;
|
||||
if (chart.TryGetChartComponent<YAxis>(out yAxis, serie.yAxisIndex))
|
||||
{
|
||||
if (yAxis.gridIndex != gridIndex)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateXYPosition(GridCoord grid, bool isY, Axis axis, Axis relativedAxis, int i,
|
||||
float categoryWidth, float relativedCategoryWidth, float barWidth, bool isStack,
|
||||
double value, ref float pX, ref float pY)
|
||||
double value, float backgroundGap, ref float pX, ref float pY)
|
||||
{
|
||||
if (isY)
|
||||
{
|
||||
@@ -315,7 +453,7 @@ namespace XCharts.Runtime
|
||||
pY = grid.context.y + valueLen - categoryWidth * 0.5f;
|
||||
}
|
||||
}
|
||||
pX = AxisHelper.GetAxisValuePosition(grid, relativedAxis, relativedCategoryWidth, 0);
|
||||
pX = AxisHelper.GetAxisValuePosition(grid, relativedAxis, relativedCategoryWidth, 0) + backgroundGap;
|
||||
if (isStack)
|
||||
{
|
||||
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
|
||||
@@ -337,7 +475,7 @@ namespace XCharts.Runtime
|
||||
pX = grid.context.x + valueLen - categoryWidth * 0.5f;
|
||||
}
|
||||
}
|
||||
pY = AxisHelper.GetAxisValuePosition(grid, relativedAxis, relativedCategoryWidth, 0);
|
||||
pY = AxisHelper.GetAxisValuePosition(grid, relativedAxis, relativedCategoryWidth, 0) + backgroundGap;
|
||||
if (isStack)
|
||||
{
|
||||
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
|
||||
|
||||
@@ -122,11 +122,11 @@ namespace XCharts.Runtime
|
||||
var relativedAxisLength = isY ? m_SerieGrid.context.width : m_SerieGrid.context.height;
|
||||
var axisXY = isY ? m_SerieGrid.context.y : m_SerieGrid.context.x;
|
||||
|
||||
var barCount = chart.GetSerieBarRealCount<SimplifiedBar>();
|
||||
var barCount = chart.GetSerieBarRealCount<SimplifiedBar>(m_SerieGrid.index);
|
||||
float categoryWidth = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
|
||||
float relativedCategoryWidth = AxisHelper.GetDataWidth(relativedAxis, relativedAxisLength, showData.Count, dataZoom);
|
||||
float barGap = chart.GetSerieBarGap<SimplifiedBar>();
|
||||
float totalBarWidth = chart.GetSerieTotalWidth<SimplifiedBar>(categoryWidth, barGap, barCount);
|
||||
float barGap = chart.GetSerieBarGap<SimplifiedBar>(m_SerieGrid.index);
|
||||
float totalBarWidth = chart.GetSerieTotalWidth<SimplifiedBar>(categoryWidth, barGap, barCount,m_SerieGrid.index);
|
||||
float barWidth = serie.GetBarWidth(categoryWidth, barCount);
|
||||
float offset = (categoryWidth - totalBarWidth) * 0.5f;
|
||||
float barGapWidth = barWidth + barWidth * barGap;
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace XCharts.Runtime
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class CandlestickHandler : SerieHandler<Candlestick>
|
||||
{
|
||||
private GridCoord m_SerieGrid;
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
{
|
||||
DrawCandlestickSerie(vh, serie);
|
||||
@@ -33,37 +34,19 @@ namespace XCharts.Runtime
|
||||
var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
var isEmptyItemFormatter = string.IsNullOrEmpty(newItemFormatter);
|
||||
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = 1;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = 0;
|
||||
param.total = 0;
|
||||
param.color = color;
|
||||
param.marker = newMarker;
|
||||
param.itemFormatter = newItemFormatter;
|
||||
param.numericFormatter = newNumericFormatter;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(serie.serieName);
|
||||
param.columns.Add(string.Empty);
|
||||
|
||||
paramList.Add(param);
|
||||
for (int i = 1; i < 5; i++)
|
||||
if (isEmptyItemFormatter)
|
||||
{
|
||||
param = new SerieParams();
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = i;
|
||||
param.category = category;
|
||||
param.dimension = 1;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = serieData.GetData(i);
|
||||
param.total = SerieHelper.GetMaxData(serie, i);
|
||||
param.value = 0;
|
||||
param.total = 0;
|
||||
param.color = color;
|
||||
param.marker = newMarker;
|
||||
param.itemFormatter = newItemFormatter;
|
||||
@@ -71,10 +54,121 @@ namespace XCharts.Runtime
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(XCSettings.lang.GetCandlestickDimensionName(i - 1));
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
param.columns.Add(serie.serieName);
|
||||
param.columns.Add(string.Empty);
|
||||
|
||||
paramList.Add(param);
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
param = new SerieParams();
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = i;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = serieData.GetData(i);
|
||||
param.total = SerieHelper.GetMaxData(serie, i);
|
||||
param.color = color;
|
||||
param.marker = newMarker;
|
||||
param.itemFormatter = newItemFormatter;
|
||||
param.numericFormatter = newNumericFormatter;
|
||||
param.isSecondaryMark = true;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(XCSettings.lang.GetCandlestickDimensionName(i - 1));
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newItemFormatter = newItemFormatter.Replace("\\n", "\n");
|
||||
var temp = newItemFormatter.Split('\n');
|
||||
foreach (var str in temp)
|
||||
{
|
||||
var param = new SerieParams();
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = 0;
|
||||
param.total = 0;
|
||||
param.color = color;
|
||||
param.marker = newMarker;
|
||||
param.itemFormatter = str;
|
||||
param.numericFormatter = newNumericFormatter;
|
||||
param.isSecondaryMark = false;
|
||||
param.columns.Clear();
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateSerieContext()
|
||||
{
|
||||
if (m_SerieGrid == null)
|
||||
return;
|
||||
|
||||
var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter() && !serie.placeHolder) || m_LegendEnter;
|
||||
var needInteract = false;
|
||||
if (!needCheck)
|
||||
{
|
||||
if (m_LastCheckContextFlag != needCheck)
|
||||
{
|
||||
m_LastCheckContextFlag = needCheck;
|
||||
serie.context.pointerItemDataIndex = -1;
|
||||
serie.context.pointerEnter = false;
|
||||
Color32 color1, toColor1;
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
serieData.context.highlight = false;
|
||||
var state = SerieHelper.GetSerieState(serie, serieData, true);
|
||||
SerieHelper.GetItemColor(out color1, out toColor1, serie, serieData, chart.theme, state);
|
||||
serieData.interact.SetColor(ref needInteract, color1, toColor1);
|
||||
}
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
return;
|
||||
}
|
||||
m_LastCheckContextFlag = needCheck;
|
||||
Color32 color, toColor;
|
||||
if (m_LegendEnter)
|
||||
{
|
||||
serie.context.pointerEnter = true;
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme);
|
||||
serieData.interact.SetColor(ref needInteract, color, toColor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
serie.context.pointerItemDataIndex = -1;
|
||||
serie.context.pointerEnter = false;
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
if (serie.context.pointerAxisDataIndexs.Contains(serieData.index) ||
|
||||
serieData.context.rect.Contains(chart.pointerPos))
|
||||
{
|
||||
serie.context.pointerItemDataIndex = serieData.index;
|
||||
serie.context.pointerEnter = true;
|
||||
serieData.context.highlight = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
serieData.context.highlight = false;
|
||||
}
|
||||
var state = SerieHelper.GetSerieState(serie, serieData, true);
|
||||
SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, state);
|
||||
serieData.interact.SetColor(ref needInteract, color, toColor);
|
||||
}
|
||||
}
|
||||
if (needInteract)
|
||||
{
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,14 +178,13 @@ namespace XCharts.Runtime
|
||||
if (serie.animation.HasFadeOut()) return;
|
||||
XAxis xAxis;
|
||||
YAxis yAxis;
|
||||
GridCoord grid;
|
||||
if (!chart.TryGetChartComponent<XAxis>(out xAxis, serie.xAxisIndex)) return;
|
||||
if (!chart.TryGetChartComponent<YAxis>(out yAxis, serie.yAxisIndex)) return;
|
||||
if (!chart.TryGetChartComponent<GridCoord>(out grid, xAxis.gridIndex)) return;
|
||||
if (!chart.TryGetChartComponent<GridCoord>(out m_SerieGrid, xAxis.gridIndex)) return;
|
||||
var theme = chart.theme;
|
||||
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
|
||||
var showData = serie.GetDataList(dataZoom);
|
||||
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
|
||||
float categoryWidth = AxisHelper.GetDataWidth(xAxis, m_SerieGrid.context.width, showData.Count, dataZoom);
|
||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||
float gap = (categoryWidth - barWidth) / 2;
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
@@ -105,9 +198,9 @@ namespace XCharts.Runtime
|
||||
double yMinValue = yAxis.context.minValue;
|
||||
double yMaxValue = yAxis.context.maxValue;
|
||||
var isYAxis = false;
|
||||
serie.containerIndex = grid.index;
|
||||
serie.containterInstanceId = grid.instanceId;
|
||||
var intensive = grid.context.width / (maxCount - serie.minShow) < 0.6f;
|
||||
serie.containerIndex = m_SerieGrid.index;
|
||||
serie.containterInstanceId = m_SerieGrid.instanceId;
|
||||
var intensive = m_SerieGrid.context.width / (maxCount - serie.minShow) < 0.6f;
|
||||
for (int i = serie.minShow; i < maxCount; i++)
|
||||
{
|
||||
var serieData = showData[i];
|
||||
@@ -129,17 +222,17 @@ namespace XCharts.Runtime
|
||||
(itemStyle.borderWidth == 0 ? theme.serie.candlestickBorderWidth :
|
||||
itemStyle.borderWidth);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
float pX = grid.context.x + i * categoryWidth;
|
||||
float zeroY = grid.context.y + yAxis.context.offset;
|
||||
float pX = xAxis.IsCategory() ? m_SerieGrid.context.x + i * categoryWidth : AxisHelper.GetAxisValuePosition(m_SerieGrid, xAxis, categoryWidth, serieData.GetData(0));
|
||||
float zeroY = m_SerieGrid.context.y + yAxis.context.offset;
|
||||
if (!xAxis.boundaryGap) pX -= categoryWidth / 2;
|
||||
float pY = zeroY;
|
||||
var barHig = 0f;
|
||||
double valueTotal = yMaxValue - yMinValue;
|
||||
var minCut = (yMinValue > 0 ? yMinValue : 0);
|
||||
var minCut = yMinValue > 0 ? yMinValue : 0;
|
||||
if (valueTotal != 0)
|
||||
{
|
||||
barHig = (float)((close - open) / valueTotal * grid.context.height);
|
||||
pY += (float)((open - minCut) / valueTotal * grid.context.height);
|
||||
barHig = (float)((close - open) / valueTotal * m_SerieGrid.context.height);
|
||||
pY += (float)((open - minCut) / valueTotal * m_SerieGrid.context.height);
|
||||
}
|
||||
serieData.context.stackHeight = barHig;
|
||||
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||
@@ -164,11 +257,11 @@ namespace XCharts.Runtime
|
||||
}
|
||||
if (serie.clip)
|
||||
{
|
||||
plb = chart.ClampInGrid(grid, plb);
|
||||
plt = chart.ClampInGrid(grid, plt);
|
||||
prt = chart.ClampInGrid(grid, prt);
|
||||
prb = chart.ClampInGrid(grid, prb);
|
||||
top = chart.ClampInGrid(grid, top);
|
||||
plb = chart.ClampInGrid(m_SerieGrid, plb);
|
||||
plt = chart.ClampInGrid(m_SerieGrid, plt);
|
||||
prt = chart.ClampInGrid(m_SerieGrid, prt);
|
||||
prb = chart.ClampInGrid(m_SerieGrid, prb);
|
||||
top = chart.ClampInGrid(m_SerieGrid, top);
|
||||
}
|
||||
serie.context.dataPoints.Add(top);
|
||||
serie.context.dataIndexs.Add(serieData.index);
|
||||
@@ -181,10 +274,16 @@ namespace XCharts.Runtime
|
||||
var itemWidth = Mathf.Abs(prt.x - plb.x);
|
||||
var itemHeight = Mathf.Abs(plt.y - prb.y);
|
||||
var center = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
|
||||
var lowPos = new Vector3(center.x, zeroY + (float)((lowest - minCut) / valueTotal * grid.context.height));
|
||||
var heighPos = new Vector3(center.x, zeroY + (float)((heighest - minCut) / valueTotal * grid.context.height));
|
||||
var lowPos = new Vector3(center.x, zeroY + (float)((lowest - minCut) / valueTotal * m_SerieGrid.context.height));
|
||||
var heighPos = new Vector3(center.x, zeroY + (float)((heighest - minCut) / valueTotal * m_SerieGrid.context.height));
|
||||
var openCenterPos = new Vector3(center.x, prb.y);
|
||||
var closeCenterPos = new Vector3(center.x, prt.y);
|
||||
|
||||
var rectMinX = Mathf.Min(plb.x, prb.x, plt.x, prt.x);
|
||||
var rectMaxX = Mathf.Max(plb.x, prb.x, plt.x, prt.x);
|
||||
var rectMinY = Mathf.Min(plb.y, prb.y, plt.y, prt.y, lowPos.y, heighPos.y);
|
||||
var rectMaxY = Mathf.Max(plb.y, prb.y, plt.y, prt.y, lowPos.y, heighPos.y);
|
||||
serieData.context.rect = new Rect(rectMinX, rectMinY, rectMaxX - rectMinX, rectMaxY - rectMinY);
|
||||
if (intensive)
|
||||
{
|
||||
UGL.DrawLine(vh, lowPos, heighPos, borderWidth, borderColor);
|
||||
@@ -203,7 +302,7 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
chart.DrawClipPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaColor,
|
||||
serie.clip, grid);
|
||||
serie.clip, m_SerieGrid);
|
||||
}
|
||||
UGL.DrawBorder(vh, center, itemWidth, itemHeight, 2 * borderWidth, borderColor, 0,
|
||||
itemStyle.cornerRadius, isYAxis, 0.5f);
|
||||
|
||||
@@ -33,37 +33,19 @@ namespace XCharts.Runtime
|
||||
var newMarker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
var newItemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
var newNumericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
var isEmptyItemFormatter = string.IsNullOrEmpty(newItemFormatter);
|
||||
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = 1;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = 0;
|
||||
param.total = 0;
|
||||
param.color = color;
|
||||
param.marker = newMarker;
|
||||
param.itemFormatter = newItemFormatter;
|
||||
param.numericFormatter = newNumericFormatter;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(serie.serieName);
|
||||
param.columns.Add(string.Empty);
|
||||
|
||||
paramList.Add(param);
|
||||
for (int i = 1; i < 5; i++)
|
||||
if (isEmptyItemFormatter)
|
||||
{
|
||||
param = new SerieParams();
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = i;
|
||||
param.category = category;
|
||||
param.dimension = 1;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = serieData.GetData(i);
|
||||
param.total = SerieHelper.GetMaxData(serie, i);
|
||||
param.value = 0;
|
||||
param.total = 0;
|
||||
param.color = color;
|
||||
param.marker = newMarker;
|
||||
param.itemFormatter = newItemFormatter;
|
||||
@@ -71,10 +53,56 @@ namespace XCharts.Runtime
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(XCSettings.lang.GetCandlestickDimensionName(i - 1));
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
param.columns.Add(serie.serieName);
|
||||
param.columns.Add(string.Empty);
|
||||
|
||||
paramList.Add(param);
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
param = new SerieParams();
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = i;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = serieData.GetData(i);
|
||||
param.total = SerieHelper.GetMaxData(serie, i);
|
||||
param.color = color;
|
||||
param.marker = newMarker;
|
||||
param.itemFormatter = newItemFormatter;
|
||||
param.numericFormatter = newNumericFormatter;
|
||||
param.isSecondaryMark = true;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(XCSettings.lang.GetCandlestickDimensionName(i - 1));
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newItemFormatter = newItemFormatter.Replace("\\n", "\n");
|
||||
var temp = newItemFormatter.Split('\n');
|
||||
foreach (var str in temp)
|
||||
{
|
||||
var param = new SerieParams();
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = 0;
|
||||
param.total = 0;
|
||||
param.color = color;
|
||||
param.marker = newMarker;
|
||||
param.itemFormatter = str;
|
||||
param.numericFormatter = newNumericFormatter;
|
||||
param.isSecondaryMark = false;
|
||||
param.columns.Clear();
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace XCharts.Runtime
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
|
||||
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
|
||||
var symbolSize = symbol.GetSize(serieData, chart.theme.serie.lineSymbolSize);
|
||||
serieData.context.highlight = false;
|
||||
serieData.interact.SetValue(ref needAnimation1, symbolSize);
|
||||
}
|
||||
|
||||
@@ -59,24 +59,36 @@ namespace XCharts.Runtime
|
||||
var dimension = VisualMapHelper.GetDimension(visualMap, defaultDimension);
|
||||
|
||||
title = serie.serieName;
|
||||
itemFormatter = SerieHelper.GetItemFormatter(serie, null, itemFormatter);
|
||||
numericFormatter = SerieHelper.GetNumericFormatter(serie, null, numericFormatter);
|
||||
marker = SerieHelper.GetItemMarker(serie, null, marker);
|
||||
var color = visualMap.GetColor(value);
|
||||
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = dimension;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.serieData = null;
|
||||
param.color = visualMap.GetColor(value);
|
||||
param.marker = SerieHelper.GetItemMarker(serie, null, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, null, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, null, numericFormatter);
|
||||
param.columns.Clear();
|
||||
if (itemFormatter == null) itemFormatter = "";
|
||||
itemFormatter = itemFormatter.Replace("\\n", "\n");
|
||||
var temp = itemFormatter.Split('\n');
|
||||
for (int i = 0; i < temp.Length; i++)
|
||||
{
|
||||
var formatter = temp[i];
|
||||
var param = i == 0 ? serie.context.param : new SerieParams();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add("count");
|
||||
param.columns.Add(ChartCached.NumberToStr(value, param.numericFormatter));
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = dimension;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.serieData = null;
|
||||
param.color = color;
|
||||
param.marker = marker;
|
||||
param.itemFormatter = formatter;
|
||||
param.numericFormatter = numericFormatter;
|
||||
param.columns.Clear();
|
||||
|
||||
paramList.Add(param);
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add("count");
|
||||
param.columns.Add(ChartCached.NumberToStr(value, param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -96,24 +108,35 @@ namespace XCharts.Runtime
|
||||
category = xAxis.GetData((int)serieData.GetData(0));
|
||||
}
|
||||
title = serie.serieName;
|
||||
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = dimension;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.serieData = serieData;
|
||||
param.color = serieData.context.color;
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
param.columns.Clear();
|
||||
if (itemFormatter == null) itemFormatter = "";
|
||||
itemFormatter = itemFormatter.Replace("\\n", "\n");
|
||||
var temp = itemFormatter.Split('\n');
|
||||
for (int i = 0; i < temp.Length; i++)
|
||||
{
|
||||
var formatter = temp[i];
|
||||
var param = i == 0 ? serie.context.param : new SerieParams();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(category);
|
||||
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(dimension), param.numericFormatter));
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = dimension;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.serieData = serieData;
|
||||
param.color = serieData.context.color;
|
||||
param.marker = marker;
|
||||
param.itemFormatter = formatter;
|
||||
param.numericFormatter = numericFormatter;
|
||||
param.columns.Clear();
|
||||
|
||||
paramList.Add(param);
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(category);
|
||||
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(dimension), param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +259,7 @@ namespace XCharts.Runtime
|
||||
var xValue = serieData.GetData(0);
|
||||
var yValue = serieData.GetData(1);
|
||||
var i = AxisHelper.GetAxisValueSplitIndex(xAxis, xValue, true, xCount);
|
||||
var j = AxisHelper.GetAxisValueSplitIndex(yAxis, yValue,true, yCount);
|
||||
var j = AxisHelper.GetAxisValueSplitIndex(yAxis, yValue, true, yCount);
|
||||
|
||||
if (serie.IsIgnoreValue(serieData, dimension))
|
||||
{
|
||||
@@ -368,7 +391,7 @@ namespace XCharts.Runtime
|
||||
var xValue = serieData.GetData(0);
|
||||
var yValue = serieData.GetData(1);
|
||||
var i = AxisHelper.GetAxisValueSplitIndex(xAxis, xValue, true, xCount);
|
||||
var j = AxisHelper.GetAxisValueSplitIndex(yAxis, yValue,true, yCount);
|
||||
var j = AxisHelper.GetAxisValueSplitIndex(yAxis, yValue, true, yCount);
|
||||
var key = GetGridKey(i, j);
|
||||
var count = 0;
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace XCharts.Runtime
|
||||
var serieData = serie.data[i];
|
||||
var dist = Vector3.Distance(chart.pointerPos, serieData.context.position);
|
||||
var size = SerieHelper.GetSysmbolSize(serie, serieData, themeSymbolSize);
|
||||
var highlight = dist <= size;
|
||||
var highlight = dist <= size * 2.5f;
|
||||
serieData.context.highlight = highlight;
|
||||
var state = SerieHelper.GetSerieState(serie, serieData, true);
|
||||
size = SerieHelper.GetSysmbolSize(serie, serieData, themeSymbolSize, state);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace XCharts.Runtime
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
|
||||
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
|
||||
var symbolSize = symbol.GetSize(serieData, chart.theme.serie.lineSymbolSize);
|
||||
serieData.context.highlight = false;
|
||||
serieData.interact.SetValue(ref needAnimation1, symbolSize);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace XCharts.Runtime
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
|
||||
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
|
||||
var symbolSize = symbol.GetSize(serieData, chart.theme.serie.lineSymbolSize);
|
||||
serieData.context.highlight = false;
|
||||
serieData.interact.SetValue(ref needAnimation1, symbolSize);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,21 @@ using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
|
||||
public enum PieType
|
||||
{
|
||||
/// <summary>
|
||||
/// solid pie chart - default fill style.
|
||||
/// ||实心饼图 - 默认填充样式
|
||||
/// </summary>
|
||||
Solid,
|
||||
|
||||
/// <summary>
|
||||
/// wireframe pie chart - only show the outline wireframe.
|
||||
/// ||线框饼图 - 仅显示轮廓线框
|
||||
/// </summary>
|
||||
Wireframe
|
||||
}
|
||||
[System.Serializable]
|
||||
[SerieConvert(typeof(Line), typeof(Bar))]
|
||||
[SerieHandler(typeof(PieHandler), true)]
|
||||
@@ -12,10 +27,20 @@ namespace XCharts.Runtime
|
||||
public class Pie : Serie
|
||||
{
|
||||
[SerializeField][Since("v3.8.1")] private bool m_RadiusGradient = false;
|
||||
[SerializeField][Since("v3.15.0")] private PieType m_PieType = PieType.Solid;
|
||||
|
||||
public override SerieColorBy defaultColorBy { get { return SerieColorBy.Data; } }
|
||||
public override bool titleJustForSerie { get { return true; } }
|
||||
|
||||
/// <summary>
|
||||
/// Pie chart type.
|
||||
/// || 饼图类型。
|
||||
/// </summary>
|
||||
public PieType pieType
|
||||
{
|
||||
get { return m_PieType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PieType, value)) { SetVerticesDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to use gradient color in pie chart.
|
||||
/// || 是否开启半径方向的渐变效果。
|
||||
|
||||
@@ -271,6 +271,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
var offset = 0f;
|
||||
var interactOffset = serie.animation.interaction.GetOffset(serie.context.outsideRadius);
|
||||
serieData.context.insideRadius = serie.context.insideRadius;
|
||||
if (serie.pieClickOffset && (serieData.selected || serieData.context.selected))
|
||||
{
|
||||
offset += interactOffset;
|
||||
@@ -358,7 +359,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, null);
|
||||
var fillColor = ChartHelper.IsClearColor(itemStyle.backgroundColor) ?
|
||||
(Color32)chart.theme.legend.unableColor : itemStyle.backgroundColor;
|
||||
(Color32)chart.theme.legend.inactiveColor : itemStyle.backgroundColor;
|
||||
UGL.DrawDoughnut(vh, serie.context.center, serie.context.insideRadius,
|
||||
serie.context.outsideRadius, fillColor, fillColor, Color.clear, 0,
|
||||
360, itemStyle.borderWidth, itemStyle.borderColor, serie.gap / 2, chart.settings.cicleSmoothness,
|
||||
@@ -381,8 +382,6 @@ namespace XCharts.Runtime
|
||||
var needOffset = (serie.pieClickOffset && (serieData.selected || serieData.context.selected));
|
||||
var offsetCenter = needOffset ? serieData.context.offsetCenter : serie.context.center;
|
||||
|
||||
var borderWidth = itemStyle.borderWidth;
|
||||
var borderColor = itemStyle.borderColor;
|
||||
|
||||
var progress = AnimationStyleHelper.CheckDataAnimation(chart, serie, n, 1);
|
||||
var insideRadius = serieData.context.insideRadius * progress;
|
||||
@@ -398,6 +397,17 @@ namespace XCharts.Runtime
|
||||
serieData.interact.SetPosition(ref interacting, offsetCenter);
|
||||
}
|
||||
}
|
||||
var borderWidth = itemStyle.borderWidth;
|
||||
var borderColor = itemStyle.GetBorderColor(color);
|
||||
if (serie.pieType == PieType.Wireframe)
|
||||
{
|
||||
color = ColorUtil.clearColor32;
|
||||
toColor = ColorUtil.clearColor32;
|
||||
if (borderWidth <= 0)
|
||||
{
|
||||
borderWidth = 4;
|
||||
}
|
||||
}
|
||||
var drawEndDegree = serieData.context.currentAngle;
|
||||
var needRoundCap = serie.roundCap && insideRadius > 0;
|
||||
UGL.DrawDoughnut(vh, offsetCenter, insideRadius,
|
||||
@@ -545,10 +555,11 @@ namespace XCharts.Runtime
|
||||
|
||||
var dist = Vector2.Distance(local, serie.context.center);
|
||||
var interactOffset = serie.animation.interaction.GetOffset(serie.context.outsideRadius);
|
||||
var maxRadius = serie.context.outsideRadius + 2 * interactOffset;
|
||||
if (dist < serie.context.insideRadius || dist > maxRadius)
|
||||
var maxRadius = serie.context.outsideRadius + interactOffset;
|
||||
if (dist < serie.context.insideRadius - interactOffset || dist > maxRadius)
|
||||
{
|
||||
return -1;
|
||||
|
||||
}
|
||||
var dir = local - new Vector2(serie.context.center.x, serie.context.center.y);
|
||||
var angle = ChartHelper.GetAngle360(Vector2.up, dir);
|
||||
for (int i = 0; i < serie.data.Count; i++)
|
||||
@@ -559,7 +570,8 @@ namespace XCharts.Runtime
|
||||
var ndist = (serieData.selected || serieData.context.selected) ?
|
||||
Vector2.Distance(local, serieData.context.offsetCenter) :
|
||||
dist;
|
||||
if (ndist >= serieData.context.insideRadius && ndist <= serieData.context.outsideRadius)
|
||||
ndist = dist;
|
||||
if (ndist >= serieData.context.insideRadius - interactOffset && ndist <= serieData.context.outsideRadius)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -59,31 +59,63 @@ namespace XCharts.Runtime
|
||||
var colorIndex = serie.colorByData ? chart.GetLegendRealShowNameIndex(serieData.legendName) : serie.context.colorIndex;
|
||||
SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, colorIndex, SerieState.Normal);
|
||||
title = serieData.name;
|
||||
for (int i = 0; i < serieData.data.Count; i++)
|
||||
|
||||
itemFormatter = SerieHelper.GetItemFormatter(serie, null, itemFormatter);
|
||||
numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
if (string.IsNullOrEmpty(itemFormatter))
|
||||
{
|
||||
var indicator = radar.GetIndicator(i);
|
||||
if (indicator == null) continue;
|
||||
for (int i = 0; i < serieData.data.Count; i++)
|
||||
{
|
||||
var indicator = radar.GetIndicator(i);
|
||||
if (indicator == null) continue;
|
||||
|
||||
var param = new SerieParams();
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = i;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = serieData.GetData(i);
|
||||
param.total = indicator.max;
|
||||
param.color = color;
|
||||
param.category = radar.GetIndicatorName(i);
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
param.columns.Clear();
|
||||
var param = new SerieParams();
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = i;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = serieData.GetData(i);
|
||||
param.total = indicator.max;
|
||||
param.color = color;
|
||||
param.category = radar.GetIndicatorName(i);
|
||||
param.marker = marker;
|
||||
param.itemFormatter = itemFormatter;
|
||||
param.numericFormatter = numericFormatter;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(indicator.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(i), param.numericFormatter));
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(indicator.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(i), param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itemFormatter = itemFormatter.Replace("\\n", "\n");
|
||||
var temp = itemFormatter.Split('\n');
|
||||
for (int i = 0; i < temp.Length; i++)
|
||||
{
|
||||
var formatter = temp[i];
|
||||
var param = i == 0 ? serie.context.param : new SerieParams();
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.dimension = i;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = serieData.GetData(i);
|
||||
param.total = serie.yTotal;
|
||||
param.color = color;
|
||||
param.category = radar.GetIndicatorName(i);
|
||||
param.marker = marker;
|
||||
param.itemFormatter = formatter;
|
||||
param.numericFormatter = numericFormatter;
|
||||
param.columns.Clear();
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +155,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var serieData = serie.data[i];
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
|
||||
var symbolSize = symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
|
||||
var symbolSize = symbol.GetSize(serieData, chart.theme.serie.lineSymbolSize);
|
||||
if (m_LegendEnter)
|
||||
{
|
||||
serieData.context.highlight = true;
|
||||
@@ -284,7 +316,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
}
|
||||
if (max - min == 0) continue;
|
||||
var radius = (float) (m_RadarCoord.context.dataRadius * (value - min) / (max - min));
|
||||
var radius = (float)(m_RadarCoord.context.dataRadius * (value - min) / (max - min));
|
||||
var currAngle = startAngle + (n + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
|
||||
radius *= rate;
|
||||
if (n == 0)
|
||||
@@ -415,7 +447,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
lineColor = m_RadarCoord.outRangeColor;
|
||||
}
|
||||
var radius = (float) (max < 0 ? m_RadarCoord.context.dataRadius - m_RadarCoord.context.dataRadius * value / max :
|
||||
var radius = (float)(max < 0 ? m_RadarCoord.context.dataRadius - m_RadarCoord.context.dataRadius * value / max :
|
||||
m_RadarCoord.context.dataRadius * value / max);
|
||||
var currAngle = startAngle + (index + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
|
||||
radius *= rate;
|
||||
|
||||
@@ -86,27 +86,37 @@ namespace XCharts.Runtime
|
||||
return;
|
||||
Color32 color, toColor;
|
||||
SerieHelper.GetItemColor(out color, out toColor, serie, serieData, chart.theme, dataIndex);
|
||||
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = defaultDimension;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = serieData.GetData(0);
|
||||
param.total = serieData.GetData(1);
|
||||
param.color = color;
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
param.columns.Clear();
|
||||
if (itemFormatter == null) itemFormatter = "";
|
||||
itemFormatter = itemFormatter.Replace("\\n", "\n");
|
||||
var temp = itemFormatter.Split('\n');
|
||||
for (int i = 0; i < temp.Length; i++)
|
||||
{
|
||||
var formatter = temp[i];
|
||||
var param = i == 0 ? serie.context.param : new SerieParams();
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = defaultDimension;
|
||||
param.serieData = serieData;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.value = serieData.GetData(0);
|
||||
param.total = serieData.GetData(1);
|
||||
param.color = color;
|
||||
param.marker = marker;
|
||||
param.itemFormatter = formatter;
|
||||
param.numericFormatter = numericFormatter;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(serieData.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(serieData.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(param.value, param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 GetLabelLineEndPosition(Serie serie, SerieData serieData, LabelLine labelLine)
|
||||
|
||||
@@ -29,25 +29,38 @@ namespace XCharts.Runtime
|
||||
|
||||
title = serie.serieName;
|
||||
|
||||
var param = serie.context.param;
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = 1;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.serieData = serieData;
|
||||
param.color = chart.GetMarkColor(serie, serieData);
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
param.columns.Clear();
|
||||
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
var color = chart.GetMarkColor(serie, serieData);
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
if (!string.IsNullOrEmpty(serieData.name))
|
||||
param.columns.Add(serieData.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(1), param.numericFormatter));
|
||||
if (itemFormatter == null) itemFormatter = "";
|
||||
itemFormatter = itemFormatter.Replace("\\n", "\n");
|
||||
var temp = itemFormatter.Split('\n');
|
||||
for (int i = 0; i < temp.Length; i++)
|
||||
{
|
||||
var formatter = temp[i];
|
||||
var param = i == 0 ? serie.context.param : new SerieParams();
|
||||
|
||||
paramList.Add(param);
|
||||
param.serieName = serie.serieName;
|
||||
param.serieIndex = serie.index;
|
||||
param.category = category;
|
||||
param.dimension = 1;
|
||||
param.dataCount = serie.dataCount;
|
||||
param.serieData = serieData;
|
||||
param.color = color;
|
||||
param.marker = marker;
|
||||
param.itemFormatter = formatter;
|
||||
param.numericFormatter = numericFormatter;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
if (!string.IsNullOrEmpty(serieData.name))
|
||||
param.columns.Add(serieData.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(1), param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
@@ -153,6 +166,8 @@ namespace XCharts.Runtime
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
|
||||
if (!symbol.ShowSymbol(serieData.index, maxCount))
|
||||
continue;
|
||||
if (serie.IsIgnoreValue(serieData))
|
||||
continue;
|
||||
|
||||
var state = SerieHelper.GetSerieState(serie, serieData, true);
|
||||
|
||||
|
||||
@@ -264,6 +264,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private float m_BarGap = 0.1f;
|
||||
[SerializeField] private float m_BarZebraWidth = 4f;
|
||||
[SerializeField] private float m_BarZebraGap = 2f;
|
||||
[SerializeField] [Since("v3.15.0")]private bool m_IgnoreZeroOccupy = false;
|
||||
|
||||
[SerializeField] private float m_Min;
|
||||
[SerializeField] private float m_Max;
|
||||
@@ -305,6 +306,7 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private float m_Top;
|
||||
[SerializeField] private float m_Bottom;
|
||||
[SerializeField] private bool m_InsertDataToHead;
|
||||
[SerializeField][Since("v3.14.0")] private bool m_RealtimeSort = false;
|
||||
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
|
||||
[SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
|
||||
@@ -631,7 +633,8 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 斑马线的粗细。
|
||||
/// The width of zebra bar. It is the width of each zebra stripe. When the value is 0, there is no zebra stripe.
|
||||
/// ||斑马线的粗细。
|
||||
/// </summary>
|
||||
public float barZebraWidth
|
||||
{
|
||||
@@ -639,13 +642,24 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarZebraWidth, value < 0 ? 0 : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 斑马线的间距。
|
||||
/// The gap of zebra bar. It is the distance between two zebra stripes. When the value is 0, there is no gap between stripes.
|
||||
/// ||斑马线的间距。
|
||||
/// </summary>
|
||||
public float barZebraGap
|
||||
{
|
||||
get { return m_BarZebraGap; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarZebraGap, value < 0 ? 0 : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to ignore the zero value bar occupy. When enabled, the bar with zero value will not occupy space,
|
||||
/// and the gap between bars will be automatically adjusted according to the actual displayed bars. Generally used in bar chart.
|
||||
/// ||柱图是否忽略值为0的柱子占位。开启后,值为0的柱子将不会占用空间,柱子之间的间距会根据实际显示的柱子自动调整。一般用在柱状图中。
|
||||
/// </summary>
|
||||
public bool ignoreZeroOccupy
|
||||
{
|
||||
get { return m_IgnoreZeroOccupy; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_IgnoreZeroOccupy, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether offset when mouse click pie chart item.
|
||||
@@ -983,6 +997,15 @@ namespace XCharts.Runtime
|
||||
set { if (PropertyUtil.SetStruct(ref m_MinShowLabelValue, value)) { SetVerticesDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to enable realtime sorting, which is used for bar-racing effect. Currently only available in Bar.
|
||||
/// ||是否开启实时排序,用来实现动态排序图效果。目前仅在Bar中生效。
|
||||
/// </summary>
|
||||
public bool realtimeSort
|
||||
{
|
||||
get { return m_RealtimeSort; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_RealtimeSort, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||
/// </summary>
|
||||
public List<SerieData> data { get { return m_Data; } }
|
||||
@@ -1327,6 +1350,7 @@ namespace XCharts.Runtime
|
||||
m_Data.RemoveAt(index);
|
||||
m_NeedUpdateFilterData = true;
|
||||
labelDirty = true;
|
||||
titleDirty = true;
|
||||
dataDirty = true;
|
||||
}
|
||||
}
|
||||
@@ -1353,6 +1377,7 @@ namespace XCharts.Runtime
|
||||
SetVerticesDirty();
|
||||
CheckDataName(dataName);
|
||||
labelDirty = true;
|
||||
titleDirty = true;
|
||||
dataDirty = true;
|
||||
return serieData;
|
||||
}
|
||||
@@ -1367,6 +1392,8 @@ namespace XCharts.Runtime
|
||||
context.totalDataIndex++;
|
||||
SetVerticesDirty();
|
||||
dataDirty = true;
|
||||
labelDirty = true;
|
||||
titleDirty = true;
|
||||
m_NeedUpdateFilterData = true;
|
||||
}
|
||||
|
||||
@@ -1401,6 +1428,7 @@ namespace XCharts.Runtime
|
||||
SetVerticesDirty();
|
||||
CheckDataName(dataName);
|
||||
labelDirty = true;
|
||||
titleDirty = true;
|
||||
return serieData;
|
||||
}
|
||||
|
||||
@@ -1433,6 +1461,7 @@ namespace XCharts.Runtime
|
||||
SetVerticesDirty();
|
||||
CheckDataName(dataName);
|
||||
labelDirty = true;
|
||||
titleDirty = true;
|
||||
return serieData;
|
||||
}
|
||||
|
||||
@@ -1467,6 +1496,7 @@ namespace XCharts.Runtime
|
||||
SetVerticesDirty();
|
||||
CheckDataName(dataName);
|
||||
labelDirty = true;
|
||||
titleDirty = true;
|
||||
return serieData;
|
||||
}
|
||||
}
|
||||
@@ -1502,6 +1532,7 @@ namespace XCharts.Runtime
|
||||
SetVerticesDirty();
|
||||
CheckDataName(dataName);
|
||||
labelDirty = true;
|
||||
titleDirty = true;
|
||||
return serieData;
|
||||
}
|
||||
}
|
||||
@@ -1740,7 +1771,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
/// <returns></returns>
|
||||
public List<SerieData> GetDataList(DataZoom dataZoom = null)
|
||||
public List<SerieData> GetDataList(DataZoom dataZoom = null, bool sorted = false)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.enable &&
|
||||
(dataZoom.IsContainsXAxis(xAxisIndex) || dataZoom.IsContainsYAxis(yAxisIndex)))
|
||||
@@ -1750,7 +1781,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
return useSortData && context.sortedData.Count > 0 ? context.sortedData : m_Data;
|
||||
return useSortData && sorted && context.sortedData.Count > 0 ? context.sortedData : m_Data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1795,6 +1826,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
SetVerticesDirty();
|
||||
dataDirty = true;
|
||||
titleDirty = true;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
@@ -2019,6 +2051,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public void AnimationFadeIn()
|
||||
{
|
||||
if (dataCount <= 0) return;
|
||||
ResetInteract();
|
||||
if (animation.enable) animation.FadeIn();
|
||||
SetVerticesDirty();
|
||||
@@ -2029,6 +2062,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public void AnimationFadeOut()
|
||||
{
|
||||
if (dataCount <= 0) return;
|
||||
ResetInteract();
|
||||
if (animation.enable) animation.FadeOut();
|
||||
SetVerticesDirty();
|
||||
@@ -2039,6 +2073,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public void AnimationPause()
|
||||
{
|
||||
if (dataCount <= 0) return;
|
||||
if (animation.enable) animation.Pause();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
@@ -2048,6 +2083,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public void AnimationResume()
|
||||
{
|
||||
if (dataCount <= 0) return;
|
||||
if (animation.enable) animation.Resume();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
@@ -2057,6 +2093,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public void AnimationReset()
|
||||
{
|
||||
if (dataCount <= 0) return;
|
||||
if (animation.enable) animation.Reset();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
@@ -2066,6 +2103,7 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public void AnimationRestart()
|
||||
{
|
||||
if (dataCount <= 0) return;
|
||||
if (animation.enable) animation.Restart();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ namespace XCharts.Runtime
|
||||
|
||||
public ChartLabel labelObject { get; set; }
|
||||
public ChartLabel titleObject { get; set; }
|
||||
public int sortIndex { get; set; }
|
||||
|
||||
private bool m_Show = true;
|
||||
/// <summary>
|
||||
@@ -644,11 +645,12 @@ namespace XCharts.Runtime
|
||||
/// the maxinum value.
|
||||
/// ||最大值。
|
||||
/// </summary>
|
||||
public double GetMaxData(bool inverse = false)
|
||||
public double GetMaxData(bool inverse = false, int startDimensionIndex = 0)
|
||||
{
|
||||
if (m_Data.Count == 0) return 0;
|
||||
var temp = double.MinValue;
|
||||
for (int i = 0; i < m_Data.Count; i++)
|
||||
if (startDimensionIndex < 0) startDimensionIndex = 0;
|
||||
for (int i = startDimensionIndex; i < m_Data.Count; i++)
|
||||
{
|
||||
var value = GetData(i, inverse);
|
||||
if (value > temp) temp = value;
|
||||
@@ -660,11 +662,12 @@ namespace XCharts.Runtime
|
||||
/// the mininum value.
|
||||
/// ||最小值。
|
||||
/// </summary>
|
||||
public double GetMinData(bool inverse = false)
|
||||
public double GetMinData(bool inverse = false, int startDimensionIndex = 0)
|
||||
{
|
||||
if (m_Data.Count == 0) return 0;
|
||||
var temp = double.MaxValue;
|
||||
for (int i = 0; i < m_Data.Count; i++)
|
||||
if (startDimensionIndex < 0) startDimensionIndex = 0;
|
||||
for (int i = startDimensionIndex; i < m_Data.Count; i++)
|
||||
{
|
||||
var value = GetData(i, inverse);
|
||||
if (value < temp) temp = value;
|
||||
@@ -758,17 +761,18 @@ namespace XCharts.Runtime
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void SetLabelActive(bool flag)
|
||||
public void SetLabelActive(bool flag, bool force = false)
|
||||
{
|
||||
if (labelObject != null) labelObject.SetActive(flag);
|
||||
if (labelObject != null) labelObject.SetActive(flag, force);
|
||||
foreach (var labelObject in context.dataLabels)
|
||||
{
|
||||
labelObject.SetActive(false);
|
||||
labelObject.SetActive(flag, force);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetIconActive(bool flag)
|
||||
{
|
||||
if (labelObject != null) labelObject.SetActive(flag);
|
||||
if (labelObject != null) labelObject.SetIconActive(flag);
|
||||
}
|
||||
|
||||
public void SetPolygon(params Vector2[] points)
|
||||
|
||||
@@ -35,6 +35,19 @@ namespace XCharts.Runtime
|
||||
public float offsetRadius;
|
||||
public float outsideRadius;
|
||||
public Vector3 position;
|
||||
/// <summary>
|
||||
/// is the exchange animation end.
|
||||
/// ||交换动画是否结束。
|
||||
/// </summary>
|
||||
public bool exchangeEnd;
|
||||
/// <summary>
|
||||
/// the current position of the exchange animation.
|
||||
/// ||交换动画的当前位置。
|
||||
/// </summary>
|
||||
public Vector3 exchangePosition;
|
||||
private float exchangeStartTime;
|
||||
private Vector3 exchangeStartPosition;
|
||||
private Vector3 exchangeEndPosition;
|
||||
public List<Vector3> dataPoints = new List<Vector3>();
|
||||
public List<ChartLabel> dataLabels = new List<ChartLabel>();
|
||||
public List<SerieData> children = new List<SerieData>();
|
||||
@@ -77,9 +90,61 @@ namespace XCharts.Runtime
|
||||
symbol = null;
|
||||
rect = Rect.zero;
|
||||
subRect = Rect.zero;
|
||||
exchangeEnd = true;
|
||||
exchangeStartPosition = Vector3.zero;
|
||||
exchangePosition = Vector3.zero;
|
||||
exchangeEndPosition = Vector3.zero;
|
||||
children.Clear();
|
||||
dataPoints.Clear();
|
||||
dataLabels.Clear();
|
||||
}
|
||||
|
||||
public void UpdateExchangePosition(ref float x, ref float y, float totalTime)
|
||||
{
|
||||
if (exchangeEndPosition.x != x || exchangeEndPosition.y != y)
|
||||
{
|
||||
if (exchangeStartPosition == Vector3.zero || Time.time - exchangeStartTime < 0.1f)
|
||||
{
|
||||
exchangeEnd = true;
|
||||
exchangeStartTime = Time.time;
|
||||
exchangeEndPosition.x = x;
|
||||
exchangeEndPosition.y = y;
|
||||
exchangeStartPosition = exchangeEndPosition;
|
||||
exchangePosition = exchangeEndPosition;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
exchangeEnd = false;
|
||||
exchangeStartTime = Time.time;
|
||||
exchangeStartPosition = exchangePosition;
|
||||
exchangeEndPosition.x = x;
|
||||
exchangeEndPosition.y = y;
|
||||
}
|
||||
}
|
||||
if (exchangeStartPosition == exchangeEndPosition)
|
||||
{
|
||||
exchangeEnd = true;
|
||||
exchangePosition = exchangeEndPosition;
|
||||
x = exchangePosition.x;
|
||||
y = exchangePosition.y;
|
||||
return;
|
||||
}
|
||||
var spendTime = Time.time - exchangeStartTime;
|
||||
totalTime /= 1000;
|
||||
if (spendTime >= totalTime)
|
||||
{
|
||||
exchangeEnd = true;
|
||||
exchangeStartPosition = exchangeEndPosition;
|
||||
exchangePosition = exchangeEndPosition;
|
||||
x = exchangePosition.x;
|
||||
y = exchangePosition.y;
|
||||
return;
|
||||
}
|
||||
exchangePosition = Vector3.Lerp(exchangeStartPosition, exchangeEndPosition, spendTime / totalTime);
|
||||
x = exchangePosition.x;
|
||||
y = exchangePosition.y;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||