[feature][legend] add new icon type:candlestick

This commit is contained in:
monitor1394
2022-08-26 23:18:35 +08:00
parent a885be625e
commit 48686e865c
3 changed files with 37 additions and 23 deletions

View File

@@ -58,6 +58,7 @@
## master ## master
* (2022.08.26) 增加`Legend`新图标类型`Candlestick`
* (2022.08.26) 优化`CandlestickChart`表现,调整相关的`AddData()`接口参数 * (2022.08.26) 优化`CandlestickChart`表现,调整相关的`AddData()`接口参数
* (2022.08.26) 增加`Tooltip``position`参数支持设置移动平台不同的显示位置 * (2022.08.26) 增加`Tooltip``position`参数支持设置移动平台不同的显示位置
* (2022.08.26) 删除`Tooltip``fixedXEnable``fixedYEnable`参数 * (2022.08.26) 删除`Tooltip``fixedXEnable``fixedYEnable`参数

View File

@@ -43,6 +43,10 @@ namespace XCharts.Runtime
/// 菱形。 /// 菱形。
/// </summary> /// </summary>
Diamond, Diamond,
/// <summary>
/// 烛台可用于K线图
/// </summary>
Candlestick,
} }
/// <summary> /// <summary>
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends. /// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.

View File

@@ -196,31 +196,34 @@ namespace XCharts.Runtime
if (legend.iconType == Legend.Type.Auto) if (legend.iconType == Legend.Type.Auto)
{ {
var serie = chart.GetSerie(item.legendName); var serie = chart.GetSerie(item.legendName);
if (serie != null && serie is Line) if (serie != null)
{ {
var sp = new Vector3(rect.center.x - rect.width / 2, rect.center.y); if (serie is Line || serie is SimplifiedLine)
var ep = new Vector3(rect.center.x + rect.width / 2, rect.center.y);
UGL.DrawLine(vh, sp, ep, chart.settings.legendIconLineWidth, color);
if (!serie.symbol.show) continue;
switch (serie.symbol.type)
{ {
case SymbolType.None: var sp = new Vector3(rect.center.x - rect.width / 2, rect.center.y);
continue; var ep = new Vector3(rect.center.x + rect.width / 2, rect.center.y);
case SymbolType.Circle: UGL.DrawLine(vh, sp, ep, chart.settings.legendIconLineWidth, color);
iconType = Legend.Type.Circle; if (!serie.symbol.show) continue;
break; switch (serie.symbol.type)
case SymbolType.Diamond: {
iconType = Legend.Type.Diamond; case SymbolType.None:
break; continue;
case SymbolType.EmptyCircle: case SymbolType.Circle:
iconType = Legend.Type.EmptyCircle; iconType = Legend.Type.Circle;
break; break;
case SymbolType.Rect: case SymbolType.Diamond:
iconType = Legend.Type.Rect; iconType = Legend.Type.Diamond;
break; break;
case SymbolType.Triangle: case SymbolType.EmptyCircle:
iconType = Legend.Type.Triangle; iconType = Legend.Type.EmptyCircle;
break; break;
case SymbolType.Rect:
iconType = Legend.Type.Rect;
break;
case SymbolType.Triangle:
iconType = Legend.Type.Triangle;
break;
}
} }
} }
else else
@@ -249,6 +252,12 @@ namespace XCharts.Runtime
case Legend.Type.Triangle: case Legend.Type.Triangle:
UGL.DrawTriangle(vh, rect.center, 1.2f * radius, color); UGL.DrawTriangle(vh, rect.center, 1.2f * radius, color);
break; break;
case Legend.Type.Candlestick:
UGL.DrawRoundRectangle(vh, rect.center, rect.width / 2, rect.height / 2, color, color,
0, null, false, 0.5f);
UGL.DrawLine(vh, new Vector3(rect.center.x, rect.center.y - rect.height / 2),
new Vector3(rect.center.x, rect.center.y + rect.height / 2), 1, color);
break;
} }
} }
} }