增加customDrawCallback自定义绘制回调

This commit is contained in:
monitor1394
2019-10-01 13:31:34 +08:00
parent a1356e0d84
commit a220017d3d
13 changed files with 23670 additions and 18433 deletions

View File

@@ -39,7 +39,8 @@ namespace XCharts
[SerializeField] protected Tooltip m_Tooltip = Tooltip.defaultTooltip;
[SerializeField] protected Series m_Series = Series.defaultSeries;
[SerializeField] protected float m_Large = 1;
[SerializeField] [Range(1, 8)] private float m_LineSmoothStyle = 2f;
[SerializeField] [Range(1, 8)] protected float m_LineSmoothStyle = 2f;
[SerializeField] protected Action<VertexHelper> m_CustomDrawCallback;
[NonSerialized] private Theme m_CheckTheme = 0;
[NonSerialized] private Title m_CheckTitle = Title.defaultTitle;
@@ -589,6 +590,10 @@ namespace XCharts
vh.Clear();
DrawBackground(vh);
DrawChart(vh);
if (m_CustomDrawCallback != null)
{
m_CustomDrawCallback(vh);
}
DrawTooltip(vh);
m_RefreshLabel = true;
}
@@ -608,7 +613,7 @@ namespace XCharts
Vector3 p2 = new Vector3(chartWidth, chartHeight);
Vector3 p3 = new Vector3(chartWidth, 0);
Vector3 p4 = new Vector3(0, 0);
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.backgroundColor);
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.backgroundColor);
}
protected void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
@@ -619,15 +624,15 @@ namespace XCharts
case SerieSymbolType.None:
break;
case SerieSymbolType.Circle:
ChartHelper.DrawCricle(vh, pos, symbolSize, color, GetSymbolCricleSegment(symbolSize));
ChartDrawer.DrawCricle(vh, pos, symbolSize, color, GetSymbolCricleSegment(symbolSize));
break;
case SerieSymbolType.EmptyCircle:
int segment = GetSymbolCricleSegment(symbolSize);
ChartHelper.DrawCricle(vh, pos, symbolSize, m_ThemeInfo.backgroundColor, segment);
ChartHelper.DrawDoughnut(vh, pos, symbolSize - tickness, symbolSize, 0, 360, color, segment);
ChartDrawer.DrawCricle(vh, pos, symbolSize, m_ThemeInfo.backgroundColor, segment);
ChartDrawer.DrawDoughnut(vh, pos, symbolSize - tickness, symbolSize, 0, 360, color, segment);
break;
case SerieSymbolType.Rect:
ChartHelper.DrawPolygon(vh, pos, symbolSize, color);
ChartDrawer.DrawPolygon(vh, pos, symbolSize, color);
break;
case SerieSymbolType.Triangle:
var x = symbolSize * Mathf.Cos(30 * Mathf.PI / 180);
@@ -635,14 +640,14 @@ namespace XCharts
var p1 = new Vector2(pos.x - x, pos.y - y);
var p2 = new Vector2(pos.x, pos.y + symbolSize);
var p3 = new Vector2(pos.x + x, pos.y - y);
ChartHelper.DrawTriangle(vh, p1, p2, p3, color);
ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
break;
case SerieSymbolType.Diamond:
p1 = new Vector2(pos.x - symbolSize, pos.y);
p2 = new Vector2(pos.x, pos.y + symbolSize);
p3 = new Vector2(pos.x + symbolSize, pos.y);
var p4 = new Vector2(pos.x, pos.y - symbolSize);
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, color);
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, color);
break;
}
}
@@ -665,7 +670,7 @@ namespace XCharts
p4 = ChartHelper.RotateRound(p4, centerPos, Vector3.forward, serie.label.rotate);
}
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, serie.label.backgroundColor);
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, serie.label.backgroundColor);
if (serie.label.border)
{
@@ -689,17 +694,17 @@ namespace XCharts
p7 = ChartHelper.RotateRound(p7, centerPos, Vector3.forward, serie.label.rotate);
p8 = ChartHelper.RotateRound(p8, centerPos, Vector3.forward, serie.label.rotate);
}
ChartHelper.DrawLine(vh, p1, p2, borderWid, serie.label.borderColor);
ChartHelper.DrawLine(vh, p3, p4, borderWid, serie.label.borderColor);
ChartHelper.DrawLine(vh, p5, p6, borderWid, serie.label.borderColor);
ChartHelper.DrawLine(vh, p7, p8, borderWid, serie.label.borderColor);
ChartDrawer.DrawLine(vh, p1, p2, borderWid, serie.label.borderColor);
ChartDrawer.DrawLine(vh, p3, p4, borderWid, serie.label.borderColor);
ChartDrawer.DrawLine(vh, p5, p6, borderWid, serie.label.borderColor);
ChartDrawer.DrawLine(vh, p7, p8, borderWid, serie.label.borderColor);
}
}
private int GetSymbolCricleSegment(float radiu)
{
int max = 50;
int segent = (int)(2 * Mathf.PI * radiu / ChartHelper.CRICLE_SMOOTHNESS);
int segent = (int)(2 * Mathf.PI * radiu / ChartDrawer.CRICLE_SMOOTHNESS);
if (segent > max) segent = max;
segent = (int)(segent / (1 + (m_Large - 1) / 10));
return segent;

View File

@@ -1,5 +1,7 @@
using UnityEngine;
using System.Collections.Generic;
using System;
using UnityEngine.UI;
namespace XCharts
{
@@ -47,7 +49,10 @@ namespace XCharts
/// </summary>
/// <value></value>
public float lineSmoothStyle { get { return m_LineSmoothStyle; } set { m_LineSmoothStyle = value; } }
/// <summary>
/// 自定义绘制回调。
/// </summary>
public Action<VertexHelper> customDrawCallback { set { m_CustomDrawCallback = value; } }
/// <summary>
/// Set the size of chart.
/// 设置图表的大小。
@@ -236,9 +241,9 @@ namespace XCharts
/// <param name="serieName">the name of serie</param>
/// <param name="dataIndex">the index of data</param>
/// <param name="value">the data will be update</param>
public virtual void UpdateData(string serieName,int dataIndex, float value)
public virtual void UpdateData(string serieName, int dataIndex, float value)
{
m_Series.UpdateData(serieName,dataIndex, value);
m_Series.UpdateData(serieName, dataIndex, value);
RefreshChart();
}
@@ -249,9 +254,9 @@ namespace XCharts
/// <param name="serieIndex">the index of serie</param>
/// <param name="dataIndex">the index of data</param>
/// <param name="value">the data will be update</param>
public virtual void UpdateData(int serieIndex,int dataIndex, float value)
public virtual void UpdateData(int serieIndex, int dataIndex, float value)
{
m_Series.UpdateData(serieIndex, dataIndex,value);
m_Series.UpdateData(serieIndex, dataIndex, value);
RefreshChart();
}
@@ -262,9 +267,9 @@ namespace XCharts
/// <param name="serieName"></param>
/// <param name="dataIndex"></param>
/// <param name="dataName"></param>
public virtual void UpdateDataName(string serieName,int dataIndex, string dataName)
public virtual void UpdateDataName(string serieName, int dataIndex, string dataName)
{
m_Series.UpdateDataName(serieName,dataIndex, dataName);
m_Series.UpdateDataName(serieName, dataIndex, dataName);
}
/// <summary>
@@ -276,7 +281,7 @@ namespace XCharts
/// <param name="dataIndex"></param>
public virtual void UpdateDataName(int serieIndex, int dataIndex, string dataName)
{
m_Series.UpdateDataName(serieIndex, dataIndex,dataName);
m_Series.UpdateDataName(serieIndex, dataIndex, dataName);
}
/// <summary>

View File

@@ -762,7 +762,7 @@ namespace XCharts
var p2 = new Vector2(coordinateX, coordinateY + coordinateHig);
var p3 = new Vector2(coordinateX + coordinateWid, coordinateY + coordinateHig);
var p4 = new Vector2(coordinateX + coordinateWid, coordinateY);
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, m_Grid.backgroundColor);
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_Grid.backgroundColor);
}
}
@@ -783,7 +783,7 @@ namespace XCharts
}
if (yAxis.splitArea.show && i < size - 1)
{
ChartHelper.DrawPolygon(vh, new Vector2(coordinateX, pY),
ChartDrawer.DrawPolygon(vh, new Vector2(coordinateX, pY),
new Vector2(coordinateX + coordinateWid, pY),
new Vector2(coordinateX + coordinateWid, pY + scaleWidth),
new Vector2(coordinateX, pY + scaleWidth),
@@ -802,7 +802,7 @@ namespace XCharts
{
pX += startX - yAxis.axisTick.length;
}
ChartHelper.DrawLine(vh, new Vector3(startX, pY), new Vector3(pX, pY),
ChartDrawer.DrawLine(vh, new Vector3(startX, pY), new Vector3(pX, pY),
yAxis.axisLine.width, m_ThemeInfo.axisLineColor);
}
if (yAxis.showSplitLine)
@@ -832,7 +832,7 @@ namespace XCharts
}
if (xAxis.splitArea.show && i < size - 1)
{
ChartHelper.DrawPolygon(vh, new Vector2(pX, coordinateY),
ChartDrawer.DrawPolygon(vh, new Vector2(pX, coordinateY),
new Vector2(pX, coordinateY + coordinateHig),
new Vector2(pX + scaleWidth, coordinateY + coordinateHig),
new Vector2(pX + scaleWidth, coordinateY),
@@ -851,7 +851,7 @@ namespace XCharts
{
pY += startY - xAxis.axisTick.length;
}
ChartHelper.DrawLine(vh, new Vector3(pX, startY), new Vector3(pX, pY),
ChartDrawer.DrawLine(vh, new Vector3(pX, startY), new Vector3(pX, pY),
xAxis.axisLine.width, m_ThemeInfo.axisLineColor);
}
if (xAxis.showSplitLine)
@@ -872,11 +872,11 @@ namespace XCharts
if (xAxis.IsValue() && xAxisIndex > 0) lineY += coordinateHig;
var left = new Vector3(coordinateX - xAxis.axisLine.width, lineY);
var top = new Vector3(coordinateX + coordinateWid + xAxis.axisLine.width, lineY);
ChartHelper.DrawLine(vh, left, top, xAxis.axisLine.width, m_ThemeInfo.axisLineColor);
ChartDrawer.DrawLine(vh, left, top, xAxis.axisLine.width, m_ThemeInfo.axisLineColor);
if (xAxis.axisLine.symbol)
{
var axisLine = xAxis.axisLine;
ChartHelper.DrawArrow(vh, new Vector3(coordinateX, lineY), top, axisLine.symbolWidth, axisLine.symbolHeight,
ChartDrawer.DrawArrow(vh, new Vector3(coordinateX, lineY), top, axisLine.symbolWidth, axisLine.symbolHeight,
axisLine.symbolOffset, axisLine.symbolDent, m_ThemeInfo.axisLineColor);
}
}
@@ -889,12 +889,12 @@ namespace XCharts
var lineX = coordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].zeroXOffset : 0);
if (yAxis.IsValue() && yAxisIndex > 0) lineX += coordinateWid;
var top = new Vector3(lineX, coordinateY + coordinateHig + yAxis.axisLine.width);
ChartHelper.DrawLine(vh, new Vector3(lineX, coordinateY - yAxis.axisLine.width),
ChartDrawer.DrawLine(vh, new Vector3(lineX, coordinateY - yAxis.axisLine.width),
top, yAxis.axisLine.width, m_ThemeInfo.axisLineColor);
if (yAxis.axisLine.symbol)
{
var axisLine = yAxis.axisLine;
ChartHelper.DrawArrow(vh, new Vector3(lineX, coordinateX), top, axisLine.symbolWidth, axisLine.symbolHeight,
ChartDrawer.DrawArrow(vh, new Vector3(lineX, coordinateX), top, axisLine.symbolWidth, axisLine.symbolHeight,
axisLine.symbolOffset, axisLine.symbolDent, m_ThemeInfo.axisLineColor);
}
}
@@ -908,10 +908,10 @@ namespace XCharts
var p3 = new Vector2(coordinateX + coordinateWid, m_DataZoom.bottom + m_DataZoom.height);
var p4 = new Vector2(coordinateX + coordinateWid, m_DataZoom.bottom);
var xAxis = xAxises[0];
ChartHelper.DrawLine(vh, p1, p2, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
ChartHelper.DrawLine(vh, p2, p3, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
ChartHelper.DrawLine(vh, p3, p4, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
ChartHelper.DrawLine(vh, p4, p1, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
ChartDrawer.DrawLine(vh, p1, p2, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
ChartDrawer.DrawLine(vh, p2, p3, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
ChartDrawer.DrawLine(vh, p3, p4, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
ChartDrawer.DrawLine(vh, p4, p1, xAxis.axisLine.width, m_ThemeInfo.dataZoomLineColor);
if (m_DataZoom.showDataShadow && m_Series.Count > 0)
{
Serie serie = m_Series.series[0];
@@ -933,13 +933,13 @@ namespace XCharts
if (i > 0)
{
Color color = m_ThemeInfo.dataZoomLineColor;
ChartHelper.DrawLine(vh, lp, np, xAxis.axisLine.width, color);
ChartDrawer.DrawLine(vh, lp, np, xAxis.axisLine.width, color);
Vector3 alp = new Vector3(lp.x, lp.y - xAxis.axisLine.width);
Vector3 anp = new Vector3(np.x, np.y - xAxis.axisLine.width);
Color areaColor = new Color(color.r, color.g, color.b, color.a * 0.75f);
Vector3 tnp = new Vector3(np.x, m_DataZoom.bottom + xAxis.axisLine.width);
Vector3 tlp = new Vector3(lp.x, m_DataZoom.bottom + xAxis.axisLine.width);
ChartHelper.DrawPolygon(vh, alp, anp, tnp, tlp, areaColor);
ChartDrawer.DrawPolygon(vh, alp, anp, tnp, tlp, areaColor);
}
lp = np;
}
@@ -953,9 +953,9 @@ namespace XCharts
p2 = new Vector2(start, m_DataZoom.bottom + m_DataZoom.height);
p3 = new Vector2(end, m_DataZoom.bottom + m_DataZoom.height);
p4 = new Vector2(end, m_DataZoom.bottom);
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.dataZoomSelectedColor);
ChartHelper.DrawLine(vh, p1, p2, xAxis.axisLine.width, m_ThemeInfo.dataZoomSelectedColor);
ChartHelper.DrawLine(vh, p3, p4, xAxis.axisLine.width, m_ThemeInfo.dataZoomSelectedColor);
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.dataZoomSelectedColor);
ChartDrawer.DrawLine(vh, p1, p2, xAxis.axisLine.width, m_ThemeInfo.dataZoomSelectedColor);
ChartDrawer.DrawLine(vh, p3, p4, xAxis.axisLine.width, m_ThemeInfo.dataZoomSelectedColor);
break;
}
}
@@ -967,19 +967,19 @@ namespace XCharts
switch (type)
{
case Axis.SplitLineType.Dashed:
ChartHelper.DrawDashLine(vh, startPos, endPos, axis.axisLine.width, color);
ChartDrawer.DrawDashLine(vh, startPos, endPos, axis.axisLine.width, color);
break;
case Axis.SplitLineType.Dotted:
ChartHelper.DrawDotLine(vh, startPos, endPos, axis.axisLine.width, color);
ChartDrawer.DrawDotLine(vh, startPos, endPos, axis.axisLine.width, color);
break;
case Axis.SplitLineType.Solid:
ChartHelper.DrawLine(vh, startPos, endPos, axis.axisLine.width, color);
ChartDrawer.DrawLine(vh, startPos, endPos, axis.axisLine.width, color);
break;
case Axis.SplitLineType.DashDot:
ChartHelper.DrawDashDotLine(vh, startPos, endPos, axis.axisLine.width, color);
ChartDrawer.DrawDashDotLine(vh, startPos, endPos, axis.axisLine.width, color);
break;
case Axis.SplitLineType.DashDotDot:
ChartHelper.DrawDashDotDotLine(vh, startPos, endPos, axis.axisLine.width, color);
ChartDrawer.DrawDashDotDotLine(vh, startPos, endPos, axis.axisLine.width, color);
break;
}
}
@@ -1022,7 +1022,7 @@ namespace XCharts
Vector3 p2 = new Vector3(pX, pY);
Vector3 p3 = new Vector3(pX + tooltipSplitWid, pY);
Vector3 p4 = new Vector3(pX + tooltipSplitWid, coordinateY);
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.tooltipFlagAreaColor);
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.tooltipFlagAreaColor);
break;
}
}
@@ -1064,7 +1064,7 @@ namespace XCharts
Vector3 p2 = new Vector3(coordinateX, pY + tooltipSplitWid);
Vector3 p3 = new Vector3(pX, pY + tooltipSplitWid);
Vector3 p4 = new Vector3(pX, pY);
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.tooltipFlagAreaColor);
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, m_ThemeInfo.tooltipFlagAreaColor);
break;
}
}

View File

@@ -64,7 +64,7 @@ namespace XCharts
{
Color areaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, highlight);
Color areaToColor = serie.GetAreaToColor(m_ThemeInfo, colorIndex, highlight);
ChartHelper.DrawPolygon(vh, p1, p2, p3, p4, areaColor, areaToColor);
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, areaColor, areaToColor);
}
}
if (!m_Series.IsStack(serie.stack, SerieType.Bar))
@@ -151,7 +151,7 @@ namespace XCharts
{
Color areaColor = serie.GetAreaColor(m_ThemeInfo, colorIndex, highlight);
Color areaToColor = serie.GetAreaToColor(m_ThemeInfo, colorIndex, highlight);
ChartHelper.DrawPolygon(vh, p4, p1, p2, p3, areaColor, areaToColor);
ChartDrawer.DrawPolygon(vh, p4, p1, p2, p3, areaColor, areaToColor);
}
}
if (!m_Series.IsStack(serie.stack, SerieType.Bar))

View File

@@ -52,7 +52,7 @@ namespace XCharts
if (dataPoints.Count < 2) dataPoints = serie.dataPoints;
var startPos = dataPoints[dataPoints.Count - 2];
var arrowPos = dataPoints[dataPoints.Count - 1];
ChartHelper.DrawArrow(vh, startPos, arrowPos, serie.lineArrow.width,
ChartDrawer.DrawArrow(vh, startPos, arrowPos, serie.lineArrow.width,
serie.lineArrow.height, serie.lineArrow.offset, serie.lineArrow.dent, lineColor);
break;
case LineArrow.Position.Start:
@@ -60,7 +60,7 @@ namespace XCharts
if (dataPoints.Count < 2) dataPoints = serie.dataPoints;
startPos = dataPoints[1];
arrowPos = dataPoints[0];
ChartHelper.DrawArrow(vh, startPos, arrowPos, serie.lineArrow.width,
ChartDrawer.DrawArrow(vh, startPos, arrowPos, serie.lineArrow.width,
serie.lineArrow.height, serie.lineArrow.offset, serie.lineArrow.dent, lineColor);
break;
}
@@ -181,19 +181,19 @@ namespace XCharts
areaColor, areaToColor, zeroPos);
break;
case LineType.Dash:
ChartHelper.DrawDashLine(vh, lp, np, serie.lineStyle.width, lineColor);
ChartDrawer.DrawDashLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
break;
case LineType.Dot:
ChartHelper.DrawDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
ChartDrawer.DrawDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
break;
case LineType.DashDot:
ChartHelper.DrawDashDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
ChartDrawer.DrawDashDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
break;
case LineType.DashDotDot:
ChartHelper.DrawDashDotDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
ChartDrawer.DrawDashDotDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
break;
}
@@ -438,19 +438,19 @@ namespace XCharts
areaColor, areaToColor, zeroPos);
break;
case LineType.Dash:
ChartHelper.DrawDashLine(vh, lp, np, serie.lineStyle.width, lineColor);
ChartDrawer.DrawDashLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
break;
case LineType.Dot:
ChartHelper.DrawDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
ChartDrawer.DrawDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
break;
case LineType.DashDot:
ChartHelper.DrawDashDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
ChartDrawer.DrawDashDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
break;
case LineType.DashDotDot:
ChartHelper.DrawDashDotDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
ChartDrawer.DrawDashDotDotLine(vh, lp, np, serie.lineStyle.width, lineColor);
isFinish = true;
break;
}
@@ -480,7 +480,7 @@ namespace XCharts
if ((isYAxis && ySmall) || (!isYAxis && xSmall))
{
if (serie.animation.CheckDetailBreak(np, isYAxis)) return false;
ChartHelper.DrawLine(vh, lp, np, serie.lineStyle.width, lineColor);
ChartDrawer.DrawLine(vh, lp, np, serie.lineStyle.width, lineColor);
if (serie.areaStyle.show)
{
DrawPolygonToZero(vh, lp, np, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
@@ -554,7 +554,7 @@ namespace XCharts
if ((isYAxis && tp1.y > lastDnPos.y) || (!isYAxis && tp1.x > lastDnPos.x) || dataIndex == 1 || IsValue())
{
isStart = true;
ChartHelper.DrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor);
ChartDrawer.DrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor);
}
}
else
@@ -563,21 +563,21 @@ namespace XCharts
{
if (np != nnp)
{
ChartHelper.DrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor);
ChartHelper.DrawTriangle(vh, upPos1, upPos2, dnPos, lineColor);
ChartDrawer.DrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor);
ChartDrawer.DrawTriangle(vh, upPos1, upPos2, dnPos, lineColor);
}
else ChartHelper.DrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor);
else ChartDrawer.DrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor);
}
else
{
if ((isYAxis && tp2.y < dnPos.y) || (!isYAxis && tp2.x < dnPos.x) || IsValue())
{
ChartHelper.DrawLine(vh, start, cp, serie.lineStyle.width, lineColor);
ChartDrawer.DrawLine(vh, start, cp, serie.lineStyle.width, lineColor);
}
else
{
ChartHelper.DrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor);
ChartHelper.DrawTriangle(vh, upPos1, upPos2, dnPos, lineColor);
ChartDrawer.DrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor);
ChartDrawer.DrawTriangle(vh, upPos1, upPos2, dnPos, lineColor);
i = segment;
}
}
@@ -604,7 +604,7 @@ namespace XCharts
if ((isYAxis && tp2.y > lastDnPos.y) || (!isYAxis && tp2.x > lastDnPos.x) || dataIndex == 1 || IsValue())
{
isStart = true;
ChartHelper.DrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor);
ChartDrawer.DrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor);
}
}
else
@@ -613,19 +613,19 @@ namespace XCharts
{
if (np != nnp)
{
ChartHelper.DrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor);
ChartHelper.DrawTriangle(vh, dnPos, upPos2, upPos1, lineColor);
ChartDrawer.DrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor);
ChartDrawer.DrawTriangle(vh, dnPos, upPos2, upPos1, lineColor);
}
else ChartHelper.DrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor);
else ChartDrawer.DrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor);
}
else
{
if ((isYAxis && tp1.y < dnPos.y) || (!isYAxis && tp1.x < dnPos.x) || IsValue())
ChartHelper.DrawLine(vh, start, cp, serie.lineStyle.width, lineColor);
ChartDrawer.DrawLine(vh, start, cp, serie.lineStyle.width, lineColor);
else
{
ChartHelper.DrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor);
ChartHelper.DrawTriangle(vh, dnPos, upPos2, upPos1, lineColor);
ChartDrawer.DrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor);
ChartDrawer.DrawTriangle(vh, dnPos, upPos2, upPos1, lineColor);
i = segment;
}
}
@@ -739,7 +739,7 @@ namespace XCharts
if ((isYAxis && ep.y > luPos.y) || (!isYAxis && ep.x > luPos.x))
{
var tp = isYAxis ? new Vector3(luPos.x, sp.y) : new Vector3(sp.x, luPos.y);
ChartHelper.DrawTriangle(vh, sp, luPos, tp, areaColor, areaToColor, areaToColor);
ChartDrawer.DrawTriangle(vh, sp, luPos, tp, areaColor, areaToColor, areaToColor);
break;
}
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
@@ -761,7 +761,7 @@ namespace XCharts
{
first = true;
var tp = isYAxis ? new Vector3(rdPos.x, ep.y) : new Vector3(ep.x, rdPos.y);
ChartHelper.DrawTriangle(vh, rdPos, tp, ep, areaToColor, areaToColor, areaColor);
ChartDrawer.DrawTriangle(vh, rdPos, tp, ep, areaToColor, areaToColor, areaColor);
sp = ep;
continue;
}
@@ -785,7 +785,7 @@ namespace XCharts
if ((isYAxis && ep.y > rdPos.y) || (!isYAxis && ep.x > rdPos.x))
{
var tp = isYAxis ? new Vector3(rdPos.x, sp.y) : new Vector3(sp.x, rdPos.y);
ChartHelper.DrawTriangle(vh, sp, rdPos, tp, areaColor, areaToColor, areaToColor);
ChartDrawer.DrawTriangle(vh, sp, rdPos, tp, areaColor, areaToColor, areaToColor);
break;
}
if (rdPos != Vector3.zero) DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
@@ -807,7 +807,7 @@ namespace XCharts
{
first = true;
var tp = isYAxis ? new Vector3(luPos.x, ep.y) : new Vector3(ep.x, luPos.y);
ChartHelper.DrawTriangle(vh, ep, luPos, tp, areaColor, areaToColor, areaToColor);
ChartDrawer.DrawTriangle(vh, ep, luPos, tp, areaColor, areaToColor, areaToColor);
sp = ep;
continue;
}
@@ -834,7 +834,7 @@ namespace XCharts
var isLessthan0 = (sp.x < zeroPos.x || ep.x < zeroPos.x);
diff = isLessthan0 ? -axis.axisLine.width : axis.axisLine.width;
if (isLessthan0) areaDiff = -areaDiff;
ChartHelper.DrawPolygon(vh, new Vector3(zeroPos.x + diff, sp.y), new Vector3(zeroPos.x + diff, ep.y), ep + areaDiff, sp + areaDiff, areaToColor, areaColor);
ChartDrawer.DrawPolygon(vh, new Vector3(zeroPos.x + diff, sp.y), new Vector3(zeroPos.x + diff, ep.y), ep + areaDiff, sp + areaDiff, areaToColor, areaColor);
}
else
{
@@ -843,11 +843,11 @@ namespace XCharts
if (isLessthan0) areaDiff = -areaDiff;
if (isLessthan0)
{
ChartHelper.DrawPolygon(vh, ep + areaDiff, sp + areaDiff, new Vector3(sp.x, zeroPos.y + diff), new Vector3(ep.x, zeroPos.y + diff), areaColor, areaToColor);
ChartDrawer.DrawPolygon(vh, ep + areaDiff, sp + areaDiff, new Vector3(sp.x, zeroPos.y + diff), new Vector3(ep.x, zeroPos.y + diff), areaColor, areaToColor);
}
else
{
ChartHelper.DrawPolygon(vh, sp + areaDiff, ep + areaDiff, new Vector3(ep.x, zeroPos.y + diff), new Vector3(sp.x, zeroPos.y + diff), areaColor, areaToColor);
ChartDrawer.DrawPolygon(vh, sp + areaDiff, ep + areaDiff, new Vector3(ep.x, zeroPos.y + diff), new Vector3(sp.x, zeroPos.y + diff), areaColor, areaToColor);
}
}
}
@@ -874,7 +874,7 @@ namespace XCharts
{
start = bezierPoints[i];
to = bezierPoints[i + 1];
ChartHelper.DrawLine(vh, start, to, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, start, to, lineWidth, lineColor);
}
return true;
}
@@ -891,8 +891,8 @@ namespace XCharts
bool isFinish = true;
if (dataIndex > 1)
{
ChartHelper.DrawTriangle(vh, smoothStartPosUp, startUp, lp, lineColor);
ChartHelper.DrawTriangle(vh, smoothStartPosDn, startDn, lp, lineColor);
ChartDrawer.DrawTriangle(vh, smoothStartPosUp, startUp, lp, lineColor);
ChartDrawer.DrawTriangle(vh, smoothStartPosDn, startDn, lp, lineColor);
}
for (int k = 1; k < bezierPoints.Count; k++)
{
@@ -907,8 +907,8 @@ namespace XCharts
diff = dir1v * lineWidth;
toUp = to - diff;
toDn = to + diff;
if (isYAxis) ChartHelper.DrawPolygon(vh, startDn, toDn, toUp, startUp, lineColor);
else ChartHelper.DrawPolygon(vh, startUp, toUp, toDn, startDn, lineColor);
if (isYAxis) ChartDrawer.DrawPolygon(vh, startDn, toDn, toUp, startUp, lineColor);
else ChartDrawer.DrawPolygon(vh, startUp, toUp, toDn, startDn, lineColor);
smoothPoints.Add(toUp);
smoothDownPoints.Add(toDn);
if (k == bezierPoints.Count - 1)
@@ -924,13 +924,13 @@ namespace XCharts
{
tnp = new Vector3(zeroPos.x + xAxis.axisLine.width, toDn.y);
tlp = new Vector3(zeroPos.x + xAxis.axisLine.width, startDn.y);
ChartHelper.DrawPolygon(vh, startDn, toDn, tnp, tlp, areaColor, areaToColor);
ChartDrawer.DrawPolygon(vh, startDn, toDn, tnp, tlp, areaColor, areaToColor);
}
else if (start.x < zeroPos.x && to.x < zeroPos.x)
{
tnp = new Vector3(zeroPos.x - xAxis.axisLine.width, toUp.y);
tlp = new Vector3(zeroPos.x - xAxis.axisLine.width, startUp.y);
ChartHelper.DrawPolygon(vh, tnp, tlp, startUp, toUp, areaToColor, areaColor);
ChartDrawer.DrawPolygon(vh, tnp, tlp, startUp, toUp, areaToColor, areaColor);
}
}
else
@@ -939,13 +939,13 @@ namespace XCharts
{
tnp = new Vector3(toDn.x, zeroPos.y + xAxis.axisLine.width);
tlp = new Vector3(startDn.x, zeroPos.y + xAxis.axisLine.width);
ChartHelper.DrawPolygon(vh, startDn, toDn, tnp, tlp, areaColor, areaToColor);
ChartDrawer.DrawPolygon(vh, startDn, toDn, tnp, tlp, areaColor, areaToColor);
}
else if (start.y < zeroPos.y && to.y < zeroPos.y)
{
tnp = new Vector3(toUp.x, zeroPos.y - xAxis.axisLine.width);
tlp = new Vector3(startUp.x, zeroPos.y - xAxis.axisLine.width);
ChartHelper.DrawPolygon(vh, tlp, tnp, toUp, startUp, areaToColor, areaColor);
ChartDrawer.DrawPolygon(vh, tlp, tnp, toUp, startUp, areaToColor, areaColor);
}
}
}
@@ -985,12 +985,12 @@ namespace XCharts
if (k < lastSmoothPoints.Count - 1)
{
tnp = lastSmoothPoints[lastCount - 1];
ChartHelper.DrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor);
ChartDrawer.DrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor);
while (lastCount < lastSmoothPoints.Count)
{
tlp = lastSmoothPoints[lastCount];
if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break;
ChartHelper.DrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor);
ChartDrawer.DrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor);
lastCount++;
tnp = tlp;
}
@@ -1002,7 +1002,7 @@ namespace XCharts
{
tlp = lastSmoothPoints[lastSmoothPoints.Count - 1];
if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break;
ChartHelper.DrawTriangle(vh, to, start, tlp, areaColor, areaColor, areaToColor);
ChartDrawer.DrawTriangle(vh, to, start, tlp, areaColor, areaColor, areaToColor);
start = to;
continue;
}
@@ -1012,7 +1012,7 @@ namespace XCharts
{
tlp = lastSmoothPoints[lastCount - 1];
if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break;
ChartHelper.DrawPolygon(vh, start, to, tnp, tlp, areaColor, areaToColor);
ChartDrawer.DrawPolygon(vh, start, to, tnp, tlp, areaColor, areaToColor);
lastCount++;
}
else
@@ -1020,12 +1020,12 @@ namespace XCharts
if (diff < 0)
{
tnp = lastSmoothPoints[lastCount - 1];
ChartHelper.DrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor);
ChartDrawer.DrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor);
while (diff < 0 && lastCount < lastSmoothPoints.Count)
{
tlp = lastSmoothPoints[lastCount];
if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break;
ChartHelper.DrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor);
ChartDrawer.DrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor);
lastCount++;
diff = isYAxis ? tlp.y - to.y : tlp.x - to.x;
tnp = tlp;
@@ -1035,7 +1035,7 @@ namespace XCharts
{
tlp = lastSmoothPoints[lastCount - 1];
if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break;
ChartHelper.DrawTriangle(vh, start, to, tlp, areaColor, areaColor, areaToColor);
ChartDrawer.DrawTriangle(vh, start, to, tlp, areaColor, areaColor, areaToColor);
}
}
start = to;
@@ -1046,7 +1046,7 @@ namespace XCharts
var p2 = lastSmoothPoints[lastSmoothPoints.Count - 1];
if (!serie.animation.CheckDetailBreak(p1, isYAxis))
{
ChartHelper.DrawTriangle(vh, p1, start, p2, areaToColor, areaColor, areaToColor);
ChartDrawer.DrawTriangle(vh, p1, start, p2, areaToColor, areaColor, areaToColor);
}
}
}
@@ -1077,15 +1077,15 @@ namespace XCharts
for (int i = 1; i < linePointList.Count; i++)
{
ep = linePointList[i];
ChartHelper.DrawLine(vh, sp, ep, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
sp = ep;
}
ChartHelper.DrawPolygon(vh, middle, lineWidth, lineColor);
ChartDrawer.DrawPolygon(vh, middle, lineWidth, lineColor);
}
else
{
if (dataIndex == 1) ChartHelper.DrawPolygon(vh, lp, lineWidth, lineColor);
ChartHelper.DrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor);
if (dataIndex == 1) ChartDrawer.DrawPolygon(vh, lp, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor);
}
if (serie.areaStyle.show)
{
@@ -1105,7 +1105,7 @@ namespace XCharts
{
ep = linePointList[i];
if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false;
ChartHelper.DrawLine(vh, sp, ep, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
if (serie.areaStyle.show)
{
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff);
@@ -1116,7 +1116,7 @@ namespace XCharts
if (nnp != np)
{
if (serie.animation.CheckDetailBreak(np, isYAxis)) return false;
ChartHelper.DrawPolygon(vh, np, lineWidth, lineColor);
ChartDrawer.DrawPolygon(vh, np, lineWidth, lineColor);
bool flag = ((isYAxis && nnp.x > np.x && np.x > zeroPos.x) || (!isYAxis && nnp.y > np.y && np.y > zeroPos.y));
if (serie.areaStyle.show && flag)
{
@@ -1142,7 +1142,7 @@ namespace XCharts
{
ep = linePointList[i];
if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false;
ChartHelper.DrawLine(vh, sp, ep, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
if (serie.areaStyle.show)
{
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff);
@@ -1150,7 +1150,7 @@ namespace XCharts
sp = ep;
}
if (serie.animation.CheckDetailBreak(middle1, isYAxis)) return false;
ChartHelper.DrawPolygon(vh, middle1, lineWidth, lineColor);
ChartDrawer.DrawPolygon(vh, middle1, lineWidth, lineColor);
if (serie.areaStyle.show && Vector3.Dot(middleZero - middle1, middle2 - middle1) <= 0)
{
DrawPolygonToZero(vh, middle1 - diff1, middle1 + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff);
@@ -1158,8 +1158,8 @@ namespace XCharts
}
else
{
if (dataIndex == 1) ChartHelper.DrawPolygon(vh, lp, lineWidth, lineColor);
ChartHelper.DrawLine(vh, lp + diff1, middle1 + diff1, lineWidth, lineColor);
if (dataIndex == 1) ChartDrawer.DrawPolygon(vh, lp, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, lp + diff1, middle1 + diff1, lineWidth, lineColor);
}
//draw middle1 to middle2
@@ -1170,10 +1170,10 @@ namespace XCharts
for (int i = 1; i < linePointList.Count; i++)
{
ep = linePointList[i];
ChartHelper.DrawLine(vh, sp, ep, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
sp = ep;
}
ChartHelper.DrawPolygon(vh, middle2, lineWidth, lineColor);
ChartDrawer.DrawPolygon(vh, middle2, lineWidth, lineColor);
if (serie.areaStyle.show && Vector3.Dot(middleZero - middle2, middle2 - middle1) >= 0)
{
DrawPolygonToZero(vh, middle2 - diff1, middle2 + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff);
@@ -1181,7 +1181,7 @@ namespace XCharts
}
else
{
ChartHelper.DrawLine(vh, middle1 + diff2, middle2 + diff2, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, middle1 + diff2, middle2 + diff2, lineWidth, lineColor);
}
//draw middle2 to np
if (Vector3.Distance(middle2, np) > 2 * lineWidth)
@@ -1192,7 +1192,7 @@ namespace XCharts
{
ep = linePointList[i];
if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false;
ChartHelper.DrawLine(vh, sp, ep, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
if (serie.areaStyle.show)
{
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff);
@@ -1200,7 +1200,7 @@ namespace XCharts
sp = ep;
}
if (serie.animation.CheckDetailBreak(np, isYAxis)) return false;
ChartHelper.DrawPolygon(vh, np, lineWidth, lineColor);
ChartDrawer.DrawPolygon(vh, np, lineWidth, lineColor);
if (serie.areaStyle.show)
{
DrawPolygonToZero(vh, np - diff1, np + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff);
@@ -1208,7 +1208,7 @@ namespace XCharts
}
else
{
ChartHelper.DrawLine(vh, middle1 + diff1, middle1 + diff1, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, middle1 + diff1, middle1 + diff1, lineWidth, lineColor);
}
break;
case LineType.StepEnd:
@@ -1227,7 +1227,7 @@ namespace XCharts
{
ep = linePointList[i];
if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false;
ChartHelper.DrawLine(vh, sp, ep, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
if (serie.areaStyle.show)
{
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff);
@@ -1235,7 +1235,7 @@ namespace XCharts
sp = ep;
}
if (serie.animation.CheckDetailBreak(middle, isYAxis)) return false;
ChartHelper.DrawPolygon(vh, middle, lineWidth, lineColor);
ChartDrawer.DrawPolygon(vh, middle, lineWidth, lineColor);
if (serie.areaStyle.show && Vector3.Dot(np - middle, middleZero - middle) <= 0)
{
DrawPolygonToZero(vh, middle - diff1, middle + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff);
@@ -1243,8 +1243,8 @@ namespace XCharts
}
else
{
if (dataIndex == 1) ChartHelper.DrawPolygon(vh, lp, lineWidth, lineColor);
ChartHelper.DrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor);
if (dataIndex == 1) ChartDrawer.DrawPolygon(vh, lp, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor);
}
if (Vector3.Distance(middle, np) > 2 * lineWidth)
@@ -1254,14 +1254,14 @@ namespace XCharts
for (int i = 1; i < linePointList.Count; i++)
{
ep = linePointList[i];
ChartHelper.DrawLine(vh, sp, ep, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
sp = ep;
}
if (nnp != np) ChartHelper.DrawPolygon(vh, np, lineWidth, lineColor);
if (nnp != np) ChartDrawer.DrawPolygon(vh, np, lineWidth, lineColor);
}
else
{
ChartHelper.DrawLine(vh, middle + diff2, np + diff2, lineWidth, lineColor);
ChartDrawer.DrawLine(vh, middle + diff2, np + diff2, lineWidth, lineColor);
}
bool flag2 = ((isYAxis && middle.x > np.x && np.x > zeroPos.x) || (!isYAxis && middle.y > np.y && np.y > zeroPos.y));
if (serie.areaStyle.show && flag2)