diff --git a/CHANGELOG-EN.md b/CHANGELOG-EN.md
index 707c0086..931864e0 100644
--- a/CHANGELOG-EN.md
+++ b/CHANGELOG-EN.md
@@ -34,6 +34,7 @@
## Latest
+* (2021.05.01) Added `Settings` parameters for painter's material #140
* (2021.05.01) Fixed an issue where some super large or super small values could not be properly represented
* (2021.04.29) Fixed an issue with `Radar` switching to `Circle` anomaly #139
* (2021.04.29) Added `Settings`'s `reversePainter` to set whether or not `Serie` is drawn in reverse order
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 457afaa7..cbf05cb1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,6 +34,7 @@
## Latest
+* (2021.05.01) 增加`Settings`中关于关于材质球设置的参数 #140
* (2021.05.01) 修复无法正确表示部分超大或超小数值的问题
* (2021.04.29) 修复`Radar`切换到`Circle`异常的问题 #139
* (2021.04.29) 增加`Settings`的`reversePainter`可设置`Serie`的绘制是否逆序
diff --git a/Documentation/XChartsAPI.md b/Documentation/XChartsAPI.md
index 0554dac5..f0f821ec 100644
--- a/Documentation/XChartsAPI.md
+++ b/Documentation/XChartsAPI.md
@@ -67,6 +67,9 @@
* `BaseChart.IsInChart(Vector2 local)`:坐标是否在图表范围内。
* `BaseChart.IsInChart(float x, float y)`:坐标是否在图表范围内。
* `BaseChart.EnableBackground(bool flag)`:开启背景组件。背景组件在`chart`受上层布局控制时无法开启。
+* `BaseChart.SetBasePainterMaterial(Material material)`:设置Base Painter的材质球。
+* `BaseChart.SetSeriePainterMaterial(Material material)`:设置Serie Painter的材质球。
+* `BaseChart.SetTopPainterMaterial(Material material)`:设置Top Painter的材质球。
## `CoordinateChart`
diff --git a/Documentation/XCharts配置项手册.md b/Documentation/XCharts配置项手册.md
index 5d10f97a..5bbe1acc 100644
--- a/Documentation/XCharts配置项手册.md
+++ b/Documentation/XCharts配置项手册.md
@@ -799,6 +799,9 @@ K线图系列。
* `reversePainter`:Painter是否逆序。逆序时index大的serie最先绘制。
* `maxPainter`:默认最大Painter数据,当Serie数量大于maxPainter时会平均分配Painter。
+* `basePainterMaterial`:Base Pointer 材质球,设置后会影响Axis等。
+* `seriePainterMaterial`:Serie Pointer 材质球,设置后会影响所有Serie。
+* `topPainterMaterial`:Top Pointer 材质球,设置后会影响Tooltip等。
* `lineSmoothStyle`:曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
* `lineSmoothness`:曲线平滑度。值越小曲线越平滑,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
* `lineSegmentDistance`: 线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
diff --git a/Documentation/xcharts-api-EN.md b/Documentation/xcharts-api-EN.md
index a7d60f59..6b1d2da3 100644
--- a/Documentation/xcharts-api-EN.md
+++ b/Documentation/xcharts-api-EN.md
@@ -66,6 +66,9 @@
* `BaseChart.IsInChart(Vector2 local)`:坐标是否在图表范围内。
* `BaseChart.IsInChart(float x, float y)`:坐标是否在图表范围内。
* `BaseChart.EnableBackground(bool flag)`:开启背景组件。背景组件在`chart`受上层布局控制时无法开启。
+* `BaseChart.SetBasePainterMaterial(Material material)`:设置Base Painter的材质球。
+* `BaseChart.SetSeriePainterMaterial(Material material)`:设置Serie Painter的材质球。
+* `BaseChart.SetTopPainterMaterial(Material material)`:设置Top Painter的材质球。
## `CoordinateChart`
diff --git a/Documentation/xcharts-configuration-EN.md b/Documentation/xcharts-configuration-EN.md
index 2967f747..1acf386e 100644
--- a/Documentation/xcharts-configuration-EN.md
+++ b/Documentation/xcharts-configuration-EN.md
@@ -692,6 +692,9 @@ K线图系列。
* `reversePainter`:Painter是否逆序。逆序时index大的serie最先绘制。
* `maxPainter`:默认最大Painter数据,当Serie数量大于maxPainter时会平均分配Painter。
+* `basePainterMaterial`:Base Pointer 材质球,设置后会影响Axis等。
+* `seriePainterMaterial`:Serie Pointer 材质球,设置后会影响所有Serie。
+* `topPainterMaterial`:Top Pointer 材质球,设置后会影响Tooltip等。
* `lineSmoothStyle`: 曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
* `lineSmoothness`: 曲线平滑度。值越小曲线越平滑,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
* `lineSegmentDistance`: 线段的分割距离。普通折线图的线是由很多线段组成,段数由该数值决定。值越小段数越多,但顶点数也会随之增加。当开启有渐变的区域填充时,数值越大渐变过渡效果越差。
diff --git a/Editor/PropertyDrawers/SettingsDrawer.cs b/Editor/PropertyDrawers/SettingsDrawer.cs
index 2e9bbd9f..1a95bf89 100644
--- a/Editor/PropertyDrawers/SettingsDrawer.cs
+++ b/Editor/PropertyDrawers/SettingsDrawer.cs
@@ -29,6 +29,9 @@ namespace XCharts
++EditorGUI.indentLevel;
PropertyField(prop, "m_ReversePainter");
PropertyField(prop, "m_MaxPainter");
+ PropertyField(prop, "m_BasePainterMaterial");
+ PropertyField(prop, "m_SeriePainterMaterial");
+ PropertyField(prop, "m_TopPainterMaterial");
PropertyField(prop, "m_LineSmoothStyle");
PropertyField(prop, "m_LineSmoothness");
PropertyField(prop, "m_LineSegmentDistance");
diff --git a/Runtime/API/BaseChart_API.cs b/Runtime/API/BaseChart_API.cs
index a62dc77a..9e8d6057 100644
--- a/Runtime/API/BaseChart_API.cs
+++ b/Runtime/API/BaseChart_API.cs
@@ -743,5 +743,45 @@ namespace XCharts
public virtual void InitCustomSerieTooltip(ref StringBuilder stringBuilder, Serie serie, int index)
{
}
+
+ ///
+ /// 设置Base Painter的材质球
+ ///
+ ///
+ public void SetBasePainterMaterial(Material material)
+ {
+ settings.basePainterMaterial = material;
+ if (m_Painter != null)
+ {
+ m_Painter.material = material;
+ }
+ }
+
+ ///
+ /// 设置Serie Painter的材质球
+ ///
+ ///
+ public void SetSeriePainterMaterial(Material material)
+ {
+ settings.basePainterMaterial = material;
+ if (m_PainterList != null)
+ {
+ foreach (var painter in m_PainterList)
+ painter.material = material;
+ }
+ }
+
+ ///
+ /// 设置Top Painter的材质球
+ ///
+ ///
+ public void SetTopPainterMaterial(Material material)
+ {
+ settings.topPainterMaterial = material;
+ if (m_PainterTop != null)
+ {
+ m_PainterTop.material = material;
+ }
+ }
}
}
diff --git a/Runtime/Component/Main/Settings.cs b/Runtime/Component/Main/Settings.cs
index 9bff0dc6..f4d05b67 100644
--- a/Runtime/Component/Main/Settings.cs
+++ b/Runtime/Component/Main/Settings.cs
@@ -19,6 +19,9 @@ namespace XCharts
{
[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(1f, 20)] protected float m_LineSegmentDistance = 3f;
@@ -44,6 +47,30 @@ namespace XCharts
set { if (PropertyUtil.SetStruct(ref m_ReversePainter, value)) SetVerticesDirty(); }
}
///
+ /// Base Pointer 材质球,设置后会影响Axis等。
+ ///
+ public Material basePainterMaterial
+ {
+ get { return m_BasePainterMaterial; }
+ set { if (PropertyUtil.SetClass(ref m_BasePainterMaterial, value)) SetComponentDirty(); }
+ }
+ ///
+ /// Serie Pointer 材质球,设置后会影响所有Serie。
+ ///
+ public Material seriePainterMaterial
+ {
+ get { return m_SeriePainterMaterial; }
+ set { if (PropertyUtil.SetClass(ref m_SeriePainterMaterial, value)) SetComponentDirty(); }
+ }
+ ///
+ /// Top Pointer 材质球,设置后会影响Tooltip等。
+ ///
+ public Material topPainterMaterial
+ {
+ get { return m_TopPainterMaterial; }
+ set { if (PropertyUtil.SetClass(ref m_TopPainterMaterial, value)) SetComponentDirty(); }
+ }
+ ///
/// Curve smoothing factor. By adjusting the smoothing coefficient, the curvature of the curve can be changed,
/// and different curves with slightly different appearance can be obtained.
/// 曲线平滑系数。通过调整平滑系数可以改变曲线的曲率,得到外观稍微有变化的不同曲线。
@@ -110,6 +137,9 @@ namespace XCharts
{
m_ReversePainter = settings.reversePainter;
m_MaxPainter = settings.maxPainter;
+ m_BasePainterMaterial = settings.basePainterMaterial;
+ m_SeriePainterMaterial = settings.seriePainterMaterial;
+ m_TopPainterMaterial = settings.topPainterMaterial;
m_LineSmoothStyle = settings.lineSmoothStyle;
m_LineSmoothness = settings.lineSmoothness;
m_LineSegmentDistance = settings.lineSegmentDistance;
diff --git a/Runtime/Internal/BaseChart.cs b/Runtime/Internal/BaseChart.cs
index 01d30108..8d9dd89d 100644
--- a/Runtime/Internal/BaseChart.cs
+++ b/Runtime/Internal/BaseChart.cs
@@ -316,6 +316,7 @@ namespace XCharts
protected override void InitPainter()
{
base.InitPainter();
+ m_Painter.material = settings.basePainterMaterial;
m_PainterList.Clear();
if (settings == null) return;
var sizeDelta = new Vector2(m_GraphWidth, m_GraphHeight);
@@ -328,6 +329,7 @@ namespace XCharts
painter.type = Painter.Type.Serie;
painter.onPopulateMesh = OnDrawPainterSerie;
painter.SetActive(false, m_DebugMode);
+ painter.material = settings.seriePainterMaterial;
m_PainterList.Add(painter);
}
m_PainterTop = ChartHelper.AddPainterObject("painter_t", transform, m_GraphMinAnchor,
@@ -335,6 +337,7 @@ namespace XCharts
m_PainterTop.type = Painter.Type.Top;
m_PainterTop.onPopulateMesh = OnDrawPainterTop;
m_PainterTop.SetActive(true, m_DebugMode);
+ m_PainterTop.material = settings.topPainterMaterial;
}
private void InitTitles()