mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 06:50:18 +00:00
Improved zebra bar chart
This commit is contained in:
@@ -42,6 +42,8 @@
|
||||
|
||||
## branch-2.0
|
||||
|
||||
* (2022.01.06) Improved `Zebra` bar chart
|
||||
|
||||
## v2.6.0
|
||||
|
||||
* (2021.12.30) Release `v2.6.0` version
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
|
||||
## branch-2.0
|
||||
|
||||
* (2022.01.06) 优化`Zebra`斑马柱图
|
||||
|
||||
## v2.6.0
|
||||
|
||||
* (2021.12.30) 发布`v2.6.0`版本
|
||||
|
||||
@@ -1696,11 +1696,11 @@ namespace XCharts
|
||||
}
|
||||
|
||||
public void Internal_CheckClipAndDrawZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size, float zebraWidth,
|
||||
float zebraGap, Color32 color, Color32 toColor, bool clip, Grid grid)
|
||||
float zebraGap, Color32 color, Color32 toColor, bool clip, Grid grid, float maxDistance)
|
||||
{
|
||||
ClampInChart(ref p1);
|
||||
ClampInChart(ref p2);
|
||||
UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color, toColor);
|
||||
UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color, toColor,maxDistance);
|
||||
}
|
||||
|
||||
protected Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, Grid grid)
|
||||
|
||||
@@ -386,14 +386,14 @@ namespace XCharts
|
||||
plt = (plb + plt) / 2;
|
||||
prt = (prt + prb) / 2;
|
||||
Internal_CheckClipAndDrawZebraLine(vh, plt, prt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
|
||||
barColor, barToColor, serie.clip, grid);
|
||||
barColor, barToColor, serie.clip, grid, grid.runtimeWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
plb = (prb + plb) / 2;
|
||||
plt = (plt + prt) / 2;
|
||||
Internal_CheckClipAndDrawZebraLine(vh, plb, plt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
|
||||
barColor, barToColor, serie.clip, grid);
|
||||
barColor, barToColor, serie.clip, grid, grid.runtimeHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -299,9 +299,25 @@ namespace XUGL
|
||||
/// <param name="color">起始颜色</param>
|
||||
/// <param name="toColor">结束颜色</param>
|
||||
public static void DrawZebraLine(VertexHelper vh, Vector3 startPoint, Vector3 endPoint, float width,
|
||||
float zebraWidth, float zebraGap, Color32 color, Color32 toColor)
|
||||
float zebraWidth, float zebraGap, Color32 color, Color32 toColor, float maxDistance)
|
||||
{
|
||||
DrawDotLine(vh, startPoint, endPoint, width, color, toColor, zebraWidth, zebraGap);
|
||||
var dist = Vector3.Distance(startPoint, endPoint);
|
||||
if (dist < 0.1f) return;
|
||||
if (zebraWidth == 0) zebraWidth = 3 * width;
|
||||
if (zebraGap == 0) zebraGap = 3 * width;
|
||||
var allSegment = Mathf.CeilToInt(maxDistance / (zebraWidth + zebraGap));
|
||||
var segment = Mathf.CeilToInt(dist / maxDistance * allSegment);
|
||||
var dir = (endPoint - startPoint).normalized;
|
||||
var sp = startPoint;
|
||||
var np = Vector3.zero;
|
||||
var isGradient = !color.Equals(toColor);
|
||||
for (int i = 1; i <= segment; i++)
|
||||
{
|
||||
np = startPoint + dir * maxDistance * i / allSegment;
|
||||
var dashep = np - dir * zebraGap;
|
||||
DrawLine(vh, sp, dashep, width, isGradient ? Color32.Lerp(color, toColor, i * 1.0f / allSegment) : color);
|
||||
sp = np;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user