mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 16:00:24 +00:00
3.0 - polar chart
This commit is contained in:
@@ -12,12 +12,11 @@ namespace XCharts
|
||||
[ComponentHandler(typeof(AngleAxisHandler), true)]
|
||||
public class AngleAxis : Axis
|
||||
{
|
||||
[SerializeField] private float m_StartAngle = 90;
|
||||
[SerializeField] private float m_StartAngle = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Starting angle of axis. 90 degrees by default, standing for top position of center.
|
||||
/// 0 degree stands for right position of center.
|
||||
/// 起始刻度的角度,默认为 90 度,即圆心的正上方。0 度为圆心的正右方。
|
||||
/// Starting angle of axis. 0 degrees by default, standing for right position of center.
|
||||
/// 起始刻度的角度,默认为 0 度,即圆心的正右方。
|
||||
/// </summary>
|
||||
public float startAngle
|
||||
{
|
||||
@@ -25,12 +24,17 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetStruct(ref m_StartAngle, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
public float GetValueAngle(float value)
|
||||
{
|
||||
return (value + context.startAngle + 360) % 360;
|
||||
}
|
||||
|
||||
public override void SetDefaultValue()
|
||||
{
|
||||
m_Show = true;
|
||||
m_Type = AxisType.Value;
|
||||
m_SplitNumber = 12;
|
||||
m_StartAngle = 90;
|
||||
m_StartAngle = 0;
|
||||
m_BoundaryGap = false;
|
||||
m_Data = new List<string>(12);
|
||||
splitLine.show = true;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
@@ -7,7 +5,7 @@ using XUGL;
|
||||
namespace XCharts
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class AngleAxisHandler : MainComponentHandler<AngleAxis>
|
||||
internal sealed class AngleAxisHandler : AxisHandler<AngleAxis>
|
||||
{
|
||||
public override void InitComponent()
|
||||
{
|
||||
@@ -16,8 +14,9 @@ namespace XCharts
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
component.startAngle = 90 - component.startAngle;
|
||||
component.context.startAngle = 90 - component.startAngle;
|
||||
UpdateAxisMinMaxValue(component);
|
||||
UpdatePointerValue(component);
|
||||
}
|
||||
|
||||
public override void DrawBase(VertexHelper vh)
|
||||
@@ -38,6 +37,8 @@ namespace XCharts
|
||||
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
|
||||
axis.context.offset = 0;
|
||||
axis.context.lastCheckInverse = axis.inverse;
|
||||
UpdateAxisTickValueList(axis);
|
||||
|
||||
if (updateChart)
|
||||
{
|
||||
UpdateAxisLabelText(axis);
|
||||
@@ -49,7 +50,10 @@ namespace XCharts
|
||||
internal void UpdateAxisLabelText(AngleAxis axis)
|
||||
{
|
||||
var runtimeWidth = 360;
|
||||
axis.UpdateLabelText(runtimeWidth, null, false);
|
||||
if (axis.context.labelObjectList.Count <= 0)
|
||||
InitAngleAxis(axis);
|
||||
else
|
||||
axis.UpdateLabelText(runtimeWidth, null, false);
|
||||
}
|
||||
|
||||
private void InitAngleAxis(AngleAxis axis)
|
||||
@@ -59,8 +63,9 @@ namespace XCharts
|
||||
PolarHelper.UpdatePolarCenter(polar, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
var radius = polar.context.radius;
|
||||
axis.context.labelObjectList.Clear();
|
||||
axis.context.startAngle = 90 - axis.startAngle;
|
||||
|
||||
string objName = "axis_angle" + axis.index;
|
||||
string objName = component.GetType().Name + axis.index;
|
||||
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||
axisObj.transform.localPosition = Vector3.zero;
|
||||
@@ -68,16 +73,16 @@ namespace XCharts
|
||||
axisObj.hideFlags = chart.chartHideFlags;
|
||||
ChartHelper.HideAllObject(axisObj);
|
||||
var splitNumber = AxisHelper.GetSplitNumber(axis, radius, null);
|
||||
var totalAngle = axis.startAngle;
|
||||
var totalAngle = axis.context.startAngle;
|
||||
var total = 360;
|
||||
var cenPos = polar.context.center;
|
||||
var txtHig = axis.axisLabel.textStyle.GetFontSize(chart.theme.axis) + 2;
|
||||
var margin = axis.axisLabel.margin;
|
||||
var margin = axis.axisLabel.margin + axis.axisTick.GetLength(chart.theme.axis.tickLength);
|
||||
var isCategory = axis.IsCategory();
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
|
||||
for (int i = 0; i < splitNumber; i++)
|
||||
{
|
||||
float scaleAngle = AxisHelper.GetScaleWidth(axis, total, i, null);
|
||||
float scaleAngle = AxisHelper.GetScaleWidth(axis, total, i + 1, null);
|
||||
bool inside = axis.axisLabel.inside;
|
||||
var labelName = AxisHelper.GetLabelName(axis, total, i, axis.context.minValue, axis.context.maxValue,
|
||||
null, isPercentStack);
|
||||
@@ -102,24 +107,31 @@ namespace XCharts
|
||||
var cenPos = polar.context.center;
|
||||
var total = 360;
|
||||
var size = AxisHelper.GetScaleNumber(angleAxis, total, null);
|
||||
var currAngle = angleAxis.startAngle;
|
||||
var currAngle = angleAxis.context.startAngle;
|
||||
var tickWidth = angleAxis.axisTick.GetWidth(chart.theme.axis.tickWidth);
|
||||
var tickLength = angleAxis.axisTick.GetLength(chart.theme.axis.tickLength);
|
||||
for (int i = 0; i < size; i++)
|
||||
var tickColor = angleAxis.axisTick.GetColor(chart.theme.axis.lineColor);
|
||||
var lineColor = angleAxis.axisLine.GetColor(chart.theme.axis.lineColor);
|
||||
var splitLineColor = angleAxis.splitLine.GetColor(chart.theme.axis.splitLineColor);
|
||||
for (int i = 1; i < size; i++)
|
||||
{
|
||||
var scaleWidth = AxisHelper.GetScaleWidth(angleAxis, total, i);
|
||||
var pos = ChartHelper.GetPos(cenPos, radius, currAngle, true);
|
||||
if (angleAxis.show && angleAxis.splitLine.show)
|
||||
{
|
||||
var splitLineColor = angleAxis.splitLine.GetColor(chart.theme.axis.splitLineColor);
|
||||
var lineWidth = angleAxis.splitLine.GetWidth(chart.theme.axis.splitLineWidth);
|
||||
UGL.DrawLine(vh, cenPos, pos, lineWidth, splitLineColor);
|
||||
}
|
||||
if (angleAxis.show && angleAxis.axisTick.show)
|
||||
{
|
||||
var tickY = radius + tickLength;
|
||||
var tickPos = ChartHelper.GetPos(cenPos, tickY, currAngle, true);
|
||||
UGL.DrawLine(vh, pos, tickPos, tickWidth, chart.theme.axis.lineColor);
|
||||
if ((i == 1 && angleAxis.axisTick.showStartTick)
|
||||
|| (i == size - 1 && angleAxis.axisTick.showEndTick)
|
||||
|| (i > 1 && i < size - 1))
|
||||
{
|
||||
var tickY = radius + tickLength;
|
||||
var tickPos = ChartHelper.GetPos(cenPos, tickY, currAngle, true);
|
||||
UGL.DrawLine(vh, pos, tickPos, tickWidth, tickColor);
|
||||
}
|
||||
}
|
||||
currAngle += scaleWidth;
|
||||
}
|
||||
@@ -127,8 +139,26 @@ namespace XCharts
|
||||
{
|
||||
var lineWidth = angleAxis.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
||||
var outsideRaidus = radius + lineWidth * 2;
|
||||
UGL.DrawDoughnut(vh, cenPos, radius, outsideRaidus, chart.theme.axis.lineColor, Color.clear);
|
||||
UGL.DrawDoughnut(vh, cenPos, radius, outsideRaidus, lineColor, Color.clear);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdatePointerValue(Axis axis)
|
||||
{
|
||||
var polar = chart.GetChartComponent<PolarCoord>(axis.polarIndex);
|
||||
if (polar == null)
|
||||
return;
|
||||
|
||||
if (!polar.context.isPointerEnter)
|
||||
{
|
||||
axis.context.pointerValue = double.PositiveInfinity;
|
||||
return;
|
||||
}
|
||||
|
||||
var dir = (chart.pointerPos - new Vector2(polar.context.center.x, polar.context.center.y)).normalized;
|
||||
var angle = ChartHelper.GetAngle360(Vector2.up, dir);
|
||||
axis.context.pointerValue = (angle - component.context.startAngle + 360) % 360;
|
||||
axis.context.pointerLabelPosition = polar.context.center + new Vector3(dir.x, dir.y) * (polar.context.radius + 25);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,9 @@ namespace XCharts
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
protected virtual Orient orient { get; }
|
||||
protected virtual Orient orient { get; set; }
|
||||
|
||||
protected void UpdatePointerValue(Axis axis)
|
||||
protected virtual void UpdatePointerValue(Axis axis)
|
||||
{
|
||||
var grid = chart.GetChartComponent<GridCoord>(axis.gridIndex);
|
||||
if (grid == null)
|
||||
@@ -256,6 +256,7 @@ namespace XCharts
|
||||
|
||||
private static double GetTick(double max)
|
||||
{
|
||||
if (max <= 1) return max / 5;
|
||||
var bigger = Math.Ceiling(Math.Abs(max));
|
||||
int n = 1;
|
||||
while (bigger / (Mathf.Pow(10, n)) > 10)
|
||||
|
||||
@@ -7,7 +7,7 @@ using XUGL;
|
||||
namespace XCharts
|
||||
{
|
||||
[UnityEngine.Scripting.Preserve]
|
||||
internal sealed class RadiusAxisHandler : MainComponentHandler<RadiusAxis>
|
||||
internal sealed class RadiusAxisHandler : AxisHandler<RadiusAxis>
|
||||
{
|
||||
public override void InitComponent()
|
||||
{
|
||||
@@ -17,6 +17,7 @@ namespace XCharts
|
||||
public override void Update()
|
||||
{
|
||||
UpdateAxisMinMaxValue(component);
|
||||
UpdatePointerValue(component);
|
||||
}
|
||||
|
||||
public override void DrawBase(VertexHelper vh)
|
||||
@@ -24,6 +25,28 @@ namespace XCharts
|
||||
DrawRadiusAxis(vh, component);
|
||||
}
|
||||
|
||||
protected override void UpdatePointerValue(Axis axis)
|
||||
{
|
||||
var polar = chart.GetChartComponent<PolarCoord>(axis.polarIndex);
|
||||
if (polar == null)
|
||||
return;
|
||||
|
||||
if (!polar.context.isPointerEnter)
|
||||
{
|
||||
axis.context.pointerValue = double.PositiveInfinity;
|
||||
return;
|
||||
}
|
||||
var angleAxis = ComponentHelper.GetAngleAxis(chart.components, polar.index);
|
||||
if (angleAxis == null)
|
||||
return;
|
||||
|
||||
var startAngle = angleAxis.context.startAngle;
|
||||
|
||||
var dist = Vector3.Distance(chart.pointerPos, polar.context.center);
|
||||
axis.context.pointerValue = axis.context.minValue + (dist / polar.context.radius) * axis.context.minMaxRange;
|
||||
axis.context.pointerLabelPosition = GetLabelPosition(polar, axis, angleAxis.context.startAngle, dist);
|
||||
}
|
||||
|
||||
private void UpdateAxisMinMaxValue(RadiusAxis axis, bool updateChart = true)
|
||||
{
|
||||
if (axis.IsCategory() || !axis.show) return;
|
||||
@@ -37,6 +60,7 @@ namespace XCharts
|
||||
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
|
||||
axis.context.offset = 0;
|
||||
axis.context.lastCheckInverse = axis.inverse;
|
||||
UpdateAxisTickValueList(axis);
|
||||
|
||||
if (updateChart)
|
||||
{
|
||||
@@ -49,7 +73,10 @@ namespace XCharts
|
||||
internal void UpdateAxisLabelText(RadiusAxis axis)
|
||||
{
|
||||
var polar = chart.GetChartComponent<PolarCoord>(axis.polarIndex);
|
||||
axis.UpdateLabelText(polar.context.radius, null, false);
|
||||
if (axis.context.labelObjectList.Count <= 0)
|
||||
InitRadiusAxis(axis);
|
||||
else
|
||||
axis.UpdateLabelText(polar.context.radius, null, false);
|
||||
}
|
||||
|
||||
private void InitRadiusAxis(RadiusAxis axis)
|
||||
@@ -65,7 +92,7 @@ namespace XCharts
|
||||
PolarHelper.UpdatePolarCenter(polar, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
axis.context.labelObjectList.Clear();
|
||||
var radius = polar.context.radius;
|
||||
var objName = "axis_radius" + axis.index;
|
||||
var objName = component.GetType().Name + axis.index;
|
||||
var axisObj = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||
axisObj.transform.localPosition = Vector3.zero;
|
||||
@@ -73,18 +100,12 @@ namespace XCharts
|
||||
axisObj.hideFlags = chart.chartHideFlags;
|
||||
ChartHelper.HideAllObject(axisObj);
|
||||
var textStyle = axis.axisLabel.textStyle;
|
||||
var splitNumber = AxisHelper.GetSplitNumber(axis, radius, null);
|
||||
var splitNumber = AxisHelper.GetScaleNumber(axis, radius, null);
|
||||
var totalWidth = 0f;
|
||||
var startAngle = angleAxis.startAngle;
|
||||
var cenPos = polar.context.center;
|
||||
var txtHig = textStyle.GetFontSize(chart.theme.axis) + 2;
|
||||
var dire = ChartHelper.GetDire(startAngle, true).normalized;
|
||||
var tickWidth = axis.axisTick.GetLength(chart.theme.axis.tickWidth);
|
||||
var tickVector = ChartHelper.GetVertialDire(dire)
|
||||
* (tickWidth + axis.axisLabel.margin);
|
||||
for (int i = 0; i <= splitNumber; i++)
|
||||
for (int i = 0; i < splitNumber; i++)
|
||||
{
|
||||
var labelWidth = AxisHelper.GetScaleWidth(axis, radius, i, null);
|
||||
var labelWidth = AxisHelper.GetScaleWidth(axis, radius, i + 1, null);
|
||||
var inside = axis.axisLabel.inside;
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series);
|
||||
var labelName = AxisHelper.GetLabelName(axis, radius, i, axis.context.minValue, axis.context.maxValue,
|
||||
@@ -98,8 +119,9 @@ namespace XCharts
|
||||
|
||||
label.label.SetAlignment(textStyle.GetAlignment(TextAnchor.MiddleCenter));
|
||||
label.SetText(labelName);
|
||||
label.SetPosition(ChartHelper.GetPos(cenPos, totalWidth, startAngle, true) + tickVector);
|
||||
label.SetPosition(GetLabelPosition(polar, axis, angleAxis.context.startAngle, totalWidth));
|
||||
label.SetActive(true);
|
||||
label.SetLabelActive(true);
|
||||
|
||||
axis.context.labelObjectList.Add(label);
|
||||
|
||||
@@ -107,6 +129,16 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 GetLabelPosition(PolarCoord polar, Axis axis, float startAngle, float totalWidth)
|
||||
{
|
||||
var cenPos = polar.context.center;
|
||||
var dire = ChartHelper.GetDire(startAngle, true).normalized;
|
||||
var tickLength = axis.axisTick.GetLength(chart.theme.axis.tickLength);
|
||||
var tickVector = ChartHelper.GetVertialDire(dire)
|
||||
* (tickLength + axis.axisLabel.margin);
|
||||
return ChartHelper.GetPos(cenPos, totalWidth, startAngle, true) + tickVector;
|
||||
}
|
||||
|
||||
private void DrawRadiusAxis(VertexHelper vh, RadiusAxis radiusAxis)
|
||||
{
|
||||
var polar = chart.GetChartComponent<PolarCoord>(radiusAxis.polarIndex);
|
||||
@@ -117,19 +149,19 @@ namespace XCharts
|
||||
if (angleAxis == null)
|
||||
return;
|
||||
|
||||
var startAngle = angleAxis.startAngle;
|
||||
var startAngle = angleAxis.context.startAngle;
|
||||
var radius = polar.context.radius;
|
||||
var cenPos = polar.context.center;
|
||||
var size = AxisHelper.GetScaleNumber(radiusAxis, radius, null);
|
||||
var totalWidth = 0f;
|
||||
var dire = ChartHelper.GetDire(startAngle, true).normalized;
|
||||
var tickWidth = radiusAxis.axisTick.GetLength(chart.theme.axis.tickWidth);
|
||||
var tickWidth = radiusAxis.axisTick.GetWidth(chart.theme.axis.tickWidth);
|
||||
var tickLength = radiusAxis.axisTick.GetLength(chart.theme.axis.tickLength);
|
||||
var tickVetor = ChartHelper.GetVertialDire(dire) * tickLength;
|
||||
for (int i = 0; i < size - 1; i++)
|
||||
for (int i = 0; i <= size; i++)
|
||||
{
|
||||
var scaleWidth = AxisHelper.GetScaleWidth(radiusAxis, radius, i);
|
||||
var pos = ChartHelper.GetPos(cenPos, totalWidth, startAngle, true);
|
||||
var pos = ChartHelper.GetPos(cenPos, totalWidth + tickWidth, startAngle, true);
|
||||
if (radiusAxis.show && radiusAxis.splitLine.show)
|
||||
{
|
||||
var outsideRaidus = totalWidth + radiusAxis.splitLine.GetWidth(chart.theme.axis.splitLineWidth) * 2;
|
||||
@@ -138,7 +170,12 @@ namespace XCharts
|
||||
}
|
||||
if (radiusAxis.show && radiusAxis.axisTick.show)
|
||||
{
|
||||
UGL.DrawLine(vh, pos, pos + tickVetor, tickWidth, chart.theme.axis.lineColor);
|
||||
if ((i == 0 && radiusAxis.axisTick.showStartTick)
|
||||
|| (i == size && radiusAxis.axisTick.showEndTick)
|
||||
|| (i > 0 && i < size))
|
||||
{
|
||||
UGL.DrawLine(vh, pos, pos + tickVetor, tickWidth, chart.theme.axis.lineColor);
|
||||
}
|
||||
}
|
||||
totalWidth += scaleWidth;
|
||||
}
|
||||
|
||||
@@ -355,10 +355,6 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public List<int> runtimeDataIndex { get { return m_RuntimeDateIndex; } internal set { m_RuntimeDateIndex = value; } }
|
||||
private List<int> m_RuntimeDateIndex = new List<int>() { -1, -1 };
|
||||
/// <summary>
|
||||
/// 当前指示的角度。
|
||||
/// </summary>
|
||||
public float runtimeAngle { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Keep Tooltiop displayed at the top.
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace XCharts
|
||||
public Vector2 pointer;
|
||||
public float width;
|
||||
public float height;
|
||||
public float angle;
|
||||
public TooltipData data = new TooltipData();
|
||||
}
|
||||
}
|
||||
@@ -98,6 +98,7 @@ namespace XCharts
|
||||
if (SetSerieTooltip(tooltip, serie))
|
||||
{
|
||||
showTooltip = true;
|
||||
chart.RefreshTopPainter();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +113,7 @@ namespace XCharts
|
||||
ListPool<Serie>.Release(containerSeries);
|
||||
if (!showTooltip)
|
||||
{
|
||||
if (tooltip.type == Tooltip.Type.Corss && (m_PointerContainer == null || m_PointerContainer.IsPointerEnter()))
|
||||
if (tooltip.type == Tooltip.Type.Corss && m_PointerContainer != null && m_PointerContainer.IsPointerEnter())
|
||||
{
|
||||
tooltip.SetActive(true);
|
||||
tooltip.SetContentActive(false);
|
||||
@@ -149,15 +150,24 @@ namespace XCharts
|
||||
if (axis.gridIndex == grid.index)
|
||||
{
|
||||
var label = GetIndicatorLabel(labelCount++);
|
||||
if (label == null) continue;
|
||||
label.SetActive(true);
|
||||
label.SetPosition(axis.context.pointerLabelPosition);
|
||||
if (axis.IsCategory())
|
||||
label.SetText(axis.GetData((int)axis.context.pointerValue));
|
||||
else
|
||||
label.SetText(axis.context.pointerValue.ToString("f2"));
|
||||
var textColor = axis.axisLabel.textStyle.GetColor(chart.theme.axis.textColor);
|
||||
label.labelBackground.color = textColor;
|
||||
SetTooltipIndicatorLabel(axis, label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_PointerContainer is PolarCoord)
|
||||
{
|
||||
var polar = m_PointerContainer as PolarCoord;
|
||||
ChartHelper.HideAllObject(m_LabelRoot);
|
||||
foreach (var component in chart.components)
|
||||
{
|
||||
if (component is AngleAxis || component is RadiusAxis)
|
||||
{
|
||||
var axis = component as Axis;
|
||||
if (axis.polarIndex == polar.index)
|
||||
{
|
||||
var label = GetIndicatorLabel(labelCount++);
|
||||
SetTooltipIndicatorLabel(axis, label);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,6 +176,21 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private void SetTooltipIndicatorLabel(Axis axis, ChartLabel label)
|
||||
{
|
||||
if (label == null) return;
|
||||
label.SetActive(true);
|
||||
label.SetLabelActive(true);
|
||||
label.SetPosition(axis.context.pointerLabelPosition);
|
||||
if (axis.IsCategory())
|
||||
label.SetText(axis.GetData((int)axis.context.pointerValue));
|
||||
else
|
||||
label.SetText(axis.context.pointerValue.ToString("f2"));
|
||||
var textColor = axis.axisLabel.textStyle.GetColor(chart.theme.axis.textColor);
|
||||
label.labelBackground.color = textColor;
|
||||
label.SetTextColor(Color.white);
|
||||
}
|
||||
|
||||
private ISerieContainer GetPointerContainerAndSeries(Tooltip tooltip, List<Serie> list)
|
||||
{
|
||||
list.Clear();
|
||||
@@ -191,6 +216,11 @@ namespace XCharts
|
||||
serie.context.pointerEnter = true;
|
||||
UpdateAxisPointerDataIndex(serie, xAxis, yAxis, container as GridCoord);
|
||||
}
|
||||
else if (container is PolarCoord)
|
||||
{
|
||||
var m_AngleAxis = ComponentHelper.GetAngleAxis(chart.components, container.index);
|
||||
tooltip.context.angle = (float)m_AngleAxis.context.pointerValue;
|
||||
}
|
||||
list.Add(serie);
|
||||
}
|
||||
else if (serie.context.pointerEnter)
|
||||
@@ -351,14 +381,15 @@ namespace XCharts
|
||||
else
|
||||
tooltip.context.data.title = category;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < series.Count; i++)
|
||||
{
|
||||
var serie = series[i];
|
||||
serie.context.isTriggerByAxis = isTriggerByAxis;
|
||||
if (isTriggerByAxis && dataIndex >= 0)
|
||||
serie.context.pointerItemDataIndex = dataIndex;
|
||||
|
||||
serie.handler.UpdateTooltipSerieParams(dataIndex, showCategory, category,
|
||||
tooltip.marker, tooltip.itemFormatter, tooltip.numericFormatter,
|
||||
ref tooltip.context.data.param,
|
||||
@@ -447,7 +478,22 @@ namespace XCharts
|
||||
Vector2 sp = new Vector2(pX, grid.context.y);
|
||||
Vector2 ep = new Vector2(pX, grid.context.y + grid.context.height);
|
||||
var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme);
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
|
||||
if (xAxis.IsCategory())
|
||||
{
|
||||
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
||||
pX = (float)(grid.context.x + splitWidth * xAxis.context.pointerValue -
|
||||
(xAxis.boundaryGap ? 0 : splitWidth / 2));
|
||||
float pY = grid.context.y + grid.context.height;
|
||||
Vector3 p1 = new Vector3(pX, grid.context.y);
|
||||
Vector3 p2 = new Vector3(pX, pY);
|
||||
Vector3 p3 = new Vector3(pX + tooltipSplitWid, pY);
|
||||
Vector3 p4 = new Vector3(pX + tooltipSplitWid, grid.context.y);
|
||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, chart.theme.tooltip.areaColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
|
||||
}
|
||||
if (tooltip.type == Tooltip.Type.Corss)
|
||||
{
|
||||
sp = new Vector2(grid.context.x, chart.pointerPos.y);
|
||||
@@ -496,7 +542,22 @@ namespace XCharts
|
||||
Vector2 sp = new Vector2(grid.context.x, pY);
|
||||
Vector2 ep = new Vector2(grid.context.x + grid.context.width, pY);
|
||||
var lineColor = TooltipHelper.GetLineColor(tooltip, chart.theme);
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
|
||||
if (yAxis.IsCategory())
|
||||
{
|
||||
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
||||
float pX = grid.context.x + grid.context.width;
|
||||
pY = (float)(grid.context.y + splitWidth * yAxis.context.pointerValue -
|
||||
(yAxis.boundaryGap ? 0 : splitWidth / 2));
|
||||
Vector3 p1 = new Vector3(grid.context.x, pY);
|
||||
Vector3 p2 = new Vector3(grid.context.x, pY + tooltipSplitWid);
|
||||
Vector3 p3 = new Vector3(pX, pY + tooltipSplitWid);
|
||||
Vector3 p4 = new Vector3(pX, pY);
|
||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, chart.theme.tooltip.areaColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, sp, ep, lineColor);
|
||||
}
|
||||
if (tooltip.type == Tooltip.Type.Corss)
|
||||
{
|
||||
sp = new Vector2(chart.pointerPos.x, grid.context.y);
|
||||
@@ -525,7 +586,7 @@ namespace XCharts
|
||||
|
||||
private void DrawPolarIndicator(VertexHelper vh, Tooltip tooltip, PolarCoord m_Polar)
|
||||
{
|
||||
if (tooltip.runtimeAngle < 0) return;
|
||||
if (tooltip.context.angle < 0) return;
|
||||
var theme = chart.theme;
|
||||
var m_AngleAxis = ComponentHelper.GetAngleAxis(chart.components, m_Polar.index);
|
||||
var lineColor = TooltipHelper.GetLineColor(tooltip, theme);
|
||||
@@ -534,7 +595,8 @@ namespace XCharts
|
||||
var cenPos = m_Polar.context.center;
|
||||
var radius = m_Polar.context.radius;
|
||||
var sp = m_Polar.context.center;
|
||||
var tooltipAngle = tooltip.runtimeAngle + m_AngleAxis.startAngle;
|
||||
var tooltipAngle = m_AngleAxis.GetValueAngle(tooltip.context.angle);
|
||||
|
||||
var ep = ChartHelper.GetPos(sp, radius, tooltipAngle, true);
|
||||
|
||||
switch (tooltip.type)
|
||||
|
||||
Reference in New Issue
Block a user