mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 01:10:08 +00:00
增加AreaStyle的高亮相关参数配置鼠标悬浮时高亮之前区域
This commit is contained in:
@@ -17,7 +17,10 @@ namespace XCharts
|
|||||||
SerializedProperty m_Origin = prop.FindPropertyRelative("m_Origin");
|
SerializedProperty m_Origin = prop.FindPropertyRelative("m_Origin");
|
||||||
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
SerializedProperty m_Color = prop.FindPropertyRelative("m_Color");
|
||||||
SerializedProperty m_ToColor = prop.FindPropertyRelative("m_ToColor");
|
SerializedProperty m_ToColor = prop.FindPropertyRelative("m_ToColor");
|
||||||
|
SerializedProperty m_HighlightColor = prop.FindPropertyRelative("m_HighlightColor");
|
||||||
|
SerializedProperty m_HighlightToColor = prop.FindPropertyRelative("m_HighlightToColor");
|
||||||
SerializedProperty m_Opacity = prop.FindPropertyRelative("m_Opacity");
|
SerializedProperty m_Opacity = prop.FindPropertyRelative("m_Opacity");
|
||||||
|
SerializedProperty m_TooltipHighlight = prop.FindPropertyRelative("m_TooltipHighlight");
|
||||||
|
|
||||||
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AreaStyleToggle, prop, "Area Style", show, false);
|
ChartEditorHelper.MakeFoldout(ref drawRect, ref m_AreaStyleToggle, prop, "Area Style", show, false);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
@@ -30,8 +33,14 @@ namespace XCharts
|
|||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_ToColor);
|
EditorGUI.PropertyField(drawRect, m_ToColor);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_HighlightColor);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_HighlightToColor);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
EditorGUI.PropertyField(drawRect, m_Opacity);
|
EditorGUI.PropertyField(drawRect, m_Opacity);
|
||||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
|
EditorGUI.PropertyField(drawRect, m_TooltipHighlight);
|
||||||
|
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||||
--EditorGUI.indentLevel;
|
--EditorGUI.indentLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,7 +50,7 @@ namespace XCharts
|
|||||||
float height = 0;
|
float height = 0;
|
||||||
if (ChartEditorHelper.IsToggle(m_AreaStyleToggle, prop))
|
if (ChartEditorHelper.IsToggle(m_AreaStyleToggle, prop))
|
||||||
{
|
{
|
||||||
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
height += 8 * EditorGUIUtility.singleLineHeight + 7 * EditorGUIUtility.standardVerticalSpacing;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -886,20 +886,14 @@ namespace XCharts
|
|||||||
|
|
||||||
public Color GetAreaColor(ThemeInfo theme, int index, bool highlight)
|
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 (areaStyle.highlightColor != Color.clear) color = areaStyle.highlightColor;
|
||||||
if (highlight) color *= color;
|
else 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;
|
|
||||||
}
|
}
|
||||||
|
color.a *= areaStyle.opacity;
|
||||||
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color GetAreaToColor(ThemeInfo theme, int index, bool highlight)
|
public Color GetAreaToColor(ThemeInfo theme, int index, bool highlight)
|
||||||
@@ -907,7 +901,11 @@ namespace XCharts
|
|||||||
if (areaStyle.toColor != Color.clear)
|
if (areaStyle.toColor != Color.clear)
|
||||||
{
|
{
|
||||||
var color = areaStyle.toColor;
|
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;
|
color.a *= areaStyle.opacity;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,10 @@ namespace XCharts
|
|||||||
[SerializeField] private AreaOrigin m_Origin;
|
[SerializeField] private AreaOrigin m_Origin;
|
||||||
[SerializeField] private Color m_Color;
|
[SerializeField] private Color m_Color;
|
||||||
[SerializeField] private Color m_ToColor;
|
[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>
|
/// <summary>
|
||||||
/// Set this to false to prevent the areafrom showing.
|
/// Set this to false to prevent the areafrom showing.
|
||||||
@@ -57,13 +60,26 @@ namespace XCharts
|
|||||||
/// Gradient color, start color to toColor.
|
/// Gradient color, start color to toColor.
|
||||||
/// 渐变色的终点颜色。
|
/// 渐变色的终点颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value></value>
|
|
||||||
public Color toColor { get { return m_ToColor; } set { m_ToColor = value; } }
|
public Color toColor { get { return m_ToColor; } set { m_ToColor = value; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
|
/// Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
|
||||||
/// 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
/// 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
|
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
|
public static AreaStyle defaultAreaStyle
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,8 +73,11 @@ namespace XCharts
|
|||||||
var showData = serie.GetDataList(m_DataZoom);
|
var showData = serie.GetDataList(m_DataZoom);
|
||||||
if (showData.Count <= 0) return;
|
if (showData.Count <= 0) return;
|
||||||
Color lineColor = serie.GetLineColor(m_ThemeInfo, colorIndex, false);
|
Color lineColor = serie.GetLineColor(m_ThemeInfo, colorIndex, false);
|
||||||
Color areaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, false);
|
Color srcAreaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, false);
|
||||||
Color areaToColor = serie.GetAreaToColor(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;
|
Vector3 lp = Vector3.zero, np = Vector3.zero, llp = Vector3.zero, nnp = Vector3.zero;
|
||||||
var yAxis = m_YAxises[serie.axisIndex];
|
var yAxis = m_YAxises[serie.axisIndex];
|
||||||
var xAxis = m_XAxises[serie.axisIndex];
|
var xAxis = m_XAxises[serie.axisIndex];
|
||||||
@@ -158,6 +161,16 @@ namespace XCharts
|
|||||||
serie.ClearSmoothList(i);
|
serie.ClearSmoothList(i);
|
||||||
if (!serie.animation.NeedAnimation(i)) break;
|
if (!serie.animation.NeedAnimation(i)) break;
|
||||||
bool isFinish = true;
|
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)
|
switch (serie.lineType)
|
||||||
{
|
{
|
||||||
case LineType.Normal:
|
case LineType.Normal:
|
||||||
@@ -351,8 +364,11 @@ namespace XCharts
|
|||||||
Vector3 llp = Vector3.zero;
|
Vector3 llp = Vector3.zero;
|
||||||
Vector3 nnp = Vector3.zero;
|
Vector3 nnp = Vector3.zero;
|
||||||
Color lineColor = serie.GetLineColor(m_ThemeInfo, colorIndex, false);
|
Color lineColor = serie.GetLineColor(m_ThemeInfo, colorIndex, false);
|
||||||
Color areaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, false);
|
Color srcAreaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, false);
|
||||||
Color areaToColor = serie.GetAreaToColor(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 xAxis = m_XAxises[serie.axisIndex];
|
||||||
var yAxis = m_YAxises[serie.axisIndex];
|
var yAxis = m_YAxises[serie.axisIndex];
|
||||||
var zeroPos = new Vector3(coordinateX + xAxis.zeroXOffset, coordinateY);
|
var zeroPos = new Vector3(coordinateX + xAxis.zeroXOffset, coordinateY);
|
||||||
@@ -412,6 +428,16 @@ namespace XCharts
|
|||||||
serie.ClearSmoothList(i);
|
serie.ClearSmoothList(i);
|
||||||
if (!serie.animation.NeedAnimation(i)) break;
|
if (!serie.animation.NeedAnimation(i)) break;
|
||||||
bool isFinish = true;
|
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)
|
switch (serie.lineType)
|
||||||
{
|
{
|
||||||
case LineType.Normal:
|
case LineType.Normal:
|
||||||
|
|||||||
Reference in New Issue
Block a user