This commit is contained in:
monitor1394
2022-05-22 22:17:38 +08:00
parent 003f4da9de
commit bafe032bb9
391 changed files with 3718 additions and 2774 deletions

View File

@@ -1,4 +1,3 @@

using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -101,9 +100,9 @@ namespace XCharts.Runtime
[SerializeField]
private List<LabelStyle> m_ContentLabelStyles = new List<LabelStyle>()
{
new LabelStyle(){ textPadding = new TextPadding(0,5,0,0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft }},
new LabelStyle(){ textPadding = new TextPadding(0,20,0,0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft }},
new LabelStyle(){ textPadding = new TextPadding(0,0,0,0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleRight }}
new LabelStyle() { textPadding = new TextPadding(0, 5, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft } },
new LabelStyle() { textPadding = new TextPadding(0, 20, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleLeft } },
new LabelStyle() { textPadding = new TextPadding(0, 0, 0, 0), textStyle = new TextStyle() { alignment = TextAnchor.MiddleRight } }
};
public TooltipContext context = new TooltipContext();
@@ -146,6 +145,7 @@ namespace XCharts.Runtime
/// {c} is the value of a Y-dimension (dimesion is 1) from a Serie that is currently indicated or whose index is 0.</br>
/// {d} is the percentage value of Y-dimensions (dimesion is 1) from serie that is currently indicated or whose index is 0, with no % sign.</br>
/// {e} is the name of the data item serieData that is currently indicated or whose index is 0.</br>
/// {f} is sum of data.</br>
/// {.1} represents a dot from serie corresponding color that specifies index as 1.</br>
/// 1 in {a1}, {b1}, {c1} represents a serie that specifies an index of 1.</br>
/// {c1:2} represents the third data from serie's current indication data item indexed to 1 (a data item has multiple data, index 2 represents the third data).</br>
@@ -161,6 +161,7 @@ namespace XCharts.Runtime
/// {c}为当前所指示或index为0的serie的y维dimesion为1的数值。</br>
/// {d}为当前所指示或index为0的serie的y维dimesion为1百分比值注意不带%号。</br>
/// {e}为当前所指示或index为0的serie的数据项serieData的name。</br>
/// {f}为数据总和。</br>
/// {.1}表示指定index为1的serie对应颜色的圆点。</br>
/// {a1}、{b1}、{c1}中的1表示指定index为1的serie。</br>
/// {c1:2}表示索引为1的serie的当前指示数据项的第3个数据一个数据项有多个数据index为2表示第3个数据。</br>
@@ -372,7 +373,7 @@ namespace XCharts.Runtime
/// |当前提示框所指示的数据项索引。
/// </summary>
public List<int> runtimeDataIndex { get { return m_RuntimeDateIndex; } internal set { m_RuntimeDateIndex = value; } }
private List<int> m_RuntimeDateIndex = new List<int>() { -1, -1 };
private List<int> m_RuntimeDateIndex = new List<int>() {-1, -1 };
/// <summary>
/// Keep Tooltiop displayed at the top.

View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Text;

View File

@@ -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);

View File

@@ -1,4 +1,3 @@
using System;
using UnityEngine;
@@ -37,6 +36,7 @@ namespace XCharts.Runtime
var content = param.itemFormatter;
FormatterHelper.ReplaceSerieLabelContent(ref content,
param.numericFormatter,
param.dataCount,
param.value,
param.total,
param.serieName,

View File

@@ -1,4 +1,3 @@
using System.Collections.Generic;
using System.Text;
using UnityEngine;
@@ -115,8 +114,6 @@ namespace XCharts.Runtime
tooltip.gameObject.transform.SetAsLastSibling();
}
private void ResetSize()
{
var maxHig = 0f;
@@ -220,8 +217,8 @@ namespace XCharts.Runtime
view.background = ChartHelper.GetOrAddComponent<Image>(view.gameObject);
view.background.sprite = tooltip.backgroundImage;
view.background.type = tooltip.backgroundType;
view.background.color = ChartHelper.IsClearColor(tooltip.backgroundColor)
? Color.white : tooltip.backgroundColor;
view.background.color = ChartHelper.IsClearColor(tooltip.backgroundColor) ?
Color.white : tooltip.backgroundColor;
view.border = ChartHelper.GetOrAddComponent<Outline>(view.gameObject);
view.border.enabled = tooltip.borderWidth > 0;
@@ -240,7 +237,7 @@ namespace XCharts.Runtime
tooltip.paddingTopBottom);
view.title = ChartHelper.AddChartLabel("title", view.gameObject.transform, tooltip.titleLabelStyle, theme.tooltip,
"", Color.clear, TextAnchor.MiddleLeft);
"", Color.clear, TextAnchor.MiddleLeft);
var item = CreateViewItem(0, view.gameObject.transform, tooltip, theme.tooltip);
view.m_Items.Add(item);
@@ -266,7 +263,7 @@ namespace XCharts.Runtime
{
var labelStyle = tooltip.GetContentLabelStyle(i);
var label = ChartHelper.AddChartLabel("column" + i, parent, labelStyle, theme,
"", Color.clear, TextAnchor.MiddleLeft);
"", Color.clear, TextAnchor.MiddleLeft);
return label;
}
}