mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 13:28:47 +00:00
Improved Candlestickchart support for inverse (#152)
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2021.06.05) Improved Candlestickchart support for inverse (#152)
|
||||||
* (2021.06.04) Optimized auto-refresh of custom `Theme` (#148)
|
* (2021.06.04) Optimized auto-refresh of custom `Theme` (#148)
|
||||||
* (2021.06.04) Fixed `Gauge` having an abnormal pointer position when the minimum value is negative
|
* (2021.06.04) Fixed `Gauge` having an abnormal pointer position when the minimum value is negative
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2021.06.05) 完善`CandlestickChart`对`inverse`的支持 (#152)
|
||||||
* (2021.06.04) 优化自定义主题`Theme`的自动刷新 (#148)
|
* (2021.06.04) 优化自定义主题`Theme`的自动刷新 (#148)
|
||||||
* (2021.06.04) 修复`Gauge`在最小值为负数时指针指示位置异常的问题
|
* (2021.06.04) 修复`Gauge`在最小值为负数时指针指示位置异常的问题
|
||||||
|
|
||||||
|
|||||||
@@ -123,40 +123,7 @@ namespace XCharts
|
|||||||
/// 是否可以显示Label
|
/// 是否可以显示Label
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool canShowLabel { get { return m_CanShowLabel; } set { m_CanShowLabel = value; } }
|
public bool canShowLabel { get { return m_CanShowLabel; } set { m_CanShowLabel = value; } }
|
||||||
/// <summary>
|
|
||||||
/// the maxinum value.
|
|
||||||
/// 最大值。
|
|
||||||
/// </summary>
|
|
||||||
public float max
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (m_Data.Count == 0) return 0;
|
|
||||||
float temp = float.MinValue;
|
|
||||||
for (int i = 0; i < m_Data.Count; i++)
|
|
||||||
{
|
|
||||||
if (m_Data[i] > temp) temp = m_Data[i];
|
|
||||||
}
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// the mininum value.
|
|
||||||
/// 最小值。
|
|
||||||
/// </summary>
|
|
||||||
public float min
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (m_Data.Count == 0) return 0;
|
|
||||||
float temp = float.MaxValue;
|
|
||||||
for (int i = 0; i < m_Data.Count; i++)
|
|
||||||
{
|
|
||||||
if (m_Data[i] < temp) temp = m_Data[i];
|
|
||||||
}
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 饼图数据项的开始角度(运行时自动计算)
|
/// 饼图数据项的开始角度(运行时自动计算)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -328,6 +295,38 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// the maxinum value.
|
||||||
|
/// 最大值。
|
||||||
|
/// </summary>
|
||||||
|
public float GetMaxData(bool inverse = false)
|
||||||
|
{
|
||||||
|
if (m_Data.Count == 0) return 0;
|
||||||
|
float temp = float.MinValue;
|
||||||
|
for (int i = 0; i < m_Data.Count; i++)
|
||||||
|
{
|
||||||
|
var value = GetData(i, inverse);
|
||||||
|
if (value > temp) temp = value;
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// the mininum value.
|
||||||
|
/// 最小值。
|
||||||
|
/// </summary>
|
||||||
|
public float GetMinData(bool inverse = false)
|
||||||
|
{
|
||||||
|
if (m_Data.Count == 0) return 0;
|
||||||
|
float temp = float.MaxValue;
|
||||||
|
for (int i = 0; i < m_Data.Count; i++)
|
||||||
|
{
|
||||||
|
var value = GetData(i, inverse);
|
||||||
|
if (value < temp) temp = value;
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
public bool UpdateData(int dimension, float value, bool updateAnimation, float animationDuration = 500f)
|
public bool UpdateData(int dimension, float value, bool updateAnimation, float animationDuration = 500f)
|
||||||
{
|
{
|
||||||
if (dimension >= 0 && dimension < data.Count)
|
if (dimension >= 0 && dimension < data.Count)
|
||||||
|
|||||||
@@ -457,8 +457,8 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (serie.type == SerieType.Candlestick)
|
if (serie.type == SerieType.Candlestick)
|
||||||
{
|
{
|
||||||
var dataMin = data.min;
|
var dataMin = data.GetMinData(inverse);
|
||||||
var dataMax = data.max;
|
var dataMax = data.GetMaxData(inverse);
|
||||||
if (dataMax > max) max = dataMax;
|
if (dataMax > max) max = dataMax;
|
||||||
if (dataMin < min) min = dataMin;
|
if (dataMin < min) min = dataMin;
|
||||||
}
|
}
|
||||||
@@ -502,7 +502,7 @@ namespace XCharts
|
|||||||
var currData = 0f;
|
var currData = 0f;
|
||||||
if (serie.type == SerieType.Candlestick)
|
if (serie.type == SerieType.Candlestick)
|
||||||
{
|
{
|
||||||
currData = showData[j].max;
|
currData = showData[j].GetMaxData(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace XCharts
|
|||||||
var close = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
var close = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
||||||
var lowest = serieData.GetCurrData(2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
var lowest = serieData.GetCurrData(2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
||||||
var heighest = serieData.GetCurrData(3, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
var heighest = serieData.GetCurrData(3, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
||||||
var isRise = close > open;
|
var isRise = yAxis.inverse ? close < open : close > open;
|
||||||
var borderWidth = open == 0 ? 0f
|
var borderWidth = open == 0 ? 0f
|
||||||
: (itemStyle.runtimeBorderWidth == 0 ? m_Theme.serie.candlestickBorderWidth
|
: (itemStyle.runtimeBorderWidth == 0 ? m_Theme.serie.candlestickBorderWidth
|
||||||
: itemStyle.runtimeBorderWidth);
|
: itemStyle.runtimeBorderWidth);
|
||||||
|
|||||||
Reference in New Issue
Block a user