mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-14 20:00:09 +00:00
增加Serie的clip参数控制是否超出坐标系外裁剪
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
# 更新日志
|
||||
|
||||
* (2020.02.10) 增加`Serie`的`clip`参数控制是否超出坐标系外裁剪(只适用于折线图、柱状图、散点图)
|
||||
* (2020.02.08) 增加`SerieSymbol`的`gap`参数控制图形标记的外留白距离
|
||||
* (2020.01.26) 增加`TextLimit`组件可以设置`AxisLabel`的文本自适应
|
||||
* (2020.01.20) 优化`Tooltip`设置`itemFormatter`时显示系列颜色
|
||||
|
||||
@@ -460,6 +460,7 @@
|
||||
* `Min`:取过滤点的最小值。
|
||||
* `Sum`:取过滤点之和。
|
||||
* `sampleAverage`:设定的采样平均值。当 `sampleType` 为 `Peak` 时,用于和过滤数据的平均值做对比是取最大值还是最小值。默认为`0`时会实时计算所有数据的平均值。
|
||||
* `clip`:是否裁剪超出坐标系部分的图形。
|
||||
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
|
||||
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||
* `lineType`:折线图样式类型。支持以下十种类型:
|
||||
@@ -502,6 +503,7 @@
|
||||
* `barCategoryGap`:同一系列的柱间距离,默认为类目间距的20%,可设固定值。在同一坐标系上,此属性会被多个 `'bar'` 系列共享。此属性应设置于此坐标系中最后一个 `'bar'` 系列上才会生效,并且是对此坐标系中所有 `'bar'` 系列生效。
|
||||
* `barZebraWidth`:斑马线的粗细。`barType` 为 `Zebra` 时有效。
|
||||
* `barZebraGap`:斑马线的间距。`barType` 为 `Zebra` 时有效。
|
||||
* `clip`:是否裁剪超出坐标系部分的图形。
|
||||
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||
* `itemStyle`:柱条样式 [ItemStyle](#ItemStyle)。
|
||||
* `areaStyle`:区域填充样式 [AreaStyle](#AreaStyle)。
|
||||
@@ -549,6 +551,7 @@
|
||||
* `show`:系列是否显示在图表上。
|
||||
* `type`:`Scatter`。
|
||||
* `name`:系列名称。用于 `tooltip` 的显示,`legend` 的图例筛选。
|
||||
* `clip`:是否裁剪超出坐标系部分的图形。
|
||||
* `symbol`:标记的图形 [SerieSymbol](#SerieSymbol)。
|
||||
* `label`:图形上的文本标签 [SerieLabel](#SerieLabel),可用于说明图形的一些数据信息,比如值,名称等。
|
||||
* `emphasis`:高亮样式 [Emphasis](#Emphasis)。
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace XCharts
|
||||
SerializedProperty m_GaugeAxis = prop.FindPropertyRelative("m_GaugeAxis");
|
||||
SerializedProperty m_GaugePointer = prop.FindPropertyRelative("m_GaugePointer");
|
||||
SerializedProperty m_TitleStyle = prop.FindPropertyRelative("m_TitleStyle");
|
||||
SerializedProperty m_Clip = prop.FindPropertyRelative("m_Clip");
|
||||
SerializedProperty m_Datas = prop.FindPropertyRelative("m_Data");
|
||||
|
||||
int index = InitToggle(prop);
|
||||
@@ -118,6 +119,8 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_SampleAverage);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Clip);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||
EditorGUI.PropertyField(drawRect, m_LineStyle);
|
||||
@@ -159,6 +162,8 @@ namespace XCharts
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_BarZebraGap);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Clip);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||
EditorGUI.PropertyField(drawRect, m_ItemStyle);
|
||||
@@ -194,6 +199,8 @@ namespace XCharts
|
||||
break;
|
||||
case SerieType.Scatter:
|
||||
case SerieType.EffectScatter:
|
||||
EditorGUI.PropertyField(drawRect, m_Clip);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Symbol);
|
||||
drawRect.y += EditorGUI.GetPropertyHeight(m_Symbol);
|
||||
EditorGUI.PropertyField(drawRect, m_Label);
|
||||
@@ -417,7 +424,7 @@ namespace XCharts
|
||||
switch (serieType)
|
||||
{
|
||||
case SerieType.Line:
|
||||
height += 13 * EditorGUIUtility.singleLineHeight + 12 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 14 * EditorGUIUtility.singleLineHeight + 13 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_LineArrow"));
|
||||
@@ -428,7 +435,7 @@ namespace XCharts
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Animation"));
|
||||
break;
|
||||
case SerieType.Bar:
|
||||
height += 16 * EditorGUIUtility.singleLineHeight + 15 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 17 * EditorGUIUtility.singleLineHeight + 16 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_ItemStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_AreaStyle"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||
@@ -450,7 +457,7 @@ namespace XCharts
|
||||
break;
|
||||
case SerieType.Scatter:
|
||||
case SerieType.EffectScatter:
|
||||
height += 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Symbol"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Label"));
|
||||
height += EditorGUI.GetPropertyHeight(prop.FindPropertyRelative("m_Emphasis"));
|
||||
|
||||
@@ -556,5 +556,34 @@ namespace XCharts
|
||||
OnLegendButtonClick(legendIndex, legendName, show);
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 坐标是否在图表范围内
|
||||
/// </summary>
|
||||
/// <param name="local"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInChart(Vector2 local)
|
||||
{
|
||||
if (local.x < 0 || local.x > chartWidth ||
|
||||
local.y < 0 || local.y > chartHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Vector3 ClampInChart(Vector3 pos)
|
||||
{
|
||||
if (IsInChart(pos)) return pos;
|
||||
else
|
||||
{
|
||||
var np = new Vector3(pos.x, pos.y);
|
||||
if (np.x < 0) np.x = 0;
|
||||
if (np.x > chartWidth) np.x = chartWidth;
|
||||
if (np.y < 0) np.y = 0;
|
||||
if (np.y > chartHeight) np.y = chartHeight;
|
||||
return np;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,6 +246,7 @@ namespace XCharts
|
||||
[SerializeField] [Range(1, 10)] private int m_ShowDataDimension;
|
||||
[SerializeField] private bool m_ShowDataName;
|
||||
[SerializeField] private bool m_ShowDataIcon;
|
||||
[SerializeField] private bool m_Clip = false;
|
||||
|
||||
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
||||
|
||||
@@ -498,9 +499,13 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// 数据项里的数据维数。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public int showDataDimension { get { return m_ShowDataDimension; } }
|
||||
/// <summary>
|
||||
/// If clip the overflow on the coordinate system.
|
||||
/// 是否裁剪超出坐标系部分的图形。
|
||||
/// </summary>
|
||||
public bool clip { get { return m_Clip; } set { m_Clip = value; } }
|
||||
/// <summary>
|
||||
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||
/// </summary>
|
||||
public List<SerieData> data { get { return m_Data; } }
|
||||
|
||||
@@ -179,6 +179,19 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否有需裁剪的serie。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal bool IsAnyClipSerie()
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
{
|
||||
if (serie.clip) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
internal bool IsAnyUpdateAnimationSerie()
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace XCharts
|
||||
titleText.text = m_Title.text.Replace("\\n", "\n");
|
||||
|
||||
Text subText = ChartHelper.AddTextObject(s_TitleObjectName + "_sub", titleObject.transform,
|
||||
m_ThemeInfo.font, m_ThemeInfo.titleTextColor, anchor, anchorMin, anchorMax, pivot,
|
||||
m_ThemeInfo.font, m_ThemeInfo.titleSubTextColor, anchor, anchorMin, anchorMax, pivot,
|
||||
new Vector2(titleWid, m_Title.subTextStyle.fontSize), m_Title.subTextStyle.fontSize,
|
||||
m_Title.subTextStyle.rotate, m_Title.subTextStyle.fontStyle);
|
||||
|
||||
@@ -712,9 +712,8 @@ namespace XCharts
|
||||
{
|
||||
}
|
||||
|
||||
private void DrawBackground(VertexHelper vh)
|
||||
protected virtual void DrawBackground(VertexHelper vh)
|
||||
{
|
||||
// draw bg
|
||||
Vector3 p1 = new Vector3(0, chartHeight);
|
||||
Vector3 p2 = new Vector3(chartWidth, chartHeight);
|
||||
Vector3 p3 = new Vector3(chartWidth, 0);
|
||||
|
||||
@@ -81,10 +81,61 @@ namespace XCharts
|
||||
base.DrawChart(vh);
|
||||
DrawCoordinate(vh);
|
||||
DrawSerie(vh);
|
||||
DrawAxisTick(vh);
|
||||
DrawDataZoomSlider(vh);
|
||||
DrawVisualMap(vh);
|
||||
}
|
||||
|
||||
protected override void DrawBackground(VertexHelper vh)
|
||||
{
|
||||
if (m_Series.IsAnyClipSerie())
|
||||
{
|
||||
var xLineDiff = xAxis0.axisLine.width;
|
||||
var yLineDiff = yAxis0.axisLine.width;
|
||||
var xSplitDiff = xAxis0.axisLine.width;
|
||||
var ySplitDiff = yAxis0.axisLine.width;
|
||||
|
||||
var cpty = coordinateY + coordinateHeight + xSplitDiff;
|
||||
var cp1 = new Vector3(coordinateX - yLineDiff, coordinateY - xLineDiff);
|
||||
var cp2 = new Vector3(coordinateX - yLineDiff, cpty);
|
||||
var cp3 = new Vector3(coordinateX + coordinateWidth + ySplitDiff, cpty);
|
||||
var cp4 = new Vector3(coordinateX + coordinateWidth + ySplitDiff, coordinateY - xLineDiff);
|
||||
ChartDrawer.DrawPolygon(vh, cp1, cp2, cp3, cp4, m_ThemeInfo.backgroundColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.DrawBackground(vh);
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawClip(VertexHelper vh)
|
||||
{
|
||||
if (!m_Series.IsAnyClipSerie()) return;
|
||||
var xLineDiff = xAxis0.axisLine.width;
|
||||
var yLineDiff = yAxis0.axisLine.width;
|
||||
var xSplitDiff = xAxis0.axisLine.width;
|
||||
var ySplitDiff = yAxis0.axisLine.width;
|
||||
var lp1 = new Vector3(0, 0);
|
||||
var lp2 = new Vector3(0, chartHeight);
|
||||
var lp3 = new Vector3(coordinateX - yLineDiff, chartHeight);
|
||||
var lp4 = new Vector3(coordinateX - yLineDiff, 0);
|
||||
ChartDrawer.DrawPolygon(vh, lp1, lp2, lp3, lp4, m_ThemeInfo.backgroundColor);
|
||||
var rp1 = new Vector3(coordinateX + coordinateWidth + ySplitDiff, 0);
|
||||
var rp2 = new Vector3(coordinateX + coordinateWidth + ySplitDiff, chartHeight);
|
||||
var rp3 = new Vector3(chartWidth, chartHeight);
|
||||
var rp4 = new Vector3(chartWidth, 0);
|
||||
ChartDrawer.DrawPolygon(vh, rp1, rp2, rp3, rp4, m_ThemeInfo.backgroundColor);
|
||||
var up1 = new Vector3(coordinateX - yLineDiff, coordinateY + coordinateHeight + ySplitDiff);
|
||||
var up2 = new Vector3(coordinateX - yLineDiff, chartHeight);
|
||||
var up3 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, chartHeight);
|
||||
var up4 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, coordinateY + coordinateHeight + ySplitDiff);
|
||||
ChartDrawer.DrawPolygon(vh, up1, up2, up3, up4, m_ThemeInfo.backgroundColor);
|
||||
var dp1 = new Vector3(coordinateX - yLineDiff, 0);
|
||||
var dp2 = new Vector3(coordinateX - yLineDiff, coordinateY - xLineDiff);
|
||||
var dp3 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, coordinateY - xLineDiff);
|
||||
var dp4 = new Vector3(coordinateX + coordinateWidth + xSplitDiff, 0);
|
||||
ChartDrawer.DrawPolygon(vh, dp1, dp2, dp3, dp4, m_ThemeInfo.backgroundColor);
|
||||
}
|
||||
|
||||
protected virtual void DrawSerie(VertexHelper vh)
|
||||
{
|
||||
@@ -130,6 +181,7 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
}
|
||||
DrawClip(vh);
|
||||
DrawLabelBackground(vh);
|
||||
DrawLinePoint(vh);
|
||||
DrawLineArrow(vh);
|
||||
@@ -858,11 +910,11 @@ namespace XCharts
|
||||
DrawGrid(vh);
|
||||
for (int i = 0; i < m_XAxises.Count; i++)
|
||||
{
|
||||
DrawXAxisTickAndSplit(vh, i, m_XAxises[i]);
|
||||
DrawXAxisSplit(vh, i, m_XAxises[i]);
|
||||
}
|
||||
for (int i = 0; i < m_YAxises.Count; i++)
|
||||
{
|
||||
DrawYAxisTickAndSplit(vh, i, m_YAxises[i]);
|
||||
DrawYAxisSplit(vh, i, m_YAxises[i]);
|
||||
}
|
||||
for (int i = 0; i < m_XAxises.Count; i++)
|
||||
{
|
||||
@@ -874,6 +926,18 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAxisTick(VertexHelper vh)
|
||||
{
|
||||
for (int i = 0; i < m_XAxises.Count; i++)
|
||||
{
|
||||
DrawXAxisTick(vh, i, m_XAxises[i]);
|
||||
}
|
||||
for (int i = 0; i < m_YAxises.Count; i++)
|
||||
{
|
||||
DrawYAxisTick(vh, i, m_YAxises[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGrid(VertexHelper vh)
|
||||
{
|
||||
if (m_Grid.show && m_Grid.backgroundColor != Color.clear)
|
||||
@@ -886,7 +950,7 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawYAxisTickAndSplit(VertexHelper vh, int yAxisIndex, YAxis yAxis)
|
||||
private void DrawYAxisSplit(VertexHelper vh, int yAxisIndex, YAxis yAxis)
|
||||
{
|
||||
if (yAxis.NeedShowSplit())
|
||||
{
|
||||
@@ -897,7 +961,6 @@ namespace XCharts
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var scaleWidth = yAxis.GetScaleWidth(coordinateHeight, i, m_DataZoom);
|
||||
float pX = 0;
|
||||
float pY = totalWidth;
|
||||
if (yAxis.boundaryGap && yAxis.axisTick.alignWithLabel)
|
||||
{
|
||||
@@ -919,9 +982,32 @@ namespace XCharts
|
||||
new Vector3(coordinateX + coordinateWidth, pY), m_ThemeInfo.axisSplitLineColor);
|
||||
}
|
||||
}
|
||||
totalWidth += scaleWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawYAxisTick(VertexHelper vh, int yAxisIndex, YAxis yAxis)
|
||||
{
|
||||
if (yAxis.NeedShowSplit())
|
||||
{
|
||||
var size = yAxis.GetScaleNumber(coordinateWidth, m_DataZoom);
|
||||
var totalWidth = coordinateY;
|
||||
var xAxis = m_XAxises[yAxisIndex];
|
||||
var zeroPos = new Vector3(coordinateX + xAxis.runtimeZeroXOffset, coordinateY + yAxis.runtimeZeroYOffset);
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var scaleWidth = yAxis.GetScaleWidth(coordinateHeight, i, m_DataZoom);
|
||||
float pX = 0;
|
||||
float pY = totalWidth;
|
||||
if (yAxis.boundaryGap && yAxis.axisTick.alignWithLabel)
|
||||
{
|
||||
pY -= scaleWidth / 2;
|
||||
}
|
||||
if (yAxis.axisTick.show)
|
||||
{
|
||||
var startX = coordinateX + (yAxis.axisLine.onZero ? m_XAxises[yAxisIndex].runtimeZeroXOffset : 0);
|
||||
startX -= yAxis.axisLine.width;
|
||||
if (yAxis.IsValue() && yAxisIndex > 0) startX += coordinateWidth;
|
||||
bool inside = yAxis.axisTick.inside;
|
||||
if ((inside && yAxisIndex == 0) || (!inside && yAxisIndex == 1))
|
||||
@@ -940,7 +1026,7 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawXAxisTickAndSplit(VertexHelper vh, int xAxisIndex, XAxis xAxis)
|
||||
private void DrawXAxisSplit(VertexHelper vh, int xAxisIndex, XAxis xAxis)
|
||||
{
|
||||
if (xAxis.NeedShowSplit())
|
||||
{
|
||||
@@ -973,9 +1059,32 @@ namespace XCharts
|
||||
new Vector3(pX, coordinateY + coordinateHeight), m_ThemeInfo.axisSplitLineColor);
|
||||
}
|
||||
}
|
||||
totalWidth += scaleWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawXAxisTick(VertexHelper vh, int xAxisIndex, XAxis xAxis)
|
||||
{
|
||||
if (xAxis.NeedShowSplit())
|
||||
{
|
||||
var size = xAxis.GetScaleNumber(coordinateWidth, m_DataZoom);
|
||||
var totalWidth = coordinateX;
|
||||
var yAxis = m_YAxises[xAxisIndex];
|
||||
var zeroPos = new Vector3(coordinateX, coordinateY + yAxis.runtimeZeroYOffset);
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
var scaleWidth = xAxis.GetScaleWidth(coordinateWidth, i, m_DataZoom);
|
||||
float pX = totalWidth;
|
||||
float pY = 0;
|
||||
if (xAxis.boundaryGap && xAxis.axisTick.alignWithLabel)
|
||||
{
|
||||
pX -= scaleWidth / 2;
|
||||
}
|
||||
if (xAxis.axisTick.show)
|
||||
{
|
||||
var startY = coordinateY + (xAxis.axisLine.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
|
||||
startY -= xAxis.axisLine.width;
|
||||
if (xAxis.IsValue() && xAxisIndex > 0) startY += coordinateHeight;
|
||||
bool inside = xAxis.axisTick.inside;
|
||||
if ((inside && xAxisIndex == 0) || (!inside && xAxisIndex == 1))
|
||||
@@ -1643,6 +1752,71 @@ namespace XCharts
|
||||
RefreshDataZoomLabel();
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
protected void CheckClipAndDrawPolygon(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4,
|
||||
Color32 color, bool clip)
|
||||
{
|
||||
if (!IsInChart(p1) || !IsInChart(p2) || !IsInChart(p3) || !IsInChart(p4)) return;
|
||||
CheckClipAndDrawPolygon(vh, p1, p2, p3, p4, color, color, clip);
|
||||
}
|
||||
|
||||
protected void CheckClipAndDrawPolygon(VertexHelper vh, Vector3 p, float radius, Color32 color,
|
||||
bool clip, bool vertical = true)
|
||||
{
|
||||
if (!IsInChart(p)) return;
|
||||
if (!clip || (clip && (IsInCooridate(p))))
|
||||
ChartDrawer.DrawPolygon(vh, p, radius, color, vertical);
|
||||
}
|
||||
|
||||
protected void CheckClipAndDrawPolygon(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4,
|
||||
Color32 startColor, Color32 toColor, bool clip)
|
||||
{
|
||||
p1 = ClampInChart(p1);
|
||||
p2 = ClampInChart(p2);
|
||||
p3 = ClampInChart(p3);
|
||||
p4 = ClampInChart(p4);
|
||||
//if (!IsInChart(p1) || !IsInChart(p2) || !IsInChart(p3) || !IsInChart(p4)) return;
|
||||
if (!clip || (clip && (IsInCooridate(p1) || IsInCooridate(p2) || IsInCooridate(p3) || IsInCooridate(p4))))
|
||||
ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, startColor, toColor);
|
||||
}
|
||||
|
||||
protected void CheckClipAndDrawTriangle(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3,
|
||||
Color32 color, bool clip)
|
||||
{
|
||||
CheckClipAndDrawTriangle(vh, p1, p2, p3, color, color, color, clip);
|
||||
}
|
||||
|
||||
protected void CheckClipAndDrawTriangle(VertexHelper vh, Vector3 p1,
|
||||
Vector3 p2, Vector3 p3, Color32 color, Color32 color2, Color32 color3, bool clip)
|
||||
{
|
||||
if (!IsInChart(p1) || !IsInChart(p2) || !IsInChart(p3)) return;
|
||||
if (!clip || (clip && (IsInCooridate(p1) || IsInCooridate(p2) || IsInCooridate(p3))))
|
||||
ChartDrawer.DrawTriangle(vh, p1, p2, p3, color, color2, color3);
|
||||
}
|
||||
|
||||
protected void CheckClipAndDrawLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size,
|
||||
Color32 color, bool clip)
|
||||
{
|
||||
if (!IsInChart(p1) || !IsInChart(p2)) return;
|
||||
if (!clip || (clip && (IsInCooridate(p1) || IsInCooridate(p2))))
|
||||
ChartDrawer.DrawLine(vh, p1, p2, size, color);
|
||||
}
|
||||
|
||||
protected void CheckClipAndDrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
|
||||
float tickness, Vector3 pos, Color color, float gap, bool clip)
|
||||
{
|
||||
if (!IsInChart(pos)) return;
|
||||
if (!clip || (clip && (IsInCooridate(pos))))
|
||||
DrawSymbol(vh, type, symbolSize, tickness, pos, color, gap);
|
||||
}
|
||||
|
||||
protected void CheckClipAndDrawZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size,
|
||||
float zebraWidth, float zebraGap, Color32 color, bool clip)
|
||||
{
|
||||
p1 = ClampInChart(p1);
|
||||
p2 = ClampInChart(p2);
|
||||
ChartDrawer.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,11 +96,12 @@ namespace XCharts
|
||||
{
|
||||
p1 = (p4 + p1) / 2;
|
||||
p2 = (p2 + p3) / 2;
|
||||
ChartDrawer.DrawZebraLine(vh, p1, p2, barWidth / 2, serie.barZebraWidth, serie.barZebraGap, areaColor);
|
||||
CheckClipAndDrawZebraLine(vh, p1, p2, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
|
||||
areaColor, serie.clip);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartDrawer.DrawPolygon(vh, p4, p1, p2, p3, areaColor, areaToColor);
|
||||
CheckClipAndDrawPolygon(vh, p4, p1, p2, p3, areaColor, areaToColor, serie.clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,11 +219,12 @@ namespace XCharts
|
||||
{
|
||||
p1 = (p4 + p1) / 2;
|
||||
p2 = (p2 + p3) / 2;
|
||||
ChartDrawer.DrawZebraLine(vh, p1, p2, barWidth / 2, serie.barZebraWidth, serie.barZebraGap, areaColor);
|
||||
CheckClipAndDrawZebraLine(vh, p1, p2, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
|
||||
areaColor, serie.clip);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartDrawer.DrawPolygon(vh, p4, p1, p2, p3, areaColor, areaToColor);
|
||||
CheckClipAndDrawPolygon(vh, p4, p1, p2, p3, areaColor, areaToColor, serie.clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace XCharts
|
||||
{
|
||||
protected void DrawLinePoint(VertexHelper vh)
|
||||
{
|
||||
var clip = m_Series.IsAnyClipSerie();
|
||||
for (int n = 0; n < m_Series.Count; n++)
|
||||
{
|
||||
var serie = m_Series.GetSerie(n);
|
||||
@@ -37,7 +38,8 @@ namespace XCharts
|
||||
float symbolSize = highlight ? serie.symbol.selectedSize : serie.symbol.size;
|
||||
var symbolColor = serie.GetSymbolColor(m_ThemeInfo, n, highlight);
|
||||
symbolSize = serie.animation.GetSysmbolSize(symbolSize);
|
||||
DrawSymbol(vh, serie.symbol.type, symbolSize, serie.lineStyle.width, p, symbolColor, serie.symbol.gap);
|
||||
CheckClipAndDrawSymbol(vh, serie.symbol.type, symbolSize, serie.lineStyle.width, p, symbolColor,
|
||||
serie.symbol.gap, clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -537,7 +539,7 @@ namespace XCharts
|
||||
if ((isYAxis && ySmall) || (!isYAxis && xSmall))
|
||||
{
|
||||
if (serie.animation.CheckDetailBreak(np, isYAxis)) return false;
|
||||
ChartDrawer.DrawLine(vh, lp, np, serie.lineStyle.width, lineColor);
|
||||
CheckClipAndDrawLine(vh, lp, np, serie.lineStyle.width, lineColor, serie.clip);
|
||||
if (serie.areaStyle.show)
|
||||
{
|
||||
DrawPolygonToZero(vh, lp, np, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
||||
@@ -607,7 +609,7 @@ namespace XCharts
|
||||
if ((isYAxis && tp1.y > lastDnPos.y) || (!isYAxis && tp1.x > lastDnPos.x) || dataIndex == 1 || IsValue())
|
||||
{
|
||||
isStart = true;
|
||||
ChartDrawer.DrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -616,21 +618,21 @@ namespace XCharts
|
||||
{
|
||||
if (np != nnp)
|
||||
{
|
||||
ChartDrawer.DrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor);
|
||||
ChartDrawer.DrawTriangle(vh, upPos1, upPos2, dnPos, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor, serie.clip);
|
||||
CheckClipAndDrawTriangle(vh, upPos1, upPos2, dnPos, lineColor, serie.clip);
|
||||
}
|
||||
else ChartDrawer.DrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor);
|
||||
else CheckClipAndDrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor, serie.clip);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((isYAxis && tp2.y < dnPos.y) || (!isYAxis && tp2.x < dnPos.x) || IsValue())
|
||||
{
|
||||
ChartDrawer.DrawLine(vh, start, cp, serie.lineStyle.width, lineColor);
|
||||
CheckClipAndDrawLine(vh, start, cp, serie.lineStyle.width, lineColor, serie.clip);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartDrawer.DrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor);
|
||||
ChartDrawer.DrawTriangle(vh, upPos1, upPos2, dnPos, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, ltp1, upPos1, dnPos, ltp2, lineColor, serie.clip);
|
||||
CheckClipAndDrawTriangle(vh, upPos1, upPos2, dnPos, lineColor, serie.clip);
|
||||
i = segment;
|
||||
}
|
||||
}
|
||||
@@ -657,7 +659,7 @@ namespace XCharts
|
||||
if ((isYAxis && tp2.y > lastDnPos.y) || (!isYAxis && tp2.x > lastDnPos.x) || dataIndex == 1 || IsValue())
|
||||
{
|
||||
isStart = true;
|
||||
ChartDrawer.DrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, stPos1, tp1, tp2, stPos2, lineColor, serie.clip);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -666,19 +668,19 @@ namespace XCharts
|
||||
{
|
||||
if (np != nnp)
|
||||
{
|
||||
ChartDrawer.DrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor);
|
||||
ChartDrawer.DrawTriangle(vh, dnPos, upPos2, upPos1, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor, serie.clip);
|
||||
CheckClipAndDrawTriangle(vh, dnPos, upPos2, upPos1, lineColor, serie.clip);
|
||||
}
|
||||
else ChartDrawer.DrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor);
|
||||
else CheckClipAndDrawPolygon(vh, ltp1, upPos1, upPos2, ltp2, lineColor, serie.clip);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((isYAxis && tp1.y < dnPos.y) || (!isYAxis && tp1.x < dnPos.x) || IsValue())
|
||||
ChartDrawer.DrawLine(vh, start, cp, serie.lineStyle.width, lineColor);
|
||||
CheckClipAndDrawLine(vh, start, cp, serie.lineStyle.width, lineColor, serie.clip);
|
||||
else
|
||||
{
|
||||
ChartDrawer.DrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor);
|
||||
ChartDrawer.DrawTriangle(vh, dnPos, upPos2, upPos1, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, ltp1, dnPos, upPos1, ltp2, lineColor, serie.clip);
|
||||
CheckClipAndDrawTriangle(vh, dnPos, upPos2, upPos1, lineColor, serie.clip);
|
||||
i = segment;
|
||||
}
|
||||
}
|
||||
@@ -792,7 +794,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);
|
||||
ChartDrawer.DrawTriangle(vh, sp, luPos, tp, areaColor, areaToColor, areaToColor);
|
||||
CheckClipAndDrawTriangle(vh, sp, luPos, tp, areaColor, areaToColor, areaToColor, serie.clip);
|
||||
break;
|
||||
}
|
||||
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
||||
@@ -814,7 +816,7 @@ namespace XCharts
|
||||
{
|
||||
first = true;
|
||||
var tp = isYAxis ? new Vector3(rdPos.x, ep.y) : new Vector3(ep.x, rdPos.y);
|
||||
ChartDrawer.DrawTriangle(vh, rdPos, tp, ep, areaToColor, areaToColor, areaColor);
|
||||
CheckClipAndDrawTriangle(vh, rdPos, tp, ep, areaToColor, areaToColor, areaColor, serie.clip);
|
||||
sp = ep;
|
||||
continue;
|
||||
}
|
||||
@@ -838,7 +840,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);
|
||||
ChartDrawer.DrawTriangle(vh, sp, rdPos, tp, areaColor, areaToColor, areaToColor);
|
||||
CheckClipAndDrawTriangle(vh, sp, rdPos, tp, areaColor, areaToColor, areaToColor, serie.clip);
|
||||
break;
|
||||
}
|
||||
if (rdPos != Vector3.zero) DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, Vector3.zero);
|
||||
@@ -860,7 +862,7 @@ namespace XCharts
|
||||
{
|
||||
first = true;
|
||||
var tp = isYAxis ? new Vector3(luPos.x, ep.y) : new Vector3(ep.x, luPos.y);
|
||||
ChartDrawer.DrawTriangle(vh, ep, luPos, tp, areaColor, areaToColor, areaToColor);
|
||||
CheckClipAndDrawTriangle(vh, ep, luPos, tp, areaColor, areaToColor, areaToColor, serie.clip);
|
||||
sp = ep;
|
||||
continue;
|
||||
}
|
||||
@@ -964,7 +966,7 @@ namespace XCharts
|
||||
{
|
||||
start = bezierPoints[i];
|
||||
to = bezierPoints[i + 1];
|
||||
ChartDrawer.DrawLine(vh, start, to, lineWidth, lineColor);
|
||||
CheckClipAndDrawLine(vh, start, to, lineWidth, lineColor, serie.clip);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -980,8 +982,8 @@ namespace XCharts
|
||||
bool isFinish = true;
|
||||
if (dataIndex > 1)
|
||||
{
|
||||
ChartDrawer.DrawTriangle(vh, smoothStartPosUp, startUp, lp, lineColor);
|
||||
ChartDrawer.DrawTriangle(vh, smoothStartPosDn, startDn, lp, lineColor);
|
||||
CheckClipAndDrawTriangle(vh, smoothStartPosUp, startUp, lp, lineColor, serie.clip);
|
||||
CheckClipAndDrawTriangle(vh, smoothStartPosDn, startDn, lp, lineColor, serie.clip);
|
||||
smoothPoints.Add(smoothStartPosUp);
|
||||
smoothDownPoints.Add(smoothStartPosDn);
|
||||
}
|
||||
@@ -1003,8 +1005,8 @@ namespace XCharts
|
||||
diff = dir1v * lineWidth;
|
||||
toUp = to - diff;
|
||||
toDn = to + diff;
|
||||
if (isYAxis) ChartDrawer.DrawPolygon(vh, startDn, toDn, toUp, startUp, lineColor);
|
||||
else ChartDrawer.DrawPolygon(vh, startUp, toUp, toDn, startDn, lineColor);
|
||||
if (isYAxis) CheckClipAndDrawPolygon(vh, startDn, toDn, toUp, startUp, lineColor, serie.clip);
|
||||
else CheckClipAndDrawPolygon(vh, startUp, toUp, toDn, startDn, lineColor, serie.clip);
|
||||
smoothPoints.Add(toUp);
|
||||
smoothDownPoints.Add(toDn);
|
||||
if (k == bezierPoints.Count - 1)
|
||||
@@ -1024,13 +1026,13 @@ namespace XCharts
|
||||
{
|
||||
tnp = new Vector3(zeroPos.x + xAxis.axisLine.width, toDn.y);
|
||||
tlp = new Vector3(zeroPos.x + xAxis.axisLine.width, startDn.y);
|
||||
ChartDrawer.DrawPolygon(vh, startDn, toDn, tnp, tlp, areaColor, areaToColor);
|
||||
CheckClipAndDrawPolygon(vh, startDn, toDn, tnp, tlp, areaColor, areaToColor, serie.clip);
|
||||
}
|
||||
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);
|
||||
ChartDrawer.DrawPolygon(vh, tnp, tlp, startUp, toUp, areaToColor, areaColor);
|
||||
CheckClipAndDrawPolygon(vh, tnp, tlp, startUp, toUp, areaToColor, areaColor, serie.clip);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1039,13 +1041,13 @@ namespace XCharts
|
||||
{
|
||||
tnp = new Vector3(toDn.x, zeroPos.y + xAxis.axisLine.width);
|
||||
tlp = new Vector3(startDn.x, zeroPos.y + xAxis.axisLine.width);
|
||||
ChartDrawer.DrawPolygon(vh, startDn, toDn, tnp, tlp, areaColor, areaToColor);
|
||||
CheckClipAndDrawPolygon(vh, startDn, toDn, tnp, tlp, areaColor, areaToColor, serie.clip);
|
||||
}
|
||||
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);
|
||||
ChartDrawer.DrawPolygon(vh, tlp, tnp, toUp, startUp, areaToColor, areaColor);
|
||||
CheckClipAndDrawPolygon(vh, tlp, tnp, toUp, startUp, areaToColor, areaColor, serie.clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1085,12 +1087,12 @@ namespace XCharts
|
||||
if (k < lastSmoothPoints.Count - 1)
|
||||
{
|
||||
tnp = lastSmoothPoints[lastCount - 1];
|
||||
ChartDrawer.DrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor);
|
||||
CheckClipAndDrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor, serie.clip);
|
||||
while (lastCount < lastSmoothPoints.Count)
|
||||
{
|
||||
tlp = lastSmoothPoints[lastCount];
|
||||
if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break;
|
||||
ChartDrawer.DrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor);
|
||||
CheckClipAndDrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor, serie.clip);
|
||||
lastCount++;
|
||||
tnp = tlp;
|
||||
}
|
||||
@@ -1102,7 +1104,7 @@ namespace XCharts
|
||||
{
|
||||
tlp = lastSmoothPoints[lastSmoothPoints.Count - 1];
|
||||
if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break;
|
||||
ChartDrawer.DrawTriangle(vh, to, start, tlp, areaColor, areaColor, areaToColor);
|
||||
CheckClipAndDrawTriangle(vh, to, start, tlp, areaColor, areaColor, areaToColor, serie.clip);
|
||||
start = to;
|
||||
continue;
|
||||
}
|
||||
@@ -1112,7 +1114,7 @@ namespace XCharts
|
||||
{
|
||||
tlp = lastSmoothPoints[lastCount - 1];
|
||||
if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break;
|
||||
ChartDrawer.DrawPolygon(vh, start, to, tnp, tlp, areaColor, areaToColor);
|
||||
CheckClipAndDrawPolygon(vh, start, to, tnp, tlp, areaColor, areaToColor, serie.clip);
|
||||
lastCount++;
|
||||
}
|
||||
else
|
||||
@@ -1120,12 +1122,12 @@ namespace XCharts
|
||||
if (diff < 0)
|
||||
{
|
||||
tnp = lastSmoothPoints[lastCount - 1];
|
||||
ChartDrawer.DrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor);
|
||||
CheckClipAndDrawTriangle(vh, start, to, tnp, areaColor, areaColor, areaToColor, serie.clip);
|
||||
while (diff < 0 && lastCount < lastSmoothPoints.Count)
|
||||
{
|
||||
tlp = lastSmoothPoints[lastCount];
|
||||
if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break;
|
||||
ChartDrawer.DrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor);
|
||||
CheckClipAndDrawTriangle(vh, tnp, to, tlp, areaToColor, areaColor, areaToColor, serie.clip);
|
||||
lastCount++;
|
||||
diff = isYAxis ? tlp.y - to.y : tlp.x - to.x;
|
||||
tnp = tlp;
|
||||
@@ -1135,7 +1137,7 @@ namespace XCharts
|
||||
{
|
||||
tlp = lastSmoothPoints[lastCount - 1];
|
||||
if (serie.animation.CheckDetailBreak(tlp, isYAxis)) break;
|
||||
ChartDrawer.DrawTriangle(vh, start, to, tlp, areaColor, areaColor, areaToColor);
|
||||
CheckClipAndDrawTriangle(vh, start, to, tlp, areaColor, areaColor, areaToColor, serie.clip);
|
||||
}
|
||||
}
|
||||
start = to;
|
||||
@@ -1146,7 +1148,7 @@ namespace XCharts
|
||||
var p2 = lastSmoothPoints[lastSmoothPoints.Count - 1];
|
||||
if (!serie.animation.CheckDetailBreak(p1, isYAxis))
|
||||
{
|
||||
ChartDrawer.DrawTriangle(vh, p1, start, p2, areaToColor, areaColor, areaToColor);
|
||||
CheckClipAndDrawTriangle(vh, p1, start, p2, areaToColor, areaColor, areaToColor, serie.clip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1177,15 +1179,15 @@ namespace XCharts
|
||||
for (int i = 1; i < linePointList.Count; i++)
|
||||
{
|
||||
ep = linePointList[i];
|
||||
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
|
||||
CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip);
|
||||
sp = ep;
|
||||
}
|
||||
ChartDrawer.DrawPolygon(vh, middle, lineWidth, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, middle, lineWidth, lineColor, serie.clip);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dataIndex == 1) ChartDrawer.DrawPolygon(vh, lp, lineWidth, lineColor);
|
||||
ChartDrawer.DrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor);
|
||||
if (dataIndex == 1) CheckClipAndDrawPolygon(vh, lp, lineWidth, lineColor, serie.clip);
|
||||
CheckClipAndDrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor, serie.clip);
|
||||
}
|
||||
if (serie.areaStyle.show)
|
||||
{
|
||||
@@ -1205,7 +1207,7 @@ namespace XCharts
|
||||
{
|
||||
ep = linePointList[i];
|
||||
if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false;
|
||||
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
|
||||
CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip);
|
||||
if (serie.areaStyle.show)
|
||||
{
|
||||
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff);
|
||||
@@ -1216,7 +1218,7 @@ namespace XCharts
|
||||
if (nnp != np)
|
||||
{
|
||||
if (serie.animation.CheckDetailBreak(np, isYAxis)) return false;
|
||||
ChartDrawer.DrawPolygon(vh, np, lineWidth, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, np, lineWidth, lineColor, serie.clip);
|
||||
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)
|
||||
{
|
||||
@@ -1242,7 +1244,7 @@ namespace XCharts
|
||||
{
|
||||
ep = linePointList[i];
|
||||
if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false;
|
||||
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
|
||||
CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip);
|
||||
if (serie.areaStyle.show)
|
||||
{
|
||||
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff);
|
||||
@@ -1250,7 +1252,7 @@ namespace XCharts
|
||||
sp = ep;
|
||||
}
|
||||
if (serie.animation.CheckDetailBreak(middle1, isYAxis)) return false;
|
||||
ChartDrawer.DrawPolygon(vh, middle1, lineWidth, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, middle1, lineWidth, lineColor, serie.clip);
|
||||
if (serie.areaStyle.show && Vector3.Dot(middleZero - middle1, middle2 - middle1) <= 0)
|
||||
{
|
||||
DrawPolygonToZero(vh, middle1 - diff1, middle1 + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff);
|
||||
@@ -1258,8 +1260,8 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dataIndex == 1) ChartDrawer.DrawPolygon(vh, lp, lineWidth, lineColor);
|
||||
ChartDrawer.DrawLine(vh, lp + diff1, middle1 + diff1, lineWidth, lineColor);
|
||||
if (dataIndex == 1) CheckClipAndDrawPolygon(vh, lp, lineWidth, lineColor, serie.clip);
|
||||
CheckClipAndDrawLine(vh, lp + diff1, middle1 + diff1, lineWidth, lineColor, serie.clip);
|
||||
}
|
||||
|
||||
//draw middle1 to middle2
|
||||
@@ -1270,10 +1272,10 @@ namespace XCharts
|
||||
for (int i = 1; i < linePointList.Count; i++)
|
||||
{
|
||||
ep = linePointList[i];
|
||||
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
|
||||
CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip);
|
||||
sp = ep;
|
||||
}
|
||||
ChartDrawer.DrawPolygon(vh, middle2, lineWidth, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, middle2, lineWidth, lineColor, serie.clip);
|
||||
if (serie.areaStyle.show && Vector3.Dot(middleZero - middle2, middle2 - middle1) >= 0)
|
||||
{
|
||||
DrawPolygonToZero(vh, middle2 - diff1, middle2 + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff);
|
||||
@@ -1281,7 +1283,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartDrawer.DrawLine(vh, middle1 + diff2, middle2 + diff2, lineWidth, lineColor);
|
||||
CheckClipAndDrawLine(vh, middle1 + diff2, middle2 + diff2, lineWidth, lineColor, serie.clip);
|
||||
}
|
||||
//draw middle2 to np
|
||||
if (Vector3.Distance(middle2, np) > 2 * lineWidth)
|
||||
@@ -1292,7 +1294,7 @@ namespace XCharts
|
||||
{
|
||||
ep = linePointList[i];
|
||||
if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false;
|
||||
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
|
||||
CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip);
|
||||
if (serie.areaStyle.show)
|
||||
{
|
||||
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff);
|
||||
@@ -1300,7 +1302,7 @@ namespace XCharts
|
||||
sp = ep;
|
||||
}
|
||||
if (serie.animation.CheckDetailBreak(np, isYAxis)) return false;
|
||||
ChartDrawer.DrawPolygon(vh, np, lineWidth, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, np, lineWidth, lineColor, serie.clip);
|
||||
if (serie.areaStyle.show)
|
||||
{
|
||||
DrawPolygonToZero(vh, np - diff1, np + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff);
|
||||
@@ -1308,7 +1310,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartDrawer.DrawLine(vh, middle1 + diff1, middle1 + diff1, lineWidth, lineColor);
|
||||
CheckClipAndDrawLine(vh, middle1 + diff1, middle1 + diff1, lineWidth, lineColor, serie.clip);
|
||||
}
|
||||
break;
|
||||
case LineType.StepEnd:
|
||||
@@ -1327,7 +1329,7 @@ namespace XCharts
|
||||
{
|
||||
ep = linePointList[i];
|
||||
if (serie.animation.CheckDetailBreak(ep, isYAxis)) return false;
|
||||
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
|
||||
CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip);
|
||||
if (serie.areaStyle.show)
|
||||
{
|
||||
DrawPolygonToZero(vh, sp, ep, axis, zeroPos, areaColor, areaToColor, areaDiff);
|
||||
@@ -1335,7 +1337,7 @@ namespace XCharts
|
||||
sp = ep;
|
||||
}
|
||||
if (serie.animation.CheckDetailBreak(middle, isYAxis)) return false;
|
||||
ChartDrawer.DrawPolygon(vh, middle, lineWidth, lineColor);
|
||||
CheckClipAndDrawPolygon(vh, middle, lineWidth, lineColor, serie.clip);
|
||||
if (serie.areaStyle.show && Vector3.Dot(np - middle, middleZero - middle) <= 0)
|
||||
{
|
||||
DrawPolygonToZero(vh, middle - diff1, middle + diff1, axis, zeroPos, areaColor, areaToColor, areaDiff);
|
||||
@@ -1343,8 +1345,8 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dataIndex == 1) ChartDrawer.DrawPolygon(vh, lp, lineWidth, lineColor);
|
||||
ChartDrawer.DrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor);
|
||||
if (dataIndex == 1) CheckClipAndDrawPolygon(vh, lp, lineWidth, lineColor, serie.clip);
|
||||
CheckClipAndDrawLine(vh, lp + diff1, middle + diff1, lineWidth, lineColor, serie.clip);
|
||||
}
|
||||
|
||||
if (Vector3.Distance(middle, np) > 2 * lineWidth)
|
||||
@@ -1354,14 +1356,14 @@ namespace XCharts
|
||||
for (int i = 1; i < linePointList.Count; i++)
|
||||
{
|
||||
ep = linePointList[i];
|
||||
ChartDrawer.DrawLine(vh, sp, ep, lineWidth, lineColor);
|
||||
CheckClipAndDrawLine(vh, sp, ep, lineWidth, lineColor, serie.clip);
|
||||
sp = ep;
|
||||
}
|
||||
if (nnp != np) ChartDrawer.DrawPolygon(vh, np, lineWidth, lineColor);
|
||||
if (nnp != np) CheckClipAndDrawPolygon(vh, np, lineWidth, lineColor, serie.clip);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartDrawer.DrawLine(vh, middle + diff2, np + diff2, lineWidth, lineColor);
|
||||
CheckClipAndDrawLine(vh, middle + diff2, np + diff2, lineWidth, lineColor, serie.clip);
|
||||
}
|
||||
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)
|
||||
|
||||
@@ -227,8 +227,6 @@ namespace XCharts
|
||||
DrawPolygon(vh, p1, p2, p3, p4, color, toColor);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void DrawPolygon(VertexHelper vh, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4,
|
||||
Color32 color)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace XCharts
|
||||
public class XChartsMgr : MonoBehaviour
|
||||
{
|
||||
public const string version = "1.2.0";
|
||||
public const int date = 20200115;
|
||||
public const int date = 20200210;
|
||||
|
||||
[SerializeField] private string m_NowVersion;
|
||||
[SerializeField] private string m_NewVersion;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
BIN
Doc/newfeature/(2020.02.10) 增加`Serie`的`clip`参数控制是否超出坐标系外裁剪.png
Normal file
BIN
Doc/newfeature/(2020.02.10) 增加`Serie`的`clip`参数控制是否超出坐标系外裁剪.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
Reference in New Issue
Block a user