diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 884a6e9d..deb70662 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -10,4 +10,4 @@ liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
-custom: ['https://www.paypal.com/paypalme/monitor1394','https://github.com/XCharts-Team/XCharts/blob/master/Documentation/res/alipay.png']
+custom: ['https://www.paypal.me/monitor1394','https://github.com/XCharts-Team/XCharts/blob/master/Documentation/res/alipay.png','https://github.com/XCharts-Team/XCharts/blob/master/Documentation/res/wechat.png']
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a290019a..18ac27a7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,6 +52,8 @@
## master
+* (2022.05.06) 修复代码动态创建图表异常的问题
+
## v3.0.0-preivew9
* (2022.05.06) 发布`v3.0.0-preivew9`版本
diff --git a/Documentation/SUPPORT.md b/Documentation/SUPPORT.md
index 8b7ad6a3..8ed7384b 100644
--- a/Documentation/SUPPORT.md
+++ b/Documentation/SUPPORT.md
@@ -1,40 +1,74 @@
-## 技术支持
+# 技术支持
-如需技术支持,可订阅VIP服务。扫后面的支付宝二维码后可加VIP群(`867291970`,验证信息请输入支付宝账号)。企业VIP可加官方群私聊群主了解详情。
+如需技术支持,可订阅`个人VIP`服务。扫后面的二维码后可加VIP群`867291970`,验证信息请输入付费的账号。 企业商务合作可联系QQ:3525422251(XCharts技术支持)。
## 订阅服务
-| |免费用户|付费咨询|个人`1`年`VIP`|个人`2`年`VIP` | 个人长期`VIP` |
-| ----- |--|--|--|--|--|
-| 订阅费用 | -- | `98`¥ | `298`¥ | `498`¥ | `888`¥ |
-| 席位时长 | -- | `1`个席位
`7`天,`7`小时* | `1`个席位
`1`年 | `1`个席位
`2`年 | `1`个席位
`长期` |
-| `服务方式:`|
-| 官方QQ群交流 | √ | √ | √ | √ | √ |
-| 即时一对一交流 | | √ | √ | √ | √ |
-| 专属VIP群交流 | | | √ | √ | √ |
-| `服务内容:`|
-| 可商用 | √ | √ | √ | √ | √ |
-| 可二次开发 | √ | √ | √ | √ | √ |
-| 有问必答 | | √ | √ | √ | √ |
-| 即时回应 | | √ | √ | √ | √ |
-| 新手指导 | | √ | √ | √ | √ |
-| 开发指导 | | √ | √ | √ | √ |
-| 优化指导 | | √ | √ | √ | √ |
-| 其他技术支持 | | | √ | √ | √ |
-| 问题及时处理 | | | √ | √ | √ |
-| 需求优先考虑 | | | √ | √ | √ |
-| 可另付费定制 | | | √ | √ | √ |
-| 可另付费加急 | | | √ | √ | √ |
-| 付费图表优惠 | | | 95折 | 95折 | 85折 |
+订阅服务分个人订阅和企业订阅:
+
+- 个人订阅:个人VIP属于个人,不可转让,XCharts只服务于订阅当事人。
+- 企业订阅:企业VIP属于企业,席位内可安排固定职员,职员离职可重新安排,XCharts通过专属企业群为企业服务。
+
+订阅服务的优势?
+
+- 提高工作效率,节省时间成本。一方面,XCharts功能强大,相关配置项非常多,VIP服务可快速帮您定位,节省去查找和核对的时间;另一方面,VIP的即时回答服务可快速为您答疑解惑,避免中断开发流程。总之,订阅VIP可让您能快速上手,快速处理问题,至少能提高`10`倍以上的工作效率。
+- 更多技术交流,更多经验交流。XCharts团队从业多年,有丰富的技术和工作经验。VIP服务不仅可以交流XCharts相关的内容,也可以咨询其他方面的技术。VIP群也有更多的交流。
+- 订阅VIP后可享受更多其他增值服务。
+
+| |免费用户|付费咨询|个人`1`年`VIP`|个人`2`年`VIP` | 个人长期`VIP` | 个人长期`SVIP` | 企业`1`年`VIP` |
+| ----- |--|--|--|--|--|--|--|
+| 订阅费用 | -- | `98`¥ | `298`¥ | `498`¥ | `898`¥ | `1998`¥ | `联系我们` |
+| 订阅时长 | -- | `7`天 | `1`年 | `2`年 | `长期` | `长期` | `1`年
+| 订阅席位 | -- | `1`个席位 | `1`个席位 | `1`个席位 | `1`个席位|`1`个席位|`5`个以上席位|
+| __`服务方式:`__|
+| 官方QQ群交流 | √ | √ | √ | √ | √ | √ | √ |
+| 即时一对一交流 | | √ | √ | √ | √ | √ | √ |
+| 专属VIP群交流 | | | √ | √ | √ | √ | √(专属企业群) |
+| __`服务内容:`__|
+| 可商用 | √ | √ | √ | √ | √ | √ | √ |
+| 可二次开发 | √ | √ | √ | √ | √ | √ | √ |
+| 有问必答 | | √ | √ | √ | √ | √ | √ |
+| 即时回答 | | √ | √ | √ | √ | √ | √ |
+| 新手指导 | | √ | √ | √ | √ | √ | √ |
+| 开发指导 | | √ | √ | √ | √ | √ | √ |
+| 优化指导 | | √ | √ | √ | √ | √ | √ |
+| 其他技术支持 | | | √ | √ | √ | √ | √ |
+| 问题及时处理 | | | √ | √ | √ | √ | √ |
+| 需求优先考虑 | | | √ | √ | √ | √ | √ |
+| 可另付费定制 | | | √ | √ | √ | √ | √ |
+| 可另付费加急 | | | √ | √ | √ | √ | √ |
+| 扩展图表购买 | | | √ | √ | √ | √ | √ |
+| 扩展图表优惠 | | | | | 85折 | 全部免费 | |
+
+## 扩展图表
+
+扩展图表为另付费购买图表,目前只对订阅了VIP服务的用户开放购买。对于`个人长期SVIP`的用户,后续新增的所有扩展图表都可以免费使用。
+
+扩展图表购买后可访问和下载源码,长期有效,并可获得持续的更新支持。
+
+|编号|扩展图表|价格|备注|
+|--|--|--|--|
+| 101 | PictorialBarChart | 98¥ | 象形柱图 |
+| 102 | FunnelChart | 98¥ | 漏斗图 |
+| 103 | PyramidChart | 98¥ | 3D金字塔 |
+| 104 | TreemapChart | 98¥ | 树形矩图 |
+| 201 | Bar3DChart | 198¥ | 3D柱图 |
+| 202 | Pie3DChart | 198¥ | 3D饼图 |
+| 203 | GanttChart | 198¥ | 甘特图 |
+| 204 | GaugeChart | 198¥ | 仪表盘 |
+| 205 | LiquidChart | 198¥ | 水位图 |
+
## 备注说明
1. __`付费定制`__ 是指用户可根据自己的需求定制不同的图表或新功能,只有`VIP`用户才享有`付费定制`权利。
2. __`付费加急`__ 是指用户可对自己非常紧急的需求进行付费,将开发优先级提到最高,并可要求在`Deadline`内交付,只有`VIP`用户才享有`付费加急`权利。
3. __`付费咨询`__ 付费咨询有效期`7`天,且总咨询时长不超过`7`个小时。
+4. __`扩展图表`__ 扩展图表需要另付费购买,目前只有VIP用户才享有购买`扩展图表`权利。购买后可访问和下载源码,长期有效,并可获得持续的更新支持。
## 捐助支持
-如果这个项目对您有帮助,请右上方点 `Star` 予以支持!也欢迎任何金额的赞助,非常感谢!
+如果这个项目对您有帮助,请右上方点 `Star` 予以支持!也欢迎任意金额的捐助,非常感谢!
-
\ No newline at end of file
+
+
diff --git a/Documentation/XChartsAPI-EN.md b/Documentation/XChartsAPI-EN.md
index b168396f..1903d45e 100644
--- a/Documentation/XChartsAPI-EN.md
+++ b/Documentation/XChartsAPI-EN.md
@@ -65,6 +65,8 @@
- [SerieContext](#SerieContext)
- [SerieConvertAttribute](#SerieConvertAttribute)
- [SerieDataContext](#SerieDataContext)
+- [SerieDataExtraComponentAttribute](#SerieDataExtraComponentAttribute)
+- [SerieDataExtraFieldAttribute](#SerieDataExtraFieldAttribute)
- [SerieExtraComponentAttribute](#SerieExtraComponentAttribute)
- [SerieHandler](#SerieHandler)
- [SerieHandler](#SerieHandler)
@@ -144,10 +146,12 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver
|public method|description|
|--|--|
| `AddChartComponent()` |public MainComponent AddChartComponent(Type type) |
+| `AddData()` |public SerieData AddData(int serieIndex, DateTime time, double yValue, string dataName = null, string dataId = null)Add a (time,y) data to serie. |
| `AddData()` |public SerieData AddData(int serieIndex, double data, string dataName = null, string dataId = null)Add a data to serie. |
| `AddData()` |public SerieData AddData(int serieIndex, double open, double close, double lowest, double heighest, string dataName = null, string dataId = null) |
| `AddData()` |public SerieData AddData(int serieIndex, double xValue, double yValue, string dataName = null, string dataId = null)Add a (x,y) data to serie. |
| `AddData()` |public SerieData AddData(int serieIndex, List multidimensionalData, string dataName = null, string dataId = null)Add an arbitray dimension data to serie,such as (x,y,z,...). |
+| `AddData()` |public SerieData AddData(string serieName, DateTime time, double yValue, string dataName = null, string dataId = null)Add a (time,y) data to serie. |
| `AddData()` |public SerieData AddData(string serieName, double data, string dataName = null, string dataId = null)Add a data to serie. |
| `AddData()` |public SerieData AddData(string serieName, double open, double close, double lowest, double heighest, string dataName = null, string dataId = null) |
| `AddData()` |public SerieData AddData(string serieName, double xValue, double yValue, string dataName = null, string dataId = null)Add a (x,y) data to serie. |
@@ -338,7 +342,7 @@ Inherits or Implemented: [BaseChart](#BaseChart)
| `GetMaxDivisibleValue()` |public static double GetMaxDivisibleValue(double max, int ceilRate) |
| `GetMaxLogValue()` |public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber) |
| `GetMinDivisibleValue()` |public static double GetMinDivisibleValue(double min, int ceilRate) |
-| `GetMinLogValue()` |public static float GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber) |
+| `GetMinLogValue()` |public static double GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber) |
| `GetPointList()` |public static void GetPointList(ref List posList, Vector3 sp, Vector3 ep, float k = 30f) |
| `GetPos()` |public static Vector3 GetPos(Vector3 center, float radius, float angle, bool isDegree = false) |
| `GetPosition()` |public static Vector3 GetPosition(Vector3 center, float angle, float radius) |
@@ -483,6 +487,7 @@ Inherits or Implemented: [Attribute](#Attribute)
|public method|description|
|--|--|
+| `NeedFormat()` |public static bool NeedFormat(string content) |
| `ReplaceAxisLabelContent()` |public static void ReplaceAxisLabelContent(ref string content, string numericFormatter, double value) |
| `ReplaceAxisLabelContent()` |public static void ReplaceAxisLabelContent(ref string content, string value) |
| `TrimAndReplaceLine()` |public static string TrimAndReplaceLine(string content) |
@@ -721,6 +726,38 @@ Inherits or Implemented: [Attribute](#Attribute)
|--|--|
| `Reset()` |public void Reset() |
+## `SerieDataExtraComponentAttribute`
+
+Inherits or Implemented: [Attribute](#Attribute)
+
+|public method|description|
+|--|--|
+| `Contains()` |public bool Contains(Type type) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute() |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6, Type type7) |
+
+## `SerieDataExtraFieldAttribute`
+
+Inherits or Implemented: [Attribute](#Attribute)
+
+|public method|description|
+|--|--|
+| `Contains()` |public bool Contains(string field) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute() |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2, string field3) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6, string field7) |
+
## `SerieExtraComponentAttribute`
Inherits or Implemented: [Attribute](#Attribute)
@@ -745,6 +782,7 @@ Inherits or Implemented: [SerieHandler where T](#SerieHandler where T),[Serie](#
|public method|description|
|--|--|
+| `GetSerieDataAutoColor()` |public virtual Color GetSerieDataAutoColor(SerieData serieData) |
| `GetSerieDataLabelOffset()` |public virtual Vector3 GetSerieDataLabelOffset(SerieData serieData, LabelStyle label) |
| `GetSerieDataLabelPosition()` |public virtual Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label) |
| `GetSerieDataTitlePosition()` |public virtual Vector3 GetSerieDataTitlePosition(SerieData serieData, TitleStyle titleStyle) |
@@ -777,13 +815,13 @@ Inherits or Implemented: [Attribute](#Attribute)
| `GetAreaStyle()` |public static AreaStyle GetAreaStyle(Serie serie, SerieData serieData) |
| `GetAreaToColor()` |public static Color32 GetAreaToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight) |
| `GetAverageData()` |public static double GetAverageData(Serie serie, int dimension = 1, DataZoom dataZoom = null) |
-| `GetItemColor()` |public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight) |
+| `GetItemColor()` |public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true) |
| `GetItemColor0()` |public static Color32 GetItemColor0(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, Color32 defaultColor) |
| `GetItemFormatter()` |public static string GetItemFormatter(Serie serie, SerieData serieData, string defaultFormatter = null) |
| `GetItemMarker()` |public static string GetItemMarker(Serie serie, SerieData serieData, string defaultMarker = null) |
| `GetItemStyle()` |public static ItemStyle GetItemStyle(Serie serie, SerieData serieData, bool highlight = false) |
| `GetItemStyleEmphasis()` |public static ItemStyle GetItemStyleEmphasis(Serie serie, SerieData serieData) |
-| `GetItemToColor()` |public static Color32 GetItemToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight) |
+| `GetItemToColor()` |public static Color32 GetItemToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true) |
| `GetLineColor()` |public static Color32 GetLineColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight) |
| `GetLineStyle()` |public static LineStyle GetLineStyle(Serie serie, SerieData serieData) |
| `GetMaxData()` |public static double GetMaxData(Serie serie, int dimension = 1, DataZoom dataZoom = null) |
diff --git a/Documentation/XChartsAPI-ZH.md b/Documentation/XChartsAPI-ZH.md
index 1fe9bc1a..bdf17833 100644
--- a/Documentation/XChartsAPI-ZH.md
+++ b/Documentation/XChartsAPI-ZH.md
@@ -65,6 +65,8 @@
- [SerieContext](#SerieContext)
- [SerieConvertAttribute](#SerieConvertAttribute)
- [SerieDataContext](#SerieDataContext)
+- [SerieDataExtraComponentAttribute](#SerieDataExtraComponentAttribute)
+- [SerieDataExtraFieldAttribute](#SerieDataExtraFieldAttribute)
- [SerieExtraComponentAttribute](#SerieExtraComponentAttribute)
- [SerieHandler](#SerieHandler)
- [SerieHandler](#SerieHandler)
@@ -144,10 +146,12 @@ Inherits or Implemented: [BaseGraph](#BaseGraph),[ISerializationCallbackReceiver
|public method|description|
|--|--|
| `AddChartComponent()` |public MainComponent AddChartComponent(Type type) |
+| `AddData()` |public SerieData AddData(int serieIndex, DateTime time, double yValue, string dataName = null, string dataId = null)添加(time,y)数据到指定的系列中。 |
| `AddData()` |public SerieData AddData(int serieIndex, double data, string dataName = null, string dataId = null)添加一个数据到指定的系列中。 |
| `AddData()` |public SerieData AddData(int serieIndex, double open, double close, double lowest, double heighest, string dataName = null, string dataId = null) |
| `AddData()` |public SerieData AddData(int serieIndex, double xValue, double yValue, string dataName = null, string dataId = null)添加(x,y)数据到指定系列中。 |
| `AddData()` |public SerieData AddData(int serieIndex, List multidimensionalData, string dataName = null, string dataId = null)添加多维数据(x,y,z...)到指定的系列中。 |
+| `AddData()` |public SerieData AddData(string serieName, DateTime time, double yValue, string dataName = null, string dataId = null)添加(time,y)数据到指定的系列中。 |
| `AddData()` |public SerieData AddData(string serieName, double data, string dataName = null, string dataId = null)If serieName doesn't exist in legend,will be add to legend. |
| `AddData()` |public SerieData AddData(string serieName, double open, double close, double lowest, double heighest, string dataName = null, string dataId = null) |
| `AddData()` |public SerieData AddData(string serieName, double xValue, double yValue, string dataName = null, string dataId = null)添加(x,y)数据到指定系列中。 |
@@ -338,7 +342,7 @@ Inherits or Implemented: [BaseChart](#BaseChart)
| `GetMaxDivisibleValue()` |public static double GetMaxDivisibleValue(double max, int ceilRate) |
| `GetMaxLogValue()` |public static double GetMaxLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber) |
| `GetMinDivisibleValue()` |public static double GetMinDivisibleValue(double min, int ceilRate) |
-| `GetMinLogValue()` |public static float GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber) |
+| `GetMinLogValue()` |public static double GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber) |
| `GetPointList()` |public static void GetPointList(ref List posList, Vector3 sp, Vector3 ep, float k = 30f) |
| `GetPos()` |public static Vector3 GetPos(Vector3 center, float radius, float angle, bool isDegree = false) |
| `GetPosition()` |public static Vector3 GetPosition(Vector3 center, float angle, float radius) |
@@ -483,6 +487,7 @@ Inherits or Implemented: [Attribute](#Attribute)
|public method|description|
|--|--|
+| `NeedFormat()` |public static bool NeedFormat(string content) |
| `ReplaceAxisLabelContent()` |public static void ReplaceAxisLabelContent(ref string content, string numericFormatter, double value) |
| `ReplaceAxisLabelContent()` |public static void ReplaceAxisLabelContent(ref string content, string value) |
| `TrimAndReplaceLine()` |public static string TrimAndReplaceLine(string content) |
@@ -721,6 +726,38 @@ Inherits or Implemented: [Attribute](#Attribute)
|--|--|
| `Reset()` |public void Reset() |
+## `SerieDataExtraComponentAttribute`
+
+Inherits or Implemented: [Attribute](#Attribute)
+
+|public method|description|
+|--|--|
+| `Contains()` |public bool Contains(Type type) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute() |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6) |
+| `SerieDataExtraComponentAttribute()` |public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6, Type type7) |
+
+## `SerieDataExtraFieldAttribute`
+
+Inherits or Implemented: [Attribute](#Attribute)
+
+|public method|description|
+|--|--|
+| `Contains()` |public bool Contains(string field) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute() |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2, string field3) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6) |
+| `SerieDataExtraFieldAttribute()` |public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6, string field7) |
+
## `SerieExtraComponentAttribute`
Inherits or Implemented: [Attribute](#Attribute)
@@ -745,6 +782,7 @@ Inherits or Implemented: [SerieHandler where T](#SerieHandler where T),[Serie](#
|public method|description|
|--|--|
+| `GetSerieDataAutoColor()` |public virtual Color GetSerieDataAutoColor(SerieData serieData) |
| `GetSerieDataLabelOffset()` |public virtual Vector3 GetSerieDataLabelOffset(SerieData serieData, LabelStyle label) |
| `GetSerieDataLabelPosition()` |public virtual Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label) |
| `GetSerieDataTitlePosition()` |public virtual Vector3 GetSerieDataTitlePosition(SerieData serieData, TitleStyle titleStyle) |
@@ -777,13 +815,13 @@ Inherits or Implemented: [Attribute](#Attribute)
| `GetAreaStyle()` |public static AreaStyle GetAreaStyle(Serie serie, SerieData serieData) |
| `GetAreaToColor()` |public static Color32 GetAreaToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight) |
| `GetAverageData()` |public static double GetAverageData(Serie serie, int dimension = 1, DataZoom dataZoom = null) |
-| `GetItemColor()` |public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight) |
+| `GetItemColor()` |public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true) |
| `GetItemColor0()` |public static Color32 GetItemColor0(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, Color32 defaultColor) |
| `GetItemFormatter()` |public static string GetItemFormatter(Serie serie, SerieData serieData, string defaultFormatter = null) |
| `GetItemMarker()` |public static string GetItemMarker(Serie serie, SerieData serieData, string defaultMarker = null) |
| `GetItemStyle()` |public static ItemStyle GetItemStyle(Serie serie, SerieData serieData, bool highlight = false) |
| `GetItemStyleEmphasis()` |public static ItemStyle GetItemStyleEmphasis(Serie serie, SerieData serieData) |
-| `GetItemToColor()` |public static Color32 GetItemToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight) |
+| `GetItemToColor()` |public static Color32 GetItemToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true) |
| `GetLineColor()` |public static Color32 GetLineColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight) |
| `GetLineStyle()` |public static LineStyle GetLineStyle(Serie serie, SerieData serieData) |
| `GetMaxData()` |public static double GetMaxData(Serie serie, int dimension = 1, DataZoom dataZoom = null) |
diff --git a/Documentation/XChartsConfiguration-EN.md b/Documentation/XChartsConfiguration-EN.md
index 1701d78e..7b8b835c 100644
--- a/Documentation/XChartsConfiguration-EN.md
+++ b/Documentation/XChartsConfiguration-EN.md
@@ -47,6 +47,7 @@
- [Axis](#Axis)
- [Background](#Background)
- [CalendarCoord](#CalendarCoord)
+- [Comment](#Comment)
- [CoordSystem](#CoordSystem)
- [DataZoom](#DataZoom)
- [GridCoord](#GridCoord)
@@ -82,9 +83,14 @@
- [AxisTick](#AxisTick)
- [BaseAxisTheme](#BaseAxisTheme)
- [BaseLine](#BaseLine)
+- [CommentItem](#CommentItem)
+- [CommentMarkStyle](#CommentMarkStyle)
- [ComponentTheme](#ComponentTheme)
- [DataZoomTheme](#DataZoomTheme)
- [Emphasis](#Emphasis)
+- [EmphasisItemStyle](#EmphasisItemStyle)
+- [EmphasisLabelLine](#EmphasisLabelLine)
+- [EmphasisLabelStyle](#EmphasisLabelStyle)
- [EndLabelStyle](#EndLabelStyle)
- [IconStyle](#IconStyle)
- [ImageStyle](#ImageStyle)
@@ -103,7 +109,6 @@
- [RadarAxisTheme](#RadarAxisTheme)
- [RadiusAxisTheme](#RadiusAxisTheme)
- [SerieData](#SerieData)
-- [SerieDataBaseInfo](#SerieDataBaseInfo)
- [SerieSymbol](#SerieSymbol)
- [SerieTheme](#SerieTheme)
- [StageColor](#StageColor)
@@ -116,13 +121,16 @@
- [TitleStyle](#TitleStyle)
- [TitleTheme](#TitleTheme)
- [TooltipTheme](#TooltipTheme)
-- [VisualMapPieces](#VisualMapPieces)
+- [VisualMapRange](#VisualMapRange)
- [VisualMapTheme](#VisualMapTheme)
## ISerieExtraComponent
- [AreaStyle](#AreaStyle)
- [Emphasis](#Emphasis)
+- [EmphasisItemStyle](#EmphasisItemStyle)
+- [EmphasisLabelLine](#EmphasisLabelLine)
+- [EmphasisLabelStyle](#EmphasisLabelStyle)
- [ImageStyle](#ImageStyle)
- [LabelLine](#LabelLine)
- [LabelStyle](#LabelStyle)
@@ -133,12 +141,14 @@
- [AreaStyle](#AreaStyle)
- [Emphasis](#Emphasis)
+- [EmphasisItemStyle](#EmphasisItemStyle)
+- [EmphasisLabelLine](#EmphasisLabelLine)
+- [EmphasisLabelStyle](#EmphasisLabelStyle)
- [ImageStyle](#ImageStyle)
- [ItemStyle](#ItemStyle)
- [LabelLine](#LabelLine)
- [LabelStyle](#LabelStyle)
- [LineStyle](#LineStyle)
-- [SerieDataBaseInfo](#SerieDataBaseInfo)
- [SerieSymbol](#SerieSymbol)
- [TitleStyle](#TitleStyle)
@@ -414,6 +424,45 @@ Inherits or Implemented: [Serie](#Serie),[INeedSerieContainer](#INeedSerieContai
## `ChildComponent`
+## `Comment`
+
+Inherits or Implemented: [MainComponent](#MainComponent)
+
+comment of chart.
+
+|field|default|comment|
+|--|--|--|
+| `show` |true | Set this to false to prevent the comment from showing. |
+| `labelStyle` | | The text style of all comments. [LabelStyle](LabelStyle)|
+| `markStyle` | | The text style of all comments. [CommentMarkStyle](CommentMarkStyle)|
+| `items` | | |
+
+## `CommentItem`
+
+Inherits or Implemented: [ChildComponent](#ChildComponent)
+
+comment of chart.
+
+|field|default|comment|
+|--|--|--|
+| `show` |true | Set this to false to prevent this comment item from showing. |
+| `content` | | content of comment. |
+| `position` | | position of comment. |
+| `markRect` | | |
+| `markStyle` | | [CommentMarkStyle](CommentMarkStyle)|
+| `labelStyle` | | The text style of all comments. [LabelStyle](LabelStyle)|
+
+## `CommentMarkStyle`
+
+Inherits or Implemented: [ChildComponent](#ChildComponent)
+
+comment of chart.
+
+|field|default|comment|
+|--|--|--|
+| `show` |true | Set this to false to prevent this comment item from showing. |
+| `lineStyle` | | [LineStyle](LineStyle)|
+
## `ComponentTheme`
Inherits or Implemented: [ChildComponent](#ChildComponent)
@@ -516,6 +565,27 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent
| `labelLine` | | [LabelLine](LabelLine)|
| `itemStyle` | | 图形样式。 [ItemStyle](ItemStyle)|
+## `EmphasisItemStyle`
+
+Inherits or Implemented: [ItemStyle](#ItemStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent)
+
+高亮的图形样式
+
+
+## `EmphasisLabelLine`
+
+Inherits or Implemented: [LabelLine](#LabelLine),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent)
+
+高亮的标签引导线样式
+
+
+## `EmphasisLabelStyle`
+
+Inherits or Implemented: [LabelStyle](#LabelStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent)
+
+高亮的标签样式
+
+
## `EndLabelStyle`
Inherits or Implemented: [LabelStyle](#LabelStyle)
@@ -704,11 +774,13 @@ Legend component.The legend component shows different sets of tags, colors, and
| `itemHeight` |12.0f | Image height of legend symbol. |
| `itemGap` |10f | The distance between each legend, horizontal distance in horizontal layout, and vertical distance in vertical layout. |
| `itemAutoColor` |true | Whether the legend symbol matches the color automatically. |
-| `textAutoColor` |false | Whether the legend text matches the color automatically. |
+| `itemOpacity` |1 | the opacity of item color. |
| `formatter` | | |
+| `numericFormatter` | | Standard numeric format strings. |
| `labelStyle` | | the style of text. [LabelStyle](LabelStyle)|
| `data` | | Data array of legend. An array item is usually a name representing string. (If it is a pie chart, it could also be the name of a single data in the pie chart) of a series. |
| `icons` | | 自定义的图例标记图形。 |
+| `colors` | | |
## `LegendTheme`
@@ -749,7 +821,7 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent
|field|default|comment|
|--|--|--|
| `show` | | Whether to show the arrow. |
-| `position` | | The position of arrow.`LineArrow.Position`:- `End`: 末端箭头- `Start`: 头端箭头|
+| `position` | | The position of arrow.`LabelStyle.Position`:- `Default`: The position of label.- `Outside`: Outside of sectors of pie chart, which relates to corresponding sector through visual guide line.- `Inside`: Inside the sectors of pie chart.- `Center`: In the center of pie chart.- `Top`: top of symbol.- `Bottom`: the bottom of symbol.- `Left`: the left of symbol.- `Right`: the right of symbol.- `Start`: the start of line.- `Middle`: the middle of line.- `End`: the end of line.|
| `arrow` | | the arrow of line. [ArrowStyle](ArrowStyle)|
## `LineStyle`
@@ -954,7 +1026,9 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
| `lineArrows` | | |
| `areaStyles` | | |
| `titleStyles` | | |
-| `emphases` | | |
+| `emphasisItemStyles` | | |
+| `emphasisLabels` | | |
+| `emphasisLabelLines` | | |
| `index` | | The index of serie. |
| `show` |true | Whether to show serie in chart. |
| `coordSystem` | | the chart coord system of serie. |
@@ -977,8 +1051,8 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
| `lineType` | | The type of line chart.`LineType`:- `Normal`: the normal line chart, 普通折线图。- `Smooth`: the smooth line chart, 平滑曲线。- `StepStart`: step line.- `StepMiddle`: step line.- `StepEnd`: step line.|
| `barType` | | 柱形图类型。`BarType`:- `Normal`: 普通柱形图- `Zebra`: 斑马柱形图- `Capsule`: 胶囊柱形图|
| `barPercentStack` |false | 柱形图是否为百分比堆积。相同stack的serie只要有一个barPercentStack为true,则就显示成百分比堆叠柱状图。 |
-| `barWidth` |0.6f | The width of the bar. Adaptive when default 0. |
-| `barGap` |0.3f; // 30 | The gap between bars between different series, is a percent value like '0.3f' , which means 30% of the bar width, can be set as a fixed value. |
+| `barWidth` |0 | The width of the bar. Adaptive when default 0. |
+| `barGap` |0.1f | The gap between bars between different series, is a percent value like '0.3f' , which means 30% of the bar width, can be set as a fixed value. |
| `barZebraWidth` |4f | 斑马线的粗细。 |
| `barZebraGap` |2f | 斑马线的间距。 |
| `min` | | 最小值。 |
@@ -1035,29 +1109,21 @@ A data item of serie.
| `name` | | the name of data item. |
| `id` | | 数据项的唯一id。唯一id不是必须设置的。 |
| `parentId` | | |
-| `baseInfos` | | |
+| `ignore` | | 是否忽略数据。当为 true 时,数据不进行绘制。 |
+| `selected` | | Whether the data item is selected. |
+| `radius` | | 自定义半径。可用在饼图中自定义某个数据项的半径。 |
| `itemStyles` | | |
| `labels` | | |
| `labelLines` | | |
-| `emphases` | | |
| `symbols` | | |
| `lineStyles` | | |
| `areaStyles` | | |
| `titleStyles` | | |
+| `emphasisItemStyles` | | |
+| `emphasisLabels` | | |
+| `emphasisLabelLines` | | |
| `data` | | An arbitrary dimension data list of data item. |
-## `SerieDataBaseInfo`
-
-Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieDataComponent](#ISerieDataComponent)
-
-数据项的其他基础数据。
-
-|field|default|comment|
-|--|--|--|
-| `ignore` |false | 是否忽略数据。当为 true 时,数据不进行绘制。 |
-| `selected` | | Whether the data item is selected. |
-| `radius` | | 自定义半径。可用在饼图中自定义某个数据项的半径。 |
-
## `SerieSymbol`
Inherits or Implemented: [SymbolStyle](#SymbolStyle),[ISerieDataComponent](#ISerieDataComponent)
@@ -1392,11 +1458,10 @@ VisualMap component. Mapping data to visual elements such as colors.
| `location` | | The location of component. [Location](Location)|
| `workOnLine` |true | Whether the visualmap is work on linestyle of linechart. |
| `workOnArea` |false | Whether the visualmap is work on areaStyle of linechart. |
-| `inRange` | | Defines the visual color in the selected range. |
| `outOfRange` | | Defines a visual color outside of the selected range. |
-| `pieces` | | 分段式每一段的相关配置。 |
+| `inRange` | | 分段式每一段的相关配置。 |
-## `VisualMapPieces`
+## `VisualMapRange`
Inherits or Implemented: [ChildComponent](#ChildComponent)
diff --git a/Documentation/XChartsConfiguration-ZH.md b/Documentation/XChartsConfiguration-ZH.md
index 791a485b..44f062f2 100644
--- a/Documentation/XChartsConfiguration-ZH.md
+++ b/Documentation/XChartsConfiguration-ZH.md
@@ -47,6 +47,7 @@
- [Axis](#Axis)
- [Background](#Background)
- [CalendarCoord](#CalendarCoord)
+- [Comment](#Comment)
- [CoordSystem](#CoordSystem)
- [DataZoom](#DataZoom)
- [GridCoord](#GridCoord)
@@ -82,9 +83,14 @@
- [AxisTick](#AxisTick)
- [BaseAxisTheme](#BaseAxisTheme)
- [BaseLine](#BaseLine)
+- [CommentItem](#CommentItem)
+- [CommentMarkStyle](#CommentMarkStyle)
- [ComponentTheme](#ComponentTheme)
- [DataZoomTheme](#DataZoomTheme)
- [Emphasis](#Emphasis)
+- [EmphasisItemStyle](#EmphasisItemStyle)
+- [EmphasisLabelLine](#EmphasisLabelLine)
+- [EmphasisLabelStyle](#EmphasisLabelStyle)
- [EndLabelStyle](#EndLabelStyle)
- [IconStyle](#IconStyle)
- [ImageStyle](#ImageStyle)
@@ -103,7 +109,6 @@
- [RadarAxisTheme](#RadarAxisTheme)
- [RadiusAxisTheme](#RadiusAxisTheme)
- [SerieData](#SerieData)
-- [SerieDataBaseInfo](#SerieDataBaseInfo)
- [SerieSymbol](#SerieSymbol)
- [SerieTheme](#SerieTheme)
- [StageColor](#StageColor)
@@ -116,13 +121,16 @@
- [TitleStyle](#TitleStyle)
- [TitleTheme](#TitleTheme)
- [TooltipTheme](#TooltipTheme)
-- [VisualMapPieces](#VisualMapPieces)
+- [VisualMapRange](#VisualMapRange)
- [VisualMapTheme](#VisualMapTheme)
## ISerieExtraComponent Serie额外组件
- [AreaStyle](#AreaStyle)
- [Emphasis](#Emphasis)
+- [EmphasisItemStyle](#EmphasisItemStyle)
+- [EmphasisLabelLine](#EmphasisLabelLine)
+- [EmphasisLabelStyle](#EmphasisLabelStyle)
- [ImageStyle](#ImageStyle)
- [LabelLine](#LabelLine)
- [LabelStyle](#LabelStyle)
@@ -133,12 +141,14 @@
- [AreaStyle](#AreaStyle)
- [Emphasis](#Emphasis)
+- [EmphasisItemStyle](#EmphasisItemStyle)
+- [EmphasisLabelLine](#EmphasisLabelLine)
+- [EmphasisLabelStyle](#EmphasisLabelStyle)
- [ImageStyle](#ImageStyle)
- [ItemStyle](#ItemStyle)
- [LabelLine](#LabelLine)
- [LabelStyle](#LabelStyle)
- [LineStyle](#LineStyle)
-- [SerieDataBaseInfo](#SerieDataBaseInfo)
- [SerieSymbol](#SerieSymbol)
- [TitleStyle](#TitleStyle)
@@ -414,6 +424,45 @@ Inherits or Implemented: [Serie](#Serie),[INeedSerieContainer](#INeedSerieContai
## `ChildComponent`
+## `Comment`
+
+Inherits or Implemented: [MainComponent](#MainComponent)
+
+图表注解组件。
+
+|field|default|comment|
+|--|--|--|
+| `show` |true | 是否显示注解组件。 |
+| `labelStyle` | | 所有组件的文本样式。 [LabelStyle](LabelStyle)|
+| `markStyle` | | 所有组件的文本样式。 [CommentMarkStyle](CommentMarkStyle)|
+| `items` | | |
+
+## `CommentItem`
+
+Inherits or Implemented: [ChildComponent](#ChildComponent)
+
+注解项。
+
+|field|default|comment|
+|--|--|--|
+| `show` |true | 是否显示当前注解项。 |
+| `content` | | 注解的文本内容。 |
+| `position` | | 注解项的位置坐标。 |
+| `markRect` | | |
+| `markStyle` | | [CommentMarkStyle](CommentMarkStyle)|
+| `labelStyle` | | 注解项的文本样式。 [LabelStyle](LabelStyle)|
+
+## `CommentMarkStyle`
+
+Inherits or Implemented: [ChildComponent](#ChildComponent)
+
+注解项。
+
+|field|default|comment|
+|--|--|--|
+| `show` |true | 是否显示当前注解项。 |
+| `lineStyle` | | [LineStyle](LineStyle)|
+
## `ComponentTheme`
Inherits or Implemented: [ChildComponent](#ChildComponent)
@@ -516,6 +565,27 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent
| `labelLine` | | [LabelLine](LabelLine)|
| `itemStyle` | | 图形样式。 [ItemStyle](ItemStyle)|
+## `EmphasisItemStyle`
+
+Inherits or Implemented: [ItemStyle](#ItemStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent)
+
+高亮的图形样式
+
+
+## `EmphasisLabelLine`
+
+Inherits or Implemented: [LabelLine](#LabelLine),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent)
+
+高亮的标签引导线样式
+
+
+## `EmphasisLabelStyle`
+
+Inherits or Implemented: [LabelStyle](#LabelStyle),[ISerieExtraComponent](#ISerieExtraComponent),[ISerieDataComponent](#ISerieDataComponent)
+
+高亮的标签样式
+
+
## `EndLabelStyle`
Inherits or Implemented: [LabelStyle](#LabelStyle)
@@ -704,11 +774,13 @@ Inherits or Implemented: [MainComponent](#MainComponent),[IPropertyChanged](#IPr
| `itemHeight` |12.0f | 图例标记的图形高度。 [default:12f] |
| `itemGap` |10f | 图例每项之间的间隔。横向布局时为水平间隔,纵向布局时为纵向间隔。 [default:10f] |
| `itemAutoColor` |true | 图例标记的图形是否自动匹配颜色。 [default:true] |
-| `textAutoColor` |false | 图例标记的文本是否自动匹配颜色。 [default:false] |
+| `itemOpacity` |1 | 图例标记的图形的颜色透明度。 |
| `formatter` | | |
+| `numericFormatter` | | 标准数字格式字符串。用于将数值格式化显示为字符串。 使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。 参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings |
| `labelStyle` | | 文本样式。 [LabelStyle](LabelStyle)|
| `data` | | If data is not specified, it will be auto collected from series. |
| `icons` | | 自定义的图例标记图形。 |
+| `colors` | | |
## `LegendTheme`
@@ -749,7 +821,7 @@ Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieExtraComponent
|field|default|comment|
|--|--|--|
| `show` | | 是否显示箭头。 |
-| `position` | | 箭头位置。`LineArrow.Position`:- `End`: 末端箭头- `Start`: 头端箭头|
+| `position` | | 箭头位置。`LabelStyle.Position`:- `Default`: 标签的位置。- `Outside`: 饼图扇区外侧,通过视觉引导线连到相应的扇区。- `Inside`: 饼图扇区内部。- `Center`: 在饼图中心位置。- `Top`: 图形标志的顶部。- `Bottom`: 图形标志的底部。- `Left`: 图形标志的左边。- `Right`: 图形标志的右边。- `Start`: 线的起始点。- `Middle`: 线的中点。- `End`: 线的结束点。|
| `arrow` | | 箭头。 [ArrowStyle](ArrowStyle)|
## `LineStyle`
@@ -954,7 +1026,9 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
| `lineArrows` | | |
| `areaStyles` | | |
| `titleStyles` | | |
-| `emphases` | | |
+| `emphasisItemStyles` | | |
+| `emphasisLabels` | | |
+| `emphasisLabelLines` | | |
| `index` | | 系列索引。 |
| `show` |true | 系列是否显示在图表上。 |
| `coordSystem` | | 使用的坐标系。 |
@@ -977,8 +1051,8 @@ Inherits or Implemented: [BaseSerie](#BaseSerie),[IComparable](#IComparable)
| `lineType` | | 折线图样式类型。`LineType`:- `Normal`: the normal line chart, 普通折线图。- `Smooth`: the smooth line chart, 平滑曲线。- `StepStart`: 阶梯线图:当前点。- `StepMiddle`: 阶梯线图:当前点和下一个点的中间。- `StepEnd`: 阶梯线图:下一个拐点。|
| `barType` | | 柱形图类型。`BarType`:- `Normal`: 普通柱形图- `Zebra`: 斑马柱形图- `Capsule`: 胶囊柱形图|
| `barPercentStack` |false | 柱形图是否为百分比堆积。相同stack的serie只要有一个barPercentStack为true,则就显示成百分比堆叠柱状图。 |
-| `barWidth` |0.6f | 柱条的宽度,不设时自适应。支持设置成相对于类目宽度的百分比。 |
-| `barGap` |0.3f; // 30 | Set barGap as '-1' can overlap bars that belong to different series, which is useful when making a series of bar be background. |
+| `barWidth` |0 | 柱条的宽度,不设时自适应。支持设置成相对于类目宽度的百分比。 |
+| `barGap` |0.1f | Set barGap as '-1' can overlap bars that belong to different series, which is useful when making a series of bar be background. |
| `barZebraWidth` |4f | 斑马线的粗细。 |
| `barZebraGap` |2f | 斑马线的间距。 |
| `min` | | 最小值。 |
@@ -1035,29 +1109,21 @@ Inherits or Implemented: [ChildComponent](#ChildComponent)
| `name` | | 数据项名称。 |
| `id` | | 数据项的唯一id。唯一id不是必须设置的。 |
| `parentId` | | |
-| `baseInfos` | | |
+| `ignore` | | 是否忽略数据。当为 true 时,数据不进行绘制。 |
+| `selected` | | 该数据项是否被选中。 |
+| `radius` | | 自定义半径。可用在饼图中自定义某个数据项的半径。 |
| `itemStyles` | | |
| `labels` | | |
| `labelLines` | | |
-| `emphases` | | |
| `symbols` | | |
| `lineStyles` | | |
| `areaStyles` | | |
| `titleStyles` | | |
+| `emphasisItemStyles` | | |
+| `emphasisLabels` | | |
+| `emphasisLabelLines` | | |
| `data` | | 可指定任意维数的数值列表。 |
-## `SerieDataBaseInfo`
-
-Inherits or Implemented: [ChildComponent](#ChildComponent),[ISerieDataComponent](#ISerieDataComponent)
-
-数据项的其他基础数据。
-
-|field|default|comment|
-|--|--|--|
-| `ignore` |false | 是否忽略数据。当为 true 时,数据不进行绘制。 |
-| `selected` | | 该数据项是否被选中。 |
-| `radius` | | 自定义半径。可用在饼图中自定义某个数据项的半径。 |
-
## `SerieSymbol`
Inherits or Implemented: [SymbolStyle](#SymbolStyle),[ISerieDataComponent](#ISerieDataComponent)
@@ -1392,11 +1458,10 @@ Inherits or Implemented: [MainComponent](#MainComponent)
| `location` | | 组件显示的位置。 [Location](Location)|
| `workOnLine` |true | 组件是否对LineChart的LineStyle有效。 |
| `workOnArea` |false | 组件是否对LineChart的AreaStyle有效。 |
-| `inRange` | | 定义 在选中范围中 的视觉颜色。 |
| `outOfRange` | | 定义 在选中范围外 的视觉颜色。 |
-| `pieces` | | 分段式每一段的相关配置。 |
+| `inRange` | | 分段式每一段的相关配置。 |
-## `VisualMapPieces`
+## `VisualMapRange`
Inherits or Implemented: [ChildComponent](#ChildComponent)
diff --git a/Documentation/XChartsFAQ-EN.md b/Documentation/XChartsFAQ-EN.md
index a2ac762d..d3b00d5b 100644
--- a/Documentation/XChartsFAQ-EN.md
+++ b/Documentation/XChartsFAQ-EN.md
@@ -32,7 +32,6 @@
[QA 26: How do I use the background component? What are the conditions?](#How-do-I-use-the-background-component-What-are-the-conditions)
[QA 27: Mesh can not have more than 65000 vertices?](#Mesh-cannot-have-more-than-65000-vertices)
[QA 28: Why are the parameters set in Serie reset after they run?](#Why-are-the-parameters-set-in-Serie-reset-after-they-run)
-[QA 29: Why are many custom colors lost after upgrading to 1.6.0? How should I upgrade?](#Why_are_many_custom_colors_lost_after_upgrading_to_1_6_0_How_should_I_upgrade)
## How-to-adjust-the-margin-between-the-axis-and-the=-background
@@ -146,16 +145,6 @@ A: This is the limit of `UGUI` on the number of vertices for a single `Graphic`.
A: Check whether `RemoveData()` and add new `Serie` in the code. If you want to keep the configuration of `Serie`, you can only `ClearData()` which just clear data and then readd the data to the old serie.
-## Why_are_many_custom_colors_lost_after_upgrading_to_1_6_0_How_should_I_upgrade
-
-A: In version `1.6.0`, in order to reduce implicit conversion, all drawing related `Color` was changed to `Color32`, so some custom colors were lost. The main components affected are: `ItemStyle`, `LineStyle`, `AreaStyle`, `Vessel`, `VisualMap`, `AxisSplitArea`, `AxisSplitLine`, `GaugeAxis`,`SerieLabel`, etc. Can use the script [UpgradeChartColor.cs](https://github.com/XCharts-Team/XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs) to upgrade.
-The upgrade steps are as follows:
-1. Back up the project.
-2. Download or copy the script [UpgradeChartColor.cs](https://github.com/XCharts-Team/XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs) in the old project `Editor`, Change the `color` field inside to `color.clear` (because some fields may not exist in the old version).
-3. After compilation, the old version of color configuration file is exported through `menu bar -> XCharts-> ExportColorConfig` (the configuration file is saved by default to `color.config` under `Assets`).
-4. Upgrade `XCharts` to the latest version.
-5. The custom color can be restored by importing `color.config` through `menu bar -> XCharts-> ImportColorConfig` (if `color.config` is not under `Assets` of the upgraded project, copy it to this directory).
-
[XCharts Homepage](https://github.com/XCharts-Team/XCharts)
[XCharts API](XChartsAPI-EN.md)
[XCharts Configuration](XChartsConfiguration-EN.md)
\ No newline at end of file
diff --git a/Documentation/XChartsFAQ-ZH.md b/Documentation/XChartsFAQ-ZH.md
index 0a10d4f3..f9d051c0 100644
--- a/Documentation/XChartsFAQ-ZH.md
+++ b/Documentation/XChartsFAQ-ZH.md
@@ -32,7 +32,6 @@
[QA 26:如何使用背景组件?有什么条件限制?](#如何使用背景组件_有什么条件限制)
[QA 27:Mesh can not have more than 65000 vertices?](#Mesh_cannot_have_more_than_65000_vertices)
[QA 28:为什么serie里设置的参数运行后又被重置了?](#为什么serie里设置的参数运行后又被重置了)
-[QA 29:为什么升级到1.6.0版本后很多自定义颜色丢失了?应该如何升级?](#为什么升级到1_6_0版本后很多自定义颜色丢失了_应该如何升级)
## 如何调整坐标轴与背景的边距
@@ -150,18 +149,6 @@
答:检测下代码里是否调用了`RemoveData()`并重新添加`Serie`了。如果想保留`Serie`的配置可以只`ClearData()`,然后重新添加数据。
-## 为什么升级到1_6_0版本后很多自定义颜色丢失了_应该如何升级
-
-答:1.6.0版本为了减少隐式转换,将所有的绘制相关的`Color`都改为了`Color32`,所以会导致一些自定义的颜色的丢失。影响到的主要组件有:`ItemStyle`,`LineStyle`,`AreaStyle`,`Vessel`,`VisualMap`,`AxisSplitArea`,`AxisSplitLine`,`GaugeAxis`,`SerieLabel`等。可以用脚本[UpgradeChartColor.cs](https://github.com/XCharts-Team/XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs)进行升级。
-升级步骤如下:
-1. 备份好你的项目。
-2. 先不升级`XCharts`,只下载或拷贝脚本[UpgradeChartColor.cs](https://github.com/XCharts-Team/XCharts/blob/master/Assets/XCharts/Editor/Tools/UpgradeChartColor.cs)放到旧项目的`Editor`下,由于旧版本可能不存在某些新版本才有的图表或者属性配置,可能会编译错误,需要处理按3,4步骤处理一下。
-3. 若是由`itemStyle.toColor2`引起的编译报错,可将导出地方的`itemStyle.toColor2`改为`Color.clear`;导入的地方注释掉即可。
-4. 若是由`LiquidChart`引起的编译报错,将所有涉及`LiquidChart`的地方都注释掉即可。
-5. 编译通过后,通过`菜单栏->XCharts->ExportColorConfig`导出旧版本的颜色配置文件(配置文件默认保存到`Assets`下的`color.config`)。
-6. 升级`XCharts`到最新版本。
-7. 通过`菜单栏->XCharts->ImportColorConfig`将`color.config`导入即可恢复自定义的颜色(如果`color.config`不在升级后的项目的`Assets`下的话需要拷贝到此目录下)。
-
[XCharts主页](https://github.com/XCharts-Team/XCharts)
[XChartsAPI](XChartsAPI-ZH.md)
[XCharts配置项手册](XChartsConfiguration-ZH.md)
diff --git a/Documentation/XChartsTutorial01-ZH.md b/Documentation/XChartsTutorial01-ZH.md
index cd456c12..fbd181b7 100644
--- a/Documentation/XChartsTutorial01-ZH.md
+++ b/Documentation/XChartsTutorial01-ZH.md
@@ -7,7 +7,7 @@
## 获取和导入 XCharts
-1. 直接放入XCharts源码到项目
+1. 直接将XCharts源码到项目
下载好XCharts源码后,直接将XCharts目录拷贝到Unity项目工程的Assets目录下。
@@ -17,46 +17,46 @@
3. 通过`Package Manager`导入XCharts
- 对于Unity 2018.3以上版本,可通过 Package Manager来导入XCharts,打开Package Manager后,通过 `Add package form git URL...`,输入XCharts的github URL: https://github.com/XCharts-Team/XCharts.git#master 稍等片刻后即可使用XCharts。
+ 对于Unity 2018.3以上版本,可通过 Package Manager来导入XCharts,打开Package Manager后,通过 `Add package form git URL...`,输入XCharts3.0的GitHub URL: `https://github.com/XCharts-Team/XCharts.git#3.0` 稍等片刻后即可使用XCharts。
也可以直接将package加入到`manifest.json`文件:打开`Packages`目录下的`manifest.json`文件,在`dependencies`下加入:
``` json
- "com.monitor1394.xcharts": "https://github.com/XCharts-Team/XCharts.git#master",
+ "com.monitor1394.xcharts": "https://github.com/XCharts-Team/XCharts.git#3.0",
```
如需更新`XCharts`,删除`manifest.json`文件(部分Unity版本可能是packages-lock.json文件)的`lock`下的`com.monitor1394.xcharts`相关内容即会重新下载编译。
## 添加一个简单图表
-在`Hierarchy`试图下右键或菜单栏`GameObject`下拉:`XCharts->LineChart`:
-
-
-
-即可快速创建一个简单的折线图出来:
+在`Hierarchy`视图下右键或菜单栏`GameObject`下拉选择`XCharts->LineChart`,即可快速创建一个默认的折线图出来:

## 添加多个Seire
-如何在上图的基础上添加两条折线呢,只需`Add Serie`按钮,选择对应的`Serie`类型即可:
+在`Inspector`视图,找到`LineChart`的面板,通过`Add Serie`按钮,可以添加第二条`Line`折线:
+


## 添加其他组件
默认图表没有`Legend`,需要`Legend`组件可通过`Add Component`按钮添加:
+

## 添加Serie组件
-如果需要给折线图区域填充颜色,可单独给`Serie`添加`Component`:
+Serie只自带了几个常见的组件,其他组件按需额外添加。比如,需要给折线图区域填充颜色,可单独给`Serie`添加`AreaStyle`组件:
+


## 添加SerieData组件
-如果需要个性化定制每个数据项的配置,可以单独给每个`SerieData`添加`Component`。比如我们给第一个折线图的第二个数据单独显示`Label`:
+如果需要个性化定制每个数据项的配置,可以单独给每个`SerieData`添加`Component`。比如我们给折线图的第二个数据单独显示`Label`:
+


@@ -68,11 +68,17 @@
## 如何快速调整参数
-`XCharts`是配置参数驱动。想要什么效果,你只需要去调整对应组件下的配置参数就可以,不需要去改`Hierarchy`试图下的节点,因为那些节点是由`XCharts`内部根据配置参数生成的。你改了也会变还原。
+`XCharts`是配置参数驱动。想要什么效果,你只需要去调整对应组件下的配置参数就可以,不需要去改`Hierarchy`视图下的节点,因为那些节点是由`XCharts`内部根据配置参数生成的,即使改了也会在刷新时被还原回来。
快速定位你想要改的效果对应的组件。这就需要对组件有一定的了解。比如我们想要让X轴的轴线末端显示箭头,如何定位?第一步,X轴定位到`XAxis0`;第二步,轴线定位到`AxisLine`;最后,再去看`AxisLine`组件下有没有这样的参数可以实现这个效果。
-`XCharts`提供从全局`Theme`、系列`Serie`、单个数据项`SerieData`全方位的参数配置。优先级从大到小为:`SerieData`->`Serie`->`Theme`。以`ItemStyle`的颜色例,如果`SerieData`的`ItemStyle`配置有颜色值,则优先用这个颜色值。
+`XCharts`提供从全局`Theme`、系列`Serie`、单个数据项`SerieData`全方位的参数配置。优先级从大到小为:`SerieData`->`Serie`->`Theme`。以`ItemStyle`的颜色为例:
+
+1. 如果`SerieData`的`ItemStyle`配置有非`0000`颜色值,则优先用这个颜色值。
+2. 如果`Serie`的`ItemStyle`配置有非`0000`颜色值,则优先用这个颜色值。
+3. 否则颜色值取自主题`Theme`的`Color Palette`。
+
+通常颜色值为0000时表示用主题默认颜色,配置为0或null时表示用主题默认配置。
## 用代码添加折线图
@@ -140,6 +146,7 @@ for (int i = 0; i < 10; i++)
```
这样一个简单的折线图就出来了:
+

如果一个Chart里面有多个系列时,则Axis的data只需要加一次,不要多个循环加重复了。记住:Axis的数据个数要和Serie的数据个数一致。
@@ -148,16 +155,38 @@ for (int i = 0; i < 10; i++)
你还可以用代码控制更多的参数,`Examples`下还有更多的其他例子,凡是`Inspector`上看到的可配置的参数,都可以通过代码来设置。[XCharts配置项手册](XChartsConfiguration-ZH.md)里面的所有参数都是可以通过代码控制的。
-另外,除非定制,建议调用[XChartsAPI接口](https://github.com/XCharts-Team/XCharts/master/Documentation/XChartsAPI-ZH.md) 里面的接口,这些接口内部会做一些关联处理,比如刷新图表等。如果自己调用了内部组件的接口,需要自己处理刷新等其他问题。
+另外,除非定制,建议调用`Chart`下提供的`public`接口,特别是数据相关操作部分。这些接口内部会做一些关联处理,比如刷新图表等。常见的接口有:
+
+1. `chart.ClearData()`:清空图表数据(不移除Series)
+2. `chart.RemoveData()`:清除图表数据(会移除所有Serie)
+3. `chart.AddSerie()`:添加Serie
+4. `chart.AddXAxisData()`:添加X轴数据
+5. `chart.AddData()`:添加Serie数据
+6. `chart.UpdateData()`:更新Serie数据
+7. `chart.UpdateXAxisData()`:更新X轴数据
+8. `chart.UpdateDataName()`:更新Serie数据的名字
+
+XCharts内部有自动刷新机制,但也是在一定条件下。如果自己调用了内部组件的接口,碰到组件没有刷新,确实找不到原因的话,可以用以下两个接口强制刷新:
+
+1. `chart.RefreshAllComponent()`:刷新图表组件,会重新初始化所有组件,不建议频繁待用。
+2. `chart.RefreshChart()`:刷新图表绘制,只刷新绘制部分,不会刷新组件文本,位置等部分。
## 使用TextMeshPro
-XCharts支持TextMeshPro,但默认是不开启的,需要自己手动切换。可通过一下两种方式开启和关闭:
+XCharts支持TextMeshPro,但默认是不开启的,需要自己手动切换。可通过以下方式开启和关闭:
+

-
+
开启后需要设置好TextMeshPro要用的全局字体,也可以在主题Theme里单独设置:
+

-建议在项目初就规划好是否使用TextMeshPro,在有很多图表的情况下再切换,可能导致某些图表无法正常初始化,这时可能需要每个图表单独的使用`Remove All Chart Object`来清理让图表重新初始化。
+
+建议在项目初就规划好是否使用TextMeshPro,并设置好字体。在已有很多图表的情况下切换TMP时,可能某些图表无法自动刷新,可以手动点击`Rebuild Chart Object`按钮来重建图表,即可正常初始化。
+
+开启了TMP项目在更新XCharts时,可能会碰到丢失了TMP引用而无法编译通过的问题,可通过以下两种方式解决:
+
+1. 找到`XCharts.Runtime.asmdef`和`XCharts.Editor.asmdef`,手动加上 `TextMeshPro`的引用
+2. 移除`PlayerSetting`中`Scripting Define Symbols`的`dUI_TextMeshPro`宏
## 用代码改图表参数
@@ -180,7 +209,7 @@ xAxis.type = Axis.AxisType.Category;
### 改Serie的参数
-新添加Serie:
+新添加的Serie:
```C#
var serie = chart.AddSerie();
@@ -220,7 +249,7 @@ var serieData = chart.AddData(0, 20);
//var serieData = serie.GetSerieData(0); //从已有数据中获取
serieData.radius = 10;
-var itemStyle = serieData.GetOrAddComponent(); //启用SerieData的Component
+var itemStyle = serieData.GetOrAddComponent(); //给数据项添加ItemStyle组件
itemStyle.color = Color.blue;
```
diff --git a/Documentation/res/alipay.png b/Documentation/res/alipay.png
index 7cd5ff78..209d49d2 100644
Binary files a/Documentation/res/alipay.png and b/Documentation/res/alipay.png differ
diff --git a/Documentation/res/linechart-simple.png b/Documentation/res/linechart-simple.png
index f58a464c..39e521fd 100644
Binary files a/Documentation/res/linechart-simple.png and b/Documentation/res/linechart-simple.png differ
diff --git a/Documentation/res/linechart.png b/Documentation/res/linechart.png
index 0166a65e..6bb2eea8 100644
Binary files a/Documentation/res/linechart.png and b/Documentation/res/linechart.png differ
diff --git a/Documentation/res/linechart1.png b/Documentation/res/linechart1.png
index 56ff9933..703c6902 100644
Binary files a/Documentation/res/linechart1.png and b/Documentation/res/linechart1.png differ
diff --git a/Documentation/res/linechart2.png b/Documentation/res/linechart2.png
index be5275d4..308870d8 100644
Binary files a/Documentation/res/linechart2.png and b/Documentation/res/linechart2.png differ
diff --git a/Documentation/res/linechart3.png b/Documentation/res/linechart3.png
index 402987b3..a91064e4 100644
Binary files a/Documentation/res/linechart3.png and b/Documentation/res/linechart3.png differ
diff --git a/Documentation/res/linechart4.png b/Documentation/res/linechart4.png
index 11da1846..929591e7 100644
Binary files a/Documentation/res/linechart4.png and b/Documentation/res/linechart4.png differ
diff --git a/Documentation/res/op_addchart.png b/Documentation/res/op_addchart.png
deleted file mode 100644
index ff67262b..00000000
Binary files a/Documentation/res/op_addchart.png and /dev/null differ
diff --git a/Documentation/res/op_addcomponent.png b/Documentation/res/op_addcomponent.png
index 0c56d3da..420e39ab 100644
Binary files a/Documentation/res/op_addcomponent.png and b/Documentation/res/op_addcomponent.png differ
diff --git a/Documentation/res/op_addserie.png b/Documentation/res/op_addserie.png
index 66300c2b..294b5fe7 100644
Binary files a/Documentation/res/op_addserie.png and b/Documentation/res/op_addserie.png differ
diff --git a/Documentation/res/op_addseriecomponent.png b/Documentation/res/op_addseriecomponent.png
index 4976c79e..ecc517fb 100644
Binary files a/Documentation/res/op_addseriecomponent.png and b/Documentation/res/op_addseriecomponent.png differ
diff --git a/Documentation/res/op_addseriedatacomponent.png b/Documentation/res/op_addseriedatacomponent.png
index fe41dd4a..6f74e895 100644
Binary files a/Documentation/res/op_addseriedatacomponent.png and b/Documentation/res/op_addseriedatacomponent.png differ
diff --git a/Documentation/res/op_textmeshpro.png b/Documentation/res/op_textmeshpro.png
index 5d498e9a..8ea4172e 100644
Binary files a/Documentation/res/op_textmeshpro.png and b/Documentation/res/op_textmeshpro.png differ
diff --git a/Documentation/res/op_textmeshpro2.png b/Documentation/res/op_textmeshpro2.png
deleted file mode 100644
index dacb2932..00000000
Binary files a/Documentation/res/op_textmeshpro2.png and /dev/null differ
diff --git a/Documentation/res/op_textmeshpro2.png.meta b/Documentation/res/op_textmeshpro2.png.meta
deleted file mode 100644
index 134cc166..00000000
--- a/Documentation/res/op_textmeshpro2.png.meta
+++ /dev/null
@@ -1,76 +0,0 @@
-fileFormatVersion: 2
-guid: 5b533c6dca4e643c0a3cf0152ea053c3
-TextureImporter:
- fileIDToRecycleName: {}
- externalObjects: {}
- serializedVersion: 4
- mipmaps:
- mipMapMode: 0
- enableMipMap: 1
- sRGBTexture: 1
- linearTexture: 0
- fadeOut: 0
- borderMipMap: 0
- mipMapsPreserveCoverage: 0
- alphaTestReferenceValue: 0.5
- mipMapFadeDistanceStart: 1
- mipMapFadeDistanceEnd: 3
- bumpmap:
- convertToNormalMap: 0
- externalNormalMap: 0
- heightScale: 0.25
- normalMapFilter: 0
- isReadable: 0
- grayScaleToAlpha: 0
- generateCubemap: 6
- cubemapConvolution: 0
- seamlessCubemap: 0
- textureFormat: 1
- maxTextureSize: 2048
- textureSettings:
- serializedVersion: 2
- filterMode: -1
- aniso: -1
- mipBias: -1
- wrapU: -1
- wrapV: -1
- wrapW: -1
- nPOTScale: 1
- lightmap: 0
- compressionQuality: 50
- spriteMode: 0
- spriteExtrude: 1
- spriteMeshType: 1
- alignment: 0
- spritePivot: {x: 0.5, y: 0.5}
- spritePixelsToUnits: 100
- spriteBorder: {x: 0, y: 0, z: 0, w: 0}
- spriteGenerateFallbackPhysicsShape: 1
- alphaUsage: 1
- alphaIsTransparency: 0
- spriteTessellationDetail: -1
- textureType: 0
- textureShape: 1
- maxTextureSizeSet: 0
- compressionQualitySet: 0
- textureFormatSet: 0
- platformSettings:
- - buildTarget: DefaultTexturePlatform
- maxTextureSize: 2048
- resizeAlgorithm: 0
- textureFormat: -1
- textureCompression: 1
- compressionQuality: 50
- crunchedCompression: 0
- allowsAlphaSplitting: 0
- overridden: 0
- androidETC2FallbackOverride: 0
- spriteSheet:
- serializedVersion: 2
- sprites: []
- outline: []
- physicsShape: []
- spritePackingTag:
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Documentation/res/op_textmeshpro3.png b/Documentation/res/op_textmeshpro3.png
index 14b3a404..52f71b77 100644
Binary files a/Documentation/res/op_textmeshpro3.png and b/Documentation/res/op_textmeshpro3.png differ
diff --git a/Documentation/res/wechat.png b/Documentation/res/wechat.png
new file mode 100644
index 00000000..c2f8b677
Binary files /dev/null and b/Documentation/res/wechat.png differ
diff --git a/Documentation/res/op_addchart.png.meta b/Documentation/res/wechat.png.meta
similarity index 97%
rename from Documentation/res/op_addchart.png.meta
rename to Documentation/res/wechat.png.meta
index 37f28a6a..a66a7c3c 100644
--- a/Documentation/res/op_addchart.png.meta
+++ b/Documentation/res/wechat.png.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 33ca1e807bf9b44daa62fa68040f7a17
+guid: c62c735b2989c4367b8c97b8ca75c216
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
diff --git a/Editor/Attributes/ComponentEditorAttribute.cs b/Editor/Attributes/ComponentEditorAttribute.cs
index 563dd05f..3e5d4601 100644
--- a/Editor/Attributes/ComponentEditorAttribute.cs
+++ b/Editor/Attributes/ComponentEditorAttribute.cs
@@ -1,5 +1,3 @@
-
-
using System;
namespace XCharts.Editor
diff --git a/Editor/Attributes/SerieEditorAttribute.cs b/Editor/Attributes/SerieEditorAttribute.cs
index 37ec0b40..c747be6f 100644
--- a/Editor/Attributes/SerieEditorAttribute.cs
+++ b/Editor/Attributes/SerieEditorAttribute.cs
@@ -1,5 +1,3 @@
-
-
using System;
namespace XCharts.Editor
diff --git a/Editor/Charts/BaseChartEditor.cs b/Editor/Charts/BaseChartEditor.cs
index 85ad890b..617d12ef 100644
--- a/Editor/Charts/BaseChartEditor.cs
+++ b/Editor/Charts/BaseChartEditor.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using System.Text;
@@ -45,7 +44,7 @@ namespace XCharts.Editor
protected virtual void OnEnable()
{
if (target == null) return;
- m_Chart = (BaseChart)target;
+ m_Chart = (BaseChart) target;
m_Script = serializedObject.FindProperty("m_Script");
m_EnableTextMeshPro = serializedObject.FindProperty("m_EnableTextMeshPro");
m_ChartName = serializedObject.FindProperty("m_ChartName");
@@ -172,7 +171,7 @@ namespace XCharts.Editor
{
m_Series.Add(prop.GetArrayElementAtIndex(i));
}
- m_Series.Sort(delegate (SerializedProperty a, SerializedProperty b)
+ m_Series.Sort(delegate(SerializedProperty a, SerializedProperty b)
{
var index1 = a.FindPropertyRelative("m_Index").intValue;
var index2 = b.FindPropertyRelative("m_Index").intValue;
diff --git a/Editor/ChildComponents/AnimationDrawer.cs b/Editor/ChildComponents/AnimationDrawer.cs
index baf8c09d..d0fb76c9 100644
--- a/Editor/ChildComponents/AnimationDrawer.cs
+++ b/Editor/ChildComponents/AnimationDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/AreaStyleDrawer.cs b/Editor/ChildComponents/AreaStyleDrawer.cs
index b581f48d..25aa9bc5 100644
--- a/Editor/ChildComponents/AreaStyleDrawer.cs
+++ b/Editor/ChildComponents/AreaStyleDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/BasePropertyDrawer.cs b/Editor/ChildComponents/BasePropertyDrawer.cs
index 61cc5265..77ae7b08 100644
--- a/Editor/ChildComponents/BasePropertyDrawer.cs
+++ b/Editor/ChildComponents/BasePropertyDrawer.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@@ -110,7 +109,7 @@ namespace XCharts.Editor
{
if (IngorePropertys.Contains(relativePropName)) return;
if (!ChartEditorHelper.PropertyFieldWithMinValue(ref m_DrawRect, m_Heights, m_KeyName, prop,
- relativePropName, minValue))
+ relativePropName, minValue))
{
Debug.LogError("PropertyField ERROR:" + prop.displayName + ", " + relativePropName);
}
@@ -119,7 +118,7 @@ namespace XCharts.Editor
{
if (IngorePropertys.Contains(relativePropName)) return;
if (!ChartEditorHelper.PropertyFieldWithMaxValue(ref m_DrawRect, m_Heights, m_KeyName, prop,
- relativePropName, maxValue))
+ relativePropName, maxValue))
{
Debug.LogError("PropertyField ERROR:" + prop.displayName + ", " + relativePropName);
}
@@ -163,25 +162,40 @@ namespace XCharts.Editor
}
}
protected bool MakeComponentFoldout(SerializedProperty prop, string relativePropName, bool relativePropEnable,
- params HeaderMenuInfo[] menus)
+ params HeaderMenuInfo[] menus)
{
if (string.IsNullOrEmpty(relativePropName))
{
return ChartEditorHelper.MakeComponentFoldout(ref m_DrawRect, m_Heights, m_PropToggles, m_KeyName,
- m_DisplayName, null, relativePropEnable, menus);
+ m_DisplayName, null, null, relativePropEnable, menus);
}
else
- {
+ {
var relativeProp = prop.FindPropertyRelative(relativePropName);
return ChartEditorHelper.MakeComponentFoldout(ref m_DrawRect, m_Heights, m_PropToggles, m_KeyName,
- m_DisplayName, relativeProp, relativePropEnable, menus);
+ m_DisplayName, relativeProp, null, relativePropEnable, menus);
}
}
- protected virtual void DrawExtendeds(SerializedProperty prop)
+ protected bool MakeComponentFoldout(SerializedProperty prop, string relativePropName, string relativePropName2,
+ bool relativePropEnable, params HeaderMenuInfo[] menus)
{
+ if (string.IsNullOrEmpty(relativePropName))
+ {
+ return ChartEditorHelper.MakeComponentFoldout(ref m_DrawRect, m_Heights, m_PropToggles, m_KeyName,
+ m_DisplayName, null, null, relativePropEnable, menus);
+ }
+ else
+ {
+ var relativeProp = prop.FindPropertyRelative(relativePropName);
+ var relativeProp2 = prop.FindPropertyRelative(relativePropName2);
+ return ChartEditorHelper.MakeComponentFoldout(ref m_DrawRect, m_Heights, m_PropToggles, m_KeyName,
+ m_DisplayName, relativeProp, relativeProp2, relativePropEnable, menus);
+ }
}
+ protected virtual void DrawExtendeds(SerializedProperty prop) { }
+
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
var key = GetKeyName(prop);
diff --git a/Editor/ChildComponents/CommentItemDrawer.cs b/Editor/ChildComponents/CommentItemDrawer.cs
new file mode 100644
index 00000000..962ba612
--- /dev/null
+++ b/Editor/ChildComponents/CommentItemDrawer.cs
@@ -0,0 +1,26 @@
+using UnityEditor;
+using UnityEngine;
+using XCharts.Runtime;
+
+namespace XCharts.Editor
+{
+ [CustomPropertyDrawer(typeof(CommentItem), true)]
+ public class CommentItemDrawer : BasePropertyDrawer
+ {
+ public override string ClassName { get { return "CommentItem"; } }
+ public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
+ {
+ base.OnGUI(pos, prop, label);
+ if (MakeComponentFoldout(prop, "m_Show", "m_Content", true))
+ {
+ ++EditorGUI.indentLevel;
+ PropertyField(prop, "m_Content");
+ PropertyField(prop, "m_Position");
+ //PropertyField(prop, "m_MarkRect");
+ //PropertyField(prop, "m_MarkStyle");
+ PropertyField(prop, "m_LabelStyle");
+ --EditorGUI.indentLevel;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Editor/ChildComponents/SerieDataBaseInfoDrawer.cs.meta b/Editor/ChildComponents/CommentItemDrawer.cs.meta
similarity index 83%
rename from Editor/ChildComponents/SerieDataBaseInfoDrawer.cs.meta
rename to Editor/ChildComponents/CommentItemDrawer.cs.meta
index fac13527..dc4966bb 100644
--- a/Editor/ChildComponents/SerieDataBaseInfoDrawer.cs.meta
+++ b/Editor/ChildComponents/CommentItemDrawer.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 418b81a68e59a4572ab57787b5362d5a
+guid: d485d6a729a1449cdb5032f380fba70f
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Editor/ChildComponents/CommentMarkStyleDrawer.cs b/Editor/ChildComponents/CommentMarkStyleDrawer.cs
new file mode 100644
index 00000000..126d7cda
--- /dev/null
+++ b/Editor/ChildComponents/CommentMarkStyleDrawer.cs
@@ -0,0 +1,22 @@
+using UnityEditor;
+using UnityEngine;
+using XCharts.Runtime;
+
+namespace XCharts.Editor
+{
+ [CustomPropertyDrawer(typeof(CommentMarkStyle), true)]
+ public class CommentMarkStyleDrawer : BasePropertyDrawer
+ {
+ public override string ClassName { get { return "MarkStyle"; } }
+ public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
+ {
+ base.OnGUI(pos, prop, label);
+ if (MakeComponentFoldout(prop, "m_Show", true))
+ {
+ ++EditorGUI.indentLevel;
+ PropertyField(prop, "m_LineStyle");
+ --EditorGUI.indentLevel;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Component/Child/SerieDataBaseInfo.cs.meta b/Editor/ChildComponents/CommentMarkStyleDrawer.cs.meta
similarity index 83%
rename from Runtime/Component/Child/SerieDataBaseInfo.cs.meta
rename to Editor/ChildComponents/CommentMarkStyleDrawer.cs.meta
index a311a0e1..d54117be 100644
--- a/Runtime/Component/Child/SerieDataBaseInfo.cs.meta
+++ b/Editor/ChildComponents/CommentMarkStyleDrawer.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: a6d8757fbd847419aaed450e020e827c
+guid: d74ed458b24774b129611ed816b6b6cd
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Editor/ChildComponents/ComponentThemeDrawer.cs b/Editor/ChildComponents/ComponentThemeDrawer.cs
index 2487692f..06bec277 100644
--- a/Editor/ChildComponents/ComponentThemeDrawer.cs
+++ b/Editor/ChildComponents/ComponentThemeDrawer.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@@ -59,6 +58,7 @@ namespace XCharts.Editor
{
public override string ClassName { get { return "Axis"; } }
}
+
[CustomPropertyDrawer(typeof(RadiusAxisTheme), true)]
public class RadiusAxisThemeDrawer : BaseAxisThemeDrawer
{
@@ -67,8 +67,9 @@ namespace XCharts.Editor
{
get
{
- return new List {
- "m_TextBackgroundColor" ,
+ return new List
+ {
+ "m_TextBackgroundColor",
"m_LineLength",
"m_SplitLineLength",
};
diff --git a/Editor/ChildComponents/DebugInfoDrawer.cs b/Editor/ChildComponents/DebugInfoDrawer.cs
index 5159dec1..af03faf3 100644
--- a/Editor/ChildComponents/DebugInfoDrawer.cs
+++ b/Editor/ChildComponents/DebugInfoDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/EmphasisStyleDrawer.cs b/Editor/ChildComponents/EmphasisStyleDrawer.cs
index 509f65c9..89377f3d 100644
--- a/Editor/ChildComponents/EmphasisStyleDrawer.cs
+++ b/Editor/ChildComponents/EmphasisStyleDrawer.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@@ -23,4 +22,22 @@ namespace XCharts.Editor
}
}
}
+
+ [CustomPropertyDrawer(typeof(EmphasisItemStyle), true)]
+ public class EmphasisItemStyleDrawer : ItemStyleDrawer
+ {
+ public override string ClassName { get { return "EmphasisItemStyle"; } }
+ }
+
+ [CustomPropertyDrawer(typeof(EmphasisLabelStyle), true)]
+ public class EmphasisLabelStyleDrawer : LabelStyleDrawer
+ {
+ public override string ClassName { get { return "EmphasisLabel"; } }
+ }
+
+ [CustomPropertyDrawer(typeof(EmphasisLabelLine), true)]
+ public class EmphasisLabelLineDrawer : LabelLineDrawer
+ {
+ public override string ClassName { get { return "EmphasisLabelLine"; } }
+ }
}
\ No newline at end of file
diff --git a/Editor/ChildComponents/IconStyleDrawer.cs b/Editor/ChildComponents/IconStyleDrawer.cs
index 803179d5..2f2e1a6f 100644
--- a/Editor/ChildComponents/IconStyleDrawer.cs
+++ b/Editor/ChildComponents/IconStyleDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/ImageStyleDrawer.cs b/Editor/ChildComponents/ImageStyleDrawer.cs
index 973d923d..8ad71d43 100644
--- a/Editor/ChildComponents/ImageStyleDrawer.cs
+++ b/Editor/ChildComponents/ImageStyleDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/ItemStyleDrawer.cs b/Editor/ChildComponents/ItemStyleDrawer.cs
index d41dd7ac..50978b07 100644
--- a/Editor/ChildComponents/ItemStyleDrawer.cs
+++ b/Editor/ChildComponents/ItemStyleDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/LabelLineDrawer.cs b/Editor/ChildComponents/LabelLineDrawer.cs
index 3888cbef..dcd2d6c3 100644
--- a/Editor/ChildComponents/LabelLineDrawer.cs
+++ b/Editor/ChildComponents/LabelLineDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/LabelStyleDrawer.cs b/Editor/ChildComponents/LabelStyleDrawer.cs
index 04117877..9ead373a 100644
--- a/Editor/ChildComponents/LabelStyleDrawer.cs
+++ b/Editor/ChildComponents/LabelStyleDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
@@ -28,6 +27,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_Background");
PropertyField(prop, "m_TextStyle");
PropertyField(prop, "m_TextPadding");
+ PropertyField(prop, "m_TextLimit");
--EditorGUI.indentLevel;
}
}
diff --git a/Editor/ChildComponents/LevelStyleDrawer.cs b/Editor/ChildComponents/LevelStyleDrawer.cs
index 38fb60aa..8879a5e7 100644
--- a/Editor/ChildComponents/LevelStyleDrawer.cs
+++ b/Editor/ChildComponents/LevelStyleDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/LineArrowDrawer.cs b/Editor/ChildComponents/LineArrowDrawer.cs
index 35929365..031498fa 100644
--- a/Editor/ChildComponents/LineArrowDrawer.cs
+++ b/Editor/ChildComponents/LineArrowDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
@@ -24,7 +23,7 @@ namespace XCharts.Editor
}
}
}
-
+
[CustomPropertyDrawer(typeof(LineArrow), true)]
public class LineArrowStyleDrawer : BasePropertyDrawer
{
diff --git a/Editor/ChildComponents/LineDrawer.cs b/Editor/ChildComponents/LineDrawer.cs
index e88a8cd8..b3d4896d 100644
--- a/Editor/ChildComponents/LineDrawer.cs
+++ b/Editor/ChildComponents/LineDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
@@ -47,6 +46,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_AutoColor");
}
}
+
[CustomPropertyDrawer(typeof(AxisTick), true)]
public class AxisTickDrawer : BaseLineDrawer
{
diff --git a/Editor/ChildComponents/LineStyleDrawer.cs b/Editor/ChildComponents/LineStyleDrawer.cs
index 623a5a18..17d6facb 100644
--- a/Editor/ChildComponents/LineStyleDrawer.cs
+++ b/Editor/ChildComponents/LineStyleDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/LocationDrawer.cs b/Editor/ChildComponents/LocationDrawer.cs
index dd279697..2cfe5963 100644
--- a/Editor/ChildComponents/LocationDrawer.cs
+++ b/Editor/ChildComponents/LocationDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/SerieDataBaseInfoDrawer.cs b/Editor/ChildComponents/SerieDataBaseInfoDrawer.cs
deleted file mode 100644
index 87673c5f..00000000
--- a/Editor/ChildComponents/SerieDataBaseInfoDrawer.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-
-using UnityEditor;
-using UnityEngine;
-using XCharts.Runtime;
-
-namespace XCharts.Editor
-{
- [CustomPropertyDrawer(typeof(SerieDataBaseInfo), true)]
- public class SerieDataBaseInfoDrawer : BasePropertyDrawer
- {
- public override string ClassName { get { return "BaseInfo"; } }
- public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
- {
- base.OnGUI(pos, prop, label);
- if (MakeComponentFoldout(prop, "m_Show", false))
- {
- ++EditorGUI.indentLevel;
- PropertyField(prop, "m_Ignore");
- PropertyField(prop, "m_Selected");
- PropertyField(prop, "m_Radius");
- --EditorGUI.indentLevel;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Editor/ChildComponents/SerieSymbolDrawer.cs b/Editor/ChildComponents/SerieSymbolDrawer.cs
index dac474db..0f3e214a 100644
--- a/Editor/ChildComponents/SerieSymbolDrawer.cs
+++ b/Editor/ChildComponents/SerieSymbolDrawer.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@@ -16,7 +15,7 @@ namespace XCharts.Editor
if (MakeComponentFoldout(prop, "m_Show", true))
{
++EditorGUI.indentLevel;
- var type = (SymbolType)prop.FindPropertyRelative("m_Type").enumValueIndex;
+ var type = (SymbolType) prop.FindPropertyRelative("m_Type").enumValueIndex;
PropertyField(prop, "m_Type");
if (type == SymbolType.Custom)
{
@@ -28,7 +27,7 @@ namespace XCharts.Editor
}
PropertyField(prop, "m_Gap");
PropertyField(prop, "m_SizeType");
- switch ((SymbolSizeType)prop.FindPropertyRelative("m_SizeType").enumValueIndex)
+ switch ((SymbolSizeType) prop.FindPropertyRelative("m_SizeType").enumValueIndex)
{
case SymbolSizeType.Custom:
PropertyField(prop, "m_Size");
diff --git a/Editor/ChildComponents/SettingsDrawer.cs b/Editor/ChildComponents/SettingsDrawer.cs
index db2a1c70..ac798997 100644
--- a/Editor/ChildComponents/SettingsDrawer.cs
+++ b/Editor/ChildComponents/SettingsDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
@@ -13,10 +12,10 @@ namespace XCharts.Editor
{
base.OnGUI(pos, prop, label);
if (MakeComponentFoldout(prop, "m_Show", false, new HeaderMenuInfo("Reset", () =>
- {
- var chart = prop.serializedObject.targetObject as BaseChart;
- chart.settings.Reset();
- })))
+ {
+ var chart = prop.serializedObject.targetObject as BaseChart;
+ chart.settings.Reset();
+ })))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_ReversePainter");
diff --git a/Editor/ChildComponents/SymbolStyleDrawer.cs b/Editor/ChildComponents/SymbolStyleDrawer.cs
index fcd854bc..d30ac905 100644
--- a/Editor/ChildComponents/SymbolStyleDrawer.cs
+++ b/Editor/ChildComponents/SymbolStyleDrawer.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@@ -16,7 +15,7 @@ namespace XCharts.Editor
if (MakeComponentFoldout(prop, "m_Show", true))
{
++EditorGUI.indentLevel;
- var type = (SymbolType)prop.FindPropertyRelative("m_Type").enumValueIndex;
+ var type = (SymbolType) prop.FindPropertyRelative("m_Type").enumValueIndex;
PropertyField(prop, "m_Type");
if (type == SymbolType.Custom)
{
diff --git a/Editor/ChildComponents/TextLimitDrawer.cs b/Editor/ChildComponents/TextLimitDrawer.cs
index bcbdfdb4..cbc0bbf3 100644
--- a/Editor/ChildComponents/TextLimitDrawer.cs
+++ b/Editor/ChildComponents/TextLimitDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/TextPaddingDrawer.cs b/Editor/ChildComponents/TextPaddingDrawer.cs
index e6821a40..608605d5 100644
--- a/Editor/ChildComponents/TextPaddingDrawer.cs
+++ b/Editor/ChildComponents/TextPaddingDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/ChildComponents/TextStyleDrawer.cs b/Editor/ChildComponents/TextStyleDrawer.cs
index 800a58f0..edaf6d0e 100644
--- a/Editor/ChildComponents/TextStyleDrawer.cs
+++ b/Editor/ChildComponents/TextStyleDrawer.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
#if dUI_TextMeshPro
diff --git a/Editor/ChildComponents/ThemeDrawer.cs b/Editor/ChildComponents/ThemeDrawer.cs
index f5743e3e..573fb02d 100644
--- a/Editor/ChildComponents/ThemeDrawer.cs
+++ b/Editor/ChildComponents/ThemeDrawer.cs
@@ -1,4 +1,3 @@
-
using System.IO;
using UnityEditor;
using UnityEngine;
@@ -20,17 +19,17 @@ namespace XCharts.Editor
var defaultX = pos.x;
var chart = prop.serializedObject.targetObject as BaseChart;
if (MakeComponentFoldout(prop, "m_Show", false, new HeaderMenuInfo("Reset|Reset to theme default color", () =>
- {
- chart.theme.sharedTheme.ResetTheme();
- chart.RefreshAllComponent();
- }), new HeaderMenuInfo("Export|Export theme to asset for a new theme", () =>
- {
- ExportThemeWindow.target = chart;
- EditorWindow.GetWindow(typeof(ExportThemeWindow));
- }), new HeaderMenuInfo("Sync color to custom|Sync shared theme color to custom color", () =>
- {
- chart.theme.SyncSharedThemeColorToCustom();
- })))
+ {
+ chart.theme.sharedTheme.ResetTheme();
+ chart.RefreshAllComponent();
+ }), new HeaderMenuInfo("Export|Export theme to asset for a new theme", () =>
+ {
+ ExportThemeWindow.target = chart;
+ EditorWindow.GetWindow(typeof(ExportThemeWindow));
+ }), new HeaderMenuInfo("Sync color to custom|Sync shared theme color to custom color", () =>
+ {
+ chart.theme.SyncSharedThemeColorToCustom();
+ })))
{
++EditorGUI.indentLevel;
var chartNameList = XCThemeMgr.GetAllThemeNames();
@@ -46,12 +45,12 @@ namespace XCharts.Editor
PropertyField(prop, "m_SharedTheme");
PropertyField(prop, "m_TransparentBackground");
PropertyField(prop, "m_EnableCustomTheme");
- using (new EditorGUI.DisabledScope(!prop.FindPropertyRelative("m_EnableCustomTheme").boolValue))
- {
- PropertyField(prop, "m_CustomBackgroundColor");
- PropertyField(prop, "m_CustomColorPalette");
- }
- --EditorGUI.indentLevel;
+ using(new EditorGUI.DisabledScope(!prop.FindPropertyRelative("m_EnableCustomTheme").boolValue))
+ {
+ PropertyField(prop, "m_CustomBackgroundColor");
+ PropertyField(prop, "m_CustomColorPalette");
+ }
+ --EditorGUI.indentLevel;
}
}
@@ -71,7 +70,7 @@ namespace XCharts.Editor
private string m_ChartName;
static void Init()
{
- window = (ExportThemeWindow)EditorWindow.GetWindow(typeof(ExportThemeWindow), false, "Export Theme", true);
+ window = (ExportThemeWindow) EditorWindow.GetWindow(typeof(ExportThemeWindow), false, "Export Theme", true);
window.minSize = new Vector2(600, 50);
window.maxSize = new Vector2(600, 50);
window.Show();
@@ -117,14 +116,14 @@ namespace XCharts.Editor
}
else if (IsAssetsExist(XCThemeMgr.GetThemeAssetPath(m_ChartName)))
{
- ShowNotification(new GUIContent("ERROR:The asset is exist! \npath="
- + XCThemeMgr.GetThemeAssetPath(m_ChartName)));
+ ShowNotification(new GUIContent("ERROR:The asset is exist! \npath=" +
+ XCThemeMgr.GetThemeAssetPath(m_ChartName)));
}
else
{
XCThemeMgr.ExportTheme(target.theme.sharedTheme, m_ChartName);
- ShowNotification(new GUIContent("SUCCESS:The theme is exported. \npath="
- + XCThemeMgr.GetThemeAssetPath(m_ChartName)));
+ ShowNotification(new GUIContent("SUCCESS:The theme is exported. \npath=" +
+ XCThemeMgr.GetThemeAssetPath(m_ChartName)));
}
}
}
diff --git a/Editor/ChildComponents/TitleStyleDrawer.cs b/Editor/ChildComponents/TitleStyleDrawer.cs
index 98c4384c..66ad6d67 100644
--- a/Editor/ChildComponents/TitleStyleDrawer.cs
+++ b/Editor/ChildComponents/TitleStyleDrawer.cs
@@ -1,4 +1,4 @@
-using UnityEditor;
+using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/MainComponents/AxisEditor.cs b/Editor/MainComponents/AxisEditor.cs
index bf5d18ed..652d0d39 100644
--- a/Editor/MainComponents/AxisEditor.cs
+++ b/Editor/MainComponents/AxisEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
@@ -13,7 +12,7 @@ namespace XCharts.Editor
var m_Type = baseProperty.FindPropertyRelative("m_Type");
var m_LogBase = baseProperty.FindPropertyRelative("m_LogBase");
var m_MinMaxType = baseProperty.FindPropertyRelative("m_MinMaxType");
- var type = (Axis.AxisType)m_Type.enumValueIndex;
+ var type = (Axis.AxisType) m_Type.enumValueIndex;
EditorGUI.indentLevel++;
if (component is ParallelAxis)
{
@@ -41,7 +40,7 @@ namespace XCharts.Editor
if (type == Axis.AxisType.Value || type == Axis.AxisType.Time)
{
PropertyField("m_MinMaxType");
- Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType)m_MinMaxType.enumValueIndex;
+ Axis.AxisMinMaxType minMaxType = (Axis.AxisMinMaxType) m_MinMaxType.enumValueIndex;
switch (minMaxType)
{
case Axis.AxisMinMaxType.Default:
@@ -95,13 +94,11 @@ namespace XCharts.Editor
[ComponentEditor(typeof(XAxis))]
public class XAxisEditor : AxisEditor
- {
- }
+ { }
[ComponentEditor(typeof(YAxis))]
public class YAxisEditor : AxisEditor
- {
- }
+ { }
[ComponentEditor(typeof(SingleAxis))]
public class SingleAxisEditor : AxisEditor
@@ -132,13 +129,11 @@ namespace XCharts.Editor
[ComponentEditor(typeof(RadiusAxis))]
public class RadiusAxisEditor : AxisEditor
- {
- }
+ { }
[ComponentEditor(typeof(ParallelAxis))]
public class ParallelAxisEditor : AxisEditor
- {
- }
+ { }
[CustomPropertyDrawer(typeof(AxisLabel), true)]
public class AxisLabelDrawer : BasePropertyDrawer
@@ -159,6 +154,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_ShowEndLabel");
PropertyField(prop, "m_Rotate");
+ PropertyField(prop, "m_Offset");
PropertyField(prop, "m_Distance");
PropertyField(prop, "m_Formatter");
PropertyField(prop, "m_NumericFormatter");
@@ -168,6 +164,7 @@ namespace XCharts.Editor
PropertyField(prop, "m_Background");
PropertyField(prop, "m_TextStyle");
PropertyField(prop, "m_TextPadding");
+ PropertyField(prop, "m_TextLimit");
--EditorGUI.indentLevel;
}
}
diff --git a/Editor/MainComponents/BackgroundEditor.cs b/Editor/MainComponents/BackgroundEditor.cs
index 25b9b5d1..33c84f3c 100644
--- a/Editor/MainComponents/BackgroundEditor.cs
+++ b/Editor/MainComponents/BackgroundEditor.cs
@@ -1,5 +1,3 @@
-
-
using UnityEditor;
using XCharts.Runtime;
diff --git a/Editor/MainComponents/CommentEditor.cs b/Editor/MainComponents/CommentEditor.cs
new file mode 100644
index 00000000..922e44a4
--- /dev/null
+++ b/Editor/MainComponents/CommentEditor.cs
@@ -0,0 +1,18 @@
+using UnityEditor;
+using XCharts.Runtime;
+
+namespace XCharts.Editor
+{
+ [ComponentEditor(typeof(Comment))]
+ public class CommentEditor : MainComponentEditor
+ {
+ public override void OnInspectorGUI()
+ {
+ ++EditorGUI.indentLevel;
+ PropertyField("m_LabelStyle");
+ //PropertyField("m_MarkStyle");
+ PropertyListField("m_Items", true);
+ --EditorGUI.indentLevel;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Editor/MainComponents/CommentEditor.cs.meta b/Editor/MainComponents/CommentEditor.cs.meta
new file mode 100644
index 00000000..8c2401fe
--- /dev/null
+++ b/Editor/MainComponents/CommentEditor.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f2364066bf3174aa39b79020266ce72d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Editor/MainComponents/DataZoomEditor.cs b/Editor/MainComponents/DataZoomEditor.cs
index 81ca348e..f54c0012 100644
--- a/Editor/MainComponents/DataZoomEditor.cs
+++ b/Editor/MainComponents/DataZoomEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using XCharts.Runtime;
diff --git a/Editor/MainComponents/GridCoordEditor.cs b/Editor/MainComponents/GridCoordEditor.cs
index d507a78e..460161ce 100644
--- a/Editor/MainComponents/GridCoordEditor.cs
+++ b/Editor/MainComponents/GridCoordEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using XCharts.Runtime;
diff --git a/Editor/MainComponents/LegendEditor.cs b/Editor/MainComponents/LegendEditor.cs
index b9835e0f..34fc3242 100644
--- a/Editor/MainComponents/LegendEditor.cs
+++ b/Editor/MainComponents/LegendEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using XCharts.Runtime;
@@ -15,12 +14,14 @@ namespace XCharts.Editor
PropertyField("m_ItemHeight");
PropertyField("m_ItemGap");
PropertyField("m_ItemAutoColor");
+ PropertyField("m_ItemOpacity");
PropertyField("m_SelectedMode");
PropertyField("m_Orient");
PropertyField("m_Formatter");
PropertyField("m_Location");
PropertyField("m_LabelStyle");
PropertyListField("m_Icons");
+ PropertyListField("m_Colors");
PropertyListField("m_Data");
--EditorGUI.indentLevel;
}
diff --git a/Editor/MainComponents/MainComponentBaseEditor.cs b/Editor/MainComponents/MainComponentBaseEditor.cs
index 1646cd4b..eb7b9b09 100644
--- a/Editor/MainComponents/MainComponentBaseEditor.cs
+++ b/Editor/MainComponents/MainComponentBaseEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using UnityEngine.Assertions;
@@ -28,12 +27,10 @@ namespace XCharts.Editor
}
public virtual void OnEnable()
- {
- }
+ { }
public virtual void OnDisable()
- {
- }
+ { }
internal void OnInternalInspectorGUI()
{
@@ -42,12 +39,10 @@ namespace XCharts.Editor
}
public virtual void OnInspectorGUI()
- {
- }
+ { }
protected virtual void DrawExtendeds()
- {
- }
+ { }
public virtual string GetDisplayTitle()
{
diff --git a/Editor/MainComponents/MainComponentEditor.cs b/Editor/MainComponents/MainComponentEditor.cs
index e8bc3abb..05e2896a 100644
--- a/Editor/MainComponents/MainComponentEditor.cs
+++ b/Editor/MainComponents/MainComponentEditor.cs
@@ -1,10 +1,8 @@
-
using XCharts.Runtime;
namespace XCharts.Editor
{
public class MainComponentEditor : MainComponentBaseEditor
- where T : MainComponent
- {
- }
+ where T : MainComponent
+ { }
}
\ No newline at end of file
diff --git a/Editor/MainComponents/MainComponentListEditor.cs b/Editor/MainComponents/MainComponentListEditor.cs
index 68afc0a3..211cb31b 100644
--- a/Editor/MainComponents/MainComponentListEditor.cs
+++ b/Editor/MainComponents/MainComponentListEditor.cs
@@ -1,9 +1,8 @@
-
using System;
using System.Collections.Generic;
-using UnityEngine.Assertions;
-using UnityEditor;
using System.Linq;
+using UnityEditor;
+using UnityEngine.Assertions;
using XCharts.Runtime;
namespace XCharts.Editor
@@ -84,7 +83,7 @@ namespace XCharts.Editor
editor.showProperty,
() => { ResetComponentEditor(id); },
() => { RemoveComponentEditor(id); }
- );
+ );
if (displayContent)
{
editor.OnInternalInspectorGUI();
@@ -120,7 +119,7 @@ namespace XCharts.Editor
if (!m_EditorTypes.TryGetValue(settingsType, out editorType))
editorType = typeof(MainComponentBaseEditor);
- var editor = (MainComponentBaseEditor)Activator.CreateInstance(editorType);
+ var editor = (MainComponentBaseEditor) Activator.CreateInstance(editorType);
editor.Init(chart, component, property, m_BaseEditor);
if (index < 0)
diff --git a/Editor/MainComponents/MarkAreaEditor.cs b/Editor/MainComponents/MarkAreaEditor.cs
index 6ca86420..43e2894e 100644
--- a/Editor/MainComponents/MarkAreaEditor.cs
+++ b/Editor/MainComponents/MarkAreaEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
@@ -31,7 +30,7 @@ namespace XCharts.Editor
if (MakeComponentFoldout(prop, "", true))
{
++EditorGUI.indentLevel;
- var type = (MarkAreaType)(prop.FindPropertyRelative("m_Type")).enumValueIndex;
+ var type = (MarkAreaType) (prop.FindPropertyRelative("m_Type")).enumValueIndex;
PropertyField(prop, "m_Type");
PropertyField(prop, "m_Name");
switch (type)
diff --git a/Editor/MainComponents/MarkLineEditor.cs b/Editor/MainComponents/MarkLineEditor.cs
index 053895d7..6c8530ae 100644
--- a/Editor/MainComponents/MarkLineEditor.cs
+++ b/Editor/MainComponents/MarkLineEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
@@ -28,7 +27,7 @@ namespace XCharts.Editor
if (MakeComponentFoldout(prop, "", true))
{
++EditorGUI.indentLevel;
- var type = (MarkLineType)(prop.FindPropertyRelative("m_Type")).enumValueIndex;
+ var type = (MarkLineType) (prop.FindPropertyRelative("m_Type")).enumValueIndex;
var group = prop.FindPropertyRelative("m_Group").intValue;
PropertyField(prop, "m_Type");
PropertyField(prop, "m_Name");
diff --git a/Editor/MainComponents/ParallelCoordEditor.cs b/Editor/MainComponents/ParallelCoordEditor.cs
index bc76ff4c..3a216f3c 100644
--- a/Editor/MainComponents/ParallelCoordEditor.cs
+++ b/Editor/MainComponents/ParallelCoordEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using XCharts.Runtime;
diff --git a/Editor/MainComponents/PolarCoordEditor.cs b/Editor/MainComponents/PolarCoordEditor.cs
index 374db56d..8d359e74 100644
--- a/Editor/MainComponents/PolarCoordEditor.cs
+++ b/Editor/MainComponents/PolarCoordEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using XCharts.Runtime;
diff --git a/Editor/MainComponents/RadarCoordEditor.cs b/Editor/MainComponents/RadarCoordEditor.cs
index 8b3c076b..752ec816 100644
--- a/Editor/MainComponents/RadarCoordEditor.cs
+++ b/Editor/MainComponents/RadarCoordEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Editor/MainComponents/ThemeEditor.cs b/Editor/MainComponents/ThemeEditor.cs
index 29c79595..86fcf5f7 100644
--- a/Editor/MainComponents/ThemeEditor.cs
+++ b/Editor/MainComponents/ThemeEditor.cs
@@ -1,5 +1,3 @@
-
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
@@ -12,7 +10,14 @@ namespace XCharts.Editor
[CustomEditor(typeof(Theme))]
public class ThemeEditor : UnityEditor.Editor
{
+ static class Styles
+ {
+ internal static GUIContent btnReset = new GUIContent("Reset", "Reset to default theme");
+ internal static GUIContent btnSync = new GUIContent("Sync Font", "Sync main theme font to sub theme font");
+ }
+
private Theme m_Theme;
+
void OnEnable()
{
m_Theme = target as Theme;
@@ -20,15 +25,15 @@ namespace XCharts.Editor
public override void OnInspectorGUI()
{
- // serializedObject.Update();
- // EditorGUILayout.PropertyField(m_BackgroundColor);
- // EditorGUILayout.PropertyField(m_ColorPalette);
- // serializedObject.ApplyModifiedProperties();
base.OnInspectorGUI();
- if (GUILayout.Button(new GUIContent("Reset", "Reset to default theme")))
+ if (GUILayout.Button(Styles.btnReset))
{
m_Theme.ResetTheme();
}
+ if (GUILayout.Button(Styles.btnSync))
+ {
+ m_Theme.SyncFontToSubComponent();
+ }
}
}
}
\ No newline at end of file
diff --git a/Editor/MainComponents/TitleEditor.cs b/Editor/MainComponents/TitleEditor.cs
index 5a275efa..2a22c056 100644
--- a/Editor/MainComponents/TitleEditor.cs
+++ b/Editor/MainComponents/TitleEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using XCharts.Runtime;
diff --git a/Editor/MainComponents/TooltipEditor.cs b/Editor/MainComponents/TooltipEditor.cs
index 6b8b55cc..af7b4344 100644
--- a/Editor/MainComponents/TooltipEditor.cs
+++ b/Editor/MainComponents/TooltipEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using XCharts.Runtime;
diff --git a/Editor/MainComponents/VisualMapEditor.cs b/Editor/MainComponents/VisualMapEditor.cs
index 16354f68..059f3c41 100644
--- a/Editor/MainComponents/VisualMapEditor.cs
+++ b/Editor/MainComponents/VisualMapEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
@@ -11,7 +10,7 @@ namespace XCharts.Editor
public override void OnInspectorGUI()
{
++EditorGUI.indentLevel;
- var type = (VisualMap.Type)baseProperty.FindPropertyRelative("m_Type").enumValueIndex;
+ var type = (VisualMap.Type) baseProperty.FindPropertyRelative("m_Type").enumValueIndex;
var isPiece = type == VisualMap.Type.Piecewise;
PropertyField("m_Type");
PropertyField("m_SerieIndex");
@@ -39,19 +38,19 @@ namespace XCharts.Editor
PropertyField("m_Location");
}
PropertyListField("m_OutOfRange");
- PropertyListField(isPiece ? "m_Pieces" : "m_InRange");
+ PropertyListField("m_InRange");
--EditorGUI.indentLevel;
}
}
- [CustomPropertyDrawer(typeof(VisualMapPieces), true)]
- public class PiecesDrawer : BasePropertyDrawer
+ [CustomPropertyDrawer(typeof(VisualMapRange), true)]
+ public class VisualMapRangeDrawer : BasePropertyDrawer
{
- public override string ClassName { get { return "Pieces"; } }
+ public override string ClassName { get { return "Range"; } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
base.OnGUI(pos, prop, label);
- if (MakeFoldout(prop, ""))
+ if (MakeFoldout(prop, "m_Color"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Min");
diff --git a/Editor/Series/HeatmapEditor.cs b/Editor/Series/HeatmapEditor.cs
index 1d2f98bb..739952ba 100644
--- a/Editor/Series/HeatmapEditor.cs
+++ b/Editor/Series/HeatmapEditor.cs
@@ -1,4 +1,3 @@
-
using XCharts.Runtime;
namespace XCharts.Editor
diff --git a/Editor/Series/RadarEditor.cs b/Editor/Series/RadarEditor.cs
index 7c672ec6..aedf9832 100644
--- a/Editor/Series/RadarEditor.cs
+++ b/Editor/Series/RadarEditor.cs
@@ -9,7 +9,7 @@ namespace XCharts.Editor
{
PropertyField("m_RadarType");
PropertyField("m_RadarIndex");
-
+
PropertyField("m_Symbol");
PropertyField("m_LineStyle");
PropertyField("m_ItemStyle");
diff --git a/Editor/Series/SerieBaseEditor.cs b/Editor/Series/SerieBaseEditor.cs
index c1a2a390..1022c1f0 100644
--- a/Editor/Series/SerieBaseEditor.cs
+++ b/Editor/Series/SerieBaseEditor.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEditor;
@@ -17,6 +16,7 @@ namespace XCharts.Editor
internal SerializedProperty baseProperty;
internal SerializedProperty showProperty;
internal List menus = new List();
+ internal List serieDataMenus = new List();
protected Dictionary m_CoordOptionsDic;
protected List m_CoordOptionsNames;
private string m_DisplayName;
@@ -62,12 +62,10 @@ namespace XCharts.Editor
}
public virtual void OnEnable()
- {
- }
+ { }
public virtual void OnDisable()
- {
- }
+ { }
internal void OnInternalInspectorGUI()
{
@@ -76,12 +74,10 @@ namespace XCharts.Editor
}
public virtual void OnInspectorGUI()
- {
- }
+ { }
protected virtual void DrawExtendeds()
- {
- }
+ { }
public virtual string GetDisplayTitle()
{
@@ -136,11 +132,11 @@ namespace XCharts.Editor
{
case SerializedPropertyType.Float:
if (prop.floatValue < min)
- prop.floatValue = (float)min;
+ prop.floatValue = (float) min;
break;
case SerializedPropertyType.Integer:
if (prop.intValue < min)
- prop.intValue = (int)min;
+ prop.intValue = (int) min;
break;
}
@@ -152,11 +148,11 @@ namespace XCharts.Editor
{
case SerializedPropertyType.Float:
if (prop.floatValue > max)
- prop.floatValue = (float)max;
+ prop.floatValue = (float) max;
break;
case SerializedPropertyType.Integer:
if (prop.intValue > max)
- prop.intValue = (int)max;
+ prop.intValue = (int) max;
break;
}
}
diff --git a/Editor/Series/SerieEditor.cs b/Editor/Series/SerieEditor.cs
index 2d7fbda9..9b410ea8 100644
--- a/Editor/Series/SerieEditor.cs
+++ b/Editor/Series/SerieEditor.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@@ -36,12 +35,11 @@ namespace XCharts.Editor
}
public virtual void OnCustomInspectorGUI()
- {
- }
+ { }
private void OnExtraInspectorGUI()
{
- foreach (var kv in Serie.extraComponentFieldNameDict)
+ foreach (var kv in Serie.extraComponentMap)
{
var prop = FindProperty(kv.Value);
if (prop.arraySize > 0)
@@ -52,11 +50,11 @@ namespace XCharts.Editor
private void PropertyFieldData()
{
m_DataFoldout = ChartEditorHelper.DrawHeader("Data", m_DataFoldout, false, null, null,
- new HeaderMenuInfo("Import ECharts Data", () =>
- {
- PraseExternalDataEditor.UpdateData(chart, serie, null);
- PraseExternalDataEditor.ShowWindow();
- }));
+ new HeaderMenuInfo("Import ECharts Data", () =>
+ {
+ PraseExternalDataEditor.UpdateData(chart, serie, null);
+ PraseExternalDataEditor.ShowWindow();
+ }));
if (!m_DataFoldout) return;
EditorGUI.indentLevel++;
var m_Datas = FindProperty("m_Data");
@@ -75,7 +73,7 @@ namespace XCharts.Editor
while (listSize > m_Datas.arraySize) m_Datas.arraySize++;
while (listSize < m_Datas.arraySize) m_Datas.arraySize--;
}
- if (listSize > 30)// && !XCSettings.editorShowAllListData)
+ if (listSize > 30) // && !XCSettings.editorShowAllListData)
{
int num = listSize > 10 ? 10 : listSize;
for (int i = 0; i < num; i++)
@@ -117,69 +115,69 @@ namespace XCharts.Editor
}
var fieldCount = dimension + (showName ? 1 : 0);
m_DataElementFoldout[index] = ChartEditorHelper.DrawHeader("SerieData " + index, flag, false, null,
- delegate (Rect drawRect)
- {
- //drawRect.width -= 2f;
- var maxX = drawRect.xMax;
- var currentWidth = drawRect.width;
- var lastX = drawRect.x;
- var lastWid = drawRect.width;
- var lastFieldWid = EditorGUIUtility.fieldWidth;
- var lastLabelWid = EditorGUIUtility.labelWidth;
- var serieData = m_Datas.GetArrayElementAtIndex(index);
- var sereName = serieData.FindPropertyRelative("m_Name");
- var data = serieData.FindPropertyRelative("m_Data");
+ delegate(Rect drawRect)
+ {
+ //drawRect.width -= 2f;
+ var maxX = drawRect.xMax;
+ var currentWidth = drawRect.width;
+ var lastX = drawRect.x;
+ var lastWid = drawRect.width;
+ var lastFieldWid = EditorGUIUtility.fieldWidth;
+ var lastLabelWid = EditorGUIUtility.labelWidth;
+ var serieData = m_Datas.GetArrayElementAtIndex(index);
+ var sereName = serieData.FindPropertyRelative("m_Name");
+ var data = serieData.FindPropertyRelative("m_Data");
#if UNITY_2019_3_OR_NEWER
- var gap = 2;
- var namegap = 3;
+ var gap = 2;
+ var namegap = 3;
#else
- var gap = 0;
- var namegap = 0;
+ var gap = 0;
+ var namegap = 0;
#endif
- if (fieldCount <= 1)
- {
- while (2 > data.arraySize)
+ if (fieldCount <= 1)
{
- var value = data.arraySize == 0 ? index : 0;
- data.arraySize++;
- data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
- }
- SerializedProperty element = data.GetArrayElementAtIndex(1);
- var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap;
- drawRect.x = startX;
- drawRect.xMax = maxX;
- EditorGUI.PropertyField(drawRect, element, GUIContent.none);
- }
- else
- {
- var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap;
- var dataWidTotal = (currentWidth - (startX + 20.5f + 1));
- var dataWid = dataWidTotal / fieldCount;
- var xWid = dataWid - 2;
- for (int i = 0; i < dimension; i++)
- {
- var dataCount = i < 1 ? 2 : i + 1;
- while (dataCount > data.arraySize)
+ while (2 > data.arraySize)
{
var value = data.arraySize == 0 ? index : 0;
data.arraySize++;
data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
}
- drawRect.x = startX + i * xWid;
- drawRect.width = dataWid + 25;
- SerializedProperty element = data.GetArrayElementAtIndex(dimension <= 1 ? 1 : i);
+ SerializedProperty element = data.GetArrayElementAtIndex(1);
+ var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap;
+ drawRect.x = startX;
+ drawRect.xMax = maxX;
EditorGUI.PropertyField(drawRect, element, GUIContent.none);
}
- if (showName)
+ else
{
- drawRect.x = startX + (fieldCount - 1) * xWid;
- drawRect.width = dataWid + 40 + dimension * namegap - 2.5f;
- EditorGUI.PropertyField(drawRect, sereName, GUIContent.none);
+ var startX = drawRect.x + EditorGUIUtility.labelWidth - EditorGUI.indentLevel * 15 + gap;
+ var dataWidTotal = (currentWidth - (startX + 20.5f + 1));
+ var dataWid = dataWidTotal / fieldCount;
+ var xWid = dataWid - 2;
+ for (int i = 0; i < dimension; i++)
+ {
+ var dataCount = i < 1 ? 2 : i + 1;
+ while (dataCount > data.arraySize)
+ {
+ var value = data.arraySize == 0 ? index : 0;
+ data.arraySize++;
+ data.GetArrayElementAtIndex(data.arraySize - 1).floatValue = value;
+ }
+ drawRect.x = startX + i * xWid;
+ drawRect.width = dataWid + 25;
+ SerializedProperty element = data.GetArrayElementAtIndex(dimension <= 1 ? 1 : i);
+ EditorGUI.PropertyField(drawRect, element, GUIContent.none);
+ }
+ if (showName)
+ {
+ drawRect.x = startX + (fieldCount - 1) * xWid;
+ drawRect.width = dataWid + 40 + dimension * namegap - 2.5f;
+ EditorGUI.PropertyField(drawRect, sereName, GUIContent.none);
+ }
+ EditorGUIUtility.fieldWidth = lastFieldWid;
+ EditorGUIUtility.labelWidth = lastLabelWid;
}
- EditorGUIUtility.fieldWidth = lastFieldWid;
- EditorGUIUtility.labelWidth = lastLabelWid;
- }
- });
+ });
if (m_DataElementFoldout[index])
{
if (!(serie is ISimplifiedSerie))
@@ -192,113 +190,53 @@ namespace XCharts.Editor
EditorGUI.indentLevel++;
var serieData = m_Datas.GetArrayElementAtIndex(index);
var m_Name = serieData.FindPropertyRelative("m_Name");
- var m_Id = serieData.FindPropertyRelative("m_Id");
- var m_ParentId = serieData.FindPropertyRelative("m_ParentId");
-
- var m_BaseInfo = serieData.FindPropertyRelative("m_BaseInfos");
- var m_Label = serieData.FindPropertyRelative("m_Labels");
- var m_ItemStyle = serieData.FindPropertyRelative("m_ItemStyles");
- var m_Emphasis = serieData.FindPropertyRelative("m_Emphases");
- var m_Symbol = serieData.FindPropertyRelative("m_Symbols");
- var m_LineStyle = serieData.FindPropertyRelative("m_LineStyles");
- var m_AreaStyle = serieData.FindPropertyRelative("m_AreaStyles");
- var m_TitleStyle = serieData.FindPropertyRelative("m_TitleStyles");
PropertyField(m_Name);
- PropertyField(m_Id);
- PropertyField(m_ParentId);
+ if (serie.GetType().IsDefined(typeof(SerieDataExtraFieldAttribute), false))
+ {
+ var attribute = serie.GetType().GetAttribute();
+ foreach (var field in attribute.fields)
+ {
+ PropertyField(serieData.FindPropertyRelative(field));
+ }
+ }
- var componentNum = m_BaseInfo.arraySize + m_Label.arraySize + m_ItemStyle.arraySize + m_Emphasis.arraySize
- + m_Symbol.arraySize + m_LineStyle.arraySize + m_AreaStyle.arraySize;
- var title = "Component";
- if (componentNum == 0) title += " (None)";
- m_DataComponentFoldout = ChartEditorHelper.DrawHeader(title, m_DataComponentFoldout, false, null, null,
- new HeaderMenuInfo("Add BaseInfo", () =>
+ serieDataMenus.Clear();
+ if (serie.GetType().IsDefined(typeof(SerieDataExtraComponentAttribute), false))
{
- serie.GetSerieData(index).GetOrAddComponent();
- }, m_BaseInfo.arraySize == 0),
- new HeaderMenuInfo("Add ItemStyle", () =>
- {
- serie.GetSerieData(index).GetOrAddComponent();
- }, m_ItemStyle.arraySize == 0),
- new HeaderMenuInfo("Add Label", () =>
- {
- serie.GetSerieData(index).GetOrAddComponent();
- }, m_Label.arraySize == 0),
- new HeaderMenuInfo("Add Emphasis", () =>
- {
- serie.GetSerieData(index).GetOrAddComponent();
- }, m_Emphasis.arraySize == 0),
- new HeaderMenuInfo("Add Symbol", () =>
- {
- serie.GetSerieData(index).GetOrAddComponent();
- }, m_Symbol.arraySize == 0),
- new HeaderMenuInfo("Add LineStyle", () =>
- {
- serie.GetSerieData(index).GetOrAddComponent();
- }, m_LineStyle.arraySize == 0),
- new HeaderMenuInfo("Add AreaStyle", () =>
- {
- serie.GetSerieData(index).GetOrAddComponent();
- }, m_AreaStyle.arraySize == 0),
- new HeaderMenuInfo("Add TitleStyle", () =>
- {
- serie.GetSerieData(index).GetOrAddComponent();
- }, m_TitleStyle.arraySize == 0),
- new HeaderMenuInfo("Remove BaseInfo", () =>
- {
- serie.GetSerieData(index).RemoveComponent();
- }, m_BaseInfo.arraySize > 0),
- new HeaderMenuInfo("Remove ItemStyle", () =>
- {
- serie.GetSerieData(index).RemoveComponent();
- }, m_ItemStyle.arraySize > 0),
- new HeaderMenuInfo("Remove Label", () =>
- {
- serie.GetSerieData(index).RemoveComponent();
- }, m_Label.arraySize > 0),
- new HeaderMenuInfo("Remove Emphasis", () =>
- {
- serie.GetSerieData(index).RemoveComponent();
- }, m_Emphasis.arraySize > 0),
- new HeaderMenuInfo("Remove Symbol", () =>
- {
- serie.GetSerieData(index).RemoveComponent();
- }, m_Symbol.arraySize > 0),
- new HeaderMenuInfo("Remove LineStyle", () =>
- {
- serie.GetSerieData(index).RemoveComponent();
- }, m_LineStyle.arraySize > 0),
- new HeaderMenuInfo("Remove AreaStyle", () =>
- {
- serie.GetSerieData(index).RemoveComponent();
- }, m_AreaStyle.arraySize > 0),
- new HeaderMenuInfo("Remove TitleStyle", () =>
- {
- serie.GetSerieData(index).RemoveComponent();
- }, m_TitleStyle.arraySize > 0),
- new HeaderMenuInfo("Remove All", () =>
+ var attribute = serie.GetType().GetAttribute();
+ foreach (var type in attribute.types)
+ {
+ var size = serieData.FindPropertyRelative(SerieData.extraComponentMap[type]).arraySize;
+ serieDataMenus.Add(new HeaderMenuInfo("Add " + type.Name, () =>
+ {
+ serie.GetSerieData(index).GetOrAddComponent(type);
+ EditorUtility.SetDirty(chart);
+ }, size == 0));
+ }
+ foreach (var type in attribute.types)
+ {
+ var size = serieData.FindPropertyRelative(SerieData.extraComponentMap[type]).arraySize;
+ serieDataMenus.Add(new HeaderMenuInfo("Remove " + type.Name, () =>
+ {
+ serie.GetSerieData(index).RemoveComponent(type);
+ EditorUtility.SetDirty(chart);
+ }, size > 0));
+ }
+ }
+ serieDataMenus.Add(new HeaderMenuInfo("Remove All", () =>
{
serie.GetSerieData(index).RemoveAllComponent();
- }, componentNum > 0));
+ }, true));
+ m_DataComponentFoldout = ChartEditorHelper.DrawHeader("Component", m_DataComponentFoldout, false, null, null, serieDataMenus);
if (m_DataComponentFoldout)
{
- if (m_BaseInfo.arraySize > 0)
- PropertyField(m_BaseInfo.GetArrayElementAtIndex(0));
- if (m_Label.arraySize > 0)
- PropertyField(m_Label.GetArrayElementAtIndex(0));
- if (m_ItemStyle.arraySize > 0)
- PropertyField(m_ItemStyle.GetArrayElementAtIndex(0));
- if (m_Emphasis.arraySize > 0)
- PropertyField(m_Emphasis.GetArrayElementAtIndex(0));
- if (m_Symbol.arraySize > 0)
- PropertyField(m_Symbol.GetArrayElementAtIndex(0));
- if (m_LineStyle.arraySize > 0)
- PropertyField(m_LineStyle.GetArrayElementAtIndex(0));
- if (m_AreaStyle.arraySize > 0)
- PropertyField(m_AreaStyle.GetArrayElementAtIndex(0));
- if (m_TitleStyle.arraySize > 0)
- PropertyField(m_TitleStyle.GetArrayElementAtIndex(0));
+ foreach (var kv in SerieData.extraComponentMap)
+ {
+ var prop = serieData.FindPropertyRelative(kv.Value);
+ if (prop.arraySize > 0)
+ PropertyField(prop.GetArrayElementAtIndex(0));
+ }
}
EditorGUI.indentLevel--;
}
diff --git a/Editor/Series/SerieListEditor.cs b/Editor/Series/SerieListEditor.cs
index a8b67ada..280ee259 100644
--- a/Editor/Series/SerieListEditor.cs
+++ b/Editor/Series/SerieListEditor.cs
@@ -1,10 +1,9 @@
-
using System;
using System.Collections.Generic;
-using UnityEngine.Assertions;
-using UnityEditor;
using System.Linq;
using System.Reflection;
+using UnityEditor;
+using UnityEngine.Assertions;
using XCharts.Runtime;
namespace XCharts.Editor
@@ -22,7 +21,6 @@ namespace XCharts.Editor
List m_Editors;
private bool m_SerieFoldout;
-
public SerieListEditor(BaseChartEditor editor)
{
Assert.IsNotNull(editor);
@@ -136,7 +134,7 @@ namespace XCharts.Editor
if (!m_EditorTypes.TryGetValue(settingsType, out editorType))
editorType = typeof(SerieBaseEditor);
- var editor = (SerieBaseEditor)Activator.CreateInstance(editorType);
+ var editor = (SerieBaseEditor) Activator.CreateInstance(editorType);
editor.Init(chart, serie, property, m_BaseEditor);
editor.menus.Clear();
editor.menus.Add(new HeaderMenuInfo("Clone", () =>
@@ -176,7 +174,7 @@ namespace XCharts.Editor
var attribute = editor.serie.GetType().GetAttribute();
foreach (var type in attribute.types)
{
- var size = editor.FindProperty(Serie.extraComponentFieldNameDict[type]).arraySize;
+ var size = editor.FindProperty(Serie.extraComponentMap[type]).arraySize;
editor.menus.Add(new HeaderMenuInfo("Add " + type.Name, () =>
{
editor.serie.AddExtraComponent(type);
@@ -187,7 +185,7 @@ namespace XCharts.Editor
}
foreach (var type in attribute.types)
{
- var size = editor.FindProperty(Serie.extraComponentFieldNameDict[type]).arraySize;
+ var size = editor.FindProperty(Serie.extraComponentMap[type]).arraySize;
editor.menus.Add(new HeaderMenuInfo("Remove " + type.Name, () =>
{
editor.serie.RemoveExtraComponent(type);
diff --git a/Editor/Series/SimplifiedBarEditor.cs b/Editor/Series/SimplifiedBarEditor.cs
index fdd9133a..c09d3ee6 100644
--- a/Editor/Series/SimplifiedBarEditor.cs
+++ b/Editor/Series/SimplifiedBarEditor.cs
@@ -1,4 +1,3 @@
-
using XCharts.Runtime;
namespace XCharts.Editor
diff --git a/Editor/Utilities/ChartEditorHelper.cs b/Editor/Utilities/ChartEditorHelper.cs
index a33e9e6e..de606eef 100644
--- a/Editor/Utilities/ChartEditorHelper.cs
+++ b/Editor/Utilities/ChartEditorHelper.cs
@@ -1,8 +1,7 @@
-
-using UnityEngine;
-using UnityEditor;
-using System.Collections.Generic;
using System;
+using System.Collections.Generic;
+using UnityEditor;
+using UnityEngine;
using XCharts.Runtime;
namespace XCharts.Editor
@@ -53,7 +52,7 @@ namespace XCharts.Editor
public static void SecondField(Rect drawRect, SerializedProperty prop)
{
- RectOffset offset = new RectOffset(-(int)EditorGUIUtility.labelWidth, 0, 0, 0);
+ RectOffset offset = new RectOffset(-(int) EditorGUIUtility.labelWidth, 0, 0, 0);
drawRect = offset.Add(drawRect);
EditorGUI.PropertyField(drawRect, prop, GUIContent.none);
drawRect = offset.Remove(drawRect);
@@ -166,7 +165,7 @@ namespace XCharts.Editor
}
public static bool MakeComponentFoldout(ref Rect drawRect, Dictionary heights,
Dictionary moduleToggle, string key, string content, SerializedProperty prop,
- bool propEnable, params HeaderMenuInfo[] menus)
+ SerializedProperty prop2, bool propEnable, params HeaderMenuInfo[] menus)
{
var sourRect = drawRect;
float defaultWidth = drawRect.width;
@@ -181,10 +180,16 @@ namespace XCharts.Editor
if (prop.propertyType == SerializedPropertyType.Boolean)
{
if (!propEnable)
- using (new EditorGUI.DisabledScope(true))
- MakeBool(drawRect, prop);
+ using(new EditorGUI.DisabledScope(true))
+ MakeBool(drawRect, prop);
else
MakeBool(drawRect, prop);
+ if (prop2 != null && !moduleToggle[key])
+ {
+ drawRect.x = EditorGUIUtility.labelWidth - EditorGUI.indentLevel * INDENT_WIDTH + ARROW_WIDTH + BOOL_WIDTH;
+ drawRect.width = defaultWidth - drawRect.x + ARROW_WIDTH;
+ EditorGUI.PropertyField(drawRect, prop2, GUIContent.none);
+ }
}
else
{
@@ -201,8 +206,6 @@ namespace XCharts.Editor
return moduleToggle[key];
}
-
-
public static void MakeBool(Rect drawRect, SerializedProperty boolProp, int index = 0, string name = null)
{
float defaultWidth = drawRect.width;
@@ -378,9 +381,9 @@ namespace XCharts.Editor
{
var temp = INDENT_WIDTH + GAP_WIDTH + iconGap;
var isSerie = "Serie".Equals(element.type);
- var elementRect = isSerie
- ? new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH - 2 * iconGap, drawRect.height)
- : new Rect(drawRect.x, drawRect.y, drawRect.width - 3 * iconWidth, drawRect.height);
+ var elementRect = isSerie ?
+ new Rect(drawRect.x, drawRect.y, drawRect.width + INDENT_WIDTH - 2 * iconGap, drawRect.height) :
+ new Rect(drawRect.x, drawRect.y, drawRect.width - 3 * iconWidth, drawRect.height);
EditorGUI.PropertyField(elementRect, element, new GUIContent("Element " + i));
var iconRect = new Rect(drawRect.width - 3 * iconWidth + temp, drawRect.y, iconWidth, drawRect.height);
var oldColor = GUI.contentColor;
@@ -436,7 +439,7 @@ namespace XCharts.Editor
if (prop.propertyType == SerializedPropertyType.Float && prop.floatValue < minValue)
prop.floatValue = minValue;
if (prop.propertyType == SerializedPropertyType.Integer && prop.intValue < minValue)
- prop.intValue = (int)minValue;
+ prop.intValue = (int) minValue;
var hig = EditorGUI.GetPropertyHeight(prop);
drawRect.y += hig;
heights[key] += hig;
@@ -451,7 +454,7 @@ namespace XCharts.Editor
if (prop.propertyType == SerializedPropertyType.Float && prop.floatValue > maxValue)
prop.floatValue = maxValue;
if (prop.propertyType == SerializedPropertyType.Integer && prop.intValue > maxValue)
- prop.intValue = (int)maxValue;
+ prop.intValue = (int) maxValue;
var hig = EditorGUI.GetPropertyHeight(prop);
drawRect.y += hig;
heights[key] += hig;
diff --git a/Editor/Utilities/EditorStyles.cs b/Editor/Utilities/EditorStyles.cs
index 08177b78..602a2693 100644
--- a/Editor/Utilities/EditorStyles.cs
+++ b/Editor/Utilities/EditorStyles.cs
@@ -1,5 +1,3 @@
-
-
using UnityEditor;
using UnityEngine;
@@ -9,12 +7,11 @@ namespace XCharts.Editor
{
static readonly Color splitterDark = new Color(0.12f, 0.12f, 0.12f, 0.5f);
static readonly Color splitterLight = new Color(0.6f, 0.6f, 0.6f, 0.5f);
- static readonly Texture2D paneOptionsIconDark = (Texture2D)EditorGUIUtility.Load("Builtin Skins/DarkSkin/Images/pane options.png");
- static readonly Texture2D paneOptionsIconLight = (Texture2D)EditorGUIUtility.Load("Builtin Skins/LightSkin/Images/pane options.png");
+ static readonly Texture2D paneOptionsIconDark = (Texture2D) EditorGUIUtility.Load("Builtin Skins/DarkSkin/Images/pane options.png");
+ static readonly Texture2D paneOptionsIconLight = (Texture2D) EditorGUIUtility.Load("Builtin Skins/LightSkin/Images/pane options.png");
static readonly Color headerBackgroundDark = new Color(0.1f, 0.1f, 0.1f, 0.2f);
static readonly Color headerBackgroundLight = new Color(1f, 1f, 1f, 0.2f);
-
public static readonly GUIStyle headerStyle = UnityEditor.EditorStyles.boldLabel;
public static readonly GUIStyle foldoutStyle = new GUIStyle(UnityEditor.EditorStyles.foldout)
{
@@ -28,7 +25,6 @@ namespace XCharts.Editor
public static readonly GUIStyle invisibleButton = "InvisibleButton";
public static readonly GUIStyle smallTickbox = new GUIStyle("ShurikenToggle");
-
public static Color splitter { get { return EditorGUIUtility.isProSkin ? splitterDark : splitterLight; } }
public static Texture2D paneOptionsIcon { get { return EditorGUIUtility.isProSkin ? paneOptionsIconDark : paneOptionsIconLight; } }
public static Color headerBackground { get { return EditorGUIUtility.isProSkin ? headerBackgroundDark : headerBackgroundLight; } }
diff --git a/Editor/Utilities/ThemeCheck.cs b/Editor/Utilities/ThemeCheck.cs
index d9c33055..bb31b353 100644
--- a/Editor/Utilities/ThemeCheck.cs
+++ b/Editor/Utilities/ThemeCheck.cs
@@ -1,4 +1,3 @@
-
using System.IO;
using UnityEditor;
using UnityEngine;
diff --git a/Editor/Widgets/ProgressBarEditor.cs b/Editor/Widgets/ProgressBarEditor.cs
index 8d57260a..112269b4 100644
--- a/Editor/Widgets/ProgressBarEditor.cs
+++ b/Editor/Widgets/ProgressBarEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using XCharts.Runtime;
diff --git a/Editor/Windows/PraseExternalDataEditor.cs b/Editor/Windows/PraseExternalDataEditor.cs
index f2d861cb..2e7667a8 100644
--- a/Editor/Windows/PraseExternalDataEditor.cs
+++ b/Editor/Windows/PraseExternalDataEditor.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEditor;
@@ -194,8 +193,7 @@ namespace XCharts.Editor
else if (a.StartsWith("selected:"))
{
string selected = a.Substring(9, a.Length - 9);
- var baseInfo = serieData.GetOrAddComponent();
- baseInfo.selected = bool.Parse(selected);
+ serieData.selected = bool.Parse(selected);
}
}
serie.AddSerieData(serieData);
diff --git a/Editor/Windows/XCSettingsEditor.cs b/Editor/Windows/XCSettingsEditor.cs
index 0908998e..c03ef5b0 100644
--- a/Editor/Windows/XCSettingsEditor.cs
+++ b/Editor/Windows/XCSettingsEditor.cs
@@ -1,4 +1,3 @@
-
using UnityEditor;
using UnityEngine;
using XCharts.Runtime;
@@ -20,10 +19,8 @@ namespace XCharts.Editor
{
XCResourcesImporter m_ResourceImporter;
- public XCResourceImporterProvider()
- : base("Project/XCharts", SettingsScope.Project)
- {
- }
+ public XCResourceImporterProvider() : base("Project/XCharts", SettingsScope.Project)
+ { }
public override void OnGUI(string searchContext)
{
diff --git a/Editor/Windows/XChartsEditor.cs b/Editor/Windows/XChartsEditor.cs
index 01b638bf..47042a75 100644
--- a/Editor/Windows/XChartsEditor.cs
+++ b/Editor/Windows/XChartsEditor.cs
@@ -1,8 +1,7 @@
-
using UnityEditor;
using UnityEngine;
-using UnityEngine.UI;
using UnityEngine.EventSystems;
+using UnityEngine.UI;
using XCharts.Runtime;
namespace XCharts.Editor
@@ -134,6 +133,7 @@ namespace XCharts.Editor
{
AddChart("CandlestickChart");
}
+
[MenuItem("XCharts/PolarChart", priority = 54)]
[MenuItem("GameObject/XCharts/PolarChart", priority = 54)]
public static void PolarChart()
diff --git a/Examples/Runtime/Example00_CheatSheet.cs b/Examples/Example00_CheatSheet.cs
similarity index 96%
rename from Examples/Runtime/Example00_CheatSheet.cs
rename to Examples/Example00_CheatSheet.cs
index 6429e3da..99bce3df 100644
--- a/Examples/Runtime/Example00_CheatSheet.cs
+++ b/Examples/Example00_CheatSheet.cs
@@ -1,4 +1,3 @@
-
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -278,13 +277,21 @@ namespace XCharts.Example
visualMap.range[0] = 0;
visualMap.range[1] = 100;
- var colors = new List{"#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf",
- "#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"};
- visualMap.inRange.Clear();
- foreach (var str in colors)
+ var colors = new List
{
- visualMap.inRange.Add(ThemeStyle.GetColor(str));
- }
+ "#313695",
+ "#4575b4",
+ "#74add1",
+ "#abd9e9",
+ "#e0f3f8",
+ "#ffffbf",
+ "#fee090",
+ "#fdae61",
+ "#f46d43",
+ "#d73027",
+ "#a50026"
+ };
+ visualMap.AddColors(colors);
var grid = chart.GetChartComponent();
grid.left = 80;
grid.bottom = 100;
diff --git a/Examples/Runtime/Example00_CheatSheet.cs.meta b/Examples/Example00_CheatSheet.cs.meta
similarity index 100%
rename from Examples/Runtime/Example00_CheatSheet.cs.meta
rename to Examples/Example00_CheatSheet.cs.meta
diff --git a/Examples/Runtime/Example01_UpdateData.cs b/Examples/Example01_UpdateData.cs
similarity index 99%
rename from Examples/Runtime/Example01_UpdateData.cs
rename to Examples/Example01_UpdateData.cs
index 76abf067..171de5d9 100644
--- a/Examples/Runtime/Example01_UpdateData.cs
+++ b/Examples/Example01_UpdateData.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example01_UpdateData.cs.meta b/Examples/Example01_UpdateData.cs.meta
similarity index 100%
rename from Examples/Runtime/Example01_UpdateData.cs.meta
rename to Examples/Example01_UpdateData.cs.meta
diff --git a/Examples/Runtime/Example02_ChartEvent.cs b/Examples/Example02_ChartEvent.cs
similarity index 99%
rename from Examples/Runtime/Example02_ChartEvent.cs
rename to Examples/Example02_ChartEvent.cs
index 599db9d1..59066a4a 100644
--- a/Examples/Runtime/Example02_ChartEvent.cs
+++ b/Examples/Example02_ChartEvent.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.EventSystems;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example02_ChartEvent.cs.meta b/Examples/Example02_ChartEvent.cs.meta
similarity index 100%
rename from Examples/Runtime/Example02_ChartEvent.cs.meta
rename to Examples/Example02_ChartEvent.cs.meta
diff --git a/Examples/Runtime/Example03_ChartAnimation.cs b/Examples/Example03_ChartAnimation.cs
similarity index 99%
rename from Examples/Runtime/Example03_ChartAnimation.cs
rename to Examples/Example03_ChartAnimation.cs
index 2ba253ee..736ff80e 100644
--- a/Examples/Runtime/Example03_ChartAnimation.cs
+++ b/Examples/Example03_ChartAnimation.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example03_ChartAnimation.cs.meta b/Examples/Example03_ChartAnimation.cs.meta
similarity index 100%
rename from Examples/Runtime/Example03_ChartAnimation.cs.meta
rename to Examples/Example03_ChartAnimation.cs.meta
diff --git a/Examples/Runtime/Example10_LineChart.cs b/Examples/Example10_LineChart.cs
similarity index 99%
rename from Examples/Runtime/Example10_LineChart.cs
rename to Examples/Example10_LineChart.cs
index ed566ad3..1067b991 100644
--- a/Examples/Runtime/Example10_LineChart.cs
+++ b/Examples/Example10_LineChart.cs
@@ -1,4 +1,3 @@
-
using System.Collections;
using UnityEngine;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example10_LineChart.cs.meta b/Examples/Example10_LineChart.cs.meta
similarity index 100%
rename from Examples/Runtime/Example10_LineChart.cs.meta
rename to Examples/Example10_LineChart.cs.meta
diff --git a/Examples/Runtime/Example11_AddSinCurve.cs b/Examples/Example11_AddSinCurve.cs
similarity index 99%
rename from Examples/Runtime/Example11_AddSinCurve.cs
rename to Examples/Example11_AddSinCurve.cs
index dd22ca3c..31491178 100644
--- a/Examples/Runtime/Example11_AddSinCurve.cs
+++ b/Examples/Example11_AddSinCurve.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example11_AddSinCurve.cs.meta b/Examples/Example11_AddSinCurve.cs.meta
similarity index 100%
rename from Examples/Runtime/Example11_AddSinCurve.cs.meta
rename to Examples/Example11_AddSinCurve.cs.meta
diff --git a/Examples/Runtime/Example12_CustomDrawing.cs b/Examples/Example12_CustomDrawing.cs
similarity index 76%
rename from Examples/Runtime/Example12_CustomDrawing.cs
rename to Examples/Example12_CustomDrawing.cs
index 3f19c62a..ace1318a 100644
--- a/Examples/Runtime/Example12_CustomDrawing.cs
+++ b/Examples/Example12_CustomDrawing.cs
@@ -1,9 +1,7 @@
-
using UnityEngine;
using UnityEngine.UI;
-using XUGL;
using XCharts.Runtime;
-
+using XUGL;
namespace XCharts.Example
{
@@ -17,15 +15,11 @@ namespace XCharts.Example
chart = gameObject.GetComponent();
if (chart == null) return;
- chart.onDraw = delegate (VertexHelper vh)
- {
- };
+ chart.onDraw = delegate(VertexHelper vh) { };
// or
- chart.onDrawBeforeSerie = delegate (VertexHelper vh, Serie serie)
- {
- };
+ chart.onDrawBeforeSerie = delegate(VertexHelper vh, Serie serie) { };
// or
- chart.onDrawAfterSerie = delegate (VertexHelper vh, Serie serie)
+ chart.onDrawAfterSerie = delegate(VertexHelper vh, Serie serie)
{
if (serie.index != 0) return;
var dataPoints = serie.context.dataPoints;
@@ -41,9 +35,7 @@ namespace XCharts.Example
}
};
// or
- chart.onDrawTop = delegate (VertexHelper vh)
- {
- };
+ chart.onDrawTop = delegate(VertexHelper vh) { };
}
}
}
\ No newline at end of file
diff --git a/Examples/Runtime/Example12_CustomDrawing.cs.meta b/Examples/Example12_CustomDrawing.cs.meta
similarity index 100%
rename from Examples/Runtime/Example12_CustomDrawing.cs.meta
rename to Examples/Example12_CustomDrawing.cs.meta
diff --git a/Examples/Runtime/Example13_LineSimple.cs b/Examples/Example13_LineSimple.cs
similarity index 82%
rename from Examples/Runtime/Example13_LineSimple.cs
rename to Examples/Example13_LineSimple.cs
index ed5b94ca..153ef575 100644
--- a/Examples/Runtime/Example13_LineSimple.cs
+++ b/Examples/Example13_LineSimple.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using XCharts.Runtime;
@@ -8,21 +7,25 @@ namespace XCharts.Example
[ExecuteInEditMode]
public class Example13_LineSimple : MonoBehaviour
{
+ void Awake()
+ {
+ AddData();
+ }
+
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
AddData();
- //OnTestBtn();
}
}
void AddData()
{
- var chart = gameObject.GetComponent();
+ var chart = gameObject.GetComponent();
if (chart == null)
{
- chart = gameObject.AddComponent();
+ chart = gameObject.AddComponent();
chart.Init();
chart.SetSize(580, 300);
}
@@ -43,8 +46,8 @@ namespace XCharts.Example
xAxis.boundaryGap = true;
chart.RemoveData();
- chart.AddSerie();
- chart.AddSerie();
+ chart.AddSerie();
+ chart.AddSerie();
for (int i = 0; i < 200; i++)
{
chart.AddXAxisData("x" + i);
diff --git a/Examples/Runtime/Example13_LineSimple.cs.meta b/Examples/Example13_LineSimple.cs.meta
similarity index 100%
rename from Examples/Runtime/Example13_LineSimple.cs.meta
rename to Examples/Example13_LineSimple.cs.meta
diff --git a/Examples/Runtime/Example20_BarChart.cs b/Examples/Example20_BarChart.cs
similarity index 97%
rename from Examples/Runtime/Example20_BarChart.cs
rename to Examples/Example20_BarChart.cs
index 594d665e..270321ac 100644
--- a/Examples/Runtime/Example20_BarChart.cs
+++ b/Examples/Example20_BarChart.cs
@@ -1,4 +1,3 @@
-
using System.Collections;
using UnityEngine;
using XCharts.Runtime;
@@ -57,7 +56,7 @@ namespace XCharts.Example
yAxis.minMaxType = Axis.AxisMinMaxType.Default;
chart.RemoveData();
- serie = chart.AddSerie( "Bar1");
+ serie = chart.AddSerie("Bar1");
for (int i = 0; i < m_DataNum; i++)
{
@@ -67,7 +66,6 @@ namespace XCharts.Example
yield return new WaitForSeconds(1);
}
-
IEnumerator BarMutilSerie()
{
chart.GetChartComponent().subText = "多条柱状图";
@@ -80,7 +78,7 @@ namespace XCharts.Example
yield return null;
}
- serie2 = chart.AddSerie( "Bar2");
+ serie2 = chart.AddSerie("Bar2");
serie2.lineType = LineType.Normal;
serie2.barWidth = 0.35f;
for (int i = 0; i < m_DataNum; i++)
@@ -152,7 +150,7 @@ namespace XCharts.Example
serie2.label.textStyle.color = Color.white;
serie2.label.formatter = "{d:f0}%";
serie2.labelDirty = true;
-
+
chart.RefreshChart();
yield return new WaitForSeconds(1);
}
diff --git a/Examples/Runtime/Example20_BarChart.cs.meta b/Examples/Example20_BarChart.cs.meta
similarity index 100%
rename from Examples/Runtime/Example20_BarChart.cs.meta
rename to Examples/Example20_BarChart.cs.meta
diff --git a/Examples/Example21_BarRace.cs b/Examples/Example21_BarRace.cs
new file mode 100644
index 00000000..c14e3ffc
--- /dev/null
+++ b/Examples/Example21_BarRace.cs
@@ -0,0 +1,46 @@
+using System.Collections;
+using UnityEngine;
+using XCharts.Runtime;
+
+namespace XCharts.Example
+{
+ [DisallowMultipleComponent]
+ public class Example21_BarRace : MonoBehaviour
+ {
+ private BarChart chart;
+ private float lastTime;
+
+ void Awake()
+ {
+ chart = gameObject.GetComponent();
+ chart.ClearData();
+ for (int i = 0; i < 5; i++)
+ {
+ chart.AddYAxisData("y" + i);
+ chart.AddData(0, Random.Range(0, 200));
+ }
+ }
+
+ void Update()
+ {
+ if (Time.time - lastTime >= 3f)
+ {
+ lastTime = Time.time;
+ UpdateData();
+ }
+ }
+
+ void UpdateData()
+ {
+ var serie = chart.GetSerie(0);
+
+ for (int i = 0; i < serie.dataCount; i++)
+ {
+ if (Random.Range(0, 1f) > 0.9f)
+ chart.UpdateData(0, i, chart.GetData(0, i) + Mathf.Round(Random.Range(0, 2000)));
+ else
+ chart.UpdateData(0, i, chart.GetData(0, i) + Mathf.Round(Random.Range(0, 200)));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Examples/Example21_BarRace.cs.meta b/Examples/Example21_BarRace.cs.meta
new file mode 100644
index 00000000..70e9a193
--- /dev/null
+++ b/Examples/Example21_BarRace.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 9842ca7fe07044666950b6f53ef65fdb
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Examples/Runtime/Example30_PieChart.cs b/Examples/Example30_PieChart.cs
similarity index 96%
rename from Examples/Runtime/Example30_PieChart.cs
rename to Examples/Example30_PieChart.cs
index 216a7ac8..e40f063c 100644
--- a/Examples/Runtime/Example30_PieChart.cs
+++ b/Examples/Example30_PieChart.cs
@@ -1,4 +1,3 @@
-
using System.Collections;
using UnityEngine;
using UnityEngine.EventSystems;
@@ -73,7 +72,7 @@ namespace XCharts.Example
chart.AddData(0, 135, "视频广告");
chart.AddData(0, 1548, "搜索引擎");
- chart.onPointerClickPie = delegate (PointerEventData e, int serieIndex, int dataIndex)
+ chart.onPointerClickPie = delegate(PointerEventData e, int serieIndex, int dataIndex)
{
};
@@ -118,12 +117,12 @@ namespace XCharts.Example
chart.RefreshChart();
yield return new WaitForSeconds(1);
- serie.data[0].GetOrAddComponent().selected = true;
+ serie.data[0].selected = true;
chart.RefreshChart();
yield return new WaitForSeconds(1);
serie.gap = 0f;
- serie.data[0].GetOrAddComponent().selected = false;
+ serie.data[0].selected = false;
chart.RefreshChart();
yield return new WaitForSeconds(1);
}
diff --git a/Examples/Runtime/Example30_PieChart.cs.meta b/Examples/Example30_PieChart.cs.meta
similarity index 100%
rename from Examples/Runtime/Example30_PieChart.cs.meta
rename to Examples/Example30_PieChart.cs.meta
diff --git a/Examples/Runtime/Example31_PieUpdateName.cs b/Examples/Example31_PieUpdateName.cs
similarity index 99%
rename from Examples/Runtime/Example31_PieUpdateName.cs
rename to Examples/Example31_PieUpdateName.cs
index b39f8a95..85091050 100644
--- a/Examples/Runtime/Example31_PieUpdateName.cs
+++ b/Examples/Example31_PieUpdateName.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example31_PieUpdateName.cs.meta b/Examples/Example31_PieUpdateName.cs.meta
similarity index 100%
rename from Examples/Runtime/Example31_PieUpdateName.cs.meta
rename to Examples/Example31_PieUpdateName.cs.meta
diff --git a/Examples/Runtime/Example40_Radar.cs b/Examples/Example40_Radar.cs
similarity index 99%
rename from Examples/Runtime/Example40_Radar.cs
rename to Examples/Example40_Radar.cs
index b56e771a..f33dc258 100644
--- a/Examples/Runtime/Example40_Radar.cs
+++ b/Examples/Example40_Radar.cs
@@ -1,4 +1,3 @@
-
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Examples/Runtime/Example40_Radar.cs.meta b/Examples/Example40_Radar.cs.meta
similarity index 100%
rename from Examples/Runtime/Example40_Radar.cs.meta
rename to Examples/Example40_Radar.cs.meta
diff --git a/Examples/Runtime/Example41_RadarUpdate.cs b/Examples/Example41_RadarUpdate.cs
similarity index 99%
rename from Examples/Runtime/Example41_RadarUpdate.cs
rename to Examples/Example41_RadarUpdate.cs
index 5effeb66..baaa46be 100644
--- a/Examples/Runtime/Example41_RadarUpdate.cs
+++ b/Examples/Example41_RadarUpdate.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example41_RadarUpdate.cs.meta b/Examples/Example41_RadarUpdate.cs.meta
similarity index 100%
rename from Examples/Runtime/Example41_RadarUpdate.cs.meta
rename to Examples/Example41_RadarUpdate.cs.meta
diff --git a/Examples/Runtime/Example50_Scatter.cs b/Examples/Example50_Scatter.cs
similarity index 87%
rename from Examples/Runtime/Example50_Scatter.cs
rename to Examples/Example50_Scatter.cs
index f2ddb276..74b8d6c3 100644
--- a/Examples/Runtime/Example50_Scatter.cs
+++ b/Examples/Example50_Scatter.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -25,12 +24,12 @@ namespace XCharts.Example
float SymbolSize(List data)
{
- return (float)(Math.Sqrt(data[2]) / 6e2);
+ return (float) (Math.Sqrt(data[2]) / 6e2);
}
float SymbolSelectedSize(List data)
{
- return (float)(Math.Sqrt(data[2]) / 5e2);
+ return (float) (Math.Sqrt(data[2]) / 5e2);
}
}
}
\ No newline at end of file
diff --git a/Examples/Runtime/Example50_Scatter.cs.meta b/Examples/Example50_Scatter.cs.meta
similarity index 100%
rename from Examples/Runtime/Example50_Scatter.cs.meta
rename to Examples/Example50_Scatter.cs.meta
diff --git a/Examples/Runtime/Example60_Heatmap.cs b/Examples/Example60_Heatmap.cs
similarity index 79%
rename from Examples/Runtime/Example60_Heatmap.cs
rename to Examples/Example60_Heatmap.cs
index fe000dff..96273243 100644
--- a/Examples/Runtime/Example60_Heatmap.cs
+++ b/Examples/Example60_Heatmap.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using XCharts.Runtime;
@@ -48,11 +47,10 @@ namespace XCharts.Example
serie.itemStyle.borderColor = Color.clear;
//设置高亮样式
- serie.AddExtraComponent();
- serie.emphasis.show = true;
- serie.emphasis.itemStyle.show = true;
- serie.emphasis.itemStyle.borderWidth = 1;
- serie.emphasis.itemStyle.borderColor = Color.black;
+ serie.AddExtraComponent();
+ serie.emphasisItemStyle.show = true;
+ serie.emphasisItemStyle.borderWidth = 1;
+ serie.emphasisItemStyle.borderColor = Color.black;
//设置视觉映射组件
var visualMap = chart.GetChartComponent();
@@ -66,17 +64,25 @@ namespace XCharts.Example
visualMap.location.left = 30;
//清空颜色重新添加
- visualMap.inRange.Clear();
var heatmapGridWid = 10f;
- int xSplitNumber = (int)(grid.context.width / heatmapGridWid);
- int ySplitNumber = (int)(grid.context.height / heatmapGridWid);
- var colors = new List{"#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf",
- "#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"};
- foreach (var str in colors)
+ int xSplitNumber = (int) (grid.context.width / heatmapGridWid);
+ int ySplitNumber = (int) (grid.context.height / heatmapGridWid);
+ var colors = new List
{
- visualMap.inRange.Add(ThemeStyle.GetColor(str));
- }
+ "#313695",
+ "#4575b4",
+ "#74add1",
+ "#abd9e9",
+ "#e0f3f8",
+ "#ffffbf",
+ "#fee090",
+ "#fdae61",
+ "#f46d43",
+ "#d73027",
+ "#a50026"
+ };
+ visualMap.AddColors(colors);
//添加xAxis的数据
for (int i = 0; i < xSplitNumber; i++)
{
diff --git a/Examples/Runtime/Example60_Heatmap.cs.meta b/Examples/Example60_Heatmap.cs.meta
similarity index 100%
rename from Examples/Runtime/Example60_Heatmap.cs.meta
rename to Examples/Example60_Heatmap.cs.meta
diff --git a/Examples/Runtime/Example80_Polar.cs b/Examples/Example80_Polar.cs
similarity index 99%
rename from Examples/Runtime/Example80_Polar.cs
rename to Examples/Example80_Polar.cs
index cb76cfb8..fdfb0b04 100644
--- a/Examples/Runtime/Example80_Polar.cs
+++ b/Examples/Example80_Polar.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example80_Polar.cs.meta b/Examples/Example80_Polar.cs.meta
similarity index 100%
rename from Examples/Runtime/Example80_Polar.cs.meta
rename to Examples/Example80_Polar.cs.meta
diff --git a/Examples/Runtime/Example90_Candlestick.cs b/Examples/Example90_Candlestick.cs
similarity index 75%
rename from Examples/Runtime/Example90_Candlestick.cs
rename to Examples/Example90_Candlestick.cs
index 64fef408..895e305d 100644
--- a/Examples/Runtime/Example90_Candlestick.cs
+++ b/Examples/Example90_Candlestick.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
using XCharts.Runtime;
@@ -31,9 +29,7 @@ namespace XCharts.Example
}
}
- void AddData()
- {
- }
+ void AddData() { }
void GenerateOHLC(int count)
{
@@ -46,15 +42,17 @@ namespace XCharts.Example
for (int i = 0; i < count; i++)
{
- baseValue = baseValue + Random.Range(0f,1f) * 30 - 10;
- for(int j=0;j< 4;j++){
- boxVals[j] = (Random.Range(0f,1f) - 0.5f) * dayRange + baseValue;
+ baseValue = baseValue + Random.Range(0f, 1f) * 30 - 10;
+ for (int j = 0; j < 4; j++)
+ {
+ boxVals[j] = (Random.Range(0f, 1f) - 0.5f) * dayRange + baseValue;
}
System.Array.Sort(boxVals);
- var openIdx = Mathf.RoundToInt(Random.Range(0f,1f) * 3);
- var closeIdx = Mathf.RoundToInt(Random.Range(0f,1f) * 2);
- if(openIdx == closeIdx){
- closeIdx ++;
+ var openIdx = Mathf.RoundToInt(Random.Range(0f, 1f) * 3);
+ var closeIdx = Mathf.RoundToInt(Random.Range(0f, 1f) * 2);
+ if (openIdx == closeIdx)
+ {
+ closeIdx++;
}
//var volumn = boxVals[3]*(1000+Random.Range(0f,1f) * 500);
var open = boxVals[openIdx];
@@ -63,7 +61,7 @@ namespace XCharts.Example
var heighest = boxVals[3];
chart.AddXAxisData(i.ToString());
- chart.AddData(0,open,close,lowest,heighest);
+ chart.AddData(0, open, close, lowest, heighest);
}
}
}
diff --git a/Examples/Runtime/Example90_Candlestick.cs.meta b/Examples/Example90_Candlestick.cs.meta
similarity index 100%
rename from Examples/Runtime/Example90_Candlestick.cs.meta
rename to Examples/Example90_Candlestick.cs.meta
diff --git a/Examples/Runtime/Example_AddChart.cs b/Examples/Example_AddChart.cs
similarity index 99%
rename from Examples/Runtime/Example_AddChart.cs
rename to Examples/Example_AddChart.cs
index 5d4ff601..80359764 100644
--- a/Examples/Runtime/Example_AddChart.cs
+++ b/Examples/Example_AddChart.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example_AddChart.cs.meta b/Examples/Example_AddChart.cs.meta
similarity index 100%
rename from Examples/Runtime/Example_AddChart.cs.meta
rename to Examples/Example_AddChart.cs.meta
diff --git a/Examples/Runtime/Example_Component.cs b/Examples/Example_Component.cs
similarity index 84%
rename from Examples/Runtime/Example_Component.cs
rename to Examples/Example_Component.cs
index 195d63f3..9847c970 100644
--- a/Examples/Runtime/Example_Component.cs
+++ b/Examples/Example_Component.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using XCharts.Runtime;
@@ -28,9 +27,7 @@ namespace XCharts.Example
label.offset = new Vector3(0, 20, 0);
var serieData = chart.AddData(0, 20);
- //var serieData = serie1.GetSerieData(0);
- var baseInfo = serieData.GetOrAddComponent();
- baseInfo.radius = 10;
+ serieData.radius = 10;
var itemStyle = serieData.GetOrAddComponent();
itemStyle.color = Color.blue;
}
diff --git a/Examples/Runtime/Example_Component.cs.meta b/Examples/Example_Component.cs.meta
similarity index 100%
rename from Examples/Runtime/Example_Component.cs.meta
rename to Examples/Example_Component.cs.meta
diff --git a/Examples/Runtime/Example_Dynamic.cs b/Examples/Example_Dynamic.cs
similarity index 93%
rename from Examples/Runtime/Example_Dynamic.cs
rename to Examples/Example_Dynamic.cs
index 43d36a3a..e2a2f94d 100644
--- a/Examples/Runtime/Example_Dynamic.cs
+++ b/Examples/Example_Dynamic.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
using XCharts.Runtime;
@@ -12,7 +11,7 @@ namespace XCharts.Example
{
public int maxCacheDataNumber = 100;
public float initDataTime = 2;
- public bool insertDataToHead = false;
+ public bool insertDataToHead = true;
private BaseChart chart;
private float updateTime;
@@ -42,7 +41,7 @@ namespace XCharts.Example
{
if (initCount < maxCacheDataNumber)
{
- int count = (int)(maxCacheDataNumber / initDataTime * Time.deltaTime);
+ int count = (int) (maxCacheDataNumber / initDataTime * Time.deltaTime);
for (int i = 0; i < count; i++)
{
timeNow = timeNow.AddSeconds(1);
diff --git a/Examples/Runtime/Example_Dynamic.cs.meta b/Examples/Example_Dynamic.cs.meta
similarity index 100%
rename from Examples/Runtime/Example_Dynamic.cs.meta
rename to Examples/Example_Dynamic.cs.meta
diff --git a/Examples/Runtime/Example_LargeData.cs b/Examples/Example_LargeData.cs
similarity index 99%
rename from Examples/Runtime/Example_LargeData.cs
rename to Examples/Example_LargeData.cs
index 6ae52e64..6165c141 100644
--- a/Examples/Runtime/Example_LargeData.cs
+++ b/Examples/Example_LargeData.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example_LargeData.cs.meta b/Examples/Example_LargeData.cs.meta
similarity index 100%
rename from Examples/Runtime/Example_LargeData.cs.meta
rename to Examples/Example_LargeData.cs.meta
diff --git a/Examples/Runtime/Example_PieChart.cs b/Examples/Example_PieChart.cs
similarity index 99%
rename from Examples/Runtime/Example_PieChart.cs
rename to Examples/Example_PieChart.cs
index f55f1b9f..173b55cc 100644
--- a/Examples/Runtime/Example_PieChart.cs
+++ b/Examples/Example_PieChart.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example_PieChart.cs.meta b/Examples/Example_PieChart.cs.meta
similarity index 100%
rename from Examples/Runtime/Example_PieChart.cs.meta
rename to Examples/Example_PieChart.cs.meta
diff --git a/Examples/Runtime/Example_Test.cs b/Examples/Example_Test.cs
similarity index 67%
rename from Examples/Runtime/Example_Test.cs
rename to Examples/Example_Test.cs
index 66049cf3..f105bc79 100644
--- a/Examples/Runtime/Example_Test.cs
+++ b/Examples/Example_Test.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
using XCharts.Runtime;
@@ -31,21 +30,22 @@ namespace XCharts.Example
void OnTestBtn()
{
- object[][] m_TestData = new object[][]{
- new object[]{"01/06/20", 2.2d, 5.6d},
- new object[]{"22/06/20", 2.4d, 5.3d},
- new object[]{"04/08/21", 4.5d, 5.4d},
- new object[]{"05/08/21", 6.3d, 6.4d},
- new object[]{"06/08/21", 3.1d, 6.4d},
- new object[]{"09/08/21", 3.9d, 6.3d},
- new object[]{"10/08/21", 1.9d, 4.6d},
+ object[][] m_TestData = new object[][]
+ {
+ new object[] { "01/06/20", 2.2d, 5.6d },
+ new object[] { "22/06/20", 2.4d, 5.3d },
+ new object[] { "04/08/21", 4.5d, 5.4d },
+ new object[] { "05/08/21", 6.3d, 6.4d },
+ new object[] { "06/08/21", 3.1d, 6.4d },
+ new object[] { "09/08/21", 3.9d, 6.3d },
+ new object[] { "10/08/21", 1.9d, 4.6d },
};
chart.ClearData();
foreach (var list in m_TestData)
{
- chart.AddXAxisData((string)list[0]);
- chart.AddData(0, (double)list[1]);
- chart.AddData(1, (double)list[2]);
+ chart.AddXAxisData((string) list[0]);
+ chart.AddData(0, (double) list[1]);
+ chart.AddData(1, (double) list[2]);
}
}
diff --git a/Examples/Runtime/Example_Test.cs.meta b/Examples/Example_Test.cs.meta
similarity index 100%
rename from Examples/Runtime/Example_Test.cs.meta
rename to Examples/Example_Test.cs.meta
diff --git a/Examples/Runtime/Example_TestTime.cs b/Examples/Example_TestTime.cs
similarity index 99%
rename from Examples/Runtime/Example_TestTime.cs
rename to Examples/Example_TestTime.cs
index bb1879b9..59f813d2 100644
--- a/Examples/Runtime/Example_TestTime.cs
+++ b/Examples/Example_TestTime.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using XCharts.Runtime;
diff --git a/Examples/Runtime/Example_TestTime.cs.meta b/Examples/Example_TestTime.cs.meta
similarity index 100%
rename from Examples/Runtime/Example_TestTime.cs.meta
rename to Examples/Example_TestTime.cs.meta
diff --git a/Examples/Runtime/XCharts.Examples.Runtime.asmdef b/Examples/XCharts.Examples.Runtime.asmdef
similarity index 100%
rename from Examples/Runtime/XCharts.Examples.Runtime.asmdef
rename to Examples/XCharts.Examples.Runtime.asmdef
diff --git a/Examples/Runtime/XCharts.Examples.Runtime.asmdef.meta b/Examples/XCharts.Examples.Runtime.asmdef.meta
similarity index 100%
rename from Examples/Runtime/XCharts.Examples.Runtime.asmdef.meta
rename to Examples/XCharts.Examples.Runtime.asmdef.meta
diff --git a/Documentation/README-EN.md b/README-EN.md
similarity index 100%
rename from Documentation/README-EN.md
rename to README-EN.md
diff --git a/Documentation/README-EN.md.meta b/README-EN.md.meta
similarity index 75%
rename from Documentation/README-EN.md.meta
rename to README-EN.md.meta
index 9f886566..eca53158 100644
--- a/Documentation/README-EN.md.meta
+++ b/README-EN.md.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 29f30ecf23bb44bc5b0820dc5ee7a23e
+guid: 16271fd54c185499f9e4a915583d43e5
TextScriptImporter:
externalObjects: {}
userData:
diff --git a/README.md b/README.md
index b16d3487..1521ee01 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@
一款基于UGUI的数据可视化图表插件。
- English Doc
+ English Doc
@@ -43,7 +43,7 @@
-一款基于`UGUI`的功能强大、易用、参数可配置的数据可视化图表插件。支持折线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等十种常见免费内置图表,以及3D柱图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图等多种付费扩展图表。
+一款基于`UGUI`的功能强大、易用、参数可配置的数据可视化图表插件。支持折线图、柱状图、饼图、雷达图、散点图、热力图、环形图、K线图、极坐标、平行坐标等十种常见免费内置图表,以及3D饼图、3D柱图、漏斗图、金字塔、仪表盘、水位图、象形柱图、甘特图、矩形树图等多种扩展图表。
[XCharts3.0 教程](Documentation/XChartsTutorial01-ZH.md)
[XCharts3.0 API](Documentation/XChartsAPI-ZH.md)
@@ -85,9 +85,10 @@
- 更小的序列化文件。
- 更好的交互体验。
- 更多的组件支持。
+- 更强大的文本自述能力。
- 更合理的组件调整。
- 更灵活的组件插拔。
-- 更方便的二次开发。
+- 更高效的二次开发。
- 更丰富的Demo示例。
## XCharts3.0 和 2.0 数据对比
@@ -105,7 +106,7 @@
- XCharts3.0 不兼容 XCharts2.0 版本,建议旧项目还是继续使用XCharts2.0,新项目使用XCharts3.0。
- XCharts2.0 进入维护阶段,后续只修复严重bug理论上不再加新功能。
- XCharts 理论上支持Unity 5.6及以上版本,但由于版本测试有限难免疏漏,发现版本兼容问题可提Issue。
-- XCharts 内置图表都为常见的图表,可以免费使用;扩展图表大部分为不常使用的图表,有需要的可付费获取,感谢对XCharts的支持。
+- XCharts 内置图表都为常见的图表,可以免费使用;扩展图表大部分为不常使用的图表,有需要的可付费获取,详情[☞ 看这里](Documentation/SUPPORT.md)
- 本仓库只包含XCharts源码,不包含Demo示例部分。需要查看Demo示例请到[XCharts-Demo](https://github.com/XCharts-Team/XCharts-Demo)
## 截图
@@ -118,7 +119,23 @@
## 使用
-[XCharts教程:5分钟上手教程](Documentation/XChartsTutorial01-ZH.md)
+1. 导入`XCharts`的`unitypackage`或者源码到项目
+2. 在`Hierarchy`视图下右键选择`XCharts->LineChart`,即可创建一个默认的折线图
+3. 在`Inspector`试图可以调整各个组件的参数,并在`Game`视图看到实时效果
+
+更多教程请看:[XCharts教程:5分钟上手教程](Documentation/XChartsTutorial01-ZH.md)
+
+## FAQ
+
+1. XCharts 可以免费使用吗?
+ 答:可以免费使用。一些高级功能和扩展图表可根据自己的需求,再单独付费订阅和购买。
+
+2. XCharts 支持代码动态修改配置和数据吗?
+ 答:支持。
+
+3. 这个插件除了用在Unity,还能用在其他平台(如Winform或WPF)吗?
+ 答:目前只支持在Unity中使用。
+
## 日志
diff --git a/Runtime/Chart/BarChart.cs b/Runtime/Chart/BarChart.cs
index f01f53ac..65cb0d73 100644
--- a/Runtime/Chart/BarChart.cs
+++ b/Runtime/Chart/BarChart.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -27,4 +26,4 @@ namespace XCharts.Runtime
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/CandlestickChart.cs b/Runtime/Chart/CandlestickChart.cs
index 9e6a162f..be7e0263 100644
--- a/Runtime/Chart/CandlestickChart.cs
+++ b/Runtime/Chart/CandlestickChart.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
namespace XCharts.Runtime
@@ -28,4 +26,4 @@ namespace XCharts.Runtime
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/HeatmapChart.cs b/Runtime/Chart/HeatmapChart.cs
index 7e013bfe..421ae09e 100644
--- a/Runtime/Chart/HeatmapChart.cs
+++ b/Runtime/Chart/HeatmapChart.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -31,8 +30,8 @@ namespace XCharts.Runtime
RemoveData();
var heatmapGridWid = 10f;
- int xSplitNumber = (int)(grid.context.width / heatmapGridWid);
- int ySplitNumber = (int)(grid.context.height / heatmapGridWid);
+ int xSplitNumber = (int) (grid.context.width / heatmapGridWid);
+ int ySplitNumber = (int) (grid.context.height / heatmapGridWid);
Heatmap.AddDefaultSerie(this, GenerateDefaultSerieName());
@@ -45,13 +44,21 @@ namespace XCharts.Runtime
visualMap.location.align = Location.Align.BottomLeft;
visualMap.location.bottom = 100;
visualMap.location.left = 30;
- var colors = new List{"#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf",
- "#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"};
- visualMap.inRange.Clear();
- foreach (var str in colors)
+ var colors = new List
{
- visualMap.inRange.Add(ThemeStyle.GetColor(str));
- }
+ "#313695",
+ "#4575b4",
+ "#74add1",
+ "#abd9e9",
+ "#e0f3f8",
+ "#ffffbf",
+ "#fee090",
+ "#fdae61",
+ "#f46d43",
+ "#d73027",
+ "#a50026"
+ };
+ visualMap.AddColors(colors);
for (int i = 0; i < xSplitNumber; i++)
{
xAxis.data.Add((i + 1).ToString());
@@ -74,4 +81,4 @@ namespace XCharts.Runtime
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/LineChart.cs b/Runtime/Chart/LineChart.cs
index 331d35c6..c5317f5c 100644
--- a/Runtime/Chart/LineChart.cs
+++ b/Runtime/Chart/LineChart.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
namespace XCharts.Runtime
@@ -28,4 +26,4 @@ namespace XCharts.Runtime
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/ParallelChart.cs b/Runtime/Chart/ParallelChart.cs
index b955dbfa..63abdf69 100644
--- a/Runtime/Chart/ParallelChart.cs
+++ b/Runtime/Chart/ParallelChart.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -28,4 +27,4 @@ namespace XCharts.Runtime
Parallel.AddDefaultSerie(this, GenerateDefaultSerieName());
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/PieChart.cs b/Runtime/Chart/PieChart.cs
index 41fb5e89..f6ef9d32 100644
--- a/Runtime/Chart/PieChart.cs
+++ b/Runtime/Chart/PieChart.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -18,4 +17,4 @@ namespace XCharts.Runtime
Pie.AddDefaultSerie(this, GenerateDefaultSerieName());
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/PolarChart.cs b/Runtime/Chart/PolarChart.cs
index 77e24b2d..580efb92 100644
--- a/Runtime/Chart/PolarChart.cs
+++ b/Runtime/Chart/PolarChart.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
namespace XCharts.Runtime
@@ -32,4 +30,4 @@ namespace XCharts.Runtime
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/RadarChart.cs b/Runtime/Chart/RadarChart.cs
index 01942892..ca01353b 100644
--- a/Runtime/Chart/RadarChart.cs
+++ b/Runtime/Chart/RadarChart.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -17,4 +16,4 @@ namespace XCharts.Runtime
Radar.AddDefaultSerie(this, GenerateDefaultSerieName());
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/RingChart.cs b/Runtime/Chart/RingChart.cs
index a591f264..ae04dd2a 100644
--- a/Runtime/Chart/RingChart.cs
+++ b/Runtime/Chart/RingChart.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
namespace XCharts.Runtime
@@ -17,4 +15,4 @@ namespace XCharts.Runtime
Ring.AddDefaultSerie(this, GenerateDefaultSerieName());
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/ScatterChart.cs b/Runtime/Chart/ScatterChart.cs
index 194b84b7..a6ce4d97 100644
--- a/Runtime/Chart/ScatterChart.cs
+++ b/Runtime/Chart/ScatterChart.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -29,4 +28,4 @@ namespace XCharts.Runtime
Scatter.AddDefaultSerie(this, GenerateDefaultSerieName());
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/SimplifiedBarChart.cs b/Runtime/Chart/SimplifiedBarChart.cs
index df919e1c..f2079b3a 100644
--- a/Runtime/Chart/SimplifiedBarChart.cs
+++ b/Runtime/Chart/SimplifiedBarChart.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
namespace XCharts.Runtime
@@ -28,4 +26,4 @@ namespace XCharts.Runtime
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/SimplifiedCandlestickChart.cs b/Runtime/Chart/SimplifiedCandlestickChart.cs
index 5abcb1f6..0d2d8ef5 100644
--- a/Runtime/Chart/SimplifiedCandlestickChart.cs
+++ b/Runtime/Chart/SimplifiedCandlestickChart.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
namespace XCharts.Runtime
@@ -28,4 +26,4 @@ namespace XCharts.Runtime
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Chart/SimplifiedLineChart.cs b/Runtime/Chart/SimplifiedLineChart.cs
index 5064c3ea..4553cbbe 100644
--- a/Runtime/Chart/SimplifiedLineChart.cs
+++ b/Runtime/Chart/SimplifiedLineChart.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
namespace XCharts.Runtime
@@ -28,4 +26,4 @@ namespace XCharts.Runtime
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Component/Animation/AnimationStyle.cs b/Runtime/Component/Animation/AnimationStyle.cs
index 15b80509..9966e134 100644
--- a/Runtime/Component/Animation/AnimationStyle.cs
+++ b/Runtime/Component/Animation/AnimationStyle.cs
@@ -1,7 +1,6 @@
-
+using System;
using System.Collections.Generic;
using UnityEngine;
-using System;
namespace XCharts.Runtime
{
@@ -233,7 +232,7 @@ namespace XCharts.Runtime
if (m_IsEnd)
return;
- m_ActualDuration = (int)((Time.time - startTime) * 1000) - (m_FadeOut ? fadeOutDelay : fadeInDelay);
+ m_ActualDuration = (int) ((Time.time - startTime) * 1000) - (m_FadeOut ? fadeOutDelay : fadeInDelay);
m_IsEnd = true;
m_IsInit = false;
@@ -380,9 +379,9 @@ namespace XCharts.Runtime
public bool IsIndexAnimation()
{
- return context.type == AnimationType.LeftToRight
- || context.type == AnimationType.Clockwise
- || context.type == AnimationType.AlongPath;
+ return context.type == AnimationType.LeftToRight ||
+ context.type == AnimationType.Clockwise ||
+ context.type == AnimationType.AlongPath;
}
public float GetIndexDelay(int dataIndex)
@@ -462,9 +461,9 @@ namespace XCharts.Runtime
if (IsInDelay())
return;
- m_ActualDuration = (int)((Time.time - startTime) * 1000) - fadeInDelay;
+ m_ActualDuration = (int) ((Time.time - startTime) * 1000) - fadeInDelay;
var duration = GetCurrAnimationDuration();
- var delta = (float)(total / duration * Time.deltaTime);
+ var delta = (float) (total / duration * Time.deltaTime);
if (m_FadeOut)
{
m_CurrDetailProgress -= delta;
@@ -534,8 +533,8 @@ namespace XCharts.Runtime
}
else
{
- if ((destProgress - startProgress > 0 && currHig > destProgress)
- || (destProgress - startProgress < 0 && currHig < destProgress))
+ if ((destProgress - startProgress > 0 && currHig > destProgress) ||
+ (destProgress - startProgress < 0 && currHig < destProgress))
{
currHig = destProgress;
isEnd = true;
@@ -613,7 +612,7 @@ namespace XCharts.Runtime
#endif
if (!enable || m_IsEnd)
return -1;
- return (int)m_CurrDetailProgress;
+ return (int) m_CurrDetailProgress;
}
public float GetUpdateAnimationDuration()
diff --git a/Runtime/Component/Animation/AnimationStyleContext.cs b/Runtime/Component/Animation/AnimationStyleContext.cs
index b4f423f3..9184e0a7 100644
--- a/Runtime/Component/Animation/AnimationStyleContext.cs
+++ b/Runtime/Component/Animation/AnimationStyleContext.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEngine;
diff --git a/Runtime/Component/Animation/AnimationStyleHelper.cs b/Runtime/Component/Animation/AnimationStyleHelper.cs
index 6f6e9bfd..332236da 100644
--- a/Runtime/Component/Animation/AnimationStyleHelper.cs
+++ b/Runtime/Component/Animation/AnimationStyleHelper.cs
@@ -39,9 +39,9 @@ namespace XCharts.Runtime
public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType)
{
- animation.context.type = animation.type == AnimationType.Default
- ? defaultType
- : animation.type;
+ animation.context.type = animation.type == AnimationType.Default ?
+ defaultType :
+ animation.type;
}
public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip)
diff --git a/Runtime/Component/Axis/AngleAxis/AngleAxis.cs b/Runtime/Component/Axis/AngleAxis/AngleAxis.cs
index c0984d15..46909d73 100644
--- a/Runtime/Component/Axis/AngleAxis/AngleAxis.cs
+++ b/Runtime/Component/Axis/AngleAxis/AngleAxis.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
diff --git a/Runtime/Component/Axis/AngleAxis/AngleAxisHandler.cs b/Runtime/Component/Axis/AngleAxis/AngleAxisHandler.cs
index 5a06cbad..b57b5a4d 100644
--- a/Runtime/Component/Axis/AngleAxis/AngleAxisHandler.cs
+++ b/Runtime/Component/Axis/AngleAxis/AngleAxisHandler.cs
@@ -86,7 +86,7 @@ namespace XCharts.Runtime
bool inside = axis.axisLabel.inside;
var labelName = AxisHelper.GetLabelName(axis, total, i, axis.context.minValue, axis.context.maxValue,
null, isPercentStack);
- var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
+ var label = ChartHelper.AddAxisLabelObject(splitNumber, i, objName + i, axisObj.transform,
new Vector2(scaleAngle, txtHig), axis,
chart.theme.axis, labelName, Color.clear);
label.text.SetAlignment(axis.axisLabel.textStyle.GetAlignment(TextAnchor.MiddleCenter));
@@ -124,9 +124,9 @@ namespace XCharts.Runtime
}
if (angleAxis.show && angleAxis.axisTick.show)
{
- if ((i == 1 && angleAxis.axisTick.showStartTick)
- || (i == size - 1 && angleAxis.axisTick.showEndTick)
- || (i > 1 && i < size - 1))
+ if ((i == 1 && angleAxis.axisTick.showStartTick) ||
+ (i == size - 1 && angleAxis.axisTick.showEndTick) ||
+ (i > 1 && i < size - 1))
{
var tickY = radius + tickLength;
var tickPos = ChartHelper.GetPos(cenPos, tickY, currAngle, true);
diff --git a/Runtime/Component/Axis/Axis.cs b/Runtime/Component/Axis/Axis.cs
index 92ad2866..4c69114d 100644
--- a/Runtime/Component/Axis/Axis.cs
+++ b/Runtime/Component/Axis/Axis.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -366,11 +365,11 @@ namespace XCharts.Runtime
{
get
{
- return m_VertsDirty
- || axisLine.anyDirty
- || axisTick.anyDirty
- || splitLine.anyDirty
- || splitArea.anyDirty;
+ return m_VertsDirty ||
+ axisLine.anyDirty ||
+ axisTick.anyDirty ||
+ splitLine.anyDirty ||
+ splitArea.anyDirty;
}
}
@@ -378,9 +377,9 @@ namespace XCharts.Runtime
{
get
{
- return m_ComponentDirty
- || axisName.anyDirty
- || axisLabel.anyDirty;
+ return m_ComponentDirty ||
+ axisName.anyDirty ||
+ axisLabel.anyDirty;
}
}
@@ -656,11 +655,11 @@ namespace XCharts.Runtime
if (IsCategory() && boundaryGap)
{
var each = axisLength / data.Count;
- return (float)(each * (value + 0.5f));
+ return (float) (each * (value + 0.5f));
}
else
{
- return axisLength * (float)((value - context.minValue) / context.minMaxRange);
+ return axisLength * (float) ((value - context.minValue) / context.minMaxRange);
}
}
@@ -754,21 +753,21 @@ namespace XCharts.Runtime
if (value <= 0 || value == 1)
return 0;
else
- return logBaseE ? (float)Math.Log(value) : (float)Math.Log(value, logBase);
+ return logBaseE ? (float) Math.Log(value) : (float) Math.Log(value, logBase);
}
public int GetLogMinIndex()
{
- return logBaseE
- ? (int)Math.Log(context.minValue)
- : (int)Math.Log(context.minValue, logBase);
+ return logBaseE ?
+ (int) Math.Log(context.minValue) :
+ (int) Math.Log(context.minValue, logBase);
}
public int GetLogMaxIndex()
{
- return logBaseE
- ? (int)Math.Log(context.maxValue)
- : (int)Math.Log(context.maxValue, logBase);
+ return logBaseE ?
+ (int) Math.Log(context.maxValue) :
+ (int) Math.Log(context.maxValue, logBase);
}
public double GetLabelValue(int index)
diff --git a/Runtime/Component/Axis/AxisContext.cs b/Runtime/Component/Axis/AxisContext.cs
index c42fe217..c47d5a6c 100644
--- a/Runtime/Component/Axis/AxisContext.cs
+++ b/Runtime/Component/Axis/AxisContext.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -56,7 +55,6 @@ namespace XCharts.Runtime
private List m_LabelValueList = new List();
private List m_RuntimeData = new List();
-
internal void Clear()
{
m_RuntimeData.Clear();
@@ -87,10 +85,10 @@ namespace XCharts.Runtime
if (end > data.Count) end = data.Count;
}
- if (start != filterStart
- || end != filterEnd
- || dataZoom.minShowNum != filterMinShow
- || isNeedUpdateFilterData)
+ if (start != filterStart ||
+ end != filterEnd ||
+ dataZoom.minShowNum != filterMinShow ||
+ isNeedUpdateFilterData)
{
filterStart = start;
filterEnd = end;
diff --git a/Runtime/Component/Axis/AxisHandler.cs b/Runtime/Component/Axis/AxisHandler.cs
index 4bf963d2..1256289b 100644
--- a/Runtime/Component/Axis/AxisHandler.cs
+++ b/Runtime/Component/Axis/AxisHandler.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
using UnityEngine.UI;
@@ -8,7 +7,7 @@ using XUGL;
namespace XCharts
{
public abstract class AxisHandler : MainComponentHandler
- where T : Axis
+ where T : Axis
{
private static readonly string s_DefaultAxisName = "name";
private double m_LastInterval = double.MinValue;
@@ -17,7 +16,7 @@ namespace XCharts
internal override void SetComponent(MainComponent component)
{
- this.component = (T)component;
+ this.component = (T) component;
}
protected virtual Vector3 GetLabelPosition(float scaleWid, int i)
@@ -25,6 +24,11 @@ namespace XCharts
return Vector3.zero;
}
+ protected virtual float GetAxisLineXOrY()
+ {
+ return 0;
+ }
+
protected virtual Orient orient { get; set; }
protected virtual void UpdatePointerValue(Axis axis)
@@ -50,8 +54,8 @@ namespace XCharts
for (int j = 0; j < axis.GetDataCount(dataZoom); j++)
{
float pY = grid.context.y + j * splitWid;
- if ((axis.boundaryGap && (local.y > pY && local.y <= pY + splitWid))
- || (!axis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
+ if ((axis.boundaryGap && (local.y > pY && local.y <= pY + splitWid)) ||
+ (!axis.boundaryGap && (local.y > pY - splitWid / 2 && local.y <= pY + splitWid / 2)))
{
axis.context.pointerValue = j;
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
@@ -70,8 +74,8 @@ namespace XCharts
for (int j = 0; j < axis.GetDataCount(dataZoom); j++)
{
float pX = grid.context.x + j * splitWid;
- if ((axis.boundaryGap && (local.x > pX && local.x <= pX + splitWid))
- || (!axis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
+ if ((axis.boundaryGap && (local.x > pX && local.x <= pX + splitWid)) ||
+ (!axis.boundaryGap && (local.x > pX - splitWid / 2 && local.x <= pX + splitWid / 2)))
{
axis.context.pointerValue = j;
axis.context.pointerLabelPosition = axis.GetLabelObjectPosition(j);
@@ -140,10 +144,10 @@ namespace XCharts
double tempMaxValue = 0;
chart.GetSeriesMinMaxValue(axis, axisIndex, out tempMinValue, out tempMaxValue);
- if (tempMinValue != axis.context.minValue
- || tempMaxValue != axis.context.maxValue
- || m_LastInterval != axis.interval
- || m_LastSplitNumber != axis.splitNumber)
+ if (tempMinValue != axis.context.minValue ||
+ tempMaxValue != axis.context.maxValue ||
+ m_LastInterval != axis.interval ||
+ m_LastSplitNumber != axis.splitNumber)
{
m_LastSplitNumber = axis.splitNumber;
m_LastInterval = axis.interval;
@@ -151,7 +155,6 @@ namespace XCharts
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
axis.context.offset = 0;
axis.context.lastCheckInverse = axis.inverse;
-
UpdateAxisTickValueList(axis);
if (tempMinValue != 0 || tempMaxValue != 0)
@@ -159,31 +162,31 @@ namespace XCharts
var grid = chart.GetChartComponent(axis.gridIndex);
if (grid != null && axis is XAxis && axis.IsValue())
{
- axis.context.offset = axis.context.minValue > 0
- ? 0
- : (axis.context.maxValue < 0
- ? grid.context.width
- : (float)(Math.Abs(axis.context.minValue) * (grid.context.width
- / (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
+ axis.context.offset = axis.context.minValue > 0 ?
+ 0 :
+ (axis.context.maxValue < 0 ?
+ grid.context.width :
+ (float) (Math.Abs(axis.context.minValue) * (grid.context.width /
+ (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
);
axis.context.x = grid.context.x;
- axis.context.y = grid.context.y;
+ axis.context.y = GetAxisLineXOrY();
axis.context.zeroY = grid.context.y;
- axis.context.zeroX = grid.context.x - (float)(axis.context.minValue * grid.context.width / axis.context.minMaxRange);
+ axis.context.zeroX = grid.context.x - (float) (axis.context.minValue * grid.context.width / axis.context.minMaxRange);
}
if (grid != null && axis is YAxis && axis.IsValue())
{
- axis.context.offset = axis.context.minValue > 0
- ? 0
- : (axis.context.maxValue < 0
- ? grid.context.height
- : (float)(Math.Abs(axis.context.minValue) * (grid.context.height
- / (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
+ axis.context.offset = axis.context.minValue > 0 ?
+ 0 :
+ (axis.context.maxValue < 0 ?
+ grid.context.height :
+ (float) (Math.Abs(axis.context.minValue) * (grid.context.height /
+ (Math.Abs(axis.context.minValue) + Math.Abs(axis.context.maxValue))))
);
- axis.context.x = grid.context.x;
+ axis.context.x = GetAxisLineXOrY();
axis.context.y = grid.context.y;
axis.context.zeroX = grid.context.x;
- axis.context.zeroY = grid.context.y - (float)(axis.context.minValue * grid.context.height / axis.context.minMaxRange);
+ axis.context.zeroY = grid.context.y - (float) (axis.context.minValue * grid.context.height / axis.context.minMaxRange);
}
}
var dataZoom = chart.GetDataZoomOfAxis(axis);
@@ -220,8 +223,8 @@ namespace XCharts
if (axis.IsTime())
{
var lastCount = axis.context.labelValueList.Count;
- DateTimeUtil.UpdateTimeAxisDateTimeList(axis.context.labelValueList, (int)axis.context.minValue,
- (int)axis.context.maxValue, axis.splitNumber);
+ DateTimeUtil.UpdateTimeAxisDateTimeList(axis.context.labelValueList, (int) axis.context.minValue,
+ (int) axis.context.maxValue, axis.splitNumber);
if (axis.context.labelValueList.Count != lastCount)
axis.SetAllDirty();
@@ -255,7 +258,7 @@ namespace XCharts
}
}
var value = 0d;
- if (Mathf.Approximately((float)(axis.context.minValue % tick), 0))
+ if (Mathf.Approximately((float) (axis.context.minValue % tick), 0))
{
value = axis.context.minValue;
}
@@ -328,9 +331,10 @@ namespace XCharts
}
}
- internal static void InitAxis(Axis axis, Axis relativedAxis, BaseChart chart, AxisHandler handler,
- Orient orient, float axisStartX, float axisStartY, float axisLength, float relativedLength)
+ protected void InitAxis(Axis relativedAxis, Orient orient,
+ float axisStartX, float axisStartY, float axisLength, float relativedLength)
{
+ Axis axis = component;
chart.InitAxisRuntimeData(axis);
var objName = ChartCached.GetComponentObjectName(axis);
@@ -358,23 +362,23 @@ namespace XCharts
var eachWidth = AxisHelper.GetEachWidth(axis, axisLength, dataZoom);
var gapWidth = axis.boundaryGap ? eachWidth / 2 : 0;
- var textWidth = axis.axisLabel.width > 0
- ? axis.axisLabel.width
- : (orient == Orient.Horizonal
- ? AxisHelper.GetScaleWidth(axis, axisLength, 0, dataZoom)
- : (axisStartX - chart.chartX)
+ var textWidth = axis.axisLabel.width > 0 ?
+ axis.axisLabel.width :
+ (orient == Orient.Horizonal ?
+ AxisHelper.GetScaleWidth(axis, axisLength, 0, dataZoom) :
+ (axisStartX - chart.chartX)
);
- var textHeight = axis.axisLabel.height > 0
- ? axis.axisLabel.height
- : 20f;
+ var textHeight = axis.axisLabel.height > 0 ?
+ axis.axisLabel.height :
+ 20f;
var isPercentStack = SeriesHelper.IsPercentStack(chart.series);
var inside = axis.axisLabel.inside;
var defaultAlignment = orient == Orient.Horizonal ? TextAnchor.MiddleCenter :
- ((inside && axis.IsLeft()) || (!inside && axis.IsRight())
- ? TextAnchor.MiddleLeft
- : TextAnchor.MiddleRight);
+ ((inside && axis.IsLeft()) || (!inside && axis.IsRight()) ?
+ TextAnchor.MiddleLeft :
+ TextAnchor.MiddleRight);
if (axis.IsCategory() && axis.boundaryGap)
splitNumber -= 1;
@@ -398,9 +402,9 @@ namespace XCharts
if (i == 0)
axis.axisLabel.SetRelatedText(label.text, labelWidth);
- var pos = handler.GetLabelPosition(totalWidth + gapWidth, i);
+ var pos = GetLabelPosition(totalWidth + gapWidth, i);
label.SetPosition(pos);
- handler.CheckValueLabelActive(axis, i, label, pos);
+ CheckValueLabelActive(axis, i, label, pos);
axis.context.labelObjectList.Add(label);
@@ -415,6 +419,7 @@ namespace XCharts
var autoColor = axis.axisLine.GetColor(chart.theme.axis.lineColor);
if (orient == Orient.Horizonal)
{
+ var posY = GetAxisLineXOrY() + offset.y;
switch (axis.axisName.labelStyle.position)
{
case LabelStyle.Position.Start:
@@ -422,9 +427,9 @@ namespace XCharts
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleRight);
label.SetActive(axis.axisName.labelStyle.show);
- label.SetPosition(axis.position == Axis.AxisPosition.Top
- ? new Vector2(zeroPos.x - offset.x, axisStartY + relativedLength + offset.y + axis.offset)
- : new Vector2(zeroPos.x - offset.x, zeroPos.y + offset.y + axis.offset));
+ label.SetPosition(axis.position == Axis.AxisPosition.Top ?
+ new Vector2(zeroPos.x - offset.x, axisStartY + relativedLength + offset.y + axis.offset) :
+ new Vector2(zeroPos.x - offset.x, posY));
break;
case LabelStyle.Position.Middle:
@@ -432,9 +437,9 @@ namespace XCharts
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show);
- label.SetPosition(axis.position == Axis.AxisPosition.Top
- ? new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY + relativedLength - offset.y + axis.offset)
- : new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY - offset.y + axis.offset));
+ label.SetPosition(axis.position == Axis.AxisPosition.Top ?
+ new Vector2(axisStartX + axisLength / 2 + offset.x, axisStartY + relativedLength - offset.y + axis.offset) :
+ new Vector2(axisStartX + axisLength / 2 + offset.x, posY));
break;
default:
@@ -442,44 +447,45 @@ namespace XCharts
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleLeft);
label.SetActive(axis.axisName.labelStyle.show);
- label.SetPosition(axis.position == Axis.AxisPosition.Top
- ? new Vector2(axisStartX + axisLength + offset.x, axisStartY + relativedLength + offset.y + axis.offset)
- : new Vector2(axisStartX + axisLength + offset.x, zeroPos.y + offset.y + axis.offset));
+ label.SetPosition(axis.position == Axis.AxisPosition.Top ?
+ new Vector2(axisStartX + axisLength + offset.x, axisStartY + relativedLength + offset.y + axis.offset) :
+ new Vector2(axisStartX + axisLength + offset.x, posY));
break;
}
}
else
{
+ var posX = GetAxisLineXOrY() + offset.x;
switch (axis.axisName.labelStyle.position)
{
case LabelStyle.Position.Start:
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
- chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
+ chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show);
label.SetPosition(axis.position == Axis.AxisPosition.Right ?
new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY - offset.y) :
- new Vector2(zeroPos.x + offset.x + axis.offset, axisStartY - offset.y));
+ new Vector2(posX, axisStartY - offset.y));
break;
case LabelStyle.Position.Middle:
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
- chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
+ chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show);
label.SetPosition(axis.position == Axis.AxisPosition.Right ?
new Vector2(axisStartX + relativedLength - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y) :
- new Vector2(axisStartX - offset.x + axis.offset, axisStartY + axisLength / 2 + offset.y));
+ new Vector2(posX, axisStartY + axisLength / 2 + offset.y));
break;
default:
//LabelStyle.Position
label = ChartHelper.AddChartLabel(s_DefaultAxisName, axisObj.transform, axis.axisName.labelStyle,
- chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
+ chart.theme.axis, axis.axisName.name, autoColor, TextAnchor.MiddleCenter);
label.SetActive(axis.axisName.labelStyle.show);
label.SetPosition(axis.position == Axis.AxisPosition.Right ?
new Vector2(axisStartX + relativedLength + offset.x + axis.offset, axisStartY + axisLength + offset.y) :
- new Vector2(zeroPos.x + offset.x + axis.offset, axisStartY + axisLength + offset.y));
+ new Vector2(posX, axisStartY + axisLength + offset.y));
break;
}
}
@@ -495,9 +501,9 @@ namespace XCharts
if (axis.IsTime() || axis.IsValue())
{
- scaleWid = axis.context.minMaxRange != 0
- ? axis.GetDistance(axis.GetLabelValue(i), axisLength)
- : 0;
+ scaleWid = axis.context.minMaxRange != 0 ?
+ axis.GetDistance(axis.GetLabelValue(i), axisLength) :
+ 0;
}
if (orient == Orient.Horizonal)
@@ -513,7 +519,7 @@ namespace XCharts
else
current += axisStartY - axis.axisLabel.distance - fontSize / 2;
- return new Vector3(axisStartX + scaleWid, current);
+ return new Vector3(axisStartX + scaleWid, current) + axis.axisLabel.offset;
}
else
{
@@ -528,7 +534,7 @@ namespace XCharts
else
current += axisStartX - axis.axisLabel.distance;
- return new Vector3(current, axisStartY + scaleWid);
+ return new Vector3(current, axisStartY + scaleWid) + axis.axisLabel.offset;
}
}
@@ -566,9 +572,9 @@ namespace XCharts
{
var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom);
- var current = orient == Orient.Horizonal
- ? startX
- : startY;
+ var current = orient == Orient.Horizonal ?
+ startX :
+ startY;
for (int i = 0; i < size; i++)
{
@@ -587,17 +593,17 @@ namespace XCharts
{
if (orient == Orient.Horizonal)
{
- float pX = axis.IsTime()
- ? (startX + axis.GetDistance(axis.GetLabelValue(i), axisLength))
- : current;
+ float pX = axis.IsTime() ?
+ (startX + axis.GetDistance(axis.GetLabelValue(i), axisLength)) :
+ current;
if (axis.boundaryGap && axis.axisTick.alignWithLabel)
pX -= scaleWidth / 2;
var sY = 0f;
var eY = 0f;
- if ((axis.axisTick.inside && axis.IsBottom())
- || (!axis.axisTick.inside && axis.IsTop()))
+ if ((axis.axisTick.inside && axis.IsBottom()) ||
+ (!axis.axisTick.inside && axis.IsTop()))
{
sY = startY + axis.offset + lineWidth;
eY = sY + tickLength;
@@ -614,17 +620,17 @@ namespace XCharts
}
else
{
- float pY = axis.IsTime()
- ? (startY + axis.GetDistance(axis.GetLabelValue(i), axisLength))
- : current;
+ float pY = axis.IsTime() ?
+ (startY + axis.GetDistance(axis.GetLabelValue(i), axisLength)) :
+ current;
if (axis.boundaryGap && axis.axisTick.alignWithLabel)
pY -= scaleWidth / 2;
var sX = 0f;
var eX = 0f;
- if ((axis.axisTick.inside && axis.IsLeft())
- || (!axis.axisTick.inside && axis.IsRight()))
+ if ((axis.axisTick.inside && axis.IsLeft()) ||
+ (!axis.axisTick.inside && axis.IsRight()))
{
sX = startX + axis.offset + lineWidth;
eX = sX + tickLength;
@@ -690,9 +696,10 @@ namespace XCharts
}
}
- internal static void DrawAxisSplit(VertexHelper vh, Axis axis, AxisTheme theme, DataZoom dataZoom,
+ protected void DrawAxisSplit(VertexHelper vh, AxisTheme theme, DataZoom dataZoom,
Orient orient, float startX, float startY, float axisLength, float splitLength, Axis relativedAxis = null)
{
+ Axis axis = component;
var lineColor = axis.splitLine.GetColor(theme.splitLineColor);
var lineWidth = axis.splitLine.GetWidth(theme.lineWidth);
var lineType = axis.splitLine.GetType(theme.splitLineType);
@@ -705,9 +712,9 @@ namespace XCharts
size += 1;
}
- var current = orient == Orient.Horizonal
- ? startX
- : startY;
+ var current = orient == Orient.Horizonal ?
+ startX :
+ startY;
for (int i = 0; i < size; i++)
{
var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, axis.IsTime() ? i : i + 1, dataZoom);
@@ -743,7 +750,7 @@ namespace XCharts
{
if (orient == Orient.Horizonal)
{
- if (relativedAxis == null || !MathUtil.Approximately(current, relativedAxis.context.x))
+ if (relativedAxis == null || !MathUtil.Approximately(current, GetAxisLineXOrY()))
ChartDrawer.DrawLineStyle(vh,
lineType,
lineWidth,
@@ -753,7 +760,7 @@ namespace XCharts
}
else
{
- if (relativedAxis == null || !MathUtil.Approximately(current, relativedAxis.context.y))
+ if (relativedAxis == null || !MathUtil.Approximately(current, GetAxisLineXOrY()))
ChartDrawer.DrawLineStyle(vh,
lineType,
lineWidth,
@@ -761,7 +768,6 @@ namespace XCharts
new Vector3(startX + splitLength, current),
lineColor);
}
-
}
}
current += scaleWidth;
diff --git a/Runtime/Component/Axis/AxisHelper.cs b/Runtime/Component/Axis/AxisHelper.cs
index 560679a4..8a1d31e4 100644
--- a/Runtime/Component/Axis/AxisHelper.cs
+++ b/Runtime/Component/Axis/AxisHelper.cs
@@ -120,15 +120,15 @@ namespace XCharts.Runtime
maxValue = -maxValue;
}
if (forcePercent)
- return string.Format("{0}%", (int)value);
+ return string.Format("{0}%", (int) value);
else
return axis.axisLabel.GetFormatterContent(index, value, minValue, maxValue);
}
else if (axis.type == Axis.AxisType.Log)
{
- float value = axis.logBaseE
- ? Mathf.Exp(axis.GetLogMinIndex() + index)
- : Mathf.Pow(axis.logBase, axis.GetLogMinIndex() + index);
+ double value = axis.logBaseE ?
+ System.Math.Exp(axis.GetLogMinIndex() + index) :
+ System.Math.Pow(axis.logBase, axis.GetLogMinIndex() + index);
if (axis.inverse)
{
value = -value;
@@ -206,16 +206,16 @@ namespace XCharts.Runtime
if (axis.boundaryGap)
{
- scaleNum = dataCount > 2 && dataCount % splitNum == 0
- ? splitNum + 1
- : splitNum + 2;
+ scaleNum = dataCount > 2 && dataCount % splitNum == 0 ?
+ splitNum + 1 :
+ splitNum + 2;
}
else
{
if (dataCount < splitNum) scaleNum = splitNum;
- else scaleNum = dataCount > 2 && dataCount % splitNum == 0
- ? splitNum
- : splitNum + 1;
+ else scaleNum = dataCount > 2 && dataCount % splitNum == 0 ?
+ splitNum :
+ splitNum + 1;
}
return scaleNum;
}
@@ -245,9 +245,9 @@ namespace XCharts.Runtime
{
var value = axis.GetLabelValue(index);
var lastValue = axis.GetLabelValue(index - 1);
- return axis.context.minMaxRange == 0
- ? 0
- : (float)(coordinateWidth * (value - lastValue) / axis.context.minMaxRange);
+ return axis.context.minMaxRange == 0 ?
+ 0 :
+ (float) (coordinateWidth * (value - lastValue) / axis.context.minMaxRange);
}
else
{
@@ -339,8 +339,7 @@ namespace XCharts.Runtime
return;
}
if (axis.type == Axis.AxisType.Time)
- {
- }
+ { }
else if (axis.minMaxType == Axis.AxisMinMaxType.Custom)
{
if (axis.min != 0 || axis.max != 0)
@@ -365,8 +364,7 @@ namespace XCharts.Runtime
case Axis.AxisMinMaxType.Default:
if (minValue == 0 && maxValue == 0)
- {
- }
+ { }
else if (minValue > 0 && maxValue > 0)
{
minValue = 0;
@@ -454,7 +452,7 @@ namespace XCharts.Runtime
if (axis.IsCategory())
{
if (dataCount == 0) dataCount = axis.data.Count;
- var categoryIndex = (int)value;
+ var categoryIndex = (int) value;
var scaleWid = AxisHelper.GetDataWidth(axis, gridHeight, dataCount, dataZoom);
float startY = gridXY + (axis.boundaryGap ? scaleWid / 2 : 0);
return startY + scaleWid * categoryIndex;
@@ -462,7 +460,7 @@ namespace XCharts.Runtime
else
{
var yDataHig = (axis.context.minMaxRange == 0) ? 0f :
- (float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
+ (float) ((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
return gridXY + yDataHig;
}
@@ -533,16 +531,16 @@ namespace XCharts.Runtime
{
int minIndex = axis.GetLogMinIndex();
float nowIndex = axis.GetLogValue(value);
- return includeGridXY
- ? gridXY + (nowIndex - minIndex) / axis.splitNumber * gridHeight
- : (nowIndex - minIndex) / axis.splitNumber * gridHeight;
+ return includeGridXY ?
+ gridXY + (nowIndex - minIndex) / axis.splitNumber * gridHeight :
+ (nowIndex - minIndex) / axis.splitNumber * gridHeight;
}
else if (axis.IsCategory())
{
- var categoryIndex = (int)value;
- return includeGridXY
- ? gridXY + (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex
- : (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex;
+ var categoryIndex = (int) value;
+ return includeGridXY ?
+ gridXY + (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex :
+ (axis.boundaryGap ? scaleWidth / 2 : 0) + scaleWidth * categoryIndex;
}
else
{
@@ -550,13 +548,13 @@ namespace XCharts.Runtime
if (axis.context.minMaxRange != 0)
{
if (realLength)
- yDataHig = (float)(value * gridHeight / axis.context.minMaxRange);
+ yDataHig = (float) (value * gridHeight / axis.context.minMaxRange);
else
- yDataHig = (float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
+ yDataHig = (float) ((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
}
- return includeGridXY
- ? gridXY + yDataHig
- : yDataHig;
+ return includeGridXY ?
+ gridXY + yDataHig :
+ yDataHig;
}
}
}
diff --git a/Runtime/Component/Axis/AxisLabel.cs b/Runtime/Component/Axis/AxisLabel.cs
index f90773ef..acac6161 100644
--- a/Runtime/Component/Axis/AxisLabel.cs
+++ b/Runtime/Component/Axis/AxisLabel.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
using UnityEngine.UI;
@@ -97,10 +96,10 @@ namespace XCharts.Runtime
return new AxisLabel()
{
m_Show = true,
- m_Interval = 0,
- m_Inside = false,
- m_Distance = 8,
- m_TextStyle = new TextStyle(),
+ m_Interval = 0,
+ m_Inside = false,
+ m_Distance = 8,
+ m_TextStyle = new TextStyle(),
};
}
}
@@ -150,9 +149,9 @@ namespace XCharts.Runtime
{
return m_FormatterFunction(labelIndex, 0, category);
}
- if (string.IsNullOrEmpty(category))
+ if (string.IsNullOrEmpty(category))
return category;
-
+
if (string.IsNullOrEmpty(m_Formatter))
{
return m_TextLimit.GetLimitContent(category);
@@ -205,7 +204,7 @@ namespace XCharts.Runtime
{
return m_FormatterFunction(labelIndex, value, null);
}
- var timestamp = (int)value;
+ var timestamp = (int) value;
var dateTime = DateTimeUtil.GetDateTime(timestamp);
var dateString = string.Empty;
if (string.IsNullOrEmpty(numericFormatter))
diff --git a/Runtime/Component/Axis/AxisLine.cs b/Runtime/Component/Axis/AxisLine.cs
index d242f93b..289a7ade 100644
--- a/Runtime/Component/Axis/AxisLine.cs
+++ b/Runtime/Component/Axis/AxisLine.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
diff --git a/Runtime/Component/Axis/AxisName.cs b/Runtime/Component/Axis/AxisName.cs
index 2e148644..412df3f9 100644
--- a/Runtime/Component/Axis/AxisName.cs
+++ b/Runtime/Component/Axis/AxisName.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
diff --git a/Runtime/Component/Axis/AxisSplitArea.cs b/Runtime/Component/Axis/AxisSplitArea.cs
index a477930c..833c0528 100644
--- a/Runtime/Component/Axis/AxisSplitArea.cs
+++ b/Runtime/Component/Axis/AxisSplitArea.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -43,7 +42,7 @@ namespace XCharts.Runtime
return new AxisSplitArea()
{
m_Show = false,
- m_Color = new List() { }
+ m_Color = new List() { }
};
}
}
diff --git a/Runtime/Component/Axis/AxisSplitLine.cs b/Runtime/Component/Axis/AxisSplitLine.cs
index aa461e20..8e47a14b 100644
--- a/Runtime/Component/Axis/AxisSplitLine.cs
+++ b/Runtime/Component/Axis/AxisSplitLine.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
diff --git a/Runtime/Component/Axis/AxisTick.cs b/Runtime/Component/Axis/AxisTick.cs
index 01d0772e..ff3e7191 100644
--- a/Runtime/Component/Axis/AxisTick.cs
+++ b/Runtime/Component/Axis/AxisTick.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
namespace XCharts.Runtime
diff --git a/Runtime/Component/Axis/ParallelAxis/ParallelAxis.cs b/Runtime/Component/Axis/ParallelAxis/ParallelAxis.cs
index 6ffe00ed..18f86050 100644
--- a/Runtime/Component/Axis/ParallelAxis/ParallelAxis.cs
+++ b/Runtime/Component/Axis/ParallelAxis/ParallelAxis.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -26,6 +25,5 @@ namespace XCharts.Runtime
axisLabel.textLimit.enable = true;
}
-
}
}
\ No newline at end of file
diff --git a/Runtime/Component/Axis/ParallelAxis/ParallelAxisHander.cs b/Runtime/Component/Axis/ParallelAxis/ParallelAxisHander.cs
index 71ebd410..76152220 100644
--- a/Runtime/Component/Axis/ParallelAxis/ParallelAxisHander.cs
+++ b/Runtime/Component/Axis/ParallelAxis/ParallelAxisHander.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
@@ -64,10 +63,10 @@ namespace XCharts.Runtime
var theme = chart.theme;
var xAxisIndex = axis.index;
axis.painter = chart.painter;
- axis.refreshComponent = delegate ()
+ axis.refreshComponent = delegate()
{
UpdateContext(axis);
- InitAxis(axis, null, chart, this,
+ InitAxis(null,
m_Orient,
axis.context.x,
axis.context.y,
@@ -118,7 +117,7 @@ namespace XCharts.Runtime
var dataZoom = chart.GetDataZoomOfAxis(axis);
- DrawAxisSplit(vh, axis, chart.theme.axis, dataZoom,
+ DrawAxisSplit(vh, chart.theme.axis, dataZoom,
m_Orient,
axis.context.x,
axis.context.y,
@@ -159,5 +158,10 @@ namespace XCharts.Runtime
axis.context.width);
}
}
+
+ protected override float GetAxisLineXOrY()
+ {
+ return component.context.y;
+ }
}
}
\ No newline at end of file
diff --git a/Runtime/Component/Axis/RadiusAxis/RadiusAxis.cs b/Runtime/Component/Axis/RadiusAxis/RadiusAxis.cs
index 69ce3c11..ab124143 100644
--- a/Runtime/Component/Axis/RadiusAxis/RadiusAxis.cs
+++ b/Runtime/Component/Axis/RadiusAxis/RadiusAxis.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
namespace XCharts.Runtime
diff --git a/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs b/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs
index d33b5fae..630a0612 100644
--- a/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs
+++ b/Runtime/Component/Axis/RadiusAxis/RadiusAxisHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -52,7 +51,7 @@ namespace XCharts.Runtime
double tempMinValue = 0;
double tempMaxValue = 0;
SeriesHelper.GetXMinMaxValue(chart.series, null, axis.polarIndex, true, axis.inverse, out tempMinValue,
- out tempMaxValue, true);
+ out tempMaxValue, true);
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
if (tempMinValue != axis.context.minValue || tempMaxValue != axis.context.maxValue)
{
@@ -132,8 +131,8 @@ namespace XCharts.Runtime
var cenPos = polar.context.center;
var dire = ChartHelper.GetDire(startAngle, true).normalized;
var tickLength = axis.axisTick.GetLength(chart.theme.axis.tickLength);
- var tickVector = ChartHelper.GetVertialDire(dire)
- * (tickLength + axis.axisLabel.distance);
+ var tickVector = ChartHelper.GetVertialDire(dire) *
+ (tickLength + axis.axisLabel.distance);
return ChartHelper.GetPos(cenPos, totalWidth, startAngle, true) + tickVector;
}
@@ -168,9 +167,9 @@ namespace XCharts.Runtime
}
if (radiusAxis.show && radiusAxis.axisTick.show)
{
- if ((i == 0 && radiusAxis.axisTick.showStartTick)
- || (i == size && radiusAxis.axisTick.showEndTick)
- || (i > 0 && i < size))
+ if ((i == 0 && radiusAxis.axisTick.showStartTick) ||
+ (i == size && radiusAxis.axisTick.showEndTick) ||
+ (i > 0 && i < size))
{
UGL.DrawLine(vh, pos, pos + tickVetor, tickWidth, chart.theme.axis.lineColor);
}
diff --git a/Runtime/Component/Axis/SingleAxis/SingleAxis.cs b/Runtime/Component/Axis/SingleAxis/SingleAxis.cs
index d167bed1..87c974e5 100644
--- a/Runtime/Component/Axis/SingleAxis/SingleAxis.cs
+++ b/Runtime/Component/Axis/SingleAxis/SingleAxis.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -87,15 +86,15 @@ namespace XCharts.Runtime
if (m_Orient == Orient.Horizonal)
{
- context.width = width == 0
- ? chartWidth - context.left - context.right
- : (width <= 1 ? chartWidth * width : width);
+ context.width = width == 0 ?
+ chartWidth - context.left - context.right :
+ (width <= 1 ? chartWidth * width : width);
}
else
{
- context.width = width == 0
- ? chartHeight - context.top - context.bottom
- : (width <= 1 ? chartHeight * width : width);
+ context.width = width == 0 ?
+ chartHeight - context.top - context.bottom :
+ (width <= 1 ? chartHeight * width : width);
}
if (context.left != 0 && context.right == 0)
diff --git a/Runtime/Component/Axis/SingleAxis/SingleAxisHandler.cs b/Runtime/Component/Axis/SingleAxis/SingleAxisHandler.cs
index 75588884..cea04762 100644
--- a/Runtime/Component/Axis/SingleAxis/SingleAxisHandler.cs
+++ b/Runtime/Component/Axis/SingleAxis/SingleAxisHandler.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
@@ -32,14 +31,14 @@ namespace XCharts.Runtime
var theme = chart.theme;
var xAxisIndex = axis.index;
axis.painter = chart.painter;
- axis.refreshComponent = delegate ()
+ axis.refreshComponent = delegate()
{
axis.UpdateRuntimeData(chart.chartX,
chart.chartY,
chart.chartWidth,
chart.chartHeight);
- InitAxis(axis, null, chart, this,
+ InitAxis(null,
axis.orient,
axis.context.x,
axis.context.y,
@@ -83,7 +82,7 @@ namespace XCharts.Runtime
if (AxisHelper.NeedShowSplit(axis))
{
var dataZoom = chart.GetDataZoomOfAxis(axis);
- DrawAxisSplit(vh, axis, chart.theme.axis, dataZoom,
+ DrawAxisSplit(vh, chart.theme.axis, dataZoom,
axis.orient,
axis.context.x,
axis.context.y,
@@ -109,14 +108,18 @@ namespace XCharts.Runtime
{
if (axis.show && axis.axisLine.show)
{
- var axisStartY = axis.context.y + axis.offset;
DrawAxisLine(vh, axis,
chart.theme.axis,
axis.orient,
axis.context.x,
- axisStartY,
+ GetAxisLineXOrY(),
axis.context.width);
}
}
+
+ protected override float GetAxisLineXOrY()
+ {
+ return component.context.y + component.offset;
+ }
}
}
\ No newline at end of file
diff --git a/Runtime/Component/Axis/XAxis/XAxis.cs b/Runtime/Component/Axis/XAxis/XAxis.cs
index ed94ff14..86059069 100644
--- a/Runtime/Component/Axis/XAxis/XAxis.cs
+++ b/Runtime/Component/Axis/XAxis/XAxis.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
diff --git a/Runtime/Component/Axis/XAxis/XAxisHander.cs b/Runtime/Component/Axis/XAxis/XAxisHander.cs
index 057ee7ff..e4020e08 100644
--- a/Runtime/Component/Axis/XAxis/XAxisHander.cs
+++ b/Runtime/Component/Axis/XAxis/XAxisHander.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
@@ -32,13 +31,13 @@ namespace XCharts.Runtime
var theme = chart.theme;
var xAxisIndex = xAxis.index;
xAxis.painter = chart.painter;
- xAxis.refreshComponent = delegate ()
+ xAxis.refreshComponent = delegate()
{
var grid = chart.GetChartComponent(xAxis.gridIndex);
if (grid != null)
{
var yAxis = chart.GetChartComponent(xAxis.index);
- InitAxis(xAxis, yAxis, chart, this,
+ InitAxis(yAxis,
orient,
grid.context.x,
grid.context.y,
@@ -94,7 +93,7 @@ namespace XCharts.Runtime
var relativedAxis = chart.GetChartComponent(xAxis.gridIndex);
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
- DrawAxisSplit(vh, xAxis, chart.theme.axis, dataZoom,
+ DrawAxisSplit(vh, chart.theme.axis, dataZoom,
Orient.Horizonal,
grid.context.x,
grid.context.y,
@@ -114,16 +113,10 @@ namespace XCharts.Runtime
var dataZoom = chart.GetDataZoomOfAxis(xAxis);
- var startY = grid.context.y + xAxis.offset;
- if (xAxis.IsTop())
- startY += grid.context.height;
- else
- startY += ComponentHelper.GetXAxisOnZeroOffset(chart.components, xAxis);
-
DrawAxisTick(vh, xAxis, chart.theme.axis, dataZoom,
Orient.Horizonal,
grid.context.x,
- startY,
+ GetAxisLineXOrY(),
grid.context.width);
}
}
@@ -136,18 +129,24 @@ namespace XCharts.Runtime
if (grid == null)
return;
- var startY = grid.context.y + xAxis.offset;
- if (xAxis.IsTop())
- startY += grid.context.height;
- else
- startY += ComponentHelper.GetXAxisOnZeroOffset(chart.components, xAxis);
-
DrawAxisLine(vh, xAxis, chart.theme.axis,
Orient.Horizonal,
grid.context.x,
- startY,
+ GetAxisLineXOrY(),
grid.context.width);
}
}
+
+ protected override float GetAxisLineXOrY()
+ {
+ var xAxis = component;
+ var grid = chart.GetChartComponent(xAxis.gridIndex);
+ var startY = grid.context.y + xAxis.offset;
+ if (xAxis.IsTop())
+ startY += grid.context.height;
+ else
+ startY += ComponentHelper.GetXAxisOnZeroOffset(chart.components, xAxis);
+ return startY;
+ }
}
}
\ No newline at end of file
diff --git a/Runtime/Component/Axis/YAxis/YAxis.cs b/Runtime/Component/Axis/YAxis/YAxis.cs
index 003672e2..aee2bd17 100644
--- a/Runtime/Component/Axis/YAxis/YAxis.cs
+++ b/Runtime/Component/Axis/YAxis/YAxis.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
namespace XCharts.Runtime
diff --git a/Runtime/Component/Axis/YAxis/YAxisHander.cs b/Runtime/Component/Axis/YAxis/YAxisHander.cs
index 8ef389df..5d91b08a 100644
--- a/Runtime/Component/Axis/YAxis/YAxisHander.cs
+++ b/Runtime/Component/Axis/YAxis/YAxisHander.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
@@ -32,13 +31,13 @@ namespace XCharts.Runtime
var theme = chart.theme;
var yAxisIndex = yAxis.index;
yAxis.painter = chart.painter;
- yAxis.refreshComponent = delegate ()
+ yAxis.refreshComponent = delegate()
{
var grid = chart.GetChartComponent(yAxis.gridIndex);
if (grid != null)
{
var xAxis = chart.GetChartComponent(yAxis.index);
- InitAxis(yAxis, xAxis, chart, this,
+ InitAxis(xAxis,
orient,
grid.context.x,
grid.context.y,
@@ -91,7 +90,7 @@ namespace XCharts.Runtime
return;
var relativedAxis = chart.GetChartComponent(yAxis.gridIndex);
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
- DrawAxisSplit(vh, yAxis, chart.theme.axis, dataZoom,
+ DrawAxisSplit(vh, chart.theme.axis, dataZoom,
Orient.Vertical,
grid.context.x,
grid.context.y,
@@ -111,15 +110,9 @@ namespace XCharts.Runtime
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
- var startX = grid.context.x + yAxis.offset;
- if (yAxis.IsRight())
- startX += grid.context.width;
- else
- startX += ComponentHelper.GetYAxisOnZeroOffset(chart.components, yAxis);
-
DrawAxisTick(vh, yAxis, chart.theme.axis, dataZoom,
Orient.Vertical,
- startX,
+ GetAxisLineXOrY(),
grid.context.y,
grid.context.height);
}
@@ -133,18 +126,24 @@ namespace XCharts.Runtime
if (grid == null)
return;
- var startX = grid.context.x + yAxis.offset;
- if (yAxis.IsRight())
- startX += grid.context.width;
- else
- startX += ComponentHelper.GetYAxisOnZeroOffset(chart.components, yAxis);
-
DrawAxisLine(vh, yAxis, chart.theme.axis,
Orient.Vertical,
- startX,
+ GetAxisLineXOrY(),
grid.context.y,
grid.context.height);
}
}
+
+ protected override float GetAxisLineXOrY()
+ {
+ var yAxis = component;
+ var grid = chart.GetChartComponent(yAxis.gridIndex);
+ var startX = grid.context.x + yAxis.offset;
+ if (yAxis.IsRight())
+ startX += grid.context.width;
+ else
+ startX += ComponentHelper.GetYAxisOnZeroOffset(chart.components, yAxis);
+ return startX;
+ }
}
}
\ No newline at end of file
diff --git a/Runtime/Component/Background/Background.cs b/Runtime/Component/Background/Background.cs
index 0e3a8425..5d963389 100644
--- a/Runtime/Component/Background/Background.cs
+++ b/Runtime/Component/Background/Background.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
using UnityEngine.UI;
diff --git a/Runtime/Component/Background/BackgroundHandler.cs b/Runtime/Component/Background/BackgroundHandler.cs
index cd6402f9..54e7ead1 100644
--- a/Runtime/Component/Background/BackgroundHandler.cs
+++ b/Runtime/Component/Background/BackgroundHandler.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
using UnityEngine.UI;
@@ -13,7 +12,7 @@ namespace XCharts.Runtime
public override void InitComponent()
{
component.painter = chart.painter;
- component.refreshComponent = delegate ()
+ component.refreshComponent = delegate()
{
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, chart.transform, chart.chartMinAnchor,
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
@@ -43,7 +42,7 @@ namespace XCharts.Runtime
var p3 = new Vector3(chart.chartX + chart.chartWidth, chart.chartY);
var p4 = new Vector3(chart.chartX, chart.chartY);
var backgroundColor = chart.theme.GetBackgroundColor(component);
-
+
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, backgroundColor);
}
}
diff --git a/Runtime/Component/Child/AreaStyle.cs b/Runtime/Component/Child/AreaStyle.cs
index e08eb5c7..0b4a45bc 100644
--- a/Runtime/Component/Child/AreaStyle.cs
+++ b/Runtime/Component/Child/AreaStyle.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
namespace XCharts.Runtime
@@ -33,11 +31,12 @@ namespace XCharts.Runtime
///
End
}
+
[SerializeField] private bool m_Show = true;
[SerializeField] private AreaOrigin m_Origin;
[SerializeField] private Color32 m_Color;
[SerializeField] private Color32 m_ToColor;
- [SerializeField] [Range(0, 1)] private float m_Opacity = 0.6f;
+ [SerializeField][Range(0, 1)] private float m_Opacity = 0.6f;
[SerializeField] private Color32 m_HighlightColor;
[SerializeField] private Color32 m_HighlightToColor;
@@ -111,7 +110,7 @@ namespace XCharts.Runtime
return m_Color;
var color = m_Color;
- color.a = (byte)(color.a * m_Opacity);
+ color.a = (byte) (color.a * m_Opacity);
return color;
}
@@ -124,7 +123,7 @@ namespace XCharts.Runtime
else
{
var color = themeColor;
- color.a = (byte)(color.a * opacity);
+ color.a = (byte) (color.a * opacity);
return color;
}
}
diff --git a/Runtime/Component/Child/ArrowStyle.cs b/Runtime/Component/Child/ArrowStyle.cs
index 794232d0..1b782339 100644
--- a/Runtime/Component/Child/ArrowStyle.cs
+++ b/Runtime/Component/Child/ArrowStyle.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
diff --git a/Runtime/Component/Child/BaseLine.cs b/Runtime/Component/Child/BaseLine.cs
index 4a0aa959..5472b77a 100644
--- a/Runtime/Component/Child/BaseLine.cs
+++ b/Runtime/Component/Child/BaseLine.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
diff --git a/Runtime/Component/Child/IconStyle.cs b/Runtime/Component/Child/IconStyle.cs
index 1a8206b8..17d847c0 100644
--- a/Runtime/Component/Child/IconStyle.cs
+++ b/Runtime/Component/Child/IconStyle.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
@@ -20,6 +19,7 @@ namespace XCharts.Runtime
///
AboveText
}
+
[SerializeField] private bool m_Show = false;
[SerializeField] private Layer m_Layer;
[SerializeField] private Align m_Align = Align.Left;
@@ -115,4 +115,4 @@ namespace XCharts.Runtime
autoHideWhenLabelEmpty = iconStyle.autoHideWhenLabelEmpty;
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Component/Child/ImageStyle.cs b/Runtime/Component/Child/ImageStyle.cs
index 6771b7fe..d37b3921 100644
--- a/Runtime/Component/Child/ImageStyle.cs
+++ b/Runtime/Component/Child/ImageStyle.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
@@ -79,4 +78,4 @@ namespace XCharts.Runtime
height = imageStyle.height;
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Component/Child/ItemStyle.cs b/Runtime/Component/Child/ItemStyle.cs
index 1ca767da..79e9403a 100644
--- a/Runtime/Component/Child/ItemStyle.cs
+++ b/Runtime/Component/Child/ItemStyle.cs
@@ -22,7 +22,7 @@ namespace XCharts.Runtime
[SerializeField] private Color32 m_BorderColor;
[SerializeField] private Color32 m_BorderColor0;
[SerializeField] private Color32 m_BorderToColor;
- [SerializeField] [Range(0, 1)] private float m_Opacity = 1;
+ [SerializeField][Range(0, 1)] private float m_Opacity = 1;
[SerializeField] private string m_ItemMarker;
[SerializeField] private string m_ItemFormatter;
[SerializeField] private string m_NumericFormatter = "";
@@ -237,7 +237,7 @@ namespace XCharts.Runtime
return m_Color;
var color = m_Color;
- color.a = (byte)(color.a * m_Opacity);
+ color.a = (byte) (color.a * m_Opacity);
return color;
}
@@ -247,7 +247,7 @@ namespace XCharts.Runtime
return m_ToColor;
var color = m_ToColor;
- color.a = (byte)(color.a * m_Opacity);
+ color.a = (byte) (color.a * m_Opacity);
return color;
}
@@ -257,7 +257,7 @@ namespace XCharts.Runtime
return m_Color0;
var color = m_Color0;
- color.a = (byte)(color.a * m_Opacity);
+ color.a = (byte) (color.a * m_Opacity);
return color;
}
@@ -268,7 +268,7 @@ namespace XCharts.Runtime
if (m_Opacity == 1 || color.a == 0)
return color;
- color.a = (byte)(color.a * m_Opacity);
+ color.a = (byte) (color.a * m_Opacity);
return color;
}
@@ -279,7 +279,7 @@ namespace XCharts.Runtime
if (m_Opacity == 1 || color.a == 0)
return color;
- color.a = (byte)(color.a * m_Opacity);
+ color.a = (byte) (color.a * m_Opacity);
return color;
}
@@ -290,7 +290,7 @@ namespace XCharts.Runtime
if (m_Opacity == 1 || color.a == 0)
return color;
- color.a = (byte)(color.a * m_Opacity);
+ color.a = (byte) (color.a * m_Opacity);
return color;
}
@@ -301,7 +301,7 @@ namespace XCharts.Runtime
if (m_Opacity == 1 || color.a == 0)
return color;
- color.a = (byte)(color.a * m_Opacity);
+ color.a = (byte) (color.a * m_Opacity);
return color;
}
@@ -332,7 +332,7 @@ namespace XCharts.Runtime
}
if (m_Opacity != 1)
{
- color.a = (byte)(color.a * m_Opacity);
+ color.a = (byte) (color.a * m_Opacity);
}
return color;
}
@@ -347,4 +347,4 @@ namespace XCharts.Runtime
return false;
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Component/Child/LineArrow.cs b/Runtime/Component/Child/LineArrow.cs
index b4284379..8b45aa84 100644
--- a/Runtime/Component/Child/LineArrow.cs
+++ b/Runtime/Component/Child/LineArrow.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -20,6 +19,7 @@ namespace XCharts.Runtime
///
Start
}
+
[SerializeField] private bool m_Show;
[SerializeField] private Position m_Position;
[SerializeField]
diff --git a/Runtime/Component/Child/LineStyle.cs b/Runtime/Component/Child/LineStyle.cs
index f71de9a6..8b1940d4 100644
--- a/Runtime/Component/Child/LineStyle.cs
+++ b/Runtime/Component/Child/LineStyle.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
namespace XCharts.Runtime
@@ -40,6 +38,7 @@ namespace XCharts.Runtime
DashDotDot,
None,
}
+
[SerializeField] private bool m_Show = true;
[SerializeField] private Type m_Type = Type.Solid;
[SerializeField] private Color32 m_Color;
@@ -47,7 +46,7 @@ namespace XCharts.Runtime
[SerializeField] private Color32 m_ToColor2;
[SerializeField] private float m_Width = 0;
[SerializeField] private float m_Length = 0;
- [SerializeField] [Range(0, 1)] private float m_Opacity = 1;
+ [SerializeField][Range(0, 1)] private float m_Opacity = 1;
///
/// Whether show line.
@@ -123,8 +122,7 @@ namespace XCharts.Runtime
}
public LineStyle()
- {
- }
+ { }
public LineStyle(float width)
{
@@ -172,7 +170,7 @@ namespace XCharts.Runtime
return m_Color;
var color = m_Color;
- color.a = (byte)(color.a * m_Opacity);
+ color.a = (byte) (color.a * m_Opacity);
return color;
}
@@ -203,7 +201,7 @@ namespace XCharts.Runtime
}
if (m_Opacity != 1)
{
- color.a = (byte)(color.a * m_Opacity);
+ color.a = (byte) (color.a * m_Opacity);
}
return color;
}
@@ -232,7 +230,7 @@ namespace XCharts.Runtime
else
{
var color = themeColor;
- color.a = (byte)(color.a * opacity);
+ color.a = (byte) (color.a * opacity);
return color;
}
}
diff --git a/Runtime/Component/Child/Location.cs b/Runtime/Component/Child/Location.cs
index f572c249..819e3560 100644
--- a/Runtime/Component/Child/Location.cs
+++ b/Runtime/Component/Child/Location.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
#if dUI_TextMeshPro
@@ -126,10 +125,10 @@ namespace XCharts.Runtime
return new Location()
{
align = Align.CenterLeft,
- left = 0.03f,
- right = 0,
- top = 0,
- bottom = 0
+ left = 0.03f,
+ right = 0,
+ top = 0,
+ bottom = 0
};
}
}
@@ -141,10 +140,10 @@ namespace XCharts.Runtime
return new Location()
{
align = Align.CenterRight,
- left = 0,
- right = 0.03f,
- top = 0,
- bottom = 0
+ left = 0,
+ right = 0.03f,
+ top = 0,
+ bottom = 0
};
}
}
@@ -156,10 +155,10 @@ namespace XCharts.Runtime
return new Location()
{
align = Align.TopCenter,
- left = 0,
- right = 0,
- top = 0.03f,
- bottom = 0
+ left = 0,
+ right = 0,
+ top = 0.03f,
+ bottom = 0
};
}
}
@@ -171,10 +170,10 @@ namespace XCharts.Runtime
return new Location()
{
align = Align.BottomCenter,
- left = 0,
- right = 0,
- top = 0,
- bottom = 0.03f
+ left = 0,
+ right = 0,
+ top = 0,
+ bottom = 0.03f
};
}
}
@@ -319,4 +318,4 @@ namespace XCharts.Runtime
UpdateAlign();
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Component/Child/SerieDataBaseInfo.cs b/Runtime/Component/Child/SerieDataBaseInfo.cs
deleted file mode 100644
index 9bf780a9..00000000
--- a/Runtime/Component/Child/SerieDataBaseInfo.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using UnityEngine;
-
-namespace XCharts.Runtime
-{
- ///
- /// 数据项的其他基础数据。
- ///
- [System.Serializable]
- public class SerieDataBaseInfo : ChildComponent, ISerieDataComponent
- {
- [SerializeField] private bool m_Ignore = false;
- [SerializeField] private bool m_Selected;
- [SerializeField] private float m_Radius;
-
- ///
- /// 是否忽略数据。当为 true 时,数据不进行绘制。
- ///
- public bool ignore
- {
- get { return m_Ignore; }
- set { if (PropertyUtil.SetStruct(ref m_Ignore, value)) SetVerticesDirty(); }
- }
- ///
- /// 自定义半径。可用在饼图中自定义某个数据项的半径。
- ///
- public float radius { get { return m_Radius; } set { m_Radius = value; } }
- ///
- /// Whether the data item is selected.
- /// |该数据项是否被选中。
- ///
- public bool selected { get { return m_Selected; } set { m_Selected = value; } }
- }
-}
\ No newline at end of file
diff --git a/Runtime/Component/Child/SerieSymbl.cs b/Runtime/Component/Child/SerieSymbl.cs
index 4062d684..34865a8d 100644
--- a/Runtime/Component/Child/SerieSymbl.cs
+++ b/Runtime/Component/Child/SerieSymbl.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -174,7 +173,7 @@ namespace XCharts.Runtime
case SymbolSizeType.FromData:
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
{
- return (float)data[dataIndex] * m_DataScale;
+ return (float) data[dataIndex] * m_DataScale;
}
else
{
@@ -183,7 +182,8 @@ namespace XCharts.Runtime
case SymbolSizeType.Function:
if (data != null && sizeFunction != null) return sizeFunction(data);
else return size == 0 ? themeSize : size;
- default: return size == 0 ? themeSize : size;
+ default:
+ return size == 0 ? themeSize : size;
}
}
@@ -204,7 +204,7 @@ namespace XCharts.Runtime
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
{
- return (float)data[dataIndex] * m_SelectedDataScale;
+ return (float) data[dataIndex] * m_SelectedDataScale;
}
else
{
@@ -218,7 +218,8 @@ namespace XCharts.Runtime
else
return selectedSize == 0 ? themeSelectedSize : selectedSize;
- default: return selectedSize == 0 ? themeSelectedSize : selectedSize;
+ default:
+ return selectedSize == 0 ? themeSelectedSize : selectedSize;
}
}
@@ -239,4 +240,4 @@ namespace XCharts.Runtime
return (dataIndex - startIndex) % (m_Interval + 1) == 0;
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Component/Child/StageColor.cs b/Runtime/Component/Child/StageColor.cs
index a4bb4617..592d9711 100644
--- a/Runtime/Component/Child/StageColor.cs
+++ b/Runtime/Component/Child/StageColor.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
diff --git a/Runtime/Component/Child/SymbolStyle.cs b/Runtime/Component/Child/SymbolStyle.cs
index c37d8815..496059e8 100644
--- a/Runtime/Component/Child/SymbolStyle.cs
+++ b/Runtime/Component/Child/SymbolStyle.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -179,11 +178,10 @@ namespace XCharts.Runtime
/// |带有涟漪特效动画的散点图的动画参数。
///
public List animationSize { get { return m_AnimationSize; } }
-
public Color32 GetColor(Color32 defaultColor)
{
return ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color;
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Component/Child/TextLimit.cs b/Runtime/Component/Child/TextLimit.cs
index 066f1f51..0d276237 100644
--- a/Runtime/Component/Child/TextLimit.cs
+++ b/Runtime/Component/Child/TextLimit.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
using UnityEngine.UI;
@@ -87,7 +86,6 @@ namespace XCharts.Runtime
m_RelatedTextWidth = labelWidth;
}
-
public string GetLimitContent(string content)
{
float checkWidth = m_MaxWidth > 0 ? m_MaxWidth : m_RelatedTextWidth;
@@ -123,9 +121,9 @@ namespace XCharts.Runtime
int middle = content.Length / 2;
int end = content.Length;
float checkWidth = m_MaxWidth > 0 ? m_MaxWidth : m_RelatedTextWidth;
-
+
float limit = checkWidth - m_Gap * 2 - suffixLen;
- if (limit < 0)
+ if (limit < 0)
return 0;
float len = 0;
diff --git a/Runtime/Component/Child/TextPadding.cs b/Runtime/Component/Child/TextPadding.cs
index 94dc7e52..27353586 100644
--- a/Runtime/Component/Child/TextPadding.cs
+++ b/Runtime/Component/Child/TextPadding.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -26,7 +25,7 @@ namespace XCharts.Runtime
public void SetPadding(float top, float right, float bottom, float left)
{
- m_Top = top; ;
+ m_Top = top;;
m_Right = right;
m_Bottom = bottom;
m_Left = left;
diff --git a/Runtime/Component/Child/TextStyle.cs b/Runtime/Component/Child/TextStyle.cs
index 5b83798b..9ea38a0b 100644
--- a/Runtime/Component/Child/TextStyle.cs
+++ b/Runtime/Component/Child/TextStyle.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
#if dUI_TextMeshPro
@@ -141,9 +140,7 @@ namespace XCharts.Runtime
}
#endif
- public TextStyle()
- {
- }
+ public TextStyle() { }
public TextStyle(int fontSize)
{
diff --git a/Examples/Runtime.meta b/Runtime/Component/Comment.meta
similarity index 77%
rename from Examples/Runtime.meta
rename to Runtime/Component/Comment.meta
index 0e44740f..27242bfd 100644
--- a/Examples/Runtime.meta
+++ b/Runtime/Component/Comment.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: f67670c9ee0e64262950aaf07562454e
+guid: 81fe767917cd3492a9f587f5d5e3a037
folderAsset: yes
DefaultImporter:
externalObjects: {}
diff --git a/Runtime/Component/Comment/Comment.cs b/Runtime/Component/Comment/Comment.cs
new file mode 100644
index 00000000..b2cb70a3
--- /dev/null
+++ b/Runtime/Component/Comment/Comment.cs
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace XCharts.Runtime
+{
+ ///
+ /// comment of chart.
+ /// |图表注解组件。
+ ///
+ [Serializable]
+ [ComponentHandler(typeof(CommentHander), true)]
+ public class Comment : MainComponent
+ {
+ [SerializeField] private bool m_Show = true;
+ [SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
+ [SerializeField] private CommentMarkStyle m_MarkStyle;
+ [SerializeField] private List m_Items = new List() { new CommentItem() };
+
+ ///
+ /// Set this to false to prevent the comment from showing.
+ /// |是否显示注解组件。
+ ///
+ public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
+ public List items { get { return m_Items; } set { m_Items = value; SetComponentDirty(); } }
+ ///
+ /// The text style of all comments.
+ /// |所有组件的文本样式。
+ ///
+ public LabelStyle labelStyle
+ {
+ get { return m_LabelStyle; }
+ set { if (PropertyUtil.SetClass(ref m_LabelStyle, value)) SetComponentDirty(); }
+ }
+ ///
+ /// The text style of all comments.
+ /// |所有组件的文本样式。
+ ///
+ public CommentMarkStyle markStyle
+ {
+ get { return m_MarkStyle; }
+ set { if (PropertyUtil.SetClass(ref m_MarkStyle, value)) SetVerticesDirty(); }
+ }
+
+ public LabelStyle GetLabelStyle(int index)
+ {
+ if (index >= 0 && index < items.Count)
+ {
+ var labelStyle = items[index].labelStyle;
+ if (labelStyle.show) return labelStyle;
+ }
+ return m_LabelStyle;
+ }
+
+ public CommentMarkStyle GetMarkStyle(int index)
+ {
+ if (index >= 0 && index < items.Count)
+ {
+ var markStyle = items[index].markStyle;
+ if (markStyle.show) return markStyle;
+ }
+ return m_MarkStyle;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Component/Comment/Comment.cs.meta b/Runtime/Component/Comment/Comment.cs.meta
new file mode 100644
index 00000000..3a9af591
--- /dev/null
+++ b/Runtime/Component/Comment/Comment.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ec99dd6b13a3b4e9789d007f23ffa499
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Component/Comment/CommentHander.cs b/Runtime/Component/Comment/CommentHander.cs
new file mode 100644
index 00000000..f1c93ab3
--- /dev/null
+++ b/Runtime/Component/Comment/CommentHander.cs
@@ -0,0 +1,71 @@
+using UnityEngine;
+using UnityEngine.UI;
+using XUGL;
+
+namespace XCharts.Runtime
+{
+ [UnityEngine.Scripting.Preserve]
+ internal sealed class CommentHander : MainComponentHandler
+ {
+ private static readonly string s_CommentObjectName = "comment";
+
+ public override void InitComponent()
+ {
+ var comment = component;
+ comment.painter = null;
+ comment.refreshComponent = delegate()
+ {
+ var objName = ChartCached.GetComponentObjectName(comment);
+ var commentObj = ChartHelper.AddObject(objName,
+ chart.transform,
+ chart.chartMinAnchor,
+ chart.chartMaxAnchor,
+ chart.chartPivot,
+ chart.chartSizeDelta);
+
+ commentObj.SetActive(comment.show);
+ 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);
+ 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);
+ label.SetPosition(item.position + labelStyle.offset);
+ }
+ };
+ comment.refreshComponent();
+ }
+
+ private string GetContent(CommentItem item)
+ {
+ if (item.content.IndexOf("{") >= 0)
+ {
+ var content = item.content;
+ FormatterHelper.ReplaceContent(ref content, 0, item.labelStyle.numericFormatter, null, chart);
+ return content;
+ }
+ else
+ {
+ return item.content;
+ }
+ }
+
+ public override void DrawTop(VertexHelper vh)
+ {
+ for (int i = 0; i < component.items.Count; i++)
+ {
+ var item = component.items[i];
+ var markStyle = component.GetMarkStyle(i);
+ if (!markStyle.show) continue;
+ var color = ChartHelper.IsClearColor(markStyle.lineStyle.color) ?
+ chart.theme.axis.splitLineColor :
+ markStyle.lineStyle.color;
+ var width = markStyle.lineStyle.width == 0 ? 1 : markStyle.lineStyle.width;
+ UGL.DrawBorder(vh, item.markRect, width, color);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Component/Comment/CommentHander.cs.meta b/Runtime/Component/Comment/CommentHander.cs.meta
new file mode 100644
index 00000000..a1e30c8a
--- /dev/null
+++ b/Runtime/Component/Comment/CommentHander.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 45362c4eed0e54d2880f2ed359ce9385
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Component/Comment/CommentItem.cs b/Runtime/Component/Comment/CommentItem.cs
new file mode 100644
index 00000000..766e780c
--- /dev/null
+++ b/Runtime/Component/Comment/CommentItem.cs
@@ -0,0 +1,47 @@
+using System;
+using UnityEngine;
+
+namespace XCharts.Runtime
+{
+ ///
+ /// comment of chart.
+ /// |注解项。
+ ///
+ [Serializable]
+ public class CommentItem : ChildComponent
+ {
+ [SerializeField] private bool m_Show = true;
+ [SerializeField] private string m_Content = "comment";
+ [SerializeField] private Vector3 m_Position;
+ [SerializeField] private Rect m_MarkRect;
+ [SerializeField] private CommentMarkStyle m_MarkStyle = new CommentMarkStyle() { show = false };
+ [SerializeField] private LabelStyle m_LabelStyle = new LabelStyle() { show = false };
+
+ ///
+ /// Set this to false to prevent this comment item from showing.
+ /// |是否显示当前注解项。
+ ///
+ public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
+ ///
+ /// position of comment.
+ /// |注解项的位置坐标。
+ ///
+ public Vector3 position { get { return m_Position; } set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetComponentDirty(); } }
+ ///
+ /// content of comment.
+ /// |注解的文本内容。
+ ///
+ public string content { get { return m_Content; } set { if (PropertyUtil.SetClass(ref m_Content, value)) SetComponentDirty(); } }
+ public Rect markRect { get { return m_MarkRect; } set { if (PropertyUtil.SetStruct(ref m_MarkRect, value)) SetVerticesDirty(); } }
+ public CommentMarkStyle markStyle { get { return m_MarkStyle; } set { if (PropertyUtil.SetClass(ref m_MarkStyle, value)) SetVerticesDirty(); } }
+ ///
+ /// The text style of all comments.
+ /// |注解项的文本样式。
+ ///
+ public LabelStyle labelStyle
+ {
+ get { return m_LabelStyle; }
+ set { if (PropertyUtil.SetClass(ref m_LabelStyle, value)) SetComponentDirty(); }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Component/Comment/CommentItem.cs.meta b/Runtime/Component/Comment/CommentItem.cs.meta
new file mode 100644
index 00000000..29b3cd2f
--- /dev/null
+++ b/Runtime/Component/Comment/CommentItem.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f082815b255e546019b6b43ac20bf4cb
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Component/Comment/CommentMarkStyle.cs b/Runtime/Component/Comment/CommentMarkStyle.cs
new file mode 100644
index 00000000..cc776aa2
--- /dev/null
+++ b/Runtime/Component/Comment/CommentMarkStyle.cs
@@ -0,0 +1,23 @@
+using System;
+using UnityEngine;
+
+namespace XCharts.Runtime
+{
+ ///
+ /// comment of chart.
+ /// |注解项。
+ ///
+ [Serializable]
+ public class CommentMarkStyle : ChildComponent
+ {
+ [SerializeField] private bool m_Show = true;
+ [SerializeField] private LineStyle m_LineStyle;
+
+ ///
+ /// Set this to false to prevent this comment item from showing.
+ /// |是否显示当前注解项。
+ ///
+ public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); } }
+ public LineStyle lineStyle { get { return m_LineStyle; } set { if (PropertyUtil.SetClass(ref m_LineStyle, value)) SetVerticesDirty(); } }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Component/Comment/CommentMarkStyle.cs.meta b/Runtime/Component/Comment/CommentMarkStyle.cs.meta
new file mode 100644
index 00000000..9e4c5ddb
--- /dev/null
+++ b/Runtime/Component/Comment/CommentMarkStyle.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 764734b787d72455782bf75bb38e465e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Component/DataZoom/DataZoom.cs b/Runtime/Component/DataZoom/DataZoom.cs
index da2399ec..d361cd5b 100644
--- a/Runtime/Component/DataZoom/DataZoom.cs
+++ b/Runtime/Component/DataZoom/DataZoom.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -57,6 +56,7 @@ namespace XCharts.Runtime
///
Percent
}
+
[SerializeField] private bool m_Enable = true;
[SerializeField] private FilterMode m_FilterMode;
[SerializeField] private List m_XAxisIndexs = new List() { 0 };
@@ -448,11 +448,11 @@ namespace XCharts.Runtime
start = context.y + context.height * m_Start / 100;
end = context.y + context.height * m_End / 100;
return ChartHelper.IsInRect(pos, context.x, context.x + context.width, start, end);
- default: return false;
+ default:
+ return false;
}
}
-
public bool IsInSelectedZoom(int totalIndex, int index, bool invert)
{
if (totalIndex <= 0)
@@ -486,7 +486,8 @@ namespace XCharts.Runtime
case Orient.Vertical:
start = context.y + context.height * m_Start / 100;
return ChartHelper.IsInRect(pos, context.x, context.x + context.width, start - 10, start + 10);
- default: return false;
+ default:
+ return false;
}
}
@@ -507,11 +508,11 @@ namespace XCharts.Runtime
case Orient.Vertical:
end = context.y + context.height * m_End / 100;
return ChartHelper.IsInRect(pos, context.x, context.x + context.width, end - 10, end + 10);
- default: return false;
+ default:
+ return false;
}
}
-
public bool IsContainsAxis(Axis axis)
{
if (axis == null)
diff --git a/Runtime/Component/DataZoom/DataZoomContext.cs b/Runtime/Component/DataZoom/DataZoomContext.cs
index 64a22627..49cf852c 100644
--- a/Runtime/Component/DataZoom/DataZoomContext.cs
+++ b/Runtime/Component/DataZoom/DataZoomContext.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
diff --git a/Runtime/Component/DataZoom/DataZoomHandler.cs b/Runtime/Component/DataZoom/DataZoomHandler.cs
index 0391233f..6fce8896 100644
--- a/Runtime/Component/DataZoom/DataZoomHandler.cs
+++ b/Runtime/Component/DataZoom/DataZoomHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
@@ -21,7 +20,7 @@ namespace XCharts.Runtime
{
var dataZoom = component;
dataZoom.painter = chart.m_PainterTop;
- dataZoom.refreshComponent = delegate ()
+ dataZoom.refreshComponent = delegate()
{
var dataZoomObject = ChartHelper.AddObject(s_DefaultDataZoom + dataZoom.index, chart.transform,
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
@@ -34,7 +33,7 @@ namespace XCharts.Runtime
startLabel.gameObject.SetActive(true);
var endLabel = ChartHelper.AddChartLabel(s_DefaultDataZoom + "end", dataZoomObject.transform,
- dataZoom.labelStyle, chart.theme.dataZoom, "", Color.clear, TextAnchor.MiddleLeft);
+ dataZoom.labelStyle, chart.theme.dataZoom, "", Color.clear, TextAnchor.MiddleLeft);
endLabel.gameObject.SetActive(true);
dataZoom.SetStartLabel(startLabel);
@@ -158,8 +157,8 @@ namespace XCharts.Runtime
return;
var dataZoom = component;
- if (dataZoom.context.isDrag || dataZoom.context.isStartDrag || dataZoom.context.isEndDrag
- || dataZoom.context.isCoordinateDrag)
+ if (dataZoom.context.isDrag || dataZoom.context.isStartDrag || dataZoom.context.isEndDrag ||
+ dataZoom.context.isCoordinateDrag)
{
chart.RefreshChart();
}
@@ -187,8 +186,8 @@ namespace XCharts.Runtime
return;
}
- if (dataZoom.IsInZoom(localPos)
- && !dataZoom.IsInSelectedZoom(localPos))
+ if (dataZoom.IsInZoom(localPos) &&
+ !dataZoom.IsInSelectedZoom(localPos))
{
var pointerX = localPos.x;
var selectWidth = grid.context.width * (dataZoom.end - dataZoom.start) / 100;
@@ -313,8 +312,8 @@ namespace XCharts.Runtime
{
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);
+ Mathf.Abs(delta / grid.context.width * 100) :
+ Mathf.Abs(delta / grid.context.height * 100);
if (delta > 0)
{
if (dataZoom.end <= dataZoom.start)
@@ -390,9 +389,9 @@ namespace XCharts.Runtime
dataZoom.SetLabelActive(false);
return;
}
- if (dataZoom.IsInSelectedZoom(local)
- || dataZoom.IsInStartZoom(local)
- || dataZoom.IsInEndZoom(local))
+ if (dataZoom.IsInSelectedZoom(local) ||
+ dataZoom.IsInStartZoom(local) ||
+ dataZoom.IsInEndZoom(local))
{
dataZoom.SetLabelActive(true);
RefreshDataZoomLabel();
@@ -406,8 +405,8 @@ namespace XCharts.Runtime
{
m_CheckDataZoomLabel = false;
var xAxis = chart.GetChartComponent(dataZoom.xAxisIndexs[0]);
- var startIndex = (int)((xAxis.data.Count - 1) * dataZoom.start / 100);
- var endIndex = (int)((xAxis.data.Count - 1) * dataZoom.end / 100);
+ var startIndex = (int) ((xAxis.data.Count - 1) * dataZoom.start / 100);
+ var endIndex = (int) ((xAxis.data.Count - 1) * dataZoom.end / 100);
if (m_DataZoomLastStartIndex != startIndex || m_DataZoomLastEndIndex != endIndex)
{
@@ -472,7 +471,7 @@ namespace XCharts.Runtime
var sampleDist = serie.sampleDist < 2 ? 2 : serie.sampleDist;
var maxCount = showData.Count;
if (sampleDist > 0)
- rate = (int)((maxCount - serie.minShow) / (dataZoom.context.width / sampleDist));
+ rate = (int) ((maxCount - serie.minShow) / (dataZoom.context.width / sampleDist));
if (rate < 1)
rate = 1;
@@ -485,7 +484,7 @@ namespace XCharts.Runtime
double value = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
serie.animation.GetUpdateAnimationDuration(), ref dataChanging, axis);
float pX = dataZoom.context.x + i * scaleWid;
- float dataHig = (float)((maxValue - minValue) == 0 ? 0 :
+ float dataHig = (float) ((maxValue - minValue) == 0 ? 0 :
(value - minValue) / (maxValue - minValue) * dataZoom.context.height);
np = new Vector3(pX, chart.chartY + dataZoom.bottom + dataHig);
if (i > 0)
@@ -561,7 +560,7 @@ namespace XCharts.Runtime
var sampleDist = serie.sampleDist < 2 ? 2 : serie.sampleDist;
var maxCount = showData.Count;
if (sampleDist > 0)
- rate = (int)((maxCount - serie.minShow) / (dataZoom.context.height / sampleDist));
+ rate = (int) ((maxCount - serie.minShow) / (dataZoom.context.height / sampleDist));
if (rate < 1)
rate = 1;
@@ -575,7 +574,7 @@ namespace XCharts.Runtime
serie.animation.GetUpdateAnimationDuration(), ref dataChanging, axis);
float pY = dataZoom.context.y + i * scaleWid;
float dataHig = (maxValue - minValue) == 0 ? 0 :
- (float)((value - minValue) / (maxValue - minValue) * dataZoom.context.width);
+ (float) ((value - minValue) / (maxValue - minValue) * dataZoom.context.width);
np = new Vector3(chart.chartX + chart.chartWidth - dataZoom.right - dataHig, pY);
if (i > 0)
{
diff --git a/Runtime/Component/DataZoom/DataZoomHelper.cs b/Runtime/Component/DataZoom/DataZoomHelper.cs
index ae749865..c7f8b813 100644
--- a/Runtime/Component/DataZoom/DataZoomHelper.cs
+++ b/Runtime/Component/DataZoom/DataZoomHelper.cs
@@ -1,4 +1,3 @@
-
namespace XCharts.Runtime
{
public static class DataZoomHelper
diff --git a/Runtime/Component/Debug/DebugInfo.cs b/Runtime/Component/Debug/DebugInfo.cs
index 8b4c1fea..5daca29c 100644
--- a/Runtime/Component/Debug/DebugInfo.cs
+++ b/Runtime/Component/Debug/DebugInfo.cs
@@ -1,8 +1,7 @@
-
-using UnityEngine;
using System;
using System.Collections.Generic;
using System.Text;
+using UnityEngine;
namespace XCharts.Runtime
{
@@ -20,12 +19,12 @@ namespace XCharts.Runtime
{
background = new ImageStyle()
{
- color = new Color32(32, 32, 32, 170)
+ color = new Color32(32, 32, 32, 170)
},
textStyle = new TextStyle()
{
- fontSize = 18,
- color = Color.white
+ fontSize = 18,
+ color = Color.white
}
};
@@ -56,7 +55,7 @@ namespace XCharts.Runtime
public void Update()
{
- if (clickChartCount >= 2)
+ if (clickChartCount > 2)
{
m_ShowDebugInfo = !m_ShowDebugInfo;
ChartHelper.SetActive(m_Label.transform, m_ShowDebugInfo);
@@ -108,6 +107,13 @@ namespace XCharts.Runtime
SetValueWithKInfo(s_Sb, "s-vert", vertCount);
SetValueWithKInfo(s_Sb, "t-vert", m_Chart.m_TopPainterVertCount, false);
+ var serie0 = m_Chart.GetSerie(0);
+ for (int i = 0; i < serie0.dataCount; i++)
+ {
+ var serieData = serie0.data[i];
+ s_Sb.AppendFormat("{0}:{1}\n", i, serieData.interact.targetVaue);
+ }
+
m_Label.SetText(s_Sb.ToString());
}
}
@@ -144,7 +150,7 @@ namespace XCharts.Runtime
ChartHelper.SetActive(labelGameObject, m_ShowDebugInfo);
var label = ChartHelper.AddChartLabel("info", labelGameObject.transform, labelStyle, theme.common,
- "", Color.clear, TextAnchor.UpperLeft);
+ "", Color.clear, TextAnchor.UpperLeft);
label.SetActive(labelStyle.show);
return label;
}
diff --git a/Runtime/Component/Emphasis.meta b/Runtime/Component/Emphasis.meta
new file mode 100644
index 00000000..68dbdad5
--- /dev/null
+++ b/Runtime/Component/Emphasis.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 4cd4074bb11fc40059363dd78b9ee98d
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Component/Child/Emphasis.cs b/Runtime/Component/Emphasis/Emphasis.cs
similarity index 99%
rename from Runtime/Component/Child/Emphasis.cs
rename to Runtime/Component/Emphasis/Emphasis.cs
index 310ec316..00197fa7 100644
--- a/Runtime/Component/Child/Emphasis.cs
+++ b/Runtime/Component/Emphasis/Emphasis.cs
@@ -1,5 +1,3 @@
-
-
using UnityEngine;
namespace XCharts.Runtime
diff --git a/Runtime/Component/Child/Emphasis.cs.meta b/Runtime/Component/Emphasis/Emphasis.cs.meta
similarity index 100%
rename from Runtime/Component/Child/Emphasis.cs.meta
rename to Runtime/Component/Emphasis/Emphasis.cs.meta
diff --git a/Runtime/Component/Emphasis/EmphasisItemStyle.cs b/Runtime/Component/Emphasis/EmphasisItemStyle.cs
new file mode 100644
index 00000000..ca5ad8e4
--- /dev/null
+++ b/Runtime/Component/Emphasis/EmphasisItemStyle.cs
@@ -0,0 +1,11 @@
+using UnityEngine;
+
+namespace XCharts.Runtime
+{
+ ///
+ /// 高亮的图形样式
+ ///
+ [System.Serializable]
+ public class EmphasisItemStyle : ItemStyle, ISerieExtraComponent, ISerieDataComponent
+ { }
+}
\ No newline at end of file
diff --git a/Runtime/Component/Emphasis/EmphasisItemStyle.cs.meta b/Runtime/Component/Emphasis/EmphasisItemStyle.cs.meta
new file mode 100644
index 00000000..73b33639
--- /dev/null
+++ b/Runtime/Component/Emphasis/EmphasisItemStyle.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 5d1095175540449f99bb9da27a5aaf04
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Component/Emphasis/EmphasisLabelLine.cs b/Runtime/Component/Emphasis/EmphasisLabelLine.cs
new file mode 100644
index 00000000..9a132ad9
--- /dev/null
+++ b/Runtime/Component/Emphasis/EmphasisLabelLine.cs
@@ -0,0 +1,11 @@
+using UnityEngine;
+
+namespace XCharts.Runtime
+{
+ ///
+ /// 高亮的标签引导线样式
+ ///
+ [System.Serializable]
+ public class EmphasisLabelLine : LabelLine, ISerieExtraComponent, ISerieDataComponent
+ { }
+}
\ No newline at end of file
diff --git a/Runtime/Component/Emphasis/EmphasisLabelLine.cs.meta b/Runtime/Component/Emphasis/EmphasisLabelLine.cs.meta
new file mode 100644
index 00000000..b6bd83fa
--- /dev/null
+++ b/Runtime/Component/Emphasis/EmphasisLabelLine.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a0d9ff3b8e09d464e9b5ea996b941314
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Component/Emphasis/EmphasisLabelStyle.cs b/Runtime/Component/Emphasis/EmphasisLabelStyle.cs
new file mode 100644
index 00000000..0279fc6c
--- /dev/null
+++ b/Runtime/Component/Emphasis/EmphasisLabelStyle.cs
@@ -0,0 +1,11 @@
+using UnityEngine;
+
+namespace XCharts.Runtime
+{
+ ///
+ /// 高亮的标签样式
+ ///
+ [System.Serializable]
+ public class EmphasisLabelStyle : LabelStyle, ISerieExtraComponent, ISerieDataComponent
+ { }
+}
\ No newline at end of file
diff --git a/Runtime/Component/Emphasis/EmphasisLabelStyle.cs.meta b/Runtime/Component/Emphasis/EmphasisLabelStyle.cs.meta
new file mode 100644
index 00000000..77199ddc
--- /dev/null
+++ b/Runtime/Component/Emphasis/EmphasisLabelStyle.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 3e025b0f4be6d4141aa08bdad0102aa7
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Component/Interaction.meta b/Runtime/Component/Interaction.meta
new file mode 100644
index 00000000..9dd74cb6
--- /dev/null
+++ b/Runtime/Component/Interaction.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 8445ec442e5314aa891cbbd6d4d966c4
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Serie/InteractData.cs b/Runtime/Component/Interaction/InteractData.cs
similarity index 95%
rename from Runtime/Serie/InteractData.cs
rename to Runtime/Component/Interaction/InteractData.cs
index c61bd060..fd9122cb 100644
--- a/Runtime/Serie/InteractData.cs
+++ b/Runtime/Component/Interaction/InteractData.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -15,6 +14,8 @@ namespace XCharts.Runtime
private bool m_UpdateFlag = false;
private bool m_ValueEnable = false;
+ internal float targetVaue { get { return m_TargetValue; } }
+
public void SetValue(ref bool needInteract, float size, bool highlight, float rate = 1.3f)
{
size = highlight ? size * rate : size;
@@ -25,14 +26,11 @@ namespace XCharts.Runtime
{
if (m_TargetValue != size)
{
- if (float.IsNaN(m_TargetValue))
- {
- needInteract = true;
- m_UpdateFlag = true;
- m_ValueEnable = true;
- m_UpdateTime = Time.time;
- m_PreviousValue = m_TargetValue;
- }
+ needInteract = true;
+ m_UpdateFlag = true;
+ m_ValueEnable = true;
+ m_UpdateTime = Time.time;
+ m_PreviousValue = m_TargetValue;
m_TargetValue = size;
}
}
diff --git a/Runtime/Serie/InteractData.cs.meta b/Runtime/Component/Interaction/InteractData.cs.meta
similarity index 83%
rename from Runtime/Serie/InteractData.cs.meta
rename to Runtime/Component/Interaction/InteractData.cs.meta
index 86930fc1..4e095073 100644
--- a/Runtime/Serie/InteractData.cs.meta
+++ b/Runtime/Component/Interaction/InteractData.cs.meta
@@ -1,5 +1,5 @@
fileFormatVersion: 2
-guid: 8ab01b44ab2454ef7ac2d71313c3d707
+guid: 42f150814cce84d66b931eed0a07d4ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
diff --git a/Runtime/Component/Label.meta b/Runtime/Component/Label.meta
new file mode 100644
index 00000000..401c6280
--- /dev/null
+++ b/Runtime/Component/Label.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: ad378dd158b5d438a87405d35a3a6546
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Component/Child/EndLabelStyle.cs b/Runtime/Component/Label/EndLabelStyle.cs
similarity index 99%
rename from Runtime/Component/Child/EndLabelStyle.cs
rename to Runtime/Component/Label/EndLabelStyle.cs
index 2f22c1b5..ecdd7e9a 100644
--- a/Runtime/Component/Child/EndLabelStyle.cs
+++ b/Runtime/Component/Label/EndLabelStyle.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
diff --git a/Runtime/Component/Child/EndLabelStyle.cs.meta b/Runtime/Component/Label/EndLabelStyle.cs.meta
similarity index 100%
rename from Runtime/Component/Child/EndLabelStyle.cs.meta
rename to Runtime/Component/Label/EndLabelStyle.cs.meta
diff --git a/Runtime/Component/Child/LabelLine.cs b/Runtime/Component/Label/LabelLine.cs
similarity index 99%
rename from Runtime/Component/Child/LabelLine.cs
rename to Runtime/Component/Label/LabelLine.cs
index 13ebe802..a0b1c2c6 100644
--- a/Runtime/Component/Child/LabelLine.cs
+++ b/Runtime/Component/Label/LabelLine.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -143,4 +142,4 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetClass(ref m_EndSymbol, value)) SetVerticesDirty(); }
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Component/Child/LabelLine.cs.meta b/Runtime/Component/Label/LabelLine.cs.meta
similarity index 100%
rename from Runtime/Component/Child/LabelLine.cs.meta
rename to Runtime/Component/Label/LabelLine.cs.meta
diff --git a/Runtime/Component/Child/LabelStyle.cs b/Runtime/Component/Label/LabelStyle.cs
similarity index 95%
rename from Runtime/Component/Child/LabelStyle.cs
rename to Runtime/Component/Label/LabelStyle.cs
index f204c198..4d96a029 100644
--- a/Runtime/Component/Child/LabelStyle.cs
+++ b/Runtime/Component/Label/LabelStyle.cs
@@ -1,4 +1,4 @@
-using UnityEngine;
+using UnityEngine;
namespace XCharts.Runtime
{
@@ -117,18 +117,19 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
}
///
- /// 标签内容字符串模版格式器。支持用 \n 换行。
+ /// formatter of label.
+ /// |标签内容字符串模版格式器。支持用 \n 换行。
/// 模板变量有:
- ///
- /// - {a}:系列名。
- /// - {b}:数据名。
- /// - {c}:数据值。
- /// - {d}:百分比。
- ///
- ///
- ///
+ /// {.}:圆点标记。
+ /// {a}:系列名。
+ /// {a}:系列名。
+ /// {b}:类目值或数据名。
+ /// {c}:数据值。
+ /// {d}:百分比。
+ /// {e}:数据名。
+ /// {f}:数据和。
/// 示例:“{b}:{c}”
- ///
+ ///
public string formatter
{
get { return m_Formatter; }
@@ -315,4 +316,4 @@ namespace XCharts.Runtime
m_TextStyle.Copy(label.m_TextStyle);
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Component/Child/LabelStyle.cs.meta b/Runtime/Component/Label/LabelStyle.cs.meta
similarity index 100%
rename from Runtime/Component/Child/LabelStyle.cs.meta
rename to Runtime/Component/Label/LabelStyle.cs.meta
diff --git a/Runtime/Component/Legend/Legend.cs b/Runtime/Component/Legend/Legend.cs
index f9842e1b..c2ff2c67 100644
--- a/Runtime/Component/Legend/Legend.cs
+++ b/Runtime/Component/Legend/Legend.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -63,7 +62,8 @@ namespace XCharts.Runtime
/// 无法选择。
///
None
- };
+ }
+
[SerializeField] private bool m_Show = true;
[SerializeField] private Type m_IconType = Type.Auto;
[SerializeField] private SelectedMode m_SelectedMode = SelectedMode.Multiple;
@@ -73,11 +73,13 @@ namespace XCharts.Runtime
[SerializeField] private float m_ItemHeight = 12.0f;
[SerializeField] private float m_ItemGap = 10f;
[SerializeField] private bool m_ItemAutoColor = true;
- [SerializeField] private bool m_TextAutoColor = false;
+ [SerializeField] private float m_ItemOpacity = 1;
[SerializeField] private string m_Formatter;
+ [SerializeField] protected string m_NumericFormatter = "";
[SerializeField] private LabelStyle m_LabelStyle = new LabelStyle();
[SerializeField] private List m_Data = new List();
[SerializeField] private List m_Icons = new List();
+ [SerializeField] private List m_Colors = new List();
public LegendContext context = new LegendContext();
@@ -171,19 +173,30 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
}
///
- /// Whether the legend text matches the color automatically.
- /// |图例标记的文本是否自动匹配颜色。
- /// [default:false]
+ /// the opacity of item color.
+ /// |图例标记的图形的颜色透明度。
///
- public bool textAutoColor
+ public float itemOpacity
{
- get { return m_TextAutoColor; }
- set { if (PropertyUtil.SetStruct(ref m_TextAutoColor, value)) SetComponentDirty(); }
+ get { return m_ItemOpacity; }
+ set { if (PropertyUtil.SetStruct(ref m_ItemOpacity, value)) SetComponentDirty(); }
}
///
- /// Legend content string template formatter. Support for wrapping lines with \n. Template:{name}.
+ /// Standard numeric format strings.
+ /// |标准数字格式字符串。用于将数值格式化显示为字符串。
+ /// 使用Axx的形式:A是格式说明符的单字符,支持C货币、D十进制、E指数、F定点数、G常规、N数字、P百分比、R往返、X十六进制的。xx是精度说明,从0-99。
+ /// 参考:https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings
+ ///
+ ///
+ public string numericFormatter
+ {
+ get { return m_NumericFormatter; }
+ set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
+ }
+ ///
+ /// Legend content string template formatter. Support for wrapping lines with \n. Template:{value}.
/// |图例内容字符串模版格式器。支持用 \n 换行。
- /// 模板变量为图例名称 {name}。
+ /// 模板变量为图例名称 {value}。
/// [default:null]
///
public string formatter
@@ -220,6 +233,11 @@ namespace XCharts.Runtime
get { return m_Icons; }
set { if (value != null) { m_Icons = value; SetComponentDirty(); } }
}
+ public List colors
+ {
+ get { return m_Colors; }
+ set { if (value != null) { m_Colors = value; SetAllDirty(); } }
+ }
///
/// 图表是否需要刷新(图例组件不需要刷新图表)
///
@@ -384,6 +402,14 @@ namespace XCharts.Runtime
}
}
+ public Color GetColor(int index)
+ {
+ if (index >= 0 && index < m_Colors.Count)
+ return m_Colors[index];
+ else
+ return Color.white;
+ }
+
///
/// Callback handling when parameters change.
/// |参数变更时的回调处理。
@@ -392,23 +418,5 @@ namespace XCharts.Runtime
{
m_Location.OnChanged();
}
-
- ///
- /// 获得图例格式化后的显示内容。
- ///
- ///
- ///
- public string GetFormatterContent(string category)
- {
- if (string.IsNullOrEmpty(m_Formatter))
- return category;
- else
- {
- var content = m_Formatter.Replace("{name}", category);
- content = content.Replace("\\n", "\n");
- content = content.Replace("
", "\n");
- return content;
- }
- }
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Component/Legend/LegendContext.cs b/Runtime/Component/Legend/LegendContext.cs
index 463403f7..9bead405 100644
--- a/Runtime/Component/Legend/LegendContext.cs
+++ b/Runtime/Component/Legend/LegendContext.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
diff --git a/Runtime/Component/Legend/LegendHandler.cs b/Runtime/Component/Legend/LegendHandler.cs
index b2852b51..58d2be40 100644
--- a/Runtime/Component/Legend/LegendHandler.cs
+++ b/Runtime/Component/Legend/LegendHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@@ -40,14 +39,20 @@ namespace XCharts.Runtime
DrawLegend(vh);
}
+ public override void OnSerieDataUpdate(int serieIndex)
+ {
+ if (FormatterHelper.NeedFormat(component.formatter))
+ component.refreshComponent();
+ }
+
private void InitLegend(Legend legend)
{
legend.painter = null;
- legend.refreshComponent = delegate ()
+ legend.refreshComponent = delegate()
{
legend.OnChanged();
var legendObject = ChartHelper.AddObject(s_LegendObjectName + legend.index, chart.transform, chart.chartMinAnchor,
- chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
+ chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
legend.gameObject = legendObject;
legendObject.hideFlags = chart.chartHideFlags;
SeriesHelper.UpdateSerieNameList(chart, ref chart.m_LegendRealShowName);
@@ -77,10 +82,11 @@ namespace XCharts.Runtime
for (int i = 0; i < datas.Count; i++)
{
if (!SeriesHelper.IsLegalLegendName(datas[i])) continue;
- string legendName = legend.GetFormatterContent(datas[i]);
+ string legendName = GetFormatterContent(legend, i, datas[i]);
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;
var item = LegendHelper.AddLegendItem(legend, i, datas[i], legendObject.transform, chart.theme,
legendName, bgColor, active, readIndex);
legend.SetButton(legendName, item, totalLegend);
@@ -136,6 +142,20 @@ namespace XCharts.Runtime
legend.refreshComponent();
}
+ private string GetFormatterContent(Legend legend, int dataIndex, string category)
+ {
+ if (string.IsNullOrEmpty(legend.formatter))
+ return category;
+ else
+ {
+ var content = legend.formatter.Replace("{name}", category);
+ content = content.Replace("{value}", category);
+ var serie = chart.GetSerie(0);
+ FormatterHelper.ReplaceContent(ref content, dataIndex, legend.numericFormatter, serie, chart);
+ return content;
+ }
+ }
+
private void OnLegendButtonClick(Legend legend, int index, string legendName, bool show)
{
chart.OnLegendButtonClick(index, legendName, show);
diff --git a/Runtime/Component/Legend/LegendHelper.cs b/Runtime/Component/Legend/LegendHelper.cs
index 297f56a1..ed580317 100644
--- a/Runtime/Component/Legend/LegendHelper.cs
+++ b/Runtime/Component/Legend/LegendHelper.cs
@@ -11,7 +11,7 @@ namespace XCharts.Runtime
var textStyle = legend.labelStyle.textStyle;
if (active)
{
- if (legend.textAutoColor) return theme.GetColor(legendIndex);
+ if (legend.labelStyle.textStyle.autoColor) return theme.GetColor(legendIndex);
else return !ChartHelper.IsClearColor(textStyle.color) ? textStyle.color : theme.legend.textColor;
}
else return theme.legend.unableColor;
@@ -21,12 +21,12 @@ namespace XCharts.Runtime
{
if (active)
{
- if (legend.itemAutoColor || legend.GetIcon(readIndex) == null)
+ if (legend.itemAutoColor)
{
return SeriesHelper.GetNameColor(chart, readIndex, legendName);
}
else
- return Color.white;
+ return legend.GetColor(readIndex);
}
else return chart.theme.legend.unableColor;
}
@@ -54,7 +54,7 @@ namespace XCharts.Runtime
ChartHelper.GetOrAddComponent(iconObj);
var label = ChartHelper.AddChartLabel("content", btnObj.transform, legend.labelStyle, theme.legend,
- content, contentColor, TextAnchor.MiddleLeft);
+ content, contentColor, TextAnchor.MiddleLeft);
label.SetActive(true);
var item = new LegendItem();
diff --git a/Runtime/Component/Mark/MarkArea.cs b/Runtime/Component/Mark/MarkArea.cs
index b10c3d4b..47ea3447 100644
--- a/Runtime/Component/Mark/MarkArea.cs
+++ b/Runtime/Component/Mark/MarkArea.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
diff --git a/Runtime/Component/Mark/MarkAreaHandler.cs b/Runtime/Component/Mark/MarkAreaHandler.cs
index c0f90ffb..9e1345b5 100644
--- a/Runtime/Component/Mark/MarkAreaHandler.cs
+++ b/Runtime/Component/Mark/MarkAreaHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -41,7 +40,7 @@ namespace XCharts.Runtime
private void InitMarkArea(MarkArea markArea)
{
markArea.painter = chart.m_PainterTop;
- 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);
diff --git a/Runtime/Component/Mark/MarkLine.cs b/Runtime/Component/Mark/MarkLine.cs
index bb610270..9b709ef2 100644
--- a/Runtime/Component/Mark/MarkLine.cs
+++ b/Runtime/Component/Mark/MarkLine.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -28,7 +27,6 @@ namespace XCharts.Runtime
Median
}
-
///
/// Use a line in the chart to illustrate.
/// |图表标线。
@@ -86,11 +84,13 @@ namespace XCharts.Runtime
item.name = "average";
item.type = MarkLineType.Average;
item.lineStyle.type = LineStyle.Type.Dashed;
- item.lineStyle.color = Color.blue;
+ item.lineStyle.color = Color.clear;
item.startSymbol.show = true;
item.startSymbol.type = SymbolType.Circle;
+ item.startSymbol.size = 4;
item.endSymbol.show = true;
item.endSymbol.type = SymbolType.Arrow;
+ item.endSymbol.size = 5;
item.label.show = true;
item.label.numericFormatter = "f1";
item.label.formatter = "{c}";
diff --git a/Runtime/Component/Mark/MarkLineHandler.cs b/Runtime/Component/Mark/MarkLineHandler.cs
index b646d985..e0471fb4 100644
--- a/Runtime/Component/Mark/MarkLineHandler.cs
+++ b/Runtime/Component/Mark/MarkLineHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -36,6 +35,7 @@ namespace XCharts.Runtime
{
if (data.runtimeLabel != null)
{
+ data.runtimeLabel.SetActive(data.label.show);
data.runtimeLabel.SetPosition(MarkLineHelper.GetLabelPosition(data));
data.runtimeLabel.SetText(MarkLineHelper.GetFormatterContent(serie, data));
}
@@ -70,13 +70,12 @@ namespace XCharts.Runtime
private void InitMarkLineLabel(Serie serie, MarkLineData data, Color serieColor)
{
data.painter = chart.m_PainterTop;
- data.refreshComponent = delegate ()
+ data.refreshComponent = delegate()
{
var textName = string.Format("markLine_{0}_{1}", serie.index, data.index);
var content = MarkLineHelper.GetFormatterContent(serie, data);
var label = ChartHelper.AddChartLabel(textName, m_MarkLineLabelRoot.transform, data.label, chart.theme.axis,
content, Color.clear, TextAnchor.MiddleCenter);
- label.SetActive(data.label.show);
label.SetIconActive(false);
label.SetActive(data.label.show);
@@ -203,7 +202,8 @@ namespace XCharts.Runtime
for (int i = 0; i < markLine.data.Count; i++)
{
var data = markLine.data[i];
- data.index = i;
+ // data.index = i;
+ data.index = markLine.index;
if (data.group == 0) continue;
if (!m_TempGroupData.ContainsKey(data.group))
{
diff --git a/Runtime/Component/Mark/MarkLineHelper.cs b/Runtime/Component/Mark/MarkLineHelper.cs
index dd6127ad..98511fa1 100644
--- a/Runtime/Component/Mark/MarkLineHelper.cs
+++ b/Runtime/Component/Mark/MarkLineHelper.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -18,7 +17,7 @@ namespace XCharts.Runtime
else
{
var content = serieLabel.formatter;
- FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, data.runtimeValue,
+ FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, data.runtimeValue,
0, serie.serieName, data.name, data.name, Color.clear);
return content;
}
diff --git a/Runtime/Component/Radar/RadarCoord.cs b/Runtime/Component/Radar/RadarCoord.cs
index 622992cd..8a2c6bb9 100644
--- a/Runtime/Component/Radar/RadarCoord.cs
+++ b/Runtime/Component/Radar/RadarCoord.cs
@@ -1,6 +1,5 @@
-
-using UnityEngine;
using System.Collections.Generic;
+using UnityEngine;
using UnityEngine.UI;
namespace XCharts.Runtime
@@ -91,6 +90,7 @@ namespace XCharts.Runtime
return true;
}
}
+
[SerializeField] private bool m_Show;
[SerializeField] private Shape m_Shape;
[SerializeField] private float m_Radius = 100;
@@ -281,12 +281,13 @@ namespace XCharts.Runtime
m_Radius = 0.35f;
m_SplitNumber = 5;
m_Indicator = true;
- m_IndicatorList = new List(5){
- new Indicator(){name="indicator1",max = 0},
- new Indicator(){name="indicator2",max = 0},
- new Indicator(){name="indicator3",max = 0},
- new Indicator(){name="indicator4",max = 0},
- new Indicator(){name="indicator5",max = 0},
+ m_IndicatorList = new List(5)
+ {
+ new Indicator() { name = "indicator1", max = 0 },
+ new Indicator() { name = "indicator2", max = 0 },
+ new Indicator() { name = "indicator3", max = 0 },
+ new Indicator() { name = "indicator4", max = 0 },
+ new Indicator() { name = "indicator5", max = 0 },
};
center[0] = 0.5f;
center[1] = 0.4f;
diff --git a/Runtime/Component/Radar/RadarCoordContext.cs b/Runtime/Component/Radar/RadarCoordContext.cs
index 79093e4b..dc45f606 100644
--- a/Runtime/Component/Radar/RadarCoordContext.cs
+++ b/Runtime/Component/Radar/RadarCoordContext.cs
@@ -1,6 +1,5 @@
-
-using UnityEngine;
using System.Collections.Generic;
+using UnityEngine;
using UnityEngine.UI;
namespace XCharts.Runtime
diff --git a/Runtime/Component/Radar/RadarCoordHandler.cs b/Runtime/Component/Radar/RadarCoordHandler.cs
index bb761676..4c72ccb8 100644
--- a/Runtime/Component/Radar/RadarCoordHandler.cs
+++ b/Runtime/Component/Radar/RadarCoordHandler.cs
@@ -1,6 +1,5 @@
-
-using UnityEngine;
using System.Collections.Generic;
+using UnityEngine;
using UnityEngine.UI;
using XUGL;
@@ -24,8 +23,8 @@ namespace XCharts.Runtime
return;
}
var radar = component;
- radar.context.isPointerEnter = radar.show
- && Vector3.Distance(radar.context.center, chart.pointerPos) <= radar.context.radius;
+ radar.context.isPointerEnter = radar.show &&
+ Vector3.Distance(radar.context.center, chart.pointerPos) <= radar.context.radius;
}
public override void DrawBase(VertexHelper vh)
@@ -37,11 +36,11 @@ namespace XCharts.Runtime
{
float txtHig = 20;
radar.painter = chart.GetPainter(radar.index);
- radar.refreshComponent = delegate ()
+ radar.refreshComponent = delegate()
{
radar.UpdateRadarCenter(chart.chartPosition, chart.chartWidth, chart.chartHeight);
var radarObject = ChartHelper.AddObject("Radar" + radar.index, chart.transform, chart.chartMinAnchor,
- chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
+ chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
radar.gameObject = radarObject;
radar.gameObject.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(radarObject.transform, INDICATOR_TEXT);
@@ -52,7 +51,7 @@ namespace XCharts.Runtime
var objName = INDICATOR_TEXT + "_" + i;
var label = ChartHelper.AddChartLabel(objName, radarObject.transform, radar.axisName.labelStyle,
- chart.theme.common, radar.GetFormatterIndicatorContent(i), Color.clear, TextAnchor.MiddleCenter);
+ chart.theme.common, radar.GetFormatterIndicatorContent(i), Color.clear, TextAnchor.MiddleCenter);
label.SetActive(radar.indicator && radar.axisName.labelStyle.show);
AxisHelper.AdjustCircleLabelPos(label, pos, radar.context.center, txtHig, radar.axisName.labelStyle.offset);
}
@@ -95,7 +94,7 @@ namespace XCharts.Runtime
if (radar.splitArea.show)
{
UGL.DrawDoughnut(vh, p, insideRadius, outsideRadius, color, Color.clear,
- 0, 360, chart.settings.cicleSmoothness);
+ 0, 360, chart.settings.cicleSmoothness);
}
if (radar.splitLine.show)
{
diff --git a/Runtime/Component/Settings/Settings.cs b/Runtime/Component/Settings/Settings.cs
index 9cdb9dba..4d8bc804 100644
--- a/Runtime/Component/Settings/Settings.cs
+++ b/Runtime/Component/Settings/Settings.cs
@@ -1,6 +1,5 @@
-
-using UnityEngine;
using System;
+using UnityEngine;
namespace XCharts.Runtime
{
@@ -12,15 +11,15 @@ namespace XCharts.Runtime
public class Settings : MainComponent
{
[SerializeField] private bool m_Show = true;
- [SerializeField] [Range(1, 20)] protected int m_MaxPainter = 10;
+ [SerializeField][Range(1, 20)] protected int m_MaxPainter = 10;
[SerializeField] protected bool m_ReversePainter = false;
[SerializeField] protected Material m_BasePainterMaterial;
[SerializeField] protected Material m_SeriePainterMaterial;
[SerializeField] protected Material m_TopPainterMaterial;
- [SerializeField] [Range(1, 10)] protected float m_LineSmoothStyle = 3f;
- [SerializeField] [Range(1f, 20)] protected float m_LineSmoothness = 2f;
- [SerializeField] [Range(0.5f, 20)] protected float m_LineSegmentDistance = 3f;
- [SerializeField] [Range(1, 10)] protected float m_CicleSmoothness = 2f;
+ [SerializeField][Range(1, 10)] protected float m_LineSmoothStyle = 3f;
+ [SerializeField][Range(1f, 20)] protected float m_LineSmoothness = 2f;
+ [SerializeField][Range(0.5f, 20)] protected float m_LineSegmentDistance = 3f;
+ [SerializeField][Range(1, 10)] protected float m_CicleSmoothness = 2f;
[SerializeField] protected float m_LegendIconLineWidth = 2;
[SerializeField] private float[] m_LegendIconCornerRadius = new float[] { 0.25f, 0.25f, 0.25f, 0.25f };
@@ -156,13 +155,13 @@ namespace XCharts.Runtime
return new Settings()
{
m_ReversePainter = false,
- m_MaxPainter = XCSettings.maxPainter,
- m_LineSmoothStyle = XCSettings.lineSmoothStyle,
- m_LineSmoothness = XCSettings.lineSmoothness,
- m_LineSegmentDistance = XCSettings.lineSegmentDistance,
- m_CicleSmoothness = XCSettings.cicleSmoothness,
- m_LegendIconLineWidth = 2,
- m_LegendIconCornerRadius = new float[] { 0.25f, 0.25f, 0.25f, 0.25f }
+ m_MaxPainter = XCSettings.maxPainter,
+ m_LineSmoothStyle = XCSettings.lineSmoothStyle,
+ m_LineSmoothness = XCSettings.lineSmoothness,
+ m_LineSegmentDistance = XCSettings.lineSegmentDistance,
+ m_CicleSmoothness = XCSettings.cicleSmoothness,
+ m_LegendIconLineWidth = 2,
+ m_LegendIconCornerRadius = new float[] { 0.25f, 0.25f, 0.25f, 0.25f }
};
}
}
diff --git a/Runtime/Component/Title/Title.cs b/Runtime/Component/Title/Title.cs
index 2fa8161a..ac4ca74d 100644
--- a/Runtime/Component/Title/Title.cs
+++ b/Runtime/Component/Title/Title.cs
@@ -1,6 +1,5 @@
-
-using UnityEngine;
using System;
+using UnityEngine;
namespace XCharts.Runtime
{
@@ -83,10 +82,10 @@ namespace XCharts.Runtime
{
get
{
- return m_ComponentDirty
- || location.componentDirty
- || m_LabelStyle.componentDirty
- || m_SubLabelStyle.componentDirty;
+ return m_ComponentDirty ||
+ location.componentDirty ||
+ m_LabelStyle.componentDirty ||
+ m_SubLabelStyle.componentDirty;
}
}
diff --git a/Runtime/Component/Title/TitleHandler.cs b/Runtime/Component/Title/TitleHandler.cs
index 98f252b8..63e32940 100644
--- a/Runtime/Component/Title/TitleHandler.cs
+++ b/Runtime/Component/Title/TitleHandler.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -8,12 +7,14 @@ namespace XCharts.Runtime
{
private static readonly string s_TitleObjectName = "title";
private static readonly string s_SubTitleObjectName = "title_sub";
+ private ChartLabel m_LabelObject;
+ private ChartLabel m_SubLabelObject;
public override void InitComponent()
{
var title = component;
title.painter = null;
- title.refreshComponent = delegate ()
+ title.refreshComponent = delegate()
{
title.OnChanged();
var anchorMin = title.location.runtimeAnchorMin;
@@ -36,16 +37,52 @@ namespace XCharts.Runtime
titleObject.hideFlags = chart.chartHideFlags;
ChartHelper.HideAllObject(titleObject);
- var label = ChartHelper.AddChartLabel(s_TitleObjectName, titleObject.transform, title.labelStyle, chart.theme.title,
- title.text, Color.clear, title.location.runtimeTextAlignment);
- label.SetActive(title.show && title.labelStyle.show);
+ 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);
- var subLabel = ChartHelper.AddChartLabel(s_SubTitleObjectName, titleObject.transform, title.subLabelStyle, chart.theme.subTitle,
- title.subText, Color.clear, title.location.runtimeTextAlignment);
- subLabel.SetActive(title.show && title.subLabelStyle.show);
- subLabel.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
+ 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);
+ m_SubLabelObject.transform.localPosition = subTitlePosition + title.subLabelStyle.offset;
};
title.refreshComponent();
}
+
+ public override void OnSerieDataUpdate(int serieIndex)
+ {
+ if (m_LabelObject != null && FormatterHelper.NeedFormat(component.text))
+ m_LabelObject.SetText(GetTitleText(component));
+ if (m_SubLabelObject != null && FormatterHelper.NeedFormat(component.subText))
+ m_SubLabelObject.SetText(GetSubTitleText(component));
+ }
+
+ private string GetTitleText(Title title)
+ {
+ if (FormatterHelper.NeedFormat(title.text))
+ {
+ var content = title.text;
+ FormatterHelper.ReplaceContent(ref content, 0, title.labelStyle.numericFormatter, null, chart);
+ return content;
+ }
+ else
+ {
+ return title.text;
+ }
+ }
+
+ private string GetSubTitleText(Title title)
+ {
+ if (FormatterHelper.NeedFormat(title.subText))
+ {
+ var content = title.subText;
+ FormatterHelper.ReplaceContent(ref content, 0, title.subLabelStyle.numericFormatter, null, chart);
+ return content;
+ }
+ else
+ {
+ return title.subText;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Runtime/Component/Title/TitleStyle.cs b/Runtime/Component/Title/TitleStyle.cs
index 711e7498..2befc2da 100644
--- a/Runtime/Component/Title/TitleStyle.cs
+++ b/Runtime/Component/Title/TitleStyle.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -11,6 +10,6 @@ namespace XCharts.Runtime
[Serializable]
public class TitleStyle : LabelStyle, ISerieDataComponent, ISerieExtraComponent
{
-
+
}
}
\ No newline at end of file
diff --git a/Runtime/Component/Tooltip/Tooltip.cs b/Runtime/Component/Tooltip/Tooltip.cs
index ca074913..c656f7dc 100644
--- a/Runtime/Component/Tooltip/Tooltip.cs
+++ b/Runtime/Component/Tooltip/Tooltip.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -101,9 +100,9 @@ namespace XCharts.Runtime
[SerializeField]
private List m_ContentLabelStyles = new List()
{
- new LabelStyle(){ textPadding = new TextPadding(0,5,0,0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft }},
- 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 }}
+ new LabelStyle() { textPadding = new TextPadding(0, 5, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft } },
+ 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 } }
};
public TooltipContext context = new TooltipContext();
@@ -146,6 +145,7 @@ namespace XCharts.Runtime
/// {c} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0.
/// {d} is the percentage value of Y-dimensions (dimesion is 1) from serie that is currently indicated or whose index is 0, with no % sign.
/// {e} is the name of the data item serieData that is currently indicated or whose index is 0.
+ /// {f} is sum of data.
/// {.1} represents a dot from serie corresponding color that specifies index as 1.
/// 1 in {a1}, {b1}, {c1} represents a serie that specifies an index of 1.
/// {c1:2} represents the third data from serie's current indication data item indexed to 1 (a data item has multiple data, index 2 represents the third data).
@@ -161,6 +161,7 @@ namespace XCharts.Runtime
/// {c}为当前所指示或index为0的serie的y维(dimesion为1)的数值。
/// {d}为当前所指示或index为0的serie的y维(dimesion为1)百分比值,注意不带%号。
/// {e}为当前所指示或index为0的serie的数据项serieData的name。
+ /// {f}为数据总和。
/// {.1}表示指定index为1的serie对应颜色的圆点。
/// {a1}、{b1}、{c1}中的1表示指定index为1的serie。
/// {c1:2}表示索引为1的serie的当前指示数据项的第3个数据(一个数据项有多个数据,index为2表示第3个数据)。
@@ -372,7 +373,7 @@ namespace XCharts.Runtime
/// |当前提示框所指示的数据项索引。
///
public List runtimeDataIndex { get { return m_RuntimeDateIndex; } internal set { m_RuntimeDateIndex = value; } }
- private List m_RuntimeDateIndex = new List() { -1, -1 };
+ private List m_RuntimeDateIndex = new List() {-1, -1 };
///
/// Keep Tooltiop displayed at the top.
diff --git a/Runtime/Component/Tooltip/TooltipContext.cs b/Runtime/Component/Tooltip/TooltipContext.cs
index c9b322ef..f00c7d0b 100644
--- a/Runtime/Component/Tooltip/TooltipContext.cs
+++ b/Runtime/Component/Tooltip/TooltipContext.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using System.Text;
diff --git a/Runtime/Component/Tooltip/TooltipHandler.cs b/Runtime/Component/Tooltip/TooltipHandler.cs
index acee6078..e55d3670 100644
--- a/Runtime/Component/Tooltip/TooltipHandler.cs
+++ b/Runtime/Component/Tooltip/TooltipHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -35,7 +34,7 @@ namespace XCharts.Runtime
private void InitTooltip(Tooltip tooltip)
{
tooltip.painter = chart.m_PainterTop;
- tooltip.refreshComponent = delegate ()
+ tooltip.refreshComponent = delegate()
{
var objName = ChartCached.GetComponentObjectName(tooltip);
tooltip.gameObject = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
@@ -186,7 +185,7 @@ namespace XCharts.Runtime
label.SetTextActive(true);
label.SetPosition(axis.context.pointerLabelPosition);
if (axis.IsCategory())
- label.SetText(axis.GetData((int)axis.context.pointerValue));
+ label.SetText(axis.GetData((int) axis.context.pointerValue));
else
label.SetText(axis.context.pointerValue.ToString("f2"));
var textColor = axis.axisLabel.textStyle.GetColor(chart.theme.axis.textColor);
@@ -210,8 +209,8 @@ namespace XCharts.Runtime
{
foreach (var serie in chart.series)
{
- if (serie is INeedSerieContainer
- && (serie as INeedSerieContainer).containterInstanceId == component.instanceId)
+ if (serie is INeedSerieContainer &&
+ (serie as INeedSerieContainer).containterInstanceId == component.instanceId)
{
var isTriggerAxis = tooltip.IsTriggerAxis();
if (container is GridCoord)
@@ -224,7 +223,7 @@ namespace XCharts.Runtime
else if (container is PolarCoord)
{
var m_AngleAxis = ComponentHelper.GetAngleAxis(chart.components, container.index);
- tooltip.context.angle = (float)m_AngleAxis.context.pointerValue;
+ tooltip.context.angle = (float) m_AngleAxis.context.pointerValue;
}
list.Add(serie);
if (!isTriggerAxis)
@@ -243,7 +242,7 @@ namespace XCharts.Runtime
serie.context.pointerAxisDataIndexs.Clear();
if (yAxis.IsCategory())
{
- serie.context.pointerAxisDataIndexs.Add((int)yAxis.context.pointerValue);
+ serie.context.pointerAxisDataIndexs.Add((int) yAxis.context.pointerValue);
yAxis.context.axisTooltipValue = yAxis.context.pointerValue;
}
else if (yAxis.IsTime())
@@ -255,7 +254,7 @@ namespace XCharts.Runtime
}
else if (xAxis.IsCategory())
{
- serie.context.pointerAxisDataIndexs.Add((int)xAxis.context.pointerValue);
+ serie.context.pointerAxisDataIndexs.Add((int) xAxis.context.pointerValue);
xAxis.context.axisTooltipValue = xAxis.context.pointerValue;
}
else
@@ -286,7 +285,7 @@ namespace XCharts.Runtime
serieData.index = i;
serie.context.sortedData.Add(serieData);
}
- serie.context.sortedData.Sort(delegate (SerieData a, SerieData b)
+ serie.context.sortedData.Sort(delegate(SerieData a, SerieData b)
{
return a.GetData(dimension).CompareTo(b.GetData(dimension));
});
@@ -437,7 +436,7 @@ namespace XCharts.Runtime
var axis = component as Axis;
if (axis.gridIndex == gridIndex && axis.IsCategory())
{
- dataIndex = (int)axis.context.pointerValue;
+ dataIndex = (int) axis.context.pointerValue;
category = axis.GetData(dataIndex);
return true;
}
@@ -494,25 +493,25 @@ namespace XCharts.Runtime
case Tooltip.Type.Corss:
case Tooltip.Type.Line:
float pX = grid.context.x;
- pX += xAxis.IsCategory()
- ? (float)(xAxis.context.pointerValue * splitWidth + (xAxis.boundaryGap ? splitWidth / 2 : 0))
- : xAxis.GetDistance(xAxis.context.axisTooltipValue, grid.context.width);
+ pX += xAxis.IsCategory() ?
+ (float) (xAxis.context.pointerValue * splitWidth + (xAxis.boundaryGap ? splitWidth / 2 : 0)) :
+ xAxis.GetDistance(xAxis.context.axisTooltipValue, grid.context.width);
Vector2 sp = new Vector2(pX, grid.context.y);
Vector2 ep = new Vector2(pX, grid.context.y + grid.context.height);
var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme);
- if (xAxis.IsCategory() && tooltip.type == Tooltip.Type.Corss)
- {
- float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
- pX = (float)(grid.context.x + splitWidth * xAxis.context.pointerValue -
- (xAxis.boundaryGap ? 0 : splitWidth / 2));
- float pY = grid.context.y + grid.context.height;
- Vector3 p1 = new Vector3(pX, grid.context.y);
- Vector3 p2 = new Vector3(pX, pY);
- Vector3 p3 = new Vector3(pX + tooltipSplitWid, pY);
- Vector3 p4 = new Vector3(pX + tooltipSplitWid, grid.context.y);
- UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, chart.theme.tooltip.areaColor);
- }
- else
+ // if (xAxis.IsCategory() && tooltip.type == Tooltip.Type.Corss)
+ // {
+ // float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
+ // pX = (float)(grid.context.x + splitWidth * xAxis.context.pointerValue -
+ // (xAxis.boundaryGap ? 0 : splitWidth / 2));
+ // float pY = grid.context.y + grid.context.height;
+ // Vector3 p1 = new Vector3(pX, grid.context.y);
+ // Vector3 p2 = new Vector3(pX, pY);
+ // Vector3 p3 = new Vector3(pX + tooltipSplitWid, pY);
+ // Vector3 p4 = new Vector3(pX + tooltipSplitWid, grid.context.y);
+ // UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, chart.theme.tooltip.areaColor);
+ // }
+ // else
{
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
}
@@ -527,7 +526,7 @@ namespace XCharts.Runtime
if (xAxis.IsCategory())
{
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
- pX = (float)(grid.context.x + splitWidth * xAxis.context.pointerValue -
+ pX = (float) (grid.context.x + splitWidth * xAxis.context.pointerValue -
(xAxis.boundaryGap ? 0 : splitWidth / 2));
float pY = grid.context.y + grid.context.height;
Vector3 p1 = new Vector3(pX, grid.context.y);
@@ -559,24 +558,24 @@ namespace XCharts.Runtime
{
case Tooltip.Type.Corss:
case Tooltip.Type.Line:
- float pY = (float)(grid.context.y + yAxis.context.pointerValue * splitWidth
- + (yAxis.boundaryGap ? splitWidth / 2 : 0));
+ float pY = (float) (grid.context.y + yAxis.context.pointerValue * splitWidth +
+ (yAxis.boundaryGap ? splitWidth / 2 : 0));
Vector2 sp = new Vector2(grid.context.x, pY);
Vector2 ep = new Vector2(grid.context.x + grid.context.width, pY);
var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme);
- if (yAxis.IsCategory() && tooltip.type == Tooltip.Type.Corss)
- {
- float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
- float pX = grid.context.x + grid.context.width;
- pY = (float)(grid.context.y + splitWidth * yAxis.context.pointerValue -
- (yAxis.boundaryGap ? 0 : splitWidth / 2));
- Vector3 p1 = new Vector3(grid.context.x, pY);
- Vector3 p2 = new Vector3(grid.context.x, pY + tooltipSplitWid);
- Vector3 p3 = new Vector3(pX, pY + tooltipSplitWid);
- Vector3 p4 = new Vector3(pX, pY);
- UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, chart.theme.tooltip.areaColor);
- }
- else
+ // if (yAxis.IsCategory() && tooltip.type == Tooltip.Type.Corss)
+ // {
+ // float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
+ // float pX = grid.context.x + grid.context.width;
+ // pY = (float)(grid.context.y + splitWidth * yAxis.context.pointerValue -
+ // (yAxis.boundaryGap ? 0 : splitWidth / 2));
+ // Vector3 p1 = new Vector3(grid.context.x, pY);
+ // Vector3 p2 = new Vector3(grid.context.x, pY + tooltipSplitWid);
+ // Vector3 p3 = new Vector3(pX, pY + tooltipSplitWid);
+ // Vector3 p4 = new Vector3(pX, pY);
+ // UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, chart.theme.tooltip.areaColor);
+ // }
+ // else
{
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
}
@@ -592,7 +591,7 @@ namespace XCharts.Runtime
{
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
float pX = grid.context.x + grid.context.width;
- pY = (float)(grid.context.y + splitWidth * yAxis.context.pointerValue -
+ pY = (float) (grid.context.y + splitWidth * yAxis.context.pointerValue -
(yAxis.boundaryGap ? 0 : splitWidth / 2));
Vector3 p1 = new Vector3(grid.context.x, pY);
Vector3 p2 = new Vector3(grid.context.x, pY + tooltipSplitWid);
diff --git a/Runtime/Component/Tooltip/TooltipHelper.cs b/Runtime/Component/Tooltip/TooltipHelper.cs
index b28da61b..9e099bd9 100644
--- a/Runtime/Component/Tooltip/TooltipHelper.cs
+++ b/Runtime/Component/Tooltip/TooltipHelper.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -37,6 +36,7 @@ namespace XCharts.Runtime
var content = param.itemFormatter;
FormatterHelper.ReplaceSerieLabelContent(ref content,
param.numericFormatter,
+ param.dataCount,
param.value,
param.total,
param.serieName,
diff --git a/Runtime/Component/Tooltip/TooltipView.cs b/Runtime/Component/Tooltip/TooltipView.cs
index de09db1d..2fe075f1 100644
--- a/Runtime/Component/Tooltip/TooltipView.cs
+++ b/Runtime/Component/Tooltip/TooltipView.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -115,8 +114,6 @@ namespace XCharts.Runtime
tooltip.gameObject.transform.SetAsLastSibling();
}
-
-
private void ResetSize()
{
var maxHig = 0f;
@@ -220,8 +217,8 @@ namespace XCharts.Runtime
view.background = ChartHelper.GetOrAddComponent(view.gameObject);
view.background.sprite = tooltip.backgroundImage;
view.background.type = tooltip.backgroundType;
- view.background.color = ChartHelper.IsClearColor(tooltip.backgroundColor)
- ? Color.white : tooltip.backgroundColor;
+ view.background.color = ChartHelper.IsClearColor(tooltip.backgroundColor) ?
+ Color.white : tooltip.backgroundColor;
view.border = ChartHelper.GetOrAddComponent(view.gameObject);
view.border.enabled = tooltip.borderWidth > 0;
@@ -240,7 +237,7 @@ namespace XCharts.Runtime
tooltip.paddingTopBottom);
view.title = ChartHelper.AddChartLabel("title", view.gameObject.transform, tooltip.titleLabelStyle, theme.tooltip,
- "", Color.clear, TextAnchor.MiddleLeft);
+ "", Color.clear, TextAnchor.MiddleLeft);
var item = CreateViewItem(0, view.gameObject.transform, tooltip, theme.tooltip);
view.m_Items.Add(item);
@@ -266,7 +263,7 @@ namespace XCharts.Runtime
{
var labelStyle = tooltip.GetContentLabelStyle(i);
var label = ChartHelper.AddChartLabel("column" + i, parent, labelStyle, theme,
- "", Color.clear, TextAnchor.MiddleLeft);
+ "", Color.clear, TextAnchor.MiddleLeft);
return label;
}
}
diff --git a/Runtime/Component/VisualMap/VisualMap.cs b/Runtime/Component/VisualMap/VisualMap.cs
index 6b374386..165aa809 100644
--- a/Runtime/Component/VisualMap/VisualMap.cs
+++ b/Runtime/Component/VisualMap/VisualMap.cs
@@ -1,11 +1,10 @@
-
using System.Collections.Generic;
using UnityEngine;
namespace XCharts.Runtime
{
[System.Serializable]
- public class VisualMapPieces : ChildComponent
+ public class VisualMapRange : ChildComponent
{
[SerializeField] private double m_Min;
[SerializeField] private double m_Max;
@@ -31,6 +30,7 @@ namespace XCharts.Runtime
public bool Contains(double value, double minMaxRange)
{
+ if (m_Min == 0 && m_Max == 0) return false;
var cmin = System.Math.Abs(m_Min) < 1 ? minMaxRange * m_Min : m_Min;
var cmax = System.Math.Abs(m_Max) < 1 ? minMaxRange * m_Max : m_Max;
return value >= cmin && value < cmax;
@@ -101,9 +101,8 @@ namespace XCharts.Runtime
[SerializeField] private bool m_WorkOnLine = true;
[SerializeField] private bool m_WorkOnArea = false;
- [SerializeField] private List m_InRange = new List();
- [SerializeField] private List m_OutOfRange = new List() { Color.gray };
- [SerializeField] private List m_Pieces = new List();
+ [SerializeField] private List m_OutOfRange = new List() { new VisualMapRange() { color = Color.gray } };
+ [SerializeField] private List m_InRange = new List();
public VisualMapContext context = new VisualMapContext();
@@ -331,19 +330,10 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_WorkOnArea, value)) SetVerticesDirty(); }
}
///
- /// Defines the visual color in the selected range.
- /// |定义 在选中范围中 的视觉颜色。
- ///
- public List inRange
- {
- get { return m_InRange; }
- set { if (value != null) { m_InRange = value; SetVerticesDirty(); } }
- }
- ///
/// Defines a visual color outside of the selected range.
/// |定义 在选中范围外 的视觉颜色。
///
- public List outOfRange
+ public List outOfRange
{
get { return m_OutOfRange; }
set { if (value != null) { m_OutOfRange = value; SetVerticesDirty(); } }
@@ -351,10 +341,10 @@ namespace XCharts.Runtime
///
/// 分段式每一段的相关配置。
///
- public List pieces
+ public List inRange
{
- get { return m_Pieces; }
- set { if (value != null) { m_Pieces = value; SetVerticesDirty(); } }
+ get { return m_InRange; }
+ set { if (value != null) { m_InRange = value; SetVerticesDirty(); } }
}
public override bool vertsDirty { get { return m_VertsDirty || location.anyDirty; } }
@@ -396,73 +386,84 @@ namespace XCharts.Runtime
}
}
- public float runtimeRangeMinHeight { get { return (float)((rangeMin - min) / (max - min) * itemHeight); } }
- public float runtimeRangeMaxHeight { get { return (float)((rangeMax - min) / (max - min) * itemHeight); } }
+ public float runtimeRangeMinHeight { get { return (float) ((rangeMin - min) / (max - min) * itemHeight); } }
+ public float runtimeRangeMaxHeight { get { return (float) ((rangeMax - min) / (max - min) * itemHeight); } }
- public List runtimeInRange
+ public void AddColors(List colors)
{
- get
+ m_InRange.Clear();
+ foreach (var color in colors)
{
- if (splitNumber == 0 || m_InRange.Count >= splitNumber || m_InRange.Count < 1 || IsPiecewise())
+ m_InRange.Add(new VisualMapRange()
{
- return m_InRange;
- }
- else
+ color = color
+ });
+ }
+ }
+
+ public void AddColors(List colors)
+ {
+ m_InRange.Clear();
+ foreach (var str in colors)
+ {
+ m_InRange.Add(new VisualMapRange()
{
- var count = splitNumber > 0 && splitNumber <= m_InRange.Count
- ? splitNumber
- : m_InRange.Count;
- if (context.inRangeColors.Count != count)
- {
- context.inRangeColors.Clear();
- var total = max - min;
- var diff1 = total / (m_InRange.Count - 1);
- var diff2 = total / splitNumber;
-
- var inCount = 0;
- var inValue = min;
- var rtValue = min;
-
- for (int i = 0; i < splitNumber; i++)
- {
- rtValue += diff2;
- if (rtValue > inValue + diff1)
- {
- inValue += diff1;
- inCount++;
- }
- if (i == splitNumber - 1)
- {
- context.inRangeColors.Add(m_InRange[m_InRange.Count - 1]);
- }
- else
- {
- var rate = (float)((rtValue - inValue) / diff1);
- context.inRangeColors.Add(Color32.Lerp(m_InRange[inCount], m_InRange[inCount + 1], rate));
- }
- }
- }
- return context.inRangeColors;
- }
+ color = ThemeStyle.GetColor(str)
+ });
}
}
public Color32 GetColor(double value)
{
- switch (type)
+ int index = GetIndex(value);
+ if (index == -1)
{
- case Type.Continuous:
- return GetContinuousColor(value);
- case Type.Piecewise:
- return GetPiecesColor(value);
- default:
- return ColorUtil.clearColor32;
+ if (m_OutOfRange.Count > 0)
+ return m_OutOfRange[0].color;
+ else
+ return ChartConst.clearColor32;
}
+
+ if (m_Type == VisualMap.Type.Piecewise)
+ {
+ return m_InRange[index].color;
+ }
+ else
+ {
+ int splitNumber = m_InRange.Count;
+ var diff = (m_Max - m_Min) / (splitNumber - 1);
+ var nowMin = m_Min + index * diff;
+ var rate = (value - nowMin) / diff;
+ if (index == splitNumber - 1)
+ return m_InRange[index].color;
+ else
+ return Color32.Lerp(m_InRange[index].color, m_InRange[index + 1].color, (float) rate);
+ }
+ }
+
+ private bool IsNeedPieceColor(double value, out int index)
+ {
+ bool flag = false;
+ index = -1;
+ for (int i = 0; i < m_InRange.Count; i++)
+ {
+ var range = m_InRange[i];
+ if (range.min != 0 || range.max != 0)
+ {
+ flag = true;
+ if (range.Contains(value, max - min))
+ {
+ index = i;
+ return true;
+ }
+ }
+ }
+ return flag;
}
private Color32 GetPiecesColor(double value)
{
- foreach (var piece in m_Pieces)
+ foreach (var piece in m_InRange)
{
if (piece.Contains(value, max - min))
{
@@ -470,54 +471,25 @@ namespace XCharts.Runtime
}
}
if (m_OutOfRange.Count > 0)
- return m_OutOfRange[0];
+ return m_OutOfRange[0].color;
else
return ChartConst.clearColor32;
}
- private Color32 GetContinuousColor(double value)
- {
- if (value < m_Min || value > m_Max)
- {
- if (m_OutOfRange.Count > 0)
- return m_OutOfRange[0];
- else
- return ChartConst.clearColor32;
- }
- int splitNumber = runtimeInRange.Count;
- if (splitNumber <= 0)
- return ChartConst.clearColor32;
-
- var index = GetIndex(value);
- if (m_Type == VisualMap.Type.Piecewise)
- {
- if (index >= 0 && index < runtimeInRange.Count)
- return runtimeInRange[index];
- else
- return ChartConst.clearColor32;
- }
- else
- {
- var diff = (m_Max - m_Min) / (splitNumber - 1);
- var nowMin = m_Min + index * diff;
- var rate = (value - nowMin) / diff;
- if (index == splitNumber - 1)
- return runtimeInRange[index];
- else
- return Color32.Lerp(runtimeInRange[index], runtimeInRange[index + 1], (float)rate);
- }
- }
-
public int GetIndex(double value)
{
- int splitNumber = runtimeInRange.Count;
+ int splitNumber = m_InRange.Count;
if (splitNumber <= 0)
return -1;
-
+ var index = -1;
+ if (IsNeedPieceColor(value, out index))
+ {
+ return index;
+ }
value = MathUtil.Clamp(value, m_Min, m_Max);
var diff = (m_Max - m_Min) / (splitNumber - 1);
- var index = -1;
+
for (int i = 0; i < splitNumber; i++)
{
if (value <= m_Min + (i + 1) * diff)
@@ -574,10 +546,10 @@ namespace XCharts.Runtime
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
var diff = calculable ? triangleLen : 0;
- if (local.x >= centerPos.x - itemWidth / 2 - diff
- && local.x <= centerPos.x + itemWidth / 2 + diff
- && local.y >= centerPos.y - itemHeight / 2 - diff
- && local.y <= centerPos.y + itemHeight / 2 + diff)
+ if (local.x >= centerPos.x - itemWidth / 2 - diff &&
+ local.x <= centerPos.x + itemWidth / 2 + diff &&
+ local.y >= centerPos.y - itemHeight / 2 - diff &&
+ local.y <= centerPos.y + itemHeight / 2 + diff)
{
return true;
}
@@ -595,18 +567,18 @@ namespace XCharts.Runtime
{
var pos1 = centerPos + Vector3.down * itemHeight / 2;
- return local.x >= centerPos.x - itemWidth / 2
- && local.x <= centerPos.x + itemWidth / 2
- && local.y >= pos1.y + runtimeRangeMinHeight
- && local.y <= pos1.y + runtimeRangeMaxHeight;
+ return local.x >= centerPos.x - itemWidth / 2 &&
+ local.x <= centerPos.x + itemWidth / 2 &&
+ local.y >= pos1.y + runtimeRangeMinHeight &&
+ local.y <= pos1.y + runtimeRangeMaxHeight;
}
else
{
var pos1 = centerPos + Vector3.left * itemHeight / 2;
- return local.x >= pos1.x + runtimeRangeMinHeight
- && local.x <= pos1.x + runtimeRangeMaxHeight
- && local.y >= centerPos.y - itemWidth / 2
- && local.y <= centerPos.y + itemWidth / 2;
+ return local.x >= pos1.x + runtimeRangeMinHeight &&
+ local.x <= pos1.x + runtimeRangeMaxHeight &&
+ local.y >= centerPos.y - itemWidth / 2 &&
+ local.y <= centerPos.y + itemWidth / 2;
}
}
@@ -620,10 +592,10 @@ namespace XCharts.Runtime
var pos1 = centerPos + Vector3.down * itemHeight / 2;
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + runtimeRangeMinHeight - radius);
- return local.x >= cpos.x - radius
- && local.x <= cpos.x + radius
- && local.y >= cpos.y - radius
- && local.y <= cpos.y + radius;
+ return local.x >= cpos.x - radius &&
+ local.x <= cpos.x + radius &&
+ local.y >= cpos.y - radius &&
+ local.y <= cpos.y + radius;
}
else
{
@@ -631,10 +603,10 @@ namespace XCharts.Runtime
var pos1 = centerPos + Vector3.left * itemHeight / 2;
var cpos = new Vector3(pos1.x + runtimeRangeMinHeight, pos1.y + itemWidth / 2 + radius);
- return local.x >= cpos.x - radius
- && local.x <= cpos.x + radius
- && local.y >= cpos.y - radius
- && local.y <= cpos.y + radius;
+ return local.x >= cpos.x - radius &&
+ local.x <= cpos.x + radius &&
+ local.y >= cpos.y - radius &&
+ local.y <= cpos.y + radius;
}
}
@@ -648,10 +620,10 @@ namespace XCharts.Runtime
var pos1 = centerPos + Vector3.down * itemHeight / 2;
var cpos = new Vector3(pos1.x + itemWidth / 2 + radius, pos1.y + runtimeRangeMaxHeight + radius);
- return local.x >= cpos.x - radius
- && local.x <= cpos.x + radius
- && local.y >= cpos.y - radius
- && local.y <= cpos.y + radius;
+ return local.x >= cpos.x - radius &&
+ local.x <= cpos.x + radius &&
+ local.y >= cpos.y - radius &&
+ local.y <= cpos.y + radius;
}
else
{
@@ -659,10 +631,10 @@ namespace XCharts.Runtime
var pos1 = centerPos + Vector3.left * itemHeight / 2;
var cpos = new Vector3(pos1.x + runtimeRangeMaxHeight + radius, pos1.y + itemWidth / 2 + radius);
- return local.x >= cpos.x - radius
- && local.x <= cpos.x + radius
- && local.y >= cpos.y - radius
- && local.y <= cpos.y + radius;
+ return local.x >= cpos.x - radius &&
+ local.x <= cpos.x + radius &&
+ local.y >= cpos.y - radius &&
+ local.y <= cpos.y + radius;
}
}
}
diff --git a/Runtime/Component/VisualMap/VisualMapContext.cs b/Runtime/Component/VisualMap/VisualMapContext.cs
index d752b138..730b537d 100644
--- a/Runtime/Component/VisualMap/VisualMapContext.cs
+++ b/Runtime/Component/VisualMap/VisualMapContext.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -15,6 +14,6 @@ namespace XCharts.Runtime
public bool maxDrag { get; internal set; }
internal List inRangeColors = new List();
-
+
}
}
\ No newline at end of file
diff --git a/Runtime/Component/VisualMap/VisualMapHandler.cs b/Runtime/Component/VisualMap/VisualMapHandler.cs
index 79c3b931..a6f672da 100644
--- a/Runtime/Component/VisualMap/VisualMapHandler.cs
+++ b/Runtime/Component/VisualMap/VisualMapHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
@@ -63,11 +62,11 @@ namespace XCharts.Runtime
return;
}
- if (local.x < chart.chartX
- || local.x > chart.chartX + chart.chartWidth
- || local.y < chart.chartY
- || local.y > chart.chartY + chart.chartHeight
- || !visualMap.IsInRangeRect(local, chart.chartRect))
+ if (local.x < chart.chartX ||
+ local.x > chart.chartX + chart.chartWidth ||
+ local.y < chart.chartY ||
+ local.y > chart.chartY + chart.chartHeight ||
+ !visualMap.IsInRangeRect(local, chart.chartRect))
{
if (visualMap.context.pointerIndex >= 0)
{
@@ -116,10 +115,10 @@ namespace XCharts.Runtime
var halfHig = visualMap.itemHeight / 2;
var xRadius = 0f;
var yRadius = 0f;
- var splitNum = visualMap.runtimeInRange.Count;
+ var splitNum = visualMap.inRange.Count;
var splitWid = visualMap.itemHeight / (splitNum - 1);
var isVertical = false;
- var colors = visualMap.runtimeInRange;
+ var colors = visualMap.inRange;
var triangeLen = chart.theme.visualMap.triangeLen;
switch (visualMap.orient)
@@ -172,8 +171,8 @@ namespace XCharts.Runtime
}
break;
}
- if (visualMap.calculable
- && (visualMap.rangeMin > visualMap.min || visualMap.rangeMax < visualMap.max))
+ if (visualMap.calculable &&
+ (visualMap.rangeMin > visualMap.min || visualMap.rangeMax < visualMap.max))
{
var rangeMin = visualMap.rangeMin;
var rangeMax = visualMap.rangeMax;
@@ -189,8 +188,8 @@ namespace XCharts.Runtime
else if (rangeMin <= splitMin && rangeMax >= splitMax)
{
var splitPos = pos1 + dir * (i - 1 + 0.5f) * splitWid;
- var startColor = colors[i - 1];
- var toColor = visualMap.IsPiecewise() ? startColor : colors[i];
+ var startColor = colors[i - 1].color;
+ var toColor = visualMap.IsPiecewise() ? startColor : colors[i].color;
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical);
}
else if (rangeMin > splitMin && rangeMax >= splitMax)
@@ -199,7 +198,7 @@ namespace XCharts.Runtime
var splitMaxPos = pos1 + dir * i * splitWid;
var splitPos = p0 + (splitMaxPos - p0) / 2;
var startColor = visualMap.GetColor(visualMap.rangeMin);
- var toColor = visualMap.IsPiecewise() ? startColor : colors[i];
+ var toColor = visualMap.IsPiecewise() ? startColor : colors[i].color;
var yRadius1 = Vector3.Distance(p0, splitMaxPos) / 2;
if (visualMap.orient == Orient.Vertical)
@@ -212,7 +211,7 @@ namespace XCharts.Runtime
var p0 = pos1 + dir * visualMap.runtimeRangeMaxHeight;
var splitMinPos = pos1 + dir * (i - 1) * splitWid;
var splitPos = splitMinPos + (p0 - splitMinPos) / 2;
- var startColor = colors[i - 1];
+ var startColor = colors[i - 1].color;
var toColor = visualMap.IsPiecewise() ? startColor : visualMap.GetColor(visualMap.rangeMax);
var yRadius1 = Vector3.Distance(p0, splitMinPos) / 2;
@@ -242,8 +241,8 @@ namespace XCharts.Runtime
for (int i = 1; i < splitNum; i++)
{
var splitPos = pos1 + dir * (i - 1 + 0.5f) * splitWid;
- var startColor = colors[i - 1];
- var toColor = visualMap.IsPiecewise() ? startColor : colors[i];
+ var startColor = colors[i - 1].color;
+ var toColor = visualMap.IsPiecewise() ? startColor : colors[i].color;
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical);
}
}
@@ -272,14 +271,14 @@ namespace XCharts.Runtime
var p2 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y + (triangeLen / 2), p0.y, p1.y));
var p3 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y - (triangeLen / 2), p0.y, p1.y));
var p4 = new Vector3(centerPos.x + halfWid + triangeLen / 2, pointerPos.y);
- UGL.DrawTriangle(vh, p2, p3, p4, colors[visualMap.context.pointerIndex]);
+ UGL.DrawTriangle(vh, p2, p3, p4, colors[visualMap.context.pointerIndex].color);
}
else
{
var p2 = new Vector3(Mathf.Clamp(pointerPos.x + (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
var p3 = new Vector3(Mathf.Clamp(pointerPos.x - (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
var p4 = new Vector3(pointerPos.x, centerPos.y + halfWid + triangeLen / 2);
- UGL.DrawTriangle(vh, p2, p3, p4, colors[visualMap.context.pointerIndex]);
+ UGL.DrawTriangle(vh, p2, p3, p4, colors[visualMap.context.pointerIndex].color);
}
}
}
@@ -293,23 +292,21 @@ namespace XCharts.Runtime
var dir = Vector3.zero;
var halfWid = visualMap.itemWidth / 2;
var halfHig = visualMap.itemHeight / 2;
- var splitNum = visualMap.runtimeInRange.Count;
- var colors = visualMap.runtimeInRange;
switch (visualMap.orient)
{
case Orient.Horizonal:
- for (int i = 0; i < visualMap.pieces.Count; i++)
+ for (int i = 0; i < visualMap.inRange.Count; i++)
{
- var piece = visualMap.pieces[i];
+ var piece = visualMap.inRange[i];
}
break;
case Orient.Vertical:
var each = visualMap.itemHeight + visualMap.itemGap;
- for (int i = 0; i < visualMap.pieces.Count; i++)
+ for (int i = 0; i < visualMap.inRange.Count; i++)
{
- var piece = visualMap.pieces[i];
+ var piece = visualMap.inRange[i];
var pos = new Vector3(centerPos.x, centerPos.y - each * i);
UGL.DrawRectangle(vh, pos, halfWid, halfHig, piece.color);
}
diff --git a/Runtime/Component/VisualMap/VisualMapHelper.cs b/Runtime/Component/VisualMap/VisualMapHelper.cs
index 42d05c2c..6351dea4 100644
--- a/Runtime/Component/VisualMap/VisualMapHelper.cs
+++ b/Runtime/Component/VisualMap/VisualMapHelper.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -78,7 +77,7 @@ namespace XCharts.Runtime
float startX = grid.context.x + axis.context.scaleWidth / 2;
value = (min + (pos.x - startX) / (grid.context.width - axis.context.scaleWidth) * (max - min));
if (visualMap.IsPiecewise())
- value = (int)value;
+ value = (int) value;
}
else
{
@@ -94,7 +93,7 @@ namespace XCharts.Runtime
float startY = grid.context.y + relativedAxis.context.scaleWidth / 2;
value = (min + (pos.y - startY) / (grid.context.height - relativedAxis.context.scaleWidth) * (max - min));
if (visualMap.IsPiecewise())
- value = (int)value;
+ value = (int) value;
}
else
{
@@ -124,7 +123,7 @@ namespace XCharts.Runtime
var grid = chart.GetChartComponent(axis.gridIndex);
var value = min + (pos.x - grid.context.x) / grid.context.width * (max - min);
var rate = (value - min) / (max - min);
- var color = itemStyle.GetGradientColor((float)rate, defaultColor);
+ var color = itemStyle.GetGradientColor((float) rate, defaultColor);
if (ChartHelper.IsClearColor(color))
return defaultColor;
@@ -139,7 +138,7 @@ namespace XCharts.Runtime
var max = axis.context.maxValue;
var value = min + (pos.x - grid.context.x) / grid.context.width * (max - min);
var rate = (value - min) / (max - min);
- var color = lineStyle.GetGradientColor((float)rate, defaultColor);
+ var color = lineStyle.GetGradientColor((float) rate, defaultColor);
if (ChartHelper.IsClearColor(color))
return defaultColor;
@@ -153,7 +152,7 @@ namespace XCharts.Runtime
return false;
if (!visualMap.show || (!visualMap.workOnLine && !visualMap.workOnArea))
return false;
- if (visualMap.inRange.Count <= 0 && visualMap.pieces.Count <= 0)
+ if (visualMap.inRange.Count <= 0)
return false;
return true;
}
@@ -163,7 +162,7 @@ namespace XCharts.Runtime
return false;
if (!visualMap.show || !visualMap.workOnLine)
return false;
- if (visualMap.inRange.Count <= 0 && visualMap.pieces.Count <= 0)
+ if (visualMap.inRange.Count <= 0)
return false;
return true;
}
@@ -173,15 +172,15 @@ namespace XCharts.Runtime
return false;
if (!visualMap.show || !visualMap.workOnArea)
return false;
- if (visualMap.inRange.Count <= 0 && visualMap.pieces.Count <= 0)
+ if (visualMap.inRange.Count <= 0)
return false;
return true;
}
public static int GetDimension(VisualMap visualMap, int serieDataCount)
{
- var dimension = visualMap != null && visualMap.dimension >= 0
- ? visualMap.dimension : serieDataCount - 1;
+ var dimension = visualMap != null && visualMap.dimension >= 0 ?
+ visualMap.dimension : serieDataCount - 1;
if (dimension > serieDataCount - 1)
dimension = serieDataCount - 1;
diff --git a/Runtime/Coord/Calendar/CalendarCoord.cs b/Runtime/Coord/Calendar/CalendarCoord.cs
index 1678f5ed..8d162105 100644
--- a/Runtime/Coord/Calendar/CalendarCoord.cs
+++ b/Runtime/Coord/Calendar/CalendarCoord.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -14,7 +13,6 @@ namespace XCharts.Runtime
}
public void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
- {
- }
+ { }
}
}
\ No newline at end of file
diff --git a/Runtime/Coord/Calendar/CalendarCoordHandler.cs b/Runtime/Coord/Calendar/CalendarCoordHandler.cs
index 7414b1f2..69eb3338 100644
--- a/Runtime/Coord/Calendar/CalendarCoordHandler.cs
+++ b/Runtime/Coord/Calendar/CalendarCoordHandler.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -6,6 +5,5 @@ namespace XCharts.Runtime
{
[UnityEngine.Scripting.Preserve]
internal sealed class CalendarCoordHandler : MainComponentHandler
- {
- }
+ { }
}
\ No newline at end of file
diff --git a/Runtime/Coord/Grid/GridCoord.cs b/Runtime/Coord/Grid/GridCoord.cs
index 30d49653..f279faa9 100644
--- a/Runtime/Coord/Grid/GridCoord.cs
+++ b/Runtime/Coord/Grid/GridCoord.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
using XUGL;
diff --git a/Runtime/Coord/Grid/GridCoordContext.cs b/Runtime/Coord/Grid/GridCoordContext.cs
index 961a3585..be4ac7a7 100644
--- a/Runtime/Coord/Grid/GridCoordContext.cs
+++ b/Runtime/Coord/Grid/GridCoordContext.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
diff --git a/Runtime/Coord/Grid/GridCoordHandler.cs b/Runtime/Coord/Grid/GridCoordHandler.cs
index eace2db8..03dec597 100644
--- a/Runtime/Coord/Grid/GridCoordHandler.cs
+++ b/Runtime/Coord/Grid/GridCoordHandler.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Text;
using UnityEngine;
@@ -14,7 +13,7 @@ namespace XCharts.Runtime
{
var grid = component;
grid.painter = chart.painter;
- grid.refreshComponent = delegate ()
+ grid.refreshComponent = delegate()
{
grid.UpdateRuntimeData(chart.chartX, chart.chartY, chart.chartWidth, chart.chartHeight);
chart.OnCoordinateChanged();
@@ -80,9 +79,9 @@ namespace XCharts.Runtime
if (grid.showBorder)
{
var borderWidth = grid.borderWidth == 0 ? chart.theme.axis.lineWidth * 2 : grid.borderWidth;
- var borderColor = ChartHelper.IsClearColor(grid.borderColor)
- ? chart.theme.axis.lineColor
- : grid.borderColor;
+ var borderColor = ChartHelper.IsClearColor(grid.borderColor) ?
+ chart.theme.axis.lineColor :
+ grid.borderColor;
UGL.DrawBorder(vh, grid.context.center, grid.context.width - borderWidth,
grid.context.height - borderWidth, borderWidth, borderColor);
}
diff --git a/Runtime/Coord/Parallel/ParallelCoord.cs b/Runtime/Coord/Parallel/ParallelCoord.cs
index 7219edc9..73147bc5 100644
--- a/Runtime/Coord/Parallel/ParallelCoord.cs
+++ b/Runtime/Coord/Parallel/ParallelCoord.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
diff --git a/Runtime/Coord/Parallel/ParallelCoordContext.cs b/Runtime/Coord/Parallel/ParallelCoordContext.cs
index 2901f84f..1d545f90 100644
--- a/Runtime/Coord/Parallel/ParallelCoordContext.cs
+++ b/Runtime/Coord/Parallel/ParallelCoordContext.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
diff --git a/Runtime/Coord/Parallel/ParallelCoordHandler.cs b/Runtime/Coord/Parallel/ParallelCoordHandler.cs
index 83633611..315e4779 100644
--- a/Runtime/Coord/Parallel/ParallelCoordHandler.cs
+++ b/Runtime/Coord/Parallel/ParallelCoordHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -19,7 +18,7 @@ namespace XCharts.Runtime
{
var grid = component;
grid.painter = chart.painter;
- grid.refreshComponent = delegate ()
+ grid.refreshComponent = delegate()
{
grid.UpdateRuntimeData(chart.chartX, chart.chartY, chart.chartWidth, chart.chartHeight);
chart.OnCoordinateChanged();
@@ -154,10 +153,10 @@ namespace XCharts.Runtime
var tempMinValue = m_SerieDimMin[i];
var tempMaxValue = m_SerieDimMax[i];
- if (tempMinValue != axis.context.minValue
- || tempMaxValue != axis.context.maxValue
- || m_LastInterval != axis.interval
- || m_LastSplitNumber != axis.splitNumber)
+ if (tempMinValue != axis.context.minValue ||
+ tempMaxValue != axis.context.maxValue ||
+ m_LastInterval != axis.interval ||
+ m_LastSplitNumber != axis.splitNumber)
{
m_LastSplitNumber = axis.splitNumber;
m_LastInterval = axis.interval;
diff --git a/Runtime/Coord/Polar/PolarCoord.cs b/Runtime/Coord/Polar/PolarCoord.cs
index f8dc0843..b251c932 100644
--- a/Runtime/Coord/Polar/PolarCoord.cs
+++ b/Runtime/Coord/Polar/PolarCoord.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -20,7 +19,6 @@ namespace XCharts.Runtime
public PolarCoordContext context = new PolarCoordContext();
-
///
/// Whether to show the polor component.
/// |是否显示极坐标。
diff --git a/Runtime/Coord/Polar/PolarCoordContext.cs b/Runtime/Coord/Polar/PolarCoordContext.cs
index 20b67c4e..035c2ca9 100644
--- a/Runtime/Coord/Polar/PolarCoordContext.cs
+++ b/Runtime/Coord/Polar/PolarCoordContext.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
diff --git a/Runtime/Coord/Polar/PolarCoordHandler.cs b/Runtime/Coord/Polar/PolarCoordHandler.cs
index a635dd8e..7c176a87 100644
--- a/Runtime/Coord/Polar/PolarCoordHandler.cs
+++ b/Runtime/Coord/Polar/PolarCoordHandler.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
using UnityEngine.UI;
@@ -24,7 +23,6 @@ namespace XCharts.Runtime
DrawPolar(vh, component);
}
-
private void DrawPolar(VertexHelper vh, PolarCoord polar)
{
PolarHelper.UpdatePolarCenter(polar, chart.chartPosition, chart.chartWidth, chart.chartHeight);
diff --git a/Runtime/Coord/Polar/PolarHelper.cs b/Runtime/Coord/Polar/PolarHelper.cs
index f0aec3a3..fa51a52a 100644
--- a/Runtime/Coord/Polar/PolarHelper.cs
+++ b/Runtime/Coord/Polar/PolarHelper.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
diff --git a/Runtime/Coord/SingleAxis/SingleAxisCoord.cs b/Runtime/Coord/SingleAxis/SingleAxisCoord.cs
index 051f0d8e..990ebe36 100644
--- a/Runtime/Coord/SingleAxis/SingleAxisCoord.cs
+++ b/Runtime/Coord/SingleAxis/SingleAxisCoord.cs
@@ -1,4 +1,3 @@
-
using System;
namespace XCharts.Runtime
@@ -6,6 +5,5 @@ namespace XCharts.Runtime
[Serializable]
[ComponentHandler(null)]
public class SingleAxisCoord : CoordSystem
- {
- }
+ { }
}
\ No newline at end of file
diff --git a/Runtime/Helper/CheckHelper.cs b/Runtime/Helper/CheckHelper.cs
index 65359132..8ccd886a 100644
--- a/Runtime/Helper/CheckHelper.cs
+++ b/Runtime/Helper/CheckHelper.cs
@@ -12,7 +12,7 @@ namespace XCharts.Runtime
public static string CheckChart(BaseGraph chart)
{
- if (chart is BaseChart) return CheckChart((BaseChart)chart);
+ if (chart is BaseChart) return CheckChart((BaseChart) chart);
else return string.Empty;
}
@@ -68,12 +68,10 @@ namespace XCharts.Runtime
}
private static void CheckLegend(BaseChart chart, StringBuilder sb)
- {
- }
+ { }
private static void CheckGrid(BaseChart chart, StringBuilder sb)
- {
- }
+ { }
private static void CheckSerie(BaseChart chart, StringBuilder sb)
{
@@ -121,11 +119,6 @@ namespace XCharts.Runtime
if (IsColorAlphaZero(serie.lineStyle.color))
sb.AppendFormat("warning:serie {0} lineStyle->color alpha is 0\n", serie.index);
}
- else if (serie is Bar)
- {
- if (serie.barWidth == 0)
- sb.AppendFormat("warning:serie {0} barWidth is 0\n", serie.index);
- }
else if (serie is Pie)
{
if (serie.radius.Length >= 2 && serie.radius[1] == 0)
diff --git a/Runtime/Helper/FormatterHelper.cs b/Runtime/Helper/FormatterHelper.cs
index b0d63a31..06490eb5 100644
--- a/Runtime/Helper/FormatterHelper.cs
+++ b/Runtime/Helper/FormatterHelper.cs
@@ -1,15 +1,14 @@
-
+using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
-using System.Linq;
namespace XCharts.Runtime
{
public static class FormatterHelper
{
public const string PH_NN = "\n";
- private static Regex s_Regex = new Regex(@"{([a-e|.]\d*)(:\d+(-\d+)?)?(:[c-g|x|p|r]\d*|:0\.#*)?}", RegexOptions.IgnoreCase);
+ private static Regex s_Regex = new Regex(@"{([a-g|.]\d*)(:\d+(-\d+)?)?(:[c-g|x|p|r]\d*|:0\.#*)?}", RegexOptions.IgnoreCase);
private static Regex s_RegexSub = new Regex(@"(0\.#*)|(\d+-\d+)|(\w+)|(\.)", RegexOptions.IgnoreCase);
private static Regex s_RegexN = new Regex(@"^\d+", RegexOptions.IgnoreCase);
private static Regex s_RegexN_N = new Regex(@"\d+-\d+", RegexOptions.IgnoreCase);
@@ -17,11 +16,16 @@ namespace XCharts.Runtime
private static Regex s_RegexNewLine = new Regex(@"[\\|/]+n||
|
", RegexOptions.IgnoreCase);
private static Regex s_RegexForAxisLabel = new Regex(@"{value(:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase);
private static Regex s_RegexSubForAxisLabel = new Regex(@"(value)|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
- private static Regex s_RegexForSerieLabel = new Regex(@"{[a-e|\.](:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase);
- private static Regex s_RegexSubForSerieLabel = new Regex(@"(\.)|([a-e])|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
+ private static Regex s_RegexForSerieLabel = new Regex(@"{[a-g|\.](:[c-g|x|p|r]\d*)?}", RegexOptions.IgnoreCase);
+ private static Regex s_RegexSubForSerieLabel = new Regex(@"(\.)|([a-g])|([c-g|x|p|r]\d*)", RegexOptions.IgnoreCase);
+
+ public static bool NeedFormat(string content)
+ {
+ return content.IndexOf('{') >= 0;
+ }
///
- /// 替换字符串中的通配符,支持的通配符有{.}、{a}、{b}、{c}、{d}、{e}。
+ /// 替换字符串中的通配符,支持的通配符有{.}、{a}、{b}、{c}、{d}、{e}、{f}、{g}。
///
/// 要替换的字符串
/// 选中的数据项serieData索引
@@ -98,9 +102,14 @@ namespace XCharts.Runtime
content = content.Replace(old, serieData.name);
}
}
- else if (p == 'c' || p == 'C' || p == 'd' || p == 'D')
+ else if (p == 'g' || p == 'G')
+ {
+ content = content.Replace(old, ChartCached.NumberToStr(serie.dataCount, ""));
+ }
+ else if (p == 'c' || p == 'C' || p == 'd' || p == 'D' || p == 'f' || p == 'f')
{
var isPercent = p == 'd' || p == 'D';
+ var isTotal = p == 'f' || p == 'f';
var bIndex = dataIndex;
var dimensionIndex = -1;
if (argsCount >= 2)
@@ -133,7 +142,7 @@ namespace XCharts.Runtime
if (dimensionIndex == -1) dimensionIndex = 1;
if (numericFormatter == string.Empty)
{
- numericFormatter = SerieHelper.GetNumericFormatter(serie, serie.GetSerieData(bIndex));
+ numericFormatter = SerieHelper.GetNumericFormatter(serie, serie.GetSerieData(bIndex), "");
}
var value = serie.GetData(bIndex, dimensionIndex, dataZoom);
if (isPercent)
@@ -142,6 +151,11 @@ namespace XCharts.Runtime
var percent = total == 0 ? 0 : value / serie.yTotal * 100;
content = content.Replace(old, ChartCached.FloatToStr(percent, numericFormatter));
}
+ else if (isTotal)
+ {
+ var total = serie.GetDataTotal(dimensionIndex, serie.GetSerieData(bIndex));
+ content = content.Replace(old, ChartCached.FloatToStr(total, numericFormatter));
+ }
else
{
content = content.Replace(old, ChartCached.FloatToStr(value, numericFormatter));
@@ -152,6 +166,58 @@ namespace XCharts.Runtime
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)
+ {
+ var mc = s_RegexForSerieLabel.Matches(content);
+ foreach (var m in mc)
+ {
+ var old = m.ToString();
+ var args = s_RegexSubForSerieLabel.Matches(old);
+ var argsCount = args.Count;
+ if (argsCount <= 0) continue;
+ var p = args[0].ToString().ElementAt(0);
+ if (argsCount >= 2)
+ {
+ numericFormatter = args[1].ToString();
+ }
+ if (p == '.')
+ {
+ content = content.Replace(old, ChartCached.ColorToDotStr(color));
+ }
+ else if (p == 'a' || p == 'A')
+ {
+ content = content.Replace(old, serieName);
+ }
+ else if (p == 'b' || p == 'B')
+ {
+ content = content.Replace(old, category);
+ }
+ else if (p == 'e' || p == 'E')
+ {
+ content = content.Replace(old, dataName);
+ }
+ else if (p == 'd' || p == 'D')
+ {
+ var rate = total == 0 ? 0 : value / total * 100;
+ content = content.Replace(old, ChartCached.NumberToStr(rate, numericFormatter));
+ }
+ else if (p == 'c' || p == 'C')
+ {
+ content = content.Replace(old, ChartCached.NumberToStr(value, numericFormatter));
+ }
+ else if (p == 'f' || p == 'f')
+ {
+ content = content.Replace(old, ChartCached.NumberToStr(total, numericFormatter));
+ }
+ else if (p == 'g' || p == 'G')
+ {
+ content = content.Replace(old, ChartCached.NumberToStr(dataCount, numericFormatter));
+ }
+ }
+ content = TrimAndReplaceLine(content);
+ }
+
private static char GetSerieIndex(string strType, ref int index)
{
index = -1;
@@ -207,48 +273,5 @@ namespace XCharts.Runtime
content = TrimAndReplaceLine(content);
}
- public static void ReplaceSerieLabelContent(ref string content, string numericFormatter, double value, double total,
- string serieName, string category, string dataName, Color color)
- {
- var mc = s_RegexForSerieLabel.Matches(content);
- foreach (var m in mc)
- {
- var old = m.ToString();
- var args = s_RegexSubForSerieLabel.Matches(old);
- var argsCount = args.Count;
- if (argsCount <= 0) continue;
- var p = args[0].ToString().ElementAt(0);
- if (argsCount >= 2)
- {
- numericFormatter = args[1].ToString();
- }
- if (p == '.')
- {
- content = content.Replace(old, ChartCached.ColorToDotStr(color));
- }
- else if (p == 'a' || p == 'A')
- {
- content = content.Replace(old, serieName);
- }
- else if (p == 'b' || p == 'B')
- {
- content = content.Replace(old, category);
- }
- else if (p == 'e' || p == 'E')
- {
- content = content.Replace(old, dataName);
- }
- else if (p == 'd' || p == 'D')
- {
- var rate = total == 0 ? 0 : value / total * 100;
- content = content.Replace(old, ChartCached.FloatToStr(rate, numericFormatter));
- }
- else if (p == 'c' || p == 'C')
- {
- content = content.Replace(old, ChartCached.FloatToStr(value, numericFormatter));
- }
- }
- content = TrimAndReplaceLine(content);
- }
}
}
\ No newline at end of file
diff --git a/Runtime/Helper/SerieHelper.cs b/Runtime/Helper/SerieHelper.cs
index 3f875f9b..2000726e 100644
--- a/Runtime/Helper/SerieHelper.cs
+++ b/Runtime/Helper/SerieHelper.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using System.Reflection;
@@ -167,9 +166,9 @@ namespace XCharts.Runtime
{
var count = 0;
if (dimension > 0) count = dimension;
- else count = serie.showDataDimension > serieData.data.Count
- ? serieData.data.Count
- : serie.showDataDimension;
+ else count = serie.showDataDimension > serieData.data.Count ?
+ serieData.data.Count :
+ serie.showDataDimension;
for (int j = 0; j < count; j++)
{
var value = serieData.data[j];
@@ -275,7 +274,7 @@ namespace XCharts.Runtime
return color;
}
- public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight)
+ public static Color32 GetItemColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true)
{
if (serie == null)
return ChartConst.clearColor32;
@@ -286,14 +285,14 @@ namespace XCharts.Runtime
if (itemStyle == null)
itemStyle = GetItemStyle(serie, serieData);
- var color = ChartHelper.IsClearColor(itemStyle.color)
- ? theme.GetColor(index)
- : itemStyle.color;
+ var color = ChartHelper.IsClearColor(itemStyle.color) ?
+ theme.GetColor(index) :
+ itemStyle.color;
if (highlight)
color = ChartHelper.GetHighlightColor(color);
-
- ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
+ if (opacity)
+ ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
return color;
}
public static Color32 GetItemColor0(Serie serie, SerieData serieData, ThemeStyle theme, bool highlight, Color32 defaultColor)
@@ -307,9 +306,9 @@ namespace XCharts.Runtime
if (itemStyle == null)
itemStyle = GetItemStyle(serie, serieData);
- var color = ChartHelper.IsClearColor(itemStyle.color0)
- ? defaultColor
- : itemStyle.color0;
+ var color = ChartHelper.IsClearColor(itemStyle.color0) ?
+ defaultColor :
+ itemStyle.color0;
if (highlight)
color = ChartHelper.GetHighlightColor(color);
@@ -318,7 +317,7 @@ namespace XCharts.Runtime
return color;
}
- public static Color32 GetItemToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight)
+ public static Color32 GetItemToColor(Serie serie, SerieData serieData, ThemeStyle theme, int index, bool highlight, bool opacity = true)
{
if (serie == null)
return ChartConst.clearColor32;
@@ -332,15 +331,16 @@ namespace XCharts.Runtime
var color = itemStyle.toColor;
if (ChartHelper.IsClearColor(color))
{
- color = ChartHelper.IsClearColor(itemStyle.color)
- ? theme.GetColor(index)
- : itemStyle.color;
+ color = ChartHelper.IsClearColor(itemStyle.color) ?
+ theme.GetColor(index) :
+ itemStyle.color;
}
if (highlight)
color = ChartHelper.GetHighlightColor(color);
- ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
+ if (opacity)
+ ChartHelper.SetColorOpacity(ref color, itemStyle.opacity);
return color;
}
@@ -385,9 +385,9 @@ namespace XCharts.Runtime
public static ItemStyle GetItemStyleEmphasis(Serie serie, SerieData serieData)
{
- if (!serie.IsPerformanceMode() && serieData != null && serieData.emphasis != null && serieData.emphasis.show)
- return serieData.emphasis.itemStyle;
- else if (serie.emphasis != null && serie.emphasis.show) return serie.emphasis.itemStyle;
+ if (!serie.IsPerformanceMode() && serieData != null && serieData.emphasisItemStyle != null && serieData.emphasisItemStyle.show)
+ return serieData.emphasisItemStyle;
+ else if (serie.emphasisItemStyle != null && serie.emphasisItemStyle.show) return serie.emphasisItemStyle;
else return null;
}
@@ -396,9 +396,9 @@ namespace XCharts.Runtime
if (serieData == null) return serie.label;
if (highlight)
{
- if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)
- return serieData.emphasis.label;
- else if (serie.emphasis != null && serie.emphasis.show) return serie.emphasis.label;
+ if (!serie.IsPerformanceMode() && serieData.emphasisLabel != null && serieData.emphasisLabel.show)
+ return serieData.emphasisLabel;
+ else if (serie.emphasisLabel != null && serie.emphasisLabel.show) return serie.emphasisLabel;
else return serie.label;
}
else
@@ -410,9 +410,9 @@ namespace XCharts.Runtime
public static LabelStyle GetSerieEmphasisLabel(Serie serie, SerieData serieData)
{
- if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)
- return serieData.emphasis.label;
- else if (serie.emphasis != null && serie.emphasis.show) return serie.emphasis.label;
+ if (!serie.IsPerformanceMode() && serieData.emphasisLabel != null && serieData.emphasisLabel.show)
+ return serieData.emphasisLabel;
+ else if (serie.emphasisLabel != null && serie.emphasisLabel.show) return serie.emphasisLabel;
else return null;
}
@@ -420,9 +420,9 @@ namespace XCharts.Runtime
{
if (highlight)
{
- if (!serie.IsPerformanceMode() && serieData.emphasis != null && serieData.emphasis.show)
- return serieData.emphasis.labelLine;
- else if (serie.emphasis != null && serie.emphasis.show) return serie.emphasis.labelLine;
+ if (!serie.IsPerformanceMode() && serieData.emphasisLabelLine != null && serieData.emphasisLabelLine.show)
+ return serieData.emphasisLabelLine;
+ else if (serie.emphasisLabelLine != null && serie.emphasisLabelLine.show) return serie.emphasisLabelLine;
else return serie.labelLine;
}
else
@@ -648,8 +648,8 @@ namespace XCharts.Runtime
var endValue = min + (max - min) * dataZoom.end / 100;
if (endValue < startValue) endValue = startValue;
- if (startValue != serie.m_FilterStartValue || endValue != serie.m_FilterEndValue
- || dataZoom.minShowNum != serie.m_FilterMinShow || serie.m_NeedUpdateFilterData)
+ if (startValue != serie.m_FilterStartValue || endValue != serie.m_FilterEndValue ||
+ dataZoom.minShowNum != serie.m_FilterMinShow || serie.m_NeedUpdateFilterData)
{
serie.m_FilterStartValue = startValue;
serie.m_FilterEndValue = endValue;
@@ -690,8 +690,8 @@ namespace XCharts.Runtime
end = start + range;
if (end > data.Count) end = data.Count;
}
- if (start != serie.m_FilterStart || end != serie.m_FilterEnd
- || dataZoom.minShowNum != serie.m_FilterMinShow || serie.m_NeedUpdateFilterData)
+ if (start != serie.m_FilterStart || end != serie.m_FilterEnd ||
+ dataZoom.minShowNum != serie.m_FilterMinShow || serie.m_NeedUpdateFilterData)
{
serie.m_FilterStart = start;
serie.m_FilterEnd = end;
@@ -733,7 +733,7 @@ namespace XCharts.Runtime
switch (serie.dataSortType)
{
case SerieDataSortType.Ascending:
- serie.context.sortedData.Sort(delegate (SerieData data1, SerieData data2)
+ serie.context.sortedData.Sort(delegate(SerieData data1, SerieData data2)
{
var value1 = data1.GetData(1);
var value2 = data2.GetData(1);
@@ -743,7 +743,7 @@ namespace XCharts.Runtime
});
break;
case SerieDataSortType.Descending:
- serie.context.sortedData.Sort(delegate (SerieData data1, SerieData data2)
+ serie.context.sortedData.Sort(delegate(SerieData data1, SerieData data2)
{
var value1 = data1.GetData(1);
var value2 = data2.GetData(1);
diff --git a/Runtime/Helper/SerieLabelHelper.cs b/Runtime/Helper/SerieLabelHelper.cs
index bcf32f48..fc189a1f 100644
--- a/Runtime/Helper/SerieLabelHelper.cs
+++ b/Runtime/Helper/SerieLabelHelper.cs
@@ -52,7 +52,7 @@ namespace XCharts.Runtime
else
{
var content = serieLabel.formatter;
- FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, dataValue,
+ FormatterHelper.ReplaceSerieLabelContent(ref content, numericFormatter, serie.dataCount, dataValue,
dataTotal, serieName, dataName, dataName, color);
return content;
}
@@ -166,8 +166,8 @@ namespace XCharts.Runtime
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
var fontSize = serieLabel.textStyle.GetFontSize(theme);
- var isOutside = serieLabel.position == LabelStyle.Position.Outside
- || serieLabel.position == LabelStyle.Position.Default;
+ var isOutside = serieLabel.position == LabelStyle.Position.Outside ||
+ serieLabel.position == LabelStyle.Position.Default;
if (!serieLabel.show) return;
if (!isOutside) return;
if (lastCheckPos == Vector3.zero)
@@ -196,8 +196,8 @@ namespace XCharts.Runtime
{
if (label == null || labelLine == null)
return serieData.context.labelPosition;
- var isOutside = label.position == LabelStyle.Position.Outside
- || label.position == LabelStyle.Position.Default;
+ var isOutside = label.position == LabelStyle.Position.Outside ||
+ label.position == LabelStyle.Position.Default;
if (isOutside && labelLine.lineType != LabelLine.LineType.HorizontalLine)
{
var currAngle = serieData.context.halfAngle;
diff --git a/Runtime/Helper/SeriesHelper.cs b/Runtime/Helper/SeriesHelper.cs
index 8296ed8b..09be09c1 100644
--- a/Runtime/Helper/SeriesHelper.cs
+++ b/Runtime/Helper/SeriesHelper.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -340,9 +339,10 @@ namespace XCharts.Runtime
for (int i = 0; i < series.Count; i++)
{
var serie = series[i];
- if ((isPolar && serie.polarIndex != axisIndex)
- || (!isPolar && serie.yAxisIndex != axisIndex)
- || !serie.show) continue;
+ if ((isPolar && serie.polarIndex != axisIndex) ||
+ (!isPolar && serie.yAxisIndex != axisIndex) ||
+ !serie.show) continue;
+ var updateDuration = serie.animation.enable?serie.animation.dataChangeDuration : 0;
if (isPercentStack && SeriesHelper.IsPercentStack(series, serie.serieName))
{
if (100 > max) max = 100;
@@ -363,7 +363,8 @@ namespace XCharts.Runtime
}
else
{
- var currData = data.GetData(yValue ? 1 : 0, inverse);
+ //var currData = data.GetData(yValue ? 1 : 0, inverse);
+ var currData = data.GetCurrData(yValue ? 1 : 0, updateDuration, inverse);
if (!serie.IsIgnoreValue(currData))
{
if (currData > max) max = currData;
@@ -383,9 +384,9 @@ namespace XCharts.Runtime
for (int i = 0; i < ss.Value.Count; i++)
{
var serie = ss.Value[i];
- if ((isPolar && serie.polarIndex != axisIndex)
- || (!isPolar && serie.yAxisIndex != axisIndex)
- || !serie.show) continue;
+ if ((isPolar && serie.polarIndex != axisIndex) ||
+ (!isPolar && serie.yAxisIndex != axisIndex) ||
+ !serie.show) continue;
var showData = serie.GetDataList(dataZoom);
if (SeriesHelper.IsPercentStack(series, serie.stack))
{
diff --git a/Runtime/I18n/Lang.cs b/Runtime/I18n/Lang.cs
index 4da92071..eb62484b 100644
--- a/Runtime/I18n/Lang.cs
+++ b/Runtime/I18n/Lang.cs
@@ -1,7 +1,6 @@
-
+using System;
using System.Collections.Generic;
using UnityEngine;
-using System;
namespace XCharts.Runtime
{
@@ -44,16 +43,90 @@ namespace XCharts.Runtime
[Serializable]
public class LangTime
{
- public List months = new List() {
- "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
- public List monthAbbr = new List(){
- "Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
- public List dayOfMonth = new List() {
- "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25","26","27","28","29","30","31"};
- public List dayOfWeek = new List() {
- "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
- public List dayOfWeekAbbr = new List() {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+ public List months = new List()
+ {
+ "January",
+ "February",
+ "March",
+ "April",
+ "May",
+ "June",
+ "July",
+ "August",
+ "September",
+ "October",
+ "November",
+ "December"
+ };
+ public List monthAbbr = new List()
+ {
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec"
+ };
+ public List dayOfMonth = new List()
+ {
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "15",
+ "16",
+ "17",
+ "18",
+ "19",
+ "20",
+ "21",
+ "22",
+ "23",
+ "24",
+ "25",
+ "26",
+ "27",
+ "28",
+ "29",
+ "30",
+ "31"
+ };
+ public List dayOfWeek = new List()
+ {
+ "Sunday",
+ "Monday",
+ "Tuesday",
+ "Wednesday",
+ "Thursday",
+ "Friday",
+ "Saturday"
+ };
+ public List dayOfWeekAbbr = new List()
+ {
+ "Sun",
+ "Mon",
+ "Tue",
+ "Wed",
+ "Thu",
+ "Fri",
+ "Sat"
+ };
}
[Serializable]
diff --git a/Runtime/Internal/Attributes/ListForComponentAttribute.cs b/Runtime/Internal/Attributes/ListForComponentAttribute.cs
index 4267b483..52a98811 100644
--- a/Runtime/Internal/Attributes/ListForComponentAttribute.cs
+++ b/Runtime/Internal/Attributes/ListForComponentAttribute.cs
@@ -6,7 +6,6 @@ namespace XCharts.Runtime
public sealed class ListForComponent : ListFor
{
public ListForComponent(Type type) : base(type)
- {
- }
+ { }
}
}
\ No newline at end of file
diff --git a/Runtime/Internal/Attributes/ListForSerieAttribute.cs b/Runtime/Internal/Attributes/ListForSerieAttribute.cs
index f7a62bf8..07bcf23d 100644
--- a/Runtime/Internal/Attributes/ListForSerieAttribute.cs
+++ b/Runtime/Internal/Attributes/ListForSerieAttribute.cs
@@ -6,7 +6,6 @@ namespace XCharts.Runtime
public sealed class ListForSerie : ListFor
{
public ListForSerie(Type type) : base(type)
- {
- }
+ { }
}
}
\ No newline at end of file
diff --git a/Runtime/Internal/Attributes/SerieDataExtraComponentAttribute.cs b/Runtime/Internal/Attributes/SerieDataExtraComponentAttribute.cs
new file mode 100644
index 00000000..cd163795
--- /dev/null
+++ b/Runtime/Internal/Attributes/SerieDataExtraComponentAttribute.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+
+namespace XCharts.Runtime
+{
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
+ public sealed class SerieDataExtraComponentAttribute : Attribute
+ {
+ public readonly List types = new List();
+
+ public SerieDataExtraComponentAttribute()
+ { }
+ public SerieDataExtraComponentAttribute(Type type1)
+ {
+ AddType(type1);
+ }
+ public SerieDataExtraComponentAttribute(Type type1, Type type2)
+ {
+ AddType(type1);
+ AddType(type2);
+ }
+ public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3)
+ {
+ AddType(type1);
+ AddType(type2);
+ AddType(type3);
+ }
+ public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4)
+ {
+ AddType(type1);
+ AddType(type2);
+ AddType(type3);
+ AddType(type4);
+ }
+ public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5)
+ {
+ AddType(type1);
+ AddType(type2);
+ AddType(type3);
+ AddType(type4);
+ AddType(type5);
+ }
+ public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6)
+ {
+ AddType(type1);
+ AddType(type2);
+ AddType(type3);
+ AddType(type4);
+ AddType(type5);
+ AddType(type6);
+ }
+ public SerieDataExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6, Type type7)
+ {
+ AddType(type1);
+ AddType(type2);
+ AddType(type3);
+ AddType(type4);
+ AddType(type5);
+ AddType(type6);
+ AddType(type7);
+ }
+
+ private void AddType(Type type)
+ {
+ if (!SerieData.extraComponentMap.ContainsKey(type))
+ throw new ArgumentException("SerieData not support extra component:" + type);
+ types.Add(type);
+ }
+
+ public bool Contains() where T : ISerieExtraComponent
+ {
+ return Contains(typeof(T));
+ }
+
+ public bool Contains(Type type)
+ {
+ return types.Contains(type);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Internal/Attributes/SerieDataExtraComponentAttribute.cs.meta b/Runtime/Internal/Attributes/SerieDataExtraComponentAttribute.cs.meta
new file mode 100644
index 00000000..43120ee7
--- /dev/null
+++ b/Runtime/Internal/Attributes/SerieDataExtraComponentAttribute.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: a77e2e342c09c4c6b95a0094ad0fcffc
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Internal/Attributes/SerieDataExtraFieldAttribute.cs b/Runtime/Internal/Attributes/SerieDataExtraFieldAttribute.cs
new file mode 100644
index 00000000..12e2c3f6
--- /dev/null
+++ b/Runtime/Internal/Attributes/SerieDataExtraFieldAttribute.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+
+namespace XCharts.Runtime
+{
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
+ public sealed class SerieDataExtraFieldAttribute : Attribute
+ {
+ public readonly List fields = new List();
+
+ public SerieDataExtraFieldAttribute()
+ { }
+ public SerieDataExtraFieldAttribute(string field1)
+ {
+ AddFiled(field1);
+ }
+ public SerieDataExtraFieldAttribute(string field1, string field2)
+ {
+ AddFiled(field1);
+ AddFiled(field2);
+ }
+ public SerieDataExtraFieldAttribute(string field1, string field2, string field3)
+ {
+ AddFiled(field1);
+ AddFiled(field2);
+ AddFiled(field3);
+ }
+ public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4)
+ {
+ AddFiled(field1);
+ AddFiled(field2);
+ AddFiled(field3);
+ AddFiled(field4);
+ }
+ public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5)
+ {
+ AddFiled(field1);
+ AddFiled(field2);
+ AddFiled(field3);
+ AddFiled(field4);
+ AddFiled(field5);
+ }
+ public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6)
+ {
+ AddFiled(field1);
+ AddFiled(field2);
+ AddFiled(field3);
+ AddFiled(field4);
+ AddFiled(field5);
+ AddFiled(field6);
+ }
+ public SerieDataExtraFieldAttribute(string field1, string field2, string field3, string field4, string field5, string field6, string field7)
+ {
+ AddFiled(field1);
+ AddFiled(field2);
+ AddFiled(field3);
+ AddFiled(field4);
+ AddFiled(field5);
+ AddFiled(field6);
+ AddFiled(field7);
+ }
+
+ private void AddFiled(string field)
+ {
+ if (!SerieData.extraFieldList.Contains(field))
+ throw new ArgumentException("SerieData not support field:" + field);
+ fields.Add(field);
+ }
+
+ public bool Contains(string field)
+ {
+ return fields.Contains(field);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Runtime/Internal/Attributes/SerieDataExtraFieldAttribute.cs.meta b/Runtime/Internal/Attributes/SerieDataExtraFieldAttribute.cs.meta
new file mode 100644
index 00000000..216bf908
--- /dev/null
+++ b/Runtime/Internal/Attributes/SerieDataExtraFieldAttribute.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: c8b0cc5a1c11e497abb7e32c7d14b25f
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Runtime/Internal/Attributes/SerieExtraComponentAttribute.cs b/Runtime/Internal/Attributes/SerieExtraComponentAttribute.cs
index 77ded703..f4cb9cea 100644
--- a/Runtime/Internal/Attributes/SerieExtraComponentAttribute.cs
+++ b/Runtime/Internal/Attributes/SerieExtraComponentAttribute.cs
@@ -9,56 +9,62 @@ namespace XCharts.Runtime
public readonly List types = new List();
public SerieExtraComponentAttribute()
- {
- }
+ { }
public SerieExtraComponentAttribute(Type type1)
{
- types.Add(type1);
+ AddType(type1);
}
public SerieExtraComponentAttribute(Type type1, Type type2)
{
- types.Add(type1);
- types.Add(type2);
+ AddType(type1);
+ AddType(type2);
}
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3)
{
- types.Add(type1);
- types.Add(type2);
- types.Add(type3);
+ AddType(type1);
+ AddType(type2);
+ AddType(type3);
}
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4)
{
- types.Add(type1);
- types.Add(type2);
- types.Add(type3);
- types.Add(type4);
+ AddType(type1);
+ AddType(type2);
+ AddType(type3);
+ AddType(type4);
}
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5)
{
- types.Add(type1);
- types.Add(type2);
- types.Add(type3);
- types.Add(type4);
- types.Add(type5);
+ AddType(type1);
+ AddType(type2);
+ AddType(type3);
+ AddType(type4);
+ AddType(type5);
}
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6)
{
- types.Add(type1);
- types.Add(type2);
- types.Add(type3);
- types.Add(type4);
- types.Add(type5);
- types.Add(type6);
+ AddType(type1);
+ AddType(type2);
+ AddType(type3);
+ AddType(type4);
+ AddType(type5);
+ AddType(type6);
}
public SerieExtraComponentAttribute(Type type1, Type type2, Type type3, Type type4, Type type5, Type type6, Type type7)
{
- types.Add(type1);
- types.Add(type2);
- types.Add(type3);
- types.Add(type4);
- types.Add(type5);
- types.Add(type6);
- types.Add(type7);
+ AddType(type1);
+ AddType(type2);
+ AddType(type3);
+ AddType(type4);
+ AddType(type5);
+ AddType(type6);
+ AddType(type7);
+ }
+
+ private void AddType(Type type)
+ {
+ if (!Serie.extraComponentMap.ContainsKey(type))
+ throw new ArgumentException("Serie not support extra component:" + type);
+ types.Add(type);
}
public bool Contains() where T : ISerieExtraComponent
diff --git a/Runtime/Internal/Attributes/SerieHandlerAttribute.cs b/Runtime/Internal/Attributes/SerieHandlerAttribute.cs
index f4b421b1..1bd21e73 100644
--- a/Runtime/Internal/Attributes/SerieHandlerAttribute.cs
+++ b/Runtime/Internal/Attributes/SerieHandlerAttribute.cs
@@ -8,7 +8,6 @@ namespace XCharts.Runtime
public readonly Type handler;
public readonly bool allowMultiple = true;
-
public SerieHandlerAttribute(Type handler)
{
this.handler = handler;
diff --git a/Runtime/Internal/BaseChart.API.cs b/Runtime/Internal/BaseChart.API.cs
index 1cba5dee..70771c55 100644
--- a/Runtime/Internal/BaseChart.API.cs
+++ b/Runtime/Internal/BaseChart.API.cs
@@ -1,8 +1,8 @@
-using UnityEngine;
-using System.Collections.Generic;
using System;
-using UnityEngine.UI;
+using System.Collections.Generic;
+using UnityEngine;
using UnityEngine.EventSystems;
+using UnityEngine.UI;
namespace XCharts.Runtime
{
@@ -100,7 +100,7 @@ namespace XCharts.Runtime
/// the callback function of click bar.
/// |点击柱形图柱条回调。参数:eventData, dataIndex
///
- public Action onPointerClickBar { set { m_OnPointerClickBar = value; m_ForceOpenRaycastTarget = true; } }
+ public Action onPointerClickBar { set { m_OnPointerClickBar = value; m_ForceOpenRaycastTarget = true; } get { return m_OnPointerClickBar; } }
///
/// 坐标轴变更数据索引时回调。参数:axis, dataIndex/dataValue
///
@@ -142,6 +142,8 @@ namespace XCharts.Runtime
serie.ResetInteract();
m_RefreshChart = true;
if (m_Painter) m_Painter.Refresh();
+ foreach (var painter in m_PainterList) painter.Refresh();
+ if (m_PainterTop) m_PainterTop.Refresh();
}
///
@@ -164,7 +166,6 @@ namespace XCharts.Runtime
RefreshPainter(serie);
}
-
///
/// Remove all series and legend data.
/// |It just emptying all of serie's data without emptying the list of series.
@@ -374,7 +375,7 @@ namespace XCharts.Runtime
public bool IsInChart(float x, float y)
{
if (x < m_ChartX || x > m_ChartX + m_ChartWidth ||
- y < m_ChartY || y > m_ChartY + m_ChartHeight)
+ y < m_ChartY || y > m_ChartY + m_ChartHeight)
{
return false;
}
@@ -527,9 +528,9 @@ namespace XCharts.Runtime
public Color32 GetItemColor(Serie serie, SerieData serieData, bool highlight = false)
{
- var colorIndex = serieData == null || !serie.useDataNameForColor
- ? GetLegendRealShowNameIndex(serie.legendName)
- : GetLegendRealShowNameIndex(serieData.legendName);
+ var colorIndex = serieData == null || !serie.useDataNameForColor ?
+ GetLegendRealShowNameIndex(serie.legendName) :
+ GetLegendRealShowNameIndex(serieData.legendName);
return SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
}
@@ -538,4 +539,4 @@ namespace XCharts.Runtime
return SerieHelper.GetItemColor(serie, null, m_Theme, serie.context.colorIndex, highlight);
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Internal/BaseChart.Component.cs b/Runtime/Internal/BaseChart.Component.cs
index c5bcb874..e7ef7b3c 100644
--- a/Runtime/Internal/BaseChart.Component.cs
+++ b/Runtime/Internal/BaseChart.Component.cs
@@ -1,7 +1,6 @@
-
-using UnityEngine;
-using System.Collections.Generic;
using System;
+using System.Collections.Generic;
+using UnityEngine;
namespace XCharts.Runtime
{
@@ -42,7 +41,7 @@ namespace XCharts.Runtime
public T AddChartComponent() where T : MainComponent
{
- return (T)AddChartComponent(typeof(T));
+ return (T) AddChartComponent(typeof(T));
}
public T AddChartComponentWhenNoExist() where T : MainComponent
@@ -119,7 +118,7 @@ namespace XCharts.Runtime
if (attrubte.handler == null)
return;
- var handler = (MainComponentHandler)Activator.CreateInstance(attrubte.handler);
+ var handler = (MainComponentHandler) Activator.CreateInstance(attrubte.handler);
handler.attribute = attrubte;
handler.chart = this;
handler.SetComponent(component);
@@ -128,13 +127,13 @@ namespace XCharts.Runtime
}
public bool RemoveChartComponent(int index = 0)
- where T : MainComponent
+ where T : MainComponent
{
return RemoveChartComponent(typeof(T), index);
}
public int RemoveChartComponents()
- where T : MainComponent
+ where T : MainComponent
{
return RemoveChartComponents(typeof(T));
}
@@ -196,7 +195,7 @@ namespace XCharts.Runtime
}
public bool HasChartComponent()
- where T : MainComponent
+ where T : MainComponent
{
return HasChartComponent(typeof(T));
}
@@ -256,14 +255,14 @@ namespace XCharts.Runtime
}
public bool TryGetChartComponent(out T component, int index = 0)
- where T : MainComponent
+ where T : MainComponent
{
component = null;
foreach (var com in m_Components)
{
if (com is T && com.index == index)
{
- component = (T)com;
+ component = (T) com;
return true;
}
}
@@ -402,11 +401,11 @@ namespace XCharts.Runtime
var yAxis = GetChartComponent();
if (yAxis.IsCategory())
{
- return yAxis.GetData((int)yAxis.context.pointerValue, dataZoom);
+ return yAxis.GetData((int) yAxis.context.pointerValue, dataZoom);
}
else if (xAxis.IsCategory())
{
- return xAxis.GetData((int)xAxis.context.pointerValue, dataZoom);
+ return xAxis.GetData((int) xAxis.context.pointerValue, dataZoom);
}
return null;
}
@@ -416,13 +415,13 @@ namespace XCharts.Runtime
var yAxis = GetChartComponent(serie.yAxisIndex);
if (yAxis.IsCategory())
{
- return yAxis.GetData((int)yAxis.context.pointerValue, dataZoom);
+ return yAxis.GetData((int) yAxis.context.pointerValue, dataZoom);
}
else if (xAxis.IsCategory())
{
- return xAxis.GetData((int)xAxis.context.pointerValue, dataZoom);
+ return xAxis.GetData((int) xAxis.context.pointerValue, dataZoom);
}
return null;
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Internal/BaseChart.Custom.cs b/Runtime/Internal/BaseChart.Custom.cs
index addfee3f..cbd04dad 100644
--- a/Runtime/Internal/BaseChart.Custom.cs
+++ b/Runtime/Internal/BaseChart.Custom.cs
@@ -1,15 +1,13 @@
-
-using UnityEngine;
-using System.Collections.Generic;
using System;
+using System.Collections.Generic;
+using UnityEngine;
namespace XCharts.Runtime
{
public partial class BaseChart
{
public virtual void InitAxisRuntimeData(Axis axis)
- {
- }
+ { }
public virtual void GetSeriesMinMaxValue(Axis axis, int axisIndex, out double tempMinValue, out double tempMaxValue)
{
@@ -31,4 +29,4 @@ namespace XCharts.Runtime
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Internal/BaseChart.Draw.cs b/Runtime/Internal/BaseChart.Draw.cs
index 39fc132b..f23303be 100644
--- a/Runtime/Internal/BaseChart.Draw.cs
+++ b/Runtime/Internal/BaseChart.Draw.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
using XUGL;
@@ -35,13 +34,13 @@ namespace XCharts.Runtime
p3 = ClampInGrid(grid, p3);
p4 = ClampInGrid(grid, p4);
}
- if (!clip || (clip && (grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3)
- && grid.Contains(p4))))
+ if (!clip || (clip && (grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) &&
+ grid.Contains(p4))))
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, startColor, toColor);
}
public void DrawClipPolygon(VertexHelper vh, ref Vector3 p1, ref Vector3 p2, ref Vector3 p3, ref Vector3 p4,
- Color32 startColor, Color32 toColor, bool clip, GridCoord grid)
+ Color32 startColor, Color32 toColor, bool clip, GridCoord grid)
{
ClampInChart(ref p1);
ClampInChart(ref p2);
@@ -54,9 +53,9 @@ namespace XCharts.Runtime
p3 = ClampInGrid(grid, p3);
p4 = ClampInGrid(grid, p4);
}
- if (!clip
- || (clip && (grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3)
- && grid.Contains(p4))))
+ if (!clip ||
+ (clip && (grid.Contains(p1) && grid.Contains(p2) && grid.Contains(p3) &&
+ grid.Contains(p4))))
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, startColor, toColor);
}
@@ -132,4 +131,4 @@ namespace XCharts.Runtime
return Color32.Lerp(areaToColor, areaColor, (pos.x - grid.context.x) / grid.context.width);
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Internal/BaseChart.Serie.cs b/Runtime/Internal/BaseChart.Serie.cs
index 169d6a37..4fa95acf 100644
--- a/Runtime/Internal/BaseChart.Serie.cs
+++ b/Runtime/Internal/BaseChart.Serie.cs
@@ -1,8 +1,7 @@
-
-using UnityEngine;
-using System.Collections.Generic;
using System;
+using System.Collections.Generic;
using System.Reflection;
+using UnityEngine;
namespace XCharts.Runtime
{
@@ -320,6 +319,38 @@ namespace XCharts.Runtime
}
return null;
}
+ ///
+ /// Add a (time,y) data to serie.
+ /// |添加(time,y)数据到指定的系列中。
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public SerieData AddData(string serieName, DateTime time, double yValue, string dataName = null, string dataId = null)
+ {
+ var xValue = DateTimeUtil.GetTimestamp(time);
+ return AddData(serieName, xValue, yValue, dataName, dataId);
+ }
+
+ ///
+ /// Add a (time,y) data to serie.
+ /// |添加(time,y)数据到指定的系列中。
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public SerieData AddData(int serieIndex, DateTime time, double yValue, string dataName = null, string dataId = null)
+ {
+ var xValue = DateTimeUtil.GetTimestamp(time);
+ return AddData(serieIndex, xValue, yValue, dataName, dataId);
+ }
+
public SerieData AddData(int serieIndex, double open, double close, double lowest, double heighest, string dataName = null, string dataId = null)
{
var serie = GetSerie(serieIndex);
@@ -710,9 +741,30 @@ namespace XCharts.Runtime
return total;
}
+ public int GetSerieBarRealCount() where T : Serie
+ {
+ var count = 0;
+ barStackSet.Clear();
+ for (int i = 0; i < m_Series.Count; i++)
+ {
+ var serie = m_Series[i];
+ if (!serie.show) continue;
+ if (serie is T)
+ {
+ if (!string.IsNullOrEmpty(serie.stack))
+ {
+ if (barStackSet.Contains(serie.stack)) continue;
+ barStackSet.Add(serie.stack);
+ }
+ count++;
+
+ }
+ }
+ return count;
+ }
private HashSet barStackSet = new HashSet();
- public float GetSerieTotalWidth(float categoryWidth, float gap) where T : Serie
+ public float GetSerieTotalWidth(float categoryWidth, float gap, int realBarCount) where T : Serie
{
float total = 0;
float lastGap = 0;
@@ -728,14 +780,14 @@ namespace XCharts.Runtime
if (barStackSet.Contains(serie.stack)) continue;
barStackSet.Add(serie.stack);
}
- var width = GetStackBarWidth(categoryWidth, serie);
+ var width = GetStackBarWidth(categoryWidth, serie, realBarCount);
if (gap == -1)
{
if (width > total) total = width;
}
else
{
- lastGap = width * gap;
+ lastGap = ChartHelper.GetActualValue(gap, width);
total += width;
total += lastGap;
}
@@ -745,21 +797,65 @@ namespace XCharts.Runtime
return total;
}
- private float GetStackBarWidth(float categoryWidth, Serie now) where T : Serie
+ public float GetSerieTotalGap(float categoryWidth, float gap, int index) where T : Serie
{
- if (string.IsNullOrEmpty(now.stack)) return now.GetBarWidth(categoryWidth);
+ if (index <= 0) return 0;
+ float total = 0;
+ barStackSet.Clear();
+ var count = 0;
+ var totalRealBarCount = GetSerieBarRealCount();
+ for (int i = 0; i < m_Series.Count; i++)
+ {
+ var serie = m_Series[i];
+ if (!serie.show) continue;
+ if (serie is T)
+ {
+ if (!string.IsNullOrEmpty(serie.stack))
+ {
+ if (barStackSet.Contains(serie.stack)) continue;
+ barStackSet.Add(serie.stack);
+ }
+ var width = GetStackBarWidth(categoryWidth, serie, totalRealBarCount);
+ if (gap == -1)
+ {
+ if (width > total) total = width;
+ }
+ else
+ {
+ total += width + ChartHelper.GetActualValue(gap, width);
+ }
+ if (count + 1 >= index)
+ break;
+ else
+ count++;
+ }
+ }
+ return total;
+ }
+
+ private float GetStackBarWidth(float categoryWidth, Serie now, int realBarCount) where T : Serie
+ {
+ if (string.IsNullOrEmpty(now.stack)) return now.GetBarWidth(categoryWidth, realBarCount);
float barWidth = 0;
for (int i = 0; i < m_Series.Count; i++)
{
var serie = m_Series[i];
- if ((serie is T)
- && serie.show && now.stack.Equals(serie.stack))
+ if ((serie is T) &&
+ serie.show && now.stack.Equals(serie.stack))
{
if (serie.barWidth > barWidth) barWidth = serie.barWidth;
}
}
- if (barWidth > 1) return barWidth;
- else return barWidth * categoryWidth;
+ if (barWidth == 0)
+ {
+ var width = ChartHelper.GetActualValue(0.6f, categoryWidth);
+ if (realBarCount == 0)
+ return width < 1 ? categoryWidth : width;
+ else
+ return width / realBarCount;
+ }
+ else
+ return ChartHelper.GetActualValue(barWidth, categoryWidth);
}
private List tempList = new List();
@@ -816,7 +912,7 @@ namespace XCharts.Runtime
return;
}
var attribute = serie.GetType().GetAttribute();
- var handler = (SerieHandler)Activator.CreateInstance(attribute.handler);
+ var handler = (SerieHandler) Activator.CreateInstance(attribute.handler);
handler.attribute = attribute;
handler.chart = this;
handler.defaultDimension = 1;
@@ -886,4 +982,4 @@ namespace XCharts.Runtime
return false;
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs
index d0b29106..50b44db5 100644
--- a/Runtime/Internal/BaseChart.cs
+++ b/Runtime/Internal/BaseChart.cs
@@ -1,11 +1,10 @@
-
-using UnityEngine;
-using UnityEngine.UI;
-using System.Collections.Generic;
using System;
-using UnityEngine.EventSystems;
-using XUGL;
+using System.Collections.Generic;
using System.Reflection;
+using UnityEngine;
+using UnityEngine.EventSystems;
+using UnityEngine.UI;
+using XUGL;
namespace XCharts.Runtime
{
@@ -20,38 +19,39 @@ namespace XCharts.Runtime
[SerializeField] protected Settings m_Settings;
#pragma warning disable 0414
- [SerializeField] [ListForComponent(typeof(AngleAxis))] private List m_AngleAxes = new List();
- [SerializeField] [ListForComponent(typeof(Background))] private List m_Backgrounds = new List();
- [SerializeField] [ListForComponent(typeof(DataZoom))] private List m_DataZooms = new List();
- [SerializeField] [ListForComponent(typeof(GridCoord))] private List m_Grids = new List();
- [SerializeField] [ListForComponent(typeof(Legend))] private List
[Serializable]
public abstract class CoordSystem : MainComponent
- {
- }
+ { }
}
\ No newline at end of file
diff --git a/Runtime/Internal/Basic/MainComponent.cs b/Runtime/Internal/Basic/MainComponent.cs
index 06813aa3..a0834de1 100644
--- a/Runtime/Internal/Basic/MainComponent.cs
+++ b/Runtime/Internal/Basic/MainComponent.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Text;
using UnityEngine;
@@ -53,13 +52,9 @@ namespace XCharts.Runtime
m_ComponentDirty = false;
}
- public virtual void Reset()
- {
- }
+ public virtual void Reset() { }
- public virtual void ClearData()
- {
- }
+ public virtual void ClearData() { }
public virtual void ClearDirty()
{
@@ -73,9 +68,7 @@ namespace XCharts.Runtime
SetComponentDirty();
}
- public virtual void SetDefaultValue()
- {
- }
+ public virtual void SetDefaultValue() { }
public virtual void OnRemove()
{
@@ -104,6 +97,7 @@ namespace XCharts.Runtime
public virtual void Update() { }
public virtual void DrawBase(VertexHelper vh) { }
public virtual void DrawTop(VertexHelper vh) { }
+ public virtual void OnSerieDataUpdate(int serieIndex) { }
public virtual void OnPointerClick(PointerEventData eventData) { }
public virtual void OnPointerDown(PointerEventData eventData) { }
public virtual void OnPointerUp(PointerEventData eventData) { }
@@ -117,13 +111,13 @@ namespace XCharts.Runtime
}
public abstract class MainComponentHandler : MainComponentHandler
- where T : MainComponent
+ where T : MainComponent
{
public T component { get; internal set; }
internal override void SetComponent(MainComponent component)
{
- this.component = (T)component;
+ this.component = (T) component;
}
}
}
\ No newline at end of file
diff --git a/Runtime/Internal/Basic/MainComponentContext.cs b/Runtime/Internal/Basic/MainComponentContext.cs
index 32db105a..02e10f7e 100644
--- a/Runtime/Internal/Basic/MainComponentContext.cs
+++ b/Runtime/Internal/Basic/MainComponentContext.cs
@@ -1,4 +1,3 @@
-
namespace XCharts.Runtime
{
public class MainComponentContext
diff --git a/Runtime/Internal/Misc/DelegateFunction.cs b/Runtime/Internal/Misc/DelegateFunction.cs
index af6b57c3..3843ca28 100644
--- a/Runtime/Internal/Misc/DelegateFunction.cs
+++ b/Runtime/Internal/Misc/DelegateFunction.cs
@@ -1,5 +1,3 @@
-
-
using System.Collections.Generic;
using UnityEngine.UI;
diff --git a/Runtime/Internal/Misc/Enums.cs b/Runtime/Internal/Misc/Enums.cs
index adc794f0..f19d2d62 100644
--- a/Runtime/Internal/Misc/Enums.cs
+++ b/Runtime/Internal/Misc/Enums.cs
@@ -1,5 +1,3 @@
-
-
namespace XCharts.Runtime
{
///
diff --git a/Runtime/Internal/Misc/INeedSerieContainer.cs b/Runtime/Internal/Misc/INeedSerieContainer.cs
index ce29c61e..c979d5d9 100644
--- a/Runtime/Internal/Misc/INeedSerieContainer.cs
+++ b/Runtime/Internal/Misc/INeedSerieContainer.cs
@@ -1,4 +1,3 @@
-
using System.Text;
using UnityEngine;
using UnityEngine.EventSystems;
diff --git a/Runtime/Internal/Misc/IPropertyChanged.cs b/Runtime/Internal/Misc/IPropertyChanged.cs
index af782c07..34f2e355 100644
--- a/Runtime/Internal/Misc/IPropertyChanged.cs
+++ b/Runtime/Internal/Misc/IPropertyChanged.cs
@@ -1,4 +1,3 @@
-
namespace XCharts.Runtime
{
///
@@ -8,5 +7,4 @@ namespace XCharts.Runtime
{
void OnChanged();
}
-}
-
+}
\ No newline at end of file
diff --git a/Runtime/Internal/Misc/ISerieContainer.cs b/Runtime/Internal/Misc/ISerieContainer.cs
index d798d710..5e09dc4c 100644
--- a/Runtime/Internal/Misc/ISerieContainer.cs
+++ b/Runtime/Internal/Misc/ISerieContainer.cs
@@ -1,4 +1,3 @@
-
namespace XCharts.Runtime
{
public interface ISerieContainer
diff --git a/Runtime/Internal/Misc/ISerieDataComponent.cs b/Runtime/Internal/Misc/ISerieDataComponent.cs
index c75f596a..0187300c 100644
--- a/Runtime/Internal/Misc/ISerieDataComponent.cs
+++ b/Runtime/Internal/Misc/ISerieDataComponent.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
@@ -6,6 +5,5 @@ using UnityEngine.UI;
namespace XCharts.Runtime
{
public interface ISerieDataComponent
- {
- }
+ { }
}
\ No newline at end of file
diff --git a/Runtime/Internal/Misc/ISerieExtraComponent.cs b/Runtime/Internal/Misc/ISerieExtraComponent.cs
index 13ae3f46..dda88d4c 100644
--- a/Runtime/Internal/Misc/ISerieExtraComponent.cs
+++ b/Runtime/Internal/Misc/ISerieExtraComponent.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
diff --git a/Runtime/Internal/Misc/ISimplifiedSerie.cs b/Runtime/Internal/Misc/ISimplifiedSerie.cs
index d3325010..20afab90 100644
--- a/Runtime/Internal/Misc/ISimplifiedSerie.cs
+++ b/Runtime/Internal/Misc/ISimplifiedSerie.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
@@ -6,6 +5,5 @@ using UnityEngine.UI;
namespace XCharts.Runtime
{
public interface ISimplifiedSerie
- {
- }
+ { }
}
\ No newline at end of file
diff --git a/Runtime/Internal/Misc/IUpdateRuntimeData.cs b/Runtime/Internal/Misc/IUpdateRuntimeData.cs
index 53f91957..c1d7f0fc 100644
--- a/Runtime/Internal/Misc/IUpdateRuntimeData.cs
+++ b/Runtime/Internal/Misc/IUpdateRuntimeData.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
diff --git a/Runtime/Internal/Object/ChartLabel.cs b/Runtime/Internal/Object/ChartLabel.cs
index ed114b5f..7da2fb5b 100644
--- a/Runtime/Internal/Object/ChartLabel.cs
+++ b/Runtime/Internal/Object/ChartLabel.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
@@ -337,4 +336,4 @@ namespace XCharts.Runtime
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Internal/Object/ChartObject.cs b/Runtime/Internal/Object/ChartObject.cs
index e17b5292..143e1202 100644
--- a/Runtime/Internal/Object/ChartObject.cs
+++ b/Runtime/Internal/Object/ChartObject.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
diff --git a/Runtime/Internal/Object/ChartText.cs b/Runtime/Internal/Object/ChartText.cs
index 2ae19f8b..c01b68a8 100644
--- a/Runtime/Internal/Object/ChartText.cs
+++ b/Runtime/Internal/Object/ChartText.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
#if dUI_TextMeshPro
@@ -47,8 +46,7 @@ namespace XCharts.Runtime
}
public ChartText()
- {
- }
+ { }
public ChartText(GameObject textParent)
{
@@ -72,7 +70,7 @@ namespace XCharts.Runtime
#if dUI_TextMeshPro
if (m_TMPText != null) m_TMPText.fontSize = fontSize;
#else
- if (m_Text != null) m_Text.fontSize = (int)fontSize;
+ if (m_Text != null) m_Text.fontSize = (int) fontSize;
#endif
}
@@ -81,7 +79,7 @@ namespace XCharts.Runtime
if (text == null) text = string.Empty;
else text = text.Replace("\\n", "\n");
#if dUI_TextMeshPro
- if(m_TMPText != null) m_TMPText.text = text;
+ if (m_TMPText != null) m_TMPText.text = text;
#else
if (m_Text != null) m_Text.text = text;
#endif
@@ -169,15 +167,33 @@ namespace XCharts.Runtime
if (m_TMPText == null) return;
switch (alignment)
{
- case TextAnchor.LowerCenter: m_TMPText.alignment = TextAlignmentOptions.Bottom; break;
- case TextAnchor.LowerLeft: m_TMPText.alignment = TextAlignmentOptions.BottomLeft; break;
- case TextAnchor.LowerRight: m_TMPText.alignment = TextAlignmentOptions.BottomRight; break;
- case TextAnchor.MiddleCenter: m_TMPText.alignment = TextAlignmentOptions.Center; break;
- case TextAnchor.MiddleLeft: m_TMPText.alignment = TextAlignmentOptions.Left; break;
- case TextAnchor.MiddleRight: m_TMPText.alignment = TextAlignmentOptions.Right; break;
- case TextAnchor.UpperCenter: m_TMPText.alignment = TextAlignmentOptions.Top; break;
- case TextAnchor.UpperLeft: m_TMPText.alignment = TextAlignmentOptions.TopLeft; break;
- case TextAnchor.UpperRight: m_TMPText.alignment = TextAlignmentOptions.TopRight; break;
+ case TextAnchor.LowerCenter:
+ m_TMPText.alignment = TextAlignmentOptions.Bottom;
+ break;
+ case TextAnchor.LowerLeft:
+ m_TMPText.alignment = TextAlignmentOptions.BottomLeft;
+ break;
+ case TextAnchor.LowerRight:
+ m_TMPText.alignment = TextAlignmentOptions.BottomRight;
+ break;
+ case TextAnchor.MiddleCenter:
+ m_TMPText.alignment = TextAlignmentOptions.Center;
+ break;
+ case TextAnchor.MiddleLeft:
+ m_TMPText.alignment = TextAlignmentOptions.Left;
+ break;
+ case TextAnchor.MiddleRight:
+ m_TMPText.alignment = TextAlignmentOptions.Right;
+ break;
+ case TextAnchor.UpperCenter:
+ m_TMPText.alignment = TextAlignmentOptions.Top;
+ break;
+ case TextAnchor.UpperLeft:
+ m_TMPText.alignment = TextAlignmentOptions.TopLeft;
+ break;
+ case TextAnchor.UpperRight:
+ m_TMPText.alignment = TextAlignmentOptions.TopRight;
+ break;
default:
m_TMPText.alignment = TextAlignmentOptions.Center;
m_TextAlignment = TextAnchor.MiddleCenter;
@@ -199,10 +215,18 @@ namespace XCharts.Runtime
if (m_TMPText == null) return;
switch (fontStyle)
{
- case FontStyle.Normal: m_TMPText.fontStyle = FontStyles.Normal; break;
- case FontStyle.Bold: m_TMPText.fontStyle = FontStyles.Bold; break;
- case FontStyle.BoldAndItalic: m_TMPText.fontStyle = FontStyles.Bold | FontStyles.Italic; break;
- case FontStyle.Italic: m_TMPText.fontStyle = FontStyles.Italic; break;
+ case FontStyle.Normal:
+ m_TMPText.fontStyle = FontStyles.Normal;
+ break;
+ case FontStyle.Bold:
+ m_TMPText.fontStyle = FontStyles.Bold;
+ break;
+ case FontStyle.BoldAndItalic:
+ m_TMPText.fontStyle = FontStyles.Bold | FontStyles.Italic;
+ break;
+ case FontStyle.Italic:
+ m_TMPText.fontStyle = FontStyles.Italic;
+ break;
}
#else
if (m_Text != null) m_Text.fontStyle = fontStyle;
diff --git a/Runtime/Internal/Object/LegendItem.cs b/Runtime/Internal/Object/LegendItem.cs
index 8c812d5e..9a6f7540 100644
--- a/Runtime/Internal/Object/LegendItem.cs
+++ b/Runtime/Internal/Object/LegendItem.cs
@@ -120,7 +120,6 @@ namespace XCharts.Runtime
else return Color.clear;
}
-
public void SetIconColor(Color color)
{
if (m_Icon)
diff --git a/Runtime/Internal/Painter.cs b/Runtime/Internal/Painter.cs
index 0e5091f1..c60041a9 100644
--- a/Runtime/Internal/Painter.cs
+++ b/Runtime/Internal/Painter.cs
@@ -1,7 +1,6 @@
-
+using System;
using UnityEngine;
using UnityEngine.UI;
-using System;
namespace XCharts.Runtime
{
diff --git a/Runtime/Internal/Pools/ListPool.cs b/Runtime/Internal/Pools/ListPool.cs
index da90cc1a..8210fde1 100644
--- a/Runtime/Internal/Pools/ListPool.cs
+++ b/Runtime/Internal/Pools/ListPool.cs
@@ -1,6 +1,4 @@
-
using System.Collections.Generic;
-using UnityEngine;
namespace XCharts.Runtime
{
@@ -34,4 +32,4 @@ namespace XCharts.Runtime
s_ListPool.ClearAll();
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Internal/Pools/ObjectPool.cs b/Runtime/Internal/Pools/ObjectPool.cs
index 7c59b82b..9dfb045d 100644
--- a/Runtime/Internal/Pools/ObjectPool.cs
+++ b/Runtime/Internal/Pools/ObjectPool.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
@@ -55,4 +54,4 @@ namespace XCharts.Runtime
m_Stack.Clear();
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Internal/Pools/SerieDataPool.cs b/Runtime/Internal/Pools/SerieDataPool.cs
index 7aeb7c75..9380580e 100644
--- a/Runtime/Internal/Pools/SerieDataPool.cs
+++ b/Runtime/Internal/Pools/SerieDataPool.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -7,9 +6,7 @@ namespace XCharts.Runtime
{
private static readonly ObjectPool s_ListPool = new ObjectPool(null, OnClear);
- static void OnGet(SerieData serieData)
- {
- }
+ static void OnGet(SerieData serieData) { }
static void OnClear(SerieData serieData)
{
@@ -26,4 +23,4 @@ namespace XCharts.Runtime
s_ListPool.Release(toRelease);
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Internal/Pools/SerieLabelPool.cs b/Runtime/Internal/Pools/SerieLabelPool.cs
index 0bb7d1de..321d8942 100644
--- a/Runtime/Internal/Pools/SerieLabelPool.cs
+++ b/Runtime/Internal/Pools/SerieLabelPool.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -67,9 +66,9 @@ namespace XCharts.Runtime
float iconWidth, float iconHeight, ThemeStyle theme)
{
var label = ChartHelper.AddChartLabel(name, parent, labelStyle, theme.common,
- "", color, TextAnchor.MiddleCenter);
+ "", color, TextAnchor.MiddleCenter);
label.SetActive(labelStyle.show);
return label.gameObject;
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Internal/Utilities/ChartCached.cs b/Runtime/Internal/Utilities/ChartCached.cs
index 2579d9ab..59a505bd 100644
--- a/Runtime/Internal/Utilities/ChartCached.cs
+++ b/Runtime/Internal/Utilities/ChartCached.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using System.Globalization;
@@ -13,7 +12,7 @@ namespace XCharts.Runtime
private const string NUMERIC_FORMATTER_X = "X";
private const string NUMERIC_FORMATTER_x = "x";
private static readonly string s_DefaultAxis = "axis_";
- private static CultureInfo ci = new CultureInfo("en-us");// "en-us", "zh-cn", "ar-iq", "de-de"
+ private static CultureInfo ci = new CultureInfo("en-us"); // "en-us", "zh-cn", "ar-iq", "de-de"
private static Dictionary s_ColorToStr = new Dictionary(100);
private static Dictionary s_SerieLabelName = new Dictionary(1000);
private static Dictionary s_ColorDotStr = new Dictionary(100);
@@ -21,7 +20,6 @@ namespace XCharts.Runtime
private static Dictionary s_AxisLabelName = new Dictionary();
private static Dictionary s_TypeName = new Dictionary();
-
private static Dictionary> s_NumberToStr = new Dictionary>();
private static Dictionary> s_PrecisionToStr = new Dictionary>();
@@ -55,18 +53,18 @@ namespace XCharts.Runtime
{
if (string.IsNullOrEmpty(formatter))
{
- if (value - (int)value == 0)
- s_NumberToStr[value][formatter] = ((int)value).ToString();
+ if (value - (int) value == 0)
+ s_NumberToStr[value][formatter] = ((int) value).ToString();
else
s_NumberToStr[value][formatter] = value.ToString();
}
- else if (formatter.StartsWith(NUMERIC_FORMATTER_D)
- || formatter.StartsWith(NUMERIC_FORMATTER_d)
- || formatter.StartsWith(NUMERIC_FORMATTER_X)
- || formatter.StartsWith(NUMERIC_FORMATTER_x)
- )
+ else if (formatter.StartsWith(NUMERIC_FORMATTER_D) ||
+ formatter.StartsWith(NUMERIC_FORMATTER_d) ||
+ formatter.StartsWith(NUMERIC_FORMATTER_X) ||
+ formatter.StartsWith(NUMERIC_FORMATTER_x)
+ )
{
- s_NumberToStr[value][formatter] = ((int)value).ToString(formatter, ci);
+ s_NumberToStr[value][formatter] = ((int) value).ToString(formatter, ci);
}
else
{
diff --git a/Runtime/Internal/Utilities/ChartConst.cs b/Runtime/Internal/Utilities/ChartConst.cs
index f4e3bfef..2b0eeb6b 100644
--- a/Runtime/Internal/Utilities/ChartConst.cs
+++ b/Runtime/Internal/Utilities/ChartConst.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
diff --git a/Runtime/Internal/Utilities/ChartDrawer.cs b/Runtime/Internal/Utilities/ChartDrawer.cs
index ecb75b92..69b7e2c5 100644
--- a/Runtime/Internal/Utilities/ChartDrawer.cs
+++ b/Runtime/Internal/Utilities/ChartDrawer.cs
@@ -1,5 +1,3 @@
-
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -97,13 +95,13 @@ namespace XCharts.Runtime
var arrowOffset = 0;
var arrowDent = arrowWidth / 3.3f;
UGL.DrawArrow(vh, startPos, pos, arrowWidth, arrowHeight,
- arrowOffset, arrowDent, color);
+ arrowOffset, arrowDent, color);
break;
}
}
public static void DrawLineStyle(VertexHelper vh, LineStyle lineStyle, Vector3 startPos, Vector3 endPos,
- Color32 defaultColor, float themeWidth, LineStyle.Type themeType)
+ Color32 defaultColor, float themeWidth, LineStyle.Type themeType)
{
var type = lineStyle.GetType(themeType);
var width = lineStyle.GetWidth(themeWidth);
diff --git a/Runtime/Internal/Utilities/ChartHelper.cs b/Runtime/Internal/Utilities/ChartHelper.cs
index 2a9f9e5d..c254007c 100644
--- a/Runtime/Internal/Utilities/ChartHelper.cs
+++ b/Runtime/Internal/Utilities/ChartHelper.cs
@@ -1,7 +1,6 @@
-
-using System.Text;
using System;
using System.Collections.Generic;
+using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.EventSystems;
@@ -365,8 +364,8 @@ namespace XCharts.Runtime
label.UpdateIcon(labelStyle.icon);
if (labelStyle.background.show)
{
- label.color = (!labelStyle.background.autoColor || autoColor == Color.clear)
- ? labelStyle.background.color : autoColor;
+ label.color = (!labelStyle.background.autoColor || autoColor == Color.clear) ?
+ labelStyle.background.color : autoColor;
label.sprite = labelStyle.background.sprite;
label.type = labelStyle.background.type;
}
@@ -442,7 +441,7 @@ namespace XCharts.Runtime
ThemeStyle theme, TextAnchor alignment)
{
var label = ChartHelper.AddChartLabel(name, parent, tooltip.indicatorLabelStyle, theme.tooltip,
- "", Color.clear, alignment);
+ "", Color.clear, alignment);
label.SetActive(tooltip.show && tooltip.indicatorLabelStyle.show);
return label;
}
@@ -451,7 +450,7 @@ namespace XCharts.Runtime
{
Vector3 dir = (ep - sp).normalized;
float dist = Vector3.Distance(sp, ep);
- int segment = (int)(dist / k);
+ int segment = (int) (dist / k);
posList.Clear();
posList.Add(sp);
for (int i = 1; i < segment; i++)
@@ -606,7 +605,7 @@ namespace XCharts.Runtime
{
Color color;
ColorUtility.TryParseHtmlString(hexColorStr, out color);
- return (Color32)color;
+ return (Color32) color;
}
public static double GetMaxDivisibleValue(double max, int ceilRate)
@@ -615,15 +614,15 @@ namespace XCharts.Runtime
if (max > -1 && max < 1)
{
int count = 1;
- int intvalue = (int)(max * Mathf.Pow(10, count));
+ int intvalue = (int) (max * Mathf.Pow(10, count));
while (intvalue == 0 && count < 12)
{
count++;
- intvalue = (int)(max * Mathf.Pow(10, count));
+ intvalue = (int) (max * Mathf.Pow(10, count));
}
var pow = Mathf.Pow(10, count);
- if (max > 0) return (int)((max * pow + 1)) / pow;
- else return (int)((max * pow - 1)) / pow;
+ if (max > 0) return (int) ((max * pow + 1)) / pow;
+ else return (int) ((max * pow - 1)) / pow;
}
if (ceilRate == 0)
{
@@ -646,7 +645,7 @@ namespace XCharts.Runtime
else
{
var mod = max % ceilRate;
- int rate = (int)(max / ceilRate);
+ int rate = (int) (max / ceilRate);
return mod == 0 ? max : (max < 0 ? rate : rate + 1) * ceilRate;
}
}
@@ -657,15 +656,15 @@ namespace XCharts.Runtime
if (min > -1 && min < 1)
{
int count = 1;
- int intvalue = (int)(min * Mathf.Pow(10, count));
+ int intvalue = (int) (min * Mathf.Pow(10, count));
while (intvalue == 0 && count < 12)
{
count++;
- intvalue = (int)(min * Mathf.Pow(10, count));
+ intvalue = (int) (min * Mathf.Pow(10, count));
}
var pow = Mathf.Pow(10, count);
- if (min > 0) return (int)((min * pow + 1)) / pow;
- else return (int)((min * pow - 1)) / pow;
+ if (min > 0) return (int) ((min * pow + 1)) / pow;
+ else return (int) ((min * pow - 1)) / pow;
}
if (ceilRate == 0)
{
@@ -687,7 +686,7 @@ namespace XCharts.Runtime
else
{
var mod = min % ceilRate;
- int rate = (int)(min / ceilRate);
+ int rate = (int) (min / ceilRate);
return mod == 0 ? min : (min < 0 ? rate - 1 : rate) * ceilRate;
}
}
@@ -701,31 +700,31 @@ namespace XCharts.Runtime
{
if (isLogBaseE)
{
- max = Mathf.Exp(splitNumber);
+ max = Math.Exp(splitNumber);
}
else
{
- max = Mathf.Pow(logBase, splitNumber);
+ max = Math.Pow(logBase, splitNumber);
}
splitNumber++;
}
return max;
}
- public static float GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)
+ public static double GetMinLogValue(double value, float logBase, bool isLogBaseE, out int splitNumber)
{
splitNumber = 0;
if (value > 1) return 1;
- float min = 1;
+ double min = 1;
while (min > value)
{
if (isLogBaseE)
{
- min = Mathf.Exp(-splitNumber);
+ min = Math.Exp(-splitNumber);
}
else
{
- min = Mathf.Pow(logBase, -splitNumber);
+ min = Math.Pow(logBase, -splitNumber);
}
splitNumber++;
}
@@ -736,11 +735,11 @@ namespace XCharts.Runtime
{
if (value > 1 || value < -1) return 0;
int count = 1;
- int intvalue = (int)(value * Mathf.Pow(10, count));
+ int intvalue = (int) (value * Mathf.Pow(10, count));
while (intvalue == 0 && count < 38)
{
count++;
- intvalue = (int)(value * Mathf.Pow(10, count));
+ intvalue = (int) (value * Mathf.Pow(10, count));
}
if (count == 38 && (value == 0 || value == 1)) return 1;
else return count;
@@ -836,16 +835,16 @@ namespace XCharts.Runtime
{
if (color.a != 0 && opacity != 1)
{
- color.a = (byte)(color.a * opacity);
+ color.a = (byte) (color.a * opacity);
}
}
public static Color32 GetHighlightColor(Color32 color, float rate = 0.8f)
{
var newColor = color;
- newColor.r = (byte)(color.r * rate);
- newColor.g = (byte)(color.g * rate);
- newColor.b = (byte)(color.b * rate);
+ newColor.r = (byte) (color.r * rate);
+ newColor.g = (byte) (color.g * rate);
+ newColor.b = (byte) (color.b * rate);
return newColor;
}
diff --git a/Runtime/Internal/Utilities/ComponentHelper.cs b/Runtime/Internal/Utilities/ComponentHelper.cs
index f273734b..f59a7035 100644
--- a/Runtime/Internal/Utilities/ComponentHelper.cs
+++ b/Runtime/Internal/Utilities/ComponentHelper.cs
@@ -1,5 +1,3 @@
-
-
using System.Collections.Generic;
namespace XCharts.Runtime
@@ -18,7 +16,7 @@ namespace XCharts.Runtime
}
return null;
}
-
+
public static RadiusAxis GetRadiusAxis(List components, int polarIndex)
{
foreach (var component in components)
diff --git a/Runtime/Internal/Utilities/DataHelper.cs b/Runtime/Internal/Utilities/DataHelper.cs
index 9d168151..ee555adc 100644
--- a/Runtime/Internal/Utilities/DataHelper.cs
+++ b/Runtime/Internal/Utilities/DataHelper.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
diff --git a/Runtime/Internal/Utilities/LayoutHelper.cs b/Runtime/Internal/Utilities/LayoutHelper.cs
index f3a0e22b..6b128f84 100644
--- a/Runtime/Internal/Utilities/LayoutHelper.cs
+++ b/Runtime/Internal/Utilities/LayoutHelper.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -213,14 +212,14 @@ namespace XCharts.Runtime
public static bool IsFixedWidthHeight(RectTransform rt)
{
return IsLeftTop(rt.anchorMin, rt.anchorMax) ||
- IsLeftCenter(rt.anchorMin, rt.anchorMax) ||
- IsLeftBottom(rt.anchorMin, rt.anchorMax) ||
- IsCenterTop(rt.anchorMin, rt.anchorMax) ||
- IsCenterCenter(rt.anchorMin, rt.anchorMax) ||
- IsCenterBottom(rt.anchorMin, rt.anchorMax) ||
- IsRightTop(rt.anchorMin, rt.anchorMax) ||
- IsRightCenter(rt.anchorMin, rt.anchorMax) ||
- IsRightBottom(rt.anchorMin, rt.anchorMax);
+ IsLeftCenter(rt.anchorMin, rt.anchorMax) ||
+ IsLeftBottom(rt.anchorMin, rt.anchorMax) ||
+ IsCenterTop(rt.anchorMin, rt.anchorMax) ||
+ IsCenterCenter(rt.anchorMin, rt.anchorMax) ||
+ IsCenterBottom(rt.anchorMin, rt.anchorMax) ||
+ IsRightTop(rt.anchorMin, rt.anchorMax) ||
+ IsRightCenter(rt.anchorMin, rt.anchorMax) ||
+ IsRightBottom(rt.anchorMin, rt.anchorMax);
}
}
diff --git a/Runtime/Internal/Utilities/MathUtil.cs b/Runtime/Internal/Utilities/MathUtil.cs
index 3a475707..2103a5fa 100644
--- a/Runtime/Internal/Utilities/MathUtil.cs
+++ b/Runtime/Internal/Utilities/MathUtil.cs
@@ -1,7 +1,6 @@
-
-using System.Text;
using System;
using System.Collections.Generic;
+using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.EventSystems;
diff --git a/Runtime/Internal/XCResourcesImporter.cs b/Runtime/Internal/XCResourcesImporter.cs
index 7ce0b980..09eea015 100644
--- a/Runtime/Internal/XCResourcesImporter.cs
+++ b/Runtime/Internal/XCResourcesImporter.cs
@@ -2,9 +2,8 @@
using System;
using System.IO;
-using UnityEngine;
using UnityEditor;
-
+using UnityEngine;
namespace XCharts.Runtime
{
@@ -16,8 +15,7 @@ namespace XCharts.Runtime
public XCResourcesImporter() { }
public void OnDestroy()
- {
- }
+ { }
public void OnGUI()
{
@@ -137,4 +135,4 @@ namespace XCharts.Runtime
}
}
-#endif
+#endif
\ No newline at end of file
diff --git a/Runtime/Internal/XCSettings.cs b/Runtime/Internal/XCSettings.cs
index 3ca47865..17a2b734 100644
--- a/Runtime/Internal/XCSettings.cs
+++ b/Runtime/Internal/XCSettings.cs
@@ -1,8 +1,7 @@
-
-using UnityEngine;
using System;
using System.Collections.Generic;
using System.IO;
+using UnityEngine;
#if dUI_TextMeshPro
using TMPro;
#endif
@@ -27,42 +26,42 @@ namespace XCharts.Runtime
#if dUI_TextMeshPro
[SerializeField] private TMP_FontAsset m_TMPFont = null;
#endif
- [SerializeField] [Range(1, 200)] private int m_FontSizeLv1 = 28;
- [SerializeField] [Range(1, 200)] private int m_FontSizeLv2 = 24;
- [SerializeField] [Range(1, 200)] private int m_FontSizeLv3 = 20;
- [SerializeField] [Range(1, 200)] private int m_FontSizeLv4 = 18;
+ [SerializeField][Range(1, 200)] private int m_FontSizeLv1 = 28;
+ [SerializeField][Range(1, 200)] private int m_FontSizeLv2 = 24;
+ [SerializeField][Range(1, 200)] private int m_FontSizeLv3 = 20;
+ [SerializeField][Range(1, 200)] private int m_FontSizeLv4 = 18;
[SerializeField] private LineStyle.Type m_AxisLineType = LineStyle.Type.Solid;
- [SerializeField] [Range(0, 20)] private float m_AxisLineWidth = 0.8f;
+ [SerializeField][Range(0, 20)] private float m_AxisLineWidth = 0.8f;
[SerializeField] private LineStyle.Type m_AxisSplitLineType = LineStyle.Type.Solid;
- [SerializeField] [Range(0, 20)] private float m_AxisSplitLineWidth = 0.8f;
- [SerializeField] [Range(0, 20)] private float m_AxisTickWidth = 0.8f;
- [SerializeField] [Range(0, 20)] private float m_AxisTickLength = 5f;
- [SerializeField] [Range(0, 200)] private float m_GaugeAxisLineWidth = 15f;
- [SerializeField] [Range(0, 20)] private float m_GaugeAxisSplitLineWidth = 0.8f;
- [SerializeField] [Range(0, 20)] private float m_GaugeAxisSplitLineLength = 15f;
- [SerializeField] [Range(0, 20)] private float m_GaugeAxisTickWidth = 0.8f;
- [SerializeField] [Range(0, 20)] private float m_GaugeAxisTickLength = 5f;
- [SerializeField] [Range(0, 20)] private float m_TootipLineWidth = 0.8f;
- [SerializeField] [Range(0, 20)] private float m_DataZoomBorderWidth = 0.5f;
- [SerializeField] [Range(0, 20)] private float m_DataZoomDataLineWidth = 0.5f;
- [SerializeField] [Range(0, 20)] private float m_VisualMapBorderWidth = 0f;
+ [SerializeField][Range(0, 20)] private float m_AxisSplitLineWidth = 0.8f;
+ [SerializeField][Range(0, 20)] private float m_AxisTickWidth = 0.8f;
+ [SerializeField][Range(0, 20)] private float m_AxisTickLength = 5f;
+ [SerializeField][Range(0, 200)] private float m_GaugeAxisLineWidth = 15f;
+ [SerializeField][Range(0, 20)] private float m_GaugeAxisSplitLineWidth = 0.8f;
+ [SerializeField][Range(0, 20)] private float m_GaugeAxisSplitLineLength = 15f;
+ [SerializeField][Range(0, 20)] private float m_GaugeAxisTickWidth = 0.8f;
+ [SerializeField][Range(0, 20)] private float m_GaugeAxisTickLength = 5f;
+ [SerializeField][Range(0, 20)] private float m_TootipLineWidth = 0.8f;
+ [SerializeField][Range(0, 20)] private float m_DataZoomBorderWidth = 0.5f;
+ [SerializeField][Range(0, 20)] private float m_DataZoomDataLineWidth = 0.5f;
+ [SerializeField][Range(0, 20)] private float m_VisualMapBorderWidth = 0f;
- [SerializeField] [Range(0, 20)] private float m_SerieLineWidth = 1.8f;
- [SerializeField] [Range(0, 200)] private float m_SerieLineSymbolSize = 5f;
- [SerializeField] [Range(0, 200)] private float m_SerieScatterSymbolSize = 20f;
- [SerializeField] [Range(0, 200)] private float m_SerieSelectedRate = 1.3f;
- [SerializeField] [Range(0, 10)] private float m_SerieCandlestickBorderWidth = 1f;
+ [SerializeField][Range(0, 20)] private float m_SerieLineWidth = 1.8f;
+ [SerializeField][Range(0, 200)] private float m_SerieLineSymbolSize = 5f;
+ [SerializeField][Range(0, 200)] private float m_SerieScatterSymbolSize = 20f;
+ [SerializeField][Range(0, 200)] private float m_SerieSelectedRate = 1.3f;
+ [SerializeField][Range(0, 10)] private float m_SerieCandlestickBorderWidth = 1f;
[SerializeField] private bool m_EditorShowAllListData = false;
- [SerializeField] [Range(1, 20)] protected int m_MaxPainter = 10;
- [SerializeField] [Range(1, 10)] protected float m_LineSmoothStyle = 3f;
- [SerializeField] [Range(1f, 20)] protected float m_LineSmoothness = 2f;
- [SerializeField] [Range(1f, 20)] protected float m_LineSegmentDistance = 3f;
- [SerializeField] [Range(1, 10)] protected float m_CicleSmoothness = 2f;
- [SerializeField] [Range(10, 50)] protected float m_VisualMapTriangeLen = 20f;
- [SerializeField] [Range(1, 20)] protected float m_PieTooltipExtraRadius = 8f;
- [SerializeField] [Range(1, 20)] protected float m_PieSelectedOffset = 8f;
+ [SerializeField][Range(1, 20)] protected int m_MaxPainter = 10;
+ [SerializeField][Range(1, 10)] protected float m_LineSmoothStyle = 3f;
+ [SerializeField][Range(1f, 20)] protected float m_LineSmoothness = 2f;
+ [SerializeField][Range(1f, 20)] protected float m_LineSegmentDistance = 3f;
+ [SerializeField][Range(1, 10)] protected float m_CicleSmoothness = 2f;
+ [SerializeField][Range(10, 50)] protected float m_VisualMapTriangeLen = 20f;
+ [SerializeField][Range(1, 20)] protected float m_PieTooltipExtraRadius = 8f;
+ [SerializeField][Range(1, 20)] protected float m_PieSelectedOffset = 8f;
[SerializeField] protected List m_CustomThemes = new List();
public static Lang lang { get { return Instance.m_Lang; } }
diff --git a/Runtime/Internal/XCThemeMgr.cs b/Runtime/Internal/XCThemeMgr.cs
index 9e6380e8..86c239cc 100644
--- a/Runtime/Internal/XCThemeMgr.cs
+++ b/Runtime/Internal/XCThemeMgr.cs
@@ -1,5 +1,3 @@
-
-
using System.Collections.Generic;
using System.IO;
using UnityEngine;
diff --git a/Runtime/Internal/XChartsMgr.cs b/Runtime/Internal/XChartsMgr.cs
index dc0680c4..e97eee78 100644
--- a/Runtime/Internal/XChartsMgr.cs
+++ b/Runtime/Internal/XChartsMgr.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
+using System.IO;
using UnityEngine;
using UnityEngine.SceneManagement;
-using System.IO;
#if UNITY_EDITOR
using UnityEditor;
#endif
@@ -20,8 +20,8 @@ namespace XCharts.Runtime
[ExecuteInEditMode]
public static class XChartsMgr
{
- public static readonly string version = "3.0.0-preview9";
- public static readonly int versionDate = 20220506;
+ public static readonly string version = "3.0.0";
+ public static readonly int versionDate = 20220522;
public static string fullVersion { get { return version + "-" + versionDate; } }
internal static List chartList = new List();
diff --git a/Runtime/Serie/Bar/Bar.cs b/Runtime/Serie/Bar/Bar.cs
index fd9d6402..89ed7024 100644
--- a/Runtime/Serie/Bar/Bar.cs
+++ b/Runtime/Serie/Bar/Bar.cs
@@ -1,8 +1,3 @@
-
-using System;
-using System.Reflection;
-using UnityEngine;
-
namespace XCharts.Runtime
{
[System.Serializable]
@@ -10,7 +5,9 @@ namespace XCharts.Runtime
[SerieConvert(typeof(Line), typeof(Pie))]
[RequireChartComponent(typeof(GridCoord))]
[DefaultAnimation(AnimationType.BottomToTop)]
- [SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
+ [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraField("m_Ignore")]
public class Bar : Serie, INeedSerieContainer
{
public int containerIndex { get; internal set; }
diff --git a/Runtime/Serie/Bar/BarHandler.cs b/Runtime/Serie/Bar/BarHandler.cs
index 88f7ccdf..d5818098 100644
--- a/Runtime/Serie/Bar/BarHandler.cs
+++ b/Runtime/Serie/Bar/BarHandler.cs
@@ -1,6 +1,6 @@
-
using System.Collections.Generic;
using UnityEngine;
+using UnityEngine.EventSystems;
using UnityEngine.UI;
using XUGL;
@@ -47,6 +47,16 @@ namespace XCharts.Runtime
}
}
+ public override void OnPointerDown(PointerEventData eventData)
+ {
+ if (!serie.context.pointerEnter) return;
+ if (serie.context.pointerItemDataIndex < 0) return;
+ if (chart.onPointerClickBar != null)
+ {
+ chart.onPointerClickBar(eventData, serie.context.pointerItemDataIndex);
+ }
+ }
+
private void UpdateSerieContext()
{
if (m_SerieGrid == null)
@@ -87,8 +97,8 @@ namespace XCharts.Runtime
serie.context.pointerEnter = false;
foreach (var serieData in serie.data)
{
- if (serie.context.pointerAxisDataIndexs.Contains(serieData.index)
- || serieData.context.rect.Contains(chart.pointerPos))
+ if (serie.context.pointerAxisDataIndexs.Contains(serieData.index) ||
+ serieData.context.rect.Contains(chart.pointerPos))
{
serie.context.pointerItemDataIndex = serieData.index;
serie.context.pointerEnter = true;
@@ -155,17 +165,17 @@ namespace XCharts.Runtime
if (isStack)
SeriesHelper.UpdateStackDataList(chart.series, serie, dataZoom, m_StackSerieData);
+ var barCount = chart.GetSerieBarRealCount();
float categoryWidth = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
float barGap = chart.GetSerieBarGap();
- float totalBarWidth = chart.GetSerieTotalWidth(categoryWidth, barGap);
- float barWidth = serie.GetBarWidth(categoryWidth);
+ float totalBarWidth = chart.GetSerieTotalWidth(categoryWidth, barGap, barCount);
+ float barWidth = serie.GetBarWidth(categoryWidth, barCount);
float offset = (categoryWidth - totalBarWidth) * 0.5f;
- float barGapWidth = barWidth + barWidth * barGap;
- float gap = serie.barGap == -1 ? offset : offset + chart.GetSerieIndexIfStack(serie) * barGapWidth;
- int maxCount = serie.maxShow > 0
- ? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
- : showData.Count;
-
+ var serieReadIndex = chart.GetSerieIndexIfStack(serie);
+ float gap = serie.barGap == -1 ? offset : offset + chart.GetSerieTotalGap(categoryWidth, barGap, serieReadIndex);
+ int maxCount = serie.maxShow > 0 ?
+ (serie.maxShow > showData.Count ? showData.Count : serie.maxShow) :
+ showData.Count;
var isPercentStack = SeriesHelper.IsPercentStack(chart.series, serie.stack);
bool dataChanging = false;
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
@@ -214,7 +224,7 @@ namespace XCharts.Runtime
if (isPercentStack)
{
var valueTotal = chart.GetSerieSameStackTotalValue(serie.stack, i);
- barHig = valueTotal != 0 ? (float)(relativedValue / valueTotal * relativedAxisLength) : 0;
+ barHig = valueTotal != 0 ? (float) (relativedValue / valueTotal * relativedAxisLength) : 0;
}
else
{
@@ -229,9 +239,9 @@ namespace XCharts.Runtime
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);
+ 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);
if (!serie.clip || (serie.clip && m_SerieGrid.Contains(top)))
serie.context.dataPoints.Add(top);
@@ -283,7 +293,7 @@ namespace XCharts.Runtime
if (axis.context.minMaxRange <= 0) pY = grid.context.y;
else
{
- var valueLen = (float)((value - axis.context.minValue) / axis.context.minMaxRange) * grid.context.height;
+ var valueLen = (float) ((value - axis.context.minValue) / axis.context.minMaxRange) * grid.context.height;
pY = grid.context.y + valueLen - categoryWidth * 0.5f;
}
}
@@ -305,7 +315,7 @@ namespace XCharts.Runtime
if (axis.context.minMaxRange <= 0) pX = grid.context.x;
else
{
- var valueLen = (float)((value - axis.context.minValue) / axis.context.minMaxRange) * grid.context.width;
+ var valueLen = (float) ((value - axis.context.minValue) / axis.context.minMaxRange) * grid.context.width;
pX = grid.context.x + valueLen - categoryWidth * 0.5f;
}
}
@@ -374,9 +384,9 @@ namespace XCharts.Runtime
{
var borderWidth = itemStyle.runtimeBorderWidth;
var backgroundColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false);
- var cornerRadius = serie.barType == BarType.Capsule && !itemStyle.IsNeedCorner()
- ? m_CapusleDefaultCornerRadius
- : itemStyle.cornerRadius;
+ var cornerRadius = serie.barType == BarType.Capsule && !itemStyle.IsNeedCorner() ?
+ m_CapusleDefaultCornerRadius :
+ itemStyle.cornerRadius;
var invert = value < 0;
if (!ChartHelper.IsClearColor(backgroundColor))
{
@@ -384,7 +394,7 @@ namespace XCharts.Runtime
cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert);
}
UGL.DrawRoundRectangle(vh, serieData.context.rect, areaColor, areaToColor, 0,
- cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert);
+ cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert);
if (serie.barType == BarType.Capsule)
{
UGL.DrawBorder(vh, serieData.context.backgroundRect, borderWidth, itemStyle.borderColor,
@@ -393,7 +403,7 @@ namespace XCharts.Runtime
else
{
UGL.DrawBorder(vh, serieData.context.rect, borderWidth, itemStyle.borderColor,
- 0, cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert, itemStyle.borderGap);
+ 0, cornerRadius, isYAxis, chart.settings.cicleSmoothness, invert, itemStyle.borderGap);
}
}
diff --git a/Runtime/Serie/Bar/SimplifiedBar.cs b/Runtime/Serie/Bar/SimplifiedBar.cs
index e47fec72..3eed9ff7 100644
--- a/Runtime/Serie/Bar/SimplifiedBar.cs
+++ b/Runtime/Serie/Bar/SimplifiedBar.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -10,6 +9,8 @@ namespace XCharts.Runtime
[CoordOptions(typeof(GridCoord))]
[DefaultAnimation(AnimationType.LeftToRight)]
[SerieExtraComponent()]
+ [SerieDataExtraComponent()]
+ [SerieDataExtraField()]
public class SimplifiedBar : Serie, INeedSerieContainer, ISimplifiedSerie
{
public int containerIndex { get; internal set; }
diff --git a/Runtime/Serie/Bar/SimplifiedBarHandler.cs b/Runtime/Serie/Bar/SimplifiedBarHandler.cs
index 09b542c6..3e4264de 100644
--- a/Runtime/Serie/Bar/SimplifiedBarHandler.cs
+++ b/Runtime/Serie/Bar/SimplifiedBarHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -138,16 +137,17 @@ namespace XCharts.Runtime
var axisLength = isY ? m_SerieGrid.context.height : m_SerieGrid.context.width;
var axisXY = isY ? m_SerieGrid.context.y : m_SerieGrid.context.x;
+ var barCount = chart.GetSerieBarRealCount();
float categoryWidth = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
- float barGap = chart.GetSerieBarGap();
- float totalBarWidth = chart.GetSerieTotalWidth(categoryWidth, barGap);
- float barWidth = serie.GetBarWidth(categoryWidth);
+ float barGap = chart.GetSerieBarGap();
+ float totalBarWidth = chart.GetSerieTotalWidth(categoryWidth, barGap, barCount);
+ float barWidth = serie.GetBarWidth(categoryWidth, barCount);
float offset = (categoryWidth - totalBarWidth) * 0.5f;
float barGapWidth = barWidth + barWidth * barGap;
float gap = serie.barGap == -1 ? offset : offset + serie.index * barGapWidth;
- int maxCount = serie.maxShow > 0
- ? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
- : showData.Count;
+ int maxCount = serie.maxShow > 0 ?
+ (serie.maxShow > showData.Count ? showData.Count : serie.maxShow) :
+ showData.Count;
bool dataChanging = false;
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
@@ -231,7 +231,7 @@ namespace XCharts.Runtime
else
{
if (axis.context.minMaxRange <= 0) pY = grid.context.y;
- else pY = grid.context.y + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.height - barWidth);
+ else pY = grid.context.y + (float) ((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.height - barWidth);
}
pX = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
}
@@ -244,7 +244,7 @@ namespace XCharts.Runtime
else
{
if (axis.context.minMaxRange <= 0) pX = grid.context.x;
- else pX = grid.context.x + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.width - barWidth);
+ else pX = grid.context.x + (float) ((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.width - barWidth);
}
pY = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
}
diff --git a/Runtime/Serie/Candlestick/Candlestick.cs b/Runtime/Serie/Candlestick/Candlestick.cs
index 79bac851..6ac985ec 100644
--- a/Runtime/Serie/Candlestick/Candlestick.cs
+++ b/Runtime/Serie/Candlestick/Candlestick.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -7,6 +6,8 @@ namespace XCharts.Runtime
[SerieHandler(typeof(CandlestickHandler), true)]
[DefaultAnimation(AnimationType.LeftToRight)]
[SerieExtraComponent()]
+ [SerieDataExtraComponent(typeof(ItemStyle), typeof(EmphasisItemStyle))]
+ [SerieDataExtraField()]
public class Candlestick : Serie, INeedSerieContainer
{
public int containerIndex { get; internal set; }
diff --git a/Runtime/Serie/Candlestick/CandlestickHandler.cs b/Runtime/Serie/Candlestick/CandlestickHandler.cs
index 0029bb81..7955f60f 100644
--- a/Runtime/Serie/Candlestick/CandlestickHandler.cs
+++ b/Runtime/Serie/Candlestick/CandlestickHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -41,6 +40,7 @@ namespace XCharts.Runtime
param.category = category;
param.dimension = 1;
param.serieData = serieData;
+ param.dataCount = serie.dataCount;
param.value = 0;
param.total = 0;
param.color = color;
@@ -61,6 +61,7 @@ namespace XCharts.Runtime
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;
@@ -93,9 +94,9 @@ namespace XCharts.Runtime
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
float barWidth = serie.GetBarWidth(categoryWidth);
float gap = (categoryWidth - barWidth) / 2;
- int maxCount = serie.maxShow > 0
- ? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
- : showData.Count;
+ int maxCount = serie.maxShow > 0 ?
+ (serie.maxShow > showData.Count ? showData.Count : serie.maxShow) :
+ showData.Count;
bool dataChanging = false;
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
@@ -118,10 +119,10 @@ namespace XCharts.Runtime
var close = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var lowest = serieData.GetCurrData(2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var heighest = serieData.GetCurrData(3, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
- var isRise = yAxis.inverse ? close < open : close > open;
- var borderWidth = open == 0 ? 0f
- : (itemStyle.runtimeBorderWidth == 0 ? theme.serie.candlestickBorderWidth
- : itemStyle.runtimeBorderWidth);
+ var isRise = yAxis.inverse ? close open;
+ var borderWidth = open == 0 ? 0f :
+ (itemStyle.runtimeBorderWidth == 0 ? theme.serie.candlestickBorderWidth :
+ itemStyle.runtimeBorderWidth);
if (serieData.IsDataChanged()) dataChanging = true;
float pX = grid.context.x + i * categoryWidth;
float zeroY = grid.context.y + yAxis.context.offset;
@@ -132,8 +133,8 @@ namespace XCharts.Runtime
var minCut = (yMinValue > 0 ? yMinValue : 0);
if (valueTotal != 0)
{
- barHig = (float)((close - open) / valueTotal * grid.context.height);
- pY += (float)((open - minCut) / valueTotal * grid.context.height);
+ barHig = (float) ((close - open) / valueTotal * grid.context.height);
+ pY += (float) ((open - minCut) / valueTotal * grid.context.height);
}
serieData.context.stackHeight = barHig;
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
@@ -153,17 +154,17 @@ namespace XCharts.Runtime
top = chart.ClampInGrid(grid, top);
}
serie.context.dataPoints.Add(top);
- var areaColor = isRise
- ? itemStyle.GetColor(theme.serie.candlestickColor)
- : itemStyle.GetColor0(theme.serie.candlestickColor0);
- var borderColor = isRise
- ? itemStyle.GetBorderColor(theme.serie.candlestickBorderColor)
- : itemStyle.GetBorderColor0(theme.serie.candlestickBorderColor0);
+ var areaColor = isRise ?
+ itemStyle.GetColor(theme.serie.candlestickColor) :
+ itemStyle.GetColor0(theme.serie.candlestickColor0);
+ var borderColor = isRise ?
+ itemStyle.GetBorderColor(theme.serie.candlestickBorderColor) :
+ itemStyle.GetBorderColor0(theme.serie.candlestickBorderColor0);
var itemWidth = Mathf.Abs(prt.x - plb.x);
var itemHeight = Mathf.Abs(plt.y - prb.y);
var center = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
- var lowPos = new Vector3(center.x, zeroY + (float)((lowest - minCut) / valueTotal * grid.context.height));
- var heighPos = new Vector3(center.x, zeroY + (float)((heighest - minCut) / valueTotal * grid.context.height));
+ var lowPos = new Vector3(center.x, zeroY + (float) ((lowest - minCut) / valueTotal * grid.context.height));
+ var heighPos = new Vector3(center.x, zeroY + (float) ((heighest - minCut) / valueTotal * grid.context.height));
var openCenterPos = new Vector3(center.x, prb.y);
var closeCenterPos = new Vector3(center.x, prt.y);
if (barWidth > 2f * borderWidth)
@@ -181,7 +182,7 @@ namespace XCharts.Runtime
serie.clip, grid);
}
UGL.DrawBorder(vh, center, itemWidth, itemHeight, 2 * borderWidth, borderColor, 0,
- itemStyle.cornerRadius, isYAxis, 0.5f);
+ itemStyle.cornerRadius, isYAxis, 0.5f);
}
}
else
diff --git a/Runtime/Serie/Candlestick/SimplifiedCandlestick.cs b/Runtime/Serie/Candlestick/SimplifiedCandlestick.cs
index 3f41cdef..820b00a5 100644
--- a/Runtime/Serie/Candlestick/SimplifiedCandlestick.cs
+++ b/Runtime/Serie/Candlestick/SimplifiedCandlestick.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -7,6 +6,8 @@ namespace XCharts.Runtime
[SerieHandler(typeof(SimplifiedCandlestickHandler), true)]
[DefaultAnimation(AnimationType.LeftToRight)]
[SerieExtraComponent()]
+ [SerieDataExtraComponent()]
+ [SerieDataExtraField()]
public class SimplifiedCandlestick : Serie, INeedSerieContainer, ISimplifiedSerie
{
public int containerIndex { get; internal set; }
diff --git a/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs b/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs
index c8f31ac5..455f6005 100644
--- a/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs
+++ b/Runtime/Serie/Candlestick/SimplifiedCandlestickHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -41,6 +40,7 @@ namespace XCharts.Runtime
param.category = category;
param.dimension = 1;
param.serieData = serieData;
+ param.dataCount = serie.dataCount;
param.value = 0;
param.total = 0;
param.color = color;
@@ -61,6 +61,7 @@ namespace XCharts.Runtime
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;
@@ -93,9 +94,9 @@ namespace XCharts.Runtime
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.context.width, showData.Count, dataZoom);
float barWidth = serie.GetBarWidth(categoryWidth);
float gap = (categoryWidth - barWidth) / 2;
- int maxCount = serie.maxShow > 0
- ? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
- : showData.Count;
+ int maxCount = serie.maxShow > 0 ?
+ (serie.maxShow > showData.Count ? showData.Count : serie.maxShow) :
+ showData.Count;
bool dataChanging = false;
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
@@ -118,10 +119,10 @@ namespace XCharts.Runtime
var close = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var lowest = serieData.GetCurrData(2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
var heighest = serieData.GetCurrData(3, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
- var isRise = yAxis.inverse ? close < open : close > open;
- var borderWidth = open == 0 ? 0f
- : (itemStyle.runtimeBorderWidth == 0 ? theme.serie.candlestickBorderWidth
- : itemStyle.runtimeBorderWidth);
+ var isRise = yAxis.inverse ? close open;
+ var borderWidth = open == 0 ? 0f :
+ (itemStyle.runtimeBorderWidth == 0 ? theme.serie.candlestickBorderWidth :
+ itemStyle.runtimeBorderWidth);
if (serieData.IsDataChanged()) dataChanging = true;
float pX = grid.context.x + i * categoryWidth;
float zeroY = grid.context.y + yAxis.context.offset;
@@ -132,8 +133,8 @@ namespace XCharts.Runtime
var minCut = (yMinValue > 0 ? yMinValue : 0);
if (valueTotal != 0)
{
- barHig = (float)((close - open) / valueTotal * grid.context.height);
- pY += (float)((open - minCut) / valueTotal * grid.context.height);
+ barHig = (float) ((close - open) / valueTotal * grid.context.height);
+ pY += (float) ((open - minCut) / valueTotal * grid.context.height);
}
serieData.context.stackHeight = barHig;
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
@@ -153,17 +154,17 @@ namespace XCharts.Runtime
// top = chart.ClampInGrid(grid, top);
// }
serie.context.dataPoints.Add(top);
- var areaColor = isRise
- ? itemStyle.GetColor(theme.serie.candlestickColor)
- : itemStyle.GetColor0(theme.serie.candlestickColor0);
- var borderColor = isRise
- ? itemStyle.GetBorderColor(theme.serie.candlestickBorderColor)
- : itemStyle.GetBorderColor0(theme.serie.candlestickBorderColor0);
+ var areaColor = isRise ?
+ itemStyle.GetColor(theme.serie.candlestickColor) :
+ itemStyle.GetColor0(theme.serie.candlestickColor0);
+ var borderColor = isRise ?
+ itemStyle.GetBorderColor(theme.serie.candlestickBorderColor) :
+ itemStyle.GetBorderColor0(theme.serie.candlestickBorderColor0);
var itemWidth = Mathf.Abs(prt.x - plb.x);
var itemHeight = Mathf.Abs(plt.y - prb.y);
var center = new Vector3((plb.x + prt.x) / 2, (plt.y + prb.y) / 2);
- var lowPos = new Vector3(center.x, zeroY + (float)((lowest - minCut) / valueTotal * grid.context.height));
- var heighPos = new Vector3(center.x, zeroY + (float)((heighest - minCut) / valueTotal * grid.context.height));
+ var lowPos = new Vector3(center.x, zeroY + (float) ((lowest - minCut) / valueTotal * grid.context.height));
+ var heighPos = new Vector3(center.x, zeroY + (float) ((heighest - minCut) / valueTotal * grid.context.height));
var openCenterPos = new Vector3(center.x, prb.y);
var closeCenterPos = new Vector3(center.x, prt.y);
if (barWidth > 2f * borderWidth)
@@ -181,7 +182,7 @@ namespace XCharts.Runtime
serie.clip, grid);
}
UGL.DrawBorder(vh, center, itemWidth, itemHeight, 2 * borderWidth, borderColor, 0,
- itemStyle.cornerRadius, isYAxis, 0.5f);
+ itemStyle.cornerRadius, isYAxis, 0.5f);
}
if (isRise)
{
diff --git a/Runtime/Serie/Heatmap/Heatmap.cs b/Runtime/Serie/Heatmap/Heatmap.cs
index 84c51394..9d713569 100644
--- a/Runtime/Serie/Heatmap/Heatmap.cs
+++ b/Runtime/Serie/Heatmap/Heatmap.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -7,7 +6,9 @@ namespace XCharts.Runtime
[SerieHandler(typeof(HeatmapHandler), true)]
[DefaultAnimation(AnimationType.LeftToRight)]
[RequireChartComponent(typeof(VisualMap))]
- [SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
+ [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraField()]
public class Heatmap : Serie, INeedSerieContainer
{
public int containerIndex { get; internal set; }
@@ -19,11 +20,10 @@ namespace XCharts.Runtime
serie.itemStyle.borderWidth = 1;
serie.itemStyle.borderColor = Color.clear;
- var emphasis = serie.AddExtraComponent();
+ var emphasis = serie.AddExtraComponent();
emphasis.show = true;
- emphasis.itemStyle.show = true;
- emphasis.itemStyle.borderWidth = 1;
- emphasis.itemStyle.borderColor = Color.black;
+ emphasis.borderWidth = 1;
+ emphasis.borderColor = Color.black;
return serie;
}
}
diff --git a/Runtime/Serie/Heatmap/HeatmapHandler.cs b/Runtime/Serie/Heatmap/HeatmapHandler.cs
index 4788496a..517033fa 100644
--- a/Runtime/Serie/Heatmap/HeatmapHandler.cs
+++ b/Runtime/Serie/Heatmap/HeatmapHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -40,7 +39,7 @@ namespace XCharts.Runtime
{
var xAxis = chart.GetChartComponent(serie.xAxisIndex);
if (xAxis != null)
- category = xAxis.GetData((int)serieData.GetData(0));
+ category = xAxis.GetData((int) serieData.GetData(0));
}
title = serie.serieName;
@@ -49,6 +48,7 @@ namespace XCharts.Runtime
param.serieName = serie.serieName;
param.serieIndex = serie.index;
param.dimension = defaultDimension;
+ param.dataCount = serie.dataCount;
param.serieData = serieData;
param.color = serieData.context.color;
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
@@ -130,7 +130,7 @@ namespace XCharts.Runtime
xAxis.boundaryGap = true;
yAxis.boundaryGap = true;
var visualMap = chart.GetVisualMapOfSerie(serie);
- var emphasis = serie.emphasis;
+ var emphasisItemStyle = serie.emphasisItemStyle;
var xCount = xAxis.data.Count;
var yCount = yAxis.data.Count;
var xWidth = m_SerieGrid.context.width / xCount;
@@ -145,15 +145,15 @@ namespace XCharts.Runtime
var rectWid = xWidth - 2 * borderWidth;
var rectHig = yWidth - 2 * borderWidth;
- var borderColor = serie.itemStyle.opacity > 0
- ? serie.itemStyle.borderColor
- : ChartConst.clearColor32;
- borderColor.a = (byte)(borderColor.a * serie.itemStyle.opacity);
+ var borderColor = serie.itemStyle.opacity > 0 ?
+ serie.itemStyle.borderColor :
+ ChartConst.clearColor32;
+ borderColor.a = (byte) (borderColor.a * serie.itemStyle.opacity);
- var borderToColor = serie.itemStyle.opacity > 0
- ? serie.itemStyle.borderToColor
- : ChartConst.clearColor32;
- borderToColor.a = (byte)(borderToColor.a * serie.itemStyle.opacity);
+ var borderToColor = serie.itemStyle.opacity > 0 ?
+ serie.itemStyle.borderToColor :
+ ChartConst.clearColor32;
+ borderToColor.a = (byte) (borderToColor.a * serie.itemStyle.opacity);
serie.context.dataPoints.Clear();
serie.animation.InitProgress(0, xCount);
@@ -166,8 +166,8 @@ namespace XCharts.Runtime
{
var serieData = serie.data[n];
serieData.index = n;
- var i = (int)serieData.GetData(0);
- var j = (int)serieData.GetData(1);
+ var i = (int) serieData.GetData(0);
+ var j = (int) serieData.GetData(1);
var dimension = VisualMapHelper.GetDimension(visualMap, serieData.data.Count);
if (serie.IsIgnoreValue(serieData, dimension))
{
@@ -185,8 +185,8 @@ namespace XCharts.Runtime
serieData.context.canShowLabel = false;
serieData.context.rect = new Rect(pos.x - rectWid / 2, pos.y - rectHig / 2, rectWid, rectHig);
if (value == 0) continue;
- if ((value < rangeMin && rangeMin != visualMap.min)
- || (value > rangeMax && rangeMax != visualMap.max))
+ if ((value < rangeMin && rangeMin != visualMap.min) ||
+ (value > rangeMax && rangeMax != visualMap.max))
{
continue;
}
@@ -199,8 +199,8 @@ namespace XCharts.Runtime
serieData.context.canShowLabel = true;
serieData.context.color = color;
- var highlight = (serieData.context.highlight)
- || visualMap.context.pointerIndex > 0;
+ var highlight = (serieData.context.highlight) ||
+ visualMap.context.pointerIndex > 0;
//UGL.DrawRectangle(vh, pos, rectWid / 2, rectHig / 2, color);
UGL.DrawRectangle(vh, serieData.context.rect, color);
@@ -209,14 +209,14 @@ namespace XCharts.Runtime
{
UGL.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor, borderToColor);
}
- if (visualMap.hoverLink && highlight && emphasis != null && emphasis.show
- && emphasis.itemStyle.borderWidth > 0)
+ if (visualMap.hoverLink && highlight && emphasisItemStyle != null &&
+ emphasisItemStyle.borderWidth > 0)
{
- var emphasisBorderWidth = emphasis.itemStyle.borderWidth;
- var emphasisBorderColor = emphasis.itemStyle.opacity > 0
- ? emphasis.itemStyle.borderColor : ChartConst.clearColor32;
- var emphasisBorderToColor = emphasis.itemStyle.opacity > 0
- ? emphasis.itemStyle.borderToColor : ChartConst.clearColor32;
+ var emphasisBorderWidth = emphasisItemStyle.borderWidth;
+ var emphasisBorderColor = emphasisItemStyle.opacity > 0 ?
+ emphasisItemStyle.borderColor : ChartConst.clearColor32;
+ var emphasisBorderToColor = emphasisItemStyle.opacity > 0 ?
+ emphasisItemStyle.borderToColor : ChartConst.clearColor32;
UGL.DrawBorder(vh, pos, rectWid, rectHig, emphasisBorderWidth, emphasisBorderColor,
emphasisBorderToColor);
}
diff --git a/Runtime/Serie/Line/Line.cs b/Runtime/Serie/Line/Line.cs
index 3e48a90a..d504f13c 100644
--- a/Runtime/Serie/Line/Line.cs
+++ b/Runtime/Serie/Line/Line.cs
@@ -1,4 +1,3 @@
-
using System;
namespace XCharts.Runtime
@@ -13,7 +12,15 @@ namespace XCharts.Runtime
typeof(EndLabelStyle),
typeof(LineArrow),
typeof(AreaStyle),
- typeof(Emphasis))]
+ typeof(EmphasisItemStyle),
+ typeof(EmphasisLabelStyle))]
+ [SerieDataExtraComponent(
+ typeof(ItemStyle),
+ typeof(LabelStyle),
+ typeof(SerieSymbol),
+ typeof(EmphasisItemStyle),
+ typeof(EmphasisLabelStyle))]
+ [SerieDataExtraField("m_Ignore")]
public class Line : Serie, INeedSerieContainer
{
public int containerIndex { get; internal set; }
diff --git a/Runtime/Serie/Line/LineHandler.GridCoord.cs b/Runtime/Serie/Line/LineHandler.GridCoord.cs
index 226e69c1..ff008396 100644
--- a/Runtime/Serie/Line/LineHandler.GridCoord.cs
+++ b/Runtime/Serie/Line/LineHandler.GridCoord.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -14,13 +13,12 @@ namespace XCharts.Runtime
{
List> m_StackSerieData = new List>();
private GridCoord m_SerieGrid;
- private float m_LastLineWidth = 0f;
public override Vector3 GetSerieDataLabelOffset(SerieData serieData, LabelStyle label)
{
- var invert = label.autoOffset
- && SerieHelper.IsDownPoint(serie, serieData.index)
- && (serie.areaStyle == null || !serie.areaStyle.show);
+ var invert = label.autoOffset &&
+ SerieHelper.IsDownPoint(serie, serieData.index) &&
+ (serie.areaStyle == null || !serie.areaStyle.show);
if (invert)
{
var offset = label.GetOffset(serie.context.insideRadius);
@@ -37,7 +35,7 @@ namespace XCharts.Runtime
if (m_SerieGrid == null)
return;
var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
- var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter()) || m_LegendEnter || m_LastLineWidth != lineWidth;
+ var needCheck = (chart.isPointerInChart && m_SerieGrid.IsPointerEnter()) || m_LegendEnter;
if (!needCheck)
{
if (m_LastCheckContextFlag != needCheck)
@@ -45,10 +43,10 @@ namespace XCharts.Runtime
m_LastCheckContextFlag = needCheck;
serie.context.pointerItemDataIndex = -1;
serie.context.pointerEnter = false;
+ serie.highlight = false;
+ serie.ResetInteract();
foreach (var serieData in serie.data)
- {
- serieData.interact.Reset();
- }
+ serieData.context.highlight = false;
if (SeriesHelper.IsStack(chart.series))
chart.RefreshTopPainter();
else
@@ -56,7 +54,6 @@ namespace XCharts.Runtime
}
return;
}
- m_LastLineWidth = lineWidth;
m_LastCheckContextFlag = needCheck;
var themeSymbolSize = chart.theme.serie.lineSymbolSize;
var themeSymbolSelectedSize = chart.theme.serie.lineSymbolSelectedSize;
@@ -146,6 +143,23 @@ namespace XCharts.Runtime
var theme = chart.theme;
var interacting = false;
var lineArrow = serie.lineArrow;
+ var visualMap = chart.GetVisualMapOfSerie(serie);
+ var isVisualMapGradient = VisualMapHelper.IsNeedLineGradient(visualMap);
+ var isY = ComponentHelper.IsAnyCategoryOfYAxis(chart.components);
+
+ Axis axis;
+ Axis relativedAxis;
+
+ if (isY)
+ {
+ axis = chart.GetChartComponent(serie.yAxisIndex);
+ relativedAxis = chart.GetChartComponent(serie.xAxisIndex);
+ }
+ else
+ {
+ axis = chart.GetChartComponent(serie.xAxisIndex);
+ relativedAxis = chart.GetChartComponent(serie.yAxisIndex);
+ }
for (int i = 0; i < count; i++)
{
var serieData = serie.GetSerieData(i);
@@ -172,20 +186,26 @@ namespace XCharts.Runtime
continue;
var highlight = serie.data[i].context.highlight || serie.highlight;
- var symbolSize = highlight
- ? theme.serie.lineSymbolSelectedSize
- : theme.serie.lineSymbolSize;
+ var symbolSize = highlight ?
+ theme.serie.lineSymbolSelectedSize :
+ theme.serie.lineSymbolSize;
if (!serieData.interact.TryGetValue(ref symbolSize, ref interacting))
{
- symbolSize = highlight
- ? symbol.GetSelectedSize(serieData.data, symbolSize)
- : symbol.GetSize(serieData.data, symbolSize);
+ symbolSize = highlight ?
+ symbol.GetSelectedSize(serieData.data, symbolSize) :
+ symbol.GetSize(serieData.data, symbolSize);
serieData.interact.SetValue(ref interacting, symbolSize);
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
}
var symbolColor = SerieHelper.GetItemColor(serie, serieData, theme, serie.index, highlight);
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, theme, serie.index, highlight);
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, serie.index, highlight, false);
+
+ if (isVisualMapGradient)
+ {
+ symbolColor = VisualMapHelper.GetLineGradientColor(visualMap, pos, m_SerieGrid, axis, relativedAxis, symbolColor);
+ symbolToColor = symbolColor;
+ }
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
@@ -289,13 +309,13 @@ namespace XCharts.Runtime
var axisLength = isY ? m_SerieGrid.context.height : m_SerieGrid.context.width;
var scaleWid = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
- int maxCount = serie.maxShow > 0
- ? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
- : showData.Count;
+ int maxCount = serie.maxShow > 0 ?
+ (serie.maxShow > showData.Count ? showData.Count : serie.maxShow) :
+ showData.Count;
int rate = LineHelper.GetDataAverageRate(serie, m_SerieGrid, maxCount, false);
- var totalAverage = serie.sampleAverage > 0
- ? serie.sampleAverage
- : DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
+ var totalAverage = serie.sampleAverage > 0 ?
+ serie.sampleAverage :
+ DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
var dataChanging = false;
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
diff --git a/Runtime/Serie/Line/LineHandler.PolarCoord.cs b/Runtime/Serie/Line/LineHandler.PolarCoord.cs
index 6a23387f..ea5b5698 100644
--- a/Runtime/Serie/Line/LineHandler.PolarCoord.cs
+++ b/Runtime/Serie/Line/LineHandler.PolarCoord.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
using XUGL;
@@ -76,7 +75,7 @@ namespace XCharts.Runtime
var serieData = serie.data[i];
var angle0 = serieData.context.angle;
var angle1 = i >= serie.dataCount - 1 ? angle0 : serie.data[i + 1].context.angle;
-
+
if (pointerAngle >= angle0 && pointerAngle < angle1)
{
serie.context.pointerItemDataIndex = i;
@@ -146,7 +145,7 @@ namespace XCharts.Runtime
cp = GetPolarPos(m_SeriePolar, m_AngleAxis, datas[i], min, max, radius);
var np = i == datas.Count - 1 ? cp :
- GetPolarPos(m_SeriePolar, m_AngleAxis, datas[i + 1], min, max, radius);
+ GetPolarPos(m_SeriePolar, m_AngleAxis, datas[i + 1], min, max, radius);
UGLHelper.GetLinePoints(lp, cp, np, lineWidth,
ref ltp, ref lbp,
@@ -214,13 +213,13 @@ namespace XCharts.Runtime
continue;
bool highlight = serieData.context.highlight || serie.highlight;
- if ((!symbol.show || !symbol.ShowSymbol(i, count) || serie.IsPerformanceMode())
- && !serieData.context.highlight)
+ if ((!symbol.show || !symbol.ShowSymbol(i, count) || serie.IsPerformanceMode()) &&
+ !serieData.context.highlight)
continue;
- var symbolSize = highlight
- ? symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSize)
- : symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
+ var symbolSize = highlight ?
+ symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSize) :
+ symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, n, highlight);
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, n, highlight);
@@ -243,15 +242,15 @@ namespace XCharts.Runtime
if (!m_AngleAxis.clockwise)
{
- angle = m_AngleAxis.GetValueAngle((float)serieData.GetData(1));
+ angle = m_AngleAxis.GetValueAngle((float) serieData.GetData(1));
}
else
{
- angle = m_AngleAxis.GetValueAngle((float)serieData.GetData(1));
+ angle = m_AngleAxis.GetValueAngle((float) serieData.GetData(1));
}
var value = serieData.GetData(0);
- var radius = (float)((value - min) / (max - min) * polarRadius);
+ var radius = (float) ((value - min) / (max - min) * polarRadius);
angle = (angle + 360) % 360;
serieData.context.angle = angle;
diff --git a/Runtime/Serie/Line/LineHandler.cs b/Runtime/Serie/Line/LineHandler.cs
index 13d814b9..f15ba49e 100644
--- a/Runtime/Serie/Line/LineHandler.cs
+++ b/Runtime/Serie/Line/LineHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -69,7 +68,7 @@ namespace XCharts.Runtime
var endLabelList = m_SerieGrid.context.endLabelList;
if (endLabelList.Count <= 1) return;
- endLabelList.Sort(delegate (ChartLabel a, ChartLabel b)
+ endLabelList.Sort(delegate(ChartLabel a, ChartLabel b)
{
if (a == null || b == null) return 1;
return b.transform.position.y.CompareTo(a.transform.position.y);
diff --git a/Runtime/Serie/Line/LineHelper.cs b/Runtime/Serie/Line/LineHelper.cs
index c7d7f401..27d06aeb 100644
--- a/Runtime/Serie/Line/LineHelper.cs
+++ b/Runtime/Serie/Line/LineHelper.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -16,7 +15,7 @@ namespace XCharts.Runtime
var rate = 0;
var width = isYAxis ? grid.context.height : grid.context.width;
if (sampleDist > 0)
- rate = (int)((maxCount - serie.minShow) / (width / sampleDist));
+ rate = (int) ((maxCount - serie.minShow) / (width / sampleDist));
if (rate < 1)
rate = 1;
return rate;
@@ -69,12 +68,12 @@ namespace XCharts.Runtime
var lp = Vector3.zero;
var isVisualMapGradient = VisualMapHelper.IsNeedAreaGradient(visualMap);
var areaLerp = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);
- var zsp = isY
- ? new Vector3(zero, points[0].position.y)
- : new Vector3(points[0].position.x, zero);
- var zep = isY
- ? new Vector3(zero, points[count - 1].position.y)
- : new Vector3(points[count - 1].position.x, zero);
+ var zsp = isY ?
+ new Vector3(zero, points[0].position.y) :
+ new Vector3(points[0].position.x, zero);
+ var zep = isY ?
+ new Vector3(zero, points[count - 1].position.y) :
+ new Vector3(points[count - 1].position.x, zero);
var lastDataIsIgnore = false;
for (int i = 0; i < points.Count; i++)
@@ -189,8 +188,8 @@ namespace XCharts.Runtime
var ip = Vector3.zero;
if (UGLHelper.GetIntersection(ltp, tp,
- new Vector3(progress, -10000),
- new Vector3(progress, 10000), ref ip))
+ new Vector3(progress, -10000),
+ new Vector3(progress, 10000), ref ip))
tp = ip;
else
tp = new Vector3(progress, tp.y);
@@ -203,8 +202,8 @@ namespace XCharts.Runtime
var ip = Vector3.zero;
if (UGLHelper.GetIntersection(lbp, bp,
- new Vector3(progress, -10000),
- new Vector3(progress, 10000), ref ip))
+ new Vector3(progress, -10000),
+ new Vector3(progress, 10000), ref ip))
bp = ip;
else
bp = new Vector3(progress, bp.y);
@@ -335,7 +334,7 @@ namespace XCharts.Runtime
if (dataCount == 2 || isBreak)
{
AddLineVertToVertexHelper(vh, clp, crp, lineColor, isVisualMapGradient, isLineStyleGradient,
- visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
+ visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
serie.context.lineEndPostion = cp;
serie.context.lineEndValue = AxisHelper.GetAxisPositionValue(grid, relativedAxis, cp);
break;
@@ -346,7 +345,7 @@ namespace XCharts.Runtime
{
if (bitp)
AddLineVertToVertexHelper(vh, itp, ibp, lineColor, isVisualMapGradient, isLineStyleGradient,
- visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
+ visualMap, serie.lineStyle, grid, axis, relativedAxis, true, lastDataIsIgnore, isIgnore);
else
{
AddLineVertToVertexHelper(vh, ltp, clp, lineColor, isVisualMapGradient, isLineStyleGradient,
@@ -455,7 +454,7 @@ namespace XCharts.Runtime
var ignore = serie.context.dataIgnores[i];
var dir = (ep - sp).normalized;
var dist = Vector3.Distance(sp, ep);
- var segment = (int)(dist / setting.lineSegmentDistance);
+ var segment = (int) (dist / setting.lineSegmentDistance);
serie.context.drawPoints.Add(new PointInfo(sp, ignore));
for (int j = 1; j < segment; j++)
{
@@ -516,8 +515,8 @@ namespace XCharts.Runtime
{
var cp = points[i];
var ignore = serie.context.dataIgnores[i];
- if ((isY && Mathf.Abs(lp.x - cp.x) <= lineWidth)
- || (!isY && Mathf.Abs(lp.y - cp.y) <= lineWidth))
+ if ((isY && Mathf.Abs(lp.x - cp.x) <= lineWidth) ||
+ (!isY && Mathf.Abs(lp.y - cp.y) <= lineWidth))
{
serie.context.drawPoints.Add(new PointInfo(cp, ignore));
lp = cp;
@@ -526,22 +525,22 @@ namespace XCharts.Runtime
switch (serie.lineType)
{
case LineType.StepStart:
- serie.context.drawPoints.Add(new PointInfo(isY
- ? new Vector3(cp.x, lp.y)
- : new Vector3(lp.x, cp.y), ignore));
+ serie.context.drawPoints.Add(new PointInfo(isY ?
+ new Vector3(cp.x, lp.y) :
+ new Vector3(lp.x, cp.y), ignore));
break;
case LineType.StepMiddle:
- serie.context.drawPoints.Add(new PointInfo(isY
- ? new Vector3(lp.x, (lp.y + cp.y) / 2)
- : new Vector3((lp.x + cp.x) / 2, lp.y), ignore));
- serie.context.drawPoints.Add(new PointInfo(isY
- ? new Vector3(cp.x, (lp.y + cp.y) / 2)
- : new Vector3((lp.x + cp.x) / 2, cp.y), ignore));
+ serie.context.drawPoints.Add(new PointInfo(isY ?
+ new Vector3(lp.x, (lp.y + cp.y) / 2) :
+ new Vector3((lp.x + cp.x) / 2, lp.y), ignore));
+ serie.context.drawPoints.Add(new PointInfo(isY ?
+ new Vector3(cp.x, (lp.y + cp.y) / 2) :
+ new Vector3((lp.x + cp.x) / 2, cp.y), ignore));
break;
case LineType.StepEnd:
- serie.context.drawPoints.Add(new PointInfo(isY
- ? new Vector3(lp.x, cp.y)
- : new Vector3(cp.x, lp.y), ignore));
+ serie.context.drawPoints.Add(new PointInfo(isY ?
+ new Vector3(lp.x, cp.y) :
+ new Vector3(cp.x, lp.y), ignore));
break;
}
serie.context.drawPoints.Add(new PointInfo(cp, ignore));
diff --git a/Runtime/Serie/Line/SimplifiedLine.cs b/Runtime/Serie/Line/SimplifiedLine.cs
index cf4bbdf2..94470d90 100644
--- a/Runtime/Serie/Line/SimplifiedLine.cs
+++ b/Runtime/Serie/Line/SimplifiedLine.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -10,6 +9,8 @@ namespace XCharts.Runtime
[CoordOptions(typeof(GridCoord))]
[DefaultAnimation(AnimationType.LeftToRight)]
[SerieExtraComponent(typeof(AreaStyle))]
+ [SerieDataExtraComponent()]
+ [SerieDataExtraField()]
public class SimplifiedLine : Serie, INeedSerieContainer, ISimplifiedSerie
{
public int containerIndex { get; internal set; }
diff --git a/Runtime/Serie/Line/SimplifiedLineHandler.cs b/Runtime/Serie/Line/SimplifiedLineHandler.cs
index 105f1c95..8b2b0e09 100644
--- a/Runtime/Serie/Line/SimplifiedLineHandler.cs
+++ b/Runtime/Serie/Line/SimplifiedLineHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -183,13 +182,13 @@ namespace XCharts.Runtime
var axisLength = isY ? m_SerieGrid.context.height : m_SerieGrid.context.width;
var scaleWid = AxisHelper.GetDataWidth(axis, axisLength, showData.Count, dataZoom);
- int maxCount = serie.maxShow > 0
- ? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
- : showData.Count;
+ int maxCount = serie.maxShow > 0 ?
+ (serie.maxShow > showData.Count ? showData.Count : serie.maxShow) :
+ showData.Count;
int rate = LineHelper.GetDataAverageRate(serie, m_SerieGrid, maxCount, false);
- var totalAverage = serie.sampleAverage > 0
- ? serie.sampleAverage
- : DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
+ var totalAverage = serie.sampleAverage > 0 ?
+ serie.sampleAverage :
+ DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
var dataChanging = false;
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
diff --git a/Runtime/Serie/Parallel/Parallel.cs b/Runtime/Serie/Parallel/Parallel.cs
index 72ace289..9d6b7528 100644
--- a/Runtime/Serie/Parallel/Parallel.cs
+++ b/Runtime/Serie/Parallel/Parallel.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -7,6 +6,8 @@ namespace XCharts.Runtime
[System.Serializable]
[SerieHandler(typeof(ParallelHandler), true)]
[RequireChartComponent(typeof(ParallelCoord))]
+ [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraField()]
public class Parallel : Serie, INeedSerieContainer
{
public int containerIndex { get; internal set; }
@@ -19,12 +20,13 @@ namespace XCharts.Runtime
for (int i = 0; i < 100; i++)
{
- var data = new List(){
- Random.Range(0f,50f),
- Random.Range(0f,100f),
- Random.Range(0f,1000f),
- Random.Range(0,5),
- };
+ var data = new List()
+ {
+ Random.Range(0f, 50f),
+ Random.Range(0f, 100f),
+ Random.Range(0f, 1000f),
+ Random.Range(0, 5),
+ };
serie.AddData(data, "data" + i);
}
chart.RefreshChart();
diff --git a/Runtime/Serie/Parallel/ParallelHandler.cs b/Runtime/Serie/Parallel/ParallelHandler.cs
index f609f7da..38a64534 100644
--- a/Runtime/Serie/Parallel/ParallelHandler.cs
+++ b/Runtime/Serie/Parallel/ParallelHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -23,8 +22,7 @@ namespace XCharts.Runtime
}
private void UpdateSerieContext()
- {
- }
+ { }
private void DrawParallelSerie(VertexHelper vh, Parallel serie)
{
@@ -44,13 +42,13 @@ namespace XCharts.Runtime
var lineColor = SerieHelper.GetLineColor(serie, null, chart.theme, serie.context.colorIndex, false);
var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth);
- float currDetailProgress = !isHorizonal
- ? parallel.context.x
- : parallel.context.y;
+ float currDetailProgress = !isHorizonal ?
+ parallel.context.x :
+ parallel.context.y;
- float totalDetailProgress = !isHorizonal
- ? parallel.context.x + parallel.context.width
- : parallel.context.y + parallel.context.height;
+ float totalDetailProgress = !isHorizonal ?
+ parallel.context.x + parallel.context.width :
+ parallel.context.y + parallel.context.height;
serie.animation.InitProgress(currDetailProgress, totalDetailProgress);
diff --git a/Runtime/Serie/Pie/Pie.cs b/Runtime/Serie/Pie/Pie.cs
index 0d4980ee..39278796 100644
--- a/Runtime/Serie/Pie/Pie.cs
+++ b/Runtime/Serie/Pie/Pie.cs
@@ -1,14 +1,16 @@
-
namespace XCharts.Runtime
{
[System.Serializable]
[SerieConvert(typeof(Line), typeof(Bar))]
[SerieHandler(typeof(PieHandler), true)]
[DefaultAnimation(AnimationType.Clockwise)]
- [SerieExtraComponent(typeof(LabelStyle), typeof(LabelLine), typeof(Emphasis))]
+ [SerieExtraComponent(typeof(LabelStyle), typeof(LabelLine), typeof(TitleStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle), typeof(EmphasisLabelLine))]
+ [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(LabelLine), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle), typeof(EmphasisLabelLine))]
+ [SerieDataExtraField("m_Ignore", "m_Selected", "m_Radius")]
public class Pie : Serie
{
public override bool useDataNameForColor { get { return true; } }
+ public override bool titleJustForSerie { get { return true; } }
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
{
diff --git a/Runtime/Serie/Pie/PieHandler.cs b/Runtime/Serie/Pie/PieHandler.cs
index 00a912c1..d8ee94ac 100644
--- a/Runtime/Serie/Pie/PieHandler.cs
+++ b/Runtime/Serie/Pie/PieHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
@@ -37,6 +36,11 @@ namespace XCharts.Runtime
return SerieLabelHelper.GetRealLabelPosition(serie, serieData, label, labelLine);
}
+ public override Vector3 GetSerieDataTitlePosition(SerieData serieData, TitleStyle titleStyle)
+ {
+ return serie.context.center;
+ }
+
public override void OnLegendButtonClick(int index, string legendName, bool show)
{
if (!serie.IsLegendName(legendName))
@@ -192,16 +196,16 @@ namespace XCharts.Runtime
{
continue;
}
- float degree = serie.pieRoseType == RoseType.Area
- ? (totalDegree / showdataCount)
- : (float)(totalDegree * value / dataTotalFilterMinAngle);
+ float degree = serie.pieRoseType == RoseType.Area ?
+ (totalDegree / showdataCount) :
+ (float) (totalDegree * value / dataTotalFilterMinAngle);
if (serie.minAngle > 0 && degree < serie.minAngle) degree = serie.minAngle;
serieData.context.toAngle = startDegree + degree;
if (serieData.radius > 0)
- serieData.context.outsideRadius = serieData.radius;
+ serieData.context.outsideRadius = ChartHelper.GetActualValue(serieData.radius, Mathf.Min(chart.chartWidth, chart.chartHeight));
else
serieData.context.outsideRadius = serie.pieRoseType > 0 ?
- serie.context.insideRadius + (float)((serie.context.outsideRadius - serie.context.insideRadius) * value / serie.context.dataMax) :
+ serie.context.insideRadius + (float) ((serie.context.outsideRadius - serie.context.insideRadius) * value / serie.context.dataMax) :
serie.context.outsideRadius;
if (serieData.context.highlight)
{
@@ -404,9 +408,9 @@ namespace XCharts.Runtime
{
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
- if (serieLabel != null && serieLabel.show
- && labelLine != null && labelLine.show
- && (serieLabel.IsDefaultPosition(LabelStyle.Position.Outside)))
+ if (serieLabel != null && serieLabel.show &&
+ labelLine != null && labelLine.show &&
+ (serieLabel.IsDefaultPosition(LabelStyle.Position.Outside)))
{
var insideRadius = serieData.context.insideRadius;
var outSideRadius = serieData.context.outsideRadius;
@@ -469,8 +473,8 @@ namespace XCharts.Runtime
pos6 = pos0 + Vector3.left * lineCircleDiff;
pos4 = pos6 + Vector3.left * r4;
}
- var pos5X = (currAngle - startAngle) % 360 > 180
- ? pos2.x - labelLine.lineLength2 : pos2.x + labelLine.lineLength2;
+ var pos5X = (currAngle - startAngle) % 360 > 180 ?
+ pos2.x - labelLine.lineLength2 : pos2.x + labelLine.lineLength2;
var pos5 = new Vector3(pos5X, pos2.y);
switch (labelLine.lineType)
{
@@ -506,9 +510,9 @@ namespace XCharts.Runtime
var serieData = serie.data[i];
if (angle >= serieData.context.startAngle && angle <= serieData.context.toAngle)
{
- var ndist = serieData.selected
- ? Vector2.Distance(local, serieData.context.offsetCenter)
- : dist;
+ var ndist = serieData.selected ?
+ Vector2.Distance(local, serieData.context.offsetCenter) :
+ dist;
if (ndist >= serieData.context.insideRadius && ndist <= serieData.context.outsideRadius)
{
return i;
diff --git a/Runtime/Serie/Radar/Radar.cs b/Runtime/Serie/Radar/Radar.cs
index 7475fe2b..3691d924 100644
--- a/Runtime/Serie/Radar/Radar.cs
+++ b/Runtime/Serie/Radar/Radar.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -7,13 +6,15 @@ namespace XCharts.Runtime
[System.Serializable]
[SerieHandler(typeof(RadarHandler), true)]
[RequireChartComponent(typeof(RadarCoord))]
- [SerieExtraComponent(typeof(LabelStyle), typeof(LabelLine), typeof(AreaStyle), typeof(Emphasis))]
+ [SerieExtraComponent(typeof(LabelStyle), typeof(AreaStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(AreaStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraField()]
public class Radar : Serie, INeedSerieContainer
{
public int containerIndex { get; internal set; }
public int containterInstanceId { get; internal set; }
-
public override bool useDataNameForColor { get { return true; } }
+
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
{
chart.AddChartComponentWhenNoExist();
diff --git a/Runtime/Serie/Radar/RadarHandler.cs b/Runtime/Serie/Radar/RadarHandler.cs
index add6cdc2..374455db 100644
--- a/Runtime/Serie/Radar/RadarHandler.cs
+++ b/Runtime/Serie/Radar/RadarHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -67,6 +66,7 @@ namespace XCharts.Runtime
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;
@@ -85,8 +85,8 @@ namespace XCharts.Runtime
private void UpdateSerieContext()
{
- var needCheck = m_LegendEnter
- || (chart.isPointerInChart && (m_RadarCoord != null && m_RadarCoord.IsPointerEnter()));
+ var needCheck = m_LegendEnter ||
+ (chart.isPointerInChart && (m_RadarCoord != null && m_RadarCoord.IsPointerEnter()));
var needInteract = false;
var needHideAll = false;
if (!needCheck)
@@ -249,7 +249,7 @@ namespace XCharts.Runtime
max = serie.context.dataMax;
}
}
- var radius = (float)(m_RadarCoord.context.dataRadius * (value - min) / (max - min));
+ var radius = (float) (m_RadarCoord.context.dataRadius * (value - min) / (max - min));
var currAngle = (n + (m_RadarCoord.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
radius *= rate;
if (n == 0)
@@ -287,14 +287,14 @@ namespace XCharts.Runtime
for (int m = 0; m < serieData.context.dataPoints.Count; m++)
{
var point = serieData.context.dataPoints[m];
- var symbolSize = isHighlight
- ? symbol.GetSelectedSize(null, chart.theme.serie.lineSymbolSelectedSize)
- : symbol.GetSize(null, chart.theme.serie.lineSymbolSize);
+ var symbolSize = isHighlight ?
+ symbol.GetSelectedSize(null, chart.theme.serie.lineSymbolSelectedSize) :
+ symbol.GetSize(null, chart.theme.serie.lineSymbolSize);
if (!serieData.interact.TryGetValue(ref symbolSize, ref interacting))
{
- symbolSize = isHighlight
- ? symbol.GetSelectedSize(serieData.data, symbolSize)
- : symbol.GetSize(serieData.data, symbolSize);
+ symbolSize = isHighlight ?
+ symbol.GetSelectedSize(serieData.data, symbolSize) :
+ symbol.GetSize(serieData.data, symbolSize);
serieData.interact.SetValue(ref interacting, symbolSize);
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
}
@@ -305,7 +305,7 @@ namespace XCharts.Runtime
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight);
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, point, symbolColor,
- symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius);
+ symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius);
}
}
}
@@ -378,8 +378,8 @@ namespace XCharts.Runtime
{
lineColor = radar.outRangeColor;
}
- var radius = (float)(max < 0 ? radar.context.dataRadius - radar.context.dataRadius * value / max
- : radar.context.dataRadius * value / max);
+ var radius = (float) (max < 0 ? radar.context.dataRadius - radar.context.dataRadius * value / max :
+ radar.context.dataRadius * value / max);
var currAngle = (index + (radar.positionType == RadarCoord.PositionType.Between ? 0.5f : 0)) * angle;
radius *= rate;
if (index == startIndex)
@@ -420,7 +420,7 @@ namespace XCharts.Runtime
{
if (radar.connectCenter)
ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, centerPos,
- chart.theme.serie.lineWidth, LineStyle.Type.Solid, lastColor, lastColor);
+ chart.theme.serie.lineWidth, LineStyle.Type.Solid, lastColor, lastColor);
ChartDrawer.DrawLineStyle(vh, lineStyle, startPoint, firstPoint, chart.theme.serie.lineWidth,
LineStyle.Type.Solid, lineColor, radar.lineGradient ? firstColor : lineColor);
}
@@ -433,9 +433,9 @@ namespace XCharts.Runtime
if (!serieData.show) continue;
var isHighlight = serie.highlight || serieData.context.highlight || serie.context.pointerEnter;
var serieIndex = serieData.index;
- var symbolSize = isHighlight
- ? serie.symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSelectedSize)
- : serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
+ var symbolSize = isHighlight ?
+ serie.symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSelectedSize) :
+ serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight);
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
@@ -448,7 +448,7 @@ namespace XCharts.Runtime
symbolToColor = radar.outRangeColor;
}
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor,
- symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
+ symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
}
}
if (!serie.animation.IsFinish())
@@ -484,9 +484,9 @@ namespace XCharts.Runtime
{
if (serie.symbol.show && serie.symbol.type != SymbolType.None)
{
- var symbolSize = isHighlight
- ? serie.symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSelectedSize)
- : serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
+ var symbolSize = isHighlight ?
+ serie.symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSelectedSize) :
+ serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize);
var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight);
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
@@ -496,7 +496,7 @@ namespace XCharts.Runtime
foreach (var point in pointList)
{
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
- symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
+ symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
}
}
}
diff --git a/Runtime/Serie/Ring/Ring.cs b/Runtime/Serie/Ring/Ring.cs
index 2e8388a4..d97cdb40 100644
--- a/Runtime/Serie/Ring/Ring.cs
+++ b/Runtime/Serie/Ring/Ring.cs
@@ -1,11 +1,12 @@
-
using UnityEngine;
namespace XCharts.Runtime
{
[System.Serializable]
[SerieHandler(typeof(RingHandler), true)]
- [SerieExtraComponent(typeof(LabelStyle), typeof(TitleStyle), typeof(Emphasis))]
+ [SerieExtraComponent(typeof(LabelStyle), typeof(TitleStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(TitleStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraField()]
public class Ring : Serie
{
public override bool useDataNameForColor { get { return true; } }
diff --git a/Runtime/Serie/Ring/RingHandler.cs b/Runtime/Serie/Ring/RingHandler.cs
index 58ed2583..70c5f400 100644
--- a/Runtime/Serie/Ring/RingHandler.cs
+++ b/Runtime/Serie/Ring/RingHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -94,12 +93,13 @@ namespace XCharts.Runtime
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 = SerieHelper.GetItemColor(serie, serieData, chart.theme, dataIndex, false);
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
- param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); ;
+ param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);;
param.columns.Clear();
param.columns.Add(param.marker);
@@ -155,7 +155,7 @@ namespace XCharts.Runtime
if (serieData.IsDataChanged()) dataChanging = true;
var value = serieData.GetFirstData(dataChangeDuration);
var max = serieData.GetLastData();
- var degree = (float)(360 * value / max);
+ var degree = (float) (360 * value / max);
var startDegree = GetStartAngle(serie);
var toDegree = GetToAngle(serie, degree);
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight);
@@ -215,8 +215,7 @@ namespace XCharts.Runtime
}
public override void OnPointerDown(PointerEventData eventData)
- {
- }
+ { }
private float GetStartAngle(Serie serie)
{
@@ -281,11 +280,11 @@ namespace XCharts.Runtime
if (itemStyle.show && itemStyle.borderWidth > 0 && !ChartHelper.IsClearColor(itemStyle.borderColor))
{
UGL.DrawDoughnut(vh, serie.context.center, outsideRadius,
- outsideRadius + itemStyle.borderWidth, itemStyle.borderColor,
- Color.clear, chart.settings.cicleSmoothness);
+ outsideRadius + itemStyle.borderWidth, itemStyle.borderColor,
+ Color.clear, chart.settings.cicleSmoothness);
UGL.DrawDoughnut(vh, serie.context.center, insideRadius,
- insideRadius + itemStyle.borderWidth, itemStyle.borderColor,
- Color.clear, chart.settings.cicleSmoothness);
+ insideRadius + itemStyle.borderWidth, itemStyle.borderColor,
+ Color.clear, chart.settings.cicleSmoothness);
}
}
diff --git a/Runtime/Serie/Scatter/BaseScatter.cs b/Runtime/Serie/Scatter/BaseScatter.cs
index 3696f2ca..bb0cbb53 100644
--- a/Runtime/Serie/Scatter/BaseScatter.cs
+++ b/Runtime/Serie/Scatter/BaseScatter.cs
@@ -1,4 +1,3 @@
-
namespace XCharts.Runtime
{
[System.Serializable]
diff --git a/Runtime/Serie/Scatter/BaseScatterHandler.cs b/Runtime/Serie/Scatter/BaseScatterHandler.cs
index 1a09fab4..f8a3aa78 100644
--- a/Runtime/Serie/Scatter/BaseScatterHandler.cs
+++ b/Runtime/Serie/Scatter/BaseScatterHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -35,6 +34,7 @@ namespace XCharts.Runtime
param.serieIndex = serie.index;
param.category = category;
param.dimension = 1;
+ param.dataCount = serie.dataCount;
param.serieData = serieData;
param.color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false);
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
@@ -130,8 +130,8 @@ namespace XCharts.Runtime
var theme = chart.theme;
int maxCount = serie.maxShow > 0 ?
- (serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow)
- : serie.dataCount;
+ (serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow) :
+ serie.dataCount;
serie.animation.InitProgress(0, 1);
var rate = serie.animation.GetCurrRate();
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
@@ -175,14 +175,14 @@ namespace XCharts.Runtime
serie.context.dataPoints.Add(pos);
serieData.context.position = pos;
var datas = serieData.data;
- var symbolSize = serie.highlight || serieData.context.highlight
- ? theme.serie.scatterSymbolSelectedSize
- : theme.serie.scatterSymbolSize;
+ var symbolSize = serie.highlight || serieData.context.highlight ?
+ theme.serie.scatterSymbolSelectedSize :
+ theme.serie.scatterSymbolSize;
if (!serieData.interact.TryGetValue(ref symbolSize, ref interacting))
{
- symbolSize = highlight
- ? symbol.GetSelectedSize(serieData.data, symbolSize)
- : symbol.GetSize(serieData.data, symbolSize);
+ symbolSize = highlight ?
+ symbol.GetSelectedSize(serieData.data, symbolSize) :
+ symbol.GetSize(serieData.data, symbolSize);
serieData.interact.SetValue(ref interacting, symbolSize);
}
@@ -193,7 +193,7 @@ namespace XCharts.Runtime
for (int count = 0; count < symbol.animationSize.Count; count++)
{
var nowSize = symbol.animationSize[count];
- color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
+ color.a = (byte) (255 * (symbolSize - nowSize) / symbolSize);
chart.DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos,
color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
}
@@ -235,8 +235,8 @@ namespace XCharts.Runtime
var theme = chart.theme;
int maxCount = serie.maxShow > 0 ?
- (serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow)
- : serie.dataCount;
+ (serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow) :
+ serie.dataCount;
serie.animation.InitProgress(0, 1);
var rate = serie.animation.GetCurrRate();
@@ -297,7 +297,7 @@ namespace XCharts.Runtime
for (int count = 0; count < symbol.animationSize.Count; count++)
{
var nowSize = symbol.animationSize[count];
- color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
+ color.a = (byte) (255 * (symbolSize - nowSize) / symbolSize);
chart.DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos,
color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
}
@@ -333,17 +333,17 @@ namespace XCharts.Runtime
{
if (axis.boundaryGap)
{
- float tick = (float)(totalWidth / (axis.context.minMaxRange + 1));
- return tick / 2 + (float)(value - axis.context.minValue) * tick;
+ float tick = (float) (totalWidth / (axis.context.minMaxRange + 1));
+ return tick / 2 + (float) (value - axis.context.minValue) * tick;
}
else
{
- return (float)((value - axis.context.minValue) / axis.context.minMaxRange * totalWidth);
+ return (float) ((value - axis.context.minValue) / axis.context.minMaxRange * totalWidth);
}
}
else
{
- return (float)((value - axis.context.minValue) / axis.context.minMaxRange * totalWidth);
+ return (float) ((value - axis.context.minValue) / axis.context.minMaxRange * totalWidth);
}
}
}
diff --git a/Runtime/Serie/Scatter/EffectScatter.cs b/Runtime/Serie/Scatter/EffectScatter.cs
index 1419adae..f2219173 100644
--- a/Runtime/Serie/Scatter/EffectScatter.cs
+++ b/Runtime/Serie/Scatter/EffectScatter.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -6,7 +5,9 @@ namespace XCharts.Runtime
[System.Serializable]
[SerieHandler(typeof(EffectScatterHandler), true)]
[CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))]
- [SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
+ [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraField("m_Radius")]
public class EffectScatter : BaseScatter
{
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
diff --git a/Runtime/Serie/Scatter/EffectScatterHandler.cs b/Runtime/Serie/Scatter/EffectScatterHandler.cs
index 5931c3d5..0ace1597 100644
--- a/Runtime/Serie/Scatter/EffectScatterHandler.cs
+++ b/Runtime/Serie/Scatter/EffectScatterHandler.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
diff --git a/Runtime/Serie/Scatter/Scatter.cs b/Runtime/Serie/Scatter/Scatter.cs
index becaa163..f633d74a 100644
--- a/Runtime/Serie/Scatter/Scatter.cs
+++ b/Runtime/Serie/Scatter/Scatter.cs
@@ -1,6 +1,3 @@
-
-
-
using UnityEngine;
namespace XCharts.Runtime
@@ -8,7 +5,9 @@ namespace XCharts.Runtime
[System.Serializable]
[SerieHandler(typeof(ScatterHandler), true)]
[CoordOptions(typeof(GridCoord), typeof(SingleAxisCoord))]
- [SerieExtraComponent(typeof(LabelStyle), typeof(Emphasis))]
+ [SerieExtraComponent(typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraComponent(typeof(ItemStyle), typeof(LabelStyle), typeof(EmphasisItemStyle), typeof(EmphasisLabelStyle))]
+ [SerieDataExtraField("m_Radius")]
public class Scatter : BaseScatter
{
public static Serie AddDefaultSerie(BaseChart chart, string serieName)
diff --git a/Runtime/Serie/Scatter/ScatterHandler.cs b/Runtime/Serie/Scatter/ScatterHandler.cs
index 932ebb85..9174cd3c 100644
--- a/Runtime/Serie/Scatter/ScatterHandler.cs
+++ b/Runtime/Serie/Scatter/ScatterHandler.cs
@@ -1,8 +1,6 @@
-
namespace XCharts.Runtime
{
[UnityEngine.Scripting.Preserve]
internal sealed class ScatterHandler : BaseScatterHandler
- {
- }
+ { }
}
\ No newline at end of file
diff --git a/Runtime/Serie/Serie.ExtraComponent.cs b/Runtime/Serie/Serie.ExtraComponent.cs
index d3630010..a46d23e3 100644
--- a/Runtime/Serie/Serie.ExtraComponent.cs
+++ b/Runtime/Serie/Serie.ExtraComponent.cs
@@ -1,21 +1,22 @@
-using UnityEngine;
-using System.Collections.Generic;
using System;
+using System.Collections.Generic;
using System.Reflection;
+using UnityEngine;
namespace XCharts.Runtime
{
public partial class Serie
{
- public static Dictionary extraComponentFieldNameDict = new Dictionary
- {
- {typeof(LabelStyle), "m_Labels"},
- {typeof(LabelLine), "m_LabelLines"},
- {typeof(EndLabelStyle), "m_EndLabels"},
- {typeof(LineArrow), "m_LineArrows"},
- {typeof(AreaStyle), "m_AreaStyles"},
- {typeof(Emphasis), "m_Emphases"},
- {typeof(TitleStyle), "m_TitleStyles"},
+ public static Dictionary extraComponentMap = new Dictionary
+ { { typeof(LabelStyle), "m_Labels" },
+ { typeof(LabelLine), "m_LabelLines" },
+ { typeof(EndLabelStyle), "m_EndLabels" },
+ { typeof(LineArrow), "m_LineArrows" },
+ { typeof(AreaStyle), "m_AreaStyles" },
+ { typeof(TitleStyle), "m_TitleStyles" },
+ { typeof(EmphasisItemStyle), "m_EmphasisItemStyles" },
+ { typeof(EmphasisLabelStyle), "m_EmphasisLabels" },
+ { typeof(EmphasisLabelLine), "m_EmphasisLabelLines" },
};
[SerializeField] private List m_Labels = new List();
@@ -24,7 +25,9 @@ namespace XCharts.Runtime
[SerializeField] private List m_LineArrows = new List();
[SerializeField] private List m_AreaStyles = new List();
[SerializeField] private List m_TitleStyles = new List();
- [SerializeField] private List m_Emphases = new List();
+ [SerializeField] private List m_EmphasisItemStyles = new List();
+ [SerializeField] private List m_EmphasisLabels = new List();
+ [SerializeField] private List m_EmphasisLabelLines = new List();
///
/// The style of area.
@@ -48,9 +51,17 @@ namespace XCharts.Runtime
///
public LineArrow lineArrow { get { return m_LineArrows.Count > 0 ? m_LineArrows[0] : null; } }
///
- /// 高亮的图形样式和文本标签样式。
+ /// 高亮的图形样式
///
- public Emphasis emphasis { get { return m_Emphases.Count > 0 ? m_Emphases[0] : null; } }
+ public EmphasisItemStyle emphasisItemStyle { get { return m_EmphasisItemStyles.Count > 0 ? m_EmphasisItemStyles[0] : null; } }
+ ///
+ /// 高亮时的标签样式
+ ///
+ public EmphasisLabelStyle emphasisLabel { get { return m_EmphasisLabels.Count > 0 ? m_EmphasisLabels[0] : null; } }
+ ///
+ /// 高亮时的标签引导线样式
+ ///
+ public EmphasisLabelLine emphasisLabelLine { get { return m_EmphasisLabelLines.Count > 0 ? m_EmphasisLabelLines[0] : null; } }
///
/// the icon of data.
/// |数据项标题样式。
@@ -60,14 +71,14 @@ namespace XCharts.Runtime
public void RemoveAllExtraComponent()
{
var serieType = GetType();
- foreach (var kv in extraComponentFieldNameDict)
+ foreach (var kv in extraComponentMap)
{
ReflectionUtil.InvokeListClear(this, serieType.GetField(kv.Value));
}
SetAllDirty();
}
- public T AddExtraComponent() where T : ChildComponent
+ public T AddExtraComponent() where T : ChildComponent, ISerieExtraComponent
{
return AddExtraComponent(typeof(T)) as T;
}
@@ -80,7 +91,7 @@ namespace XCharts.Runtime
if (attr.Contains(type))
{
var fieldName = string.Empty;
- if (extraComponentFieldNameDict.TryGetValue(type, out fieldName))
+ if (extraComponentMap.TryGetValue(type, out fieldName))
{
var field = typeof(Serie).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
if (ReflectionUtil.InvokeListCount(this, field) <= 0)
@@ -114,7 +125,7 @@ namespace XCharts.Runtime
if (attr.Contains(type))
{
var fieldName = string.Empty;
- if (extraComponentFieldNameDict.TryGetValue(type, out fieldName))
+ if (extraComponentMap.TryGetValue(type, out fieldName))
{
var field = typeof(Serie).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
ReflectionUtil.InvokeListClear(this, field);
diff --git a/Runtime/Serie/Serie.cs b/Runtime/Serie/Serie.cs
index 0774405b..191de67f 100644
--- a/Runtime/Serie/Serie.cs
+++ b/Runtime/Serie/Serie.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -76,8 +75,6 @@ namespace XCharts.Runtime
Capsule
}
-
-
///
/// 雷达图类型
///
@@ -185,8 +182,8 @@ namespace XCharts.Runtime
[SerializeField] private LineType m_LineType = LineType.Normal;
[SerializeField] private BarType m_BarType = BarType.Normal;
[SerializeField] private bool m_BarPercentStack = false;
- [SerializeField] private float m_BarWidth = 0.6f;
- [SerializeField] private float m_BarGap = 0.3f; // 30%
+ [SerializeField] private float m_BarWidth = 0;
+ [SerializeField] private float m_BarGap = 0.1f;
[SerializeField] private float m_BarZebraWidth = 4f;
[SerializeField] private float m_BarZebraGap = 2f;
@@ -204,9 +201,9 @@ namespace XCharts.Runtime
[SerializeField] private RoseType m_RoseType = RoseType.None;
[SerializeField] private float m_Gap;
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.48f };
- [SerializeField] private float[] m_Radius = new float[2] { 0, 80 };
+ [SerializeField] private float[] m_Radius = new float[2] { 0, 0.28f };
- [SerializeField] [Range(1, 10)] private int m_ShowDataDimension;
+ [SerializeField][Range(1, 10)] private int m_ShowDataDimension;
[SerializeField] private bool m_ShowDataName;
[SerializeField] private bool m_ShowDataIcon;
[SerializeField] private bool m_Clip = false;
@@ -826,7 +823,7 @@ namespace XCharts.Runtime
(areaStyle != null && areaStyle.vertsDirty) ||
(label != null && label.vertsDirty) ||
(labelLine != null && labelLine.vertsDirty) ||
- (emphasis != null && emphasis.vertsDirty) ||
+ (emphasisItemStyle != null && emphasisItemStyle.vertsDirty) ||
(titleStyle != null && titleStyle.vertsDirty) ||
AnySerieDataVerticesDirty();
}
@@ -836,11 +833,13 @@ namespace XCharts.Runtime
{
get
{
- return m_ComponentDirty
- || symbol.componentDirty
- || (titleStyle != null && titleStyle.componentDirty)
- || (label != null && label.componentDirty)
- || (labelLine != null && labelLine.componentDirty);
+ return m_ComponentDirty ||
+ symbol.componentDirty ||
+ (titleStyle != null && titleStyle.componentDirty) ||
+ (label != null && label.componentDirty) ||
+ (labelLine != null && labelLine.componentDirty) ||
+ (emphasisLabel != null && emphasisLabel.componentDirty) ||
+ (emphasisLabelLine != null && emphasisLabelLine.componentDirty);
}
}
public override void ClearVerticesDirty()
@@ -855,8 +854,8 @@ namespace XCharts.Runtime
areaStyle.ClearVerticesDirty();
if (label != null)
label.ClearVerticesDirty();
- if (emphasis != null)
- emphasis.ClearVerticesDirty();
+ if (emphasisItemStyle != null)
+ emphasisItemStyle.ClearVerticesDirty();
if (lineArrow != null)
lineArrow.ClearVerticesDirty();
if (titleStyle != null)
@@ -875,8 +874,10 @@ namespace XCharts.Runtime
areaStyle.ClearComponentDirty();
if (label != null)
label.ClearComponentDirty();
- if (emphasis != null)
- emphasis.ClearComponentDirty();
+ if (emphasisLabel != null)
+ emphasisLabel.ClearComponentDirty();
+ if (emphasisLabelLine != null)
+ emphasisLabelLine.ClearComponentDirty();
if (lineArrow != null)
lineArrow.ClearComponentDirty();
if (titleStyle != null)
@@ -1061,6 +1062,7 @@ namespace XCharts.Runtime
public void ResetInteract()
{
+ interact.Reset();
foreach (var serieData in m_Data)
serieData.interact.Reset();
}
@@ -1451,8 +1453,8 @@ namespace XCharts.Runtime
///
public List GetDataList(DataZoom dataZoom = null)
{
- if (dataZoom != null && dataZoom.enable
- && (dataZoom.IsContainsXAxis(xAxisIndex) || dataZoom.IsContainsYAxis(yAxisIndex)))
+ if (dataZoom != null && dataZoom.enable &&
+ (dataZoom.IsContainsXAxis(xAxisIndex) || dataZoom.IsContainsYAxis(yAxisIndex)))
{
SerieHelper.UpdateFilterData(this, dataZoom);
return m_FilterData;
@@ -1570,10 +1572,18 @@ namespace XCharts.Runtime
serieData.context.highlight = flag;
}
- public float GetBarWidth(float categoryWidth)
+ public float GetBarWidth(float categoryWidth, int barCount = 0)
{
- if (m_BarWidth > 1) return m_BarWidth;
- else return m_BarWidth * categoryWidth;
+ if (m_BarWidth == 0)
+ {
+ var width = ChartHelper.GetActualValue(0.6f, categoryWidth);
+ if (barCount == 0)
+ return width < 1 ? categoryWidth : width;
+ else
+ return width / barCount;
+ }
+ else
+ return ChartHelper.GetActualValue(m_BarWidth, categoryWidth);
}
public bool IsIgnoreIndex(int index, int dimension = 1)
@@ -1586,9 +1596,7 @@ namespace XCharts.Runtime
public bool IsIgnoreValue(SerieData serieData, int dimension = 1)
{
- if (serieData.baseInfo != null && serieData.baseInfo.ignore)
- return true;
- return IsIgnoreValue(serieData.GetData(dimension));
+ return serieData.ignore || IsIgnoreValue(serieData.GetData(dimension));
}
public bool IsIgnoreValue(double value)
@@ -1747,4 +1755,4 @@ namespace XCharts.Runtime
return newSerie;
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Serie/SerieContext.cs b/Runtime/Serie/SerieContext.cs
index 1298be7b..931513f1 100644
--- a/Runtime/Serie/SerieContext.cs
+++ b/Runtime/Serie/SerieContext.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -105,5 +104,6 @@ namespace XCharts.Runtime
///
public List drawPoints = new List();
public SerieParams param = new SerieParams();
+ public ChartLabel titleObject { get; set; }
}
}
\ No newline at end of file
diff --git a/Runtime/Serie/SerieData.cs b/Runtime/Serie/SerieData.cs
index 289cf454..50ce21bc 100644
--- a/Runtime/Serie/SerieData.cs
+++ b/Runtime/Serie/SerieData.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -13,19 +12,44 @@ namespace XCharts.Runtime
[System.Serializable]
public class SerieData : ChildComponent
{
+ public static List extraFieldList = new List()
+ {
+ "m_Id",
+ "m_ParentId",
+ "m_Ignore",
+ "m_Selected",
+ "m_Radius"
+ };
+ public static Dictionary extraComponentMap = new Dictionary
+ { { typeof(ItemStyle), "m_ItemStyles" },
+ { typeof(LabelStyle), "m_Labels" },
+ { typeof(LabelLine), "m_LabelLines" },
+ { typeof(SerieSymbol), "m_Symbols" },
+ { typeof(LineStyle), "m_LineStyles" },
+ { typeof(AreaStyle), "m_AreaStyles" },
+ { typeof(TitleStyle), "m_TitleStyles" },
+ { typeof(EmphasisItemStyle), "m_EmphasisItemStyles" },
+ { typeof(EmphasisLabelStyle), "m_EmphasisLabels" },
+ { typeof(EmphasisLabelLine), "m_EmphasisLabelLines" },
+ };
+
[SerializeField] private int m_Index;
[SerializeField] private string m_Name;
[SerializeField] private string m_Id;
[SerializeField] private string m_ParentId;
- [SerializeField] private List m_BaseInfos = new List();
+ [SerializeField] private bool m_Ignore;
+ [SerializeField] private bool m_Selected;
+ [SerializeField] private float m_Radius;
[SerializeField] private List m_ItemStyles = new List();
[SerializeField] private List m_Labels = new List();
[SerializeField] private List m_LabelLines = new List();
- [SerializeField] private List m_Emphases = new List();
[SerializeField] private List m_Symbols = new List();
[SerializeField] private List m_LineStyles = new List();
[SerializeField] private List m_AreaStyles = new List();
[SerializeField] private List m_TitleStyles = new List();
+ [SerializeField] private List m_EmphasisItemStyles = new List();
+ [SerializeField] private List m_EmphasisLabels = new List();
+ [SerializeField] private List m_EmphasisLabelLines = new List();
[SerializeField] private List m_Data = new List();
[NonSerialized] public SerieDataContext context = new SerieDataContext();
@@ -48,12 +72,28 @@ namespace XCharts.Runtime
public string id { get { return m_Id; } set { m_Id = value; } }
public string parentId { get { return m_ParentId; } set { m_ParentId = value; } }
///
+ /// 是否忽略数据。当为 true 时,数据不进行绘制。
+ ///
+ public bool ignore
+ {
+ get { return m_Ignore; }
+ set { if (PropertyUtil.SetStruct(ref m_Ignore, value)) SetVerticesDirty(); }
+ }
+ ///
+ /// 自定义半径。可用在饼图中自定义某个数据项的半径。
+ ///
+ public float radius { get { return m_Radius; } set { m_Radius = value; } }
+ ///
+ /// Whether the data item is selected.
+ /// |该数据项是否被选中。
+ ///
+ public bool selected { get { return m_Selected; } set { m_Selected = value; } }
+ ///
/// 数据项图例名称。当数据项名称不为空时,图例名称即为系列名称;反之则为索引index。
///
///
public string legendName { get { return string.IsNullOrEmpty(name) ? ChartCached.IntToStr(index) : name; } }
- public SerieDataBaseInfo baseInfo { get { return m_BaseInfos.Count > 0 ? m_BaseInfos[0] : null; } }
///
/// 单个数据项的标签设置。
///
@@ -64,16 +104,24 @@ namespace XCharts.Runtime
///
public ItemStyle itemStyle { get { return m_ItemStyles.Count > 0 ? m_ItemStyles[0] : null; } }
///
- /// 单个数据项的高亮样式设置。
- ///
- public Emphasis emphasis { get { return m_Emphases.Count > 0 ? m_Emphases[0] : null; } }
- ///
/// 单个数据项的标记设置。
///
public SerieSymbol symbol { get { return m_Symbols.Count > 0 ? m_Symbols[0] : null; } }
public LineStyle lineStyle { get { return m_LineStyles.Count > 0 ? m_LineStyles[0] : null; } }
public AreaStyle areaStyle { get { return m_AreaStyles.Count > 0 ? m_AreaStyles[0] : null; } }
public TitleStyle titleStyle { get { return m_TitleStyles.Count > 0 ? m_TitleStyles[0] : null; } }
+ ///
+ /// 高亮的图形样式
+ ///
+ public EmphasisItemStyle emphasisItemStyle { get { return m_EmphasisItemStyles.Count > 0 ? m_EmphasisItemStyles[0] : null; } }
+ ///
+ /// 高亮时的标签样式
+ ///
+ public EmphasisLabelStyle emphasisLabel { get { return m_EmphasisLabels.Count > 0 ? m_EmphasisLabels[0] : null; } }
+ ///
+ /// 高亮时的标签引导线样式
+ ///
+ public EmphasisLabelLine emphasisLabelLine { get { return m_EmphasisLabelLines.Count > 0 ? m_EmphasisLabelLines[0] : null; } }
///
/// An arbitrary dimension data list of data item.
@@ -85,8 +133,6 @@ namespace XCharts.Runtime
/// |该数据项是否要显示。
///
public bool show { get { return m_Show; } set { m_Show = value; } }
- public float radius { get { return baseInfo != null ? baseInfo.radius : 0; } }
- public bool selected { get { return (baseInfo != null && baseInfo.selected) || context.selected; } }
private List m_PreviousData = new List();
private List m_DataUpdateTime = new List();
@@ -97,50 +143,49 @@ namespace XCharts.Runtime
{
get
{
- return m_VertsDirty
- || (baseInfo != null && baseInfo.vertsDirty)
- || (labelLine != null && labelLine.vertsDirty)
- || (itemStyle != null && itemStyle.vertsDirty)
- || (symbol != null && symbol.vertsDirty)
- || (lineStyle != null && lineStyle.vertsDirty)
- || (areaStyle != null && areaStyle.vertsDirty);
+ return m_VertsDirty ||
+ (labelLine != null && labelLine.vertsDirty) ||
+ (itemStyle != null && itemStyle.vertsDirty) ||
+ (symbol != null && symbol.vertsDirty) ||
+ (lineStyle != null && lineStyle.vertsDirty) ||
+ (areaStyle != null && areaStyle.vertsDirty) ||
+ (emphasisItemStyle != null && emphasisItemStyle.vertsDirty);
}
}
public override bool componentDirty
{
get
{
- return m_ComponentDirty
- || (baseInfo != null && baseInfo.componentDirty)
- || (labelStyle != null && labelStyle.componentDirty)
- || (labelLine != null && labelLine.componentDirty)
- || (titleStyle != null && titleStyle.componentDirty)
- || (emphasis != null && emphasis.componentDirty);
+ return m_ComponentDirty ||
+ (labelStyle != null && labelStyle.componentDirty) ||
+ (labelLine != null && labelLine.componentDirty) ||
+ (titleStyle != null && titleStyle.componentDirty) ||
+ (emphasisLabel != null && emphasisLabel.componentDirty) ||
+ (emphasisLabelLine != null && emphasisLabelLine.componentDirty);
}
}
public override void ClearVerticesDirty()
{
base.ClearVerticesDirty();
- if (baseInfo != null) baseInfo.ClearVerticesDirty();
if (labelLine != null) labelLine.ClearVerticesDirty();
if (itemStyle != null) itemStyle.ClearVerticesDirty();
if (lineStyle != null) lineStyle.ClearVerticesDirty();
if (areaStyle != null) areaStyle.ClearVerticesDirty();
if (symbol != null) symbol.ClearVerticesDirty();
- if (emphasis != null) emphasis.ClearVerticesDirty();
+ if (emphasisItemStyle != null) emphasisItemStyle.ClearVerticesDirty();
}
public override void ClearComponentDirty()
{
base.ClearComponentDirty();
- if (baseInfo != null) baseInfo.ClearComponentDirty();
if (labelLine != null) labelLine.ClearComponentDirty();
if (itemStyle != null) itemStyle.ClearComponentDirty();
if (lineStyle != null) lineStyle.ClearComponentDirty();
if (areaStyle != null) areaStyle.ClearComponentDirty();
if (symbol != null) symbol.ClearComponentDirty();
- if (emphasis != null) emphasis.ClearComponentDirty();
+ if (emphasisLabel != null) emphasisLabel.ClearComponentDirty();
+ if (emphasisLabelLine != null) emphasisLabelLine.ClearComponentDirty();
}
public void Reset()
@@ -157,73 +202,84 @@ namespace XCharts.Runtime
m_PreviousData.Clear();
m_DataUpdateTime.Clear();
m_DataUpdateFlag.Clear();
- m_BaseInfos.Clear();
m_Labels.Clear();
m_LabelLines.Clear();
m_ItemStyles.Clear();
- m_Emphases.Clear();
m_Symbols.Clear();
m_LineStyles.Clear();
m_AreaStyles.Clear();
m_TitleStyles.Clear();
+ m_EmphasisItemStyles.Clear();
+ m_EmphasisLabels.Clear();
+ m_EmphasisLabelLines.Clear();
}
- public T GetOrAddComponent() where T : ChildComponent
+ public T GetOrAddComponent() where T : ChildComponent, ISerieDataComponent
+ {
+ return GetOrAddComponent(typeof(T)) as T;
+ }
+
+ public ISerieDataComponent GetOrAddComponent(Type type)
{
- var type = typeof(T);
if (type == typeof(ItemStyle))
{
if (m_ItemStyles.Count == 0)
m_ItemStyles.Add(new ItemStyle() { show = true });
- return m_ItemStyles[0] as T;
- }
- else if (type == typeof(SerieDataBaseInfo))
- {
- if (m_BaseInfos.Count == 0)
- m_BaseInfos.Add(new SerieDataBaseInfo() { });
- return m_BaseInfos[0] as T;
+ return m_ItemStyles[0];
}
else if (type == typeof(LabelStyle))
{
if (m_Labels.Count == 0)
m_Labels.Add(new LabelStyle() { show = true });
- return m_Labels[0] as T;
+ return m_Labels[0];
}
else if (type == typeof(LabelLine))
{
if (m_LabelLines.Count == 0)
m_LabelLines.Add(new LabelLine() { show = true });
- return m_LabelLines[0] as T;
+ return m_LabelLines[0];
}
- else if (type == typeof(Emphasis))
+ else if (type == typeof(EmphasisItemStyle))
{
- if (m_Emphases.Count == 0)
- m_Emphases.Add(new Emphasis() { show = true });
- return m_Emphases[0] as T;
+ if (m_EmphasisItemStyles.Count == 0)
+ m_EmphasisItemStyles.Add(new EmphasisItemStyle() { show = true });
+ return m_EmphasisItemStyles[0];
+ }
+ else if (type == typeof(EmphasisLabelStyle))
+ {
+ if (m_EmphasisLabels.Count == 0)
+ m_EmphasisLabels.Add(new EmphasisLabelStyle() { show = true });
+ return m_EmphasisLabels[0];
+ }
+ else if (type == typeof(EmphasisLabelLine))
+ {
+ if (m_EmphasisLabelLines.Count == 0)
+ m_EmphasisLabelLines.Add(new EmphasisLabelLine() { show = true });
+ return m_EmphasisLabelLines[0];
}
else if (type == typeof(SerieSymbol))
{
if (m_Symbols.Count == 0)
m_Symbols.Add(new SerieSymbol() { show = true });
- return m_Symbols[0] as T;
+ return m_Symbols[0];
}
else if (type == typeof(LineStyle))
{
if (m_LineStyles.Count == 0)
m_LineStyles.Add(new LineStyle() { show = true });
- return m_LineStyles[0] as T;
+ return m_LineStyles[0];
}
else if (type == typeof(AreaStyle))
{
if (m_AreaStyles.Count == 0)
m_AreaStyles.Add(new AreaStyle() { show = true });
- return m_AreaStyles[0] as T;
+ return m_AreaStyles[0];
}
else if (type == typeof(TitleStyle))
{
if (m_TitleStyles.Count == 0)
m_TitleStyles.Add(new TitleStyle() { show = true });
- return m_TitleStyles[0] as T;
+ return m_TitleStyles[0];
}
else
{
@@ -233,12 +289,13 @@ namespace XCharts.Runtime
public void RemoveAllComponent()
{
- m_BaseInfos.Clear();
m_ItemStyles.Clear();
m_Labels.Clear();
m_LabelLines.Clear();
m_Symbols.Clear();
- m_Emphases.Clear();
+ m_EmphasisItemStyles.Clear();
+ m_EmphasisLabels.Clear();
+ m_EmphasisLabelLines.Clear();
m_LineStyles.Clear();
m_AreaStyles.Clear();
m_TitleStyles.Clear();
@@ -246,17 +303,23 @@ namespace XCharts.Runtime
public void RemoveComponent() where T : ISerieDataComponent
{
- var type = typeof(T);
+ RemoveComponent(typeof(T));
+ }
+
+ public void RemoveComponent(Type type)
+ {
if (type == typeof(ItemStyle))
m_ItemStyles.Clear();
- else if (type == typeof(SerieDataBaseInfo))
- m_BaseInfos.Clear();
else if (type == typeof(LabelStyle))
m_Labels.Clear();
else if (type == typeof(LabelLine))
m_LabelLines.Clear();
- else if (type == typeof(Emphasis))
- m_Emphases.Clear();
+ else if (type == typeof(EmphasisItemStyle))
+ m_EmphasisItemStyles.Clear();
+ else if (type == typeof(EmphasisLabelStyle))
+ m_EmphasisLabels.Clear();
+ else if (type == typeof(EmphasisLabelLine))
+ m_EmphasisLabelLines.Clear();
else if (type == typeof(SerieSymbol))
m_Symbols.Clear();
else if (type == typeof(LineStyle))
@@ -483,4 +546,4 @@ namespace XCharts.Runtime
return UGLHelper.IsPointInPolygon(p, m_PolygonPoints);
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Serie/SerieDataContext.cs b/Runtime/Serie/SerieDataContext.cs
index 17ca5aba..7f251297 100644
--- a/Runtime/Serie/SerieDataContext.cs
+++ b/Runtime/Serie/SerieDataContext.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -57,7 +56,15 @@ namespace XCharts.Runtime
/// Whether the data item is highlighted.
/// |该数据项是否被高亮,一般由鼠标悬停或图例悬停触发高亮。
///
- public bool highlight;
+ public bool highlight
+ {
+ get { return m_Highligth; }
+ set
+ {
+ m_Highligth = value;
+ }
+ }
+ private bool m_Highligth;
public bool selected;
public void Reset()
diff --git a/Runtime/Serie/SerieHandler.cs b/Runtime/Serie/SerieHandler.cs
index 37541167..084432df 100644
--- a/Runtime/Serie/SerieHandler.cs
+++ b/Runtime/Serie/SerieHandler.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -34,8 +33,7 @@ namespace XCharts.Runtime
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory,
string category, string marker,
string itemFormatter, string numericFormatter,
- ref List paramList, ref string title)
- { }
+ ref List paramList, ref string title) { }
public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }
public virtual void OnLegendButtonEnter(int index, string legendName) { }
public virtual void OnLegendButtonExit(int index, string legendName) { }
@@ -63,7 +61,7 @@ namespace XCharts.Runtime
internal override void SetSerie(Serie serie)
{
- this.serie = (T)serie;
+ this.serie = (T) serie;
this.serie.context.param.serieType = typeof(T);
m_NeedInitComponent = true;
AnimationStyleHelper.UpdateSerieAnimation(serie);
@@ -119,6 +117,7 @@ namespace XCharts.Runtime
if (serie.vertsDirty)
{
chart.RefreshPainter(serie);
+ serie.ResetInteract();
serie.ClearVerticesDirty();
}
}
@@ -220,7 +219,7 @@ namespace XCharts.Runtime
var serieData = serie.data[j];
serieData.index = count;
serieData.labelObject = null;
- if (AddSerieLabel(m_SerieLabelRoot, serie, serieData, ref count))
+ if (AddSerieLabel(m_SerieLabelRoot, serieData, ref count))
{
m_InitedLabel = true;
count++;
@@ -229,7 +228,7 @@ namespace XCharts.Runtime
RefreshLabelInternal();
}
- protected bool AddSerieLabel(GameObject serieLabelRoot, Serie serie, SerieData serieData, ref int count)
+ protected bool AddSerieLabel(GameObject serieLabelRoot, SerieData serieData, ref int count)
{
if (serieData == null)
return false;
@@ -245,15 +244,14 @@ namespace XCharts.Runtime
var serieEmphasisLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData);
- if (!serieLabel.show
- && (serieEmphasisLabel == null || !serieEmphasisLabel.show))
+ if (!serieLabel.show &&
+ (serieEmphasisLabel == null || !serieEmphasisLabel.show))
return false;
- var colorIndex = serie.useDataNameForColor ? serieData.index : serie.index;
- var dataAutoColor = (Color)SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false);
+ var dataAutoColor = GetSerieDataAutoColor(serieData);
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, serie.index, serieData.index);
var label = ChartHelper.AddChartLabel(textName, serieLabelRoot.transform, serieLabel, chart.theme.common,
- "", dataAutoColor, TextAnchor.MiddleCenter);
+ "", dataAutoColor, TextAnchor.MiddleCenter);
label.SetActive(serieLabel.show);
serieData.labelObject = label;
@@ -261,7 +259,7 @@ namespace XCharts.Runtime
{
foreach (var childSerieData in serieData.context.children)
{
- AddSerieLabel(serieLabelRoot, serie, childSerieData, ref count);
+ AddSerieLabel(serieLabelRoot, childSerieData, ref count);
count++;
}
}
@@ -280,7 +278,7 @@ namespace XCharts.Runtime
return;
}
InitRoot();
- var dataAutoColor = (Color)chart.GetLegendRealShowNameColor(serie.legendName);
+ var dataAutoColor = (Color) chart.GetLegendRealShowNameColor(serie.legendName);
m_EndLabel = ChartHelper.AddChartLabel(s_SerieEndLabelObjectName, m_SerieRoot.transform, serie.endLabel,
chart.theme.common, "", dataAutoColor, TextAnchor.MiddleLeft);
m_EndLabel.SetActive(serie.endLabel.show);
@@ -297,19 +295,59 @@ namespace XCharts.Runtime
ChartHelper.RemoveComponent(serieTitleRoot);
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
- for (int i = 0; i < serie.dataCount; i++)
+
+ if (serie.titleJustForSerie)
{
- var serieData = serie.data[i];
- var titleStyle = SerieHelper.GetTitleStyle(serie, serieData);
- if (titleStyle == null) continue;
- var color = chart.GetItemColor(serie, serieData);
- var label = ChartHelper.AddChartLabel("title_" + i, serieTitleRoot.transform, titleStyle, chart.theme.common,
- serieData.name, color, TextAnchor.MiddleCenter);
- serieData.titleObject = label;
- label.SetActive(titleStyle.show);
- var labelPosition = GetSerieDataTitlePosition(serieData, titleStyle);
- var offset = titleStyle.GetOffset(serie.context.insideRadius);
- label.SetPosition(labelPosition + offset);
+ var titleStyle = SerieHelper.GetTitleStyle(serie, null);
+ if (titleStyle != null)
+ {
+ var color = chart.GetItemColor(serie, null);
+ var content = string.Empty;
+ if (string.IsNullOrEmpty(titleStyle.formatter))
+ {
+ content = serie.serieName;
+ }
+ else
+ {
+ content = titleStyle.formatter;
+ FormatterHelper.ReplaceContent(ref content, 0, titleStyle.numericFormatter, serie, chart);
+ }
+ var label = ChartHelper.AddChartLabel("title_" + 0, serieTitleRoot.transform, titleStyle, chart.theme.common,
+ content, color, TextAnchor.MiddleCenter);
+ serie.context.titleObject = label;
+ label.SetActive(titleStyle.show);
+ var labelPosition = GetSerieDataTitlePosition(null, titleStyle);
+ var offset = titleStyle.GetOffset(serie.context.insideRadius);
+ label.SetPosition(labelPosition + offset);
+ }
+ }
+ else
+ {
+ for (int i = 0; i < serie.dataCount; i++)
+ {
+ var serieData = serie.data[i];
+ var titleStyle = SerieHelper.GetTitleStyle(serie, serieData);
+ if (titleStyle == null) continue;
+ var color = chart.GetItemColor(serie, serieData);
+ var content = string.Empty;
+ if (string.IsNullOrEmpty(titleStyle.formatter))
+ {
+ content = serieData.name;
+ }
+ else
+ {
+ content = titleStyle.formatter;
+ FormatterHelper.ReplaceContent(ref content, 0, titleStyle.numericFormatter, serie, chart);
+ }
+ FormatterHelper.ReplaceContent(ref content, i, titleStyle.numericFormatter, serie, chart);
+ var label = ChartHelper.AddChartLabel("title_" + i, serieTitleRoot.transform, titleStyle, chart.theme.common,
+ content, color, TextAnchor.MiddleCenter);
+ serieData.titleObject = label;
+ label.SetActive(titleStyle.show);
+ var labelPosition = GetSerieDataTitlePosition(serieData, titleStyle);
+ var offset = titleStyle.GetOffset(serie.context.insideRadius);
+ label.SetPosition(labelPosition + offset);
+ }
}
}
@@ -319,7 +357,6 @@ namespace XCharts.Runtime
return;
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
-
foreach (var serieData in serie.data)
{
if (serieData.labelObject == null)
@@ -329,23 +366,29 @@ namespace XCharts.Runtime
var isHighlight = (serieData.context.highlight && emphasisLabel != null && emphasisLabel.show);
var isIgnore = serie.IsIgnoreIndex(serieData.index, defaultDimension);
var currLabel = isHighlight && emphasisLabel != null ? emphasisLabel : serieLabel;
- if (serie.show
- && currLabel != null
- && (currLabel.show || isHighlight)
- && serieData.context.canShowLabel
- && !isIgnore)
+ if (serie.show &&
+ currLabel != null &&
+ (currLabel.show || isHighlight) &&
+ serieData.context.canShowLabel &&
+ !isIgnore)
{
var value = serieData.GetCurrData(defaultDimension, dataChangeDuration);
var total = serie.GetDataTotal(defaultDimension, serieData);
var color = chart.GetItemColor(serie, serieData);
- var content = string.IsNullOrEmpty(currLabel.formatter)
- ? ChartCached.NumberToStr(value, serieLabel.numericFormatter)
- : SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
+ var content = string.IsNullOrEmpty(currLabel.formatter) ?
+ ChartCached.NumberToStr(value, serieLabel.numericFormatter) :
+ SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
currLabel, color);
serieData.SetLabelActive(!isIgnore);
serieData.labelObject.SetText(content);
UpdateLabelPosition(serieData, currLabel);
+ if (currLabel.textStyle.autoColor)
+ {
+ var dataAutoColor = GetSerieDataAutoColor(serieData);
+ if (!ChartHelper.IsClearColor(dataAutoColor))
+ serieData.labelObject.SetTextColor(dataAutoColor);
+ }
}
else
{
@@ -368,7 +411,7 @@ namespace XCharts.Runtime
{
var value = serie.context.lineEndValue;
var content = SerieLabelHelper.GetFormatterContent(serie, null, value, 0,
- endLabelStyle, Color.clear);
+ endLabelStyle, Color.clear);
m_EndLabel.SetText(content);
m_EndLabel.SetPosition(serie.context.lineEndPostion + endLabelStyle.offset);
}
@@ -384,9 +427,9 @@ namespace XCharts.Runtime
public virtual Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label)
{
- return ChartHelper.IsZeroVector(serieData.context.labelPosition)
- ? serieData.context.position
- : serieData.context.labelPosition;
+ return ChartHelper.IsZeroVector(serieData.context.labelPosition) ?
+ serieData.context.position :
+ serieData.context.labelPosition;
}
public virtual Vector3 GetSerieDataLabelOffset(SerieData serieData, LabelStyle label)
@@ -399,6 +442,12 @@ namespace XCharts.Runtime
return serieData.context.position;
}
+ public virtual Color GetSerieDataAutoColor(SerieData serieData)
+ {
+ var colorIndex = serie.useDataNameForColor ? serieData.index : serie.index;
+ return (Color) SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false, false);
+ }
+
protected void UpdateCoordSerieParams(ref List paramList, ref string title,
int dataIndex, bool showCategory, string category, string marker,
string itemFormatter, string numericFormatter)
@@ -423,6 +472,7 @@ namespace XCharts.Runtime
param.category = category;
param.dimension = 1;
param.serieData = serieData;
+ param.dataCount = serie.dataCount;
param.value = serieData.GetData(1);
param.total = serie.yTotal;
param.color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serie.context.colorIndex, false);
@@ -464,6 +514,7 @@ namespace XCharts.Runtime
param.category = category;
param.dimension = dimension;
param.serieData = serieData;
+ param.dataCount = serie.dataCount;
param.value = serieData.GetData(param.dimension);
param.total = SerieHelper.GetMaxData(serie, dimension);
param.color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false);
diff --git a/Runtime/Serie/SerieParams.cs b/Runtime/Serie/SerieParams.cs
index 59392dc5..d2948a8c 100644
--- a/Runtime/Serie/SerieParams.cs
+++ b/Runtime/Serie/SerieParams.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -14,6 +13,7 @@ namespace XCharts.Runtime
public string category;
public int dimension;
public SerieData serieData;
+ public int dataCount;
public double value;
public double total;
public Color32 color;
diff --git a/Runtime/Theme/AxisTheme.cs b/Runtime/Theme/AxisTheme.cs
index 3f73869c..be4496be 100644
--- a/Runtime/Theme/AxisTheme.cs
+++ b/Runtime/Theme/AxisTheme.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
using UnityEngine;
@@ -147,27 +146,30 @@ namespace XCharts.Runtime
m_LineColor = ColorUtil.GetColor("#514D4D");
m_TickColor = ColorUtil.GetColor("#514D4D");
m_SplitLineColor = ColorUtil.GetColor("#51515120");
- m_SplitAreaColors = new List{
- new Color32(250,250,250,77),
- new Color32(200,200,200,77)
+ m_SplitAreaColors = new List
+ {
+ new Color32(250, 250, 250, 77),
+ new Color32(200, 200, 200, 77)
};
break;
case ThemeType.Light:
m_LineColor = ColorUtil.GetColor("#514D4D");
m_TickColor = ColorUtil.GetColor("#514D4D");
m_SplitLineColor = ColorUtil.GetColor("#51515120");
- m_SplitAreaColors = new List{
- new Color32(250,250,250,77),
- new Color32(200,200,200,77)
+ m_SplitAreaColors = new List
+ {
+ new Color32(250, 250, 250, 77),
+ new Color32(200, 200, 200, 77)
};
break;
case ThemeType.Dark:
m_LineColor = ColorUtil.GetColor("#B9B8CE");
m_TickColor = ColorUtil.GetColor("#B9B8CE");
m_SplitLineColor = ColorUtil.GetColor("#484753");
- m_SplitAreaColors = new List{
- new Color32(255,255,255,(byte)(0.02f * 255)),
- new Color32(255,255,255,(byte)(0.05f * 255))
+ m_SplitAreaColors = new List
+ {
+ new Color32(255, 255, 255, (byte) (0.02f * 255)),
+ new Color32(255, 255, 255, (byte) (0.05f * 255))
};
break;
}
@@ -195,32 +197,28 @@ namespace XCharts.Runtime
public class AxisTheme : BaseAxisTheme
{
public AxisTheme(ThemeType theme) : base(theme)
- {
- }
+ { }
}
[Serializable]
public class RadiusAxisTheme : BaseAxisTheme
{
public RadiusAxisTheme(ThemeType theme) : base(theme)
- {
- }
+ { }
}
[Serializable]
public class AngleAxisTheme : BaseAxisTheme
{
public AngleAxisTheme(ThemeType theme) : base(theme)
- {
- }
+ { }
}
[Serializable]
public class PolarAxisTheme : BaseAxisTheme
{
public PolarAxisTheme(ThemeType theme) : base(theme)
- {
- }
+ { }
}
[Serializable]
diff --git a/Runtime/Theme/ComponentTheme.cs b/Runtime/Theme/ComponentTheme.cs
index f9f8144e..e68fdfb8 100644
--- a/Runtime/Theme/ComponentTheme.cs
+++ b/Runtime/Theme/ComponentTheme.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
#if dUI_TextMeshPro
diff --git a/Runtime/Theme/DataZoomTheme.cs b/Runtime/Theme/DataZoomTheme.cs
index cd5c8582..0c4a8862 100644
--- a/Runtime/Theme/DataZoomTheme.cs
+++ b/Runtime/Theme/DataZoomTheme.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -103,7 +102,7 @@ namespace XCharts.Runtime
break;
case ThemeType.Dark:
m_TextColor = ColorUtil.GetColor("#B9B8CE");
- m_FillerColor = new Color32(135, 163, 206, (byte)(0.2f * 255));
+ m_FillerColor = new Color32(135, 163, 206, (byte) (0.2f * 255));
m_BorderColor = ColorUtil.GetColor("#71708A");
m_DataLineColor = ColorUtil.GetColor("#71708A");
m_DataAreaColor = ColorUtil.GetColor("#71708A");
diff --git a/Runtime/Theme/LegendTheme.cs b/Runtime/Theme/LegendTheme.cs
index aab9e9ec..259abd4c 100644
--- a/Runtime/Theme/LegendTheme.cs
+++ b/Runtime/Theme/LegendTheme.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
#if dUI_TextMeshPro
@@ -31,7 +30,7 @@ namespace XCharts.Runtime
public LegendTheme(ThemeType theme) : base(theme)
{
m_UnableColor = ColorUtil.GetColor("#cccccc");
-
+
}
}
}
\ No newline at end of file
diff --git a/Runtime/Theme/SerieTheme.cs b/Runtime/Theme/SerieTheme.cs
index f9ec2605..f22e0c68 100644
--- a/Runtime/Theme/SerieTheme.cs
+++ b/Runtime/Theme/SerieTheme.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
diff --git a/Runtime/Theme/SubTitleTheme.cs b/Runtime/Theme/SubTitleTheme.cs
index cce69a4d..7e0ae934 100644
--- a/Runtime/Theme/SubTitleTheme.cs
+++ b/Runtime/Theme/SubTitleTheme.cs
@@ -1,4 +1,3 @@
-
using System;
namespace XCharts.Runtime
diff --git a/Runtime/Theme/Theme.cs b/Runtime/Theme/Theme.cs
index 7eb5b066..da0b32cc 100644
--- a/Runtime/Theme/Theme.cs
+++ b/Runtime/Theme/Theme.cs
@@ -1,8 +1,7 @@
-
-using System.Collections.Generic;
-using UnityEngine;
using System;
+using System.Collections.Generic;
using System.Text;
+using UnityEngine;
#if dUI_TextMeshPro
using TMPro;
#endif
@@ -56,7 +55,6 @@ namespace XCharts.Runtime
set { PropertyUtil.SetClass(ref m_ThemeName, value); }
}
-
///
/// the contrast color of chart.
/// |对比色。
@@ -247,8 +245,12 @@ namespace XCharts.Runtime
{
switch (m_ThemeType)
{
- case ThemeType.Default: ResetToDefaultTheme(this); return true;
- case ThemeType.Dark: ResetToDarkTheme(this); return true;
+ case ThemeType.Default:
+ ResetToDefaultTheme(this);
+ return true;
+ case ThemeType.Dark:
+ ResetToDarkTheme(this);
+ return true;
case ThemeType.Custom:
return false;
}
@@ -267,7 +269,6 @@ namespace XCharts.Runtime
return theme;
}
-
///
/// default theme.
/// |默认主题。
@@ -383,7 +384,7 @@ namespace XCharts.Runtime
{
Color color;
ColorUtility.TryParseHtmlString(hexColorStr, out color);
- return (Color32)color;
+ return (Color32) color;
}
public void SetColorPalette(List hexColorStringList)
diff --git a/Runtime/Theme/ThemeStyle.cs b/Runtime/Theme/ThemeStyle.cs
index 394e3af9..8c3f2ab7 100644
--- a/Runtime/Theme/ThemeStyle.cs
+++ b/Runtime/Theme/ThemeStyle.cs
@@ -1,8 +1,7 @@
-
-using System.Collections.Generic;
-using UnityEngine;
using System;
+using System.Collections.Generic;
using System.Text;
+using UnityEngine;
#if dUI_TextMeshPro
using TMPro;
#endif
@@ -230,9 +229,8 @@ namespace XCharts.Runtime
{
Color color;
ColorUtility.TryParseHtmlString(hexColorStr, out color);
- return (Color32)color;
+ return (Color32) color;
}
-
}
}
\ No newline at end of file
diff --git a/Runtime/Theme/TitleTheme.cs b/Runtime/Theme/TitleTheme.cs
index c914ce03..e675cf56 100644
--- a/Runtime/Theme/TitleTheme.cs
+++ b/Runtime/Theme/TitleTheme.cs
@@ -1,4 +1,3 @@
-
using System;
namespace XCharts.Runtime
diff --git a/Runtime/Theme/TooltipTheme.cs b/Runtime/Theme/TooltipTheme.cs
index 882cb655..a0d0dab1 100644
--- a/Runtime/Theme/TooltipTheme.cs
+++ b/Runtime/Theme/TooltipTheme.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
diff --git a/Runtime/Theme/VisualMapTheme.cs b/Runtime/Theme/VisualMapTheme.cs
index aa5cfc83..3810838d 100644
--- a/Runtime/Theme/VisualMapTheme.cs
+++ b/Runtime/Theme/VisualMapTheme.cs
@@ -1,4 +1,3 @@
-
using System;
using UnityEngine;
@@ -10,7 +9,7 @@ namespace XCharts.Runtime
[SerializeField] protected float m_BorderWidth;
[SerializeField] protected Color32 m_BorderColor;
[SerializeField] protected Color32 m_BackgroundColor;
- [SerializeField] [Range(10, 50)] protected float m_TriangeLen = 20f;
+ [SerializeField][Range(10, 50)] protected float m_TriangeLen = 20f;
///
/// the width of border.
diff --git a/Runtime/Utilities/ColorUtil.cs b/Runtime/Utilities/ColorUtil.cs
index 000f3999..ab650e4f 100644
--- a/Runtime/Utilities/ColorUtil.cs
+++ b/Runtime/Utilities/ColorUtil.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
namespace XCharts.Runtime
@@ -17,7 +16,7 @@ namespace XCharts.Runtime
{
Color color;
ColorUtility.TryParseHtmlString(hexColorStr, out color);
- return (Color32)color;
+ return (Color32) color;
}
}
}
\ No newline at end of file
diff --git a/Runtime/Utilities/DateTimeUtil.cs b/Runtime/Utilities/DateTimeUtil.cs
index c9d00bc9..361218f2 100644
--- a/Runtime/Utilities/DateTimeUtil.cs
+++ b/Runtime/Utilities/DateTimeUtil.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections.Generic;
@@ -24,20 +23,19 @@ namespace XCharts.Runtime
private static string s_SecondDateFormatter = "HH:mm:ss";
//private static string s_DateFormatter = "yyyy-MM-dd HH:mm:ss";
-
public static int GetTimestamp()
{
- return (int)(DateTime.Now - k_DateTime1970).TotalSeconds;
+ return (int) (DateTime.Now - k_DateTime1970).TotalSeconds;
}
public static int GetTimestamp(DateTime time)
{
- return (int)(time - k_DateTime1970).TotalSeconds;
+ return (int) (time - k_DateTime1970).TotalSeconds;
}
public static DateTime GetDateTime(int timestamp)
{
- long span = ((long)timestamp) * 10000000;
+ long span = ((long) timestamp) * 10000000;
return k_DateTime1970.Add(new TimeSpan(span));
}
@@ -50,15 +48,15 @@ namespace XCharts.Runtime
}
else if (range >= DateTimeUtil.ONE_MONTH * DateTimeUtil.MIN_TIME_SPLIT_NUMBER)
{
- dateString = dateTime.Month == 1
- ? dateTime.ToString(s_YearDateFormatter)
- : XCSettings.lang.GetMonthAbbr(dateTime.Month);
+ dateString = dateTime.Month == 1 ?
+ dateTime.ToString(s_YearDateFormatter) :
+ XCSettings.lang.GetMonthAbbr(dateTime.Month);
}
else if (range >= DateTimeUtil.ONE_DAY * DateTimeUtil.MIN_TIME_SPLIT_NUMBER)
{
- dateString = dateTime.Day == 1
- ? XCSettings.lang.GetMonthAbbr(dateTime.Month)
- : XCSettings.lang.GetDay(dateTime.Day);
+ dateString = dateTime.Day == 1 ?
+ XCSettings.lang.GetMonthAbbr(dateTime.Month) :
+ XCSettings.lang.GetDay(dateTime.Day);
}
else if (range >= DateTimeUtil.ONE_HOUR * DateTimeUtil.MIN_TIME_SPLIT_NUMBER)
{
@@ -87,6 +85,7 @@ namespace XCharts.Runtime
list.Clear();
var range = maxTimestamp - minTimestamp;
if (range <= 0) return;
+ if (splitNumber <= 0) splitNumber = 1;
var dtMin = DateTimeUtil.GetDateTime(minTimestamp);
var dtMax = DateTimeUtil.GetDateTime(maxTimestamp);
if (range >= ONE_YEAR * MIN_TIME_SPLIT_NUMBER)
diff --git a/Runtime/Utilities/DefineSymbolsUtil.cs b/Runtime/Utilities/DefineSymbolsUtil.cs
index 811e636d..12a24c82 100644
--- a/Runtime/Utilities/DefineSymbolsUtil.cs
+++ b/Runtime/Utilities/DefineSymbolsUtil.cs
@@ -16,7 +16,7 @@ namespace XCharts.Runtime
{
var flag = false;
var num = 0;
- foreach (var buildTargetGroup in (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup)))
+ foreach (var buildTargetGroup in (BuildTargetGroup[]) Enum.GetValues(typeof(BuildTargetGroup)))
{
if (IsValidBuildTargetGroup(buildTargetGroup))
{
@@ -39,7 +39,7 @@ namespace XCharts.Runtime
{
var flag = false;
var num = 0;
- foreach (var buildTargetGroup in (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup)))
+ foreach (var buildTargetGroup in (BuildTargetGroup[]) Enum.GetValues(typeof(BuildTargetGroup)))
{
if (IsValidBuildTargetGroup(buildTargetGroup))
{
@@ -73,8 +73,8 @@ namespace XCharts.Runtime
var method1 = type.GetMethod("GetTargetStringFromBuildTargetGroup", BindingFlags.Static | BindingFlags.NonPublic);
var method2 = typeof(PlayerSettings).GetMethod("GetPlatformName", BindingFlags.Static | BindingFlags.NonPublic);
if (method1 == null || method2 == null) return true;
- var str1 = (string)method1.Invoke(null, new object[] { group });
- var str2 = (string)method2.Invoke(null, new object[] { group });
+ var str1 = (string) method1.Invoke(null, new object[] { group });
+ var str2 = (string) method2.Invoke(null, new object[] { group });
if (string.IsNullOrEmpty(str1))
{
return !string.IsNullOrEmpty(str2);
diff --git a/Runtime/Utilities/PropertyUtil.cs b/Runtime/Utilities/PropertyUtil.cs
index 717dd8e5..313ac3d4 100644
--- a/Runtime/Utilities/PropertyUtil.cs
+++ b/Runtime/Utilities/PropertyUtil.cs
@@ -1,4 +1,3 @@
-
using System.Collections.Generic;
using UnityEngine;
@@ -50,4 +49,4 @@ namespace XCharts.Runtime
return true;
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/Utilities/ReflectionUtil.cs b/Runtime/Utilities/ReflectionUtil.cs
index d1105bf7..5af73afa 100644
--- a/Runtime/Utilities/ReflectionUtil.cs
+++ b/Runtime/Utilities/ReflectionUtil.cs
@@ -1,4 +1,3 @@
-
using System;
using System.Collections;
using System.Collections.Generic;
@@ -26,7 +25,7 @@ namespace XCharts.Runtime
public static int InvokeListCount(object obj, FieldInfo field)
{
var list = field.GetValue(obj);
- return (int)list.GetType().GetProperty("Count").GetValue(list, null);
+ return (int) list.GetType().GetProperty("Count").GetValue(list, null);
}
public static void InvokeListAdd(object obj, FieldInfo field, object item)
@@ -45,10 +44,9 @@ namespace XCharts.Runtime
{
var list = field.GetValue(obj);
var item = list.GetType().GetProperty("Item").GetValue(list, new object[] { i });
- return (T)item;
+ return (T) item;
}
-
public static void InvokeListAddTo(object obj, FieldInfo field, Action callback)
{
var list = field.GetValue(obj);
@@ -57,7 +55,7 @@ namespace XCharts.Runtime
for (int i = 0; i < count; i++)
{
var item = listType.GetProperty("Item").GetValue(list, new object[] { i });
- callback((T)item);
+ callback((T) item);
}
}
@@ -88,9 +86,9 @@ namespace XCharts.Runtime
{
var properties = type.GetProperties();
var customList = typeof(List<>).MakeGenericType((properties[properties.Length - 1]).PropertyType);
- returnObj = (IList)Activator.CreateInstance(customList);
- var list = (IList)returnObj;
- foreach (var item in ((IList)obj))
+ returnObj = (IList) Activator.CreateInstance(customList);
+ var list = (IList) returnObj;
+ foreach (var item in ((IList) obj))
{
if (item == null)
continue;
diff --git a/Runtime/Utilities/RuntimeUtil.cs b/Runtime/Utilities/RuntimeUtil.cs
index 4e3d7a44..72cfa5fa 100644
--- a/Runtime/Utilities/RuntimeUtil.cs
+++ b/Runtime/Utilities/RuntimeUtil.cs
@@ -1,7 +1,6 @@
-
using System;
-using System.IO;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;
@@ -62,7 +61,7 @@ namespace XCharts.Runtime
public static T GetAttribute(this Type type, bool check = true) where T : Attribute
{
if (type.IsDefined(typeof(T), false))
- return (T)type.GetCustomAttributes(typeof(T), false)[0];
+ return (T) type.GetCustomAttributes(typeof(T), false) [0];
else
{
if (check)
@@ -73,7 +72,7 @@ namespace XCharts.Runtime
public static T GetAttribute(this MemberInfo type, bool check = true) where T : Attribute
{
if (type.IsDefined(typeof(T), false))
- return (T)type.GetCustomAttributes(typeof(T), false)[0];
+ return (T) type.GetCustomAttributes(typeof(T), false) [0];
else
{
if (check)
diff --git a/Runtime/Widgets/ProgressBar.cs b/Runtime/Widgets/ProgressBar.cs
index 734debbf..8efac8a0 100644
--- a/Runtime/Widgets/ProgressBar.cs
+++ b/Runtime/Widgets/ProgressBar.cs
@@ -1,4 +1,3 @@
-
using UnityEngine;
using UnityEngine.UI;
using XUGL;
@@ -10,7 +9,7 @@ namespace XCharts.Runtime
[DisallowMultipleComponent]
public class ProgressBar : BaseChart
{
- [SerializeField] [Range(0f, 1f)] private float m_Value = 0.5f;
+ [SerializeField][Range(0f, 1f)] private float m_Value = 0.5f;
[SerializeField] private Color m_BackgroundColor = new Color32(255, 233, 233, 255);
[SerializeField] private Color m_StartColor = Color.blue;
[SerializeField] private Color m_EndColor = Color.red;
@@ -34,7 +33,6 @@ namespace XCharts.Runtime
}
#endif
-
protected override void OnDrawPainterBase(VertexHelper vh, Painter painter)
{
vh.Clear();
@@ -50,4 +48,4 @@ namespace XCharts.Runtime
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/XUGL/SVG/SVGPath.cs b/Runtime/XUGL/SVG/SVGPath.cs
index 3ced766e..9239ee1c 100644
--- a/Runtime/XUGL/SVG/SVGPath.cs
+++ b/Runtime/XUGL/SVG/SVGPath.cs
@@ -42,7 +42,7 @@ namespace XUGL
}
else
{
- var type = s_PathValueRegex.Match(key).Groups[1].ToString().ToCharArray()[0];
+ var type = s_PathValueRegex.Match(key).Groups[1].ToString().ToCharArray() [0];
var mc3 = s_PathValueRegex2.Matches(key);
SVGPathSeg seg = null;
switch (type)
@@ -151,7 +151,7 @@ namespace XUGL
var cp1 = seg.relative ? np + seg.p1 : seg.p1;
cp2 = seg.relative ? np + seg.p2 : seg.p2;
var ep = seg.relative ? np + seg.p3 : seg.p3;
- var dist = (int)Vector2.Distance(np, ep) * 2;
+ var dist = (int) Vector2.Distance(np, ep) * 2;
if (dist < 2) dist = 2;
UGLHelper.GetBezierList2(ref bezierList, np, ep, dist, cp1, cp2);
for (int n = 1; n < bezierList.Count; n++)
@@ -162,7 +162,7 @@ namespace XUGL
cp1 = np + (np - cp2).normalized * Vector2.Distance(np, cp2);
var scp2 = seg.relative ? np + seg.p1 : seg.p1;
ep = seg.relative ? np + seg.p2 : seg.p2;
- dist = (int)Vector2.Distance(np, ep) * 2;
+ dist = (int) Vector2.Distance(np, ep) * 2;
if (dist < 2) dist = 2;
UGLHelper.GetBezierList2(ref bezierList, np, ep, dist, cp1, scp2);
for (int n = 1; n < bezierList.Count; n++)
diff --git a/Runtime/XUGL/UGL.cs b/Runtime/XUGL/UGL.cs
index e53590be..b260a52e 100644
--- a/Runtime/XUGL/UGL.cs
+++ b/Runtime/XUGL/UGL.cs
@@ -27,7 +27,7 @@ namespace XUGL
/// 箭头凹度
/// 颜色
public static void DrawArrow(VertexHelper vh, Vector3 startPoint, Vector3 arrowPoint, float width,
- float height, float offset, float dent, Color32 color)
+ float height, float offset, float dent, Color32 color)
{
var dir = (arrowPoint - startPoint).normalized;
var sharpPos = arrowPoint + (offset + height / 4) * dir;
@@ -187,13 +187,13 @@ namespace XUGL
}
public static void AddVertToVertexHelper(VertexHelper vh, Vector3 top,
- Vector3 bottom, Color32 color, bool needTriangle = true)
+ Vector3 bottom, Color32 color, bool needTriangle = true)
{
AddVertToVertexHelper(vh, top, bottom, color, color, needTriangle);
}
public static void AddVertToVertexHelper(VertexHelper vh, Vector3 top,
- Vector3 bottom, Color32 topColor, Color32 bottomColor, bool needTriangle = true)
+ Vector3 bottom, Color32 topColor, Color32 bottomColor, bool needTriangle = true)
{
var lastVertCount = vh.currentVertCount;
vh.AddVert(top, topColor, Vector2.zero);
@@ -518,7 +518,7 @@ namespace XUGL
/// 颜色
/// 是否垂直方向
public static void DrawRectangle(VertexHelper vh, Vector3 p, float xRadius, float yRadius,
- Color32 color, bool vertical = true)
+ Color32 color, bool vertical = true)
{
DrawRectangle(vh, p, xRadius, yRadius, color, color, vertical);
}
@@ -1049,14 +1049,14 @@ namespace XUGL
if (borderWidth == 0 || UGLHelper.IsClearColor(color)) return;
var halfWid = rectWidth / 2;
var halfHig = rectHeight / 2;
- var lbIn = new Vector3(center.x - halfWid, center.y - halfHig);
- var lbOt = new Vector3(center.x - halfWid - borderWidth, center.y - halfHig - borderWidth);
- var ltIn = new Vector3(center.x - halfWid, center.y + halfHig);
- var ltOt = new Vector3(center.x - halfWid - borderWidth, center.y + halfHig + borderWidth);
- var rtIn = new Vector3(center.x + halfWid, center.y + halfHig);
- var rtOt = new Vector3(center.x + halfWid + borderWidth, center.y + halfHig + borderWidth);
- var rbIn = new Vector3(center.x + halfWid, center.y - halfHig);
- var rbOt = new Vector3(center.x + halfWid + borderWidth, center.y - halfHig - borderWidth);
+ var lbIn = new Vector3(center.x - halfWid - extWidth, center.y - halfHig - extWidth);
+ var lbOt = new Vector3(center.x - halfWid - borderWidth - extWidth, center.y - halfHig - borderWidth - extWidth);
+ var ltIn = new Vector3(center.x - halfWid - extWidth, center.y + halfHig + extWidth);
+ var ltOt = new Vector3(center.x - halfWid - borderWidth - extWidth, center.y + halfHig + borderWidth + extWidth);
+ var rtIn = new Vector3(center.x + halfWid + extWidth, center.y + halfHig + extWidth);
+ var rtOt = new Vector3(center.x + halfWid + borderWidth + extWidth, center.y + halfHig + borderWidth + extWidth);
+ var rbIn = new Vector3(center.x + halfWid + extWidth, center.y - halfHig - extWidth);
+ var rbOt = new Vector3(center.x + halfWid + borderWidth + extWidth, center.y - halfHig - borderWidth - extWidth);
float brLt = 0, brRt = 0, brRb = 0, brLb = 0;
bool needRound = false;
InitCornerRadius(cornerRadius, rectWidth, rectHeight, horizontal, invertCorner, ref brLt, ref brRt, ref brRb,
@@ -1185,7 +1185,7 @@ namespace XUGL
}
public static void DrawTriangle(VertexHelper vh, Vector3 p1,
- Vector3 p2, Vector3 p3, Color32 color, Color32 color2, Color32 color3)
+ Vector3 p2, Vector3 p3, Color32 color, Color32 color2, Color32 color3)
{
UIVertex v1 = new UIVertex();
v1.position = p1;
@@ -1213,7 +1213,7 @@ namespace XUGL
}
public static void DrawCricle(VertexHelper vh, Vector3 center, float radius, Color32 color,
- Color32 toColor, float smoothness = 2f)
+ Color32 toColor, float smoothness = 2f)
{
DrawSector(vh, center, radius, color, toColor, 0, 360, 0, s_ClearColor32, smoothness);
}
@@ -1260,13 +1260,13 @@ namespace XUGL
}
public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color,
- float startDegree, float toDegree, float smoothness = 2f)
+ float startDegree, float toDegree, float smoothness = 2f)
{
DrawSector(vh, center, radius, color, color, startDegree, toDegree, 0, s_ClearColor32, smoothness);
}
public static void DrawSector(VertexHelper vh, Vector3 center, float radius, Color32 color, Color32 toColor,
- float startDegree, float toDegree, int gradientType = 0, bool isYAxis = false, float smoothness = 2f)
+ float startDegree, float toDegree, int gradientType = 0, bool isYAxis = false, float smoothness = 2f)
{
DrawSector(vh, center, radius, color, toColor, startDegree, toDegree, 0, s_ClearColor32, 0, smoothness,
gradientType, isYAxis);
@@ -1308,7 +1308,7 @@ namespace XUGL
if (gap > 0 && Mathf.Abs(toDegree - startDegree) >= 360) gap = 0;
radius -= borderWidth;
smoothness = (smoothness < 0 ? 2f : smoothness);
- int segments = (int)((2 * Mathf.PI * radius) * (Mathf.Abs(toDegree - startDegree) / 360) / smoothness);
+ int segments = (int) ((2 * Mathf.PI * radius) * (Mathf.Abs(toDegree - startDegree) / 360) / smoothness);
if (segments < 1) segments = 1;
float startAngle = startDegree * Mathf.Deg2Rad;
float toAngle = toDegree * Mathf.Deg2Rad;
@@ -1381,9 +1381,9 @@ namespace XUGL
{
p4 = new Vector3(p3.x, realCenter.y);
var dist = p4.x - realCenter.x;
- var tcolor = Color32.Lerp(color, toColor, dist >= 0
- ? dist / radius
- : Mathf.Min(radius + dist, radius) / radius);
+ var tcolor = Color32.Lerp(color, toColor, dist >= 0 ?
+ dist / radius :
+ Mathf.Min(radius + dist, radius) / radius);
if (isLeft && (i == segments || i == 0)) tcolor = toColor;
DrawQuadrilateral(vh, lastP4, p2, p3, p4, lastColor, tcolor);
lastP4 = p4;
@@ -1500,7 +1500,7 @@ namespace XUGL
var needSpace = gap != 0;
var diffAngle = Mathf.Abs(toDegree - startDegree) * Mathf.Deg2Rad;
- int segments = (int)((2 * Mathf.PI * outsideRadius) * (diffAngle * Mathf.Rad2Deg / 360) / smoothness);
+ int segments = (int) ((2 * Mathf.PI * outsideRadius) * (diffAngle * Mathf.Rad2Deg / 360) / smoothness);
if (segments < 1) segments = 1;
float startAngle = startDegree * Mathf.Deg2Rad;
float toAngle = toDegree * Mathf.Deg2Rad;
@@ -1755,7 +1755,7 @@ namespace XUGL
float lineWidth, Color32 lineColor, float smoothness)
{
var dist = Vector3.Distance(sp, ep);
- var segment = (int)(dist / (smoothness <= 0 ? 2f : smoothness));
+ var segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness));
UGLHelper.GetBezierList2(ref s_CurvesPosList, sp, ep, segment, cp1, cp2);
DrawCurvesInternal(vh, s_CurvesPosList, lineWidth, lineColor);
}
@@ -1898,4 +1898,4 @@ namespace XUGL
}
}
}
-}
+}
\ No newline at end of file
diff --git a/Runtime/XUGL/UGLHelper.cs b/Runtime/XUGL/UGLHelper.cs
index da775b82..9d17934f 100644
--- a/Runtime/XUGL/UGLHelper.cs
+++ b/Runtime/XUGL/UGLHelper.cs
@@ -7,18 +7,18 @@ namespace XUGL
{
public static bool IsValueEqualsColor(Color32 color1, Color32 color2)
{
- return color1.a == color2.a
- && color1.b == color2.b
- && color1.g == color2.g
- && color1.r == color2.r;
+ return color1.a == color2.a &&
+ color1.b == color2.b &&
+ color1.g == color2.g &&
+ color1.r == color2.r;
}
public static bool IsValueEqualsColor(Color color1, Color color2)
{
- return color1.a == color2.a
- && color1.b == color2.b
- && color1.g == color2.g
- && color1.r == color2.r;
+ return color1.a == color2.a &&
+ color1.b == color2.b &&
+ color1.g == color2.g &&
+ color1.r == color2.r;
}
public static bool IsValueEqualsString(string str1, string str2)
@@ -32,21 +32,21 @@ namespace XUGL
public static bool IsValueEqualsVector2(Vector2 v1, Vector2 v2)
{
- return v1.x == v2.x
- && v1.y == v2.y;
+ return v1.x == v2.x &&
+ v1.y == v2.y;
}
public static bool IsValueEqualsVector3(Vector3 v1, Vector3 v2)
{
- return v1.x == v2.x
- && v1.y == v2.y
- && v1.z == v2.z;
+ return v1.x == v2.x &&
+ v1.y == v2.y &&
+ v1.z == v2.z;
}
public static bool IsValueEqualsVector3(Vector3 v1, Vector2 v2)
{
- return v1.x == v2.x
- && v1.y == v2.y;
+ return v1.x == v2.x &&
+ v1.y == v2.y;
}
public static bool IsValueEqualsList(List list1, List list2)
@@ -60,8 +60,7 @@ namespace XUGL
for (int i = 0; i < list1.Count; i++)
{
if (list1[i] == null && list2[i] == null)
- {
- }
+ { }
else
{
if (list1[i] != null)
@@ -81,25 +80,25 @@ namespace XUGL
public static bool IsClearColor(Color32 color)
{
- return color.a == 0
- && color.b == 0
- && color.g == 0
- && color.r == 0;
+ return color.a == 0 &&
+ color.b == 0 &&
+ color.g == 0 &&
+ color.r == 0;
}
public static bool IsClearColor(Color color)
{
- return color.a == 0
- && color.b == 0
- && color.g == 0
- && color.r == 0;
+ return color.a == 0 &&
+ color.b == 0 &&
+ color.g == 0 &&
+ color.r == 0;
}
public static bool IsZeroVector(Vector3 pos)
{
- return pos.x == 0
- && pos.y == 0
- && pos.z == 0;
+ return pos.x == 0 &&
+ pos.y == 0 &&
+ pos.z == 0;
}
public static Vector3 RotateRound(Vector3 position, Vector3 center, Vector3 axis, float angle)
@@ -110,7 +109,7 @@ namespace XUGL
}
public static void GetBezierList(ref List posList, Vector3 sp, Vector3 ep,
- Vector3 lsp, Vector3 nep, float smoothness = 2f, float k = 2.0f)
+ Vector3 lsp, Vector3 nep, float smoothness = 2f, float k = 2.0f)
{
float dist = Mathf.Abs(sp.x - ep.x);
Vector3 cp1, cp2;
@@ -129,8 +128,8 @@ namespace XUGL
if (nep == ep) cp2 = ep;
else cp2 = ep - (nep - sp).normalized * diff;
dist = Vector3.Distance(sp, ep);
- int segment = (int)(dist / (smoothness <= 0 ? 2f : smoothness));
- if (segment < 1) segment = (int)(dist / 0.5f);
+ int segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness));
+ if (segment < 1) segment = (int) (dist / 0.5f);
if (segment < 4) segment = 4;
GetBezierList2(ref posList, sp, ep, segment, cp1, cp2);
if (posList.Count < 2)
@@ -150,7 +149,7 @@ namespace XUGL
Vector3 cp2 = sp + dist / k * dir * (k - 1);
cp1.x = sp.x;
cp2.x = ep.x;
- int segment = (int)(dist / (smoothness <= 0 ? 2f : smoothness));
+ int segment = (int) (dist / (smoothness <= 0 ? 2f : smoothness));
GetBezierList2(ref posList, sp, ep, segment, cp1, cp2);
if (posList.Count < 2)
{
@@ -165,7 +164,7 @@ namespace XUGL
List list = new List();
for (int i = 0; i < segment; i++)
{
- list.Add(GetBezier(i / (float)segment, sp, cp, ep));
+ list.Add(GetBezier(i / (float) segment, sp, cp, ep));
}
list.Add(ep);
return list;
@@ -181,7 +180,7 @@ namespace XUGL
}
for (int i = 0; i < segment; i++)
{
- posList.Add((GetBezier2(i / (float)segment, sp, cp, cp2, ep)));
+ posList.Add((GetBezier2(i / (float) segment, sp, cp, cp2, ep)));
}
posList.Add(ep);
}
diff --git a/package.json b/package.json
index c9b6a187..36a942cc 100644
--- a/package.json
+++ b/package.json
@@ -1,9 +1,9 @@
{
"name": "com.monitor1394.xcharts",
"displayName": "XCharts",
- "version": "3.0.0-preview9",
- "date": "20220506",
- "checkdate": "20220506",
+ "version": "3.0.0",
+ "date": "20220522",
+ "checkdate": "20220522",
"desc": "如果 XCharts 对您有帮助,希望您能在 Github 上点 Star 支持,非常感谢!",
"unity": "2018.3",
"description": "A charting and data visualization library for Unity.",