#define Graph_And_Chart_PRO using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; using UnityEngine.UI; namespace ChartAndGraph { /// /// holds settings for an axis division. /// [Serializable] public class ChartDivisionInfo : IInternalSettings { public enum DivisionMessure { TotalDivisions, DataUnits } /// /// validates all properties of this instance. (check if they have correct values) /// public void ValidateProperites() { if (total < 0) total = 0; fontSharpness = Mathf.Clamp(fontSharpness, 1f, 3f); fontSize = Mathf.Max(fontSize, 0); fractionDigits = Mathf.Clamp(fractionDigits, 0, 7); markThickness = Mathf.Max(markThickness, 0f); materialTiling.TileFactor = Mathf.Max(materialTiling.TileFactor, 0f); textPrefix = (textPrefix == null) ? "" : textPrefix; textSuffix = (textSuffix == null) ? "" : textSuffix; } protected virtual float ValidateTotal(float total) { return total; } /// /// total division lines /// [SerializeField] [Canvas, NonCanvas] [Tooltip("messure used to create divisions")] protected DivisionMessure messure = DivisionMessure.TotalDivisions; /// /// data units per each division in the chart /// [SerializeField] [Canvas, NonCanvas] [Tooltip("data units per division")] protected float unitsPerDivision; /// /// total division lines /// [SerializeField] [Canvas, NonCanvas] [Tooltip("total division lines")] private int total = 3; /// /// total division lines /// public int Total { get { return total; } set { total = value; RaiseOnChanged(); } } /// /// Material for the line of the division /// [SerializeField] [Canvas, NonCanvas] [Tooltip("Material for the line of the division")] private Material material; /// /// Material for the division lines /// public Material Material { get { return material; } set { material = value; RaiseOnChanged(); } } /// /// Material tiling for the division lines. Use this to strech or tile the material along the line /// [SerializeField] [Canvas, NonCanvas] [Tooltip("Material tiling for the division lines. Use this to strech or tile the material along the line")] private MaterialTiling materialTiling = new MaterialTiling(false, 100f); /// /// Material tiling for the division lines. Use this to strech or tile the material along the line /// public MaterialTiling MaterialTiling { get {return materialTiling;} set { materialTiling = value; RaiseOnChanged(); } } /// /// The length of the far side of the division lines. This is used only by 3d chart when MarkDepth >0 /// [SerializeField] [Simple, NonCanvas] [Tooltip("The length of the far side of the division lines. This is used only by 3d chart when MarkDepth >0")] private AutoFloat markBackLength = new AutoFloat(true, 0.5f); /// /// The length of the far side of the division lines. This is used only by 3d charts when MarkDepth >0 /// public AutoFloat MarkBackLength { get { return markBackLength; } set { markBackLength = value; RaiseOnChanged(); } } /// /// The length of the the division lines. /// [SerializeField] [Simple, Canvas, NonCanvas] [Tooltip("The length of the the division lines.")] private AutoFloat markLength = new AutoFloat(true,0.5f); /// /// The length of the the division lines. /// public AutoFloat MarkLength { get { return markLength; } set { markLength = value; RaiseOnChanged(); } } /// /// the depth of the division line. This is used by 3d charts only /// [SerializeField] [Simple, NonCanvas] private AutoFloat markDepth = new AutoFloat(true,0.5f); public AutoFloat MarkDepth { get { return markDepth; } set { markDepth = value; RaiseOnChanged(); } } /// /// the thickness of the division lines /// [SerializeField] [Simple, Canvas, NonCanvas] [Tooltip("the thickness of the division lines")] private float markThickness = 0.1f; /// /// the thickness of the division lines /// public float MarkThickness { get { return markThickness; } set { markThickness = value; RaiseOnChanged(); } } /// /// A prefab for the division labels /// [SerializeField] [Simple,Canvas, NonCanvas] [Tooltip("A prefab for the division labels")] private MonoBehaviour textPrefab; /// /// A prefab for the division labels /// public MonoBehaviour TextPrefab { get { return textPrefab; } set { textPrefab = value; RaiseOnChanged(); } } /// /// prefix for the axis labels /// [SerializeField] [Simple,Canvas,NonCanvas] [Tooltip("prefix for the axis labels")] private string textPrefix; /// /// prefix for the axis labels /// public string TextPrefix { get { return textPrefix; } set { textPrefix = value; RaiseOnChanged(); } } /// /// suffix for the axis labels /// [SerializeField] [Simple, Canvas, NonCanvas] [Tooltip("suffix for the axis labels")] private string textSuffix; /// /// suffix for the axis labels /// public string TextSuffix { get { return textSuffix; } set { textSuffix = value; RaiseOnChanged(); } } /// /// the number of fraction digits in the division labels. /// [Range(0,7)] [Simple, Canvas, NonCanvas] [SerializeField] [Tooltip("the number of fraction digits in text labels")] private int fractionDigits = 2; /// /// the number of fraction digits in text labels. /// public int FractionDigits { get { return fractionDigits; } set { fractionDigits = value; RaiseOnChanged(); } } /// /// Label font size /// [Simple,Canvas, NonCanvas] [SerializeField] [Tooltip("Label font size")] private int fontSize = 12; /// /// Label font size /// public int FontSize { get { return fontSize; } set { fontSize = value; RaiseOnChanged(); } } /// /// makes the labels sharper if they are blurry /// [Range(1f,3f)] [Simple, Canvas, NonCanvas] [Tooltip("makes the labels sharper if they are blurry")] [SerializeField] private float fontSharpness = 1f; /// /// makes the labels sharper if they are blurry /// public float FontSharpness { get { return fontSharpness; } set { fontSharpness = value; RaiseOnChanged(); } } /// /// depth seperation the division lables. used by 3d charts only /// [Simple, NonCanvas] [SerializeField] [Tooltip("depth seperation the division lables")] private float textDepth; /// /// depth seperation the division lables.used by 3d charts only /// public float TextDepth { get { return textDepth; } set { textDepth = value; RaiseOnChanged(); } } /// /// breadth seperation for the division labels /// [Simple, Canvas,NonCanvas] [SerializeField] [Tooltip("breadth seperation for the division labels")] private float textSeperation; /// /// breadth seperation for the division labels /// public float TextSeperation { get { return textSeperation; } set { textSeperation = value; RaiseOnChanged(); } } /// /// Alignment of the division lables /// [Simple, Canvas, NonCanvas] [SerializeField] [Tooltip("Alignment of the division lables")] private ChartDivisionAligment alignment = ChartDivisionAligment.Standard; /// /// Alignment of the division lables /// public ChartDivisionAligment Alignment { get { return alignment; } set { alignment = value; RaiseOnChanged(); } } #pragma warning disable 0067 private event EventHandler OnDataUpdate; #pragma warning restore 0067 private event EventHandler OnDataChanged; protected virtual void RaiseOnChanged() { if (OnDataChanged != null) OnDataChanged(this, EventArgs.Empty); } #region Intenal Use event EventHandler IInternalSettings.InternalOnDataUpdate { add { OnDataUpdate += value; } remove { OnDataUpdate -= value; } } event EventHandler IInternalSettings.InternalOnDataChanged { add { OnDataChanged += value; } remove { OnDataChanged -= value; } } #endregion } }