mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-17 05:50:09 +00:00
增加Axis可通过inverse参数设置坐标轴反向
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
# 更新日志
|
||||
|
||||
* (2020.04.17) 增加`Axis`可通过`inverse`参数设置坐标轴反转
|
||||
* (2020.04.16) 修复`Check warning`在`Unity2019.3`上的显示问题
|
||||
* (2020.04.16) 修复`PieChart`在设置`Space`参数后动画绘制异常的问题
|
||||
* (2020.04.11) 发布`v1.4.0`版本
|
||||
|
||||
@@ -323,9 +323,10 @@
|
||||
* `max`:设定的坐标轴刻度最大值,当 `minMaxType` 为 `Custom` 时有效。
|
||||
* `ceilRate`:最大最小值向上取整的倍率。默认为0时自动计算。
|
||||
* `splitNumber`:坐标轴的分割段数。默认为 `5`。当 `splitNumber` 设为 `0` 时,表示绘制所有的类目数据。
|
||||
* `interval`:强制设置坐标轴分割间隔。无法在类目轴中使用。设置改值时 `splitNumber` 无效。
|
||||
* `interval`:强制设置坐标轴分割间隔。无法在类目轴中使用。设置该值时 `splitNumber` 无效。
|
||||
* `boundaryGap`:坐标轴两边是否留白。默认为 `true`。
|
||||
* `maxCache`:类目数据中可缓存的最大数据量。默认为0没有限制,大于0时超过指定值会移除旧数据再插入新数据。
|
||||
* `inverse`:是否反向坐标轴。只在数值轴`Value`中有效。
|
||||
* `data`:类目数据,在类目轴(`type: 'Category'`)中有效。
|
||||
* `axisLine`:坐标轴轴线相关配置 [AxisLine](#AxisLine)。
|
||||
* `axisName`:坐标轴名称相关配置 [AxisName](#AxisName)。
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace XCharts
|
||||
SerializedProperty m_Min = prop.FindPropertyRelative("m_Min");
|
||||
SerializedProperty m_Max = prop.FindPropertyRelative("m_Max");
|
||||
SerializedProperty m_CeilRate = prop.FindPropertyRelative("m_CeilRate");
|
||||
SerializedProperty m_Inverse = prop.FindPropertyRelative("m_Inverse");
|
||||
|
||||
int index = InitToggle(prop);
|
||||
bool toggle = m_AxisModuleToggle[index];
|
||||
@@ -90,6 +91,8 @@ namespace XCharts
|
||||
}
|
||||
EditorGUI.PropertyField(drawRect, m_CeilRate);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
EditorGUI.PropertyField(drawRect, m_Inverse);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
}
|
||||
EditorGUI.PropertyField(drawRect, m_SplitNumber);
|
||||
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
@@ -170,7 +173,7 @@ namespace XCharts
|
||||
}
|
||||
else if (type == Axis.AxisType.Value)
|
||||
{
|
||||
height += 2 * EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
|
||||
height += 3 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
|
||||
SerializedProperty m_MinMaxType = prop.FindPropertyRelative("m_MinMaxType");
|
||||
if (m_MinMaxType.enumValueIndex == (int)Axis.AxisMinMaxType.Custom)
|
||||
{
|
||||
|
||||
@@ -77,6 +77,7 @@ namespace XCharts
|
||||
[SerializeField] protected float m_LogBase = 10;
|
||||
[SerializeField] protected bool m_LogBaseE = false;
|
||||
[SerializeField] protected int m_CeilRate = 0;
|
||||
[SerializeField] protected bool m_Inverse = false;
|
||||
[SerializeField] protected List<string> m_Data = new List<string>();
|
||||
[SerializeField] protected AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
||||
[SerializeField] protected AxisName m_AxisName = AxisName.defaultAxisName;
|
||||
@@ -196,6 +197,15 @@ namespace XCharts
|
||||
set { if (PropertyUtility.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the axis are reversed or not. Invalid in `Category` axis.
|
||||
/// 是否反向坐标轴。在类目轴中无效。
|
||||
/// </summary>
|
||||
public bool inverse
|
||||
{
|
||||
get { return m_Inverse; }
|
||||
set { if (m_Type == AxisType.Value && PropertyUtility.SetStruct(ref m_Inverse, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Category data, available in type: 'Category' axis.
|
||||
/// 类目数据,在类目轴(type: 'category')中有效。
|
||||
/// </summary>
|
||||
@@ -328,7 +338,7 @@ namespace XCharts
|
||||
public float runtimeZeroYOffset { get; internal set; }
|
||||
public int runtimeMinLogIndex { get { return logBaseE ? (int)Mathf.Log(runtimeMinValue) : (int)Mathf.Log(runtimeMinValue, logBase); } }
|
||||
public int runtimeMaxLogIndex { get { return logBaseE ? (int)Mathf.Log(runtimeMaxValue) : (int)Mathf.Log(runtimeMaxValue, logBase); } }
|
||||
|
||||
internal bool runtimeLastCheckInverse { get; set; }
|
||||
private int filterStart;
|
||||
private int filterEnd;
|
||||
private int filterMinShow;
|
||||
@@ -566,7 +576,6 @@ namespace XCharts
|
||||
DataZoom dataZoom, bool forcePercent)
|
||||
{
|
||||
int split = GetSplitNumber(coordinateWidth, dataZoom);
|
||||
|
||||
if (m_Type == AxisType.Value)
|
||||
{
|
||||
if (minValue == 0 && maxValue == 0) return string.Empty;
|
||||
@@ -581,6 +590,12 @@ namespace XCharts
|
||||
{
|
||||
value = (minValue + (maxValue - minValue) * index / (split - 1));
|
||||
}
|
||||
if (inverse)
|
||||
{
|
||||
value = -value;
|
||||
minValue = -minValue;
|
||||
maxValue = -maxValue;
|
||||
}
|
||||
if (forcePercent) return string.Format("{0}%", (int)value);
|
||||
else return m_AxisLabel.GetFormatterContent(value, minValue, maxValue);
|
||||
}
|
||||
@@ -588,6 +603,12 @@ namespace XCharts
|
||||
{
|
||||
float value = m_LogBaseE ? Mathf.Exp(runtimeMinLogIndex + index) :
|
||||
Mathf.Pow(m_LogBase, runtimeMinLogIndex + index);
|
||||
if (inverse)
|
||||
{
|
||||
value = -value;
|
||||
minValue = -minValue;
|
||||
maxValue = -maxValue;
|
||||
}
|
||||
return m_AxisLabel.GetFormatterContent(value, minValue, maxValue, true);
|
||||
}
|
||||
var showData = GetDataList(dataZoom);
|
||||
@@ -740,8 +761,16 @@ namespace XCharts
|
||||
{
|
||||
if (min != 0 || max != 0)
|
||||
{
|
||||
minValue = min;
|
||||
maxValue = max;
|
||||
if (inverse)
|
||||
{
|
||||
minValue = -max;
|
||||
maxValue = -min;
|
||||
}
|
||||
else
|
||||
{
|
||||
minValue = min;
|
||||
maxValue = max;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -755,22 +784,22 @@ namespace XCharts
|
||||
else if (minValue > 0 && maxValue > 0)
|
||||
{
|
||||
minValue = 0;
|
||||
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue,m_CeilRate) : maxValue;
|
||||
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue, m_CeilRate) : maxValue;
|
||||
}
|
||||
else if (minValue < 0 && maxValue < 0)
|
||||
{
|
||||
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue,m_CeilRate) : minValue;
|
||||
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue, m_CeilRate) : minValue;
|
||||
maxValue = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue,m_CeilRate) : minValue;
|
||||
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue,m_CeilRate) : maxValue;
|
||||
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue, m_CeilRate) : minValue;
|
||||
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue, m_CeilRate) : maxValue;
|
||||
}
|
||||
break;
|
||||
case Axis.AxisMinMaxType.MinMax:
|
||||
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue,m_CeilRate) : minValue;
|
||||
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue,m_CeilRate) : maxValue;
|
||||
minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue, m_CeilRate) : minValue;
|
||||
maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue, m_CeilRate) : maxValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -723,10 +723,10 @@ namespace XCharts
|
||||
/// <param name="axisIndex"></param>
|
||||
/// <param name="minVaule"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
internal void GetXMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis,
|
||||
internal void GetXMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis, bool inverse,
|
||||
out float minVaule, out float maxValue)
|
||||
{
|
||||
GetMinMaxValue(dataZoom, axisIndex, isValueAxis, false, out minVaule, out maxValue);
|
||||
GetMinMaxValue(dataZoom, axisIndex, isValueAxis, inverse, false, out minVaule, out maxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -736,15 +736,15 @@ namespace XCharts
|
||||
/// <param name="axisIndex"></param>
|
||||
/// <param name="minVaule"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
internal void GetYMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis,
|
||||
internal void GetYMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis, bool inverse,
|
||||
out float minVaule, out float maxValue)
|
||||
{
|
||||
GetMinMaxValue(dataZoom, axisIndex, isValueAxis, true, out minVaule, out maxValue);
|
||||
GetMinMaxValue(dataZoom, axisIndex, isValueAxis, inverse, true, out minVaule, out maxValue);
|
||||
}
|
||||
|
||||
private Dictionary<int, List<Serie>> _stackSeriesForMinMax = new Dictionary<int, List<Serie>>();
|
||||
private Dictionary<int, float> _serieTotalValueForMinMax = new Dictionary<int, float>();
|
||||
internal void GetMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis, bool yValue,
|
||||
internal void GetMinMaxValue(DataZoom dataZoom, int axisIndex, bool isValueAxis, bool inverse, bool yValue,
|
||||
out float minVaule, out float maxValue)
|
||||
{
|
||||
float min = int.MaxValue;
|
||||
@@ -769,17 +769,9 @@ namespace XCharts
|
||||
var showData = m_Series[i].GetDataList(dataZoom);
|
||||
foreach (var data in showData)
|
||||
{
|
||||
if (yValue)
|
||||
{
|
||||
var currData = data.GetData(1);
|
||||
if (currData > max) max = currData;
|
||||
if (currData < min) min = currData;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data.data[0] > max) max = data.data[0];
|
||||
if (data.data[0] < min) min = data.data[0];
|
||||
}
|
||||
var currData = data.GetData(yValue ? 1 : 0, inverse);
|
||||
if (currData > max) max = currData;
|
||||
if (currData < min) min = currData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -809,11 +801,11 @@ namespace XCharts
|
||||
{
|
||||
if (!_serieTotalValueForMinMax.ContainsKey(j))
|
||||
_serieTotalValueForMinMax[j] = 0;
|
||||
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] +
|
||||
(yValue ? showData[j].GetData(1) : showData[i].data[0]);
|
||||
var currData = (yValue ? showData[j].GetData(1) : showData[j].GetData(0));
|
||||
if (inverse) currData = -currData;
|
||||
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] + currData;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
float tmax = int.MinValue;
|
||||
float tmin = int.MaxValue;
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace XCharts
|
||||
SetDataState(dataIndex, currHig);
|
||||
if (m_FadeOut)
|
||||
{
|
||||
if (currHig <= 0)
|
||||
if ((destHig > 0 && currHig <= 0) || (destHig < 0 && currHig >= 0))
|
||||
{
|
||||
End();
|
||||
currHig = 0;
|
||||
|
||||
@@ -176,20 +176,20 @@ namespace XCharts
|
||||
private List<float> m_DataUpdateTime = new List<float>();
|
||||
private List<bool> m_DataUpdateFlag = new List<bool>();
|
||||
|
||||
public float GetData(int index)
|
||||
public float GetData(int index, bool inverse = false)
|
||||
{
|
||||
if (index >= 0 && index < m_Data.Count)
|
||||
{
|
||||
return m_Data[index];
|
||||
return inverse ? -m_Data[index] : m_Data[index];
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
public float GetPreviousData(int index)
|
||||
public float GetPreviousData(int index, bool inverse = false)
|
||||
{
|
||||
if (index >= 0 && index < m_PreviousData.Count)
|
||||
{
|
||||
return m_PreviousData[index];
|
||||
return inverse ? -m_PreviousData[index] : m_PreviousData[index];
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ namespace XCharts
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float GetCurrData(int index, float animationDuration = 500f)
|
||||
public float GetCurrData(int index, float animationDuration = 500f, bool inverse = false)
|
||||
{
|
||||
if (index < m_DataUpdateFlag.Count && m_DataUpdateFlag[index] && animationDuration > 0)
|
||||
{
|
||||
@@ -215,18 +215,18 @@ namespace XCharts
|
||||
if (time <= total)
|
||||
{
|
||||
CheckLastData();
|
||||
var curr = Mathf.Lerp(GetPreviousData(index), GetData(index), time / total);
|
||||
var curr = Mathf.Lerp(GetPreviousData(index, inverse), GetData(index, inverse), time / total);
|
||||
return curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_DataUpdateFlag[index] = false;
|
||||
return GetData(index);
|
||||
return GetData(index, inverse);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetData(index);
|
||||
return GetData(index, inverse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace XCharts
|
||||
{
|
||||
sb.Append(key).Append(!string.IsNullOrEmpty(key) ? " : " : "");
|
||||
sb.Append("[").Append(ChartCached.FloatToStr(xValue, 0, tooltip.forceENotation)).Append(",")
|
||||
.Append(ChartCached.FloatToStr(yValue, 0, tooltip.forceENotation)).Append("]\n");
|
||||
.Append(ChartCached.FloatToStr(yValue, 0, tooltip.forceENotation)).Append("]");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -275,8 +275,8 @@ namespace XCharts
|
||||
for (int n = 0; n < serie.data.Count; n++)
|
||||
{
|
||||
var serieData = serie.data[n];
|
||||
var xdata = serieData.data[0];
|
||||
var ydata = serieData.data[1];
|
||||
var xdata = serieData.GetData(0, xAxis.inverse);
|
||||
var ydata = serieData.GetData(1, yAxis.inverse);
|
||||
var symbolSize = serie.symbol.GetSize(serieData == null ? null : serieData.data);
|
||||
if (Mathf.Abs(xValue - xdata) / xRate < symbolSize
|
||||
&& Mathf.Abs(yValue - ydata) / yRate < symbolSize)
|
||||
@@ -799,25 +799,28 @@ namespace XCharts
|
||||
{
|
||||
if (axis is XAxis)
|
||||
{
|
||||
m_Series.GetXMinMaxValue(m_DataZoom, axisIndex, true, out tempMinValue, out tempMaxValue);
|
||||
m_Series.GetXMinMaxValue(m_DataZoom, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, true, out tempMinValue, out tempMaxValue);
|
||||
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, true, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, false, out tempMinValue, out tempMaxValue);
|
||||
m_Series.GetYMinMaxValue(m_DataZoom, axisIndex, false, axis.inverse, out tempMinValue, out tempMaxValue);
|
||||
}
|
||||
axis.AdjustMinMaxValue(ref tempMinValue, ref tempMaxValue, true);
|
||||
if (tempMinValue != axis.runtimeMinValue || tempMaxValue != axis.runtimeMaxValue)
|
||||
{
|
||||
m_CheckMinMaxValue = true;
|
||||
axis.UpdateMinValue(tempMinValue, !m_IsPlayingAnimation);
|
||||
axis.UpdateMaxValue(tempMaxValue, !m_IsPlayingAnimation);
|
||||
m_IsPlayingAnimation = true;
|
||||
var needCheck = !m_IsPlayingAnimation && axis.runtimeLastCheckInverse == axis.inverse;
|
||||
axis.UpdateMinValue(tempMinValue, needCheck);
|
||||
axis.UpdateMaxValue(tempMaxValue, needCheck);
|
||||
axis.runtimeZeroXOffset = 0;
|
||||
axis.runtimeZeroYOffset = 0;
|
||||
axis.runtimeLastCheckInverse = axis.inverse;
|
||||
if (tempMinValue != 0 || tempMaxValue != 0)
|
||||
{
|
||||
if (axis is XAxis && axis.IsValue())
|
||||
@@ -1135,7 +1138,7 @@ namespace XCharts
|
||||
Vector3 np = Vector3.zero;
|
||||
float minValue = 0;
|
||||
float maxValue = 0;
|
||||
m_Series.GetYMinMaxValue(null, 0, IsValue(), out minValue, out maxValue);
|
||||
m_Series.GetYMinMaxValue(null, 0, IsValue(), axis.inverse, out minValue, out maxValue);
|
||||
axis.AdjustMinMaxValue(ref minValue, ref maxValue, true);
|
||||
|
||||
int rate = 1;
|
||||
@@ -1149,7 +1152,7 @@ namespace XCharts
|
||||
for (int i = 0; i < maxCount; i += rate)
|
||||
{
|
||||
float value = SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
|
||||
serie.animation.GetUpdateAnimationDuration(), ref dataChanging);
|
||||
serie.animation.GetUpdateAnimationDuration(), ref dataChanging, axis.inverse);
|
||||
float pX = coordinateX + i * scaleWid;
|
||||
float dataHig = (axis.runtimeMaxValue - axis.runtimeMinValue) == 0 ? 0 :
|
||||
(value - axis.runtimeMinValue) / (axis.runtimeMaxValue - axis.runtimeMinValue) * hig;
|
||||
@@ -1783,11 +1786,11 @@ namespace XCharts
|
||||
}
|
||||
|
||||
protected void CheckClipAndDrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
|
||||
float tickness, Vector3 pos, Color color, Color toColor, float gap, bool clip,float[] cornerRadius)
|
||||
float tickness, Vector3 pos, Color color, Color toColor, float gap, bool clip, float[] cornerRadius)
|
||||
{
|
||||
if (!IsInChart(pos)) return;
|
||||
if (!clip || (clip && (IsInCooridate(pos))))
|
||||
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap,cornerRadius);
|
||||
DrawSymbol(vh, type, symbolSize, tickness, pos, color, toColor, gap, cornerRadius);
|
||||
}
|
||||
|
||||
protected void CheckClipAndDrawZebraLine(VertexHelper vh, Vector3 p1, Vector3 p2, float size,
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace XCharts
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);
|
||||
|
||||
serieData.canShowLabel = true;
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration);
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse);
|
||||
float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||
float pX = seriesHig[i] + coordinateX + xAxis.runtimeZeroXOffset + yAxis.axisLine.width;
|
||||
@@ -193,7 +193,7 @@ namespace XCharts
|
||||
|| serie.data[i].highlighted
|
||||
|| serie.highlighted;
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);
|
||||
float value = serieData.GetCurrData(1, dataChangeDuration);
|
||||
float value = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
|
||||
float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
float pX = coordinateX + i * categoryWidth;
|
||||
@@ -354,25 +354,53 @@ namespace XCharts
|
||||
if (isYAxis)
|
||||
{
|
||||
var diff = Vector3.right * radius;
|
||||
var pcl = (plt + plb) / 2 + diff;
|
||||
var pcr = (prt + prb) / 2 - diff;
|
||||
if (pcr.x > pcl.x)
|
||||
if (plt.x < prt.x)
|
||||
{
|
||||
CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, areaColor, areaToColor, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pcl, radius, areaColor, 180, 360);
|
||||
ChartDrawer.DrawSector(vh, pcr, radius, areaToColor, 0, 180);
|
||||
var pcl = (plt + plb) / 2 + diff;
|
||||
var pcr = (prt + prb) / 2 - diff;
|
||||
if (pcr.x > pcl.x)
|
||||
{
|
||||
CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, areaColor, areaToColor, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pcl, radius, areaColor, 180, 360);
|
||||
ChartDrawer.DrawSector(vh, pcr, radius, areaToColor, 0, 180);
|
||||
}
|
||||
}
|
||||
else if (plt.x > prt.x)
|
||||
{
|
||||
var pcl = (plt + plb) / 2 - diff;
|
||||
var pcr = (prt + prb) / 2 + diff;
|
||||
if (pcr.x < pcl.x)
|
||||
{
|
||||
CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, areaColor, areaToColor, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pcl, radius, areaColor, 0, 180);
|
||||
ChartDrawer.DrawSector(vh, pcr, radius, areaToColor, 180, 360);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var diff = Vector3.up * radius;
|
||||
var pct = (plt + prt) / 2 - diff;
|
||||
var pcb = (plb + prb) / 2 + diff;
|
||||
if (pct.y > pcb.y)
|
||||
if (plt.y > plb.y)
|
||||
{
|
||||
CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, areaColor, areaToColor, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pct, radius, areaToColor, 270, 450);
|
||||
ChartDrawer.DrawSector(vh, pcb, radius, areaColor, 90, 270);
|
||||
var pct = (plt + prt) / 2 - diff;
|
||||
var pcb = (plb + prb) / 2 + diff;
|
||||
if (pct.y > pcb.y)
|
||||
{
|
||||
CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, areaColor, areaToColor, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pct, radius, areaToColor, 270, 450);
|
||||
ChartDrawer.DrawSector(vh, pcb, radius, areaColor, 90, 270);
|
||||
}
|
||||
}
|
||||
else if (plt.y < plb.y)
|
||||
{
|
||||
var pct = (plt + prt) / 2 + diff;
|
||||
var pcb = (plb + prb) / 2 - diff;
|
||||
if (pct.y < pcb.y)
|
||||
{
|
||||
CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, areaColor, areaToColor, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pct, radius, areaToColor, 90, 270);
|
||||
ChartDrawer.DrawSector(vh, pcb, radius, areaColor, 270, 450);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace XCharts
|
||||
serie.dataPoints.Add(Vector3.zero);
|
||||
continue;
|
||||
}
|
||||
var value = serieData.GetCurrData(dimension, dataChangeDuration);
|
||||
var value = serieData.GetCurrData(dimension, dataChangeDuration, yAxis.inverse);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
var pos = new Vector3(zeroX + (i + 0.5f) * xWidth, zeroY + (j + 0.5f) * yWidth);
|
||||
serie.dataPoints.Add(pos);
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace XCharts
|
||||
else
|
||||
{
|
||||
float yValue = SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage,
|
||||
i, dataChangeDuration, ref dataChanging);
|
||||
i, dataChangeDuration, ref dataChanging,yAxis.inverse);
|
||||
seriesHig[i] += GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, seriesHig[i], ref np,
|
||||
dataChangeDuration);
|
||||
serie.dataPoints.Add(np);
|
||||
@@ -155,7 +155,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
float yValue = showData[i].GetCurrData(1, dataChangeDuration);
|
||||
float yValue = showData[i].GetCurrData(1, dataChangeDuration,yAxis.inverse);
|
||||
seriesHig[i] += GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, seriesHig[i], ref np,
|
||||
dataChangeDuration);
|
||||
serie.dataPoints.Add(np);
|
||||
@@ -187,7 +187,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
float yValue = showData[i].GetCurrData(1, dataChangeDuration);
|
||||
float yValue = showData[i].GetCurrData(1, dataChangeDuration,yAxis.inverse);
|
||||
GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, 0, ref firstLastPos, dataChangeDuration);
|
||||
}
|
||||
}
|
||||
@@ -204,7 +204,7 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
float yValue = showData[i].GetCurrData(1, dataChangeDuration);
|
||||
float yValue = showData[i].GetCurrData(1, dataChangeDuration,yAxis.inverse);
|
||||
GetDataPoint(xAxis, yAxis, showData, yValue, startX, i, scaleWid, 0, ref lastNextPos, dataChangeDuration);
|
||||
}
|
||||
}
|
||||
@@ -350,12 +350,13 @@ namespace XCharts
|
||||
}
|
||||
|
||||
private float SampleValue(ref List<SerieData> showData, SampleType sampleType, int rate,
|
||||
int minCount, int maxCount, float totalAverage, int index, float dataChangeDuration, ref bool dataChanging)
|
||||
int minCount, int maxCount, float totalAverage, int index, float dataChangeDuration,
|
||||
ref bool dataChanging,bool inverse)
|
||||
{
|
||||
if (rate <= 1 || index == minCount)
|
||||
{
|
||||
if (showData[index].IsDataChanged()) dataChanging = true;
|
||||
return showData[index].GetCurrData(1, dataChangeDuration);
|
||||
return showData[index].GetCurrData(1, dataChangeDuration,inverse);
|
||||
}
|
||||
switch (sampleType)
|
||||
{
|
||||
@@ -364,7 +365,7 @@ namespace XCharts
|
||||
float total = 0;
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
total += showData[i].GetCurrData(1, dataChangeDuration);
|
||||
total += showData[i].GetCurrData(1, dataChangeDuration,inverse);
|
||||
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||
}
|
||||
if (sampleType == SampleType.Average) return total / rate;
|
||||
@@ -373,7 +374,7 @@ namespace XCharts
|
||||
float max = float.MinValue;
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
var value = showData[i].GetCurrData(1, dataChangeDuration);
|
||||
var value = showData[i].GetCurrData(1, dataChangeDuration,inverse);
|
||||
if (value > max) max = value;
|
||||
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||
}
|
||||
@@ -382,7 +383,7 @@ namespace XCharts
|
||||
float min = float.MaxValue;
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
var value = showData[i].GetCurrData(1, dataChangeDuration);
|
||||
var value = showData[i].GetCurrData(1, dataChangeDuration,inverse);
|
||||
if (value < min) min = value;
|
||||
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||
}
|
||||
@@ -393,7 +394,7 @@ namespace XCharts
|
||||
total = 0;
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
var value = showData[i].GetCurrData(1, dataChangeDuration);
|
||||
var value = showData[i].GetCurrData(1, dataChangeDuration,inverse);
|
||||
total += value;
|
||||
if (value < min) min = value;
|
||||
if (value > max) max = value;
|
||||
@@ -404,7 +405,7 @@ namespace XCharts
|
||||
else return min;
|
||||
}
|
||||
if (showData[index].IsDataChanged()) dataChanging = true;
|
||||
return showData[index].GetCurrData(1, dataChangeDuration);
|
||||
return showData[index].GetCurrData(1, dataChangeDuration,inverse);
|
||||
}
|
||||
|
||||
private float GetDataPoint(Axis xAxis, Axis yAxis, List<SerieData> showData, float yValue, float startX, int i,
|
||||
@@ -422,7 +423,7 @@ namespace XCharts
|
||||
float yMaxValue = yAxis.GetCurrMaxValue(duration);
|
||||
if (xAxis.IsValue() || xAxis.IsLog())
|
||||
{
|
||||
float xValue = i > showData.Count - 1 ? 0 : showData[i].data[0];
|
||||
float xValue = i > showData.Count - 1 ? 0 : showData[i].GetData(0,xAxis.inverse);
|
||||
float pX = coordinateX + xAxis.axisLine.width;
|
||||
float pY = serieHig + coordinateY + xAxis.axisLine.width;
|
||||
if (xAxis.IsLog())
|
||||
@@ -516,7 +517,7 @@ namespace XCharts
|
||||
{
|
||||
for (int j = 0; j < rate; j++) seriesHig.Add(0);
|
||||
}
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration);
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration,xAxis.inverse);
|
||||
float pY = startY + i * scaleWid;
|
||||
float pX = seriesHig[i] + coordinateX + yAxis.axisLine.width;
|
||||
float dataHig = 0;
|
||||
@@ -543,7 +544,7 @@ namespace XCharts
|
||||
{
|
||||
i = maxCount - 1;
|
||||
seriesHig.Add(0);
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration);
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration,xAxis.inverse);
|
||||
float pY = startY + i * scaleWid;
|
||||
float pX = seriesHig[i] + coordinateX + yAxis.axisLine.width;
|
||||
float dataHig = 0;
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace XCharts
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, highlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||
float xValue = serieData.GetCurrData(0, dataChangeDuration);
|
||||
float yValue = serieData.GetCurrData(1, dataChangeDuration);
|
||||
float xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
|
||||
float yValue = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
float pX = coordinateX + xAxis.axisLine.width;
|
||||
float pY = coordinateY + yAxis.axisLine.width;
|
||||
|
||||
Reference in New Issue
Block a user