mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 01:10:08 +00:00
增加GanttChart甘特图
This commit is contained in:
@@ -39,7 +39,12 @@ namespace XCharts
|
||||
/// Log axis, suitable for log data.
|
||||
/// 对数轴。适用于对数数据。
|
||||
/// </summary>
|
||||
Log
|
||||
Log,
|
||||
/// <summary>
|
||||
/// Time axis, suitable for continuous time series data.
|
||||
/// 时间轴。适用于连续的时序数据。
|
||||
/// </summary>
|
||||
Time
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -408,6 +413,7 @@ namespace XCharts
|
||||
public int runtimeMaxLogIndex { get { return logBaseE ? (int)Mathf.Log(runtimeMaxValue) : (int)Mathf.Log(runtimeMaxValue, logBase); } }
|
||||
internal bool runtimeLastCheckInverse { get; set; }
|
||||
internal float runtimeMinMaxRange { get { return m_MinMaxValueRange; } set { m_MinMaxValueRange = value; } }
|
||||
internal List<string> runtimeData { get { return m_RuntimeData; } }
|
||||
private int filterStart;
|
||||
private int filterEnd;
|
||||
private int filterMinShow;
|
||||
@@ -426,6 +432,7 @@ namespace XCharts
|
||||
private float m_RuntimeMaxValueUpdateTime;
|
||||
private bool m_RuntimeMinValueFirstChanged = true;
|
||||
private bool m_RuntimeMaxValueFirstChanged = true;
|
||||
protected List<string> m_RuntimeData = new List<string>();
|
||||
|
||||
public Axis Clone()
|
||||
{
|
||||
@@ -484,6 +491,7 @@ namespace XCharts
|
||||
public void ClearData()
|
||||
{
|
||||
m_Data.Clear();
|
||||
m_RuntimeData.Clear();
|
||||
SetAllDirty();
|
||||
}
|
||||
|
||||
@@ -574,10 +582,14 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_Data;
|
||||
return m_Data.Count > 0 ? m_Data : m_RuntimeData;
|
||||
}
|
||||
}
|
||||
|
||||
internal List<string> GetDataList(){
|
||||
return m_Data.Count > 0 ? m_Data : m_RuntimeData;
|
||||
}
|
||||
|
||||
private List<string> emptyFliter = new List<string>();
|
||||
/// <summary>
|
||||
/// 更新dataZoom对应的类目数据列表
|
||||
@@ -596,24 +608,25 @@ namespace XCharts
|
||||
filterEnd = endIndex;
|
||||
filterMinShow = dataZoom.minShowNum;
|
||||
m_NeedUpdateFilterData = false;
|
||||
if (m_Data.Count > 0)
|
||||
var data = GetDataList();
|
||||
if (data.Count > 0)
|
||||
{
|
||||
var count = endIndex == startIndex ? 1 : endIndex - startIndex + 1;
|
||||
if (count < dataZoom.minShowNum)
|
||||
{
|
||||
if (dataZoom.minShowNum > m_Data.Count) count = m_Data.Count;
|
||||
if (dataZoom.minShowNum > data.Count) count = data.Count;
|
||||
else count = dataZoom.minShowNum;
|
||||
}
|
||||
if (startIndex + count > m_Data.Count)
|
||||
if (startIndex + count > data.Count)
|
||||
{
|
||||
int start = endIndex - count;
|
||||
filterData = m_Data.GetRange(start < 0 ? 0 : start, count);
|
||||
filterData = data.GetRange(start < 0 ? 0 : start, count);
|
||||
}
|
||||
else filterData = m_Data.GetRange(startIndex, count);
|
||||
else filterData = data.GetRange(startIndex, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
filterData = m_Data;
|
||||
filterData = data;
|
||||
}
|
||||
}
|
||||
else if (endIndex == 0)
|
||||
|
||||
@@ -64,6 +64,10 @@ namespace XCharts
|
||||
/// K线图。K线图的data至少包含四个数据:[open, close, lowest, highest]
|
||||
/// </summary>
|
||||
Candlestick,
|
||||
/// <summary>
|
||||
/// 甘特图。甘特图的data至少包含两个数据:[start, end]
|
||||
/// </summary>
|
||||
Gantt,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -781,7 +785,7 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// 数据项里的数据维数。
|
||||
/// </summary>
|
||||
public int showDataDimension { get { return m_ShowDataDimension; } }
|
||||
public int showDataDimension { get { return m_ShowDataDimension; } internal set { m_ShowDataDimension = value; } }
|
||||
/// <summary>
|
||||
/// 在Editor的inpsector上是否显示name参数
|
||||
/// </summary>
|
||||
@@ -1234,6 +1238,7 @@ namespace XCharts
|
||||
{
|
||||
CheckMaxCache();
|
||||
var serieData = SerieDataPool.Get();
|
||||
serieData.data.Clear();
|
||||
serieData.data.Add(xValue);
|
||||
serieData.data.Add(yValue);
|
||||
serieData.name = dataName;
|
||||
@@ -1245,10 +1250,20 @@ namespace XCharts
|
||||
return serieData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加 (open, close, lowest, heighest) 数据
|
||||
/// </summary>
|
||||
/// <param name="open"></param>
|
||||
/// <param name="close"></param>
|
||||
/// <param name="lowest"></param>
|
||||
/// <param name="heighest"></param>
|
||||
/// <param name="dataName"></param>
|
||||
/// <returns></returns>
|
||||
public SerieData AddData(float open, float close, float lowest, float heighest, string dataName = null)
|
||||
{
|
||||
CheckMaxCache();
|
||||
var serieData = SerieDataPool.Get();
|
||||
serieData.data.Clear();
|
||||
serieData.data.Add(open);
|
||||
serieData.data.Add(close);
|
||||
serieData.data.Add(lowest);
|
||||
@@ -1678,7 +1693,9 @@ namespace XCharts
|
||||
return type == SerieType.Line
|
||||
|| type == SerieType.Bar
|
||||
|| type == SerieType.Scatter
|
||||
|| type == SerieType.Heatmap;
|
||||
|| type == SerieType.Heatmap
|
||||
|| type == SerieType.Gantt
|
||||
|| type == SerieType.Candlestick;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -188,9 +188,8 @@ namespace XCharts
|
||||
}
|
||||
else
|
||||
{
|
||||
var content = m_Formatter.Replace("{value}", category);
|
||||
content = content.Replace("\\n", "\n");
|
||||
content = content.Replace("<br/>", "\n");
|
||||
var content = m_Formatter;
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, category);
|
||||
return m_TextLimit.GetLimitContent(content);
|
||||
}
|
||||
}
|
||||
@@ -224,5 +223,21 @@ namespace XCharts
|
||||
return content;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetFormatterDateTime(DateTime dateTime)
|
||||
{
|
||||
var format = string.IsNullOrEmpty(numericFormatter) ? "yyyy/M/d" : numericFormatter;
|
||||
if (!string.IsNullOrEmpty(m_Formatter))
|
||||
{
|
||||
var content = m_Formatter;
|
||||
FormatterHelper.ReplaceAxisLabelContent(ref content, dateTime.ToString(format));
|
||||
return m_TextLimit.GetLimitContent(content);
|
||||
}
|
||||
else
|
||||
{
|
||||
var content = dateTime.ToString(format);
|
||||
return m_TextLimit.GetLimitContent(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,8 @@
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -191,6 +188,10 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public float runtimePieOffsetRadius { get; internal set; }
|
||||
public Vector3 runtimePosition { get; internal set; }
|
||||
/// <summary>
|
||||
/// 绘制区域。
|
||||
/// </summary>
|
||||
public Rect runtimeRect { get; internal set; }
|
||||
public float runtimeAngle { get; internal set; }
|
||||
public Vector3 runtiemPieOffsetCenter { get; internal set; }
|
||||
public float runtimeStackHig { get; internal set; }
|
||||
|
||||
@@ -85,5 +85,13 @@ namespace XCharts
|
||||
runtimeText.SetText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
if (runtimeText != null)
|
||||
{
|
||||
runtimeText.SetColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user