mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-20 23:40:10 +00:00
Merge branch 'develop'
This commit is contained in:
@@ -32,6 +32,10 @@
|
||||
|
||||
## Latest
|
||||
|
||||
* (2021.03.06) Added `PieChart`'s `minAngle` parameter to support setting minimum sector angle #117
|
||||
* (2021.03.05) Added support for `Legend` for several built-in ICONS #90
|
||||
* (2021.03.02) Added `DataRoom` support for value axes #71
|
||||
* (2021.03.02) Optimized `TextMeshPro` compatibility issue #125
|
||||
* (2021.03.01) Fixed display exception of hidden gameObjects when enabling and disabling a chart #125
|
||||
|
||||
## v2.0.1
|
||||
|
||||
@@ -32,7 +32,11 @@
|
||||
|
||||
## Latest
|
||||
|
||||
* (2021.03.01) 修复隐藏和显示chart时部分已隐藏的节点显示异常的问题 #125
|
||||
* (2021.03.06) 增加`PieChart`的`minAngle`参数支持设置最小扇区角度 #117
|
||||
* (2021.03.05) 增加`Legend`几种内置图标的支持 #90
|
||||
* (2021.03.02) 增加`DataZoom`对数值轴的支持 #71
|
||||
* (2021.03.02) 优化`TextMeshPro`兼容问题 #125
|
||||
* (2021.03.01) 修复隐藏和显示图表时部分已隐藏的节点显示异常的问题 #125
|
||||
|
||||
## v2.0.1
|
||||
|
||||
|
||||
@@ -115,6 +115,14 @@
|
||||
相关参数:
|
||||
|
||||
* `show`:是否显示图例组件。
|
||||
* `iconType`:图例图标类型。有以下几种类型:
|
||||
* `Auto`:自动匹配。
|
||||
* `Custom`:自定义图标。
|
||||
* `EmptyCircle`:空心圆。
|
||||
* `Circle`:实心圆。
|
||||
* `Rect`:正方形。可通过`Setting`的`legendIconCornerRadius`参数调整圆角。
|
||||
* `Triangle`:三角形。
|
||||
* `Diamond`:菱形。
|
||||
* `selectedMode`:选择模式。控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 `None` 关闭。有以下三种选择方式:
|
||||
* `Multiple`:多选。
|
||||
* `Single`:单选。
|
||||
@@ -619,6 +627,7 @@
|
||||
* `space`:扇区间隙。
|
||||
* `center`:中心点坐标。当值为`0-1`的浮点数时表示百分比。
|
||||
* `radius`:半径。`radius[0]`为内径,`radius[1]`为外径。当内径大于0时即为圆环图。
|
||||
* `minAngle`:最小的扇区角度(0-360)。用于防止某个值过小导致扇区太小影响交互。
|
||||
* `roundCap`:是否启用圆弧效果。
|
||||
* `ignore`:是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制,对应的`Label`和`Legend`也不会显示。
|
||||
* `ignoreValue`:忽略数据的默认值。默认值默认为0,当 `ignore` 为 `true` 才有效。
|
||||
|
||||
@@ -113,6 +113,14 @@ Legend component.The legend component shows different sets of symbol, colors, an
|
||||
Parameters:
|
||||
|
||||
* `show`: Whether show legend component.
|
||||
* `iconType`: the legend icon symbol type:
|
||||
* `Auto` : Auto match.
|
||||
* `Custom` : Custom icon.
|
||||
* `EmptyCircle` : hollow circle.
|
||||
* `Circle` : solid Circle.
|
||||
* `Rect` : square.
|
||||
* `Triangle` :
|
||||
* `Diamond` :
|
||||
* `selectedMode`: Selected mode of legend, which controls whether series can be toggled displaying by clicking legends:
|
||||
* `Multiple`: multi-select.
|
||||
* `Single`: single select.
|
||||
@@ -227,7 +235,7 @@ Tooltip component.
|
||||
* Example: `"{a}, {c}"`, `"{a1}, {c1: f1}"`, `"{a1}, {c1:0: f1}"`, `"{a1} : {c1:1-1: f1}"`
|
||||
* `titleFormatter`: The string template formatter for the tooltip title content. Support for wrapping lines with `\n`. This is only valid if the `itemFormatter` is in effect. The placeholder `{I}` can be set separately to indicate that the title is ignored and not displayed.
|
||||
* `itemFormatter`: a string template formatter for a single Serie or data item content. Support for wrapping lines with `\n`. When `formatter` is not null, use `formatter` first, otherwise use `itemFormatter`.
|
||||
* `numericFormatter`: Standard numeric format string. Used to format numeric values to display as strings. Using 'Axx' form: 'A' is the single character of the format specifier, supporting 'C' currency, 'D' decimal, 'E' exponent, 'F' number of vertices, 'G' regular, 'N' digits, 'P' percentage, 'R' round tripping, 'X' hex etc. 'XX' is the precision specification, from '0' - '99'. see: <https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings>
|
||||
* `numericFormatter`: Standard numeric format string. Used to format numeric values to display as strings. Using `Axx` form: `A` is the single character of the format specifier, supporting `C` currency, `D` decimal, `E` exponent, `F` number of vertices, `G` regular, `N` digits, `P` percentage, `R` round tripping, `X` hex etc. `XX` is the precision specification, from `0` - `99`. see: <https://docs.microsoft.com/zh-cn/dotnet/standard/base-types/standard-numeric-format-strings>
|
||||
* `fixedWidth`: Fixed width. Higher priority than `minWidth`.
|
||||
* `fixedHeight`: Fixed height. Higher priority than `minHeight`.
|
||||
* `minWidth`: Minimum width. If `fixedWidth` has a value, get `fixedWidth` first.
|
||||
@@ -260,7 +268,7 @@ Vessel component for liquid chart. There can be multiple vessels in a Chart, whi
|
||||
## `DataZoom`
|
||||
|
||||
DataZoom component is used for zooming a specific area, which enables user to investigate data in detail, or get an overview of the data, or get rid of outlier points.
|
||||
Currently only the control 'X' axis is supported.
|
||||
Currently only the control `X` axis is supported.
|
||||
|
||||
* `enable`: Whether to show dataZoom.
|
||||
* `supportInside`: Whether built-in support is supported. Built into the coordinate system to allow the user to zoom in and out of the coordinate system by mouse dragging, mouse wheel, finger swiping (on the touch screen).
|
||||
@@ -308,7 +316,7 @@ VisualMap component. mapping data to visual elements such as colors.
|
||||
* `min`: The minimum allowed. `min` must be user specified. `[min, max]` forms the domain of the visualMap.
|
||||
* `max`: The maximum allowed. `max` must be user specified. `[min, max]` forms the domain of the visualMap.
|
||||
* `range`: Specifies the position of the numeric value corresponding to the handle. Range should be within the range of [min,max].
|
||||
* ~~`text`: Text on both ends. such as ['High', 'Low'].~~
|
||||
* ~~`text`: Text on both ends. such as [`High`, `Low`].~~
|
||||
* ~~`textGap`: The distance between the two text bodies.~~
|
||||
* `splitNumber`: For continuous data, it is automatically evenly divided into several segments and automatically matches the size of inRange color list when the default is 0.
|
||||
* `calculable`: Whether the handle used for dragging is displayed (the handle can be dragged to adjust the selected range).
|
||||
@@ -512,6 +520,7 @@ Line chart serie.
|
||||
* `space`: 扇区间隙。
|
||||
* `center`: 中心点坐标。当值为`0-1`的浮点数时表示百分比。
|
||||
* `radius`: 半径。`radius[0]`为内径,`radius[1]`为外径。当内径大于0时即为圆环图。
|
||||
* `minAngle`: The minimum angle of sector(0-360). It prevents some sector from being too small when value is small.
|
||||
* `roundCap`: 是否启用圆弧效果。
|
||||
* `ignore`: 是否开启忽略数据。当为 `true` 时,数据值为 `ignoreValue` 时不进行绘制,对应的`Label`和`Legend`也不会显示。
|
||||
* `ignoreValue`: 忽略数据的默认值。默认值默认为0,当 `ignore` 为 `true` 才有效。
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace XCharts
|
||||
if (MakeFoldout(prop, "m_Show"))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_IconType");
|
||||
PropertyField(prop, "m_ItemWidth");
|
||||
PropertyField(prop, "m_ItemHeight");
|
||||
PropertyField(prop, "m_ItemGap");
|
||||
|
||||
@@ -108,6 +108,7 @@ namespace XCharts
|
||||
PropertyField(prop, "m_Space");
|
||||
PropertyTwoFiled(prop, "m_Center");
|
||||
PropertyTwoFiled(prop, "m_Radius");
|
||||
PropertyField(prop, "m_MinAngle");
|
||||
PropertyField(prop, "m_RoundCap");
|
||||
PropertyField(prop, "m_Ignore");
|
||||
PropertyField(prop, "m_IgnoreValue");
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace XCharts
|
||||
if (MakeFoldout(prop, ""))
|
||||
{
|
||||
var btnWidth = 50;
|
||||
var btnRect = new Rect(pos.x + pos.width - btnWidth, pos.y, btnWidth, EditorGUIUtility.singleLineHeight);
|
||||
var btnRect = new Rect(pos.x + pos.width - btnWidth, pos.y, btnWidth, EditorGUIUtility.singleLineHeight);
|
||||
if (GUI.Button(btnRect, new GUIContent("Reset", "Reset to default settings")))
|
||||
{
|
||||
var chart = prop.serializedObject.targetObject as BaseChart;
|
||||
@@ -32,7 +32,8 @@ namespace XCharts
|
||||
PropertyField(prop, "m_LineSmoothness");
|
||||
PropertyField(prop, "m_LineSegmentDistance");
|
||||
PropertyField(prop, "m_CicleSmoothness");
|
||||
|
||||
PropertyField(prop, "m_LegendIconLineWidth");
|
||||
PropertyListField(prop, "m_LegendIconCornerRadius", true);
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,6 +361,14 @@ namespace XCharts
|
||||
public float runtimeWidth { get; private set; }
|
||||
public float runtimeHeight { get; private set; }
|
||||
|
||||
class AxisIndexValueInfo
|
||||
{
|
||||
public float min;
|
||||
public float max;
|
||||
}
|
||||
private Dictionary<int, AxisIndexValueInfo> m_XAxisIndexInfos = new Dictionary<int, AxisIndexValueInfo>();
|
||||
private Dictionary<int, AxisIndexValueInfo> m_YAxisIndexInfos = new Dictionary<int, AxisIndexValueInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// The start label.
|
||||
/// 组件的开始信息文本。
|
||||
@@ -395,7 +403,8 @@ namespace XCharts
|
||||
end = 70,
|
||||
m_ScrollSensitivity = 10,
|
||||
m_TextStyle = new TextStyle(),
|
||||
m_LineStyle = new LineStyle(LineStyle.Type.Solid){
|
||||
m_LineStyle = new LineStyle(LineStyle.Type.Solid)
|
||||
{
|
||||
opacity = 0.3f
|
||||
},
|
||||
m_AreaStyle = new AreaStyle()
|
||||
@@ -472,6 +481,23 @@ namespace XCharts
|
||||
return xAxisIndexs.Contains(index);// || yAxisIndexs.Contains(index);
|
||||
}
|
||||
|
||||
public Color32 GetFillerColor(Color32 themeColor)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(fillerColor)) return themeColor;
|
||||
else return fillerColor;
|
||||
}
|
||||
|
||||
public Color32 GetBackgroundColor(Color32 themeColor)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(backgroundColor)) return themeColor;
|
||||
else return backgroundColor;
|
||||
}
|
||||
public Color32 GetBorderColor(Color32 themeColor)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(borderColor)) return themeColor;
|
||||
else return borderColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示文本
|
||||
/// </summary>
|
||||
@@ -538,21 +564,71 @@ namespace XCharts
|
||||
runtimeHeight = chartHeight - runtimeTop - runtimeBottom;
|
||||
}
|
||||
|
||||
public Color32 GetFillerColor(Color32 themeColor)
|
||||
internal void SetXAxisIndexValueInfo(int xAxisIndex, float min, float max)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(fillerColor)) return themeColor;
|
||||
else return fillerColor;
|
||||
if (!m_XAxisIndexInfos.ContainsKey(xAxisIndex))
|
||||
{
|
||||
m_XAxisIndexInfos[xAxisIndex] = new AxisIndexValueInfo()
|
||||
{
|
||||
min = min,
|
||||
max = max
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
m_XAxisIndexInfos[xAxisIndex].min = min;
|
||||
m_XAxisIndexInfos[xAxisIndex].max = max;
|
||||
}
|
||||
}
|
||||
|
||||
public Color32 GetBackgroundColor(Color32 themeColor)
|
||||
internal void SetYAxisIndexValueInfo(int yAxisIndex, float min, float max)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(backgroundColor)) return themeColor;
|
||||
else return backgroundColor;
|
||||
if (!m_YAxisIndexInfos.ContainsKey(yAxisIndex))
|
||||
{
|
||||
m_YAxisIndexInfos[yAxisIndex] = new AxisIndexValueInfo()
|
||||
{
|
||||
min = min,
|
||||
max = max
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
m_YAxisIndexInfos[yAxisIndex].min = min;
|
||||
m_YAxisIndexInfos[yAxisIndex].max = max;
|
||||
}
|
||||
}
|
||||
public Color32 GetBorderColor(Color32 themeColor)
|
||||
|
||||
internal bool IsXAxisIndexValue(int axisIndex)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(borderColor)) return themeColor;
|
||||
else return borderColor;
|
||||
return m_XAxisIndexInfos.ContainsKey(axisIndex);
|
||||
}
|
||||
|
||||
internal bool IsYAxisIndexValue(int axisIndex)
|
||||
{
|
||||
return m_YAxisIndexInfos.ContainsKey(axisIndex);
|
||||
}
|
||||
|
||||
internal void GetXAxisIndexValue(int axisIndex, out float min, out float max)
|
||||
{
|
||||
min = 0;
|
||||
max = 0;
|
||||
if (m_XAxisIndexInfos.ContainsKey(axisIndex))
|
||||
{
|
||||
var info = m_XAxisIndexInfos[axisIndex];
|
||||
min = info.min;
|
||||
max = info.max;
|
||||
}
|
||||
}
|
||||
internal void GetYAxisIndexValue(int axisIndex, out float min, out float max)
|
||||
{
|
||||
min = 0;
|
||||
max = 0;
|
||||
if (m_YAxisIndexInfos.ContainsKey(axisIndex))
|
||||
{
|
||||
var info = m_YAxisIndexInfos[axisIndex];
|
||||
min = info.min;
|
||||
max = info.max;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,37 @@ namespace XCharts
|
||||
[System.Serializable]
|
||||
public class Legend : MainComponent, IPropertyChanged
|
||||
{
|
||||
public enum Type
|
||||
{
|
||||
/// <summary>
|
||||
/// 自动匹配。
|
||||
/// </summary>
|
||||
Auto,
|
||||
/// <summary>
|
||||
/// 自定义图标。
|
||||
/// </summary>
|
||||
Custom,
|
||||
/// <summary>
|
||||
/// 空心圆。
|
||||
/// </summary>
|
||||
EmptyCircle,
|
||||
/// <summary>
|
||||
/// 圆形。
|
||||
/// </summary>
|
||||
Circle,
|
||||
/// <summary>
|
||||
/// 正方形。可通过Setting的legendIconCornerRadius参数调整圆角。
|
||||
/// </summary>
|
||||
Rect,
|
||||
/// <summary>
|
||||
/// 三角形。
|
||||
/// </summary>
|
||||
Triangle,
|
||||
/// <summary>
|
||||
/// 菱形。
|
||||
/// </summary>
|
||||
Diamond,
|
||||
}
|
||||
/// <summary>
|
||||
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
|
||||
/// 图例选择的模式,控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。
|
||||
@@ -39,10 +70,11 @@ namespace XCharts
|
||||
None
|
||||
}
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Type m_IconType;
|
||||
[SerializeField] private SelectedMode m_SelectedMode;
|
||||
[SerializeField] private Orient m_Orient = Orient.Horizonal;
|
||||
[SerializeField] private Location m_Location = Location.defaultRight;
|
||||
[SerializeField] private float m_ItemWidth = 24.0f;
|
||||
[SerializeField] private float m_ItemWidth = 25.0f;
|
||||
[SerializeField] private float m_ItemHeight = 12.0f;
|
||||
[SerializeField] private float m_ItemGap = 10f;
|
||||
[SerializeField] private bool m_ItemAutoColor = true;
|
||||
@@ -64,11 +96,20 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Type of legend.
|
||||
/// 图例类型。
|
||||
/// [default:Type.Auto]
|
||||
/// </summary>
|
||||
public Type iconType
|
||||
{
|
||||
get { return m_IconType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_IconType, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
|
||||
/// 选择模式。控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 None 关闭。
|
||||
/// [default:SelectedMode.Multiple]
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public SelectedMode selectedMode
|
||||
{
|
||||
get { return m_SelectedMode; }
|
||||
@@ -226,11 +267,12 @@ namespace XCharts
|
||||
{
|
||||
var legend = new Legend
|
||||
{
|
||||
m_IconType = Type.Auto,
|
||||
m_Show = false,
|
||||
m_SelectedMode = SelectedMode.Multiple,
|
||||
m_Orient = Orient.Horizonal,
|
||||
m_Location = Location.defaultTop,
|
||||
m_ItemWidth = 24.0f,
|
||||
m_ItemWidth = 25.0f,
|
||||
m_ItemHeight = 12.0f,
|
||||
m_ItemGap = 10f,
|
||||
};
|
||||
@@ -336,6 +378,7 @@ namespace XCharts
|
||||
{
|
||||
m_DataBtnList[name] = item;
|
||||
int index = m_DataBtnList.Values.Count;
|
||||
item.SetIconActive(iconType == Type.Custom);
|
||||
item.SetActive(show);
|
||||
}
|
||||
|
||||
|
||||
@@ -256,6 +256,7 @@ namespace XCharts
|
||||
[SerializeField] private float m_Max;
|
||||
[SerializeField] private float m_StartAngle;
|
||||
[SerializeField] private float m_EndAngle;
|
||||
[SerializeField] private float m_MinAngle;
|
||||
[SerializeField] private bool m_Clockwise = true;
|
||||
[FormerlySerializedAs("m_ArcShaped")]
|
||||
[SerializeField] private bool m_RoundCap;
|
||||
@@ -295,14 +296,16 @@ namespace XCharts
|
||||
|
||||
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
||||
|
||||
[NonSerialized] private int m_FilterStart;
|
||||
[NonSerialized] private int m_FilterEnd;
|
||||
[NonSerialized] private int m_FilterMinShow;
|
||||
[NonSerialized] private List<SerieData> m_FilterData;
|
||||
[NonSerialized] internal int m_FilterStart;
|
||||
[NonSerialized] internal int m_FilterEnd;
|
||||
[NonSerialized] internal float m_FilterStartValue;
|
||||
[NonSerialized] internal float m_FilterEndValue;
|
||||
[NonSerialized] internal int m_FilterMinShow;
|
||||
[NonSerialized] internal bool m_NeedUpdateFilterData;
|
||||
[NonSerialized] internal List<SerieData> m_FilterData = new List<SerieData>();
|
||||
[NonSerialized] private Dictionary<int, List<Vector3>> m_UpSmoothPoints = new Dictionary<int, List<Vector3>>();
|
||||
[NonSerialized] private Dictionary<int, List<Vector3>> m_DownSmoothPoints = new Dictionary<int, List<Vector3>>();
|
||||
[NonSerialized] private List<Vector3> m_DataPoints = new List<Vector3>();
|
||||
[NonSerialized] private bool m_NeedUpdateFilterData;
|
||||
[NonSerialized] private bool m_NameDirty;
|
||||
|
||||
/// <summary>
|
||||
@@ -630,6 +633,15 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetStruct(ref m_EndAngle, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The minimum angle of sector(0-360). It prevents some sector from being too small when value is small.
|
||||
/// 最小的扇区角度(0-360)。用于防止某个值过小导致扇区太小影响交互。
|
||||
/// </summary>
|
||||
public float minAngle
|
||||
{
|
||||
get { return m_MinAngle; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MinAngle, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否顺时针。
|
||||
/// </summary>
|
||||
public bool clockwise
|
||||
@@ -1426,7 +1438,7 @@ namespace XCharts
|
||||
if (dataZoom != null && dataZoom.enable
|
||||
&& (dataZoom.xAxisIndexs.Contains(xAxisIndex) || dataZoom.yAxisIndexs.Contains(yAxisIndex)))
|
||||
{
|
||||
UpdateFilterData(dataZoom);
|
||||
SerieHelper.UpdateFilterData(this, dataZoom);
|
||||
return m_FilterData;
|
||||
}
|
||||
else
|
||||
@@ -1435,53 +1447,6 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private List<SerieData> emptyFilter = new List<SerieData>();
|
||||
/// <summary>
|
||||
/// 根据dataZoom更新数据列表缓存
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
internal void UpdateFilterData(DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.enable
|
||||
&& (dataZoom.xAxisIndexs.Contains(xAxisIndex) || dataZoom.yAxisIndexs.Contains(yAxisIndex)))
|
||||
{
|
||||
var startIndex = (int)((data.Count - 1) * dataZoom.start / 100);
|
||||
var endIndex = (int)((data.Count - 1) * dataZoom.end / 100);
|
||||
if (endIndex < startIndex) endIndex = startIndex;
|
||||
|
||||
if (startIndex != m_FilterStart || endIndex != m_FilterEnd || dataZoom.minShowNum != m_FilterMinShow || m_NeedUpdateFilterData)
|
||||
{
|
||||
m_FilterStart = startIndex;
|
||||
m_FilterEnd = endIndex;
|
||||
m_FilterMinShow = dataZoom.minShowNum;
|
||||
m_NeedUpdateFilterData = false;
|
||||
var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1;
|
||||
if (count < dataZoom.minShowNum)
|
||||
{
|
||||
if (dataZoom.minShowNum > m_Data.Count) count = m_Data.Count;
|
||||
else count = dataZoom.minShowNum;
|
||||
}
|
||||
if (m_Data.Count > 0)
|
||||
{
|
||||
if (startIndex + count > m_Data.Count)
|
||||
{
|
||||
int start = endIndex - count;
|
||||
m_FilterData = m_Data.GetRange(start < 0 ? 0 : start, count);
|
||||
}
|
||||
else m_FilterData = m_Data.GetRange(startIndex, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_FilterData = m_Data;
|
||||
}
|
||||
}
|
||||
else if (endIndex == 0)
|
||||
{
|
||||
m_FilterData = emptyFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新指定索引的维度Y数据
|
||||
/// </summary>
|
||||
|
||||
@@ -539,7 +539,7 @@ namespace XCharts
|
||||
{
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
m_Series[i].UpdateFilterData(dataZoom);
|
||||
SerieHelper.UpdateFilterData(m_Series[i], dataZoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace XCharts
|
||||
[SerializeField] [Range(1f, 20)] protected float m_LineSmoothness = 2f;
|
||||
[SerializeField] [Range(1f, 20)] protected float m_LineSegmentDistance = 3f;
|
||||
[SerializeField] [Range(1, 10)] protected float m_CicleSmoothness = 2f;
|
||||
[SerializeField] protected float m_LegendIconLineWidth = 2;
|
||||
[SerializeField] private float[] m_LegendIconCornerRadius = new float[] { 0.25f, 0.25f, 0.25f, 0.25f };
|
||||
|
||||
/// <summary>
|
||||
/// max painter.
|
||||
@@ -75,6 +77,26 @@ namespace XCharts
|
||||
set { if (PropertyUtil.SetStruct(ref m_CicleSmoothness, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the width of line serie legend.
|
||||
/// Line类型图例图标的线条宽度。
|
||||
/// </summary>
|
||||
public float legendIconLineWidth
|
||||
{
|
||||
get { return m_LegendIconLineWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LegendIconLineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The radius of rounded corner. Its unit is px. Use array to respectively specify the 4 corner radiuses((clockwise upper left, upper right, bottom right and bottom left)).
|
||||
/// 图例圆角半径。用数组分别指定4个圆角半径(顺时针左上,右上,右下,左下)。
|
||||
/// </summary>
|
||||
public float[] legendIconCornerRadius
|
||||
{
|
||||
get { return m_LegendIconCornerRadius; }
|
||||
set { if (PropertyUtil.SetClass(ref m_LegendIconCornerRadius, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public void Copy(Settings settings)
|
||||
{
|
||||
m_MaxPainter = settings.maxPainter;
|
||||
@@ -82,6 +104,8 @@ namespace XCharts
|
||||
m_LineSmoothness = settings.lineSmoothness;
|
||||
m_LineSegmentDistance = settings.lineSegmentDistance;
|
||||
m_CicleSmoothness = settings.cicleSmoothness;
|
||||
m_LegendIconLineWidth = settings.legendIconLineWidth;
|
||||
ChartHelper.CopyArray(m_LegendIconCornerRadius, settings.legendIconCornerRadius);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
@@ -100,6 +124,8 @@ namespace XCharts
|
||||
m_LineSmoothness = XChartsSettings.lineSmoothness,
|
||||
m_LineSegmentDistance = XChartsSettings.lineSegmentDistance,
|
||||
m_CicleSmoothness = XChartsSettings.cicleSmoothness,
|
||||
m_LegendIconLineWidth = 2,
|
||||
m_LegendIconCornerRadius = new float[] { 0.25f, 0.25f, 0.25f, 0.25f }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -815,6 +815,7 @@ namespace XCharts
|
||||
vh.Clear();
|
||||
DrawBackground(vh);
|
||||
DrawPainterBase(vh);
|
||||
DrawLegend(vh);
|
||||
foreach (var drawSerie in m_DrawSeries) drawSerie.DrawBase(vh);
|
||||
}
|
||||
|
||||
@@ -868,6 +869,81 @@ namespace XCharts
|
||||
UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, backgroundColor);
|
||||
}
|
||||
|
||||
protected virtual void DrawLegend(VertexHelper vh)
|
||||
{
|
||||
if (m_Series.Count == 0) return;
|
||||
foreach (var legend in m_Legends)
|
||||
{
|
||||
if (!legend.show) continue;
|
||||
if (legend.iconType == Legend.Type.Custom) continue;
|
||||
foreach (var kv in legend.buttonList)
|
||||
{
|
||||
var item = kv.Value;
|
||||
var rect = item.GetIconRect();
|
||||
var radius = Mathf.Min(rect.width, rect.height) / 2;
|
||||
var color = item.GetIconColor();
|
||||
var iconType = legend.iconType;
|
||||
if (legend.iconType == Legend.Type.Auto)
|
||||
{
|
||||
var serie = m_Series.GetSerie(item.legendName);
|
||||
if (serie != null && serie.type == SerieType.Line)
|
||||
{
|
||||
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, m_Settings.legendIconLineWidth, color);
|
||||
if (!serie.symbol.show) continue;
|
||||
switch (serie.symbol.type)
|
||||
{
|
||||
case SerieSymbolType.None:
|
||||
continue;
|
||||
case SerieSymbolType.Circle:
|
||||
iconType = Legend.Type.Circle;
|
||||
break;
|
||||
case SerieSymbolType.Diamond:
|
||||
iconType = Legend.Type.Diamond;
|
||||
break;
|
||||
case SerieSymbolType.EmptyCircle:
|
||||
iconType = Legend.Type.EmptyCircle;
|
||||
break;
|
||||
case SerieSymbolType.Rect:
|
||||
iconType = Legend.Type.Rect;
|
||||
break;
|
||||
case SerieSymbolType.Triangle:
|
||||
iconType = Legend.Type.Triangle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iconType = Legend.Type.Rect;
|
||||
}
|
||||
}
|
||||
switch (iconType)
|
||||
{
|
||||
case Legend.Type.Rect:
|
||||
var cornerRadius = m_Settings.legendIconCornerRadius;
|
||||
UGL.DrawRoundRectangle(vh, rect.center, rect.width, rect.height, color, color,
|
||||
0, cornerRadius, false, 0.5f);
|
||||
break;
|
||||
case Legend.Type.Circle:
|
||||
UGL.DrawCricle(vh, rect.center, radius, color);
|
||||
break;
|
||||
case Legend.Type.Diamond:
|
||||
UGL.DrawDiamond(vh, rect.center, radius, color);
|
||||
break;
|
||||
case Legend.Type.EmptyCircle:
|
||||
var backgroundColor = ThemeHelper.GetBackgroundColor(m_Theme, m_Background);
|
||||
UGL.DrawEmptyCricle(vh, rect.center, radius, 2 * m_Settings.legendIconLineWidth,
|
||||
color, color, backgroundColor, 1f);
|
||||
break;
|
||||
case Legend.Type.Triangle:
|
||||
UGL.DrawTriangle(vh, rect.center, 1.2f * radius, color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawSymbol(VertexHelper vh, SerieSymbolType type, float symbolSize,
|
||||
float tickness, Vector3 pos, Color32 color, Color32 toColor, float gap, float[] cornerRadius)
|
||||
{
|
||||
|
||||
@@ -843,6 +843,11 @@ namespace XCharts
|
||||
Mathf.Abs(axis.runtimeMinValue) * (grid.runtimeHeight / (Mathf.Abs(axis.runtimeMinValue) + Mathf.Abs(axis.runtimeMaxValue)));
|
||||
}
|
||||
}
|
||||
if (dataZoom != null && dataZoom.enable)
|
||||
{
|
||||
if (axis is XAxis) dataZoom.SetXAxisIndexValueInfo(axisIndex, tempMinValue, tempMaxValue);
|
||||
else dataZoom.SetXAxisIndexValueInfo(axisIndex, tempMinValue, tempMaxValue);
|
||||
}
|
||||
if (updateChart)
|
||||
{
|
||||
UpdateAxisLabelText(axis);
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace XCharts
|
||||
var rate = serie.animation.GetCurrRate();
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
var dataChanging = false;
|
||||
for (int n = serie.minShow; n < maxCount; n++)
|
||||
var dataList = serie.GetDataList(dataZoom);
|
||||
foreach (var serieData in dataList)
|
||||
{
|
||||
var serieData = serie.GetDataList(dataZoom)[n];
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
|
||||
if (!symbol.ShowSymbol(n, maxCount)) continue;
|
||||
if (!symbol.ShowSymbol(serieData.index, maxCount)) continue;
|
||||
var highlight = serie.highlighted || serieData.highlighted;
|
||||
var color = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
@@ -46,7 +46,7 @@ namespace XCharts
|
||||
var pos = new Vector3(pX + xDataHig, pY + yDataHig);
|
||||
serie.dataPoints.Add(pos);
|
||||
serieData.runtimePosition = pos;
|
||||
var datas = serie.data[n].data;
|
||||
var datas = serieData.data;
|
||||
float symbolSize = 0;
|
||||
if (serie.highlighted || serieData.highlighted)
|
||||
{
|
||||
|
||||
@@ -168,10 +168,11 @@ namespace XCharts
|
||||
var data = serie.data;
|
||||
serie.runtimeDataMax = serie.yMax;
|
||||
serie.runtimePieDataTotal = serie.yTotal;
|
||||
serie.animation.InitProgress(data.Count, 0, 360);
|
||||
|
||||
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
float totalDegree = 360f;
|
||||
float totalDegree = 0;
|
||||
float startDegree = 0;
|
||||
float zeroReplaceValue = 0;
|
||||
int showdataCount = 0;
|
||||
foreach (var sd in serie.data)
|
||||
{
|
||||
@@ -180,12 +181,19 @@ namespace XCharts
|
||||
}
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
bool isAllZeroValue = SerieHelper.IsAllZeroValue(serie, 1);
|
||||
float zeroReplaceValue = totalDegree / data.Count;
|
||||
var dataTotalFilterMinAngle = serie.runtimePieDataTotal;
|
||||
if (isAllZeroValue)
|
||||
{
|
||||
totalDegree = 360;
|
||||
zeroReplaceValue = totalDegree / data.Count;
|
||||
serie.runtimeDataMax = zeroReplaceValue;
|
||||
serie.runtimePieDataTotal = totalDegree;
|
||||
serie.runtimePieDataTotal = 360;
|
||||
}
|
||||
else
|
||||
{
|
||||
dataTotalFilterMinAngle = GetTotalAngle(serie, serie.runtimePieDataTotal, ref totalDegree);
|
||||
}
|
||||
serie.animation.InitProgress(data.Count, 0, 360);
|
||||
for (int n = 0; n < data.Count; n++)
|
||||
{
|
||||
var serieData = data[n];
|
||||
@@ -199,12 +207,14 @@ namespace XCharts
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float degree = serie.pieRoseType == RoseType.Area ?
|
||||
(totalDegree / showdataCount) : (totalDegree * value / serie.runtimePieDataTotal);
|
||||
float degree = serie.pieRoseType == RoseType.Area
|
||||
? (totalDegree / showdataCount)
|
||||
: (totalDegree * value / dataTotalFilterMinAngle);
|
||||
if (serie.minAngle > 0 && degree < serie.minAngle) degree = serie.minAngle;
|
||||
serieData.runtimePieToAngle = startDegree + degree;
|
||||
|
||||
serieData.runtimePieOutsideRadius = serie.pieRoseType > 0 ?
|
||||
serie.runtimeInsideRadius + (serie.runtimeOutsideRadius - serie.runtimeInsideRadius) * value / serie.runtimeDataMax :
|
||||
serie.runtimeInsideRadius +
|
||||
(serie.runtimeOutsideRadius - serie.runtimeInsideRadius) * value / serie.runtimeDataMax :
|
||||
serie.runtimeOutsideRadius;
|
||||
if (serieData.highlighted)
|
||||
{
|
||||
@@ -238,10 +248,14 @@ namespace XCharts
|
||||
if (serie.pieClickOffset && serieData.selected)
|
||||
{
|
||||
serieData.runtimePieOffsetRadius += chart.theme.serie.pieSelectedOffset;
|
||||
if (serieData.runtimePieInsideRadius > 0) serieData.runtimePieInsideRadius += chart.theme.serie.pieSelectedOffset;
|
||||
if (serieData.runtimePieInsideRadius > 0)
|
||||
{
|
||||
serieData.runtimePieInsideRadius += chart.theme.serie.pieSelectedOffset;
|
||||
}
|
||||
serieData.runtimePieOutsideRadius += chart.theme.serie.pieSelectedOffset;
|
||||
}
|
||||
serieData.runtiemPieOffsetCenter = new Vector3(serie.runtimeCenterPos.x + serieData.runtimePieOffsetRadius * currSin,
|
||||
serieData.runtiemPieOffsetCenter = new Vector3(
|
||||
serie.runtimeCenterPos.x + serieData.runtimePieOffsetRadius * currSin,
|
||||
serie.runtimeCenterPos.y + serieData.runtimePieOffsetRadius * currCos);
|
||||
}
|
||||
serieData.canShowLabel = serieData.runtimePieCurrAngle >= serieData.runtimePieHalfAngle;
|
||||
@@ -251,6 +265,30 @@ namespace XCharts
|
||||
SerieLabelHelper.AvoidLabelOverlap(serie);
|
||||
}
|
||||
|
||||
private float GetTotalAngle(Serie serie, float dataTotal, ref float totalAngle)
|
||||
{
|
||||
totalAngle = 360f;
|
||||
if (serie.minAngle > 0)
|
||||
{
|
||||
var rate = serie.minAngle / 360;
|
||||
var minAngleValue = dataTotal * rate;
|
||||
foreach (var serieData in serie.data)
|
||||
{
|
||||
var value = serieData.GetData(1);
|
||||
if (value < minAngleValue)
|
||||
{
|
||||
totalAngle -= serie.minAngle;
|
||||
dataTotal -= value;
|
||||
}
|
||||
}
|
||||
return dataTotal;
|
||||
}
|
||||
else
|
||||
{
|
||||
return dataTotal;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPieCenter(VertexHelper vh, Serie serie, ItemStyle itemStyle, float insideRadius)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(itemStyle.centerColor))
|
||||
@@ -279,8 +317,10 @@ namespace XCharts
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.highlighted);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
var serieNameCount = chart.m_LegendRealShowName.IndexOf(serieData.legendName);
|
||||
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieNameCount, serieData.highlighted);
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieNameCount, serieData.highlighted);
|
||||
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieNameCount,
|
||||
serieData.highlighted);
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieNameCount,
|
||||
serieData.highlighted);
|
||||
var borderWidth = itemStyle.borderWidth;
|
||||
var borderColor = itemStyle.borderColor;
|
||||
|
||||
@@ -289,16 +329,18 @@ namespace XCharts
|
||||
var drawEndDegree = serieData.runtimePieCurrAngle;
|
||||
var needRoundCap = serie.roundCap && serieData.runtimePieInsideRadius > 0;
|
||||
UGL.DrawDoughnut(vh, serieData.runtiemPieOffsetCenter, serieData.runtimePieInsideRadius,
|
||||
serieData.runtimePieOutsideRadius, color, toColor, Color.clear, serieData.runtimePieStartAngle, drawEndDegree,
|
||||
borderWidth, borderColor, serie.pieSpace / 2, chart.settings.cicleSmoothness, needRoundCap, true);
|
||||
serieData.runtimePieOutsideRadius, color, toColor, Color.clear, serieData.runtimePieStartAngle,
|
||||
drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2, chart.settings.cicleSmoothness,
|
||||
needRoundCap, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
var drawEndDegree = serieData.runtimePieCurrAngle;
|
||||
var needRoundCap = serie.roundCap && serieData.runtimePieInsideRadius > 0;
|
||||
UGL.DrawDoughnut(vh, serie.runtimeCenterPos, serieData.runtimePieInsideRadius, serieData.runtimePieOutsideRadius,
|
||||
color, toColor, Color.clear, serieData.runtimePieStartAngle, drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2,
|
||||
chart.settings.cicleSmoothness, needRoundCap, true);
|
||||
UGL.DrawDoughnut(vh, serie.runtimeCenterPos, serieData.runtimePieInsideRadius,
|
||||
serieData.runtimePieOutsideRadius, color, toColor, Color.clear, serieData.runtimePieStartAngle,
|
||||
drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2, chart.settings.cicleSmoothness,
|
||||
needRoundCap, true);
|
||||
DrawPieCenter(vh, serie, itemStyle, serieData.runtimePieInsideRadius);
|
||||
}
|
||||
if (!serie.animation.CheckDetailBreak(serieData.runtimePieToAngle)) serie.animation.SetDataFinish(n);
|
||||
@@ -432,14 +474,16 @@ namespace XCharts
|
||||
pos6 = pos0 + Vector3.left * lineCircleDiff;
|
||||
pos4 = pos6 + Vector3.left * r4;
|
||||
}
|
||||
var pos5 = new Vector3(currAngle > 180 ? pos2.x - serieLabel.lineLength2 : pos2.x + serieLabel.lineLength2, pos2.y);
|
||||
var pos5X = currAngle > 180 ? pos2.x - serieLabel.lineLength2 : pos2.x + serieLabel.lineLength2;
|
||||
var pos5 = new Vector3(pos5X, pos2.y);
|
||||
switch (serieLabel.lineType)
|
||||
{
|
||||
case SerieLabel.LineType.BrokenLine:
|
||||
UGL.DrawLine(vh, pos1, pos2, pos5, serieLabel.lineWidth, color);
|
||||
break;
|
||||
case SerieLabel.LineType.Curves:
|
||||
UGL.DrawCurves(vh, pos1, pos5, pos1, pos2, serieLabel.lineWidth, color, chart.settings.lineSmoothness);
|
||||
UGL.DrawCurves(vh, pos1, pos5, pos1, pos2, serieLabel.lineWidth, color,
|
||||
chart.settings.lineSmoothness);
|
||||
break;
|
||||
case SerieLabel.LineType.HorizontalLine:
|
||||
UGL.DrawCricle(vh, pos0, horizontalLineCircleRadius, color);
|
||||
@@ -472,7 +516,10 @@ namespace XCharts
|
||||
Color color = serieColor;
|
||||
if (isHighlight)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(serie.emphasis.label.textStyle.color)) color = serie.emphasis.label.textStyle.color;
|
||||
if (!ChartHelper.IsClearColor(serie.emphasis.label.textStyle.color))
|
||||
{
|
||||
color = serie.emphasis.label.textStyle.color;
|
||||
}
|
||||
}
|
||||
else if (!ChartHelper.IsClearColor(serieLabel.textStyle.color))
|
||||
{
|
||||
@@ -485,7 +532,9 @@ namespace XCharts
|
||||
var fontSize = isHighlight
|
||||
? serie.emphasis.label.textStyle.GetFontSize(chart.theme.common)
|
||||
: serieLabel.textStyle.GetFontSize(chart.theme.common);
|
||||
var fontStyle = isHighlight ? serie.emphasis.label.textStyle.fontStyle : serieLabel.textStyle.fontStyle;
|
||||
var fontStyle = isHighlight
|
||||
? serie.emphasis.label.textStyle.fontStyle
|
||||
: serieLabel.textStyle.fontStyle;
|
||||
|
||||
serieData.labelObject.label.SetColor(color);
|
||||
serieData.labelObject.label.SetFontSize(fontSize);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
@@ -305,5 +306,105 @@ namespace XCharts
|
||||
serie.runtimeDataMax = ChartHelper.GetMaxDivisibleValue(max, ceilRate);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<SerieData> emptyFilter = new List<SerieData>();
|
||||
/// <summary>
|
||||
/// 根据dataZoom更新数据列表缓存
|
||||
/// </summary>
|
||||
/// <param name="dataZoom"></param>
|
||||
internal static void UpdateFilterData(Serie serie, DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.enable
|
||||
&& (dataZoom.xAxisIndexs.Contains(serie.xAxisIndex) || dataZoom.yAxisIndexs.Contains(serie.yAxisIndex)))
|
||||
{
|
||||
if (dataZoom.IsXAxisIndexValue(serie.xAxisIndex))
|
||||
{
|
||||
float min = 0, max = 0;
|
||||
dataZoom.GetXAxisIndexValue(serie.xAxisIndex, out min, out max);
|
||||
UpdateFilterData_XAxisValue(serie, dataZoom, 0, min, max);
|
||||
}
|
||||
else if (dataZoom.IsYAxisIndexValue(serie.yAxisIndex))
|
||||
{
|
||||
float min = 0, max = 0;
|
||||
dataZoom.GetYAxisIndexValue(serie.yAxisIndex, out min, out max);
|
||||
UpdateFilterData_XAxisValue(serie, dataZoom, 0, min, max);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateFilterData_Category(serie, dataZoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateFilterData_XAxisValue(Serie serie, DataZoom dataZoom, int dimension, float min, float max)
|
||||
{
|
||||
var data = serie.data;
|
||||
var startValue = min + (max - min) * dataZoom.start / 100;
|
||||
var endValue = min + (max - min) * dataZoom.end / 100;
|
||||
if (endValue < startValue) endValue = startValue;
|
||||
|
||||
if (startValue != serie.m_FilterStartValue || endValue != serie.m_FilterEndValue
|
||||
|| dataZoom.minShowNum != serie.m_FilterMinShow || serie.m_NeedUpdateFilterData)
|
||||
{
|
||||
serie.m_FilterStartValue = startValue;
|
||||
serie.m_FilterEndValue = endValue;
|
||||
serie.m_FilterMinShow = dataZoom.minShowNum;
|
||||
serie.m_NeedUpdateFilterData = false;
|
||||
|
||||
serie.m_FilterData.Clear();
|
||||
foreach (var serieData in data)
|
||||
{
|
||||
var value = serieData.GetData(dimension);
|
||||
if (value >= startValue && value <= endValue)
|
||||
{
|
||||
serie.m_FilterData.Add(serieData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (endValue == 0)
|
||||
{
|
||||
serie.m_FilterData = emptyFilter;
|
||||
}
|
||||
}
|
||||
|
||||
private static void UpdateFilterData_Category(Serie serie, DataZoom dataZoom)
|
||||
{
|
||||
var data = serie.data;
|
||||
var startIndex = (int)((data.Count - 1) * dataZoom.start / 100);
|
||||
var endIndex = (int)((data.Count - 1) * dataZoom.end / 100);
|
||||
if (endIndex < startIndex) endIndex = startIndex;
|
||||
|
||||
if (startIndex != serie.m_FilterStart || endIndex != serie.m_FilterEnd
|
||||
|| dataZoom.minShowNum != serie.m_FilterMinShow || serie.m_NeedUpdateFilterData)
|
||||
{
|
||||
serie.m_FilterStart = startIndex;
|
||||
serie.m_FilterEnd = endIndex;
|
||||
serie.m_FilterMinShow = dataZoom.minShowNum;
|
||||
serie.m_NeedUpdateFilterData = false;
|
||||
var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1;
|
||||
if (count < dataZoom.minShowNum)
|
||||
{
|
||||
if (dataZoom.minShowNum > data.Count) count = data.Count;
|
||||
else count = dataZoom.minShowNum;
|
||||
}
|
||||
if (data.Count > 0)
|
||||
{
|
||||
if (startIndex + count > data.Count)
|
||||
{
|
||||
int start = endIndex - count;
|
||||
data = data.GetRange(start < 0 ? 0 : start, count);
|
||||
}
|
||||
else serie.m_FilterData = data.GetRange(startIndex, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
serie.m_FilterData = data;
|
||||
}
|
||||
}
|
||||
else if (endIndex == 0)
|
||||
{
|
||||
serie.m_FilterData = emptyFilter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,6 +105,28 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public Rect GetIconRect()
|
||||
{
|
||||
if (m_GameObject && m_IconRect)
|
||||
{
|
||||
var pos = m_GameObject.transform.localPosition;
|
||||
var sizeDelta = m_IconRect.sizeDelta;
|
||||
var y = pos.y - (m_Rect.sizeDelta.y - sizeDelta.y) / 2 - sizeDelta.y;
|
||||
return new Rect(pos.x, y, m_IconRect.sizeDelta.x, m_IconRect.sizeDelta.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Rect.zero;
|
||||
}
|
||||
}
|
||||
|
||||
public Color GetIconColor()
|
||||
{
|
||||
if (m_Icon) return m_Icon.color;
|
||||
else return Color.clear;
|
||||
}
|
||||
|
||||
|
||||
public void SetIconColor(Color color)
|
||||
{
|
||||
if (m_Icon)
|
||||
@@ -121,6 +143,14 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public void SetIconActive(bool active)
|
||||
{
|
||||
if (m_Icon)
|
||||
{
|
||||
m_Icon.gameObject.SetActive(active);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetContentColor(Color color)
|
||||
{
|
||||
if (m_Text != null)
|
||||
|
||||
@@ -52,7 +52,6 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
//UGL.DrawPolygon(vh, pos, symbolSize, color, toColor);
|
||||
UGL.DrawRoundRectangle(vh, pos, symbolSize, symbolSize, color, color, 0, cornerRadius, true);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -621,6 +621,16 @@ namespace XCharts
|
||||
foreach (var item in fromList) toList.Add(item);
|
||||
return true;
|
||||
}
|
||||
public static bool CopyArray<T>(T[] toList, T[] fromList)
|
||||
{
|
||||
if (toList == null || fromList == null) return false;
|
||||
if (toList.Length != fromList.Length)
|
||||
{
|
||||
toList = new T[fromList.Length];
|
||||
}
|
||||
for (int i = 0; i < fromList.Length; i++) toList[i] = fromList[i];
|
||||
return true;
|
||||
}
|
||||
|
||||
public static List<float> ParseFloatFromString(string jsonData)
|
||||
{
|
||||
|
||||
@@ -566,7 +566,8 @@ namespace XUGL
|
||||
/// <param name="rotate"></param>
|
||||
/// <param name="cornerRadius"></param>
|
||||
public static void DrawRoundRectangle(VertexHelper vh, Vector3 center, float rectWidth, float rectHeight,
|
||||
Color32 color, Color32 toColor, float rotate = 0, float[] cornerRadius = null, bool isYAxis = false)
|
||||
Color32 color, Color32 toColor, float rotate = 0, float[] cornerRadius = null, bool isYAxis = false,
|
||||
float smoothness = 2)
|
||||
{
|
||||
var isGradient = !UGLHelper.IsValueEqualsColor(color, toColor);
|
||||
var halfWid = rectWidth / 2;
|
||||
@@ -645,10 +646,10 @@ namespace XUGL
|
||||
if (roundRbLeft.x < roundLb.x) roundRbLeft.x = roundLb.x;
|
||||
if (!isGradient)
|
||||
{
|
||||
DrawSector(vh, roundLt, brLt, color, color, 270, 360, 1, isYAxis);
|
||||
DrawSector(vh, roundRt, brRt, toColor, toColor, 0, 90, 1, isYAxis);
|
||||
DrawSector(vh, roundRb, brRb, toColor, toColor, 90, 180, 1, isYAxis);
|
||||
DrawSector(vh, roundLb, brLb, color, color, 180, 270, 1, isYAxis);
|
||||
DrawSector(vh, roundLt, brLt, color, color, 270, 360, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundRt, brRt, toColor, toColor, 0, 90, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundRb, brRb, toColor, toColor, 90, 180, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundLb, brLb, color, color, 180, 270, 1, isYAxis, smoothness);
|
||||
|
||||
DrawQuadrilateral(vh, ltIn, ltInRight, lbInRight, lbIn, color, color);
|
||||
DrawQuadrilateral(vh, lbIn2, roundLb, roundLbRight, lbIn2Right, color, color);
|
||||
@@ -677,10 +678,10 @@ namespace XUGL
|
||||
var upRightColor = Color32.Lerp(tempRightColor, toColor, (maxRight - brRt) / maxRight);
|
||||
var downRightColor = Color32.Lerp(tempRightColor, toColor, (maxRight - brRb) / maxRight);
|
||||
|
||||
DrawSector(vh, roundLt, brLt, color, upLeftColor, 270, 360, 1, isYAxis);
|
||||
DrawSector(vh, roundRt, brRt, upRightColor, toColor, 0, 90, 1, isYAxis);
|
||||
DrawSector(vh, roundRb, brRb, downRightColor, toColor, 90, 180, 1, isYAxis);
|
||||
DrawSector(vh, roundLb, brLb, color, downLeftColor, 180, 270, 1, isYAxis);
|
||||
DrawSector(vh, roundLt, brLt, color, upLeftColor, 270, 360, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundRt, brRt, upRightColor, toColor, 0, 90, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundRb, brRb, downRightColor, toColor, 90, 180, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundLb, brLb, color, downLeftColor, 180, 270, 1, isYAxis, smoothness);
|
||||
|
||||
DrawQuadrilateral(vh, lbIn, ltIn, ltInRight, lbInRight, color, tempLeftColor);
|
||||
DrawQuadrilateral(vh, lbIn2, roundLb, roundLbRight, lbIn2Right, downLeftColor,
|
||||
@@ -739,10 +740,10 @@ namespace XUGL
|
||||
|
||||
if (!isGradient)
|
||||
{
|
||||
DrawSector(vh, roundLt, brLt, toColor, toColor, 270, 360, 1, isYAxis);
|
||||
DrawSector(vh, roundRt, brRt, toColor, toColor, 0, 90, 1, isYAxis);
|
||||
DrawSector(vh, roundRb, brRb, color, color, 90, 180, 1, isYAxis);
|
||||
DrawSector(vh, roundLb, brLb, color, color, 180, 270, 1, isYAxis);
|
||||
DrawSector(vh, roundLt, brLt, toColor, toColor, 270, 360, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundRt, brRt, toColor, toColor, 0, 90, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundRb, brRb, color, color, 90, 180, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundLb, brLb, color, color, 180, 270, 1, isYAxis, smoothness);
|
||||
|
||||
DrawQuadrilateral(vh, ltIn2, rtIn, rtInDown, ltIn2Down, toColor, toColor);
|
||||
DrawQuadrilateral(vh, ltIn, roundLt, roundLtDown, ltInDown, toColor, toColor);
|
||||
@@ -765,10 +766,10 @@ namespace XUGL
|
||||
var leftDownColor = Color32.Lerp(color, tempDownColor, brLb / maxdown);
|
||||
var rightDownColor = Color32.Lerp(color, tempDownColor, brRb / maxdown);
|
||||
|
||||
DrawSector(vh, roundLt, brLt, leftUpColor, toColor, 270, 360, 1, isYAxis);
|
||||
DrawSector(vh, roundRt, brRt, rightUpColor, toColor, 0, 90, 1, isYAxis);
|
||||
DrawSector(vh, roundRb, brRb, rightDownColor, color, 90, 180, 1, isYAxis);
|
||||
DrawSector(vh, roundLb, brLb, leftDownColor, color, 180, 270, 1, isYAxis);
|
||||
DrawSector(vh, roundLt, brLt, leftUpColor, toColor, 270, 360, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundRt, brRt, rightUpColor, toColor, 0, 90, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundRb, brRb, rightDownColor, color, 90, 180, 1, isYAxis, smoothness);
|
||||
DrawSector(vh, roundLb, brLb, leftDownColor, color, 180, 270, 1, isYAxis, smoothness);
|
||||
|
||||
DrawQuadrilateral(vh, ltIn2, rtIn, rtInDown, ltIn2Down, toColor, tempUpColor);
|
||||
DrawQuadrilateral(vh, ltIn, roundLt, roundLtDown, ltInDown, leftUpColor,
|
||||
|
||||
Reference in New Issue
Block a user