mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 22:10:11 +00:00
3.0
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
@@ -35,7 +34,7 @@ namespace XCharts.Runtime
|
||||
private void InitTooltip(Tooltip tooltip)
|
||||
{
|
||||
tooltip.painter = chart.m_PainterTop;
|
||||
tooltip.refreshComponent = delegate ()
|
||||
tooltip.refreshComponent = delegate()
|
||||
{
|
||||
var objName = ChartCached.GetComponentObjectName(tooltip);
|
||||
tooltip.gameObject = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
||||
@@ -186,7 +185,7 @@ namespace XCharts.Runtime
|
||||
label.SetTextActive(true);
|
||||
label.SetPosition(axis.context.pointerLabelPosition);
|
||||
if (axis.IsCategory())
|
||||
label.SetText(axis.GetData((int)axis.context.pointerValue));
|
||||
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);
|
||||
@@ -210,8 +209,8 @@ namespace XCharts.Runtime
|
||||
{
|
||||
foreach (var serie in chart.series)
|
||||
{
|
||||
if (serie is INeedSerieContainer
|
||||
&& (serie as INeedSerieContainer).containterInstanceId == component.instanceId)
|
||||
if (serie is INeedSerieContainer &&
|
||||
(serie as INeedSerieContainer).containterInstanceId == component.instanceId)
|
||||
{
|
||||
var isTriggerAxis = tooltip.IsTriggerAxis();
|
||||
if (container is GridCoord)
|
||||
@@ -224,7 +223,7 @@ namespace XCharts.Runtime
|
||||
else if (container is PolarCoord)
|
||||
{
|
||||
var m_AngleAxis = ComponentHelper.GetAngleAxis(chart.components, container.index);
|
||||
tooltip.context.angle = (float)m_AngleAxis.context.pointerValue;
|
||||
tooltip.context.angle = (float) m_AngleAxis.context.pointerValue;
|
||||
}
|
||||
list.Add(serie);
|
||||
if (!isTriggerAxis)
|
||||
@@ -243,7 +242,7 @@ namespace XCharts.Runtime
|
||||
serie.context.pointerAxisDataIndexs.Clear();
|
||||
if (yAxis.IsCategory())
|
||||
{
|
||||
serie.context.pointerAxisDataIndexs.Add((int)yAxis.context.pointerValue);
|
||||
serie.context.pointerAxisDataIndexs.Add((int) yAxis.context.pointerValue);
|
||||
yAxis.context.axisTooltipValue = yAxis.context.pointerValue;
|
||||
}
|
||||
else if (yAxis.IsTime())
|
||||
@@ -255,7 +254,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else if (xAxis.IsCategory())
|
||||
{
|
||||
serie.context.pointerAxisDataIndexs.Add((int)xAxis.context.pointerValue);
|
||||
serie.context.pointerAxisDataIndexs.Add((int) xAxis.context.pointerValue);
|
||||
xAxis.context.axisTooltipValue = xAxis.context.pointerValue;
|
||||
}
|
||||
else
|
||||
@@ -286,7 +285,7 @@ namespace XCharts.Runtime
|
||||
serieData.index = i;
|
||||
serie.context.sortedData.Add(serieData);
|
||||
}
|
||||
serie.context.sortedData.Sort(delegate (SerieData a, SerieData b)
|
||||
serie.context.sortedData.Sort(delegate(SerieData a, SerieData b)
|
||||
{
|
||||
return a.GetData(dimension).CompareTo(b.GetData(dimension));
|
||||
});
|
||||
@@ -437,7 +436,7 @@ namespace XCharts.Runtime
|
||||
var axis = component as Axis;
|
||||
if (axis.gridIndex == gridIndex && axis.IsCategory())
|
||||
{
|
||||
dataIndex = (int)axis.context.pointerValue;
|
||||
dataIndex = (int) axis.context.pointerValue;
|
||||
category = axis.GetData(dataIndex);
|
||||
return true;
|
||||
}
|
||||
@@ -494,25 +493,25 @@ namespace XCharts.Runtime
|
||||
case Tooltip.Type.Corss:
|
||||
case Tooltip.Type.Line:
|
||||
float pX = grid.context.x;
|
||||
pX += xAxis.IsCategory()
|
||||
? (float)(xAxis.context.pointerValue * splitWidth + (xAxis.boundaryGap ? splitWidth / 2 : 0))
|
||||
: xAxis.GetDistance(xAxis.context.axisTooltipValue, grid.context.width);
|
||||
pX += xAxis.IsCategory() ?
|
||||
(float) (xAxis.context.pointerValue * splitWidth + (xAxis.boundaryGap ? splitWidth / 2 : 0)) :
|
||||
xAxis.GetDistance(xAxis.context.axisTooltipValue, grid.context.width);
|
||||
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);
|
||||
if (xAxis.IsCategory() && tooltip.type == Tooltip.Type.Corss)
|
||||
{
|
||||
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
|
||||
// if (xAxis.IsCategory() && tooltip.type == Tooltip.Type.Corss)
|
||||
// {
|
||||
// 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);
|
||||
}
|
||||
@@ -527,7 +526,7 @@ namespace XCharts.Runtime
|
||||
if (xAxis.IsCategory())
|
||||
{
|
||||
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
||||
pX = (float)(grid.context.x + splitWidth * xAxis.context.pointerValue -
|
||||
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);
|
||||
@@ -559,24 +558,24 @@ namespace XCharts.Runtime
|
||||
{
|
||||
case Tooltip.Type.Corss:
|
||||
case Tooltip.Type.Line:
|
||||
float pY = (float)(grid.context.y + yAxis.context.pointerValue * splitWidth
|
||||
+ (yAxis.boundaryGap ? splitWidth / 2 : 0));
|
||||
float pY = (float) (grid.context.y + yAxis.context.pointerValue * splitWidth +
|
||||
(yAxis.boundaryGap ? splitWidth / 2 : 0));
|
||||
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);
|
||||
if (yAxis.IsCategory() && tooltip.type == Tooltip.Type.Corss)
|
||||
{
|
||||
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
|
||||
// if (yAxis.IsCategory() && tooltip.type == Tooltip.Type.Corss)
|
||||
// {
|
||||
// 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);
|
||||
}
|
||||
@@ -592,7 +591,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
float tooltipSplitWid = splitWidth < 1 ? 1 : splitWidth;
|
||||
float pX = grid.context.x + grid.context.width;
|
||||
pY = (float)(grid.context.y + splitWidth * yAxis.context.pointerValue -
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user