增加DataZoom主题配置

This commit is contained in:
monitor1394
2019-06-14 09:41:15 +08:00
parent dfb0b33fe3
commit 100f25fc1b
6 changed files with 153 additions and 137 deletions

View File

@@ -411,7 +411,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -855,7 +855,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -1557,7 +1557,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -2034,7 +2034,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.16078432, g: 0.16078432, b: 0.16078432, a: 1}
m_Color: {r: 0.654902, g: 0.654902, b: 0.654902, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -2556,7 +2556,7 @@ GameObject:
- component: {fileID: 724935910}
- component: {fileID: 724935908}
m_Layer: 5
m_Name: xchart
m_Name: line
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -2611,21 +2611,21 @@ MonoBehaviour:
m_BackgroundColor:
serializedVersion: 2
rgba: 4294967295
m_ContrastColor:
serializedVersion: 2
rgba: 4283256145
m_TextColor:
serializedVersion: 2
rgba: 4283256145
m_SubTextColor:
m_TitleSubTextColor:
serializedVersion: 2
rgba: 4283256145
rgba: 0
m_LegendTextColor:
serializedVersion: 2
rgba: 4293848814
m_UnableColor:
m_LegendUnableColor:
serializedVersion: 2
rgba: 4291611852
rgba: 0
m_AxisTextColor:
serializedVersion: 2
rgba: 0
m_AxisLineColor:
serializedVersion: 2
rgba: 4283256145
@@ -2647,6 +2647,15 @@ MonoBehaviour:
m_TooltipLineColor:
serializedVersion: 2
rgba: 1680419113
m_DataZoomTextColor:
serializedVersion: 2
rgba: 0
m_DataZoomLineColor:
serializedVersion: 2
rgba: 0
m_DataZoomSelectedColor:
serializedVersion: 2
rgba: 0
m_ColorPalette:
- serializedVersion: 2
rgba: 4281415106
@@ -3722,7 +3731,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -3760,7 +3769,7 @@ GameObject:
- component: {fileID: 887794270}
- component: {fileID: 887794269}
m_Layer: 5
m_Name: xchart (1)
m_Name: bar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -3809,33 +3818,33 @@ MonoBehaviour:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Theme: 1
m_Theme: 3
m_ThemeInfo:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_BackgroundColor:
serializedVersion: 2
rgba: 4294967295
m_ContrastColor:
serializedVersion: 2
rgba: 4283256145
rgba: 4280427042
m_TextColor:
serializedVersion: 2
rgba: 4283256145
m_SubTextColor:
rgba: 4293848814
m_TitleSubTextColor:
serializedVersion: 2
rgba: 4283256145
rgba: 4293848814
m_LegendTextColor:
serializedVersion: 2
rgba: 4293848814
m_UnableColor:
m_LegendUnableColor:
serializedVersion: 2
rgba: 4291611852
m_AxisTextColor:
serializedVersion: 2
rgba: 4293848814
m_AxisLineColor:
serializedVersion: 2
rgba: 4283256145
rgba: 4293848814
m_AxisSplitLineColor:
serializedVersion: 2
rgba: 542200145
rgba: 4289374890
m_TooltipBackgroundColor:
serializedVersion: 2
rgba: 3042005329
@@ -3847,33 +3856,42 @@ MonoBehaviour:
rgba: 4294967295
m_TooltipLabelColor:
serializedVersion: 2
rgba: 4280887593
rgba: 4289177511
m_TooltipLineColor:
serializedVersion: 2
rgba: 1680419113
rgba: 4293848814
m_DataZoomTextColor:
serializedVersion: 2
rgba: 4294967295
m_DataZoomLineColor:
serializedVersion: 2
rgba: 1174405119
m_DataZoomSelectedColor:
serializedVersion: 2
rgba: 1037095120
m_ColorPalette:
- serializedVersion: 2
rgba: 4281415106
rgba: 4284902365
- serializedVersion: 2
rgba: 4283712815
rgba: 4288715381
- serializedVersion: 2
rgba: 4289241185
rgba: 4287077862
- serializedVersion: 2
rgba: 4284842708
rgba: 4289315213
- serializedVersion: 2
rgba: 4289644433
rgba: 4283662058
- serializedVersion: 2
rgba: 4286816116
rgba: 4286111214
- serializedVersion: 2
rgba: 4280452810
rgba: 4285768563
- serializedVersion: 2
rgba: 4288324285
rgba: 4290558323
- serializedVersion: 2
rgba: 4285821038
rgba: 4289431922
- serializedVersion: 2
rgba: 4285556052
rgba: 4287416977
- serializedVersion: 2
rgba: 4292070596
rgba: 4282556404
m_Title:
m_Show: 1
m_Text: Chart Title
@@ -5139,7 +5157,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.16078432, g: 0.16078432, b: 0.16078432, a: 1}
m_Color: {r: 0.654902, g: 0.654902, b: 0.654902, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -5577,7 +5595,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -5651,7 +5669,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -5833,7 +5851,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -6203,7 +6221,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -6460,7 +6478,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -7094,7 +7112,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.7607843, g: 0.20784314, b: 0.19215687, a: 1}
m_Color: {r: 0.8666667, g: 0.41960785, b: 0.4, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -7310,7 +7328,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
@@ -7797,7 +7815,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.31764707, g: 0.3019608, b: 0.3019608, a: 1}
m_Color: {r: 0.93333334, g: 0.93333334, b: 0.93333334, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:

View File

@@ -36,11 +36,11 @@ namespace XCharts
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty m_Font = prop.FindPropertyRelative("m_Font");
SerializedProperty m_BackgroundColor = prop.FindPropertyRelative("m_BackgroundColor");
SerializedProperty m_ContrastColor = prop.FindPropertyRelative("m_ContrastColor");
SerializedProperty m_TextColor = prop.FindPropertyRelative("m_TextColor");
SerializedProperty m_SubTextColor = prop.FindPropertyRelative("m_SubTextColor");
SerializedProperty m_SubTextColor = prop.FindPropertyRelative("m_TitleSubTextColor");
SerializedProperty m_LegendTextColor = prop.FindPropertyRelative("m_LegendTextColor");
SerializedProperty m_UnableColor = prop.FindPropertyRelative("m_UnableColor");
SerializedProperty m_LegendUnableColor = prop.FindPropertyRelative("m_LegendUnableColor");
SerializedProperty m_AxisTextColor = prop.FindPropertyRelative("m_AxisTextColor");
SerializedProperty m_AxisLineColor = prop.FindPropertyRelative("m_AxisLineColor");
SerializedProperty m_AxisSplitLineColor = prop.FindPropertyRelative("m_AxisSplitLineColor");
SerializedProperty m_TooltipBackgroundColor = prop.FindPropertyRelative("m_TooltipBackgroundColor");
@@ -48,6 +48,9 @@ namespace XCharts
SerializedProperty m_TooltipTextColor = prop.FindPropertyRelative("m_TooltipTextColor");
SerializedProperty m_TooltipLabelColor = prop.FindPropertyRelative("m_TooltipLabelColor");
SerializedProperty m_TooltipLineColor = prop.FindPropertyRelative("m_TooltipLineColor");
SerializedProperty m_DataZoomLineColor = prop.FindPropertyRelative("m_DataZoomLineColor");
SerializedProperty m_DataZoomSelectedColor = prop.FindPropertyRelative("m_DataZoomSelectedColor");
SerializedProperty m_DataZoomTextColor = prop.FindPropertyRelative("m_DataZoomTextColor");
SerializedProperty m_ColorPalette = prop.FindPropertyRelative("m_ColorPalette");
++EditorGUI.indentLevel;
@@ -55,15 +58,15 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_BackgroundColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_ContrastColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_TextColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_SubTextColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_LegendTextColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_UnableColor);
EditorGUI.PropertyField(drawRect, m_LegendUnableColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_AxisTextColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_AxisLineColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -79,6 +82,12 @@ namespace XCharts
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_TooltipLineColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_DataZoomLineColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_DataZoomSelectedColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, m_DataZoomTextColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
m_ColorPaletteFoldout = EditorGUI.Foldout(drawRect, m_ColorPaletteFoldout, "ColorPalette");
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
@@ -100,7 +109,7 @@ namespace XCharts
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
float height = 0;
int propertyCount = 14;
int propertyCount = 17;
if (m_ColorPaletteFoldout)
{
SerializedProperty m_ColorPalette = prop.FindPropertyRelative("m_ColorPalette");

View File

@@ -70,7 +70,6 @@ namespace XCharts
protected override void Awake()
{
raycastTarget = false;
m_ThemeInfo = ThemeInfo.Default;
rectTransform.anchorMax = Vector2.zero;
rectTransform.anchorMin = Vector2.zero;
rectTransform.pivot = Vector2.zero;
@@ -91,7 +90,7 @@ namespace XCharts
CheckTooltip();
CheckRefreshChart();
}
#if UNITY_EDITOR
protected override void Reset()
{
@@ -145,7 +144,7 @@ namespace XCharts
RefreshChart();
}
public virtual void SetActive(string legend,bool active)
public virtual void SetActive(string legend, bool active)
{
m_Legend.SetActive(legend, active);
m_Series.SetActive(legend, active);
@@ -238,17 +237,17 @@ namespace XCharts
m_Legend.SetButton(i, btn);
m_Legend.SetActive(i, IsActive(i));
m_Legend.UpdateButtonColor(i, m_ThemeInfo.GetColor(i), m_ThemeInfo.unableColor);
m_Legend.UpdateButtonColor(i, m_ThemeInfo.GetColor(i), m_ThemeInfo.legendUnableColor);
btn.GetComponentInChildren<Text>().text = m_Legend.data[i];
ChartHelper.AddEventListener(btn.gameObject, EventTriggerType.PointerDown, (data) =>
{
int count = (data as PointerEventData).clickCount;
int index = int.Parse(data.selectedObject.name.Split('_')[1]);
SetActive(index, !m_Legend.IsActive(index));
m_Legend.UpdateButtonColor(index, m_ThemeInfo.GetColor(index), m_ThemeInfo.unableColor);
OnYMaxValueChanged();
OnLegendButtonClicked();
RefreshChart();
int count = (data as PointerEventData).clickCount;
int index = int.Parse(data.selectedObject.name.Split('_')[1]);
SetActive(index, !m_Legend.IsActive(index));
m_Legend.UpdateButtonColor(index, m_ThemeInfo.GetColor(index), m_ThemeInfo.legendUnableColor);
OnYMaxValueChanged();
OnLegendButtonClicked();
RefreshChart();
});
}
}
@@ -325,7 +324,7 @@ namespace XCharts
{
if (!m_Tooltip.show || !m_Tooltip.isInited)
{
if(m_Tooltip.dataIndex != 0)
if (m_Tooltip.dataIndex != 0)
{
m_Tooltip.dataIndex = 0;
m_Tooltip.SetActive(false);
@@ -335,7 +334,7 @@ namespace XCharts
}
m_Tooltip.SetLabelActive(m_Tooltip.crossLabel);
m_Tooltip.dataIndex = 0;
Vector2 local;
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform,

View File

@@ -223,33 +223,10 @@ namespace XCharts
m_Tooltip.UpdateContentPos(pos);
}
TextGenerationSettings GetTextSetting()
{
var setting = new TextGenerationSettings();
var fontdata = FontData.defaultFontData;
//setting.generationExtents = rectTransform.rect.size;
setting.generationExtents = new Vector2(200.0F, 50.0F);
setting.fontSize = 14;
setting.textAnchor = TextAnchor.MiddleCenter;
setting.scaleFactor = 1f;
setting.color = Color.red;
setting.font = m_ThemeInfo.font;
setting.pivot = new Vector2(0.5f, 0.5f);
setting.richText = false;
setting.lineSpacing = 0;
setting.fontStyle = FontStyle.Normal;
setting.resizeTextForBestFit = false;
setting.horizontalOverflow = HorizontalWrapMode.Overflow;
setting.verticalOverflow = VerticalWrapMode.Overflow;
return setting;
}
protected override void OnThemeChanged()
{
base.OnThemeChanged();
InitDataZoom();
InitSplitX();
InitSplitY();
}
@@ -279,7 +256,7 @@ namespace XCharts
for (int i = 0; i < m_YAxis.GetSplitNumber(m_DataZoom); i++)
{
Text txt = ChartHelper.AddTextObject(s_DefaultSplitNameY + i, titleObject.transform,
m_ThemeInfo.font, m_ThemeInfo.textColor, TextAnchor.MiddleRight, Vector2.zero,
m_ThemeInfo.font, m_ThemeInfo.axisTextColor, TextAnchor.MiddleRight, Vector2.zero,
Vector2.zero, new Vector2(1, 0.5f), new Vector2(m_Coordinate.left, 20),
m_Coordinate.fontSize, m_XAxis.textRotation);
txt.transform.localPosition = GetSplitYPosition(splitWidth, i);
@@ -301,7 +278,7 @@ namespace XCharts
for (int i = 0; i < m_XAxis.GetSplitNumber(m_DataZoom); i++)
{
Text txt = ChartHelper.AddTextObject(s_DefaultSplitNameX + i, titleObject.transform,
m_ThemeInfo.font, m_ThemeInfo.textColor, TextAnchor.MiddleCenter, Vector2.zero,
m_ThemeInfo.font, m_ThemeInfo.axisTextColor, TextAnchor.MiddleCenter, Vector2.zero,
Vector2.zero, new Vector2(1, 0.5f), new Vector2(splitWidth, 20),
m_Coordinate.fontSize, m_XAxis.textRotation);
@@ -319,10 +296,10 @@ namespace XCharts
dataZoomObject.transform.localPosition = Vector3.zero;
ChartHelper.HideAllObject(dataZoomObject, s_DefaultDataZoom);
m_DataZoom.startLabel = ChartHelper.AddTextObject(s_DefaultDataZoom + "start",
dataZoomObject.transform, m_ThemeInfo.font, m_ThemeInfo.textColor, TextAnchor.MiddleRight,
dataZoomObject.transform, m_ThemeInfo.font, m_ThemeInfo.dataZoomTextColor, TextAnchor.MiddleRight,
Vector2.zero, Vector2.zero, new Vector2(1, 0.5f), new Vector2(200, 20));
m_DataZoom.endLabel = ChartHelper.AddTextObject(s_DefaultDataZoom + "end",
dataZoomObject.transform, m_ThemeInfo.font, m_ThemeInfo.textColor, TextAnchor.MiddleLeft,
dataZoomObject.transform, m_ThemeInfo.font, m_ThemeInfo.dataZoomTextColor, TextAnchor.MiddleLeft,
Vector2.zero, Vector2.zero, new Vector2(0, 0.5f), new Vector2(200, 20));
m_DataZoom.SetLabelActive(false);
m_XAxis.UpdateFilterData(m_DataZoom);
@@ -599,10 +576,10 @@ namespace XCharts
var p2 = new Vector2(coordinateX, m_DataZoom.bottom + m_DataZoom.height);
var p3 = new Vector2(coordinateX + coordinateWid, m_DataZoom.bottom + m_DataZoom.height);
var p4 = new Vector2(coordinateX + coordinateWid, m_DataZoom.bottom);
ChartHelper.DrawLine(vh, p1, p2, m_Coordinate.tickness, m_ThemeInfo.axisSplitLineColor);
ChartHelper.DrawLine(vh, p2, p3, m_Coordinate.tickness, m_ThemeInfo.axisSplitLineColor);
ChartHelper.DrawLine(vh, p3, p4, m_Coordinate.tickness, m_ThemeInfo.axisSplitLineColor);
ChartHelper.DrawLine(vh, p4, p1, m_Coordinate.tickness, m_ThemeInfo.axisSplitLineColor);
ChartHelper.DrawLine(vh, p1, p2, m_Coordinate.tickness, m_ThemeInfo.dataZoomLineColor);
ChartHelper.DrawLine(vh, p2, p3, m_Coordinate.tickness, m_ThemeInfo.dataZoomLineColor);
ChartHelper.DrawLine(vh, p3, p4, m_Coordinate.tickness, m_ThemeInfo.dataZoomLineColor);
ChartHelper.DrawLine(vh, p4, p1, m_Coordinate.tickness, m_ThemeInfo.dataZoomLineColor);
if (m_DataZoom.showDataShadow && m_Series.Count > 0)
{
Serie serie = m_Series.series[0];
@@ -617,7 +594,7 @@ namespace XCharts
np = new Vector3(pX, m_DataZoom.bottom + dataHig);
if (i > 0)
{
Color color = m_ThemeInfo.axisSplitLineColor;
Color color = m_ThemeInfo.dataZoomLineColor;
ChartHelper.DrawLine(vh, lp, np, m_Coordinate.tickness, color);
Vector3 alp = new Vector3(lp.x, lp.y - m_Coordinate.tickness);
Vector3 anp = new Vector3(np.x, np.y - m_Coordinate.tickness);
@@ -638,9 +615,9 @@ namespace XCharts
p2 = new Vector2(start, m_DataZoom.bottom + m_DataZoom.height);
p3 = new Vector2(end, m_DataZoom.bottom + m_DataZoom.height);
p4 = new Vector2(end, m_DataZoom.bottom);
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.axisSplitLineColor);
ChartHelper.DrawLine(vh, p1, p2, m_Coordinate.tickness, m_ThemeInfo.axisSplitLineColor);
ChartHelper.DrawLine(vh, p3, p4, m_Coordinate.tickness, m_ThemeInfo.axisSplitLineColor);
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.dataZoomSelectedColor);
ChartHelper.DrawLine(vh, p1, p2, m_Coordinate.tickness, m_ThemeInfo.dataZoomSelectedColor);
ChartHelper.DrawLine(vh, p3, p4, m_Coordinate.tickness, m_ThemeInfo.dataZoomSelectedColor);
break;
}
}
@@ -684,7 +661,7 @@ namespace XCharts
private void CheckDataZoom()
{
if(raycastTarget != m_DataZoom.show)
if (raycastTarget != m_DataZoom.show)
{
raycastTarget = m_DataZoom.show;
}
@@ -818,7 +795,7 @@ namespace XCharts
public override void OnEndDrag(PointerEventData eventData)
{
if(m_DataZoomDrag || m_DataZoomStartDrag || m_DataZoomEndDrag)
if (m_DataZoomDrag || m_DataZoomStartDrag || m_DataZoomEndDrag)
{
RefreshChart();
}

View File

@@ -16,11 +16,11 @@ namespace XCharts
{
[SerializeField] private Font m_Font;
[SerializeField] private Color32 m_BackgroundColor;
[SerializeField] private Color32 m_ContrastColor;
[SerializeField] private Color32 m_TextColor;
[SerializeField] private Color32 m_SubTextColor;
[SerializeField] private Color32 m_TitleSubTextColor;
[SerializeField] private Color32 m_LegendTextColor;
[SerializeField] private Color32 m_UnableColor;
[SerializeField] private Color32 m_LegendUnableColor;
[SerializeField] private Color32 m_AxisTextColor;
[SerializeField] private Color32 m_AxisLineColor;
[SerializeField] private Color32 m_AxisSplitLineColor;
[SerializeField] private Color32 m_TooltipBackgroundColor;
@@ -28,15 +28,18 @@ namespace XCharts
[SerializeField] private Color32 m_TooltipTextColor;
[SerializeField] private Color32 m_TooltipLabelColor;
[SerializeField] private Color32 m_TooltipLineColor;
[SerializeField] private Color32 m_DataZoomTextColor;
[SerializeField] private Color32 m_DataZoomLineColor;
[SerializeField] private Color32 m_DataZoomSelectedColor;
[SerializeField] private Color32[] m_ColorPalette;
public Font font { get { return m_Font; } set { m_Font = value; } }
public Color32 backgroundColor { get { return m_BackgroundColor; } set { m_BackgroundColor = value; } }
public Color32 contrastColor { get { return m_ContrastColor; } set { m_ContrastColor = value; } }
public Color32 textColor { get { return m_TextColor; } set { m_TextColor = value; } }
public Color32 subTextColor { get { return m_SubTextColor; } set { m_SubTextColor = value; } }
public Color32 titleSubTextColor { get { return m_TitleSubTextColor; } set { m_TitleSubTextColor = value; } }
public Color32 legendTextColor { get { return m_LegendTextColor; } set { m_LegendTextColor = value; } }
public Color32 unableColor { get { return m_UnableColor; } set { m_UnableColor = value; } }
public Color32 legendUnableColor { get { return m_LegendUnableColor; } set { m_LegendUnableColor = value; } }
public Color32 axisTextColor { get { return m_AxisTextColor; } set { m_AxisTextColor = value; } }
public Color32 axisLineColor { get { return m_AxisLineColor; } set { m_AxisLineColor = value; } }
public Color32 axisSplitLineColor { get { return m_AxisSplitLineColor; } set { m_AxisSplitLineColor = value; } }
public Color32 tooltipBackgroundColor { get { return m_TooltipBackgroundColor; } set { m_TooltipBackgroundColor = value; } }
@@ -44,6 +47,9 @@ namespace XCharts
public Color32 tooltipTextColor { get { return m_TooltipTextColor; } set { m_TooltipTextColor = value; } }
public Color32 tooltipLabelColor { get { return m_TooltipLabelColor; } set { m_TooltipLabelColor = value; } }
public Color32 tooltipLineColor { get { return m_TooltipLineColor; } set { m_TooltipLineColor = value; } }
public Color32 dataZoomTextColor { get { return m_DataZoomTextColor; } set { m_DataZoomTextColor = value; } }
public Color32 dataZoomLineColor { get { return m_DataZoomLineColor; } set { m_DataZoomLineColor = value; } }
public Color32 dataZoomSelectedColor { get { return m_DataZoomSelectedColor; } set { m_DataZoomSelectedColor = value; } }
public Color32[] colorPalette { get { return m_ColorPalette; } set { m_ColorPalette = value; } }
public Color32 GetColor(int index)
@@ -60,17 +66,20 @@ namespace XCharts
{
m_Font = theme.m_Font;
m_BackgroundColor = theme.m_BackgroundColor;
m_ContrastColor = theme.m_ContrastColor;
m_UnableColor = theme.m_UnableColor;
m_LegendUnableColor = theme.m_LegendUnableColor;
m_TextColor = theme.m_TextColor;
m_SubTextColor = theme.m_SubTextColor;
m_TitleSubTextColor = theme.m_TitleSubTextColor;
m_LegendTextColor = theme.m_LegendTextColor;
m_AxisTextColor = theme.m_AxisTextColor;
m_AxisLineColor = theme.m_AxisLineColor;
m_AxisSplitLineColor = theme.m_AxisSplitLineColor;
m_TooltipBackgroundColor = theme.m_TooltipBackgroundColor;
m_TooltipTextColor = theme.m_TooltipTextColor;
m_TooltipLabelColor = theme.m_TooltipLabelColor;
m_TooltipLineColor = theme.m_TooltipLineColor;
m_DataZoomLineColor = theme.m_DataZoomLineColor;
m_DataZoomSelectedColor = theme.m_DataZoomSelectedColor;
m_DataZoomTextColor = theme.m_DataZoomTextColor;
m_ColorPalette = new Color32[theme.m_ColorPalette.Length];
for (int i = 0; i < theme.m_ColorPalette.Length; i++)
{
@@ -86,11 +95,11 @@ namespace XCharts
{
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
m_BackgroundColor = new Color32(255, 255, 255, 255),
m_ContrastColor = GetColor("#514D4D"),
m_UnableColor = GetColor("#cccccc"),
m_LegendUnableColor = GetColor("#cccccc"),
m_TextColor = GetColor("#514D4D"),
m_SubTextColor = GetColor("#514D4D"),
m_TitleSubTextColor = GetColor("#514D4D"),
m_LegendTextColor = GetColor("#eee"),
m_AxisTextColor = GetColor("#514D4D"),
m_AxisLineColor = GetColor("#514D4D"),
m_AxisSplitLineColor = GetColor("#51515120"),
m_TooltipBackgroundColor = GetColor("#515151B5"),
@@ -98,6 +107,9 @@ namespace XCharts
m_TooltipFlagAreaColor = GetColor("#51515120"),
m_TooltipLabelColor = GetColor("#292929FF"),
m_TooltipLineColor = GetColor("#29292964"),
m_DataZoomLineColor = GetColor("#51515120"),
m_DataZoomSelectedColor = GetColor("#51515120"),
m_DataZoomTextColor = GetColor("#514D4D"),
m_ColorPalette = new Color32[]
{
new Color32(194, 53, 49, 255),
@@ -124,11 +136,11 @@ namespace XCharts
{
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
m_BackgroundColor = new Color32(255, 255, 255, 255),
m_ContrastColor = GetColor("#514D4D"),
m_UnableColor = GetColor("#cccccc"),
m_LegendUnableColor = GetColor("#cccccc"),
m_TextColor = GetColor("#514D4D"),
m_SubTextColor = GetColor("#514D4D"),
m_TitleSubTextColor = GetColor("#514D4D"),
m_LegendTextColor = GetColor("#514D4D"),
m_AxisTextColor = GetColor("#514D4D"),
m_AxisLineColor = GetColor("#514D4D"),
m_AxisSplitLineColor = GetColor("#51515120"),
m_TooltipBackgroundColor = GetColor("#515151B5"),
@@ -136,6 +148,9 @@ namespace XCharts
m_TooltipFlagAreaColor = GetColor("#51515120"),
m_TooltipLabelColor = GetColor("#292929FF"),
m_TooltipLineColor = GetColor("#29292964"),
m_DataZoomLineColor = GetColor("#51515120"),
m_DataZoomSelectedColor = GetColor("#51515120"),
m_DataZoomTextColor = GetColor("#514D4D"),
m_ColorPalette = new Color32[]
{
new Color32(55, 162, 218, 255),
@@ -163,12 +178,12 @@ namespace XCharts
return new ThemeInfo()
{
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
m_UnableColor = GetColor("#cccccc"),
m_LegendUnableColor = GetColor("#cccccc"),
m_BackgroundColor = new Color32(34, 34, 34, 255),
m_ContrastColor = GetColor("#eee"),
m_TextColor = GetColor("#eee"),
m_SubTextColor = GetColor("#eee"),
m_TitleSubTextColor = GetColor("#eee"),
m_LegendTextColor = GetColor("#eee"),
m_AxisTextColor = GetColor("#eee"),
m_AxisLineColor = GetColor("#eee"),
m_AxisSplitLineColor = GetColor("#aaa"),
m_TooltipBackgroundColor = GetColor("#515151B5"),
@@ -176,6 +191,9 @@ namespace XCharts
m_TooltipFlagAreaColor = GetColor("#51515120"),
m_TooltipLabelColor = GetColor("#A7A7A7FF"),
m_TooltipLineColor = GetColor("#eee"),
m_DataZoomLineColor = GetColor("#FFFFFF45"),
m_DataZoomSelectedColor = GetColor("#D0D0D03D"),
m_DataZoomTextColor = GetColor("#FFFFFFFF"),
m_ColorPalette = new Color32[]
{
new Color32(221, 107, 102, 255),
@@ -212,17 +230,20 @@ namespace XCharts
public bool Equals(ThemeInfo other)
{
return m_Font == other.m_Font &&
ChartHelper.IsValueEqualsColor(m_UnableColor, other.m_UnableColor) &&
ChartHelper.IsValueEqualsColor(m_LegendUnableColor, other.m_LegendUnableColor) &&
ChartHelper.IsValueEqualsColor(m_BackgroundColor, other.m_BackgroundColor) &&
ChartHelper.IsValueEqualsColor(m_ContrastColor, other.m_ContrastColor) &&
ChartHelper.IsValueEqualsColor(m_TextColor, other.m_TextColor) &&
ChartHelper.IsValueEqualsColor(m_SubTextColor, other.m_SubTextColor) &&
ChartHelper.IsValueEqualsColor(m_TitleSubTextColor, other.m_TitleSubTextColor) &&
ChartHelper.IsValueEqualsColor(m_AxisTextColor, other.m_AxisTextColor) &&
ChartHelper.IsValueEqualsColor(m_AxisLineColor, other.m_AxisLineColor) &&
ChartHelper.IsValueEqualsColor(m_AxisSplitLineColor, other.m_AxisSplitLineColor) &&
ChartHelper.IsValueEqualsColor(m_TooltipBackgroundColor, other.m_TooltipBackgroundColor) &&
ChartHelper.IsValueEqualsColor(m_AxisSplitLineColor, other.m_AxisSplitLineColor) &&
ChartHelper.IsValueEqualsColor(m_TooltipTextColor, other.m_TooltipTextColor) &&
ChartHelper.IsValueEqualsColor(m_TooltipFlagAreaColor, other.m_TooltipFlagAreaColor) &&
ChartHelper.IsValueEqualsColor(m_DataZoomLineColor, other.m_DataZoomLineColor) &&
ChartHelper.IsValueEqualsColor(m_DataZoomSelectedColor, other.m_DataZoomSelectedColor) &&
ChartHelper.IsValueEqualsColor(m_DataZoomTextColor, other.m_DataZoomTextColor) &&
m_ColorPalette.Length == other.m_ColorPalette.Length;
}

View File

@@ -165,7 +165,7 @@ namespace XCharts
var img = GetOrAddComponent<Image>(labelObj);
img.color = Color.black;
Text txt = AddTextObject("Text", labelObj.transform, font, Color.white, TextAnchor.MiddleCenter,
new Vector2(0, 0), new Vector2(1, 1), new Vector2(1,1), sizeDelta, 16);
new Vector2(0, 0), new Vector2(1, 1), new Vector2(1, 1), sizeDelta, 16);
txt.GetComponent<RectTransform>().offsetMin = Vector2.zero;
txt.GetComponent<RectTransform>().offsetMax = Vector2.zero;
txt.text = "Text";
@@ -535,29 +535,25 @@ namespace XCharts
//获取两直线交点
public static Vector3 GetIntersection(Vector3 lineAStart, Vector3 lineAEnd, Vector3 lineBStart, Vector3 lineBEnd)
public static Vector3 GetIntersection(Vector3 lineAStart, Vector3 lineAEnd, Vector3 lineBStart,
Vector3 lineBEnd)
{
float x1 = lineAStart.x, y1 = lineAStart.y;
float x2 = lineAEnd.x, y2 = lineAEnd.y;
float x3 = lineBStart.x, y3 = lineBStart.y;
float x4 = lineBEnd.x, y4 = lineBEnd.y;
//equations of the form x=c (two vertical lines)
if (x1 == x2 && x3 == x4 && x1 == x3)
{
return Vector3.zero;
}
//equations of the form y=c (two horizontal lines)
if (y1 == y2 && y3 == y4 && y1 == y3)
{
return Vector3.zero;
}
//equations of the form x=c (two vertical lines)
if (x1 == x2 && x3 == x4)
{
return Vector3.zero;
}
//equations of the form y=c (two horizontal lines)
if (y1 == y2 && y3 == y4)
{
return Vector3.zero;
@@ -579,14 +575,10 @@ namespace XCharts
}
else
{
//compute slope of line 1 (m1) and c2
float m1 = (y2 - y1) / (x2 - x1);
float c1 = -m1 * x1 + y1;
//compute slope of line 2 (m2) and c2
float m2 = (y4 - y3) / (x4 - x3);
float c2 = -m2 * x3 + y3;
//solving equations (3) & (4) => x = (c1-c2)/(m2-m1)
//plugging x value in equation (4) => y = c2 + m2 * x
x = (c1 - c2) / (m2 - m1);
y = c2 + m2 * x;
}