This commit is contained in:
monitor1394
2022-03-29 22:06:10 +08:00
parent b784900fda
commit 1ad87920d0
17 changed files with 130 additions and 117 deletions

View File

@@ -71,7 +71,7 @@ namespace XCharts.Runtime
public override void SetDefaultValue()
{
m_Show = false;
m_Show = true;
m_Image = null;
m_ImageType = Image.Type.Sliced;
m_ImageColor = Color.white;

View File

@@ -33,32 +33,6 @@ namespace XCharts.Runtime
component.refreshComponent();
}
//protected void DrawBackground(VertexHelper vh)
//{
//TODO: CooridateChart
// if (SeriesHelper.IsAnyClipSerie(m_Series))
// {
// var xLineDiff = xAxis0.axisLine.GetWidth(m_Theme.axis.lineWidth);
// var yLineDiff = yAxis0.axisLine.GetWidth(m_Theme.axis.lineWidth);
// var xSplitDiff = xAxis0.splitLine.GetWidth(m_Theme.axis.splitLineWidth);
// var ySplitDiff = yAxis0.splitLine.GetWidth(m_Theme.axis.splitLineWidth);
// foreach (var grid in m_Grids)
// {
// var cpty = grid.context.runtimeY + grid.context.runtimeHeight + ySplitDiff;
// var cp1 = new Vector3(grid.context.runtimeX - yLineDiff, grid.context.runtimeY - xLineDiff);
// var cp2 = new Vector3(grid.context.runtimeX - yLineDiff, cpty);
// var cp3 = new Vector3(grid.context.runtimeX + grid.context.runtimeWidth + xSplitDiff, cpty);
// var cp4 = new Vector3(grid.context.runtimeX + grid.context.runtimeWidth + xSplitDiff, grid.context.runtimeY - xLineDiff);
// var backgroundColor = ThemeHelper.GetBackgroundColor(m_Theme, m_Background);
// UGL.DrawQuadrilateral(vh, cp1, cp2, cp3, cp4, backgroundColor);
// }
// }
// else
// {
// base.DrawBackground(vh);
// }
// }
public override void DrawBase(VertexHelper vh)
{
if (!component.show)

View File

@@ -1,6 +1,4 @@

using System;
using UnityEngine;
using UnityEngine;
namespace XCharts.Runtime
{
@@ -69,7 +67,6 @@ namespace XCharts.Runtime
End
}
[SerializeField] private bool m_Show = true;
[SerializeField] Position m_Position = Position.Outside;
[SerializeField] private Vector3 m_Offset;
@@ -81,7 +78,7 @@ namespace XCharts.Runtime
[SerializeField] private float m_BackgroundHeight = 0;
[SerializeField] private string m_NumericFormatter = "";
[SerializeField] private bool m_AutoOffset = false;
[SerializeField] private bool m_AutoColor = false;
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
private SerieLabelFormatterFunction m_FormatterFunction;
@@ -97,7 +94,6 @@ namespace XCharts.Runtime
m_BackgroundHeight = 0;
m_NumericFormatter = "";
m_AutoOffset = false;
m_AutoColor = false;
}
/// <summary>
@@ -211,14 +207,7 @@ namespace XCharts.Runtime
get { return m_AutoOffset; }
set { if (PropertyUtil.SetStruct(ref m_AutoOffset, value)) SetAllDirty(); }
}
/// <summary>
/// 是否开启自动颜色。当开启时会根据已支持的serie自动设置颜色。
/// </summary>
public bool autoColor
{
get { return m_AutoColor; }
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetAllDirty(); }
}
/// <summary>
/// the sytle of text.

View File

@@ -20,6 +20,7 @@ namespace XCharts.Runtime
[SerializeField] private float m_Rotate = 0;
[SerializeField] private float m_ExtraWidth = 0;
[SerializeField] private Vector2 m_Offset = Vector2.zero;
[SerializeField] private bool m_AutoColor = false;
[SerializeField] private Color m_Color = Color.clear;
[SerializeField] private bool m_AutoBackgroundColor = false;
[SerializeField] private Color m_BackgroundColor = Color.clear;
@@ -61,9 +62,15 @@ namespace XCharts.Runtime
get { return m_Offset; }
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetComponentDirty(); }
}
public Vector3 offsetv3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
/// <summary>
/// 是否开启自动颜色。当开启时,会自动设置颜色。
/// </summary>
public bool autoColor
{
get { return m_AutoColor; }
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetAllDirty(); }
}
/// <summary>
/// the color of text.
/// |文本的颜色。
@@ -207,7 +214,9 @@ namespace XCharts.Runtime
font = textStyle.font;
rotate = textStyle.rotate;
offset = textStyle.offset;
autoColor = textStyle.autoColor;
color = textStyle.color;
autoBackgroundColor = textStyle.autoBackgroundColor;
backgroundColor = textStyle.backgroundColor;
fontSize = textStyle.fontSize;
fontStyle = textStyle.fontStyle;
@@ -251,5 +260,13 @@ namespace XCharts.Runtime
{
return m_AutoAlign ? systemAlignment : alignment;
}
public Color32 GetBackgroundColor(Color32 chartBackgroundColor)
{
if (m_AutoColor || ChartHelper.IsClearColor(m_BackgroundColor))
return chartBackgroundColor;
else
return m_BackgroundColor;
}
}
}

View File

@@ -198,7 +198,7 @@ namespace XCharts.Runtime
UGL.DrawDiamond(vh, rect.center, radius, color);
break;
case Legend.Type.EmptyCircle:
var backgroundColor = chart.theme.GetBackgroundColor(chart.GetChartComponent<Background>());
var backgroundColor = chart.GetChartBackgroundColor();
UGL.DrawEmptyCricle(vh, rect.center, radius, 2 * chart.settings.legendIconLineWidth,
color, color, backgroundColor, 1f);
break;

View File

@@ -78,12 +78,14 @@ namespace XCharts.Runtime
var element = ChartHelper.AddSerieLabel(textName, m_MarkLineLabelRoot.transform, label.backgroundWidth,
label.backgroundHeight, color, label.textStyle, chart.theme);
var isAutoSize = label.backgroundWidth == 0 || label.backgroundHeight == 0;
var backgroundColor = label.textStyle.GetBackgroundColor(chart.GetChartBackgroundColor());
var item = ChartHelper.GetOrAddComponent<ChartLabel>(element);
item.SetLabel(element, isAutoSize, label.paddingLeftRight, label.paddingTopBottom);
item.SetIconActive(false);
item.SetActive(data.label.show);
item.SetPosition(MarkLineHelper.GetLabelPosition(data));
item.SetText(MarkLineHelper.GetFormatterContent(serie, data));
item.color = backgroundColor;
data.runtimeLabel = item;
};
data.refreshComponent();