mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 03:58:49 +00:00
3.0 - scatter chart and candlestick chart
This commit is contained in:
@@ -230,9 +230,10 @@ namespace XCharts
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, theme, serie.index, highlight);
|
||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, serie.index, highlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
||||
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||
chart.DrawClipSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
||||
symbolColor, symbolToColor, symbolEmptyColor, symbol.gap, clip, cornerRadius, m_SerieGrid,
|
||||
symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, clip, cornerRadius, m_SerieGrid,
|
||||
i > 0 ? serie.context.dataPoints[i - 1] : m_SerieGrid.context.position);
|
||||
}
|
||||
if (interacting)
|
||||
|
||||
@@ -91,11 +91,12 @@ namespace XCharts
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, n, highlight);
|
||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, n, highlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, highlight);
|
||||
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, highlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||
|
||||
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
|
||||
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, serieData.context.position,
|
||||
symbolColor, symbolToColor, symbolEmptyColor, symbol.gap, cornerRadius);
|
||||
symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace XCharts
|
||||
{
|
||||
public override void Update()
|
||||
{
|
||||
base.Update();
|
||||
UpdateSerieContext();
|
||||
}
|
||||
|
||||
@@ -30,23 +31,10 @@ namespace XCharts
|
||||
marker, itemFormatter, numericFormatter);
|
||||
}
|
||||
|
||||
public override void RefreshLabelInternal()
|
||||
public override Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label)
|
||||
{
|
||||
var data = serie.data;
|
||||
for (int n = 0; n < data.Count; n++)
|
||||
{
|
||||
var serieData = data[n];
|
||||
if (!serieData.context.canShowLabel || serie.IsIgnoreValue(serieData))
|
||||
{
|
||||
serieData.SetLabelActive(false);
|
||||
continue;
|
||||
}
|
||||
if (!serieData.show) continue;
|
||||
|
||||
var colorIndex = chart.GetLegendRealShowNameIndex(serieData.name);
|
||||
Color color = chart.theme.GetColor(colorIndex);
|
||||
DrawPieLabel(serie, n, serieData, color);
|
||||
}
|
||||
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
|
||||
return SerieLabelHelper.GetRealLabelPosition(serieData, label, labelLine);
|
||||
}
|
||||
|
||||
public override void OnLegendButtonClick(int index, string legendName, bool show)
|
||||
@@ -103,8 +91,7 @@ namespace XCharts
|
||||
|
||||
private void UpdateSerieContext()
|
||||
{
|
||||
var needCheck = m_LegendEnter
|
||||
|| (chart.isPointerInChart && PointerIsInPieSerie(serie, chart.pointerPos));
|
||||
var needCheck = m_LegendEnter || (chart.isPointerInChart && PointerIsInPieSerie(serie, chart.pointerPos));
|
||||
var needInteract = false;
|
||||
if (!needCheck)
|
||||
{
|
||||
@@ -118,6 +105,7 @@ namespace XCharts
|
||||
var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName);
|
||||
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false);
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, false);
|
||||
serieData.context.highlight = false;
|
||||
serieData.interact.SetValueAndColor(ref needInteract, serieData.context.outsideRadius, color, toColor);
|
||||
}
|
||||
if (needInteract)
|
||||
@@ -375,7 +363,8 @@ namespace XCharts
|
||||
{
|
||||
foreach (var serie in chart.series)
|
||||
{
|
||||
if (serie is Pie && serie.pieClickOffset) return true;
|
||||
if (serie is Pie && serie.pieClickOffset)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -388,7 +377,8 @@ namespace XCharts
|
||||
{
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
if (serieData.context.highlight) return true;
|
||||
if (serieData.context.highlight)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -421,8 +411,12 @@ namespace XCharts
|
||||
var outSideRadius = serieData.context.outsideRadius;
|
||||
var center = serie.context.center;
|
||||
var currAngle = serieData.context.halfAngle;
|
||||
if (!ChartHelper.IsClearColor(labelLine.lineColor)) color = labelLine.lineColor;
|
||||
else if (labelLine.lineType == LabelLine.LineType.HorizontalLine) color *= color;
|
||||
|
||||
if (!ChartHelper.IsClearColor(labelLine.lineColor))
|
||||
color = labelLine.lineColor;
|
||||
else if (labelLine.lineType == LabelLine.LineType.HorizontalLine)
|
||||
color *= color;
|
||||
|
||||
float currSin = Mathf.Sin(currAngle * Mathf.Deg2Rad);
|
||||
float currCos = Mathf.Cos(currAngle * Mathf.Deg2Rad);
|
||||
var radius1 = labelLine.lineType == LabelLine.LineType.HorizontalLine ?
|
||||
@@ -492,91 +486,26 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPieLabel(Serie serie, int dataIndex, SerieData serieData, Color serieColor)
|
||||
{
|
||||
if (serieData.labelObject == null) return;
|
||||
var emphasis = serie.emphasis;
|
||||
var currAngle = serieData.context.halfAngle;
|
||||
var isHighlight = (serieData.context.highlight && emphasis != null && emphasis.label.show);
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData);
|
||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
||||
var showLabel = ((serieLabel.show || isHighlight) && serieData.context.canShowLabel);
|
||||
if (showLabel)
|
||||
{
|
||||
serieData.SetLabelActive(showLabel);
|
||||
float rotate = 0;
|
||||
bool isInsidePosition = serieLabel.position == LabelStyle.Position.Inside;
|
||||
if (serieLabel.textStyle.rotate > 0 && isInsidePosition)
|
||||
{
|
||||
if (currAngle > 180) rotate += 270 - currAngle;
|
||||
else rotate += -(currAngle - 90);
|
||||
}
|
||||
Color color = serieColor;
|
||||
if (isHighlight)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(emphasis.label.textStyle.color))
|
||||
{
|
||||
color = emphasis.label.textStyle.color;
|
||||
}
|
||||
}
|
||||
else if (!ChartHelper.IsClearColor(serieLabel.textStyle.color))
|
||||
{
|
||||
color = serieLabel.textStyle.color;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = isInsidePosition ? Color.white : serieColor;
|
||||
}
|
||||
var fontSize = isHighlight
|
||||
? emphasis.label.textStyle.GetFontSize(chart.theme.common)
|
||||
: serieLabel.textStyle.GetFontSize(chart.theme.common);
|
||||
var fontStyle = isHighlight
|
||||
? emphasis.label.textStyle.fontStyle
|
||||
: serieLabel.textStyle.fontStyle;
|
||||
|
||||
serieData.labelObject.label.SetColor(color);
|
||||
serieData.labelObject.label.SetFontSize(fontSize);
|
||||
serieData.labelObject.label.SetFontStyle(fontStyle);
|
||||
serieData.labelObject.SetLabelRotate(rotate);
|
||||
if (!string.IsNullOrEmpty(serieLabel.formatter))
|
||||
{
|
||||
var value = serieData.data[1];
|
||||
var total = serie.yTotal;
|
||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
|
||||
serieLabel, serieColor);
|
||||
if (serieData.labelObject.SetText(content)) chart.RefreshPainter(serie);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (serieData.labelObject.SetText(serieData.name)) chart.RefreshPainter(serie);
|
||||
}
|
||||
serieData.labelObject.SetPosition(SerieLabelHelper.GetRealLabelPosition(serieData, serieLabel, labelLine));
|
||||
if (showLabel) serieData.labelObject.SetLabelPosition(serieLabel.offset);
|
||||
else serieData.SetLabelActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
serieData.SetLabelActive(false);
|
||||
}
|
||||
serieData.labelObject.UpdateIcon(iconStyle);
|
||||
}
|
||||
|
||||
private int GetPiePosIndex(Serie serie, Vector2 local)
|
||||
{
|
||||
if (!(serie is Pie)) return -1;
|
||||
if (!(serie is Pie))
|
||||
return -1;
|
||||
|
||||
var dist = Vector2.Distance(local, serie.context.center);
|
||||
var maxRadius = serie.context.outsideRadius + 3 * chart.theme.serie.pieSelectedOffset;
|
||||
if (dist < serie.context.insideRadius || dist > maxRadius) return -1;
|
||||
Vector2 dir = local - new Vector2(serie.context.center.x, serie.context.center.y);
|
||||
float angle = ChartHelper.GetAngle360(Vector2.up, dir);
|
||||
if (dist < serie.context.insideRadius || dist > maxRadius)
|
||||
return -1;
|
||||
|
||||
var dir = local - new Vector2(serie.context.center.x, serie.context.center.y);
|
||||
var angle = ChartHelper.GetAngle360(Vector2.up, dir);
|
||||
for (int i = 0; i < serie.data.Count; i++)
|
||||
{
|
||||
var serieData = serie.data[i];
|
||||
if (angle >= serieData.context.startAngle && angle <= serieData.context.toAngle)
|
||||
{
|
||||
var ndist = !serieData.selected ? dist :
|
||||
Vector2.Distance(local, serieData.context.offsetCenter);
|
||||
var ndist = serieData.selected
|
||||
? Vector2.Distance(local, serieData.context.offsetCenter)
|
||||
: dist;
|
||||
if (ndist >= serieData.context.insideRadius && ndist <= serieData.context.outsideRadius)
|
||||
{
|
||||
return i;
|
||||
@@ -588,9 +517,13 @@ namespace XCharts
|
||||
|
||||
private bool PointerIsInPieSerie(Serie serie, Vector2 local)
|
||||
{
|
||||
if (!(serie is Pie)) return false;
|
||||
if (!(serie is Pie))
|
||||
return false;
|
||||
|
||||
var dist = Vector2.Distance(local, serie.context.center);
|
||||
if (dist >= serie.context.insideRadius && dist <= serie.context.outsideRadius) return true;
|
||||
if (dist >= serie.context.insideRadius && dist <= serie.context.outsideRadius)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace XCharts
|
||||
for (int i = 0; i < serieData.data.Count; i++)
|
||||
{
|
||||
var indicator = radar.GetIndicator(i);
|
||||
if (indicator == null) continue;
|
||||
|
||||
var param = new SerieParams();
|
||||
param.serieName = serie.serieName;
|
||||
@@ -75,58 +76,13 @@ namespace XCharts
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
param.columns.Add(indicator == null ? string.Empty : indicator.name);
|
||||
param.columns.Add(indicator.name);
|
||||
param.columns.Add(ChartCached.NumberToStr(serieData.GetData(i), param.numericFormatter));
|
||||
|
||||
paramList.Add(param);
|
||||
}
|
||||
}
|
||||
|
||||
public override void RefreshLabelInternal()
|
||||
{
|
||||
for (int i = 0; i < chart.series.Count; i++)
|
||||
{
|
||||
var serie = chart.GetSerie(i);
|
||||
if (!(serie is Radar)) continue;
|
||||
if (!serie.show && serie.radarType != RadarType.Single) continue;
|
||||
var radar = chart.GetChartComponent<RadarCoord>(serie.radarIndex);
|
||||
if (radar == null) continue;
|
||||
var center = radar.context.center;
|
||||
for (int n = 0; n < serie.dataCount; n++)
|
||||
{
|
||||
var serieData = serie.data[n];
|
||||
if (serieData.labelObject == null) continue;
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
||||
var labelPos = serieData.context.labelPosition;
|
||||
if (serieLabel.margin != 0)
|
||||
{
|
||||
labelPos += serieLabel.margin * (labelPos - center).normalized;
|
||||
}
|
||||
serieData.labelObject.SetPosition(labelPos);
|
||||
serieData.labelObject.UpdateIcon(iconStyle);
|
||||
if (serie.show && serieLabel.show && serieData.context.canShowLabel)
|
||||
{
|
||||
var value = serieData.GetCurrData(1);
|
||||
var max = radar.GetIndicatorMax(n);
|
||||
SerieLabelHelper.ResetLabel(serieData.labelObject.label, serieLabel, chart.theme);
|
||||
serieData.SetLabelActive(serieData.context.labelPosition != Vector3.zero);
|
||||
serieData.labelObject.SetLabelPosition(serieLabel.offset);
|
||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, max,
|
||||
serieLabel, Color.clear);
|
||||
if (serieData.labelObject.SetText(content))
|
||||
{
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
serieData.SetLabelActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnLegendButtonClick(int index, string legendName, bool show)
|
||||
{
|
||||
if (!serie.IsLegendName(legendName))
|
||||
@@ -323,9 +279,10 @@ namespace XCharts
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, isHighlight);
|
||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, j, isHighlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
||||
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
||||
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
|
||||
symbolToColor, symbolEmptyColor, serie.symbol.gap, cornerRadius);
|
||||
symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -458,6 +415,7 @@ namespace XCharts
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
||||
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
||||
if (!radar.IsInIndicatorRange(j, serieData.GetData(1)))
|
||||
{
|
||||
@@ -465,7 +423,7 @@ namespace XCharts
|
||||
symbolToColor = radar.outRangeColor;
|
||||
}
|
||||
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.context.labelPosition, symbolColor,
|
||||
symbolToColor, symbolEmptyColor, serie.symbol.gap, cornerRadius);
|
||||
symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
|
||||
}
|
||||
}
|
||||
if (!serie.animation.IsFinish())
|
||||
@@ -508,11 +466,12 @@ namespace XCharts
|
||||
var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight);
|
||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, serieIndex, isHighlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight);
|
||||
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight);
|
||||
foreach (var point in pointList)
|
||||
{
|
||||
chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor,
|
||||
symbolToColor, symbolEmptyColor, serie.symbol.gap, cornerRadius);
|
||||
symbolToColor, symbolEmptyColor, borderColor, serie.symbol.gap, cornerRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +156,7 @@ namespace XCharts
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight);
|
||||
var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
||||
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||
double xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
|
||||
double yValue = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
|
||||
@@ -194,16 +195,17 @@ namespace XCharts
|
||||
{
|
||||
var nowSize = symbol.animationSize[count];
|
||||
color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
|
||||
chart.DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos, color, toColor, emptyColor, symbol.gap, cornerRadius);
|
||||
chart.DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos,
|
||||
color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
|
||||
}
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (symbolSize > 100) symbolSize = 100;
|
||||
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, color, toColor, emptyColor, symbol.gap, cornerRadius);
|
||||
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
||||
color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
|
||||
}
|
||||
|
||||
}
|
||||
if (!serie.animation.IsFinish())
|
||||
{
|
||||
@@ -258,6 +260,7 @@ namespace XCharts
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, theme, colorIndex, highlight);
|
||||
var emptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, colorIndex, highlight, false);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
||||
var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||
var xValue = serieData.GetCurrData(0, dataChangeDuration, axis.inverse);
|
||||
|
||||
@@ -296,7 +299,7 @@ namespace XCharts
|
||||
var nowSize = symbol.animationSize[count];
|
||||
color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
|
||||
chart.DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos,
|
||||
color, toColor, emptyColor, symbol.gap, cornerRadius);
|
||||
color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
|
||||
}
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
@@ -304,7 +307,7 @@ namespace XCharts
|
||||
{
|
||||
if (symbolSize > 100) symbolSize = 100;
|
||||
chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
||||
color, toColor, emptyColor, symbol.gap, cornerRadius);
|
||||
color, toColor, emptyColor, borderColor, symbol.gap, cornerRadius);
|
||||
}
|
||||
}
|
||||
if (!serie.animation.IsFinish())
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace XCharts
|
||||
public AreaStyle areaStyle { get { return m_AreaStyles.Count > 0 ? m_AreaStyles[0] : null; } }
|
||||
/// <summary>
|
||||
/// Text label of graphic element,to explain some data information about graphic item like value, name and so on.
|
||||
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。s
|
||||
/// 图形上的文本标签,可用于说明图形的一些数据信息,比如值,名称等。
|
||||
/// </summary>
|
||||
public LabelStyle label { get { return m_Labels.Count > 0 ? m_Labels[0] : null; } }
|
||||
public LabelStyle endLabel { get { return m_EndLabels.Count > 0 ? m_EndLabels[0] : null; } }
|
||||
|
||||
@@ -30,8 +30,10 @@ namespace XCharts
|
||||
public virtual void OnScroll(PointerEventData eventData) { }
|
||||
public virtual void RefreshLabelNextFrame() { }
|
||||
public virtual void RefreshLabelInternal() { }
|
||||
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, string marker,
|
||||
string itemFormatter, string numericFormatter, ref List<SerieParams> paramList, ref string title)
|
||||
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory,
|
||||
string category, string marker,
|
||||
string itemFormatter, string numericFormatter,
|
||||
ref List<SerieParams> paramList, ref string title)
|
||||
{ }
|
||||
public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }
|
||||
public virtual void OnLegendButtonEnter(int index, string legendName) { }
|
||||
@@ -59,6 +61,7 @@ namespace XCharts
|
||||
this.serie.context.param.serieType = typeof(T);
|
||||
m_NeedInitComponent = true;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (m_NeedInitComponent)
|
||||
@@ -256,32 +259,64 @@ namespace XCharts
|
||||
{
|
||||
if (!m_InitedLabel)
|
||||
return;
|
||||
|
||||
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
|
||||
var total = serie.yTotal;
|
||||
var isNeedInvertPositionSerie = serie is Line;
|
||||
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
if (serieData.labelObject == null)
|
||||
continue;
|
||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||
var emphasisLabel = SerieHelper.GetSerieEmphasisLabel(serie, serieData);
|
||||
var isHighlight = (serieData.context.highlight && emphasisLabel != null && emphasisLabel.show);
|
||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
||||
var isIgnore = serie.IsIgnoreIndex(serieData.index);
|
||||
var currLabel = isHighlight && emphasisLabel != null ? emphasisLabel : serieLabel;
|
||||
|
||||
serieData.labelObject.SetPosition(serieData.context.position);
|
||||
serieData.labelObject.UpdateIcon(iconStyle);
|
||||
if (serie.show && serieLabel != null
|
||||
&& serieLabel.show && serieData.context.canShowLabel && !isIgnore)
|
||||
|
||||
if (serie.show
|
||||
&& currLabel != null
|
||||
&& (currLabel.show || isHighlight)
|
||||
&& serieData.context.canShowLabel
|
||||
&& !isIgnore)
|
||||
{
|
||||
var value = serieData.GetData(1);
|
||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
|
||||
serieLabel, chart.theme.GetColor(colorIndex));
|
||||
var invert = serieLabel.autoOffset
|
||||
&& serie is Line
|
||||
var content = serie.useDataNameForColor && string.IsNullOrEmpty(currLabel.formatter)
|
||||
? serieData.name
|
||||
: SerieLabelHelper.GetFormatterContent(serie, serieData, serieData.GetData(1), total,
|
||||
currLabel, chart.theme.GetColor(colorIndex));
|
||||
|
||||
var invert = currLabel.autoOffset
|
||||
&& isNeedInvertPositionSerie
|
||||
&& SerieHelper.IsDownPoint(serie, serieData.index)
|
||||
&& (serie.areaStyle == null || !serie.areaStyle.show);
|
||||
var labelPosition = GetSerieDataLabelPosition(serieData, serieLabel);
|
||||
SerieLabelHelper.ResetLabel(serieData.labelObject.label, serieLabel, chart.theme);
|
||||
var labelPosition = GetSerieDataLabelPosition(serieData, currLabel);
|
||||
var isInsidePosition = currLabel.position == LabelStyle.Position.Inside;
|
||||
|
||||
//text color
|
||||
var textColor = chart.theme.common.textColor;
|
||||
if (!ChartHelper.IsClearColor(currLabel.textStyle.color))
|
||||
textColor = currLabel.textStyle.color;
|
||||
else if (isInsidePosition)
|
||||
textColor = Color.white;
|
||||
//text rotate
|
||||
var rotate = currLabel.textStyle.rotate;
|
||||
if (currLabel.textStyle.rotate > 0 && isInsidePosition)
|
||||
{
|
||||
var currAngle = serieData.context.halfAngle;
|
||||
if (currAngle > 0)
|
||||
{
|
||||
if (currAngle > 180) rotate += 270 - currAngle;
|
||||
else rotate += -(currAngle - 90);
|
||||
}
|
||||
}
|
||||
SerieLabelHelper.ResetLabel(serieData.labelObject.label, currLabel, chart.theme, textColor, rotate);
|
||||
serieData.SetLabelActive(!isIgnore);
|
||||
serieData.labelObject.SetPosition(labelPosition
|
||||
+ (invert ? -serieLabel.offset : serieLabel.offset));
|
||||
+ (invert ? -currLabel.offset : currLabel.offset));
|
||||
serieData.labelObject.SetText(content);
|
||||
}
|
||||
else
|
||||
@@ -364,7 +399,7 @@ namespace XCharts
|
||||
param.color = chart.theme.GetColor(dataIndex);
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = itemFormatter;
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); ;
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
|
||||
Reference in New Issue
Block a user