mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 13:28:47 +00:00
[feature][pie] support onPointerEnterPie
This commit is contained in:
@@ -58,6 +58,7 @@
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2022.09.02) 增加`onPointerEnterPie`回调支持
|
||||||
* (2022.09.02) 优化`HeatmapChart`
|
* (2022.09.02) 优化`HeatmapChart`
|
||||||
* (2022.08.30) 优化`RadarChart`
|
* (2022.08.30) 优化`RadarChart`
|
||||||
* (2022.08.30) 修复`DataZoom`在某些情况下计算范围不准确的问题 (#221)
|
* (2022.08.30) 修复`DataZoom`在某些情况下计算范围不准确的问题 (#221)
|
||||||
|
|||||||
@@ -96,11 +96,17 @@ namespace XCharts.Runtime
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public CustomDrawGaugePointerFunction customDrawGaugePointerFunction { set { m_CustomDrawGaugePointerFunction = value; } get { return m_CustomDrawGaugePointerFunction; } }
|
public CustomDrawGaugePointerFunction customDrawGaugePointerFunction { set { m_CustomDrawGaugePointerFunction = value; } get { return m_CustomDrawGaugePointerFunction; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the callback function of click pie area.
|
/// the callback function of pointer click pie area.
|
||||||
/// |点击饼图区域回调。参数:PointerEventData,SerieIndex,SerieDataIndex
|
/// |点击饼图区域回调。参数:PointerEventData,SerieIndex,SerieDataIndex
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<PointerEventData, int, int> onPointerClickPie { set { m_OnPointerClickPie = value; m_ForceOpenRaycastTarget = true; } get { return m_OnPointerClickPie; } }
|
public Action<PointerEventData, int, int> onPointerClickPie { set { m_OnPointerClickPie = value; m_ForceOpenRaycastTarget = true; } get { return m_OnPointerClickPie; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// the callback function of pointer enter pie area.
|
||||||
|
/// |鼠标进入和离开饼图区域回调,SerieDataIndex为-1时表示离开。参数:PointerEventData,SerieIndex,SerieDataIndex
|
||||||
|
/// </summary>
|
||||||
|
[Since("v3.3.0")]
|
||||||
|
public Action<int, int> onPointerEnterPie { set { m_OnPointerEnterPie = value; m_ForceOpenRaycastTarget = true; } get { return m_OnPointerEnterPie; } }
|
||||||
|
/// <summary>
|
||||||
/// the callback function of click bar.
|
/// the callback function of click bar.
|
||||||
/// |点击柱形图柱条回调。参数:eventData, dataIndex
|
/// |点击柱形图柱条回调。参数:eventData, dataIndex
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ namespace XCharts.Runtime
|
|||||||
protected Action<VertexHelper, Serie> m_OnDrawSerieBefore;
|
protected Action<VertexHelper, Serie> m_OnDrawSerieBefore;
|
||||||
protected Action<VertexHelper, Serie> m_OnDrawSerieAfter;
|
protected Action<VertexHelper, Serie> m_OnDrawSerieAfter;
|
||||||
protected Action<PointerEventData, int, int> m_OnPointerClickPie;
|
protected Action<PointerEventData, int, int> m_OnPointerClickPie;
|
||||||
|
protected Action<int, int> m_OnPointerEnterPie;
|
||||||
protected Action<PointerEventData, int> m_OnPointerClickBar;
|
protected Action<PointerEventData, int> m_OnPointerClickBar;
|
||||||
protected Action<Axis, double> m_OnAxisPointerValueChanged;
|
protected Action<Axis, double> m_OnAxisPointerValueChanged;
|
||||||
protected Action<Legend, int, string, bool> m_OnLegendClick;
|
protected Action<Legend, int, string, bool> m_OnLegendClick;
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ namespace XCharts.Runtime
|
|||||||
serieData.context.highlight = false;
|
serieData.context.highlight = false;
|
||||||
serieData.interact.SetValueAndColor(ref needInteract, serieData.context.outsideRadius, color, toColor);
|
serieData.interact.SetValueAndColor(ref needInteract, serieData.context.outsideRadius, color, toColor);
|
||||||
}
|
}
|
||||||
|
if (chart.onPointerEnterPie != null)
|
||||||
|
{
|
||||||
|
chart.onPointerEnterPie(serie.index, serie.context.pointerItemDataIndex);
|
||||||
|
}
|
||||||
if (needInteract)
|
if (needInteract)
|
||||||
{
|
{
|
||||||
chart.RefreshPainter(serie);
|
chart.RefreshPainter(serie);
|
||||||
@@ -131,8 +135,9 @@ namespace XCharts.Runtime
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_LastCheckContextFlag = needCheck;
|
m_LastCheckContextFlag = needCheck;
|
||||||
serie.context.pointerItemDataIndex = -1;
|
var lastPointerItemDataIndex = serie.context.pointerItemDataIndex;
|
||||||
var dataIndex = GetPiePosIndex(serie, chart.pointerPos);
|
var dataIndex = GetPiePosIndex(serie, chart.pointerPos);
|
||||||
|
serie.context.pointerItemDataIndex = -1;
|
||||||
for (int i = 0; i < serie.dataCount; i++)
|
for (int i = 0; i < serie.dataCount; i++)
|
||||||
{
|
{
|
||||||
var serieData = serie.data[i];
|
var serieData = serie.data[i];
|
||||||
@@ -154,6 +159,14 @@ namespace XCharts.Runtime
|
|||||||
serieData.interact.SetValueAndColor(ref needInteract, serieData.context.outsideRadius, color, toColor);
|
serieData.interact.SetValueAndColor(ref needInteract, serieData.context.outsideRadius, color, toColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (lastPointerItemDataIndex != serie.context.pointerItemDataIndex)
|
||||||
|
{
|
||||||
|
needInteract = true;
|
||||||
|
if (chart.onPointerEnterPie != null)
|
||||||
|
{
|
||||||
|
chart.onPointerEnterPie(serie.index, serie.context.pointerItemDataIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (needInteract)
|
if (needInteract)
|
||||||
{
|
{
|
||||||
chart.RefreshPainter(serie);
|
chart.RefreshPainter(serie);
|
||||||
|
|||||||
Reference in New Issue
Block a user