重构VisualMap和DataZoom

This commit is contained in:
monitor1394
2021-05-13 09:38:32 +08:00
parent a30c036245
commit 718e600279
12 changed files with 831 additions and 655 deletions

View File

@@ -70,6 +70,18 @@ namespace XCharts
/// </summary>
public Settings settings { get { return m_Settings; } }
/// <summary>
/// dataZoom component.
/// 区域缩放组件。
/// </summary>
public DataZoom dataZoom { get { return m_DataZooms.Count > 0 ? m_DataZooms[0] : null; } }
public List<DataZoom> dataZooms { get { return m_DataZooms; } }
/// <summary>
/// visualMap component.
/// 视觉映射组件。
/// </summary>
public VisualMap visualMap { get { return m_VisualMaps.Count > 0 ? m_VisualMaps[0] : null; } }
public List<VisualMap> visualMaps { get { return m_VisualMaps; } }
/// <summary>
/// The x of chart.
/// 图表的X
/// </summary>

View File

@@ -163,5 +163,16 @@ namespace XCharts
ChartHelper.DestroyAllChildren(transform);
//SetAllComponentDirty();
}
public bool ScreenPointToChartPoint(Vector2 screenPoint, out Vector2 chartPoint)
{
var cam = canvas.renderMode == RenderMode.ScreenSpaceOverlay ? null : canvas.worldCamera;
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform,
screenPoint, cam, out chartPoint))
{
return false;
}
return true;
}
}
}

View File

@@ -33,16 +33,7 @@ namespace XCharts
/// 两个y轴。
/// </summary>
public List<YAxis> yAxes { get { return m_YAxes; } }
/// <summary>
/// dataZoom component.
/// 区域缩放组件。
/// </summary>
public DataZoom dataZoom { get { return m_DataZooms.Count > 0 ? m_DataZooms[0] : null; } }
/// <summary>
/// visualMap component.
/// 视觉映射组件。
/// </summary>
public VisualMap visualMap { get { return m_VisualMaps.Count > 0 ? m_VisualMaps[0] : null; } }
/// <summary>
/// X轴
/// </summary>
@@ -204,7 +195,13 @@ namespace XCharts
/// </summary>
public void RefreshDataZoom()
{
RefreshDataZoomLabel();
foreach (var handler in m_ComponentHandlers)
{
if (handler is DataZoomHandler)
{
(handler as DataZoomHandler).RefreshDataZoomLabel();
}
}
}
/// <summary>