增加LiquidChart水位图

This commit is contained in:
monitor1394
2020-07-06 08:41:28 +08:00
parent 16905ee336
commit 14023cc713
23 changed files with 847 additions and 5 deletions

View File

@@ -56,6 +56,10 @@ namespace XCharts
/// 环形图。只支持一个数据的环形图。
/// </summary>
Ring,
/// <summary>
/// 水位图。
/// </summary>
Liquid,
}
/// <summary>
@@ -218,6 +222,7 @@ namespace XCharts
[SerializeField] private string m_Stack;
[SerializeField] [Range(0, 1)] private int m_AxisIndex = 0;
[SerializeField] private int m_RadarIndex = 0;
[SerializeField] private int m_VesselIndex = 0;
[SerializeField] protected int m_MinShow;
[SerializeField] protected int m_MaxShow;
[SerializeField] protected int m_MaxCache;
@@ -274,6 +279,10 @@ namespace XCharts
[SerializeField] private bool m_Large = true;
[SerializeField] private int m_LargeThreshold = 200;
[SerializeField] private bool m_AvoidLabelOverlap = false;
[SerializeField] private float m_WaveHeight = 10f;
[SerializeField] private float m_WaveLength = 20f;
[SerializeField] private float m_WaveSpeed = 5f;
[SerializeField] private float m_WaveOffset = 0f;
[SerializeField] private RadarType m_RadarType = RadarType.Multiple;
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
@@ -347,6 +356,15 @@ namespace XCharts
set { if (PropertyUtility.SetStruct(ref m_RadarIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// Index of vesel component that liquid chart uses.
/// 水位图所使用的 vessel 组件的 index。
/// </summary>
public int vesselIndex
{
get { return m_VesselIndex; }
set { if (PropertyUtility.SetStruct(ref m_VesselIndex, value)) SetVerticesDirty(); }
}
/// <summary>
/// The min number of data to show in chart.
/// 系列所显示数据的最小索引
/// </summary>
@@ -796,6 +814,39 @@ namespace XCharts
set { if (PropertyUtility.SetStruct(ref m_AvoidLabelOverlap, value)) SetVerticesDirty(); }
}
/// <summary>
/// Wave length of the wave, which is relative to the diameter.
/// 波长。为0-1小数时指直线的百分比。
/// </summary>
public float waveLength
{
get { return m_WaveLength; }
set { if (PropertyUtility.SetStruct(ref m_WaveLength, value)) SetVerticesDirty(); }
}
/// <summary>
/// 波高。
/// </summary>
public float waveHeight
{
get { return m_WaveHeight; }
set { if (PropertyUtility.SetStruct(ref m_WaveHeight, value)) SetVerticesDirty(); }
}
/// <summary>
/// 波偏移。
/// </summary>
public float waveOffset
{
get { return m_WaveOffset; }
set { if (PropertyUtility.SetStruct(ref m_WaveOffset, value)) SetVerticesDirty(); }
}
/// <summary>
/// 波速。正数时左移,负数时右移。
/// </summary>
public float waveSpeed
{
get { return m_WaveSpeed; }
set { if (PropertyUtility.SetStruct(ref m_WaveSpeed, value)) SetVerticesDirty(); }
}
/// <summary>
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
/// </summary>
public List<SerieData> data { get { return m_Data; } }
@@ -891,7 +942,9 @@ namespace XCharts
/// 饼图的数据项之和
/// </summary>
public float runtimePieDataTotal { get; internal set; }
public float runtimeWaveSpeed { get; internal set; }
internal int runtimeLastCheckDataCount { get; set; }
internal float runtimeCheckValue { get; set; }
public bool nameDirty { get { return m_NameDirty; } }
private void SetNameDirty()

View File

@@ -0,0 +1,176 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System;
using UnityEngine;
namespace XCharts
{
/// <summary>
/// Vessel component for liquid chart.
/// <para>
/// 容器组件。
/// 一般用于LiquidChart。
/// </para>
/// </summary>
[Serializable]
public class Vessel : MainComponent
{
public enum Shape
{
/// <summary>
/// 圆形
/// </summary>
Circle,
/// <summary>
/// 正方形。
/// </summary>
Rect,
/// <summary>
/// 三角形。
/// </summary>
Triangle,
/// <summary>
/// 菱形。
/// </summary>
Diamond,
/// <summary>
/// 不显示标记。
/// </summary>
None,
}
[SerializeField] private bool m_Show = true;
[SerializeField] private Shape m_Shape = Shape.Circle;
[SerializeField] private float m_ShapeWidth = 5f;
[SerializeField] private float m_Gap = 10f;
[SerializeField] private Color m_Color;
[SerializeField] private Color m_BackgroundColor;
[SerializeField] private bool m_AutoColor = true;
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
[SerializeField] private float m_Radius = 0.5f;
[SerializeField] [Range(0.5f, 10f)] private float m_Smoothness = 1f;
/// <summary>
/// Whether to show the grid in rectangular coordinate.
/// 是否显示直角坐标系网格。
/// </summary>
public bool show
{
get { return m_Show; }
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
}
/// <summary>
/// 形状。
/// </summary>
public Shape shape
{
get { return m_Shape; }
set { if (PropertyUtility.SetStruct(ref m_Shape, value)) SetVerticesDirty(); }
}
/// <summary>
/// 容器宽度。
/// </summary>
public float shapeWidth
{
get { return m_ShapeWidth; }
set { if (PropertyUtility.SetStruct(ref m_ShapeWidth, value)) SetVerticesDirty(); }
}
/// <summary>
/// 间隙
/// </summary>
public float gap
{
get { return m_Gap; }
set { if (PropertyUtility.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
}
/// <summary>
/// 中心点。数组的第一项是横坐标,第二项是纵坐标。
/// 当值为0-1之间时表示百分比设置成百分比时第一项是相对于容器宽度第二项是相对于容器高度。
/// </summary>
public float[] center
{
get { return m_Center; }
set { if (value != null) { m_Center = value; SetAllDirty(); } }
}
/// <summary>
/// 半径。
/// </summary>
public float radius
{
get { return m_Radius; }
set { if (PropertyUtility.SetStruct(ref m_Radius, value)) SetAllDirty(); }
}
/// <summary>
/// 水波平滑度。
/// </summary>
public float smoothness
{
get { return m_Smoothness; }
set { if (PropertyUtility.SetStruct(ref m_Smoothness, value)) SetAllDirty(); }
}
/// <summary>
/// Background color of polar, which is transparent by default.
/// 背景色,默认透明。
/// </summary>
public Color backgroundColor
{
get { return m_BackgroundColor; }
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
}
/// <summary>
/// 容器颜色。默认和serie一致。
/// </summary>
public Color color
{
get { return m_Color; }
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
}
/// <summary>
/// 是否自动颜色。为true时颜色会和serie一致。
/// </summary>
public bool autoColor
{
get { return m_AutoColor; }
set { if (PropertyUtility.SetStruct(ref m_AutoColor, value)) SetVerticesDirty(); }
}
public int index { get; internal set; }
/// <summary>
/// the runtime center position of vessel.
/// 运行时中心点。
/// </summary>
public Vector3 runtimeCenterPos { get; internal set; }
/// <summary>
/// the runtime radius of vessel.
/// 运行时半径。
/// </summary>
public float runtimeRadius { get; internal set; }
/// <summary>
/// 运行时内半径。
/// </summary>
public float runtimeInnerRadius { get; internal set; }
public static Vessel defaultVessel
{
get
{
var vessel = new Vessel
{
m_Show = true,
m_Shape = Shape.Circle,
m_ShapeWidth = 5,
m_Gap = 10,
m_Radius = 0.35f,
m_AutoColor = true,
m_Color = new Color32(70, 70, 240, 255),
m_Smoothness = 1
};
vessel.center[0] = 0.5f;
vessel.center[1] = 0.45f;
return vessel;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04afad352c62a405691c66f18c3f9db7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: