[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
* (2022.08.26) 增加`Legend`新图标类型`Candlestick`
* (2022.08.26) 优化`CandlestickChart`表现,调整相关的`AddData()`接口参数
* (2022.08.26) 增加`Tooltip``position`参数支持设置移动平台不同的显示位置
* (2022.08.26) 删除`Tooltip``fixedXEnable``fixedYEnable`参数

View File

@@ -43,6 +43,10 @@ namespace XCharts.Runtime
/// 菱形。
/// </summary>
Diamond,
/// <summary>
/// 烛台可用于K线图
/// </summary>
Candlestick,
}
/// <summary>
/// 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)
{
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);
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)
if (serie is Line || serie is SimplifiedLine)
{
case SymbolType.None:
continue;
case SymbolType.Circle:
iconType = Legend.Type.Circle;
break;
case SymbolType.Diamond:
iconType = Legend.Type.Diamond;
break;
case SymbolType.EmptyCircle:
iconType = Legend.Type.EmptyCircle;
break;
case SymbolType.Rect:
iconType = Legend.Type.Rect;
break;
case SymbolType.Triangle:
iconType = Legend.Type.Triangle;
break;
var sp = new Vector3(rect.center.x - rect.width / 2, rect.center.y);
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:
continue;
case SymbolType.Circle:
iconType = Legend.Type.Circle;
break;
case SymbolType.Diamond:
iconType = Legend.Type.Diamond;
break;
case SymbolType.EmptyCircle:
iconType = Legend.Type.EmptyCircle;
break;
case SymbolType.Rect:
iconType = Legend.Type.Rect;
break;
case SymbolType.Triangle:
iconType = Legend.Type.Triangle;
break;
}
}
}
else
@@ -249,6 +252,12 @@ namespace XCharts.Runtime
case Legend.Type.Triangle:
UGL.DrawTriangle(vh, rect.center, 1.2f * radius, color);
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;
}
}
}