mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-16 05:10:12 +00:00
增加AreaStyle的高亮相关参数配置鼠标悬浮时高亮之前区域
This commit is contained in:
@@ -886,20 +886,14 @@ namespace XCharts
|
||||
|
||||
public Color GetAreaColor(ThemeInfo theme, int index, bool highlight)
|
||||
{
|
||||
if (areaStyle.color != Color.clear)
|
||||
var color = areaStyle.color != Color.clear ? areaStyle.color : (Color)theme.GetColor(index);
|
||||
if (highlight)
|
||||
{
|
||||
var color = areaStyle.color;
|
||||
if (highlight) color *= color;
|
||||
color.a *= areaStyle.opacity;
|
||||
return color;
|
||||
}
|
||||
else
|
||||
{
|
||||
var color = (Color)theme.GetColor(index);
|
||||
if (highlight) color *= color;
|
||||
color.a *= areaStyle.opacity;
|
||||
return color;
|
||||
if (areaStyle.highlightColor != Color.clear) color = areaStyle.highlightColor;
|
||||
else color *= color;
|
||||
}
|
||||
color.a *= areaStyle.opacity;
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color GetAreaToColor(ThemeInfo theme, int index, bool highlight)
|
||||
@@ -907,7 +901,11 @@ namespace XCharts
|
||||
if (areaStyle.toColor != Color.clear)
|
||||
{
|
||||
var color = areaStyle.toColor;
|
||||
if (highlight) color *= color;
|
||||
if (highlight)
|
||||
{
|
||||
if (areaStyle.highlightToColor != Color.clear) color = areaStyle.highlightToColor;
|
||||
else color *= color;
|
||||
}
|
||||
color.a *= areaStyle.opacity;
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,10 @@ namespace XCharts
|
||||
[SerializeField] private AreaOrigin m_Origin;
|
||||
[SerializeField] private Color m_Color;
|
||||
[SerializeField] private Color m_ToColor;
|
||||
[SerializeField][Range(0,1)] private float m_Opacity;
|
||||
[SerializeField] [Range(0, 1)] private float m_Opacity;
|
||||
[SerializeField] private bool m_TooltipHighlight;
|
||||
[SerializeField] private Color m_HighlightColor;
|
||||
[SerializeField] private Color m_HighlightToColor;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the areafrom showing.
|
||||
@@ -57,13 +60,26 @@ namespace XCharts
|
||||
/// Gradient color, start color to toColor.
|
||||
/// 渐变色的终点颜色。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Color toColor { get { return m_ToColor; } set { m_ToColor = value; } }
|
||||
/// <summary>
|
||||
/// Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
|
||||
/// 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||
/// </summary>
|
||||
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
|
||||
/// <summary>
|
||||
/// 鼠标悬浮时是否高亮之前的区域
|
||||
/// </summary>
|
||||
public bool tooltipHighlight { get { return m_TooltipHighlight; } set { m_TooltipHighlight = value; } }
|
||||
/// <summary>
|
||||
/// the color of area,default use serie color.
|
||||
/// 高亮时区域填充的颜色,如果highlightToColor不是默认值,则表示渐变色的起点颜色。
|
||||
/// </summary>
|
||||
public Color highlightColor { get { return m_HighlightColor; } set { m_HighlightColor = value; } }
|
||||
/// <summary>
|
||||
/// Gradient color, start highlightColor to highlightToColor.
|
||||
/// 高亮时渐变色的终点颜色。
|
||||
/// </summary>
|
||||
public Color highlightToColor { get { return m_HighlightToColor; } set { m_HighlightToColor = value; } }
|
||||
|
||||
public static AreaStyle defaultAreaStyle
|
||||
{
|
||||
|
||||
@@ -73,8 +73,11 @@ namespace XCharts
|
||||
var showData = serie.GetDataList(m_DataZoom);
|
||||
if (showData.Count <= 0) return;
|
||||
Color lineColor = serie.GetLineColor(m_ThemeInfo, colorIndex, false);
|
||||
Color areaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, false);
|
||||
Color areaToColor = serie.GetAreaToColor(m_ThemeInfo, colorIndex, false);
|
||||
Color srcAreaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, false);
|
||||
Color srcAreaToColor = serie.GetAreaToColor(m_ThemeInfo, colorIndex, false);
|
||||
Color highlightAreaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, true);
|
||||
Color highlightAreaToColor = serie.GetAreaToColor(m_ThemeInfo, colorIndex, true);
|
||||
Color areaColor, areaToColor;
|
||||
Vector3 lp = Vector3.zero, np = Vector3.zero, llp = Vector3.zero, nnp = Vector3.zero;
|
||||
var yAxis = m_YAxises[serie.axisIndex];
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
@@ -158,6 +161,16 @@ namespace XCharts
|
||||
serie.ClearSmoothList(i);
|
||||
if (!serie.animation.NeedAnimation(i)) break;
|
||||
bool isFinish = true;
|
||||
if (serie.areaStyle.tooltipHighlight && m_Tooltip.show && i <= m_Tooltip.dataIndex[0])
|
||||
{
|
||||
areaColor = highlightAreaColor;
|
||||
areaToColor = highlightAreaToColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
areaColor = srcAreaColor;
|
||||
areaToColor = srcAreaToColor;
|
||||
}
|
||||
switch (serie.lineType)
|
||||
{
|
||||
case LineType.Normal:
|
||||
@@ -351,8 +364,11 @@ namespace XCharts
|
||||
Vector3 llp = Vector3.zero;
|
||||
Vector3 nnp = Vector3.zero;
|
||||
Color lineColor = serie.GetLineColor(m_ThemeInfo, colorIndex, false);
|
||||
Color areaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, false);
|
||||
Color areaToColor = serie.GetAreaToColor(m_ThemeInfo, colorIndex, false);
|
||||
Color srcAreaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, false);
|
||||
Color srcAreaToColor = serie.GetAreaToColor(m_ThemeInfo, colorIndex, false);
|
||||
Color highlightAreaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, true);
|
||||
Color highlightAreaToColor = serie.GetAreaToColor(m_ThemeInfo, colorIndex, true);
|
||||
Color areaColor, areaToColor;
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
var yAxis = m_YAxises[serie.axisIndex];
|
||||
var zeroPos = new Vector3(coordinateX + xAxis.zeroXOffset, coordinateY);
|
||||
@@ -412,6 +428,16 @@ namespace XCharts
|
||||
serie.ClearSmoothList(i);
|
||||
if (!serie.animation.NeedAnimation(i)) break;
|
||||
bool isFinish = true;
|
||||
if (serie.areaStyle.tooltipHighlight && m_Tooltip.show && i < m_Tooltip.dataIndex[0])
|
||||
{
|
||||
areaColor = highlightAreaColor;
|
||||
areaToColor = highlightAreaToColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
areaColor = srcAreaToColor;
|
||||
areaToColor = srcAreaToColor;
|
||||
}
|
||||
switch (serie.lineType)
|
||||
{
|
||||
case LineType.Normal:
|
||||
|
||||
Reference in New Issue
Block a user