mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-25 02:10:16 +00:00
XCharts 2.0
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -37,24 +38,26 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The theme info.
|
||||
/// The theme.
|
||||
/// </summary>
|
||||
public ThemeInfo themeInfo { get { return m_ThemeInfo; } set { m_ThemeInfo = value; } }
|
||||
public ChartTheme theme { get { return m_Theme; } set { m_Theme = value; } }
|
||||
/// <summary>
|
||||
/// The title setting of chart.
|
||||
/// 标题组件
|
||||
/// </summary>
|
||||
public Title title { get { return m_Title; } }
|
||||
public Title title { get { return m_Titles.Count > 0 ? m_Titles[0] : null; } }
|
||||
public List<Title> titles { get { return m_Titles; } }
|
||||
/// <summary>
|
||||
/// The legend setting of chart.
|
||||
/// 图例组件
|
||||
/// </summary>
|
||||
public Legend legend { get { return m_Legend; } }
|
||||
public Legend legend { get { return m_Legends.Count > 0 ? m_Legends[0] : null; } }
|
||||
public List<Legend> legends { get { return m_Legends; } }
|
||||
/// <summary>
|
||||
/// The tooltip setting of chart.
|
||||
/// 提示框组件
|
||||
/// </summary>
|
||||
public Tooltip tooltip { get { return m_Tooltip; } }
|
||||
public Tooltip tooltip { get { return m_Tooltips.Count > 0 ? m_Tooltips[0] : null; } }
|
||||
/// <summary>
|
||||
/// The series setting of chart.
|
||||
/// 系列列表
|
||||
@@ -85,6 +88,10 @@ namespace XCharts
|
||||
/// 图表的高
|
||||
/// </summary>
|
||||
public float chartHeight { get { return m_ChartHeight; } }
|
||||
public Vector2 chartMinAnchor { get { return m_ChartMinAnchor; } }
|
||||
public Vector2 chartMaxAnchor { get { return m_ChartMaxAnchor; } }
|
||||
public Vector2 chartPivot { get { return m_ChartPivot; } }
|
||||
public Vector2 chartSizeDelta { get { return m_ChartSizeDelta; } }
|
||||
/// <summary>
|
||||
/// The position of chart.
|
||||
/// 图表的左下角起始坐标。
|
||||
@@ -96,6 +103,11 @@ namespace XCharts
|
||||
/// 自定义绘制回调。
|
||||
/// </summary>
|
||||
public Action<VertexHelper> onCustomDraw { set { m_OnCustomDrawCallback = value; } }
|
||||
/// <summary>
|
||||
/// the callback function of click pie area.
|
||||
/// 点击饼图区域回调。参数:PointerEventData,SerieIndex,SerieDataIndex
|
||||
/// </summary>
|
||||
public Action<PointerEventData, int, int> onPointerClickPie { set { m_OnPointerClickPie = value; m_ForceOpenRaycastTarget = true; } get { return m_OnPointerClickPie; } }
|
||||
|
||||
/// <summary>
|
||||
/// Redraw chart in next frame.
|
||||
@@ -104,6 +116,7 @@ namespace XCharts
|
||||
public void RefreshChart()
|
||||
{
|
||||
m_RefreshChart = true;
|
||||
if (m_Painter) m_Painter.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -114,8 +127,8 @@ namespace XCharts
|
||||
public virtual void ClearData()
|
||||
{
|
||||
m_Series.ClearData();
|
||||
m_Legend.ClearData();
|
||||
m_Tooltip.ClearValue();
|
||||
foreach (var legend in m_Legends) legend.ClearData();
|
||||
tooltip.ClearValue();
|
||||
m_CheckAnimation = false;
|
||||
m_ReinitLabel = true;
|
||||
RefreshChart();
|
||||
@@ -128,9 +141,10 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public virtual void RemoveData()
|
||||
{
|
||||
m_Legend.ClearData();
|
||||
foreach (var legend in m_Legends) legend.ClearData();
|
||||
foreach (var radar in m_Radars) radar.indicatorList.Clear();
|
||||
m_Series.RemoveAll();
|
||||
m_Tooltip.ClearValue();
|
||||
tooltip.ClearValue();
|
||||
m_CheckAnimation = false;
|
||||
m_ReinitLabel = true;
|
||||
m_SerieLabelRoot = null;
|
||||
@@ -145,7 +159,7 @@ namespace XCharts
|
||||
public virtual void RemoveData(string serieName)
|
||||
{
|
||||
m_Series.Remove(serieName);
|
||||
m_Legend.RemoveData(serieName);
|
||||
foreach (var legend in m_Legends) legend.RemoveData(serieName);
|
||||
m_SerieLabelRoot = null;
|
||||
RefreshChart();
|
||||
}
|
||||
@@ -182,7 +196,7 @@ namespace XCharts
|
||||
{
|
||||
RefreshLabel();
|
||||
}
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -205,7 +219,7 @@ namespace XCharts
|
||||
{
|
||||
RefreshLabel();
|
||||
}
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -228,7 +242,7 @@ namespace XCharts
|
||||
{
|
||||
RefreshLabel();
|
||||
}
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -251,7 +265,7 @@ namespace XCharts
|
||||
{
|
||||
RefreshLabel();
|
||||
}
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -275,7 +289,7 @@ namespace XCharts
|
||||
{
|
||||
RefreshLabel();
|
||||
}
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -299,7 +313,7 @@ namespace XCharts
|
||||
{
|
||||
RefreshLabel();
|
||||
}
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
return serieData;
|
||||
}
|
||||
@@ -315,7 +329,7 @@ namespace XCharts
|
||||
{
|
||||
if (m_Series.UpdateData(serieName, dataIndex, value))
|
||||
{
|
||||
RefreshChart();
|
||||
RefreshPainter(m_Series.GetSerie(serieName));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -332,7 +346,7 @@ namespace XCharts
|
||||
{
|
||||
if (m_Series.UpdateData(serieIndex, dataIndex, value))
|
||||
{
|
||||
RefreshChart();
|
||||
RefreshPainter(m_Series.GetSerie(serieIndex));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -348,7 +362,7 @@ namespace XCharts
|
||||
{
|
||||
if (m_Series.UpdateData(serieName, dataIndex, multidimensionalData))
|
||||
{
|
||||
RefreshChart();
|
||||
RefreshPainter(m_Series.GetSerie(serieName));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -364,7 +378,7 @@ namespace XCharts
|
||||
{
|
||||
if (m_Series.UpdateData(serieIndex, dataIndex, multidimensionalData))
|
||||
{
|
||||
RefreshChart();
|
||||
RefreshPainter(m_Series.GetSerie(serieIndex));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -381,7 +395,7 @@ namespace XCharts
|
||||
{
|
||||
if (m_Series.UpdateData(serieName, dataIndex, dimension, value))
|
||||
{
|
||||
RefreshChart();
|
||||
RefreshPainter(m_Series.GetSerie(serieName));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -398,7 +412,7 @@ namespace XCharts
|
||||
{
|
||||
if (m_Series.UpdateData(serieIndex, dataIndex, dimension, value))
|
||||
{
|
||||
RefreshChart();
|
||||
RefreshPainter(m_Series.GetSerie(serieIndex));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -459,15 +473,18 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void UpdateLegendColor(string legendName, bool active)
|
||||
internal virtual void UpdateLegendColor(string legendName, bool active)
|
||||
{
|
||||
var legendIndex = m_LegendRealShowName.IndexOf(legendName);
|
||||
if (legendIndex >= 0)
|
||||
{
|
||||
var iconColor = LegendHelper.GetIconColor(legend, legendIndex, m_ThemeInfo, m_Series, legendName, active);
|
||||
var contentColor = LegendHelper.GetContentColor(legend, m_ThemeInfo, active);
|
||||
m_Legend.UpdateButtonColor(legendName, iconColor);
|
||||
m_Legend.UpdateContentColor(legendName, contentColor);
|
||||
foreach (var legend in m_Legends)
|
||||
{
|
||||
var iconColor = LegendHelper.GetIconColor(legend, legendIndex, m_Theme, m_Series, legendName, active);
|
||||
var contentColor = LegendHelper.GetContentColor(legend, m_Theme, active);
|
||||
legend.UpdateButtonColor(legendName, iconColor);
|
||||
legend.UpdateContentColor(legendName, contentColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,25 +558,28 @@ namespace XCharts
|
||||
|
||||
/// <summary>
|
||||
/// Update chart theme.
|
||||
/// 切换图表主题。
|
||||
/// 切换内置主题。
|
||||
/// </summary>
|
||||
/// <param name="theme">theme</param>
|
||||
public void UpdateTheme(Theme theme)
|
||||
public bool UpdateTheme(Theme theme)
|
||||
{
|
||||
m_ThemeInfo.theme = theme;
|
||||
OnThemeChanged();
|
||||
RefreshChart();
|
||||
if (theme == Theme.Custom)
|
||||
{
|
||||
Debug.LogError("UpdateTheme: not support switch to Custom theme.");
|
||||
return false;
|
||||
}
|
||||
m_Theme.theme = theme;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update chart theme info.
|
||||
/// 切换图表主题。
|
||||
/// </summary>
|
||||
/// <param name="themeInfo">themeInfo</param>
|
||||
public void UpdateThemeInfo(ThemeInfo themeInfo)
|
||||
/// <param name="theme">theme</param>
|
||||
public void UpdateTheme(ChartTheme theme)
|
||||
{
|
||||
m_ThemeInfo = themeInfo;
|
||||
UpdateTheme(m_ThemeInfo.theme);
|
||||
m_Theme.CopyTheme(theme);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -572,8 +592,6 @@ namespace XCharts
|
||||
m_Series.AnimationEnable(flag);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// fadeIn animation.
|
||||
/// 开始渐入动画。
|
||||
@@ -667,46 +685,14 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否可以开启背景组件。背景组件在chart受上层布局控制时无法开启。
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool CanShowBackgroundComponent()
|
||||
public Vector3 GetTitlePosition(Title title)
|
||||
{
|
||||
return !m_IsControlledByLayout && m_Background.runtimeActive;
|
||||
return chartPosition + title.location.GetPosition(chartWidth, chartHeight);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开启背景组件。背景组件在chart受上层布局控制时不适用。
|
||||
/// </summary>
|
||||
/// <param name="flag"></param>
|
||||
public void EnableBackground(bool flag)
|
||||
public bool ContainsSerie(SerieType serieType)
|
||||
{
|
||||
if (flag && !CanShowBackgroundComponent())
|
||||
{
|
||||
var msg = "The background component cannot be activated because chart is controlled by LayoutGroup,"
|
||||
+ " or its parent have more than one child.";
|
||||
Debug.LogError(msg);
|
||||
return;
|
||||
}
|
||||
m_Background.show = flag;
|
||||
return SeriesHelper.ContainsSerie(m_Series, serieType);
|
||||
}
|
||||
|
||||
public Vector3 GetTitlePosition()
|
||||
{
|
||||
return chartPosition + m_Title.location.GetPosition(chartWidth, chartHeight);
|
||||
}
|
||||
|
||||
[Obsolete("Use BaseChart.RefreshLabel() instead.", true)]
|
||||
public void ReinitChartLabel() { }
|
||||
|
||||
[Obsolete("Use BaseChart.AnimationFadeIn() instead.", true)]
|
||||
public void AnimationStart() { }
|
||||
|
||||
[Obsolete("Use BaseChart.AnimationFadeOut() instead.", true)]
|
||||
public void MissAnimationStart() { }
|
||||
|
||||
[Obsolete("Use onCustomDraw instead.", false)]
|
||||
public Action<VertexHelper> customDrawCallback { set { m_OnCustomDrawCallback = value; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
@@ -17,6 +17,12 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public partial class BaseGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// The background component.
|
||||
/// 背景组件。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Background background { get { return m_Background; } }
|
||||
/// <summary>
|
||||
/// The x of graph.
|
||||
/// 图形的X
|
||||
@@ -125,6 +131,11 @@ namespace XCharts
|
||||
m_RefreshChart = true;
|
||||
}
|
||||
|
||||
public void RefreshAllComponent()
|
||||
{
|
||||
SetAllComponentDirty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测警告信息。
|
||||
/// </summary>
|
||||
@@ -141,6 +152,7 @@ namespace XCharts
|
||||
public void RemoveChartObject()
|
||||
{
|
||||
ChartHelper.DestroyAllChildren(transform);
|
||||
//SetAllComponentDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -18,68 +17,48 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public partial class CoordinateChart
|
||||
{
|
||||
/// <summary>
|
||||
/// The lower left position x of coordinate system.
|
||||
/// 坐标系的左下角坐标X。
|
||||
/// </summary>
|
||||
public float coordinateX { get { return m_CoordinateX; } }
|
||||
/// <summary>
|
||||
/// The lower left position y of coordinate system.
|
||||
/// 坐标系的左下角坐标Y。
|
||||
/// </summary>
|
||||
public float coordinateY { get { return m_CoordinateY; } }
|
||||
|
||||
/// <summary>
|
||||
/// the width of coordinate system。
|
||||
/// 坐标系的宽。
|
||||
/// </summary>
|
||||
public float coordinateWidth { get { return m_CoordinateWidth; } }
|
||||
/// <summary>
|
||||
/// the height of coordinate system。
|
||||
/// 坐标系的高。
|
||||
/// </summary>
|
||||
public float coordinateHeight { get { return m_CoordinateHeight; } }
|
||||
/// <summary>
|
||||
/// grid component.
|
||||
/// 网格组件。
|
||||
/// </summary>
|
||||
public Grid grid { get { return m_Grid; } }
|
||||
public Grid grid { get { return m_Grids.Count > 0 ? m_Grids[0] : null; } }
|
||||
public List<Grid> grids { get { return m_Grids; } }
|
||||
/// <summary>
|
||||
/// the x axises,xAxises[0] is the first x axis, xAxises[1] is the second x axis.
|
||||
/// the x Axes,xAxes[0] is the first x axis, xAxes[1] is the second x axis.
|
||||
/// 两个x轴。
|
||||
/// </summary>
|
||||
public List<XAxis> xAxises { get { return m_XAxises; } }
|
||||
public List<XAxis> xAxes { get { return m_XAxes; } }
|
||||
/// <summary>
|
||||
/// the y axises, yAxises[0] is the first y axis, yAxises[1] is the second y axis.
|
||||
/// the y Axes, yAxes[0] is the first y axis, yAxes[1] is the second y axis.
|
||||
/// 两个y轴。
|
||||
/// </summary>
|
||||
public List<YAxis> yAxises { get { return m_YAxises; } }
|
||||
public List<YAxis> yAxes { get { return m_YAxes; } }
|
||||
/// <summary>
|
||||
/// dataZoom component.
|
||||
/// 区域缩放组件。
|
||||
/// </summary>
|
||||
public DataZoom dataZoom { get { return m_DataZoom; } }
|
||||
public DataZoom dataZoom { get { return m_DataZooms.Count > 0 ? m_DataZooms[0] : null; } }
|
||||
/// <summary>
|
||||
/// visualMap component.
|
||||
/// 视觉映射组件。
|
||||
/// </summary>
|
||||
public VisualMap visualMap { get { return m_VisualMap; } }
|
||||
public VisualMap visualMap { get { return m_VisualMaps.Count > 0 ? m_VisualMaps[0] : null; } }
|
||||
/// <summary>
|
||||
/// X轴(下)
|
||||
/// </summary>
|
||||
public XAxis xAxis0 { get { return m_XAxises[0]; } }
|
||||
public XAxis xAxis0 { get { return m_XAxes.Count > 0 ? m_XAxes[0] : null; } }
|
||||
/// <summary>
|
||||
/// X轴(上)
|
||||
/// </summary>
|
||||
public XAxis xAxis1 { get { return m_XAxises[1]; } }
|
||||
public XAxis xAxis1 { get { return m_XAxes.Count > 1 ? m_XAxes[1] : null; } }
|
||||
/// <summary>
|
||||
/// Y轴(左)
|
||||
/// </summary>
|
||||
public YAxis yAxis0 { get { return m_YAxises[0]; } }
|
||||
public YAxis yAxis0 { get { return m_YAxes.Count > 0 ? m_YAxes[0] : null; } }
|
||||
/// <summary>
|
||||
/// Y轴(右)
|
||||
/// </summary>
|
||||
public YAxis yAxis1 { get { return m_YAxises[1]; } }
|
||||
public YAxis yAxis1 { get { return m_YAxes.Count > 1 ? m_YAxes[1] : null; } }
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -105,13 +84,13 @@ namespace XCharts
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all data of axises.
|
||||
/// Remove all data of Axes.
|
||||
/// 清除所有x轴和y轴的类目数据。
|
||||
/// </summary>
|
||||
public void ClearAxisData()
|
||||
{
|
||||
foreach (var item in m_XAxises) item.data.Clear();
|
||||
foreach (var item in m_YAxises) item.data.Clear();
|
||||
foreach (var item in m_XAxes) item.data.Clear();
|
||||
foreach (var item in m_YAxes) item.data.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -122,7 +101,7 @@ namespace XCharts
|
||||
/// <param name="xAxisIndex">which xAxis should category add to</param>
|
||||
public void AddXAxisData(string category, int xAxisIndex = 0)
|
||||
{
|
||||
m_XAxises[xAxisIndex].AddData(category);
|
||||
m_XAxes[xAxisIndex].AddData(category);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -133,7 +112,7 @@ namespace XCharts
|
||||
/// <param name="yAxisIndex">which yAxis should category add to</param>
|
||||
public void AddYAxisData(string category, int yAxisIndex = 0)
|
||||
{
|
||||
m_YAxises[yAxisIndex].AddData(category);
|
||||
m_YAxes[yAxisIndex].AddData(category);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -142,11 +121,11 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public bool IsValue()
|
||||
{
|
||||
foreach (var axis in m_XAxises)
|
||||
foreach (var axis in m_XAxes)
|
||||
{
|
||||
if (axis.show && !axis.IsValue() && !axis.IsLog()) return false;
|
||||
}
|
||||
foreach (var axis in m_YAxises)
|
||||
foreach (var axis in m_YAxes)
|
||||
{
|
||||
if (axis.show && !axis.IsValue() && !axis.IsLog()) return false;
|
||||
}
|
||||
@@ -158,11 +137,11 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public bool IsCategory()
|
||||
{
|
||||
foreach (var axis in m_XAxises)
|
||||
foreach (var axis in m_XAxes)
|
||||
{
|
||||
if (axis.show && !axis.IsCategory()) return false;
|
||||
}
|
||||
foreach (var axis in m_YAxises)
|
||||
foreach (var axis in m_YAxes)
|
||||
{
|
||||
if (axis.show && !axis.IsCategory()) return false;
|
||||
}
|
||||
@@ -172,26 +151,46 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// 坐标是否在坐标轴内。
|
||||
/// </summary>
|
||||
public bool IsInCooridate(Vector2 local)
|
||||
public bool IsInGrid(Grid grid, Vector2 local)
|
||||
{
|
||||
return IsInCooridate(local.x, local.y);
|
||||
return IsInGrid(grid, local.x, local.y);
|
||||
}
|
||||
|
||||
public bool IsInCooridate(Vector3 local)
|
||||
public bool IsInGrid(Grid grid, Vector3 local)
|
||||
{
|
||||
return IsInCooridate(local.x, local.y);
|
||||
return IsInGrid(grid, local.x, local.y);
|
||||
}
|
||||
|
||||
public bool IsInCooridate(float x, float y)
|
||||
public bool IsInGrid(Grid grid, float x, float y)
|
||||
{
|
||||
if (x < m_CoordinateX - 1 || x > m_CoordinateX + m_CoordinateWidth + 1 ||
|
||||
y < m_CoordinateY - 1 || y > m_CoordinateY + m_CoordinateHeight + 1)
|
||||
if (x < grid.runtimeX - 1 || x > grid.runtimeX + grid.runtimeWidth + 1 ||
|
||||
y < grid.runtimeY - 1 || y > grid.runtimeY + grid.runtimeHeight + 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsInAnyGrid(Vector2 local)
|
||||
{
|
||||
foreach (var grid in m_Grids)
|
||||
{
|
||||
if (IsInGrid(grid, local)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Grid GetGrid(Vector2 local)
|
||||
{
|
||||
for (int i = 0; i < m_Grids.Count; i++)
|
||||
{
|
||||
var grid = m_Grids[i];
|
||||
grid.index = i;
|
||||
if (IsInGrid(grid, local)) return grid;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 在下一帧刷新DataZoom
|
||||
/// </summary>
|
||||
@@ -208,16 +207,16 @@ namespace XCharts
|
||||
CheckMinMaxValue();
|
||||
}
|
||||
|
||||
public Vector3 ClampInCoordinate(Vector3 pos)
|
||||
public Vector3 ClampInGrid(Grid grid, Vector3 pos)
|
||||
{
|
||||
if (IsInCooridate(pos)) return pos;
|
||||
if (IsInGrid(grid, pos)) return pos;
|
||||
else
|
||||
{
|
||||
// var pos = new Vector3(pos.x, pos.y);
|
||||
if (pos.x < m_CoordinateX) pos.x = m_CoordinateX;
|
||||
if (pos.x > m_CoordinateX + m_CoordinateWidth) pos.x = m_CoordinateX + m_CoordinateWidth;
|
||||
if (pos.y < m_CoordinateY) pos.y = m_CoordinateY;
|
||||
if (pos.y > m_CoordinateY + m_CoordinateHeight) pos.y = m_CoordinateY + m_CoordinateHeight;
|
||||
if (pos.x < grid.runtimeX) pos.x = grid.runtimeX;
|
||||
if (pos.x > grid.runtimeX + grid.runtimeWidth) pos.x = grid.runtimeX + grid.runtimeWidth;
|
||||
if (pos.y < grid.runtimeY) pos.y = grid.runtimeY;
|
||||
if (pos.y > grid.runtimeY + grid.runtimeHeight) pos.y = grid.runtimeY + grid.runtimeHeight;
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
@@ -230,10 +229,10 @@ namespace XCharts
|
||||
{
|
||||
if (index >= 0 && index <= 1)
|
||||
{
|
||||
var xAxis = m_XAxises[index];
|
||||
var yAxis = m_YAxises[index];
|
||||
var tempX = m_XAxises[index].Clone();
|
||||
xAxis.Copy(m_YAxises[index]);
|
||||
var xAxis = m_XAxes[index];
|
||||
var yAxis = m_YAxes[index];
|
||||
var tempX = m_XAxes[index].Clone();
|
||||
xAxis.Copy(m_YAxes[index]);
|
||||
yAxis.Copy(tempX);
|
||||
xAxis.runtimeZeroXOffset = 0;
|
||||
xAxis.runtimeZeroYOffset = 0;
|
||||
@@ -252,10 +251,14 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public void UpdateCoordinate()
|
||||
{
|
||||
m_CoordinateX = m_ChartX + m_Grid.left;
|
||||
m_CoordinateY = m_ChartY + m_Grid.bottom;
|
||||
m_CoordinateWidth = m_ChartWidth - m_Grid.left - m_Grid.right;
|
||||
m_CoordinateHeight = m_ChartHeight - m_Grid.top - m_Grid.bottom;
|
||||
foreach (var grid in m_Grids)
|
||||
{
|
||||
grid.UpdateRuntimeData(m_ChartX, m_ChartY, m_ChartWidth, m_ChartHeight);
|
||||
}
|
||||
foreach (var dataZoom in m_DataZooms)
|
||||
{
|
||||
dataZoom.UpdateRuntimeData(m_ChartX, m_ChartY, m_ChartWidth, m_ChartHeight);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -264,8 +267,26 @@ namespace XCharts
|
||||
public void SetMaxCache(int maxCache)
|
||||
{
|
||||
foreach (var serie in m_Series.list) serie.maxCache = maxCache;
|
||||
foreach (var axis in m_XAxises) axis.maxCache = maxCache;
|
||||
foreach (var axis in m_YAxises) axis.maxCache = maxCache;
|
||||
foreach (var axis in m_XAxes) axis.maxCache = maxCache;
|
||||
foreach (var axis in m_YAxes) axis.maxCache = maxCache;
|
||||
}
|
||||
|
||||
public Grid GetGrid(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_Grids.Count) return m_Grids[index];
|
||||
else return null;
|
||||
}
|
||||
|
||||
public XAxis GetXAxis(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_XAxes.Count) return m_XAxes[index];
|
||||
else return null;
|
||||
}
|
||||
|
||||
public YAxis GetYAxis(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_YAxes.Count) return m_YAxes[index];
|
||||
else return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public partial class LiquidChart
|
||||
public partial class BaseChart
|
||||
{
|
||||
public Vessel vessel { get { return m_Vessels.Count > 0 ? m_Vessels[0] : null; } }
|
||||
/// <summary>
|
||||
/// 容器组件列表。
|
||||
/// </summary>
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public partial class PieChart
|
||||
{
|
||||
/// <summary>
|
||||
/// the callback function of click pie area.
|
||||
/// 点击饼图区域回调。参数:PointerEventData,SerieIndex,SerieDataIndex
|
||||
/// </summary>
|
||||
public Action<PointerEventData, int, int> onPointerClickPie { set { m_OnPointerClickPie = value; m_ForceOpenRaycastTarget = true; } }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -15,16 +12,16 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// 极坐标。
|
||||
/// </summary>
|
||||
public Polar polar { get { return m_Polar; } }
|
||||
public Polar polar { get { return m_Polars.Count > 0 ? m_Polars[0] : null; } }
|
||||
/// <summary>
|
||||
/// Angle axis of Polar Coordinate.
|
||||
/// 极坐标系的角度轴。
|
||||
/// </summary>
|
||||
public AngleAxis angleAxis { get { return m_AngleAxis; } }
|
||||
public AngleAxis angleAxis { get { return m_AngleAxes.Count > 0 ? m_AngleAxes[0] : null; } }
|
||||
/// <summary>
|
||||
/// Radial axis of polar coordinate.
|
||||
/// 极坐标系的径向轴。
|
||||
/// </summary>
|
||||
public RadiusAxis radiusAxis { get { return m_RadiusAxis; } }
|
||||
public RadiusAxis radiusAxis { get { return m_RadiusAxes.Count > 0 ? m_RadiusAxes[0] : null; } }
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,23 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public partial class RadarChart
|
||||
public partial class BaseChart
|
||||
{
|
||||
public Radar radar { get { return m_Radars.Count > 0 ? m_Radars[0] : null; } }
|
||||
/// <summary>
|
||||
/// 雷达坐标系组件列表。
|
||||
/// </summary>
|
||||
public List<Radar> radars { get { return m_Radars; } }
|
||||
|
||||
/// <summary>
|
||||
/// 移除所有数据,包含雷达坐标系指示器数据。
|
||||
/// </summary>
|
||||
public override void RemoveData()
|
||||
{
|
||||
base.RemoveData();
|
||||
foreach (var radar in m_Radars)
|
||||
{
|
||||
radar.indicatorList.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移除所有雷达坐标系组件。
|
||||
/// </summary>
|
||||
@@ -57,7 +46,7 @@ namespace XCharts
|
||||
/// <param name="showSplitArea">是否显示分割区域</param>
|
||||
/// <returns></returns>
|
||||
public Radar AddRadar(Radar.Shape shape, Vector2 center, float radius, int splitNumber = 5,
|
||||
float lineWidth = 0.6f, bool showIndicator = true, bool showSplitArea = true)
|
||||
float lineWidth = 0f, bool showIndicator = true, bool showSplitArea = true)
|
||||
{
|
||||
var radar = new Radar();
|
||||
radar.shape = shape;
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -17,8 +17,6 @@ namespace XCharts
|
||||
[DisallowMultipleComponent]
|
||||
public partial class BarChart : CoordinateChart
|
||||
{
|
||||
protected Action<PointerEventData, int> m_OnPointerClickBar;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
@@ -28,14 +26,13 @@ namespace XCharts
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
m_Title.text = "BarChart";
|
||||
m_Tooltip.type = Tooltip.Type.Shadow;
|
||||
title.text = "BarChart";
|
||||
tooltip.type = Tooltip.Type.Shadow;
|
||||
RemoveData();
|
||||
AddSerie(SerieType.Bar, "serie1");
|
||||
SerieTemplate.AddDefaultBarSerie(this, "serie1");
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
AddXAxisData("x" + (i + 1));
|
||||
AddData(0, UnityEngine.Random.Range(10, 90));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -46,7 +43,7 @@ namespace XCharts
|
||||
if (m_OnPointerClickBar == null) return;
|
||||
if (pointerPos == Vector2.zero) return;
|
||||
UpdateTooltipValue(pointerPos);
|
||||
var dataIndex = m_Tooltip.runtimeDataIndex[0];
|
||||
var dataIndex = tooltip.runtimeDataIndex[0];
|
||||
if (dataIndex >= 0)
|
||||
{
|
||||
m_OnPointerClickBar(eventData, dataIndex);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -12,17 +12,9 @@ namespace XCharts
|
||||
{
|
||||
public class ChartComponent
|
||||
{
|
||||
[SerializeField] protected string m_JsonData;
|
||||
[SerializeField] protected bool m_DataFromJson;
|
||||
|
||||
[NonSerialized] protected bool m_VertsDirty;
|
||||
[NonSerialized] protected bool m_ComponentDirty;
|
||||
|
||||
/// <summary>
|
||||
/// json格式的字符串数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string jsonData { get { return m_JsonData; } set { m_JsonData = value; ParseJsonData(value); } }
|
||||
[NonSerialized] protected Painter m_Painter;
|
||||
/// <summary>
|
||||
/// 图表重绘标记。
|
||||
/// </summary>
|
||||
@@ -35,23 +27,9 @@ namespace XCharts
|
||||
/// 需要重绘图表或重新初始化组件。
|
||||
/// </summary>
|
||||
public bool anyDirty { get { return vertsDirty || componentDirty; } }
|
||||
internal void OnAfterDeserialize()
|
||||
{
|
||||
if (m_DataFromJson)
|
||||
{
|
||||
ParseJsonData(m_JsonData);
|
||||
m_DataFromJson = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnBeforeSerialize()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void ParseJsonData(string json)
|
||||
{
|
||||
throw new Exception("no support yet");
|
||||
}
|
||||
public Painter painter { get { return m_Painter; } set { m_Painter = value; } }
|
||||
public Action refreshComponent { get; set; }
|
||||
public GameObject gameObject { get; set; }
|
||||
|
||||
internal virtual void SetVerticesDirty()
|
||||
{
|
||||
@@ -85,4 +63,12 @@ namespace XCharts
|
||||
SetComponentDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public class MainComponent : ChartComponent
|
||||
{
|
||||
}
|
||||
|
||||
public class SubComponent : ChartComponent
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -64,10 +64,25 @@ namespace XCharts
|
||||
/// </summary>
|
||||
Custom
|
||||
}
|
||||
/// <summary>
|
||||
/// the position of axis in grid.
|
||||
/// 坐标轴在Grid中的位置
|
||||
/// </summary>
|
||||
public enum AxisPosition
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Bottom,
|
||||
Top
|
||||
}
|
||||
|
||||
[SerializeField] protected bool m_Show = true;
|
||||
[SerializeField] protected AxisType m_Type;
|
||||
[SerializeField] protected AxisMinMaxType m_MinMaxType;
|
||||
[SerializeField] protected int m_GridIndex;
|
||||
[SerializeField] protected int m_PolarIndex;
|
||||
[SerializeField] protected AxisPosition m_Position;
|
||||
[SerializeField] protected float m_Offset;
|
||||
[SerializeField] protected float m_Min;
|
||||
[SerializeField] protected float m_Max;
|
||||
[SerializeField] protected int m_SplitNumber = 5;
|
||||
@@ -97,7 +112,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of axis.
|
||||
@@ -106,7 +121,7 @@ namespace XCharts
|
||||
public AxisType type
|
||||
{
|
||||
get { return m_Type; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of axis minmax.
|
||||
@@ -115,7 +130,43 @@ namespace XCharts
|
||||
public AxisMinMaxType minMaxType
|
||||
{
|
||||
get { return m_MinMaxType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_MinMaxType, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MinMaxType, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The index of the grid on which the axis are located, by default, is in the first grid.
|
||||
/// 坐标轴所在的 grid 的索引,默认位于第一个 grid。
|
||||
/// </summary>
|
||||
public int gridIndex
|
||||
{
|
||||
get { return m_GridIndex; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_GridIndex, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The index of the polar on which the axis are located, by default, is in the first polar.
|
||||
/// 坐标轴所在的 ploar 的索引,默认位于第一个 polar。
|
||||
/// </summary>
|
||||
public int polarIndex
|
||||
{
|
||||
get { return m_PolarIndex; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PolarIndex, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the position of axis in grid.
|
||||
/// 坐标轴在Grid中的位置。
|
||||
/// </summary>
|
||||
public AxisPosition position
|
||||
{
|
||||
get { return m_Position; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the offset of axis from the default position. Useful when the same position has multiple axes.
|
||||
/// 坐标轴相对默认位置的偏移。在相同position有多个坐标轴时有用。
|
||||
/// </summary>
|
||||
public float offset
|
||||
{
|
||||
get { return m_Offset; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The minimun value of axis.Valid when `minMaxType` is `Custom`
|
||||
@@ -124,7 +175,7 @@ namespace XCharts
|
||||
public float min
|
||||
{
|
||||
get { return m_Min; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Min, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The maximum value of axis.Valid when `minMaxType` is `Custom`
|
||||
@@ -133,7 +184,7 @@ namespace XCharts
|
||||
public float max
|
||||
{
|
||||
get { return m_Max; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Max, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Max, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Number of segments that the axis is split into.
|
||||
@@ -142,7 +193,7 @@ namespace XCharts
|
||||
public int splitNumber
|
||||
{
|
||||
get { return m_SplitNumber; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Compulsively set segmentation interval for axis.This is unavailable for category axis.
|
||||
@@ -151,7 +202,7 @@ namespace XCharts
|
||||
public float interval
|
||||
{
|
||||
get { return m_Interval; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The boundary gap on both sides of a coordinate axis, which is valid only for category axis with type: 'Category'.
|
||||
@@ -160,7 +211,7 @@ namespace XCharts
|
||||
public bool boundaryGap
|
||||
{
|
||||
get { return IsCategory() ? m_BoundaryGap : false; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BoundaryGap, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BoundaryGap, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Base of logarithm, which is valid only for numeric axes with type: 'Log'.
|
||||
@@ -172,7 +223,7 @@ namespace XCharts
|
||||
set
|
||||
{
|
||||
if (value <= 0 || value == 1) value = 10;
|
||||
if (PropertyUtility.SetStruct(ref m_LogBase, value)) SetAllDirty();
|
||||
if (PropertyUtil.SetStruct(ref m_LogBase, value)) SetAllDirty();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -182,7 +233,7 @@ namespace XCharts
|
||||
public bool logBaseE
|
||||
{
|
||||
get { return m_LogBaseE; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_LogBaseE, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LogBaseE, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The max number of axis data cache.
|
||||
@@ -192,7 +243,7 @@ namespace XCharts
|
||||
public int maxCache
|
||||
{
|
||||
get { return m_MaxCache; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calculated.
|
||||
@@ -201,7 +252,7 @@ namespace XCharts
|
||||
public int ceilRate
|
||||
{
|
||||
get { return m_CeilRate; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the axis are reversed or not. Invalid in `Category` axis.
|
||||
@@ -210,7 +261,7 @@ namespace XCharts
|
||||
public bool inverse
|
||||
{
|
||||
get { return m_Inverse; }
|
||||
set { if (m_Type == AxisType.Value && PropertyUtility.SetStruct(ref m_Inverse, value)) SetAllDirty(); }
|
||||
set { if (m_Type == AxisType.Value && PropertyUtil.SetStruct(ref m_Inverse, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the positive position of axis is in clockwise. True for clockwise by default.
|
||||
@@ -219,7 +270,7 @@ namespace XCharts
|
||||
public bool clockwise
|
||||
{
|
||||
get { return m_Clockwise; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Clockwise, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Clockwise, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Category data, available in type: 'Category' axis.
|
||||
@@ -312,7 +363,7 @@ namespace XCharts
|
||||
/// the axis label text list.
|
||||
/// 坐标轴刻度标签的Text列表。
|
||||
/// </summary>
|
||||
public List<Text> axisLabelTextList { get { return m_AxisLabelTextList; } set { m_AxisLabelTextList = value; } }
|
||||
public List<ChartText> axisLabelTextList { get { return m_AxisLabelTextList; } set { m_AxisLabelTextList = value; } }
|
||||
/// <summary>
|
||||
/// the current minimun value.
|
||||
/// 当前最小值。
|
||||
@@ -361,9 +412,9 @@ namespace XCharts
|
||||
private int filterEnd;
|
||||
private int filterMinShow;
|
||||
private List<string> filterData;
|
||||
private List<Text> m_AxisLabelTextList = new List<Text>();
|
||||
private List<ChartText> m_AxisLabelTextList = new List<ChartText>();
|
||||
private GameObject m_TooltipLabel;
|
||||
private Text m_TooltipLabelText;
|
||||
private ChartText m_TooltipLabelText;
|
||||
private RectTransform m_TooltipLabelRect;
|
||||
private float m_RuntimeMinValue;
|
||||
private float m_RuntimeLastMinValue;
|
||||
@@ -381,6 +432,7 @@ namespace XCharts
|
||||
var axis = new Axis();
|
||||
axis.show = show;
|
||||
axis.type = type;
|
||||
axis.gridIndex = 0;
|
||||
axis.minMaxType = minMaxType;
|
||||
axis.min = min;
|
||||
axis.max = max;
|
||||
@@ -407,6 +459,7 @@ namespace XCharts
|
||||
show = axis.show;
|
||||
type = axis.type;
|
||||
minMaxType = axis.minMaxType;
|
||||
gridIndex = axis.gridIndex;
|
||||
min = axis.min;
|
||||
max = axis.max;
|
||||
splitNumber = axis.splitNumber;
|
||||
@@ -514,7 +567,7 @@ namespace XCharts
|
||||
/// <returns></returns>
|
||||
internal List<string> GetDataList(DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.enable)
|
||||
if (dataZoom != null && dataZoom.enable && dataZoom.IsContainsAxisIndex(index))
|
||||
{
|
||||
UpdateFilterData(dataZoom);
|
||||
return filterData;
|
||||
@@ -532,7 +585,7 @@ namespace XCharts
|
||||
/// <param name="dataZoom"></param>
|
||||
internal void UpdateFilterData(DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.enable)
|
||||
if (dataZoom != null && dataZoom.enable && dataZoom.IsContainsAxisIndex(index))
|
||||
{
|
||||
var startIndex = (int)((data.Count - 1) * dataZoom.start / 100);
|
||||
var endIndex = (int)((data.Count - 1) * dataZoom.end / 100);
|
||||
@@ -593,7 +646,7 @@ namespace XCharts
|
||||
if (axisLabelTextList[i] != null)
|
||||
{
|
||||
var text = AxisHelper.GetLabelName(this, coordinateWidth, i, minValue, maxValue, dataZoom, forcePercent);
|
||||
axisLabelTextList[i].text = text;
|
||||
axisLabelTextList[i].SetText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -602,31 +655,28 @@ namespace XCharts
|
||||
{
|
||||
m_TooltipLabel = label;
|
||||
m_TooltipLabelRect = label.GetComponent<RectTransform>();
|
||||
m_TooltipLabelText = label.GetComponentInChildren<Text>();
|
||||
m_TooltipLabelText = new ChartText(label);
|
||||
ChartHelper.SetActive(m_TooltipLabel, true);
|
||||
}
|
||||
|
||||
internal void SetTooltipLabelColor(Color bgColor, Color textColor)
|
||||
{
|
||||
m_TooltipLabel.GetComponent<Image>().color = bgColor;
|
||||
m_TooltipLabelText.color = textColor;
|
||||
m_TooltipLabelText.SetColor(textColor);
|
||||
}
|
||||
|
||||
internal void SetTooltipLabelActive(bool flag)
|
||||
{
|
||||
if (m_TooltipLabel && m_TooltipLabel.activeInHierarchy != flag)
|
||||
{
|
||||
ChartHelper.SetActive(m_TooltipLabel, flag);
|
||||
}
|
||||
ChartHelper.SetActive(m_TooltipLabel, flag);
|
||||
}
|
||||
|
||||
internal void UpdateTooptipLabelText(string text)
|
||||
{
|
||||
if (m_TooltipLabelText)
|
||||
if (m_TooltipLabelText != null)
|
||||
{
|
||||
m_TooltipLabelText.text = text;
|
||||
m_TooltipLabelRect.sizeDelta = new Vector2(m_TooltipLabelText.preferredWidth + 8,
|
||||
m_TooltipLabelText.preferredHeight + 8);
|
||||
m_TooltipLabelText.SetText(text);
|
||||
m_TooltipLabelRect.sizeDelta = new Vector2(m_TooltipLabelText.GetPreferredWidth() + 8,
|
||||
m_TooltipLabelText.GetPreferredHeight() + 8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,10 +803,24 @@ namespace XCharts
|
||||
return logBaseE ? Mathf.Log(value) : Mathf.Log(value, logBase);
|
||||
}
|
||||
|
||||
public override void ParseJsonData(string jsonData)
|
||||
public bool IsLeft()
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
||||
m_Data = ChartHelper.ParseStringFromString(jsonData);
|
||||
return position == AxisPosition.Left;
|
||||
}
|
||||
|
||||
public bool IsRight()
|
||||
{
|
||||
return position == AxisPosition.Right;
|
||||
}
|
||||
|
||||
public bool IsTop()
|
||||
{
|
||||
return position == AxisPosition.Top;
|
||||
}
|
||||
|
||||
public bool IsBottom()
|
||||
{
|
||||
return position == AxisPosition.Bottom;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -780,13 +844,15 @@ namespace XCharts
|
||||
m_Max = 0,
|
||||
m_SplitNumber = 5,
|
||||
m_BoundaryGap = true,
|
||||
m_Position = AxisPosition.Bottom,
|
||||
m_Offset = 0,
|
||||
m_Data = new List<string>()
|
||||
{
|
||||
"x1","x2","x3","x4","x5"
|
||||
}
|
||||
};
|
||||
axis.splitLine.show = false;
|
||||
axis.splitLine.lineStyle.type = LineStyle.Type.Dashed;
|
||||
axis.splitLine.lineStyle.type = LineStyle.Type.None;
|
||||
axis.axisLabel.textLimit.enable = true;
|
||||
return axis;
|
||||
}
|
||||
@@ -813,10 +879,11 @@ namespace XCharts
|
||||
m_Max = 0,
|
||||
m_SplitNumber = 5,
|
||||
m_BoundaryGap = false,
|
||||
m_Position = AxisPosition.Left,
|
||||
m_Data = new List<string>(5),
|
||||
};
|
||||
axis.splitLine.show = true;
|
||||
axis.splitLine.lineStyle.type = LineStyle.Type.Dashed;
|
||||
axis.splitLine.lineStyle.type = LineStyle.Type.None;
|
||||
axis.axisLabel.textLimit.enable = false;
|
||||
return axis;
|
||||
}
|
||||
@@ -868,7 +935,7 @@ namespace XCharts
|
||||
public float startAngle
|
||||
{
|
||||
get { return m_StartAngle; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_StartAngle, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_StartAngle, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
public float runtimeStartAngle { get; set; }
|
||||
@@ -881,9 +948,9 @@ namespace XCharts
|
||||
{
|
||||
m_Show = true,
|
||||
m_Type = AxisType.Value,
|
||||
m_SplitNumber = 13,
|
||||
m_SplitNumber = 12,
|
||||
m_BoundaryGap = false,
|
||||
m_Data = new List<string>(13),
|
||||
m_Data = new List<string>(12),
|
||||
};
|
||||
axis.splitLine.show = true;
|
||||
axis.splitLine.lineStyle.type = LineStyle.Type.Solid;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System.Net.Mime;
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -41,7 +41,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
internal set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
internal set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the image of background.
|
||||
@@ -50,7 +50,7 @@ namespace XCharts
|
||||
public Sprite image
|
||||
{
|
||||
get { return m_Image; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Image, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Image, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -60,7 +60,7 @@ namespace XCharts
|
||||
public Image.Type imageType
|
||||
{
|
||||
get { return m_ImageType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ImageType, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ImageType, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -69,7 +69,7 @@ namespace XCharts
|
||||
public Color imageColor
|
||||
{
|
||||
get { return m_ImageColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_ImageColor, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_ImageColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -79,14 +79,9 @@ namespace XCharts
|
||||
public bool hideThemeBackgroundColor
|
||||
{
|
||||
get { return m_HideThemeBackgroundColor; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_HideThemeBackgroundColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_HideThemeBackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否已激活
|
||||
/// </summary>
|
||||
public bool runtimeActive { get; internal set; }
|
||||
|
||||
public static Background defaultBackground
|
||||
{
|
||||
get
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -68,8 +69,8 @@ namespace XCharts
|
||||
}
|
||||
[SerializeField] private bool m_Enable;
|
||||
[SerializeField] private FilterMode m_FilterMode;
|
||||
[SerializeField] private int m_XAxisIndex;
|
||||
[SerializeField] private int m_YAxisIndex;
|
||||
[SerializeField] private List<int> m_XAxisIndexs = new List<int>() { 0 };
|
||||
[SerializeField] private List<int> m_YAxisIndexs = new List<int>() { };
|
||||
[SerializeField] private bool m_SupportInside;
|
||||
[SerializeField] private bool m_SupportSlider;
|
||||
[SerializeField] private bool m_SupportSelect;
|
||||
@@ -77,8 +78,13 @@ namespace XCharts
|
||||
[SerializeField] private bool m_ShowDetail;
|
||||
[SerializeField] private bool m_ZoomLock;
|
||||
[SerializeField] private bool m_Realtime;
|
||||
[SerializeField] private Color m_BackgroundColor;
|
||||
[SerializeField] private float m_Height;
|
||||
[SerializeField] protected Color32 m_FillerColor;
|
||||
[SerializeField] protected Color32 m_BorderColor;
|
||||
[SerializeField] protected float m_BorderWidth;
|
||||
[SerializeField] protected Color32 m_BackgroundColor;
|
||||
[SerializeField] private float m_Left;
|
||||
[SerializeField] private float m_Right;
|
||||
[SerializeField] private float m_Top;
|
||||
[SerializeField] private float m_Bottom;
|
||||
[SerializeField] private RangeMode m_RangeMode;
|
||||
[SerializeField] private float m_Start;
|
||||
@@ -88,8 +94,9 @@ namespace XCharts
|
||||
[SerializeField] private int m_MinShowNum = 1;
|
||||
[Range(1f, 20f)]
|
||||
[SerializeField] private float m_ScrollSensitivity = 1.1f;
|
||||
[SerializeField] private int m_FontSize = 18;
|
||||
[SerializeField] private FontStyle m_FontStyle;
|
||||
[SerializeField] private TextStyle m_TextStyle;
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.Solid);
|
||||
[SerializeField] private AreaStyle m_AreaStyle = new AreaStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show dataZoom.
|
||||
@@ -98,7 +105,7 @@ namespace XCharts
|
||||
public bool enable
|
||||
{
|
||||
get { return m_Enable; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The mode of data filter.
|
||||
@@ -107,25 +114,25 @@ namespace XCharts
|
||||
public FilterMode filterMode
|
||||
{
|
||||
get { return m_FilterMode; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_FilterMode, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FilterMode, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Specify which xAxis is controlled by the dataZoom.
|
||||
/// 控制哪一个 x 轴。
|
||||
/// 控制的 x 轴索引列表。
|
||||
/// </summary>
|
||||
public int xAxisIndex
|
||||
public List<int> xAxisIndexs
|
||||
{
|
||||
get { return m_XAxisIndex; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_XAxisIndex, value)) SetVerticesDirty(); }
|
||||
get { return m_XAxisIndexs; }
|
||||
set { if (PropertyUtil.SetClass(ref m_XAxisIndexs, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Specify which yAxis is controlled by the dataZoom.
|
||||
/// 控制哪一个 y 轴。
|
||||
/// 控制的 y 轴索引列表。
|
||||
/// </summary>
|
||||
public int yAxisIndex
|
||||
public List<int> yAxisIndexs
|
||||
{
|
||||
get { return m_YAxisIndex; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_YAxisIndex, value)) SetVerticesDirty(); }
|
||||
get { return m_YAxisIndexs; }
|
||||
set { if (PropertyUtil.SetClass(ref m_YAxisIndexs, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether built-in support is supported.
|
||||
@@ -137,7 +144,7 @@ namespace XCharts
|
||||
public bool supportInside
|
||||
{
|
||||
get { return m_SupportInside; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SupportInside, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SupportInside, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether a slider is supported. There are separate sliders on which the user zooms or roams.
|
||||
@@ -146,7 +153,7 @@ namespace XCharts
|
||||
public bool supportSlider
|
||||
{
|
||||
get { return m_SupportSlider; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SupportSlider, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SupportSlider, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否支持框选。提供一个选框进行数据区域缩放。
|
||||
@@ -154,7 +161,7 @@ namespace XCharts
|
||||
private bool supportSelect
|
||||
{
|
||||
get { return m_SupportSelect; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SupportSelect, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SupportSelect, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show data shadow, to indicate the data tendency in brief.
|
||||
@@ -164,7 +171,7 @@ namespace XCharts
|
||||
public bool showDataShadow
|
||||
{
|
||||
get { return m_ShowDataShadow; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ShowDataShadow, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowDataShadow, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show detail, that is, show the detailed data information when dragging.
|
||||
@@ -174,7 +181,7 @@ namespace XCharts
|
||||
public bool showDetail
|
||||
{
|
||||
get { return m_ShowDetail; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ShowDetail, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowDetail, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Specify whether to lock the size of window (selected area).
|
||||
@@ -185,7 +192,7 @@ namespace XCharts
|
||||
public bool zoomLock
|
||||
{
|
||||
get { return m_ZoomLock; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ZoomLock, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ZoomLock, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show data shadow in dataZoom-silder component, to indicate the data tendency in brief.
|
||||
@@ -197,32 +204,81 @@ namespace XCharts
|
||||
/// The background color of the component.
|
||||
/// 组件的背景颜色。
|
||||
/// </summary>
|
||||
private Color backgroundColor
|
||||
public Color backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of dataZoom data area.
|
||||
/// 数据区域颜色。
|
||||
/// </summary>
|
||||
public Color32 fillerColor
|
||||
{
|
||||
get { return m_FillerColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_FillerColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the color of dataZoom border.
|
||||
/// 边框颜色。
|
||||
/// </summary>
|
||||
public Color32 borderColor
|
||||
{
|
||||
get { return m_BorderColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框宽。
|
||||
/// </summary>
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between dataZoom component and the bottom side of the container.
|
||||
/// bottom value is a instant pixel value like 10.
|
||||
/// bottom value is a instant pixel value like 10 or float value [0-1].
|
||||
/// default:10
|
||||
/// 组件离容器下侧的距离。
|
||||
/// </summary>
|
||||
public float bottom
|
||||
{
|
||||
get { return m_Bottom; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The height of dataZoom component.
|
||||
/// height value is a instant pixel value like 10.
|
||||
/// default:50
|
||||
/// 组件高度。
|
||||
/// Distance between dataZoom component and the top side of the container.
|
||||
/// top value is a instant pixel value like 10 or float value [0-1].
|
||||
/// default:10
|
||||
/// 组件离容器上侧的距离。
|
||||
/// </summary>
|
||||
public float height
|
||||
public float top
|
||||
{
|
||||
get { return m_Height; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
|
||||
get { return m_Top; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between dataZoom component and the left side of the container.
|
||||
/// left value is a instant pixel value like 10 or float value [0-1].
|
||||
/// default:10
|
||||
/// 组件离容器左侧的距离。
|
||||
/// </summary>
|
||||
public float left
|
||||
{
|
||||
get { return m_Left; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between dataZoom component and the right side of the container.
|
||||
/// right value is a instant pixel value like 10 or float value [0-1].
|
||||
/// default:10
|
||||
/// 组件离容器右侧的距离。
|
||||
/// </summary>
|
||||
public float right
|
||||
{
|
||||
get { return m_Right; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Use absolute value or percent value in DataZoom.start and DataZoom.end.
|
||||
@@ -232,7 +288,7 @@ namespace XCharts
|
||||
public RangeMode rangeMode
|
||||
{
|
||||
get { return m_RangeMode; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_RangeMode, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_RangeMode, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The start percentage of the window out of the data extent, in the range of 0 ~ 100.
|
||||
@@ -261,7 +317,7 @@ namespace XCharts
|
||||
public int minShowNum
|
||||
{
|
||||
get { return m_MinShowNum; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_MinShowNum, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MinShowNum, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The sensitivity of dataZoom scroll.
|
||||
@@ -272,37 +328,49 @@ namespace XCharts
|
||||
public float scrollSensitivity
|
||||
{
|
||||
get { return m_ScrollSensitivity; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ScrollSensitivity, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font size.
|
||||
/// 文字的字体大小。
|
||||
/// </summary>
|
||||
public int fontSize
|
||||
{
|
||||
get { return m_FontSize; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ScrollSensitivity, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font style.
|
||||
/// 文字字体的风格。
|
||||
/// 文字格式。
|
||||
/// </summary>
|
||||
public FontStyle fontStyle
|
||||
public TextStyle textStyle
|
||||
{
|
||||
get { return m_FontStyle; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
|
||||
get { return m_TextStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 阴影线条样式。
|
||||
/// </summary>
|
||||
public LineStyle lineStyle
|
||||
{
|
||||
get { return m_LineStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_LineStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 阴影填充样式。
|
||||
/// </summary>
|
||||
public AreaStyle areaStyle
|
||||
{
|
||||
get { return m_AreaStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_AreaStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
public int index { get; internal set; }
|
||||
public float runtimeX { get; private set; }
|
||||
public float runtimeY { get; private set; }
|
||||
public float runtimeWidth { get; private set; }
|
||||
public float runtimeHeight { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The start label.
|
||||
/// 组件的开始信息文本。
|
||||
/// </summary>
|
||||
private Text m_StartLabel { get; set; }
|
||||
private ChartText m_StartLabel { get; set; }
|
||||
/// <summary>
|
||||
/// The end label.
|
||||
/// 组件的结束信息文本。
|
||||
/// </summary>
|
||||
private Text m_EndLabel { get; set; }
|
||||
private ChartText m_EndLabel { get; set; }
|
||||
|
||||
public static DataZoom defaultDataZoom
|
||||
{
|
||||
@@ -310,18 +378,31 @@ namespace XCharts
|
||||
{
|
||||
return new DataZoom()
|
||||
{
|
||||
supportInside = true,
|
||||
supportSlider = true,
|
||||
filterMode = FilterMode.None,
|
||||
xAxisIndex = 0,
|
||||
yAxisIndex = 0,
|
||||
xAxisIndexs = new List<int>() { 0 },
|
||||
yAxisIndexs = new List<int>() { },
|
||||
showDataShadow = true,
|
||||
showDetail = false,
|
||||
zoomLock = false,
|
||||
m_Height = 0,
|
||||
m_Bottom = 10,
|
||||
m_Left = 10,
|
||||
m_Right = 10,
|
||||
m_Top = 0.9f,
|
||||
rangeMode = RangeMode.Percent,
|
||||
start = 30,
|
||||
end = 70,
|
||||
m_ScrollSensitivity = 10,
|
||||
m_TextStyle = new TextStyle(),
|
||||
m_LineStyle = new LineStyle(LineStyle.Type.Solid){
|
||||
opacity = 0.3f
|
||||
},
|
||||
m_AreaStyle = new AreaStyle()
|
||||
{
|
||||
show = true,
|
||||
opacity = 0.3f,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -333,10 +414,14 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInZoom(Vector2 pos, float startX, float startY, float width)
|
||||
public bool IsInZoom(Vector2 pos)
|
||||
{
|
||||
Rect rect = Rect.MinMaxRect(startX, startY + m_Bottom, startX + width, startY + m_Bottom + m_Height);
|
||||
return rect.Contains(pos);
|
||||
if (pos.x < runtimeX - 1 || pos.x > runtimeX + runtimeWidth + 1 ||
|
||||
pos.y < runtimeY - 1 || pos.y > runtimeY + runtimeHeight + 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -346,11 +431,11 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInSelectedZoom(Vector2 pos, float startX, float startY, float width)
|
||||
public bool IsInSelectedZoom(Vector2 pos)
|
||||
{
|
||||
var start = startX + width * m_Start / 100;
|
||||
var end = startX + width * m_End / 100;
|
||||
Rect rect = Rect.MinMaxRect(start, startY + m_Bottom, end, startY + m_Bottom + m_Height);
|
||||
var start = runtimeX + runtimeWidth * m_Start / 100;
|
||||
var end = runtimeX + runtimeWidth * m_End / 100;
|
||||
Rect rect = Rect.MinMaxRect(start, runtimeY, end, runtimeY + runtimeHeight);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
@@ -361,10 +446,10 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInStartZoom(Vector2 pos, float startX, float startY, float width)
|
||||
public bool IsInStartZoom(Vector2 pos)
|
||||
{
|
||||
var start = startX + width * m_Start / 100;
|
||||
Rect rect = Rect.MinMaxRect(start - 10, startY + m_Bottom, start + 10, startY + m_Bottom + m_Height);
|
||||
var start = runtimeX + runtimeWidth * m_Start / 100;
|
||||
Rect rect = Rect.MinMaxRect(start - 10, runtimeY, start + 10, runtimeY + runtimeHeight);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
@@ -375,24 +460,29 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInEndZoom(Vector2 pos, float startX, float startY, float width)
|
||||
public bool IsInEndZoom(Vector2 pos)
|
||||
{
|
||||
var end = startX + width * m_End / 100;
|
||||
Rect rect = Rect.MinMaxRect(end - 10, startY + m_Bottom, end + 10, startY + m_Bottom + m_Height);
|
||||
var end = runtimeX + runtimeWidth * m_End / 100;
|
||||
Rect rect = Rect.MinMaxRect(end - 10, runtimeY, end + 10, runtimeY + runtimeHeight);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
public bool IsContainsAxisIndex(int index)
|
||||
{
|
||||
return xAxisIndexs.Contains(index);// || yAxisIndexs.Contains(index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示文本
|
||||
/// </summary>
|
||||
/// <param name="flag"></param>
|
||||
internal void SetLabelActive(bool flag)
|
||||
{
|
||||
if (m_StartLabel && m_StartLabel.gameObject.activeInHierarchy != flag)
|
||||
if (m_StartLabel != null && m_StartLabel.gameObject.activeInHierarchy != flag)
|
||||
{
|
||||
m_StartLabel.gameObject.SetActive(flag);
|
||||
}
|
||||
if (m_EndLabel && m_EndLabel.gameObject.activeInHierarchy != flag)
|
||||
if (m_EndLabel != null && m_EndLabel.gameObject.activeInHierarchy != flag)
|
||||
{
|
||||
m_EndLabel.gameObject.SetActive(flag);
|
||||
}
|
||||
@@ -404,7 +494,7 @@ namespace XCharts
|
||||
/// <param name="text"></param>
|
||||
internal void SetStartLabelText(string text)
|
||||
{
|
||||
if (m_StartLabel) m_StartLabel.text = text;
|
||||
if (m_StartLabel != null) m_StartLabel.SetText(text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -413,43 +503,56 @@ namespace XCharts
|
||||
/// <param name="text"></param>
|
||||
internal void SetEndLabelText(string text)
|
||||
{
|
||||
if (m_EndLabel) m_EndLabel.text = text;
|
||||
if (m_EndLabel != null) m_EndLabel.SetText(text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取DataZoom的高,当height设置为0时,自动计算合适的偏移。
|
||||
/// </summary>
|
||||
/// <param name="gridBottom"></param>
|
||||
/// <returns></returns>
|
||||
internal float GetHeight(float gridBottom)
|
||||
{
|
||||
if (height <= 0)
|
||||
{
|
||||
height = gridBottom - bottom - 30;
|
||||
if (height < 10) height = 10;
|
||||
return height;
|
||||
}
|
||||
else return height;
|
||||
}
|
||||
|
||||
internal void SetStartLabel(Text startLabel)
|
||||
internal void SetStartLabel(ChartText startLabel)
|
||||
{
|
||||
m_StartLabel = startLabel;
|
||||
}
|
||||
|
||||
internal void SetEndLabel(Text endLabel)
|
||||
internal void SetEndLabel(ChartText endLabel)
|
||||
{
|
||||
m_EndLabel = endLabel;
|
||||
}
|
||||
|
||||
internal void UpdateStartLabelPosition(Vector3 pos)
|
||||
{
|
||||
m_StartLabel.transform.localPosition = pos;
|
||||
m_StartLabel.SetLocalPosition(pos);
|
||||
}
|
||||
|
||||
internal void UpdateEndLabelPosition(Vector3 pos)
|
||||
{
|
||||
m_EndLabel.transform.localPosition = pos;
|
||||
m_EndLabel.SetLocalPosition(pos);
|
||||
}
|
||||
|
||||
internal void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
|
||||
{
|
||||
var runtimeLeft = left <= 1 ? left * chartWidth : left;
|
||||
var runtimeBottom = bottom <= 1 ? bottom * chartHeight : bottom;
|
||||
var runtimeTop = top <= 1 ? top * chartHeight : top;
|
||||
var runtimeRight = right <= 1 ? right * chartWidth : right;
|
||||
runtimeX = chartX + runtimeLeft;
|
||||
runtimeY = chartY + runtimeBottom;
|
||||
runtimeWidth = chartWidth - runtimeLeft - runtimeRight;
|
||||
runtimeHeight = chartHeight - runtimeTop - runtimeBottom;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -47,11 +47,12 @@ namespace XCharts
|
||||
[SerializeField] private float m_ItemGap = 10f;
|
||||
[SerializeField] private bool m_ItemAutoColor = true;
|
||||
[SerializeField] private string m_Formatter;
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18);
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
[SerializeField] private List<string> m_Data = new List<string>();
|
||||
[SerializeField] private List<Sprite> m_Icons = new List<Sprite>();
|
||||
|
||||
private Dictionary<string, LegendItem> m_DataBtnList = new Dictionary<string, LegendItem>();
|
||||
private Dictionary<int, float> m_RuntimeEachWidth = new Dictionary<int, float>();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show legend component.
|
||||
@@ -60,7 +61,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Selected mode of legend, which controls whether series can be toggled displaying by clicking legends.
|
||||
@@ -71,7 +72,7 @@ namespace XCharts
|
||||
public SelectedMode selectedMode
|
||||
{
|
||||
get { return m_SelectedMode; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SelectedMode, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SelectedMode, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Specify whether the layout of legend component is horizontal or vertical.
|
||||
@@ -81,7 +82,7 @@ namespace XCharts
|
||||
public Orient orient
|
||||
{
|
||||
get { return m_Orient; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Orient, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Orient, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The location of legend.
|
||||
@@ -91,7 +92,7 @@ namespace XCharts
|
||||
public Location location
|
||||
{
|
||||
get { return m_Location; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Location, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Image width of legend symbol.
|
||||
@@ -101,7 +102,7 @@ namespace XCharts
|
||||
public float itemWidth
|
||||
{
|
||||
get { return m_ItemWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ItemWidth, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemWidth, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Image height of legend symbol.
|
||||
@@ -111,7 +112,7 @@ namespace XCharts
|
||||
public float itemHeight
|
||||
{
|
||||
get { return m_ItemHeight; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The distance between each legend, horizontal distance in horizontal layout, and vertical distance in vertical layout.
|
||||
@@ -121,7 +122,7 @@ namespace XCharts
|
||||
public float itemGap
|
||||
{
|
||||
get { return m_ItemGap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the legend symbol matches the color automatically.
|
||||
@@ -131,7 +132,7 @@ namespace XCharts
|
||||
public bool itemAutoColor
|
||||
{
|
||||
get { return m_ItemAutoColor; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemAutoColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Legend content string template formatter. Support for wrapping lines with \n. Template:{name}.
|
||||
@@ -142,7 +143,7 @@ namespace XCharts
|
||||
public string formatter
|
||||
{
|
||||
get { return m_Formatter; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the style of text.
|
||||
@@ -151,7 +152,7 @@ namespace XCharts
|
||||
public TextStyle textStyle
|
||||
{
|
||||
get { return m_TextStyle; }
|
||||
set { if (PropertyUtility.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Data array of legend. An array item is usually a name representing string. (If it is a pie chart,
|
||||
@@ -173,6 +174,7 @@ namespace XCharts
|
||||
get { return m_Icons; }
|
||||
set { if (value != null) { m_Icons = value; SetComponentDirty(); } }
|
||||
}
|
||||
public int index { get; internal set; }
|
||||
/// <summary>
|
||||
/// 图表是否需要刷新(图例组件不需要刷新图表)
|
||||
/// </summary>
|
||||
@@ -209,7 +211,7 @@ namespace XCharts
|
||||
/// <summary>
|
||||
/// 多列时每列的宽度
|
||||
/// </summary>
|
||||
public Dictionary<int, float> runtimeEachWidth { get; internal set; }
|
||||
public Dictionary<int, float> runtimeEachWidth { get { return m_RuntimeEachWidth; }}
|
||||
/// <summary>
|
||||
/// 单列高度
|
||||
/// </summary>
|
||||
@@ -231,11 +233,10 @@ namespace XCharts
|
||||
m_ItemWidth = 24.0f,
|
||||
m_ItemHeight = 12.0f,
|
||||
m_ItemGap = 10f,
|
||||
runtimeEachWidth = new Dictionary<int, float>()
|
||||
};
|
||||
legend.location.top = 30;
|
||||
legend.location.top = 35;
|
||||
legend.textStyle.offset = new Vector2(2, 0);
|
||||
legend.textStyle.fontSize = 18;
|
||||
legend.textStyle.fontSize = 0;
|
||||
return legend;
|
||||
}
|
||||
}
|
||||
@@ -393,18 +394,6 @@ namespace XCharts
|
||||
m_Location.OnChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parsing the data from the JSON string.
|
||||
/// 从json字符串解析数据,json格式如:['legend1','legend2','legend3','legend4','legend5']
|
||||
/// </summary>
|
||||
/// <param name="jsonData"></param>
|
||||
public override void ParseJsonData(string jsonData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
||||
m_Data = ChartHelper.ParseStringFromString(jsonData);
|
||||
SetComponentDirty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获得图例格式化后的显示内容。
|
||||
/// </summary>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -33,7 +33,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// [default:[0.5f,0.45f]]The center of ploar. The center[0] is the x-coordinate, and the center[1] is the y-coordinate.
|
||||
@@ -53,7 +53,7 @@ namespace XCharts
|
||||
public float radius
|
||||
{
|
||||
get { return m_Radius; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Radius, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// [default:Color.clear]Background color of polar, which is transparent by default.
|
||||
@@ -62,9 +62,9 @@ namespace XCharts
|
||||
public Color backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public int index { get; internal set; }
|
||||
/// <summary>
|
||||
/// the center position of polar in container.
|
||||
/// 极坐标在容器中的具体中心点。
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
@@ -84,10 +84,12 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public Text text { get; set; }
|
||||
}
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private Shape m_Shape;
|
||||
[SerializeField] private float m_Radius = 100;
|
||||
[SerializeField] private int m_SplitNumber = 5;
|
||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
|
||||
[SerializeField] private AxisLine m_AxisLine = AxisLine.defaultAxisLine;
|
||||
[SerializeField] private AxisSplitLine m_SplitLine = AxisSplitLine.defaultSplitLine;
|
||||
[SerializeField] private AxisSplitArea m_SplitArea = AxisSplitArea.defaultSplitArea;
|
||||
[SerializeField] private bool m_Indicator = true;
|
||||
@@ -97,6 +99,12 @@ namespace XCharts
|
||||
[SerializeField] private bool m_IsAxisTooltip;
|
||||
[SerializeField] private List<Indicator> m_IndicatorList = new List<Indicator>();
|
||||
/// <summary>
|
||||
/// [default:true]
|
||||
/// Set this to false to prevent the radar from showing.
|
||||
/// 是否显示雷达坐标系组件。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// Radar render type, in which 'Polygon' and 'Circle' are supported.
|
||||
/// 雷达图绘制类型,支持 'Polygon' 和 'Circle'。
|
||||
/// </summary>
|
||||
@@ -104,7 +112,7 @@ namespace XCharts
|
||||
public Shape shape
|
||||
{
|
||||
get { return m_Shape; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Shape, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Shape, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the radius of radar.
|
||||
@@ -113,7 +121,7 @@ namespace XCharts
|
||||
public float radius
|
||||
{
|
||||
get { return m_Radius; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Radius, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Segments of indicator axis.
|
||||
@@ -122,7 +130,7 @@ namespace XCharts
|
||||
public int splitNumber
|
||||
{
|
||||
get { return m_SplitNumber; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the center of radar chart.
|
||||
@@ -135,13 +143,22 @@ namespace XCharts
|
||||
set { if (value != null) { m_Center = value; SetAllDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// axis line.
|
||||
/// 轴线。
|
||||
/// </summary>
|
||||
public AxisLine axisLine
|
||||
{
|
||||
get { return m_AxisLine; }
|
||||
set { if (PropertyUtil.SetClass(ref m_AxisLine, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// split line.
|
||||
/// 分割线。
|
||||
/// </summary>
|
||||
public AxisSplitLine splitLine
|
||||
{
|
||||
get { return m_SplitLine; }
|
||||
set { if (PropertyUtility.SetClass(ref m_SplitLine, value, true)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_SplitLine, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Split area of axis in grid area.
|
||||
@@ -150,7 +167,7 @@ namespace XCharts
|
||||
public AxisSplitArea splitArea
|
||||
{
|
||||
get { return m_SplitArea; }
|
||||
set { if (PropertyUtility.SetClass(ref m_SplitArea, value, true)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_SplitArea, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show indicator.
|
||||
@@ -159,7 +176,7 @@ namespace XCharts
|
||||
public bool indicator
|
||||
{
|
||||
get { return m_Indicator; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Indicator, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Indicator, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The gap of indicator and radar.
|
||||
@@ -168,7 +185,7 @@ namespace XCharts
|
||||
public float indicatorGap
|
||||
{
|
||||
get { return m_IndicatorGap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_IndicatorGap, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_IndicatorGap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The ratio of maximum and minimum values rounded upward. The default is 0, which is automatically calculated.
|
||||
@@ -177,7 +194,7 @@ namespace XCharts
|
||||
public int ceilRate
|
||||
{
|
||||
get { return m_CeilRate; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_CeilRate, value < 0 ? 0 : value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否Tooltip显示轴线上的所有数据。
|
||||
@@ -185,7 +202,7 @@ namespace XCharts
|
||||
public bool isAxisTooltip
|
||||
{
|
||||
get { return m_IsAxisTooltip; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_IsAxisTooltip, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_IsAxisTooltip, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The position type of indicator.
|
||||
@@ -194,7 +211,7 @@ namespace XCharts
|
||||
public PositionType positionType
|
||||
{
|
||||
get { return m_PositionType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_PositionType, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PositionType, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the indicator list.
|
||||
@@ -226,6 +243,7 @@ namespace XCharts
|
||||
{
|
||||
var radar = new Radar
|
||||
{
|
||||
m_Show = true,
|
||||
m_Shape = Shape.Polygon,
|
||||
m_Radius = 0.35f,
|
||||
m_SplitNumber = 5,
|
||||
@@ -242,7 +260,6 @@ namespace XCharts
|
||||
radar.center[1] = 0.4f;
|
||||
radar.splitLine.show = true;
|
||||
radar.splitArea.show = true;
|
||||
radar.splitLine.lineStyle.width = 0.6f;
|
||||
return radar;
|
||||
}
|
||||
}
|
||||
@@ -259,38 +276,6 @@ namespace XCharts
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ParseJsonData(string jsonData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
||||
string pattern = "[\"|'](.*?)[\"|']";
|
||||
if (Regex.IsMatch(jsonData, pattern))
|
||||
{
|
||||
m_IndicatorList.Clear();
|
||||
MatchCollection m = Regex.Matches(jsonData, pattern);
|
||||
foreach (Match match in m)
|
||||
{
|
||||
m_IndicatorList.Add(new Indicator()
|
||||
{
|
||||
name = match.Groups[1].Value
|
||||
});
|
||||
}
|
||||
}
|
||||
pattern = "(\\d+)";
|
||||
if (Regex.IsMatch(jsonData, pattern))
|
||||
{
|
||||
MatchCollection m = Regex.Matches(jsonData, pattern);
|
||||
int index = 0;
|
||||
foreach (Match match in m)
|
||||
{
|
||||
if (m_IndicatorList[index] != null)
|
||||
{
|
||||
m_IndicatorList[index].max = int.Parse(match.Groups[1].Value);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float GetIndicatorMin(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_IndicatorList.Count)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -226,9 +226,11 @@ namespace XCharts
|
||||
[SerializeField] private SerieType m_Type;
|
||||
[SerializeField] private string m_Name;
|
||||
[SerializeField] private string m_Stack;
|
||||
[SerializeField] [Range(0, 1)] private int m_AxisIndex = 0;
|
||||
[SerializeField] private int m_XAxisIndex = 0;
|
||||
[SerializeField] private int m_YAxisIndex = 0;
|
||||
[SerializeField] private int m_RadarIndex = 0;
|
||||
[SerializeField] private int m_VesselIndex = 0;
|
||||
[SerializeField] private int m_PolarIndex = 0;
|
||||
[SerializeField] protected int m_MinShow;
|
||||
[SerializeField] protected int m_MaxShow;
|
||||
[SerializeField] protected int m_MaxCache;
|
||||
@@ -267,7 +269,7 @@ namespace XCharts
|
||||
[SerializeField] private bool m_ClickOffset = true;
|
||||
[SerializeField] private RoseType m_RoseType = RoseType.None;
|
||||
[SerializeField] private float m_Space;
|
||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.5f };
|
||||
[SerializeField] private float[] m_Center = new float[2] { 0.5f, 0.45f };
|
||||
[SerializeField] private float[] m_Radius = new float[2] { 0, 80 };
|
||||
[SerializeField] private SerieLabel m_Label = new SerieLabel();
|
||||
[SerializeField] private SerieAnimation m_Animation = new SerieAnimation();
|
||||
@@ -310,7 +312,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) { SetVerticesDirty(); SetNameDirty(); } }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) { SetVerticesDirty(); SetNameDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// the chart type of serie.
|
||||
@@ -319,7 +321,7 @@ namespace XCharts
|
||||
public SerieType type
|
||||
{
|
||||
get { return m_Type; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Series name used for displaying in tooltip and filtering with legend.
|
||||
@@ -328,7 +330,7 @@ namespace XCharts
|
||||
public string name
|
||||
{
|
||||
get { return m_Name; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Name, value)) { SetVerticesDirty(); SetNameDirty(); } }
|
||||
set { if (PropertyUtil.SetClass(ref m_Name, value)) { SetVerticesDirty(); SetNameDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Legend name. When the serie name is not empty, the legend name is the series name; Otherwise, it is index.
|
||||
@@ -342,16 +344,25 @@ namespace XCharts
|
||||
public string stack
|
||||
{
|
||||
get { return m_Stack; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Stack, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Stack, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Index of axis to combine with, which is useful for multiple x axes in one chart.
|
||||
/// 使用的坐标轴轴的 index,在单个图表实例中存在多个坐标轴轴的时候有用。
|
||||
/// the index of XAxis.
|
||||
/// 使用X轴的index。
|
||||
/// </summary>
|
||||
public int axisIndex
|
||||
public int xAxisIndex
|
||||
{
|
||||
get { return m_AxisIndex; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_AxisIndex, value)) SetVerticesDirty(); }
|
||||
get { return m_XAxisIndex; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_XAxisIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the index of YAxis.
|
||||
/// 使用Y轴的index。
|
||||
/// </summary>
|
||||
public int yAxisIndex
|
||||
{
|
||||
get { return m_YAxisIndex; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_YAxisIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Index of radar component that radar chart uses.
|
||||
@@ -360,7 +371,7 @@ namespace XCharts
|
||||
public int radarIndex
|
||||
{
|
||||
get { return m_RadarIndex; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_RadarIndex, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_RadarIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Index of vesel component that liquid chart uses.
|
||||
@@ -369,7 +380,16 @@ namespace XCharts
|
||||
public int vesselIndex
|
||||
{
|
||||
get { return m_VesselIndex; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_VesselIndex, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_VesselIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Index of polar component that serie uses.
|
||||
/// 所使用的 polar 组件的 index。
|
||||
/// </summary>
|
||||
public int polarIndex
|
||||
{
|
||||
get { return m_PolarIndex; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PolarIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The min number of data to show in chart.
|
||||
@@ -378,7 +398,7 @@ namespace XCharts
|
||||
public int minShow
|
||||
{
|
||||
get { return m_MinShow; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_MinShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MinShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// The max number of data to show in chart.
|
||||
@@ -387,7 +407,7 @@ namespace XCharts
|
||||
public int maxShow
|
||||
{
|
||||
get { return m_MaxShow; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_MaxShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MaxShow, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// The max number of serie data cache.
|
||||
@@ -398,7 +418,7 @@ namespace XCharts
|
||||
public int maxCache
|
||||
{
|
||||
get { return m_MaxCache; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MaxCache, value < 0 ? 0 : value)) { SetVerticesDirty(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// The style of area.
|
||||
@@ -407,7 +427,7 @@ namespace XCharts
|
||||
public AreaStyle areaStyle
|
||||
{
|
||||
get { return m_AreaStyle; }
|
||||
set { if (PropertyUtility.SetClass(ref m_AreaStyle, value, true)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_AreaStyle, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the symbol of serie data item.
|
||||
@@ -416,7 +436,7 @@ namespace XCharts
|
||||
public SerieSymbol symbol
|
||||
{
|
||||
get { return m_Symbol; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Symbol, value, true)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Symbol, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The type of line chart.
|
||||
@@ -425,7 +445,7 @@ namespace XCharts
|
||||
public LineType lineType
|
||||
{
|
||||
get { return m_LineType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the min pixel dist of sample.
|
||||
@@ -434,7 +454,7 @@ namespace XCharts
|
||||
public float sampleDist
|
||||
{
|
||||
get { return m_SampleDist; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SampleDist, value < 0 ? 0 : value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SampleDist, value < 0 ? 0 : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of sample.
|
||||
@@ -443,7 +463,7 @@ namespace XCharts
|
||||
public SampleType sampleType
|
||||
{
|
||||
get { return m_SampleType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SampleType, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SampleType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 设定的采样平均值。当sampleType 为 Peak 时,用于和过滤数据的平均值做对比是取最大值还是最小值。默认为0时会实时计算所有数据的平均值。
|
||||
@@ -451,7 +471,7 @@ namespace XCharts
|
||||
public float sampleAverage
|
||||
{
|
||||
get { return m_SampleAverage; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SampleAverage, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SampleAverage, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The style of line.
|
||||
@@ -460,7 +480,7 @@ namespace XCharts
|
||||
public LineStyle lineStyle
|
||||
{
|
||||
get { return m_LineStyle; }
|
||||
set { if (PropertyUtility.SetClass(ref m_LineStyle, value, true)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_LineStyle, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 柱形图类型。
|
||||
@@ -468,7 +488,7 @@ namespace XCharts
|
||||
public BarType barType
|
||||
{
|
||||
get { return m_BarType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BarType, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 柱形图是否为百分比堆积。相同stack的serie只要有一个barPercentStack为true,则就显示成百分比堆叠柱状图。
|
||||
@@ -476,7 +496,7 @@ namespace XCharts
|
||||
public bool barPercentStack
|
||||
{
|
||||
get { return m_BarPercentStack; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BarPercentStack, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarPercentStack, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The width of the bar. Adaptive when default 0.
|
||||
@@ -485,7 +505,7 @@ namespace XCharts
|
||||
public float barWidth
|
||||
{
|
||||
get { return m_BarWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BarWidth, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The gap between bars between different series, is a percent value like '0.3f' , which means 30% of the bar width, can be set as a fixed value.
|
||||
@@ -500,7 +520,7 @@ namespace XCharts
|
||||
public float barGap
|
||||
{
|
||||
get { return m_BarGap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BarGap, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The bar gap of a single series, defaults to be 20% of the category gap, can be set as a fixed value.
|
||||
@@ -513,7 +533,7 @@ namespace XCharts
|
||||
public float barCategoryGap
|
||||
{
|
||||
get { return m_BarCategoryGap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BarCategoryGap, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarCategoryGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 斑马线的粗细。
|
||||
@@ -521,7 +541,7 @@ namespace XCharts
|
||||
public float barZebraWidth
|
||||
{
|
||||
get { return m_BarZebraWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BarZebraWidth, value < 0 ? 0 : value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarZebraWidth, value < 0 ? 0 : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 斑马线的间距。
|
||||
@@ -529,7 +549,7 @@ namespace XCharts
|
||||
public float barZebraGap
|
||||
{
|
||||
get { return m_BarZebraGap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BarZebraGap, value < 0 ? 0 : value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BarZebraGap, value < 0 ? 0 : value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -539,7 +559,7 @@ namespace XCharts
|
||||
public bool pieClickOffset
|
||||
{
|
||||
get { return m_ClickOffset; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ClickOffset, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ClickOffset, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show as Nightingale chart.
|
||||
@@ -548,7 +568,7 @@ namespace XCharts
|
||||
public RoseType pieRoseType
|
||||
{
|
||||
get { return m_RoseType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_RoseType, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_RoseType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the space of pie chart item.
|
||||
@@ -557,7 +577,7 @@ namespace XCharts
|
||||
public float pieSpace
|
||||
{
|
||||
get { return m_Space; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Space, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Space, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the center of chart.
|
||||
@@ -577,25 +597,13 @@ namespace XCharts
|
||||
get { return m_Radius; }
|
||||
set { if (value != null && value.Length == 2) { m_Radius = value; SetVerticesDirty(); } }
|
||||
}
|
||||
[Obsolete("Use Serie.center instead.", true)]
|
||||
public float[] pieCenter
|
||||
{
|
||||
get { return center; }
|
||||
set { center = value; }
|
||||
}
|
||||
[Obsolete("Use Serie.radius instead.", true)]
|
||||
public float[] pieRadius
|
||||
{
|
||||
get { return radius; }
|
||||
set { radius = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 最小值,映射到 startAngle。
|
||||
/// </summary>
|
||||
public float min
|
||||
{
|
||||
get { return m_Min; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 最大值,映射到 endAngle。
|
||||
@@ -603,7 +611,7 @@ namespace XCharts
|
||||
public float max
|
||||
{
|
||||
get { return m_Max; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Max, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Max, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 起始角度。和时钟一样,12点钟位置是0度,顺时针到360度。
|
||||
@@ -611,7 +619,7 @@ namespace XCharts
|
||||
public float startAngle
|
||||
{
|
||||
get { return m_StartAngle; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_StartAngle, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_StartAngle, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 结束角度。和时钟一样,12点钟位置是0度,顺时针到360度。
|
||||
@@ -619,7 +627,7 @@ namespace XCharts
|
||||
public float endAngle
|
||||
{
|
||||
get { return m_EndAngle; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_EndAngle, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_EndAngle, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否顺时针。
|
||||
@@ -627,7 +635,7 @@ namespace XCharts
|
||||
public bool clockwise
|
||||
{
|
||||
get { return m_Clockwise; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Clockwise, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Clockwise, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -636,7 +644,7 @@ namespace XCharts
|
||||
public float ringGap
|
||||
{
|
||||
get { return m_RingGap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_RingGap, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_RingGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 刻度分割段数。最大可设置36。
|
||||
@@ -644,7 +652,7 @@ namespace XCharts
|
||||
public int splitNumber
|
||||
{
|
||||
get { return m_SplitNumber; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value > 36 ? 36 : value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value > 36 ? 36 : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否开启圆弧效果。
|
||||
@@ -652,7 +660,7 @@ namespace XCharts
|
||||
public bool roundCap
|
||||
{
|
||||
get { return m_RoundCap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_RoundCap, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_RoundCap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否开启忽略数据。当为 true 时,数据值为 ignoreValue 时不进行绘制。
|
||||
@@ -660,7 +668,7 @@ namespace XCharts
|
||||
public bool ignore
|
||||
{
|
||||
get { return m_Ignore; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Ignore, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Ignore, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 忽略数据的默认值。当ignore为true才有效。
|
||||
@@ -668,7 +676,7 @@ namespace XCharts
|
||||
public float ignoreValue
|
||||
{
|
||||
get { return m_IgnoreValue; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_IgnoreValue, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_IgnoreValue, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 雷达图类型。
|
||||
@@ -676,7 +684,7 @@ namespace XCharts
|
||||
public RadarType radarType
|
||||
{
|
||||
get { return m_RadarType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_RadarType, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_RadarType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 仪表盘轴线。
|
||||
@@ -684,7 +692,7 @@ namespace XCharts
|
||||
public GaugeAxis gaugeAxis
|
||||
{
|
||||
get { return m_GaugeAxis; }
|
||||
set { if (PropertyUtility.SetClass(ref m_GaugeAxis, value, true)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_GaugeAxis, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 仪表盘指针。
|
||||
@@ -692,7 +700,7 @@ namespace XCharts
|
||||
public GaugePointer gaugePointer
|
||||
{
|
||||
get { return m_GaugePointer; }
|
||||
set { if (PropertyUtility.SetClass(ref m_GaugePointer, value, true)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_GaugePointer, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 仪表盘类型。
|
||||
@@ -700,7 +708,7 @@ namespace XCharts
|
||||
public GaugeType gaugeType
|
||||
{
|
||||
get { return m_GaugeType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_GaugeType, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_GaugeType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Text label of graphic element,to explain some data information about graphic item like value, name and so on.
|
||||
@@ -709,7 +717,7 @@ namespace XCharts
|
||||
public SerieLabel label
|
||||
{
|
||||
get { return m_Label; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Label, value, true)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Label, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The start animation.
|
||||
@@ -718,7 +726,7 @@ namespace XCharts
|
||||
public SerieAnimation animation
|
||||
{
|
||||
get { return m_Animation; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Animation, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The arrow of line.
|
||||
@@ -727,7 +735,7 @@ namespace XCharts
|
||||
public LineArrow lineArrow
|
||||
{
|
||||
get { return m_LineArrow; }
|
||||
set { if (PropertyUtility.SetClass(ref m_LineArrow, value, true)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_LineArrow, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The style of data item.
|
||||
@@ -736,7 +744,7 @@ namespace XCharts
|
||||
public ItemStyle itemStyle
|
||||
{
|
||||
get { return m_ItemStyle; }
|
||||
set { if (PropertyUtility.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 高亮的图形样式和文本标签样式。
|
||||
@@ -744,7 +752,7 @@ namespace XCharts
|
||||
public Emphasis emphasis
|
||||
{
|
||||
get { return m_Emphasis; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Emphasis, value, true)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Emphasis, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 标题样式。
|
||||
@@ -752,7 +760,7 @@ namespace XCharts
|
||||
public TitleStyle titleStyle
|
||||
{
|
||||
get { return m_TitleStyle; }
|
||||
set { if (PropertyUtility.SetClass(ref m_TitleStyle, value, true)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_TitleStyle, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项里的数据维数。
|
||||
@@ -769,7 +777,7 @@ namespace XCharts
|
||||
public bool clip
|
||||
{
|
||||
get { return m_Clip; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Clip, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Clip, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Show negative number as positive number.
|
||||
@@ -778,7 +786,7 @@ namespace XCharts
|
||||
public bool showAsPositiveNumber
|
||||
{
|
||||
get { return m_ShowAsPositiveNumber; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否开启大数据量优化,在数据图形特别多而出现卡顿时候可以开启。
|
||||
@@ -790,7 +798,7 @@ namespace XCharts
|
||||
get { return m_Large; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtility.SetStruct(ref m_Large, value))
|
||||
if (PropertyUtil.SetStruct(ref m_Large, value))
|
||||
{
|
||||
SetAllDirty();
|
||||
label.SetComponentDirty();
|
||||
@@ -805,7 +813,7 @@ namespace XCharts
|
||||
get { return m_LargeThreshold; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtility.SetStruct(ref m_LargeThreshold, value))
|
||||
if (PropertyUtil.SetStruct(ref m_LargeThreshold, value))
|
||||
{
|
||||
SetAllDirty();
|
||||
label.SetComponentDirty();
|
||||
@@ -818,7 +826,7 @@ namespace XCharts
|
||||
public bool avoidLabelOverlap
|
||||
{
|
||||
get { return m_AvoidLabelOverlap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_AvoidLabelOverlap, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AvoidLabelOverlap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Wave length of the wave, which is relative to the diameter.
|
||||
@@ -827,7 +835,7 @@ namespace XCharts
|
||||
public float waveLength
|
||||
{
|
||||
get { return m_WaveLength; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_WaveLength, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_WaveLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 波高。
|
||||
@@ -835,7 +843,7 @@ namespace XCharts
|
||||
public float waveHeight
|
||||
{
|
||||
get { return m_WaveHeight; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_WaveHeight, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_WaveHeight, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 波偏移。
|
||||
@@ -843,7 +851,7 @@ namespace XCharts
|
||||
public float waveOffset
|
||||
{
|
||||
get { return m_WaveOffset; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_WaveOffset, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_WaveOffset, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 波速。正数时左移,负数时右移。
|
||||
@@ -851,7 +859,7 @@ namespace XCharts
|
||||
public float waveSpeed
|
||||
{
|
||||
get { return m_WaveSpeed; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_WaveSpeed, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_WaveSpeed, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||
@@ -950,7 +958,9 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public float runtimePieDataTotal { get; internal set; }
|
||||
public float runtimeWaveSpeed { get; internal set; }
|
||||
public Painter runtimeCanvas { get; internal set; }
|
||||
internal float runtimeCheckValue { get; set; }
|
||||
public int runtimeGridIndex { get; internal set; }
|
||||
public bool nameDirty { get { return m_NameDirty; } }
|
||||
|
||||
private void SetNameDirty()
|
||||
@@ -1413,7 +1423,8 @@ namespace XCharts
|
||||
/// <returns></returns>
|
||||
public List<SerieData> GetDataList(DataZoom dataZoom = null)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.enable)
|
||||
if (dataZoom != null && dataZoom.enable
|
||||
&& (dataZoom.xAxisIndexs.Contains(xAxisIndex) || dataZoom.yAxisIndexs.Contains(yAxisIndex)))
|
||||
{
|
||||
UpdateFilterData(dataZoom);
|
||||
return m_FilterData;
|
||||
@@ -1431,7 +1442,8 @@ namespace XCharts
|
||||
/// <param name="dataZoom"></param>
|
||||
internal void UpdateFilterData(DataZoom dataZoom)
|
||||
{
|
||||
if (dataZoom != null && dataZoom.enable)
|
||||
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);
|
||||
@@ -1674,6 +1686,14 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsCoordinateSerie()
|
||||
{
|
||||
return type == SerieType.Line
|
||||
|| type == SerieType.Bar
|
||||
|| type == SerieType.Scatter
|
||||
|| type == SerieType.Heatmap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定index的数据图标的尺寸
|
||||
/// </summary>
|
||||
@@ -1708,9 +1728,9 @@ namespace XCharts
|
||||
/// 从json中导入数据
|
||||
/// </summary>
|
||||
/// <param name="jsonData"></param>
|
||||
public override void ParseJsonData(string jsonData)
|
||||
public void ParseJsonData(string jsonData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(jsonData) || !m_DataFromJson) return;
|
||||
if (string.IsNullOrEmpty(jsonData)) return;
|
||||
jsonData = jsonData.Replace("\r\n", "");
|
||||
jsonData = jsonData.Replace(" ", "");
|
||||
jsonData = jsonData.Replace("\n", "");
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
@@ -21,10 +21,6 @@ namespace XCharts
|
||||
[SerializeField] protected List<Serie> m_Series;
|
||||
[NonSerialized] private bool m_LabelDirty;
|
||||
|
||||
[Obsolete("Use Series.list instead.", true)]
|
||||
public List<Serie> series { get { return m_Series; } }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// the list of serie
|
||||
/// 系列列表。
|
||||
@@ -261,15 +257,11 @@ namespace XCharts
|
||||
{
|
||||
serie.symbol.show = true;
|
||||
serie.symbol.type = SerieSymbolType.Circle;
|
||||
serie.symbol.size = 20f;
|
||||
serie.symbol.selectedSize = 30f;
|
||||
}
|
||||
else if (type == SerieType.Line)
|
||||
{
|
||||
serie.symbol.show = true;
|
||||
serie.symbol.type = SerieSymbolType.EmptyCircle;
|
||||
serie.symbol.size = 2.5f;
|
||||
serie.symbol.selectedSize = 5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -698,14 +690,5 @@ namespace XCharts
|
||||
if (serie.animation.enable) serie.animation.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从json中解析数据
|
||||
/// </summary>
|
||||
/// <param name="jsonData"></param>
|
||||
public override void ParseJsonData(string jsonData)
|
||||
{
|
||||
//TODO:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
@@ -17,14 +17,21 @@ namespace XCharts
|
||||
[Serializable]
|
||||
public class Settings : MainComponent
|
||||
{
|
||||
[SerializeField] [Range(1, 20)] protected int m_MaxPainter = 10;
|
||||
[SerializeField] [Range(1, 10)] protected float m_LineSmoothStyle = 3f;
|
||||
[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] [Range(10, 50)] protected float m_VisualMapTriangeLen = 20f;
|
||||
[SerializeField] [Range(1, 20)] protected float m_PieTooltipExtraRadius = 8f;
|
||||
[SerializeField] [Range(1, 20)] protected float m_PieSelectedOffset = 8f;
|
||||
|
||||
/// <summary>
|
||||
/// max painter.
|
||||
/// 设定的painter数量。
|
||||
/// </summary>
|
||||
public int maxPainter
|
||||
{
|
||||
get { return m_MaxPainter; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MaxPainter, value < 0 ? 1 : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Curve smoothing factor. By adjusting the smoothing coefficient, the curvature of the curve can be changed,
|
||||
/// and different curves with slightly different appearance can be obtained.
|
||||
@@ -33,7 +40,7 @@ namespace XCharts
|
||||
public float lineSmoothStyle
|
||||
{
|
||||
get { return m_LineSmoothStyle; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Smoothness of curve. The smaller the value, the smoother the curve, but the number of vertices will increase.
|
||||
@@ -44,7 +51,7 @@ namespace XCharts
|
||||
public float lineSmoothness
|
||||
{
|
||||
get { return m_LineSmoothness; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineSmoothStyle, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The partition distance of a line segment. A line in a normal line chart is made up of many segments,
|
||||
@@ -56,7 +63,7 @@ namespace XCharts
|
||||
public float lineSegmentDistance
|
||||
{
|
||||
get { return m_LineSegmentDistance; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_LineSegmentDistance, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineSegmentDistance, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the smoothess of cricle.
|
||||
@@ -65,32 +72,36 @@ namespace XCharts
|
||||
public float cicleSmoothness
|
||||
{
|
||||
get { return m_CicleSmoothness; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_CicleSmoothness, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_CicleSmoothness, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 可视化组件的调节三角形边长。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float visualMapTriangeLen
|
||||
|
||||
public void Copy(Settings settings)
|
||||
{
|
||||
get { return m_VisualMapTriangeLen; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_VisualMapTriangeLen, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
m_MaxPainter = settings.maxPainter;
|
||||
m_LineSmoothStyle = settings.lineSmoothStyle;
|
||||
m_LineSmoothness = settings.lineSmoothness;
|
||||
m_LineSegmentDistance = settings.lineSegmentDistance;
|
||||
m_CicleSmoothness = settings.cicleSmoothness;
|
||||
}
|
||||
/// <summary>
|
||||
/// 饼图鼠标移到高亮时的额外半径
|
||||
/// </summary>
|
||||
public float pieTooltipExtraRadius
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
get { return m_PieTooltipExtraRadius; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_PieTooltipExtraRadius, value < 0 ? 0f : value)) SetVerticesDirty(); }
|
||||
Copy(DefaultSettings);
|
||||
}
|
||||
/// <summary>
|
||||
/// 饼图选中时的中心点偏移
|
||||
/// </summary>
|
||||
public float pieSelectedOffset
|
||||
|
||||
public static Settings DefaultSettings
|
||||
{
|
||||
get { return m_PieSelectedOffset; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_PieSelectedOffset, value < 0 ? 0f : value)) SetVerticesDirty(); }
|
||||
get
|
||||
{
|
||||
return new Settings()
|
||||
{
|
||||
m_MaxPainter = XChartsSettings.maxPainter,
|
||||
m_LineSmoothStyle = XChartsSettings.lineSmoothStyle,
|
||||
m_LineSmoothness = XChartsSettings.lineSmoothness,
|
||||
m_LineSegmentDistance = XChartsSettings.lineSegmentDistance,
|
||||
m_CicleSmoothness = XChartsSettings.cicleSmoothness,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,629 +0,0 @@
|
||||
using System.Text;
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 主题
|
||||
/// </summary>
|
||||
public enum Theme
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认主题。
|
||||
/// </summary>
|
||||
Default,
|
||||
/// <summary>
|
||||
/// 亮主题。
|
||||
/// </summary>
|
||||
Light,
|
||||
/// <summary>
|
||||
/// 暗主题。
|
||||
/// </summary>
|
||||
Dark
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
/// <summary>
|
||||
/// Theme.
|
||||
/// 主题相关配置。
|
||||
/// </summary>
|
||||
public class ThemeInfo : MainComponent
|
||||
{
|
||||
[SerializeField] private Theme m_Theme = Theme.Default;
|
||||
[SerializeField] private Font m_Font;
|
||||
[SerializeField] private Color32 m_BackgroundColor;
|
||||
[FormerlySerializedAs("m_TextColor")]
|
||||
[SerializeField] private Color32 m_TitleTextColor;
|
||||
[SerializeField] private Color32 m_TitleSubTextColor;
|
||||
[SerializeField] private Color32 m_LegendTextColor;
|
||||
[SerializeField] private Color32 m_LegendUnableColor;
|
||||
[SerializeField] private Color32 m_AxisTextColor;
|
||||
[SerializeField] private Color32 m_AxisLineColor;
|
||||
[SerializeField] private Color32 m_AxisSplitLineColor;
|
||||
[SerializeField] private Color32 m_TooltipBackgroundColor;
|
||||
[SerializeField] private Color32 m_TooltipFlagAreaColor;
|
||||
[SerializeField] private Color32 m_TooltipTextColor;
|
||||
[SerializeField] private Color32 m_TooltipLabelColor;
|
||||
[SerializeField] private Color32 m_TooltipLineColor;
|
||||
[SerializeField] private Color32 m_DataZoomTextColor;
|
||||
[SerializeField] private Color32 m_DataZoomLineColor;
|
||||
[SerializeField] private Color32 m_DataZoomSelectedColor;
|
||||
[SerializeField] private Color32 m_VisualMapBackgroundColor;
|
||||
[SerializeField] private Color32 m_VisualMapBorderColor;
|
||||
[SerializeField] private Color32[] m_ColorPalette;
|
||||
|
||||
[SerializeField] private Font m_CustomFont;
|
||||
[SerializeField] private Color32 m_CustomBackgroundColor;
|
||||
[FormerlySerializedAs("m_CustomTextColor")]
|
||||
[SerializeField] private Color32 m_CustomTitleTextColor;
|
||||
[SerializeField] private Color32 m_CustomTitleSubTextColor;
|
||||
[SerializeField] private Color32 m_CustomLegendTextColor;
|
||||
[SerializeField] private Color32 m_CustomLegendUnableColor;
|
||||
[SerializeField] private Color32 m_CustomAxisTextColor;
|
||||
[SerializeField] private Color32 m_CustomAxisLineColor;
|
||||
[SerializeField] private Color32 m_CustomAxisSplitLineColor;
|
||||
[SerializeField] private Color32 m_CustomTooltipBackgroundColor;
|
||||
[SerializeField] private Color32 m_CustomTooltipFlagAreaColor;
|
||||
[SerializeField] private Color32 m_CustomTooltipTextColor;
|
||||
[SerializeField] private Color32 m_CustomTooltipLabelColor;
|
||||
[SerializeField] private Color32 m_CustomTooltipLineColor;
|
||||
[SerializeField] private Color32 m_CustomDataZoomTextColor;
|
||||
[SerializeField] private Color32 m_CustomDataZoomLineColor;
|
||||
[SerializeField] private Color32 m_CustomDataZoomSelectedColor;
|
||||
[SerializeField] private Color32 m_CustomVisualMapBackgroundColor;
|
||||
[SerializeField] private Color32 m_CustomVisualMapBorderColor;
|
||||
[SerializeField] private List<Color32> m_CustomColorPalette = new List<Color32>(13);
|
||||
/// <summary>
|
||||
/// the theme of chart.
|
||||
/// 主题类型。
|
||||
/// </summary>
|
||||
public Theme theme
|
||||
{
|
||||
get { return m_Theme; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Theme, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the font of chart text。
|
||||
/// 字体。
|
||||
/// </summary>
|
||||
public Font font
|
||||
{
|
||||
get { return m_CustomFont != null ? m_CustomFont : m_Font; }
|
||||
set { if (PropertyUtility.SetClass(ref m_CustomFont, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the background color of chart.
|
||||
/// 背景颜色。
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomBackgroundColor) ? m_CustomBackgroundColor : m_BackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomBackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the main title text color.
|
||||
/// 主标题颜色。
|
||||
/// </summary>
|
||||
public Color32 titleTextColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTitleTextColor) ? m_CustomTitleTextColor : m_TitleTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTitleTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the subtitie text color.
|
||||
/// 副标题颜色。
|
||||
/// </summary>
|
||||
public Color32 titleSubTextColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTitleSubTextColor) ? m_CustomTitleSubTextColor : m_TitleSubTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTitleSubTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the legend text color.
|
||||
/// 图例文字的颜色。
|
||||
/// </summary>
|
||||
public Color32 legendTextColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomLegendTextColor) ? m_CustomLegendTextColor : m_LegendTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomLegendTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the legend unable text color.
|
||||
/// 图例变为不可用时的按钮颜色。
|
||||
/// </summary>
|
||||
public Color32 legendUnableColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomLegendUnableColor) ? m_CustomLegendUnableColor : m_LegendUnableColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomLegendUnableColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the axis text color.
|
||||
/// 坐标轴上标签的颜色。
|
||||
/// </summary>
|
||||
public Color32 axisTextColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomAxisTextColor) ? m_CustomAxisTextColor : m_AxisTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomAxisTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of axis line.
|
||||
/// 坐标轴轴线的颜色。
|
||||
/// </summary>
|
||||
public Color32 axisLineColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomAxisLineColor) ? m_CustomAxisLineColor : m_AxisLineColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomAxisLineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of axis split line.
|
||||
/// 分割线的颜色,默认和坐标轴轴线颜色一致。
|
||||
/// </summary>
|
||||
public Color32 axisSplitLineColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomAxisSplitLineColor) ? m_CustomAxisSplitLineColor : m_AxisSplitLineColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomAxisSplitLineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the tooltip background color.
|
||||
/// 提示框背景颜色。
|
||||
/// </summary>
|
||||
public Color32 tooltipBackgroundColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTooltipBackgroundColor) ? m_CustomTooltipBackgroundColor : m_TooltipBackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTooltipBackgroundColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of tooltip shadow crosshair indicator.
|
||||
/// 提示框阴影指示器的颜色。
|
||||
/// </summary>
|
||||
public Color32 tooltipFlagAreaColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTooltipFlagAreaColor) ? m_CustomTooltipFlagAreaColor : m_TooltipFlagAreaColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTooltipFlagAreaColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of tooltip text.
|
||||
/// 提示框文字颜色。
|
||||
/// </summary>
|
||||
public Color32 tooltipTextColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTooltipTextColor) ? m_CustomTooltipTextColor : m_TooltipTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTooltipTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the background color of tooltip cross indicator's axis label.
|
||||
/// 提示框的十字指示器坐标轴标签的背景颜色。
|
||||
/// </summary>
|
||||
public Color32 tooltipLabelColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTooltipLabelColor) ? m_CustomTooltipLabelColor : m_TooltipLabelColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLabelColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color tooltip indicator line.
|
||||
/// 提示框的指示线的颜色。
|
||||
/// </summary>
|
||||
public Color32 tooltipLineColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomTooltipLineColor) ? m_CustomTooltipLineColor : m_TooltipLineColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomTooltipLineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of datazoom text.
|
||||
/// 区域缩放的文字颜色。
|
||||
/// </summary>
|
||||
public Color32 dataZoomTextColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomDataZoomTextColor) ? m_CustomDataZoomTextColor : m_DataZoomTextColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of datazoom line.
|
||||
/// 区域缩放的线条颜色。
|
||||
/// </summary>
|
||||
public Color32 dataZoomLineColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomDataZoomLineColor) ? m_CustomDataZoomLineColor : m_DataZoomLineColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomLineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of datazoom selected area.
|
||||
/// 区域缩放的选中区域颜色。
|
||||
/// </summary>
|
||||
public Color32 dataZoomSelectedColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomDataZoomSelectedColor) ? m_CustomDataZoomSelectedColor : m_DataZoomSelectedColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomDataZoomSelectedColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 视觉映射组件的背景色。
|
||||
/// </summary>
|
||||
public Color32 visualMapBackgroundColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomVisualMapBackgroundColor) ? m_CustomVisualMapBackgroundColor : m_VisualMapBackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomVisualMapBackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 视觉映射的边框色。
|
||||
/// </summary>
|
||||
public Color32 visualMapBorderColor
|
||||
{
|
||||
get { return !ChartHelper.IsClearColor(m_CustomVisualMapBorderColor) ? m_CustomVisualMapBorderColor : m_VisualMapBorderColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CustomVisualMapBorderColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The color list of palette. If no color is set in series, the colors would be adopted sequentially and circularly from this list as the colors of series.
|
||||
/// 调色盘颜色列表。如果系列没有设置颜色,则会依次循环从该列表中取颜色作为系列颜色。
|
||||
/// </summary>
|
||||
public List<Color32> colorPalette { set { m_CustomColorPalette = value; SetVerticesDirty(); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color of the specified index from the palette.
|
||||
/// 获得调色盘对应系列索引的颜色值。
|
||||
/// </summary>
|
||||
/// <param name="index">编号索引</param>
|
||||
/// <returns>the color,or Color.clear when failed.颜色值,失败时返回Color.clear</returns>
|
||||
public Color32 GetColor(int index)
|
||||
{
|
||||
if (index < 0) index = 0;
|
||||
if (m_CustomColorPalette.Count > 0)
|
||||
{
|
||||
var customIndex = index < m_CustomColorPalette.Count ? index : index % m_CustomColorPalette.Count;
|
||||
if (customIndex < m_CustomColorPalette.Count
|
||||
&& !ChartHelper.IsClearColor(m_CustomColorPalette[customIndex]))
|
||||
{
|
||||
return m_CustomColorPalette[customIndex];
|
||||
}
|
||||
}
|
||||
var newIndex = index < m_ColorPalette.Length ? index : index % m_ColorPalette.Length;
|
||||
if (newIndex < m_ColorPalette.Length)
|
||||
return m_ColorPalette[newIndex];
|
||||
else return Color.clear;
|
||||
}
|
||||
|
||||
public void CheckWarning(StringBuilder sb)
|
||||
{
|
||||
if (m_Font == null && m_CustomFont == null)
|
||||
{
|
||||
sb.AppendFormat("warning:theme->font is null\n");
|
||||
}
|
||||
if (m_ColorPalette.Length == 0 && m_CustomColorPalette.Count == 0)
|
||||
{
|
||||
sb.AppendFormat("warning:theme->colorPalette is empty\n");
|
||||
}
|
||||
for (int i = 0; i < m_ColorPalette.Length; i++)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(m_ColorPalette[i]) && m_ColorPalette[i].a == 0)
|
||||
sb.AppendFormat("warning:theme->colorPalette[{0}] alpha = 0\n", i);
|
||||
}
|
||||
for (int i = 0; i < m_CustomColorPalette.Count; i++)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(m_CustomColorPalette[i]) && m_CustomColorPalette[i].a == 0)
|
||||
sb.AppendFormat("warning:theme->colorPalette[{0}] alpha = 0\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<int, string> _colorDic = new Dictionary<int, string>();
|
||||
/// <summary>
|
||||
/// Gets the hexadecimal color string of the specified index from the palette.
|
||||
/// 获得指定索引的十六进制颜色值字符串。
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public string GetColorStr(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
index = index % m_ColorPalette.Length;
|
||||
if (_colorDic.ContainsKey(index)) return _colorDic[index];
|
||||
else
|
||||
{
|
||||
_colorDic[index] = ColorUtility.ToHtmlStringRGBA(GetColor(index));
|
||||
return _colorDic[index];
|
||||
}
|
||||
}
|
||||
|
||||
public void Copy(Theme theme)
|
||||
{
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Dark:
|
||||
Copy(ThemeInfo.Dark);
|
||||
break;
|
||||
case Theme.Default:
|
||||
Copy(ThemeInfo.Default);
|
||||
break;
|
||||
case Theme.Light:
|
||||
Copy(ThemeInfo.Light);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// copy all configurations from theme.
|
||||
/// 复制主题的所有配置。
|
||||
/// </summary>
|
||||
/// <param name="theme"></param>
|
||||
public void Copy(ThemeInfo theme)
|
||||
{
|
||||
m_Theme = theme.theme;
|
||||
m_Font = theme.m_Font;
|
||||
m_BackgroundColor = theme.m_BackgroundColor;
|
||||
m_LegendUnableColor = theme.m_LegendUnableColor;
|
||||
m_TitleTextColor = theme.m_TitleTextColor;
|
||||
m_TitleSubTextColor = theme.m_TitleSubTextColor;
|
||||
m_LegendTextColor = theme.m_LegendTextColor;
|
||||
m_AxisTextColor = theme.m_AxisTextColor;
|
||||
m_AxisLineColor = theme.m_AxisLineColor;
|
||||
m_AxisSplitLineColor = theme.m_AxisSplitLineColor;
|
||||
m_TooltipBackgroundColor = theme.m_TooltipBackgroundColor;
|
||||
m_TooltipTextColor = theme.m_TooltipTextColor;
|
||||
m_TooltipLabelColor = theme.m_TooltipLabelColor;
|
||||
m_TooltipLineColor = theme.m_TooltipLineColor;
|
||||
m_DataZoomLineColor = theme.m_DataZoomLineColor;
|
||||
m_DataZoomSelectedColor = theme.m_DataZoomSelectedColor;
|
||||
m_DataZoomTextColor = theme.m_DataZoomTextColor;
|
||||
m_VisualMapBackgroundColor = theme.m_VisualMapBackgroundColor;
|
||||
m_VisualMapBorderColor = theme.m_VisualMapBorderColor;
|
||||
m_ColorPalette = new Color32[theme.m_ColorPalette.Length];
|
||||
for (int i = 0; i < theme.m_ColorPalette.Length; i++)
|
||||
{
|
||||
m_ColorPalette[i] = theme.m_ColorPalette[i];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all custom configurations.
|
||||
/// 重置,清除所有自定义配置。
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
m_Theme = Theme.Default;
|
||||
m_Font = null;
|
||||
m_BackgroundColor = Color.clear;
|
||||
m_LegendUnableColor = Color.clear;
|
||||
m_TitleTextColor = Color.clear;
|
||||
m_TitleSubTextColor = Color.clear;
|
||||
m_LegendTextColor = Color.clear;
|
||||
m_AxisTextColor = Color.clear;
|
||||
m_AxisLineColor = Color.clear;
|
||||
m_AxisSplitLineColor = Color.clear;
|
||||
m_TooltipBackgroundColor = Color.clear;
|
||||
m_TooltipTextColor = Color.clear;
|
||||
m_TooltipLabelColor = Color.clear;
|
||||
m_TooltipLineColor = Color.clear;
|
||||
m_DataZoomLineColor = Color.clear;
|
||||
m_DataZoomSelectedColor = Color.clear;
|
||||
m_DataZoomTextColor = Color.clear;
|
||||
m_VisualMapBackgroundColor = Color.clear;
|
||||
m_VisualMapBorderColor = Color.clear;
|
||||
for (int i = 0; i < m_CustomColorPalette.Count; i++)
|
||||
{
|
||||
m_CustomColorPalette[i] = Color.clear;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// default theme.
|
||||
/// 默认主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ThemeInfo Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ThemeInfo()
|
||||
{
|
||||
m_Theme = Theme.Default,
|
||||
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
|
||||
m_BackgroundColor = new Color32(255, 255, 255, 255),
|
||||
m_LegendUnableColor = GetColor("#cccccc"),
|
||||
m_TitleTextColor = GetColor("#514D4D"),
|
||||
m_TitleSubTextColor = GetColor("#514D4D"),
|
||||
m_LegendTextColor = GetColor("#514D4D"),
|
||||
m_AxisTextColor = GetColor("#514D4D"),
|
||||
m_AxisLineColor = GetColor("#514D4D"),
|
||||
m_AxisSplitLineColor = GetColor("#51515120"),
|
||||
m_TooltipBackgroundColor = GetColor("#515151C8"),
|
||||
m_TooltipTextColor = GetColor("#FFFFFFFF"),
|
||||
m_TooltipFlagAreaColor = GetColor("#51515120"),
|
||||
m_TooltipLabelColor = GetColor("#292929FF"),
|
||||
m_TooltipLineColor = GetColor("#29292964"),
|
||||
m_DataZoomLineColor = GetColor("#51515120"),
|
||||
m_DataZoomSelectedColor = GetColor("#51515120"),
|
||||
m_DataZoomTextColor = GetColor("#514D4D"),
|
||||
m_VisualMapBackgroundColor = GetColor("#51515120"),
|
||||
m_VisualMapBorderColor = GetColor("#cccccc"),
|
||||
m_ColorPalette = new Color32[]
|
||||
{
|
||||
new Color32(194, 53, 49, 255),
|
||||
new Color32(47, 69, 84, 255),
|
||||
new Color32(97, 160, 168, 255),
|
||||
new Color32(212, 130, 101, 255),
|
||||
new Color32(145, 199, 174, 255),
|
||||
new Color32(116, 159, 131, 255),
|
||||
new Color32(202, 134, 34, 255),
|
||||
new Color32(189, 162, 154, 255),
|
||||
new Color32(110, 112, 116, 255),
|
||||
new Color32(84, 101, 112, 255),
|
||||
new Color32(196, 204, 211, 255)
|
||||
},
|
||||
m_CustomColorPalette = new List<Color32>{
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// light theme.
|
||||
/// 亮主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ThemeInfo Light
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ThemeInfo()
|
||||
{
|
||||
m_Theme = Theme.Light,
|
||||
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
|
||||
m_BackgroundColor = new Color32(255, 255, 255, 255),
|
||||
m_LegendUnableColor = GetColor("#cccccc"),
|
||||
m_TitleTextColor = GetColor("#514D4D"),
|
||||
m_TitleSubTextColor = GetColor("#514D4D"),
|
||||
m_LegendTextColor = GetColor("#514D4D"),
|
||||
m_AxisTextColor = GetColor("#514D4D"),
|
||||
m_AxisLineColor = GetColor("#514D4D"),
|
||||
m_AxisSplitLineColor = GetColor("#51515120"),
|
||||
m_TooltipBackgroundColor = GetColor("#515151C8"),
|
||||
m_TooltipTextColor = GetColor("#FFFFFFFF"),
|
||||
m_TooltipFlagAreaColor = GetColor("#51515120"),
|
||||
m_TooltipLabelColor = GetColor("#292929FF"),
|
||||
m_TooltipLineColor = GetColor("#29292964"),
|
||||
m_DataZoomLineColor = GetColor("#51515120"),
|
||||
m_DataZoomSelectedColor = GetColor("#51515120"),
|
||||
m_DataZoomTextColor = GetColor("#514D4D"),
|
||||
m_VisualMapBackgroundColor = GetColor("#51515120"),
|
||||
m_VisualMapBorderColor = GetColor("#cccccc"),
|
||||
m_ColorPalette = new Color32[]
|
||||
{
|
||||
new Color32(55, 162, 218, 255),
|
||||
new Color32(255, 159, 127, 255),
|
||||
new Color32(50, 197, 233, 255),
|
||||
new Color32(251, 114, 147, 255),
|
||||
new Color32(103, 224, 227, 255),
|
||||
new Color32(224, 98, 174, 255),
|
||||
new Color32(159, 230, 184, 255),
|
||||
new Color32(230, 144, 209, 255),
|
||||
new Color32(255, 219, 92, 255),
|
||||
new Color32(230, 188, 243, 255),
|
||||
new Color32(157, 150, 245, 255),
|
||||
new Color32(131, 120, 234, 255),
|
||||
new Color32(150, 191, 255, 255)
|
||||
},
|
||||
m_CustomColorPalette = new List<Color32>{
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dark theme.
|
||||
/// 暗主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ThemeInfo Dark
|
||||
{
|
||||
get
|
||||
{
|
||||
return new ThemeInfo()
|
||||
{
|
||||
m_Theme = Theme.Dark,
|
||||
m_Font = Resources.GetBuiltinResource<Font>("Arial.ttf"),
|
||||
m_LegendUnableColor = GetColor("#cccccc"),
|
||||
m_BackgroundColor = new Color32(34, 34, 34, 255),
|
||||
m_TitleTextColor = GetColor("#eee"),
|
||||
m_TitleSubTextColor = GetColor("#eee"),
|
||||
m_LegendTextColor = GetColor("#eee"),
|
||||
m_AxisTextColor = GetColor("#eee"),
|
||||
m_AxisLineColor = GetColor("#eee"),
|
||||
m_AxisSplitLineColor = GetColor("#aaa"),
|
||||
m_TooltipBackgroundColor = GetColor("#515151C8"),
|
||||
m_TooltipTextColor = GetColor("#FFFFFFFF"),
|
||||
m_TooltipFlagAreaColor = GetColor("#51515120"),
|
||||
m_TooltipLabelColor = GetColor("#A7A7A7FF"),
|
||||
m_TooltipLineColor = GetColor("#eee"),
|
||||
m_DataZoomLineColor = GetColor("#FFFFFF45"),
|
||||
m_DataZoomSelectedColor = GetColor("#D0D0D03D"),
|
||||
m_DataZoomTextColor = GetColor("#FFFFFFFF"),
|
||||
m_VisualMapBackgroundColor = GetColor("#aaa"),
|
||||
m_VisualMapBorderColor = GetColor("#cccccc"),
|
||||
m_ColorPalette = new Color32[]
|
||||
{
|
||||
new Color32(221, 107, 102, 255),
|
||||
new Color32(117, 154, 160, 255),
|
||||
new Color32(230, 157, 135, 255),
|
||||
new Color32(141, 193, 169, 255),
|
||||
new Color32(234, 126, 83, 255),
|
||||
new Color32(238, 221, 120, 255),
|
||||
new Color32(115, 163, 115, 255),
|
||||
new Color32(115, 185, 188, 255),
|
||||
new Color32(114, 137, 171, 255),
|
||||
new Color32(145, 202, 140, 255),
|
||||
new Color32(244, 159, 66, 255)
|
||||
},
|
||||
m_CustomColorPalette = new List<Color32>{
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear,
|
||||
Color.clear
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert the html string to color.
|
||||
/// 将字符串颜色值转成Color。
|
||||
/// </summary>
|
||||
/// <param name="hexColorStr"></param>
|
||||
/// <returns></returns>
|
||||
public static Color32 GetColor(string hexColorStr)
|
||||
{
|
||||
Color color;
|
||||
ColorUtility.TryParseHtmlString(hexColorStr, out color);
|
||||
return (Color32)color;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
@@ -19,9 +19,9 @@ namespace XCharts
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private string m_Text;
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle(16);
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
[SerializeField] private string m_SubText;
|
||||
[SerializeField] private TextStyle m_SubTextStyle = new TextStyle(14);
|
||||
[SerializeField] private TextStyle m_SubTextStyle = new TextStyle();
|
||||
[SerializeField] private float m_ItemGap = 8;
|
||||
[SerializeField] private Location m_Location = Location.defaultTop;
|
||||
|
||||
@@ -30,19 +30,12 @@ namespace XCharts
|
||||
/// Set this to false to prevent the title from showing.
|
||||
/// 是否显示标题组件。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||
public bool show { get { return m_Show; } set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The main title text, supporting \n for newlines.
|
||||
/// 主标题文本,支持使用 \n 换行。
|
||||
/// </summary>
|
||||
public string text { get { return m_Text; } set { if (PropertyUtility.SetClass(ref m_Text, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// [default:16]
|
||||
/// main title font size.
|
||||
/// 主标题文字的字体大小。
|
||||
/// </summary>
|
||||
[Obsolete("use textStyle instead.", true)]
|
||||
public int textFontSize { get { return m_TextStyle.fontSize; } set { m_TextStyle.fontSize = value; } }
|
||||
public string text { get { return m_Text; } set { if (PropertyUtil.SetClass(ref m_Text, value)) SetComponentDirty(); } }
|
||||
/// <summary>
|
||||
/// The text style of main title.
|
||||
/// 主标题文本样式。
|
||||
@@ -50,7 +43,7 @@ namespace XCharts
|
||||
public TextStyle textStyle
|
||||
{
|
||||
get { return m_TextStyle; }
|
||||
set { if (PropertyUtility.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Subtitle text, supporting for \n for newlines.
|
||||
@@ -59,7 +52,7 @@ namespace XCharts
|
||||
public string subText
|
||||
{
|
||||
get { return m_SubText; }
|
||||
set { if (PropertyUtility.SetClass(ref m_SubText, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_SubText, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The text style of sub title.
|
||||
@@ -68,18 +61,7 @@ namespace XCharts
|
||||
public TextStyle subTextStyle
|
||||
{
|
||||
get { return m_SubTextStyle; }
|
||||
set { if (PropertyUtility.SetClass(ref m_SubTextStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// [default:14]
|
||||
/// subtitle font size.
|
||||
/// 副标题文字的字体大小。
|
||||
/// </summary>
|
||||
[Obsolete("use subTextStyle instead.", true)]
|
||||
public int subTextFontSize
|
||||
{
|
||||
get { return m_SubTextStyle.fontSize; }
|
||||
set { m_SubTextStyle.fontSize = value; }
|
||||
set { if (PropertyUtil.SetClass(ref m_SubTextStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// [default:8]
|
||||
@@ -89,7 +71,7 @@ namespace XCharts
|
||||
public float itemGap
|
||||
{
|
||||
get { return m_ItemGap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemGap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The location of title component.
|
||||
@@ -98,9 +80,11 @@ namespace XCharts
|
||||
public Location location
|
||||
{
|
||||
get { return m_Location; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Location, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public int index { get; internal set; }
|
||||
|
||||
public override bool vertsDirty { get { return false; } }
|
||||
public override bool componentDirty
|
||||
{
|
||||
@@ -123,10 +107,10 @@ namespace XCharts
|
||||
{
|
||||
m_Show = true,
|
||||
m_Text = "Chart Title",
|
||||
m_TextStyle = new TextStyle(16),
|
||||
m_TextStyle = new TextStyle(),
|
||||
m_SubText = "",
|
||||
m_SubTextStyle = new TextStyle(14),
|
||||
m_ItemGap = 8,
|
||||
m_SubTextStyle = new TextStyle(),
|
||||
m_ItemGap = 0,
|
||||
m_Location = Location.defaultTop
|
||||
};
|
||||
return title;
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
using System.Linq;
|
||||
using System.Collections.ObjectModel;
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -66,12 +64,12 @@ namespace XCharts
|
||||
[SerializeField] private bool m_AlwayShow = false;
|
||||
[SerializeField] private Vector2 m_Offset = new Vector2(18f, -25f);
|
||||
[SerializeField] private Sprite m_BackgroundImage;
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18, FontStyle.Normal);
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.Solid, 0.7f);
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle(LineStyle.Type.None);
|
||||
|
||||
private GameObject m_GameObject;
|
||||
private GameObject m_Content;
|
||||
private Text m_ContentText;
|
||||
private ChartText m_ContentText;
|
||||
private Image m_ContentImage;
|
||||
private RectTransform m_ContentRect;
|
||||
private RectTransform m_ContentTextRect;
|
||||
@@ -84,7 +82,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) { SetAllDirty(); SetActive(value); } }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) { SetAllDirty(); SetActive(value); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Indicator type.
|
||||
@@ -93,7 +91,7 @@ namespace XCharts
|
||||
public Type type
|
||||
{
|
||||
get { return m_Type; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// A string template formatter for the total content of the prompt box. Support for wrapping lines with \n.
|
||||
@@ -161,10 +159,6 @@ namespace XCharts
|
||||
/// 最小高度。如若 fixedHeight 设有值,优先取 fixedHeight。
|
||||
/// </summary>
|
||||
public float minHeight { get { return m_MinHeight; } set { m_MinHeight = value; } }
|
||||
[Obsolete("Use Tooltip.textStyle.fontSize instead.", true)]
|
||||
public int fontSize { get; set; }
|
||||
[Obsolete("Use Tooltip.textStyle.fontStyle instead.", true)]
|
||||
public FontStyle fontStyle { get; set; }
|
||||
/// <summary>
|
||||
/// 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,
|
||||
@@ -178,7 +172,7 @@ namespace XCharts
|
||||
public string numericFormatter
|
||||
{
|
||||
get { return m_NumericFormatter; }
|
||||
set { if (PropertyUtility.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the text padding of left and right. defaut:5.
|
||||
@@ -291,6 +285,11 @@ namespace XCharts
|
||||
/// 当前指示的角度。
|
||||
/// </summary>
|
||||
public float runtimeAngle { get; internal set; }
|
||||
/// <summary>
|
||||
/// 当前指示的Grid索引。
|
||||
/// </summary>
|
||||
public int runtimeGridIndex { get; internal set; }
|
||||
public int runtimePolarIndex { get; internal set; }
|
||||
|
||||
public static Tooltip defaultTooltip
|
||||
{
|
||||
@@ -329,7 +328,7 @@ namespace XCharts
|
||||
m_ContentRect = m_Content.GetComponent<RectTransform>();
|
||||
m_ContentImage = m_Content.GetComponent<Image>();
|
||||
m_ContentImage.raycastTarget = false;
|
||||
m_ContentText = m_Content.GetComponentInChildren<Text>();
|
||||
m_ContentText = new ChartText(m_Content);
|
||||
if (m_ContentText != null)
|
||||
{
|
||||
m_ContentTextRect = m_ContentText.gameObject.GetComponentInChildren<RectTransform>();
|
||||
@@ -343,6 +342,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public void UpdateToTop()
|
||||
{
|
||||
if (m_GameObject == null) return;
|
||||
int count = m_GameObject.transform.parent.childCount;
|
||||
m_GameObject.GetComponent<RectTransform>().SetSiblingIndex(count - 1);
|
||||
}
|
||||
@@ -376,9 +376,9 @@ namespace XCharts
|
||||
/// <param name="color"></param>
|
||||
public void SetContentTextColor(Color color)
|
||||
{
|
||||
if (m_ContentText)
|
||||
if (m_ContentText != null)
|
||||
{
|
||||
m_ContentText.color = color;
|
||||
m_ContentText.SetColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,16 +388,16 @@ namespace XCharts
|
||||
/// <param name="txt"></param>
|
||||
public void UpdateContentText(string txt)
|
||||
{
|
||||
if (m_ContentText)
|
||||
if (m_ContentText != null)
|
||||
{
|
||||
m_ContentText.text = txt;
|
||||
m_ContentText.SetText(txt);
|
||||
float wid, hig;
|
||||
if (m_FixedWidth > 0) wid = m_FixedWidth;
|
||||
else if (m_MinWidth > 0 && m_ContentText.preferredWidth < m_MinWidth) wid = m_MinWidth;
|
||||
else wid = m_ContentText.preferredWidth + m_PaddingLeftRight * 2;
|
||||
else if (m_MinWidth > 0 && m_ContentText.GetPreferredWidth() < m_MinWidth) wid = m_MinWidth;
|
||||
else wid = m_ContentText.GetPreferredWidth() + m_PaddingLeftRight * 2;
|
||||
if (m_FixedHeight > 0) hig = m_FixedHeight;
|
||||
else if (m_MinHeight > 0 && m_ContentText.preferredHeight < m_MinHeight) hig = m_MinHeight;
|
||||
else hig = m_ContentText.preferredHeight + m_PaddingTopBottom * 2;
|
||||
else if (m_MinHeight > 0 && m_ContentText.GetPreferredHeight() < m_MinHeight) hig = m_MinHeight;
|
||||
else hig = m_ContentText.GetPreferredHeight() + m_PaddingTopBottom * 2;
|
||||
if (m_ContentRect != null) m_ContentRect.sizeDelta = new Vector2(wid, hig);
|
||||
if (m_ContentTextRect != null)
|
||||
{
|
||||
@@ -476,7 +476,8 @@ namespace XCharts
|
||||
internal void UpdateLastDataIndex()
|
||||
{
|
||||
lastDataIndex[0] = runtimeDataIndex[0];
|
||||
lastDataIndex[1] = runtimeDataIndex[1];
|
||||
if (runtimeDataIndex.Count > 1)
|
||||
lastDataIndex[1] = runtimeDataIndex[1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -485,7 +486,9 @@ namespace XCharts
|
||||
/// <returns></returns>
|
||||
public bool IsSelected()
|
||||
{
|
||||
return runtimeDataIndex[0] >= 0 || runtimeDataIndex[1] >= 0;
|
||||
foreach (var index in runtimeDataIndex)
|
||||
if (index >= 0) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -495,7 +498,9 @@ namespace XCharts
|
||||
/// <returns></returns>
|
||||
public bool IsSelected(int index)
|
||||
{
|
||||
return runtimeDataIndex[0] == index || runtimeDataIndex[1] == index;
|
||||
foreach (var temp in runtimeDataIndex)
|
||||
if (temp == index) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void ClearSerieDataIndex()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -62,7 +62,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The shape of vessel.
|
||||
@@ -72,7 +72,7 @@ namespace XCharts
|
||||
public Shape shape
|
||||
{
|
||||
get { return m_Shape; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Shape, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Shape, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Thickness of vessel.
|
||||
@@ -82,7 +82,7 @@ namespace XCharts
|
||||
public float shapeWidth
|
||||
{
|
||||
get { return m_ShapeWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ShapeWidth, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShapeWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The gap between the vessel and the liquid.
|
||||
@@ -92,7 +92,7 @@ namespace XCharts
|
||||
public float gap
|
||||
{
|
||||
get { return m_Gap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The center of vesselß. The center[0] is the x-coordinate, and the center[1] is the y-coordinate.
|
||||
@@ -115,7 +115,7 @@ namespace XCharts
|
||||
public float radius
|
||||
{
|
||||
get { return m_Radius; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Radius, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Radius, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The smoothness of wave.
|
||||
@@ -125,7 +125,7 @@ namespace XCharts
|
||||
public float smoothness
|
||||
{
|
||||
get { return m_Smoothness; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Smoothness, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Smoothness, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Background color of polar, which is transparent by default.
|
||||
@@ -135,7 +135,7 @@ namespace XCharts
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Vessel color. The default is consistent with Serie.
|
||||
@@ -144,7 +144,7 @@ namespace XCharts
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether automatic color. If true, the color matches serie.
|
||||
@@ -154,7 +154,7 @@ namespace XCharts
|
||||
public bool autoColor
|
||||
{
|
||||
get { return m_AutoColor; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_AutoColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public int index { get; internal set; }
|
||||
/// <summary>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -101,7 +101,7 @@ namespace XCharts
|
||||
public bool enable
|
||||
{
|
||||
get { return m_Enable; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Enable, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to display components. If set to false, it will not show up, but the data mapping function still exists.
|
||||
@@ -113,7 +113,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of visualmap component.
|
||||
@@ -122,7 +122,7 @@ namespace XCharts
|
||||
public Type type
|
||||
{
|
||||
get { return m_Type; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 映射方向。
|
||||
@@ -130,7 +130,7 @@ namespace XCharts
|
||||
public Direction direction
|
||||
{
|
||||
get { return m_Direction; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Direction, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Direction, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the selected mode for Piecewise visualMap.
|
||||
@@ -139,7 +139,7 @@ namespace XCharts
|
||||
public SelectedMode selectedMode
|
||||
{
|
||||
get { return m_SelectedMode; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SelectedMode, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SelectedMode, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The minimum allowed. 'min' must be user specified. [visualmap.min, visualmap.max] forms the "domain" of the visualMap.
|
||||
@@ -149,7 +149,7 @@ namespace XCharts
|
||||
public float min
|
||||
{
|
||||
get { return m_Min; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Min, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The maximum allowed. 'max' must be user specified. [visualmap.min, visualmap.max] forms the "domain" of the visualMap.
|
||||
@@ -187,7 +187,7 @@ namespace XCharts
|
||||
public int splitNumber
|
||||
{
|
||||
get { return m_SplitNumber; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SplitNumber, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SplitNumber, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether the handle used for dragging is displayed (the handle can be dragged to adjust the selected range).
|
||||
@@ -197,7 +197,7 @@ namespace XCharts
|
||||
public bool calculable
|
||||
{
|
||||
get { return m_Calculable; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Calculable, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Calculable, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to update in real time while dragging.
|
||||
@@ -207,7 +207,7 @@ namespace XCharts
|
||||
public bool realtime
|
||||
{
|
||||
get { return m_Realtime; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Realtime, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Realtime, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The width of the figure, that is, the width of the color bar.
|
||||
@@ -217,7 +217,7 @@ namespace XCharts
|
||||
public float itemWidth
|
||||
{
|
||||
get { return m_ItemWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ItemWidth, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The height of the figure, that is, the height of the color bar.
|
||||
@@ -227,7 +227,7 @@ namespace XCharts
|
||||
public float itemHeight
|
||||
{
|
||||
get { return m_ItemHeight; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ItemHeight, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ItemHeight, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Border line width.
|
||||
@@ -237,7 +237,7 @@ namespace XCharts
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Specifies "which dimension" of the data to map to the visual element. "Data" is series.data.
|
||||
@@ -248,7 +248,7 @@ namespace XCharts
|
||||
public int dimension
|
||||
{
|
||||
get { return m_Dimension; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Dimension, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Dimension, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// When the hoverLink function is turned on, when the mouse hovers over the visualMap component,
|
||||
@@ -263,7 +263,7 @@ namespace XCharts
|
||||
public bool hoverLink
|
||||
{
|
||||
get { return m_HoverLink; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_HoverLink, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_HoverLink, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Automatically set min, Max value
|
||||
@@ -272,7 +272,7 @@ namespace XCharts
|
||||
public bool autoMinMax
|
||||
{
|
||||
get { return m_AutoMinMax; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_AutoMinMax, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoMinMax, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Specify whether the layout of component is horizontal or vertical.
|
||||
@@ -282,7 +282,7 @@ namespace XCharts
|
||||
public Orient orient
|
||||
{
|
||||
get { return m_Orient; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Orient, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Orient, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The location of component.
|
||||
@@ -291,7 +291,7 @@ namespace XCharts
|
||||
public Location location
|
||||
{
|
||||
get { return m_Location; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Location, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Location, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Defines the visual color in the selected range.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -38,7 +38,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the left side of the container.
|
||||
@@ -47,7 +47,7 @@ namespace XCharts
|
||||
public float left
|
||||
{
|
||||
get { return m_Left; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Left, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Left, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the right side of the container.
|
||||
@@ -56,7 +56,7 @@ namespace XCharts
|
||||
public float right
|
||||
{
|
||||
get { return m_Right; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Right, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Right, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the top side of the container.
|
||||
@@ -65,7 +65,7 @@ namespace XCharts
|
||||
public float top
|
||||
{
|
||||
get { return m_Top; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Top, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Top, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between grid component and the bottom side of the container.
|
||||
@@ -74,7 +74,7 @@ namespace XCharts
|
||||
public float bottom
|
||||
{
|
||||
get { return m_Bottom; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Background color of grid, which is transparent by default.
|
||||
@@ -83,7 +83,24 @@ namespace XCharts
|
||||
public Color backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public int index { get; internal set; }
|
||||
public float runtimeX { get; private set; }
|
||||
public float runtimeY { get; private set; }
|
||||
public float runtimeWidth { get; private set; }
|
||||
public float runtimeHeight { get; private set; }
|
||||
|
||||
internal void UpdateRuntimeData(float chartX, float chartY, float chartWidth, float chartHeight)
|
||||
{
|
||||
var runtimeLeft = left <= 1 ? left * chartWidth : left;
|
||||
var runtimeBottom = bottom <= 1 ? bottom * chartHeight : bottom;
|
||||
var runtimeTop = top <= 1 ? top * chartHeight : top;
|
||||
var runtimeRight = right <= 1 ? right * chartWidth : right;
|
||||
runtimeX = chartX + runtimeLeft;
|
||||
runtimeY = chartY + runtimeBottom;
|
||||
runtimeWidth = chartWidth - runtimeLeft - runtimeRight;
|
||||
runtimeHeight = chartHeight - runtimeTop - runtimeBottom;
|
||||
}
|
||||
|
||||
public static Grid defaultGrid
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class MainComponent : ChartComponent
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
@@ -55,7 +55,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the origin of area.
|
||||
@@ -64,7 +64,7 @@ namespace XCharts
|
||||
public AreaOrigin origin
|
||||
{
|
||||
get { return m_Origin; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Origin, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Origin, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of area,default use serie color.
|
||||
@@ -73,7 +73,7 @@ namespace XCharts
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gradient color, start color to toColor.
|
||||
@@ -82,7 +82,7 @@ namespace XCharts
|
||||
public Color32 toColor
|
||||
{
|
||||
get { return m_ToColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Opacity of the component. Supports value from 0 to 1, and the component will not be drawn when set to 0.
|
||||
@@ -91,7 +91,7 @@ namespace XCharts
|
||||
public float opacity
|
||||
{
|
||||
get { return m_Opacity; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 鼠标悬浮时是否高亮之前的区域
|
||||
@@ -99,7 +99,7 @@ namespace XCharts
|
||||
public bool tooltipHighlight
|
||||
{
|
||||
get { return m_TooltipHighlight; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_TooltipHighlight, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TooltipHighlight, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of area,default use serie color.
|
||||
@@ -108,7 +108,7 @@ namespace XCharts
|
||||
public Color32 highlightColor
|
||||
{
|
||||
get { return m_HighlightColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_HighlightColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_HighlightColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gradient color, start highlightColor to highlightToColor.
|
||||
@@ -117,7 +117,7 @@ namespace XCharts
|
||||
public Color32 highlightToColor
|
||||
{
|
||||
get { return m_HighlightToColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_HighlightToColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_HighlightToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public static AreaStyle defaultAreaStyle
|
||||
@@ -129,10 +129,32 @@ namespace XCharts
|
||||
m_Show = false,
|
||||
m_Color = Color.clear,
|
||||
m_ToColor = Color.clear,
|
||||
m_Opacity = 1
|
||||
m_Opacity = 0.6f
|
||||
};
|
||||
return area;
|
||||
}
|
||||
}
|
||||
|
||||
public Color32 GetColor()
|
||||
{
|
||||
if (m_Opacity == 1) return m_Color;
|
||||
var color = m_Color;
|
||||
color.a = (byte)(color.a * m_Opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 themeColor)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(color))
|
||||
{
|
||||
return GetColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
var color = themeColor;
|
||||
color.a = (byte)(color.a * opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
97
Runtime/Component/Sub/Arrow.cs
Normal file
97
Runtime/Component/Sub/Arrow.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Arrow : SubComponent
|
||||
{
|
||||
[SerializeField] private float m_Width = 10;
|
||||
[SerializeField] private float m_Height = 15;
|
||||
[SerializeField] private float m_Offset = 0;
|
||||
[SerializeField] private float m_Dent = 3;
|
||||
[SerializeField] private Color32 m_Color = Color.clear;
|
||||
|
||||
/// <summary>
|
||||
/// The widht of arrow.
|
||||
/// 箭头宽。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The height of arrow.
|
||||
/// 箭头高。
|
||||
/// </summary>
|
||||
public float height
|
||||
{
|
||||
get { return m_Height; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The offset of arrow.
|
||||
/// 箭头偏移。
|
||||
/// </summary>
|
||||
public float offset
|
||||
{
|
||||
get { return m_Offset; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The dent of arrow.
|
||||
/// 箭头的凹度。
|
||||
/// </summary>
|
||||
public float dent
|
||||
{
|
||||
get { return m_Dent; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Dent, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the color of arrow.
|
||||
/// 箭头颜色。
|
||||
/// </summary>
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public Arrow Clone()
|
||||
{
|
||||
var arrow = new Arrow();
|
||||
arrow.width = width;
|
||||
arrow.height = height;
|
||||
arrow.offset = offset;
|
||||
arrow.dent = dent;
|
||||
arrow.color = color;
|
||||
return arrow;
|
||||
}
|
||||
|
||||
public void Copy(Arrow arrow)
|
||||
{
|
||||
width = arrow.width;
|
||||
height = arrow.height;
|
||||
offset = arrow.offset;
|
||||
dent = arrow.dent;
|
||||
color = arrow.color;
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 defaultColor)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(color)) return defaultColor;
|
||||
else return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0b05891df2284bc588cf6b668bfeb7b
|
||||
guid: bf0a2263a511d4348a256df8e732bb1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -22,15 +22,12 @@ namespace XCharts
|
||||
[SerializeField] private string m_Formatter;
|
||||
[SerializeField] private int m_Interval = 0;
|
||||
[SerializeField] private bool m_Inside = false;
|
||||
[SerializeField] private float m_Rotate;
|
||||
[SerializeField] private float m_Margin;
|
||||
[SerializeField] private Color m_Color;
|
||||
[SerializeField] private int m_FontSize;
|
||||
[SerializeField] private FontStyle m_FontStyle;
|
||||
[SerializeField] private string m_NumericFormatter = "";
|
||||
[SerializeField] private bool m_ShowAsPositiveNumber = false;
|
||||
[SerializeField] private bool m_OnZero = false;
|
||||
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis label from appearing.
|
||||
@@ -39,7 +36,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The display interval of the axis label.
|
||||
@@ -48,7 +45,7 @@ namespace XCharts
|
||||
public int interval
|
||||
{
|
||||
get { return m_Interval; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Set this to true so the axis labels face the inside direction.
|
||||
@@ -57,16 +54,7 @@ namespace XCharts
|
||||
public bool inside
|
||||
{
|
||||
get { return m_Inside; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Inside, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Rotation degree of axis label, which is especially useful when there is no enough space for category axis.
|
||||
/// 刻度标签旋转的角度,在类目轴的类目标签显示不下的时候可以通过旋转防止标签之间重叠。
|
||||
/// </summary>
|
||||
public float rotate
|
||||
{
|
||||
get { return m_Rotate; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Inside, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The margin between the axis label and the axis line.
|
||||
@@ -75,34 +63,7 @@ namespace XCharts
|
||||
public float margin
|
||||
{
|
||||
get { return m_Margin; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Margin, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of axis label text.
|
||||
/// 刻度标签文字的颜色,默认取Theme的axisTextColor。
|
||||
/// </summary>
|
||||
public Color color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font size.
|
||||
/// 文字的字体大小。
|
||||
/// </summary>
|
||||
public int fontSize
|
||||
{
|
||||
get { return m_FontSize; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font style.
|
||||
/// 文字字体的风格。
|
||||
/// </summary>
|
||||
public FontStyle fontStyle
|
||||
{
|
||||
get { return m_FontStyle; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Margin, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图例内容字符串模版格式器。支持用 \n 换行。
|
||||
@@ -111,7 +72,7 @@ namespace XCharts
|
||||
public string formatter
|
||||
{
|
||||
get { return m_Formatter; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -124,7 +85,7 @@ namespace XCharts
|
||||
public string numericFormatter
|
||||
{
|
||||
get { return m_NumericFormatter; }
|
||||
set { if (PropertyUtility.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -134,7 +95,7 @@ namespace XCharts
|
||||
public bool showAsPositiveNumber
|
||||
{
|
||||
get { return m_ShowAsPositiveNumber; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -143,7 +104,7 @@ namespace XCharts
|
||||
public bool onZero
|
||||
{
|
||||
get { return m_OnZero; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_OnZero, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_OnZero, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -155,6 +116,16 @@ namespace XCharts
|
||||
set { if (value != null) { m_TextLimit = value; SetComponentDirty(); } }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The text style of axis name.
|
||||
/// 文本样式。
|
||||
/// </summary>
|
||||
public TextStyle textStyle
|
||||
{
|
||||
get { return m_TextStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public override bool componentDirty { get { return m_ComponentDirty || m_TextLimit.componentDirty; } }
|
||||
internal override void ClearComponentDirty()
|
||||
{
|
||||
@@ -171,11 +142,8 @@ namespace XCharts
|
||||
m_Show = true,
|
||||
m_Interval = 0,
|
||||
m_Inside = false,
|
||||
m_Rotate = 0,
|
||||
m_Margin = 8,
|
||||
m_Color = Color.clear,
|
||||
m_FontSize = 18,
|
||||
m_FontStyle = FontStyle.Normal
|
||||
m_TextStyle = new TextStyle(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -187,12 +155,10 @@ namespace XCharts
|
||||
axisLable.formatter = formatter;
|
||||
axisLable.interval = interval;
|
||||
axisLable.inside = inside;
|
||||
axisLable.rotate = rotate;
|
||||
axisLable.margin = margin;
|
||||
axisLable.color = color;
|
||||
axisLable.fontSize = fontSize;
|
||||
axisLable.numericFormatter = numericFormatter;
|
||||
axisLable.textLimit = textLimit.Clone();
|
||||
axisLable.textStyle.Copy(textStyle);
|
||||
return axisLable;
|
||||
}
|
||||
|
||||
@@ -202,15 +168,13 @@ namespace XCharts
|
||||
formatter = axisLable.formatter;
|
||||
interval = axisLable.interval;
|
||||
inside = axisLable.inside;
|
||||
rotate = axisLable.rotate;
|
||||
margin = axisLable.margin;
|
||||
color = axisLable.color;
|
||||
fontSize = axisLable.fontSize;
|
||||
numericFormatter = axisLable.numericFormatter;
|
||||
textLimit.Copy(axisLable.textLimit);
|
||||
textStyle.Copy(axisLable.textStyle);
|
||||
}
|
||||
|
||||
public void SetRelatedText(Text txt, float labelWidth)
|
||||
public void SetRelatedText(ChartText txt, float labelWidth)
|
||||
{
|
||||
m_TextLimit.SetRelatedText(txt, labelWidth);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
@@ -11,29 +11,15 @@ namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings related to axis line.
|
||||
/// 坐标轴的分隔线。
|
||||
/// 坐标轴轴线。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AxisLine : SubComponent
|
||||
public class AxisLine : BaseLine
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private bool m_OnZero;
|
||||
[SerializeField] private float m_Width = 0.6f;
|
||||
[SerializeField] private bool m_Symbol;
|
||||
[SerializeField] private float m_SymbolWidth;
|
||||
[SerializeField] private float m_SymbolHeight;
|
||||
[SerializeField] private float m_SymbolOffset;
|
||||
[SerializeField] private float m_SymbolDent;
|
||||
[SerializeField] private bool m_ShowArrow;
|
||||
[SerializeField] private Arrow m_Arrow = new Arrow();
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis line from showing.
|
||||
/// 是否显示坐标轴轴线。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// When mutiple axes exists, this option can be used to specify which axis can be "onZero" to.
|
||||
/// X 轴或者 Y 轴的轴线是否在另一个轴的 0 刻度上,只有在另一个轴为数值轴且包含 0 刻度时有效。
|
||||
@@ -41,63 +27,26 @@ namespace XCharts
|
||||
public bool onZero
|
||||
{
|
||||
get { return m_OnZero; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_OnZero, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// line style line width.
|
||||
/// 坐标轴线线宽。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_OnZero, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show the arrow symbol of axis.
|
||||
/// 是否显示箭头。
|
||||
/// </summary>
|
||||
public bool symbol
|
||||
public bool showArrow
|
||||
{
|
||||
get { return m_Symbol; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Symbol, value)) SetVerticesDirty(); }
|
||||
get { return m_ShowArrow; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ShowArrow, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of arrow symbol.
|
||||
/// 箭头宽。
|
||||
/// the arrow of line.
|
||||
/// 轴线箭头。
|
||||
/// </summary>
|
||||
public float symbolWidth
|
||||
public Arrow arrow
|
||||
{
|
||||
get { return m_SymbolWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SymbolWidth, value)) SetVerticesDirty(); }
|
||||
get { return m_Arrow; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Arrow, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the height of arrow symbol.
|
||||
/// 箭头高。
|
||||
/// </summary>
|
||||
public float symbolHeight
|
||||
{
|
||||
get { return m_SymbolHeight; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SymbolHeight, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the offset of arrow symbol.
|
||||
/// 箭头偏移。
|
||||
/// </summary>
|
||||
public float symbolOffset
|
||||
{
|
||||
get { return m_SymbolOffset; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SymbolOffset, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the dent of arrow symbol.
|
||||
/// 箭头的凹陷程度。
|
||||
/// </summary>
|
||||
public float symbolDent
|
||||
{
|
||||
get { return m_SymbolDent; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SymbolDent, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public static AxisLine defaultAxisLine
|
||||
{
|
||||
get
|
||||
@@ -106,12 +55,9 @@ namespace XCharts
|
||||
{
|
||||
m_Show = true,
|
||||
m_OnZero = true,
|
||||
m_Width = 0.7f,
|
||||
m_Symbol = false,
|
||||
m_SymbolWidth = 10,
|
||||
m_SymbolHeight = 15,
|
||||
m_SymbolOffset = -5f,
|
||||
m_SymbolDent = 3,
|
||||
m_ShowArrow = false,
|
||||
m_Arrow = new Arrow(),
|
||||
m_LineStyle = new LineStyle(LineStyle.Type.None),
|
||||
};
|
||||
return axisLine;
|
||||
}
|
||||
@@ -122,25 +68,17 @@ namespace XCharts
|
||||
var axisLine = new AxisLine();
|
||||
axisLine.show = show;
|
||||
axisLine.onZero = onZero;
|
||||
axisLine.width = width;
|
||||
axisLine.symbol = symbol;
|
||||
axisLine.symbolWidth = symbolWidth;
|
||||
axisLine.symbolHeight = symbolHeight;
|
||||
axisLine.symbolOffset = symbolOffset;
|
||||
axisLine.symbolDent = symbolDent;
|
||||
axisLine.showArrow = showArrow;
|
||||
axisLine.arrow = arrow.Clone();
|
||||
return axisLine;
|
||||
}
|
||||
|
||||
public void Copy(AxisLine axisLine)
|
||||
{
|
||||
show = axisLine.show;
|
||||
base.Copy(axisLine);
|
||||
onZero = axisLine.onZero;
|
||||
width = axisLine.width;
|
||||
symbol = axisLine.symbol;
|
||||
symbolWidth = axisLine.symbolWidth;
|
||||
symbolHeight = axisLine.symbolHeight;
|
||||
symbolOffset = axisLine.symbolOffset;
|
||||
symbolDent = axisLine.symbolDent;
|
||||
showArrow = axisLine.showArrow;
|
||||
arrow.Copy(axisLine.arrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -30,11 +30,7 @@ namespace XCharts
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private string m_Name;
|
||||
[SerializeField] private Location m_Location;
|
||||
[SerializeField] private Vector2 m_Offset;
|
||||
[SerializeField] private float m_Rotate;
|
||||
[SerializeField] private Color m_Color;
|
||||
[SerializeField] private int m_FontSize;
|
||||
[SerializeField] private FontStyle m_FontStyle;
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show axis name.
|
||||
@@ -43,7 +39,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the name of axis.
|
||||
@@ -52,7 +48,7 @@ namespace XCharts
|
||||
public string name
|
||||
{
|
||||
get { return m_Name; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Name, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Name, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Location of axis name.
|
||||
@@ -61,52 +57,17 @@ namespace XCharts
|
||||
public Location location
|
||||
{
|
||||
get { return m_Location; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Location, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Location, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the offset of axis name and axis line.
|
||||
/// 坐标轴名称与轴线之间的偏移。
|
||||
/// The text style of axis name.
|
||||
/// 文本样式。
|
||||
/// </summary>
|
||||
public Vector2 offset
|
||||
public TextStyle textStyle
|
||||
{
|
||||
get { return m_Offset; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Rotation of axis name.
|
||||
/// 坐标轴名字旋转,角度值。
|
||||
/// </summary>
|
||||
public float rotate
|
||||
{
|
||||
get { return m_Rotate; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Color of axis name.
|
||||
/// 坐标轴名称的文字颜色。
|
||||
/// </summary>
|
||||
public Color color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// axis name font size.
|
||||
/// 坐标轴名称的文字大小。
|
||||
/// </summary>
|
||||
public int fontSize
|
||||
{
|
||||
get { return m_FontSize; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// axis name font style.
|
||||
/// 坐标轴名称的文字风格。
|
||||
/// </summary>
|
||||
public FontStyle fontStyle
|
||||
{
|
||||
get { return m_FontStyle; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
|
||||
get { return m_TextStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public static AxisName defaultAxisName
|
||||
@@ -118,10 +79,7 @@ namespace XCharts
|
||||
m_Show = false,
|
||||
m_Name = "axisName",
|
||||
m_Location = Location.End,
|
||||
m_Rotate = 0,
|
||||
m_Color = Color.clear,
|
||||
m_FontSize = 18,
|
||||
m_FontStyle = FontStyle.Normal
|
||||
m_TextStyle = new TextStyle(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -132,11 +90,7 @@ namespace XCharts
|
||||
axisName.show = show;
|
||||
axisName.name = name;
|
||||
axisName.location = location;
|
||||
axisName.offset = offset;
|
||||
axisName.rotate = rotate;
|
||||
axisName.color = color;
|
||||
axisName.fontSize = fontSize;
|
||||
axisName.fontStyle = fontStyle;
|
||||
axisName.textStyle.Copy(textStyle);
|
||||
return axisName;
|
||||
}
|
||||
|
||||
@@ -145,11 +99,7 @@ namespace XCharts
|
||||
show = axisName.show;
|
||||
name = axisName.name;
|
||||
location = axisName.location;
|
||||
offset = axisName.offset;
|
||||
rotate = axisName.rotate;
|
||||
color = axisName.color;
|
||||
fontSize = axisName.fontSize;
|
||||
fontStyle = axisName.fontStyle;
|
||||
textStyle.Copy(axisName.textStyle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -28,7 +28,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Color of split area. SplitArea color could also be set in color array,
|
||||
@@ -49,10 +49,7 @@ namespace XCharts
|
||||
return new AxisSplitArea()
|
||||
{
|
||||
m_Show = false,
|
||||
m_Color = new List<Color32>(){
|
||||
new Color32(250,250,250,77),
|
||||
new Color32(200,200,200,77)
|
||||
}
|
||||
m_Color = new List<Color32>() { }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -73,10 +70,18 @@ namespace XCharts
|
||||
ChartHelper.CopyList(color, splitArea.color);
|
||||
}
|
||||
|
||||
public Color32 getColor(int index)
|
||||
public Color32 GetColor(int index, BaseAxisTheme theme)
|
||||
{
|
||||
var i = index % color.Count;
|
||||
return color[i];
|
||||
if (color.Count > 0)
|
||||
{
|
||||
var i = index % color.Count;
|
||||
return color[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
var i = index % theme.splitAreaColors.Count;
|
||||
return theme.splitAreaColors[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -15,33 +15,14 @@ namespace XCharts
|
||||
/// 坐标轴在 grid 区域中的分隔线。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class AxisSplitLine : SubComponent
|
||||
public class AxisSplitLine : BaseLine
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private int m_Interval;
|
||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle(0.7f);
|
||||
|
||||
/// <summary>
|
||||
/// Set this to true to show the split line.
|
||||
/// 是否显示分隔线。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public int interval
|
||||
{
|
||||
get { return m_Interval; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 线条样式
|
||||
/// </summary>
|
||||
public LineStyle lineStyle
|
||||
{
|
||||
get { return m_LineStyle; }
|
||||
set { if (value != null) { m_LineStyle = value; SetVerticesDirty(); } }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public override bool vertsDirty { get { return m_VertsDirty || m_LineStyle.anyDirty; } }
|
||||
@@ -72,23 +53,8 @@ namespace XCharts
|
||||
|
||||
public void Copy(AxisSplitLine splitLine)
|
||||
{
|
||||
show = splitLine.show;
|
||||
base.Copy(splitLine);
|
||||
interval = splitLine.interval;
|
||||
lineStyle.Copy(splitLine.lineStyle);
|
||||
}
|
||||
|
||||
internal Color32 GetColor(ThemeInfo theme)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(lineStyle.color))
|
||||
{
|
||||
return lineStyle.GetColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
var color = theme.axisSplitLineColor;
|
||||
color.a = (byte)(color.a * lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool NeedShow(int index)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
@@ -15,23 +15,11 @@ namespace XCharts
|
||||
/// 坐标轴刻度相关设置。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AxisTick : SubComponent
|
||||
public class AxisTick : BaseLine
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] private bool m_AlignWithLabel;
|
||||
[SerializeField] private bool m_Inside;
|
||||
[SerializeField] private float m_Length;
|
||||
[SerializeField] private float m_Width;
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis tick from showing.
|
||||
/// 是否显示坐标轴刻度。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Align axis tick with label, which is available only when boundaryGap is set to be true in category axis.
|
||||
/// 类目轴中在 boundaryGap 为 true 的时候有效,可以保证刻度线和标签对齐。
|
||||
@@ -39,7 +27,7 @@ namespace XCharts
|
||||
public bool alignWithLabel
|
||||
{
|
||||
get { return m_AlignWithLabel; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_AlignWithLabel, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AlignWithLabel, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Set this to true so the axis labels face the inside direction.
|
||||
@@ -48,25 +36,7 @@ namespace XCharts
|
||||
public bool inside
|
||||
{
|
||||
get { return m_Inside; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Inside, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The length of the axis tick.
|
||||
/// 坐标轴刻度的长度。
|
||||
/// </summary>
|
||||
public float length
|
||||
{
|
||||
get { return m_Length; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The width of the axis tick.Keep the same width with axis line when default 0.
|
||||
/// 坐标轴刻度的宽度。默认为0时宽度和坐标轴一致。
|
||||
/// </summary>
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Inside, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public static AxisTick defaultTick
|
||||
@@ -78,8 +48,6 @@ namespace XCharts
|
||||
m_Show = true,
|
||||
m_AlignWithLabel = false,
|
||||
m_Inside = false,
|
||||
m_Width = 0f,
|
||||
m_Length = 5f
|
||||
};
|
||||
return tick;
|
||||
}
|
||||
@@ -91,8 +59,7 @@ namespace XCharts
|
||||
axisTick.show = show;
|
||||
axisTick.alignWithLabel = alignWithLabel;
|
||||
axisTick.inside = inside;
|
||||
axisTick.length = length;
|
||||
axisTick.width = width;
|
||||
axisTick.lineStyle = lineStyle.Clone();
|
||||
return axisTick;
|
||||
}
|
||||
|
||||
@@ -101,8 +68,6 @@ namespace XCharts
|
||||
show = axisTick.show;
|
||||
alignWithLabel = axisTick.alignWithLabel;
|
||||
inside = axisTick.inside;
|
||||
length = axisTick.length;
|
||||
width = axisTick.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
89
Runtime/Component/Sub/BaseLine.cs
Normal file
89
Runtime/Component/Sub/BaseLine.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// Settings related to base line.
|
||||
/// 线条基础配置。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class BaseLine : SubComponent
|
||||
{
|
||||
[SerializeField] protected bool m_Show;
|
||||
[SerializeField] protected LineStyle m_LineStyle = new LineStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis line from showing.
|
||||
/// 是否显示坐标轴轴线。
|
||||
/// </summary>
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 线条样式
|
||||
/// </summary>
|
||||
public LineStyle lineStyle
|
||||
{
|
||||
get { return m_LineStyle; }
|
||||
set { if (value != null) { m_LineStyle = value; SetVerticesDirty(); } }
|
||||
}
|
||||
|
||||
public static BaseLine defaultBaseLine
|
||||
{
|
||||
get
|
||||
{
|
||||
var axisLine = new BaseLine
|
||||
{
|
||||
m_Show = true,
|
||||
m_LineStyle = new LineStyle()
|
||||
};
|
||||
return axisLine;
|
||||
}
|
||||
}
|
||||
|
||||
public BaseLine()
|
||||
{
|
||||
lineStyle = new LineStyle();
|
||||
}
|
||||
|
||||
public BaseLine(bool show) : base()
|
||||
{
|
||||
m_Show = show;
|
||||
}
|
||||
|
||||
public void Copy(BaseLine axisLine)
|
||||
{
|
||||
show = axisLine.show;
|
||||
lineStyle.Copy(axisLine.lineStyle);
|
||||
}
|
||||
|
||||
public LineStyle.Type GetType(LineStyle.Type themeType)
|
||||
{
|
||||
return lineStyle.GetType(themeType);
|
||||
}
|
||||
|
||||
public float GetWidth(float themeWidth)
|
||||
{
|
||||
return lineStyle.GetWidth(themeWidth);
|
||||
}
|
||||
|
||||
public float GetLength(float themeLength)
|
||||
{
|
||||
return lineStyle.GetLength(themeLength);
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 themeColor)
|
||||
{
|
||||
return lineStyle.GetColor(themeColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85c7f8858dca444f88830d61b9af3700
|
||||
guid: 4c431b00ccffe4db4b61179b6df06eb2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
@@ -41,7 +41,7 @@ namespace XCharts
|
||||
public SerieLabel label
|
||||
{
|
||||
get { return m_Label; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Label, value, true)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Label, value, true)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图形样式。
|
||||
@@ -49,7 +49,7 @@ namespace XCharts
|
||||
public ItemStyle itemStyle
|
||||
{
|
||||
get { return m_ItemStyle; }
|
||||
set { if (PropertyUtility.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_ItemStyle, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public override bool vertsDirty { get { return m_VertsDirty || label.vertsDirty || itemStyle.vertsDirty; } }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -17,135 +17,10 @@ namespace XCharts
|
||||
[System.Serializable]
|
||||
public class GaugeAxis : SubComponent
|
||||
{
|
||||
[System.Serializable]
|
||||
public class AxisLine
|
||||
{
|
||||
[System.Serializable]
|
||||
public class StageColor
|
||||
{
|
||||
[SerializeField] private float m_Percent;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
/// <summary>
|
||||
/// 结束位置百分比。
|
||||
/// </summary>
|
||||
public float percent { get { return m_Percent; } set { m_Percent = value; } }
|
||||
/// <summary>
|
||||
/// 颜色。
|
||||
/// </summary>
|
||||
public Color32 color { get { return m_Color; } set { m_Color = value; } }
|
||||
|
||||
public StageColor(float percent, Color32 color)
|
||||
{
|
||||
m_Percent = percent;
|
||||
m_Color = color;
|
||||
}
|
||||
}
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private float m_Width = 15f;
|
||||
[SerializeField] private float m_Opacity = 1f;
|
||||
[SerializeField] private Color32 m_BarColor;
|
||||
[SerializeField] private Color32 m_BarBackgroundColor = new Color32(200, 200, 200, 255);
|
||||
[SerializeField]
|
||||
private List<StageColor> m_StageColor = new List<StageColor>()
|
||||
{
|
||||
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Set this to false to prevent the axis line from showing.
|
||||
/// 是否显示坐标轴轴线。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// line style line width.
|
||||
/// 坐标轴线线宽。
|
||||
/// </summary>
|
||||
public float width { get { return m_Width; } set { m_Width = value; } }
|
||||
/// <summary>
|
||||
/// The opacity of axis line.
|
||||
/// 透明度。
|
||||
/// </summary>
|
||||
public float opacity { get { return m_Opacity; } set { m_Opacity = value; } }
|
||||
/// <summary>
|
||||
/// 进度条颜色。
|
||||
/// </summary>
|
||||
public Color32 barColor { get { return m_BarColor; } set { m_BarColor = value; } }
|
||||
/// <summary>
|
||||
/// 进度条背景颜色。
|
||||
/// </summary>
|
||||
public Color32 barBackgroundColor { get { return m_BarBackgroundColor; } set { m_BarBackgroundColor = value; } }
|
||||
/// <summary>
|
||||
/// 阶段颜色。
|
||||
/// </summary>
|
||||
public List<StageColor> stageColor { get { return m_StageColor; } set { m_StageColor = value; } }
|
||||
}
|
||||
/// <summary>
|
||||
/// 分割线
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class SplitLine
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private float m_Length = 15;
|
||||
[SerializeField]
|
||||
private LineStyle m_LineStyle = new LineStyle()
|
||||
{
|
||||
width = 1.5f,
|
||||
type = LineStyle.Type.Solid,
|
||||
color = new Color32(238, 238, 238, 255)
|
||||
};
|
||||
/// <summary>
|
||||
/// 是否显示分割线。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// 分割线长度。
|
||||
/// </summary>
|
||||
public float length { get { return m_Length; } set { m_Length = value; } }
|
||||
/// <summary>
|
||||
/// 分割线样式。
|
||||
/// </summary>
|
||||
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
|
||||
}
|
||||
/// <summary>
|
||||
/// 刻度
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AxisTick
|
||||
{
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private float m_Length = 5;
|
||||
[SerializeField] private float m_SplitNumber = 5;
|
||||
[SerializeField]
|
||||
private LineStyle m_LineStyle = new LineStyle()
|
||||
{
|
||||
width = 1f,
|
||||
type = LineStyle.Type.Solid,
|
||||
color = new Color32(238, 238, 238, 255)
|
||||
};
|
||||
/// <summary>
|
||||
/// 是否显示刻度。
|
||||
/// </summary>
|
||||
public bool show { get { return m_Show; } set { m_Show = value; } }
|
||||
/// <summary>
|
||||
/// 刻度长度。当为0-1的浮点数时表示半径的百分比。
|
||||
/// </summary>
|
||||
public float length { get { return m_Length; } set { m_Length = value; } }
|
||||
/// <summary>
|
||||
/// 分割线之间的分割段数。
|
||||
/// </summary>
|
||||
public float splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
|
||||
/// <summary>
|
||||
/// 刻度线样式。
|
||||
/// </summary>
|
||||
public LineStyle lineStyle { get { return m_LineStyle; } set { m_LineStyle = value; } }
|
||||
}
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private AxisLine m_AxisLine = new AxisLine();
|
||||
[SerializeField] private SplitLine m_SplitLine = new SplitLine();
|
||||
[SerializeField] private AxisTick m_AxisTick = new AxisTick();
|
||||
[SerializeField] private GaugeAxisLine m_AxisLine = new GaugeAxisLine(true);
|
||||
[SerializeField] private GaugeAxisSplitLine m_SplitLine = new GaugeAxisSplitLine(true);
|
||||
[SerializeField] private GaugeAxisTick m_AxisTick = new GaugeAxisTick(true);
|
||||
[SerializeField] private SerieLabel m_AxisLabel = new SerieLabel();
|
||||
[SerializeField] private List<string> m_AxisLabelText = new List<string>();
|
||||
|
||||
@@ -154,17 +29,17 @@ namespace XCharts
|
||||
/// axis line style.
|
||||
/// 仪表盘轴线样式。
|
||||
/// </summary>
|
||||
public AxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
|
||||
public GaugeAxisLine axisLine { get { return m_AxisLine; } set { m_AxisLine = value; } }
|
||||
/// <summary>
|
||||
/// slit line style.
|
||||
/// 分割线。
|
||||
/// </summary>
|
||||
public SplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } }
|
||||
public GaugeAxisSplitLine splitLine { get { return m_SplitLine; } set { m_SplitLine = value; } }
|
||||
/// <summary>
|
||||
/// axis tick style.
|
||||
/// 刻度。
|
||||
/// </summary>
|
||||
public AxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
|
||||
public GaugeAxisTick axisTick { get { return m_AxisTick; } set { m_AxisTick = value; } }
|
||||
/// <summary>
|
||||
/// axis label style.
|
||||
/// 文本标签。
|
||||
@@ -181,23 +56,24 @@ namespace XCharts
|
||||
|
||||
public List<float> runtimeStageAngle = new List<float>();
|
||||
public List<Vector3> runtimeLabelPosition = new List<Vector3>();
|
||||
private List<LabelObject> m_RuntimeLabelList = new List<LabelObject>();
|
||||
private List<ChartLabel> m_RuntimeLabelList = new List<ChartLabel>();
|
||||
|
||||
internal Color32 GetAxisLineColor(ThemeInfo theme, int index)
|
||||
internal Color32 GetAxisLineColor(ChartTheme theme, int index)
|
||||
{
|
||||
var color = !ChartHelper.IsClearColor(axisLine.barColor) ? axisLine.barColor : theme.GetColor(index);
|
||||
ChartHelper.SetColorOpacity(ref color, axisLine.opacity);
|
||||
ChartHelper.SetColorOpacity(ref color, axisLine.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
internal Color32 GetAxisLineBackgroundColor(ThemeInfo theme, int index)
|
||||
internal Color32 GetAxisLineBackgroundColor(ChartTheme theme, int index)
|
||||
{
|
||||
var color = !ChartHelper.IsClearColor(axisLine.barBackgroundColor) ? axisLine.barBackgroundColor : ChartConst.greyColor32;
|
||||
ChartHelper.SetColorOpacity(ref color, axisLine.opacity);
|
||||
var color = !ChartHelper.IsClearColor(axisLine.barBackgroundColor)
|
||||
? axisLine.barBackgroundColor : ChartConst.greyColor32;
|
||||
ChartHelper.SetColorOpacity(ref color, axisLine.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
internal Color32 GetSplitLineColor(ThemeInfo theme, int serieIndex, float angle)
|
||||
internal Color32 GetSplitLineColor(Color32 themeColor, int serieIndex, float angle)
|
||||
{
|
||||
Color32 color;
|
||||
if (!ChartHelper.IsClearColor(splitLine.lineStyle.color))
|
||||
@@ -206,21 +82,12 @@ namespace XCharts
|
||||
ChartHelper.SetColorOpacity(ref color, splitLine.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
for (int i = 0; i < runtimeStageAngle.Count; i++)
|
||||
{
|
||||
if (angle < runtimeStageAngle[i])
|
||||
{
|
||||
color = axisLine.stageColor[i].color;
|
||||
ChartHelper.SetColorOpacity(ref color, splitLine.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
color = theme.GetColor(serieIndex);
|
||||
color = themeColor;
|
||||
ChartHelper.SetColorOpacity(ref color, splitLine.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
internal Color32 GetAxisTickColor(ThemeInfo theme, int serieIndex, float angle)
|
||||
internal Color32 GetAxisTickColor(Color32 themeColor, int serieIndex, float angle)
|
||||
{
|
||||
Color32 color;
|
||||
if (!ChartHelper.IsClearColor(axisTick.lineStyle.color))
|
||||
@@ -229,21 +96,12 @@ namespace XCharts
|
||||
ChartHelper.SetColorOpacity(ref color, axisTick.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
for (int i = 0; i < runtimeStageAngle.Count; i++)
|
||||
{
|
||||
if (angle < runtimeStageAngle[i])
|
||||
{
|
||||
color = axisLine.stageColor[i].color;
|
||||
ChartHelper.SetColorOpacity(ref color, axisTick.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
color = theme.GetColor(serieIndex);
|
||||
color = themeColor;
|
||||
ChartHelper.SetColorOpacity(ref color, axisTick.lineStyle.opacity);
|
||||
return color;
|
||||
}
|
||||
|
||||
internal Color32 GetPointerColor(ThemeInfo theme, int serieIndex, float angle, ItemStyle itemStyle)
|
||||
internal Color32 GetPointerColor(ChartTheme theme, int serieIndex, float angle, ItemStyle itemStyle)
|
||||
{
|
||||
Color32 color;
|
||||
if (!ChartHelper.IsClearColor(itemStyle.color))
|
||||
@@ -269,12 +127,12 @@ namespace XCharts
|
||||
m_RuntimeLabelList.Clear();
|
||||
}
|
||||
|
||||
public void AddLabelObject(LabelObject label)
|
||||
public void AddLabelObject(ChartLabel label)
|
||||
{
|
||||
m_RuntimeLabelList.Add(label);
|
||||
}
|
||||
|
||||
public LabelObject GetLabelObject(int index)
|
||||
public ChartLabel GetLabelObject(int index)
|
||||
{
|
||||
if (index >= 0 && index < m_RuntimeLabelList.Count)
|
||||
{
|
||||
|
||||
63
Runtime/Component/Sub/GaugeAxisLine.cs
Normal file
63
Runtime/Component/Sub/GaugeAxisLine.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[System.Serializable]
|
||||
public class StageColor
|
||||
{
|
||||
[SerializeField] private float m_Percent;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
/// <summary>
|
||||
/// 结束位置百分比。
|
||||
/// </summary>
|
||||
public float percent { get { return m_Percent; } set { m_Percent = value; } }
|
||||
/// <summary>
|
||||
/// 颜色。
|
||||
/// </summary>
|
||||
public Color32 color { get { return m_Color; } set { m_Color = value; } }
|
||||
|
||||
public StageColor(float percent, Color32 color)
|
||||
{
|
||||
m_Percent = percent;
|
||||
m_Color = color;
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class GaugeAxisLine : BaseLine
|
||||
{
|
||||
[SerializeField] private Color32 m_BarColor;
|
||||
[SerializeField] private Color32 m_BarBackgroundColor = new Color32(200, 200, 200, 255);
|
||||
[SerializeField]
|
||||
private List<StageColor> m_StageColor = new List<StageColor>()
|
||||
{
|
||||
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||
};
|
||||
/// <summary>
|
||||
/// 进度条颜色。
|
||||
/// </summary>
|
||||
public Color32 barColor { get { return m_BarColor; } set { m_BarColor = value; } }
|
||||
/// <summary>
|
||||
/// 进度条背景颜色。
|
||||
/// </summary>
|
||||
public Color32 barBackgroundColor { get { return m_BarBackgroundColor; } set { m_BarBackgroundColor = value; } }
|
||||
/// <summary>
|
||||
/// 阶段颜色。
|
||||
/// </summary>
|
||||
public List<StageColor> stageColor { get { return m_StageColor; } set { m_StageColor = value; } }
|
||||
|
||||
public GaugeAxisLine(bool show) : base(show)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94e905091d07140de987a531a6ff90d9
|
||||
guid: 2c35880091e5a4382876c47bd843a99f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
20
Runtime/Component/Sub/GaugeAxisSplitLine.cs
Normal file
20
Runtime/Component/Sub/GaugeAxisSplitLine.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 分割线
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class GaugeAxisSplitLine : BaseLine
|
||||
{
|
||||
public GaugeAxisSplitLine(bool show) : base(show)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7fa63cd119419441789620060693a7cb
|
||||
guid: 27a5f68720fa741ddbd50217b585a9e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
27
Runtime/Component/Sub/GaugeAxisTick.cs
Normal file
27
Runtime/Component/Sub/GaugeAxisTick.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 刻度
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class GaugeAxisTick : BaseLine
|
||||
{
|
||||
[SerializeField] private float m_SplitNumber = 5;
|
||||
/// <summary>
|
||||
/// 分割线之间的分割段数。
|
||||
/// </summary>
|
||||
public float splitNumber { get { return m_SplitNumber; } set { m_SplitNumber = value; } }
|
||||
public GaugeAxisTick(bool show) : base(show)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Sub/GaugeAxisTick.cs.meta
Normal file
11
Runtime/Component/Sub/GaugeAxisTick.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e9ace80811494ca5aad05b59c61a74f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -29,7 +29,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pointer length. It can be an absolute value, or it can be a percentage relative to the radius (0-1).
|
||||
@@ -38,7 +38,7 @@ namespace XCharts
|
||||
public float length
|
||||
{
|
||||
get { return m_Length; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Pointer width.
|
||||
@@ -47,7 +47,7 @@ namespace XCharts
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -84,7 +84,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项颜色。
|
||||
@@ -92,7 +92,7 @@ namespace XCharts
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gradient color1.
|
||||
@@ -101,7 +101,7 @@ namespace XCharts
|
||||
public Color32 toColor
|
||||
{
|
||||
get { return m_ToColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gradient color2.Only valid in line diagrams.
|
||||
@@ -110,7 +110,7 @@ namespace XCharts
|
||||
public Color32 toColor2
|
||||
{
|
||||
get { return m_ToColor2; }
|
||||
set { if (PropertyUtility.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项背景颜色。
|
||||
@@ -118,7 +118,7 @@ namespace XCharts
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 中心区域颜色。
|
||||
@@ -126,7 +126,7 @@ namespace XCharts
|
||||
public Color32 centerColor
|
||||
{
|
||||
get { return m_CenterColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_CenterColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_CenterColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 中心区域间隙。
|
||||
@@ -134,7 +134,7 @@ namespace XCharts
|
||||
public float centerGap
|
||||
{
|
||||
get { return m_CenterGap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_CenterGap, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_CenterGap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据项背景宽度。
|
||||
@@ -142,7 +142,7 @@ namespace XCharts
|
||||
public float backgroundWidth
|
||||
{
|
||||
get { return m_BackgroundWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框的类型。
|
||||
@@ -150,7 +150,7 @@ namespace XCharts
|
||||
public Type borderType
|
||||
{
|
||||
get { return m_BorderType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BorderType, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框的颜色。
|
||||
@@ -158,7 +158,7 @@ namespace XCharts
|
||||
public Color32 borderColor
|
||||
{
|
||||
get { return m_BorderColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_BorderColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 边框宽。
|
||||
@@ -166,7 +166,7 @@ namespace XCharts
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形。
|
||||
@@ -174,7 +174,7 @@ namespace XCharts
|
||||
public float opacity
|
||||
{
|
||||
get { return m_Opacity; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 提示框单项的字符串模版格式器。具体配置参考`Tooltip`的`formatter`
|
||||
@@ -182,7 +182,7 @@ namespace XCharts
|
||||
public string tooltipFormatter
|
||||
{
|
||||
get { return m_TooltipFormatter; }
|
||||
set { if (PropertyUtility.SetClass(ref m_TooltipFormatter, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_TooltipFormatter, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Standard numeric format strings.
|
||||
@@ -194,7 +194,7 @@ namespace XCharts
|
||||
public string numericFormatter
|
||||
{
|
||||
get { return m_NumericFormatter; }
|
||||
set { if (PropertyUtility.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <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)).
|
||||
@@ -203,7 +203,7 @@ namespace XCharts
|
||||
public float[] cornerRadius
|
||||
{
|
||||
get { return m_CornerRadius; }
|
||||
set { if (PropertyUtility.SetClass(ref m_CornerRadius, value, true)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_CornerRadius, value, true)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 实际边框宽。边框不显示时为0。
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -28,10 +28,14 @@ namespace XCharts
|
||||
}
|
||||
[SerializeField] private bool m_Show;
|
||||
[SerializeField] Position m_Position;
|
||||
[SerializeField] private float m_Width = 10;
|
||||
[SerializeField] private float m_Height = 15;
|
||||
[SerializeField] private float m_Offset = 0;
|
||||
[SerializeField] private float m_Dent = 3;
|
||||
[SerializeField]
|
||||
private Arrow m_Arrow = new Arrow()
|
||||
{
|
||||
width = 10,
|
||||
height = 15,
|
||||
offset = 0,
|
||||
dent = 3
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show the arrow.
|
||||
@@ -40,7 +44,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The position of arrow.
|
||||
@@ -49,43 +53,17 @@ namespace XCharts
|
||||
public Position position
|
||||
{
|
||||
get { return m_Position; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The widht of arrow.
|
||||
/// 箭头宽。
|
||||
/// the arrow of line.
|
||||
/// 箭头。
|
||||
/// </summary>
|
||||
public float width
|
||||
public Arrow arrow
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The height of arrow.
|
||||
/// 箭头高。
|
||||
/// </summary>
|
||||
public float height
|
||||
{
|
||||
get { return m_Height; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Height, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The offset of arrow.
|
||||
/// 箭头偏移。
|
||||
/// </summary>
|
||||
public float offset
|
||||
{
|
||||
get { return m_Offset; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The dent of arrow.
|
||||
/// 箭头的凹度。
|
||||
/// </summary>
|
||||
public float dent
|
||||
{
|
||||
get { return m_Dent; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Dent, value)) SetVerticesDirty(); }
|
||||
get { return m_Arrow; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Arrow, value)) SetVerticesDirty(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
|
||||
using UnityEngine;
|
||||
@@ -44,13 +44,15 @@ namespace XCharts
|
||||
/// 双点划线
|
||||
/// </summary>
|
||||
DashDotDot,
|
||||
None,
|
||||
}
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private Type m_Type = Type.Solid;
|
||||
[SerializeField] private Color32 m_Color;
|
||||
[SerializeField] private Color32 m_ToColor;
|
||||
[SerializeField] private Color32 m_ToColor2;
|
||||
[SerializeField] private float m_Width = 0.8f;
|
||||
[SerializeField] private float m_Width = 0;
|
||||
[SerializeField] private float m_Length = 0;
|
||||
[SerializeField] [Range(0, 1)] private float m_Opacity = 1;
|
||||
|
||||
/// <summary>
|
||||
@@ -60,7 +62,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of line.
|
||||
@@ -69,7 +71,7 @@ namespace XCharts
|
||||
public Type type
|
||||
{
|
||||
get { return m_Type; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of line, default use serie color.
|
||||
@@ -78,7 +80,7 @@ namespace XCharts
|
||||
public Color32 color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the middle color of line, default use serie color.
|
||||
@@ -87,7 +89,7 @@ namespace XCharts
|
||||
public Color32 toColor
|
||||
{
|
||||
get { return m_ToColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the end color of line, default use serie color.
|
||||
@@ -96,7 +98,7 @@ namespace XCharts
|
||||
public Color32 toColor2
|
||||
{
|
||||
get { return m_ToColor2; }
|
||||
set { if (PropertyUtility.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_ToColor2, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of line.
|
||||
@@ -105,7 +107,16 @@ namespace XCharts
|
||||
public float width
|
||||
{
|
||||
get { return m_Width; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Width, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the length of line.
|
||||
/// 线长。
|
||||
/// /// </summary>
|
||||
public float length
|
||||
{
|
||||
get { return m_Length; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Length, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Opacity of the line. Supports value from 0 to 1, and the line will not be drawn when set to 0.
|
||||
@@ -114,7 +125,7 @@ namespace XCharts
|
||||
public float opacity
|
||||
{
|
||||
get { return m_Opacity; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Opacity, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public LineStyle()
|
||||
@@ -126,6 +137,11 @@ namespace XCharts
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public LineStyle(LineStyle.Type type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public LineStyle(LineStyle.Type type, float width)
|
||||
{
|
||||
this.type = type;
|
||||
@@ -190,5 +206,34 @@ namespace XCharts
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
public Type GetType(Type themeType)
|
||||
{
|
||||
return type == Type.None ? themeType : type;
|
||||
}
|
||||
|
||||
public float GetWidth(float themeWidth)
|
||||
{
|
||||
return width == 0 ? themeWidth : width;
|
||||
}
|
||||
|
||||
public float GetLength(float themeLength)
|
||||
{
|
||||
return length == 0 ? themeLength : length;
|
||||
}
|
||||
|
||||
public Color32 GetColor(Color32 themeColor)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(color))
|
||||
{
|
||||
return GetColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
var color = themeColor;
|
||||
color.a = (byte)(color.a * opacity);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -39,7 +42,10 @@ namespace XCharts
|
||||
[SerializeField] private float m_Top;
|
||||
[SerializeField] private float m_Bottom;
|
||||
|
||||
private TextAnchor m_TextAnchor;
|
||||
private TextAnchor m_TextAlignment;
|
||||
#if dUI_TextMeshPro
|
||||
private TextAlignmentOptions m_TMPTextAlignment;
|
||||
#endif
|
||||
private Vector2 m_AnchorMin;
|
||||
private Vector2 m_AnchorMax;
|
||||
private Vector2 m_Pivot;
|
||||
@@ -50,7 +56,7 @@ namespace XCharts
|
||||
public Align align
|
||||
{
|
||||
get { return m_Align; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Align, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Align, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
@@ -59,7 +65,7 @@ namespace XCharts
|
||||
public float left
|
||||
{
|
||||
get { return m_Left; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Left, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Left, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
@@ -68,7 +74,7 @@ namespace XCharts
|
||||
public float right
|
||||
{
|
||||
get { return m_Right; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Right, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Right, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
@@ -77,7 +83,7 @@ namespace XCharts
|
||||
public float top
|
||||
{
|
||||
get { return m_Top; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Top, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Top, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
/// <summary>
|
||||
/// Distance between component and the left side of the container.
|
||||
@@ -86,7 +92,7 @@ namespace XCharts
|
||||
public float bottom
|
||||
{
|
||||
get { return m_Bottom; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Bottom, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Bottom, value)) { SetComponentDirty(); UpdateAlign(); } }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -94,7 +100,11 @@ namespace XCharts
|
||||
/// Location对应的Anchor锚点
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public TextAnchor runtimeTextAnchor { get { return m_TextAnchor; } }
|
||||
public TextAnchor runtimeTextAlignment { get { return m_TextAlignment; } }
|
||||
|
||||
#if dUI_TextMeshPro
|
||||
public TextAlignmentOptions runtimeTMPTextAlignment { get { return m_TMPTextAlignment; } }
|
||||
#endif
|
||||
/// <summary>
|
||||
/// the minimum achor.
|
||||
/// Location对应的anchorMin。
|
||||
@@ -179,55 +189,82 @@ namespace XCharts
|
||||
switch (m_Align)
|
||||
{
|
||||
case Align.BottomCenter:
|
||||
m_TextAnchor = TextAnchor.LowerCenter;
|
||||
m_TextAlignment = TextAnchor.LowerCenter;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Bottom;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0.5f, 0);
|
||||
m_AnchorMax = new Vector2(0.5f, 0);
|
||||
m_Pivot = new Vector2(0.5f, 0);
|
||||
break;
|
||||
case Align.BottomLeft:
|
||||
m_TextAnchor = TextAnchor.LowerLeft;
|
||||
m_TextAlignment = TextAnchor.LowerLeft;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.BottomLeft;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0, 0);
|
||||
m_AnchorMax = new Vector2(0, 0);
|
||||
m_Pivot = new Vector2(0, 0);
|
||||
break;
|
||||
case Align.BottomRight:
|
||||
m_TextAnchor = TextAnchor.LowerRight;
|
||||
m_TextAlignment = TextAnchor.LowerRight;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.BottomRight;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(1, 0);
|
||||
m_AnchorMax = new Vector2(1, 0);
|
||||
m_Pivot = new Vector2(1, 0);
|
||||
break;
|
||||
case Align.Center:
|
||||
m_TextAnchor = TextAnchor.MiddleCenter;
|
||||
m_TextAlignment = TextAnchor.MiddleCenter;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Center;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0.5f, 0.5f);
|
||||
m_AnchorMax = new Vector2(0.5f, 0.5f);
|
||||
m_Pivot = new Vector2(0.5f, 0.5f);
|
||||
break;
|
||||
case Align.CenterLeft:
|
||||
m_TextAnchor = TextAnchor.MiddleLeft;
|
||||
m_TextAlignment = TextAnchor.MiddleLeft;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Left;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0, 0.5f);
|
||||
m_AnchorMax = new Vector2(0, 0.5f);
|
||||
m_Pivot = new Vector2(0, 0.5f);
|
||||
break;
|
||||
case Align.CenterRight:
|
||||
m_TextAnchor = TextAnchor.MiddleRight;
|
||||
m_TextAlignment = TextAnchor.MiddleRight;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Right;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(1, 0.5f);
|
||||
m_AnchorMax = new Vector2(1, 0.5f);
|
||||
m_Pivot = new Vector2(1, 0.5f);
|
||||
break;
|
||||
case Align.TopCenter:
|
||||
m_TextAnchor = TextAnchor.UpperCenter;
|
||||
m_TextAlignment = TextAnchor.UpperCenter;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.Top;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0.5f, 1);
|
||||
m_AnchorMax = new Vector2(0.5f, 1);
|
||||
m_Pivot = new Vector2(0.5f, 1);
|
||||
break;
|
||||
case Align.TopLeft:
|
||||
m_TextAnchor = TextAnchor.UpperLeft;
|
||||
m_TextAlignment = TextAnchor.UpperLeft;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.TopLeft;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(0, 1);
|
||||
m_AnchorMax = new Vector2(0, 1);
|
||||
m_Pivot = new Vector2(0, 1);
|
||||
break;
|
||||
case Align.TopRight:
|
||||
m_TextAnchor = TextAnchor.UpperRight;
|
||||
m_TextAlignment = TextAnchor.UpperRight;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPTextAlignment = TextAlignmentOptions.TopRight;
|
||||
#endif
|
||||
m_AnchorMin = new Vector2(1, 1);
|
||||
m_AnchorMax = new Vector2(1, 1);
|
||||
m_Pivot = new Vector2(1, 1);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
@@ -34,7 +34,7 @@ namespace XCharts
|
||||
[SerializeField] private SerieSymbol m_Symbol = new SerieSymbol();
|
||||
[SerializeField] private List<float> m_Data = new List<float>();
|
||||
|
||||
public LabelObject labelObject { get; set; }
|
||||
public ChartLabel labelObject { get; set; }
|
||||
|
||||
private bool m_Show = true;
|
||||
private float m_RtPieOutsideRadius;
|
||||
@@ -169,6 +169,7 @@ namespace XCharts
|
||||
public Vector3 runtimePosition { get; internal set; }
|
||||
public float runtimeAngle { get; internal set; }
|
||||
public Vector3 runtiemPieOffsetCenter { get; internal set; }
|
||||
public float runtimeStackHig { get; internal set; }
|
||||
private List<float> m_PreviousData = new List<float>();
|
||||
private List<float> m_DataUpdateTime = new List<float>();
|
||||
private List<bool> m_DataUpdateFlag = new List<bool>();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -83,15 +83,10 @@ namespace XCharts
|
||||
[SerializeField] private Vector3 m_Offset;
|
||||
[SerializeField] private float m_Margin;
|
||||
[SerializeField] private string m_Formatter;
|
||||
[SerializeField] private float m_Rotate = 0;
|
||||
[SerializeField] private float m_PaddingLeftRight = 2f;
|
||||
[SerializeField] private float m_PaddingTopBottom = 2f;
|
||||
[SerializeField] private Color m_Color;
|
||||
[SerializeField] private Color32 m_BackgroundColor;
|
||||
[SerializeField] private float m_BackgroundWidth = 0;
|
||||
[SerializeField] private float m_BackgroundHeight = 0;
|
||||
[SerializeField] private int m_FontSize = 18;
|
||||
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
|
||||
[SerializeField] private bool m_Line = true;
|
||||
[SerializeField] private LineType m_LineType = LineType.BrokenLine;
|
||||
[SerializeField] private Color32 m_LineColor = ChartConst.clearColor32;
|
||||
@@ -103,6 +98,7 @@ namespace XCharts
|
||||
[SerializeField] private Color32 m_BorderColor = ChartConst.greyColor32;
|
||||
[SerializeField] private string m_NumericFormatter = "";
|
||||
[SerializeField] private bool m_AutoOffset = false;
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
@@ -112,12 +108,8 @@ namespace XCharts
|
||||
m_Margin = 0;
|
||||
m_PaddingLeftRight = 2f;
|
||||
m_PaddingTopBottom = 2f;
|
||||
m_Color = Color.clear;
|
||||
m_BackgroundColor = Color.clear;
|
||||
m_BackgroundWidth = 0;
|
||||
m_BackgroundHeight = 0;
|
||||
m_FontSize = 18;
|
||||
m_FontStyle = FontStyle.Normal;
|
||||
m_Line = true;
|
||||
m_LineType = LineType.BrokenLine;
|
||||
m_LineColor = Color.clear;
|
||||
@@ -138,7 +130,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The position of label.
|
||||
@@ -147,7 +139,7 @@ namespace XCharts
|
||||
public Position position
|
||||
{
|
||||
get { return m_Position; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Position, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 标签内容字符串模版格式器。支持用 \n 换行。
|
||||
@@ -165,7 +157,7 @@ namespace XCharts
|
||||
public string formatter
|
||||
{
|
||||
get { return m_Formatter; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Formatter, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Formatter, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// offset to the host graphic element.
|
||||
@@ -174,7 +166,7 @@ namespace XCharts
|
||||
public Vector3 offset
|
||||
{
|
||||
get { return m_Offset; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 距离轴线的距离。
|
||||
@@ -182,25 +174,7 @@ namespace XCharts
|
||||
public float margin
|
||||
{
|
||||
get { return m_Margin; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Margin, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Text color,If set as default ,the color will assigned as series color.
|
||||
/// 自定义文字颜色,默认和系列的颜色一致。
|
||||
/// </summary>
|
||||
public Color color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Color, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the background color. If set as default, it means than don't show background.
|
||||
/// 标签的背景色,默认无颜色。
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Margin, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of background. If set as default value 0, it means than the background width auto set as the text width.
|
||||
@@ -210,7 +184,7 @@ namespace XCharts
|
||||
public float backgroundWidth
|
||||
{
|
||||
get { return m_BackgroundWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BackgroundWidth, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BackgroundWidth, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the height of background. If set as default value 0, it means than the background height auto set as the text height.
|
||||
@@ -220,16 +194,7 @@ namespace XCharts
|
||||
public float backgroundHeight
|
||||
{
|
||||
get { return m_BackgroundHeight; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BackgroundHeight, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Rotate label.
|
||||
/// 标签旋转。
|
||||
/// </summary>
|
||||
public float rotate
|
||||
{
|
||||
get { return m_Rotate; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BackgroundHeight, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the text padding of left and right. defaut:2.
|
||||
@@ -238,7 +203,7 @@ namespace XCharts
|
||||
public float paddingLeftRight
|
||||
{
|
||||
get { return m_PaddingLeftRight; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_PaddingLeftRight, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PaddingLeftRight, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the text padding of top and bottom. defaut:2.
|
||||
@@ -247,25 +212,7 @@ namespace XCharts
|
||||
public float paddingTopBottom
|
||||
{
|
||||
get { return m_PaddingTopBottom; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_PaddingTopBottom, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font size.
|
||||
/// 文字的字体大小。
|
||||
/// </summary>
|
||||
public int fontSize
|
||||
{
|
||||
get { return m_FontSize; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font style.
|
||||
/// 文字的字体风格。
|
||||
/// </summary>
|
||||
public FontStyle fontStyle
|
||||
{
|
||||
get { return m_FontStyle; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PaddingTopBottom, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show visual guide line.Will show when label position is set as 'outside'.
|
||||
@@ -274,7 +221,7 @@ namespace XCharts
|
||||
public bool line
|
||||
{
|
||||
get { return m_Line; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Line, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Line, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of visual guide line.
|
||||
@@ -283,7 +230,7 @@ namespace XCharts
|
||||
public LineType lineType
|
||||
{
|
||||
get { return m_LineType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of visual guild line.
|
||||
@@ -292,7 +239,7 @@ namespace XCharts
|
||||
public Color32 lineColor
|
||||
{
|
||||
get { return m_LineColor; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_LineColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of visual guild line.
|
||||
@@ -301,7 +248,7 @@ namespace XCharts
|
||||
public float lineWidth
|
||||
{
|
||||
get { return m_LineWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The length of the first segment of visual guide line.
|
||||
@@ -310,7 +257,7 @@ namespace XCharts
|
||||
public float lineLength1
|
||||
{
|
||||
get { return m_LineLength1; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_LineLength1, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineLength1, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// The length of the second segment of visual guide line.
|
||||
@@ -319,7 +266,7 @@ namespace XCharts
|
||||
public float lineLength2
|
||||
{
|
||||
get { return m_LineLength2; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_LineLength2, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineLength2, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Whether to show border.
|
||||
@@ -328,7 +275,7 @@ namespace XCharts
|
||||
public bool border
|
||||
{
|
||||
get { return m_Border; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Border, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Border, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of border.
|
||||
@@ -337,7 +284,7 @@ namespace XCharts
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of border.
|
||||
@@ -346,7 +293,7 @@ namespace XCharts
|
||||
public Color32 borderColor
|
||||
{
|
||||
get { return m_BorderColor; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_BorderColor, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Standard numeric format strings.
|
||||
@@ -358,7 +305,7 @@ namespace XCharts
|
||||
public string numericFormatter
|
||||
{
|
||||
get { return m_NumericFormatter; }
|
||||
set { if (PropertyUtility.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_NumericFormatter, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否开启自动偏移。当开启时,Y的偏移会自动判断曲线的开口来决定向上还是向下偏移。
|
||||
@@ -366,7 +313,17 @@ namespace XCharts
|
||||
public bool autoOffset
|
||||
{
|
||||
get { return m_AutoOffset; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_AutoOffset, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_AutoOffset, value)) SetAllDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the sytle of text.
|
||||
/// 文本样式。
|
||||
/// </summary>
|
||||
public TextStyle textStyle
|
||||
{
|
||||
get { return m_TextStyle; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value)) SetAllDirty(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -81,8 +81,8 @@ namespace XCharts
|
||||
[SerializeField] private bool m_Show = true;
|
||||
[SerializeField] private SerieSymbolType m_Type = SerieSymbolType.EmptyCircle;
|
||||
[SerializeField] private SerieSymbolSizeType m_SizeType = SerieSymbolSizeType.Custom;
|
||||
[SerializeField] private float m_Size = 6f;
|
||||
[SerializeField] private float m_SelectedSize = 10f;
|
||||
[SerializeField] private float m_Size = 0f;
|
||||
[SerializeField] private float m_SelectedSize = 0f;
|
||||
[SerializeField] private int m_DataIndex = 1;
|
||||
[SerializeField] private float m_DataScale = 1;
|
||||
[SerializeField] private float m_SelectedDataScale = 1.5f;
|
||||
@@ -98,8 +98,8 @@ namespace XCharts
|
||||
m_Show = false;
|
||||
m_Type = SerieSymbolType.EmptyCircle;
|
||||
m_SizeType = SerieSymbolSizeType.Custom;
|
||||
m_Size = 6f;
|
||||
m_SelectedDataScale = 10f;
|
||||
m_Size = 0f;
|
||||
m_SelectedSize = 0f;
|
||||
m_DataIndex = 1;
|
||||
m_DataScale = 1;
|
||||
m_SelectedDataScale = 1.5f;
|
||||
@@ -118,7 +118,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetAllDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetAllDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of symbol.
|
||||
@@ -127,7 +127,7 @@ namespace XCharts
|
||||
public SerieSymbolType type
|
||||
{
|
||||
get { return m_Type; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Type, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of symbol size.
|
||||
@@ -136,7 +136,7 @@ namespace XCharts
|
||||
public SerieSymbolSizeType sizeType
|
||||
{
|
||||
get { return m_SizeType; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SizeType, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SizeType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the size of symbol.
|
||||
@@ -145,7 +145,7 @@ namespace XCharts
|
||||
public float size
|
||||
{
|
||||
get { return m_Size; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Size, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the size of selected symbol.
|
||||
@@ -154,7 +154,7 @@ namespace XCharts
|
||||
public float selectedSize
|
||||
{
|
||||
get { return m_SelectedSize; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SelectedSize, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SelectedSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// whitch data index is when the sizeType assined as FromData.
|
||||
@@ -163,7 +163,7 @@ namespace XCharts
|
||||
public int dataIndex
|
||||
{
|
||||
get { return m_DataIndex; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_DataIndex, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DataIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the scale of data when sizeType assined as FromData.
|
||||
@@ -172,7 +172,7 @@ namespace XCharts
|
||||
public float dataScale
|
||||
{
|
||||
get { return m_DataScale; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_DataScale, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DataScale, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the scale of selected data when sizeType assined as FromData.
|
||||
@@ -181,7 +181,7 @@ namespace XCharts
|
||||
public float selectedDataScale
|
||||
{
|
||||
get { return m_SelectedDataScale; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SelectedDataScale, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the callback of size when sizeType assined as Callback.
|
||||
@@ -190,7 +190,7 @@ namespace XCharts
|
||||
public SymbolSizeCallback sizeCallback
|
||||
{
|
||||
get { return m_SizeCallback; }
|
||||
set { if (PropertyUtility.SetClass(ref m_SizeCallback, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_SizeCallback, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the callback of size when sizeType assined as Callback.
|
||||
@@ -199,7 +199,7 @@ namespace XCharts
|
||||
public SymbolSizeCallback selectedSizeCallback
|
||||
{
|
||||
get { return m_SelectedSizeCallback; }
|
||||
set { if (PropertyUtility.SetClass(ref m_SelectedSizeCallback, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_SelectedSizeCallback, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the index start to show symbol.
|
||||
@@ -208,7 +208,7 @@ namespace XCharts
|
||||
public int startIndex
|
||||
{
|
||||
get { return m_StartIndex; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_StartIndex, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_StartIndex, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the interval of show symbol.
|
||||
@@ -217,7 +217,7 @@ namespace XCharts
|
||||
public int interval
|
||||
{
|
||||
get { return m_Interval; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Interval, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// whether to show the last symbol.
|
||||
@@ -226,7 +226,7 @@ namespace XCharts
|
||||
public bool forceShowLast
|
||||
{
|
||||
get { return m_ForceShowLast; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_ForceShowLast, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ForceShowLast, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the gap of symbol and line segment.
|
||||
@@ -235,7 +235,7 @@ namespace XCharts
|
||||
public float gap
|
||||
{
|
||||
get { return m_Gap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetVerticesDirty(); }
|
||||
}
|
||||
private List<float> m_AnimationSize = new List<float>() { 0, 5, 10 };
|
||||
/// <summary>
|
||||
@@ -249,26 +249,25 @@ namespace XCharts
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSize(List<float> data)
|
||||
public float GetSize(List<float> data, float themeSize)
|
||||
{
|
||||
if (data == null) return size;
|
||||
switch (m_SizeType)
|
||||
{
|
||||
case SerieSymbolSizeType.Custom:
|
||||
return size;
|
||||
return size == 0 ? themeSize : size;
|
||||
case SerieSymbolSizeType.FromData:
|
||||
if (dataIndex >= 0 && dataIndex < data.Count)
|
||||
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
|
||||
{
|
||||
return data[dataIndex] * m_DataScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
return size;
|
||||
return size == 0 ? themeSize : size;
|
||||
}
|
||||
case SerieSymbolSizeType.Callback:
|
||||
if (sizeCallback != null) return sizeCallback(data);
|
||||
else return size;
|
||||
default: return size;
|
||||
if (data != null && sizeCallback != null) return sizeCallback(data);
|
||||
else return size == 0 ? themeSize : size;
|
||||
default: return size == 0 ? themeSize : size;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,26 +276,25 @@ namespace XCharts
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public float GetSelectedSize(List<float> data)
|
||||
public float GetSelectedSize(List<float> data, float themeSelectedSize)
|
||||
{
|
||||
if (data == null) return selectedSize;
|
||||
switch (m_SizeType)
|
||||
{
|
||||
case SerieSymbolSizeType.Custom:
|
||||
return selectedSize;
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
case SerieSymbolSizeType.FromData:
|
||||
if (dataIndex >= 0 && dataIndex < data.Count)
|
||||
if (data != null && dataIndex >= 0 && dataIndex < data.Count)
|
||||
{
|
||||
return data[dataIndex] * m_SelectedDataScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
return selectedSize;
|
||||
return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
}
|
||||
case SerieSymbolSizeType.Callback:
|
||||
if (selectedSizeCallback != null) return selectedSizeCallback(data);
|
||||
else return selectedSize;
|
||||
default: return selectedSize;
|
||||
if (data != null && selectedSizeCallback != null) return selectedSizeCallback(data);
|
||||
else return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
default: return selectedSize == 0 ? themeSelectedSize : selectedSize;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -33,7 +33,7 @@ namespace XCharts
|
||||
public bool enable
|
||||
{
|
||||
get { return m_Enable; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Enable, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Enable, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Set the maximum width. A default of 0 indicates automatic fetch; otherwise, custom.
|
||||
@@ -43,7 +43,7 @@ namespace XCharts
|
||||
public float maxWidth
|
||||
{
|
||||
get { return m_MaxWidth; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_MaxWidth, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_MaxWidth, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// White pixel distance at both ends.
|
||||
@@ -53,7 +53,7 @@ namespace XCharts
|
||||
public float gap
|
||||
{
|
||||
get { return m_Gap; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Gap, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Gap, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Suffixes when the length exceeds.
|
||||
@@ -63,11 +63,10 @@ namespace XCharts
|
||||
public string suffix
|
||||
{
|
||||
get { return m_Suffix; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Suffix, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Suffix, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
private Text m_RelatedText;
|
||||
private TextGenerationSettings m_RelatedTextSettings;
|
||||
private ChartText m_RelatedText;
|
||||
private float m_RelatedTextWidth = 0;
|
||||
|
||||
public TextLimit Clone()
|
||||
@@ -88,10 +87,9 @@ namespace XCharts
|
||||
suffix = textLimit.suffix;
|
||||
}
|
||||
|
||||
public void SetRelatedText(Text txt, float labelWidth)
|
||||
public void SetRelatedText(ChartText txt, float labelWidth)
|
||||
{
|
||||
m_RelatedText = txt;
|
||||
m_RelatedTextSettings = txt.GetGenerationSettings(Vector2.zero);
|
||||
m_RelatedTextWidth = labelWidth;
|
||||
}
|
||||
|
||||
@@ -104,8 +102,8 @@ namespace XCharts
|
||||
{
|
||||
if (m_Enable)
|
||||
{
|
||||
float len = m_RelatedText.cachedTextGenerator.GetPreferredWidth(content, m_RelatedTextSettings);
|
||||
float suffixLen = m_RelatedText.cachedTextGenerator.GetPreferredWidth(suffix, m_RelatedTextSettings);
|
||||
float len = m_RelatedText.GetPreferredWidth(content);
|
||||
float suffixLen = m_RelatedText.GetPreferredWidth(suffix);
|
||||
if (len >= checkWidth - m_Gap * 2)
|
||||
{
|
||||
return content.Substring(0, GetAdaptLength(content, suffixLen)) + suffix;
|
||||
@@ -133,7 +131,7 @@ namespace XCharts
|
||||
float len = 0;
|
||||
while (len != limit && middle != start)
|
||||
{
|
||||
len = m_RelatedText.cachedTextGenerator.GetPreferredWidth(content.Substring(0, middle), m_RelatedTextSettings);
|
||||
len = m_RelatedText.GetPreferredWidth(content.Substring(0, middle));
|
||||
if (len < limit)
|
||||
{
|
||||
start = middle;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -18,18 +21,20 @@ namespace XCharts
|
||||
public class TextStyle : SubComponent
|
||||
{
|
||||
[SerializeField] private Font m_Font;
|
||||
|
||||
[SerializeField] private float m_Rotate = 0;
|
||||
[SerializeField] private Vector2 m_Offset = Vector2.zero;
|
||||
[SerializeField] private Color m_Color = Color.clear;
|
||||
[SerializeField] private Color m_BackgroundColor = Color.clear;
|
||||
[SerializeField] private int m_FontSize = 18;
|
||||
[SerializeField] private int m_FontSize = 0;
|
||||
[SerializeField] private FontStyle m_FontStyle = FontStyle.Normal;
|
||||
[SerializeField] private float m_LineSpacing = 1f;
|
||||
// [SerializeField] private float m_PaddingLeft = 0f;
|
||||
// [SerializeField] private float m_PaddingRight = 0f;
|
||||
// [SerializeField] private float m_PaddingTop = 0f;
|
||||
// [SerializeField] private float m_PaddingBottom = 0f;
|
||||
|
||||
[SerializeField] private TextAnchor m_Alignment = TextAnchor.MiddleCenter;
|
||||
#if dUI_TextMeshPro
|
||||
[SerializeField] private TMP_FontAsset m_TMPFont;
|
||||
[SerializeField] private FontStyles m_TMPFontStyle = FontStyles.Normal;
|
||||
[SerializeField] private TextAlignmentOptions m_TMPAlignment = TextAlignmentOptions.Left;
|
||||
#endif
|
||||
/// <summary>
|
||||
/// Rotation of text.
|
||||
/// 文本的旋转。
|
||||
@@ -38,7 +43,7 @@ namespace XCharts
|
||||
public float rotate
|
||||
{
|
||||
get { return m_Rotate; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the offset of position.
|
||||
@@ -48,7 +53,7 @@ namespace XCharts
|
||||
public Vector2 offset
|
||||
{
|
||||
get { return m_Offset; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Offset, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public Vector3 offsetv3 { get { return new Vector3(m_Offset.x, m_Offset.y, 0); } }
|
||||
@@ -61,7 +66,7 @@ namespace XCharts
|
||||
public Color color
|
||||
{
|
||||
get { return m_Color; }
|
||||
set { if (PropertyUtility.SetColor(ref m_Color, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_Color, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
@@ -71,7 +76,7 @@ namespace XCharts
|
||||
public Color backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtility.SetColor(ref m_BackgroundColor, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the font of text. When `null`, the theme's font is used by default.
|
||||
@@ -81,7 +86,7 @@ namespace XCharts
|
||||
public Font font
|
||||
{
|
||||
get { return m_Font; }
|
||||
set { if (PropertyUtility.SetClass(ref m_Font, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_Font, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font size.
|
||||
@@ -91,7 +96,7 @@ namespace XCharts
|
||||
public int fontSize
|
||||
{
|
||||
get { return m_FontSize; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// font style.
|
||||
@@ -101,7 +106,7 @@ namespace XCharts
|
||||
public FontStyle fontStyle
|
||||
{
|
||||
get { return m_FontStyle; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FontStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// text line spacing.
|
||||
@@ -111,8 +116,34 @@ namespace XCharts
|
||||
public float lineSpacing
|
||||
{
|
||||
get { return m_LineSpacing; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_LineSpacing, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineSpacing, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 对齐方式。
|
||||
/// </summary>
|
||||
public TextAnchor alignment
|
||||
{
|
||||
get { return m_Alignment; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Alignment, value)) SetComponentDirty(); }
|
||||
}
|
||||
#if dUI_TextMeshPro
|
||||
public TMP_FontAsset tmpFont
|
||||
{
|
||||
get { return m_TMPFont; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TMPFont, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public FontStyles tmpFontStyle
|
||||
{
|
||||
get { return m_TMPFontStyle; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TMPFontStyle, value)) SetComponentDirty(); }
|
||||
}
|
||||
public TextAlignmentOptions tmpAlignment
|
||||
{
|
||||
get { return m_TMPAlignment; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TMPAlignment, value)) SetComponentDirty(); }
|
||||
}
|
||||
#endif
|
||||
|
||||
public TextStyle()
|
||||
{
|
||||
@@ -143,5 +174,44 @@ namespace XCharts
|
||||
this.color = color;
|
||||
this.rotate = rotate;
|
||||
}
|
||||
|
||||
public void Copy(TextStyle textStyle)
|
||||
{
|
||||
font = textStyle.font;
|
||||
rotate = textStyle.rotate;
|
||||
offset = textStyle.offset;
|
||||
color = textStyle.color;
|
||||
backgroundColor = textStyle.backgroundColor;
|
||||
fontSize = textStyle.fontSize;
|
||||
fontStyle = textStyle.fontStyle;
|
||||
lineSpacing = textStyle.lineSpacing;
|
||||
alignment = textStyle.alignment;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPFont = textStyle.tmpFont;
|
||||
m_TMPAlignment = textStyle.tmpAlignment;
|
||||
m_TMPFontStyle = textStyle.tmpFontStyle;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void UpdateAlignmentByLocation(Location location)
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPAlignment = location.runtimeTMPTextAlignment;
|
||||
#else
|
||||
m_Alignment = location.runtimeTextAlignment;
|
||||
#endif
|
||||
}
|
||||
|
||||
public Color GetColor(Color defaultColor)
|
||||
{
|
||||
if (ChartHelper.IsClearColor(color)) return defaultColor;
|
||||
else return color;
|
||||
}
|
||||
|
||||
public int GetFontSize(ComponentTheme defaultTheme)
|
||||
{
|
||||
if(fontSize == 0) return defaultTheme.fontSize;
|
||||
else return fontSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
@@ -22,7 +22,7 @@ namespace XCharts
|
||||
{
|
||||
[SerializeField] private bool m_Show;
|
||||
[FormerlySerializedAs("m_textStyle")]
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle(18);
|
||||
[SerializeField] private TextStyle m_TextStyle = new TextStyle();
|
||||
|
||||
/// <summary>
|
||||
/// Whether to show title.
|
||||
@@ -31,7 +31,7 @@ namespace XCharts
|
||||
public bool show
|
||||
{
|
||||
get { return m_Show; }
|
||||
set { if (PropertyUtility.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Show, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,7 +41,7 @@ namespace XCharts
|
||||
public TextStyle textStyle
|
||||
{
|
||||
get { return m_TextStyle; }
|
||||
set { if (PropertyUtility.SetClass(ref m_TextStyle, value, true)) SetComponentDirty(); }
|
||||
set { if (PropertyUtil.SetClass(ref m_TextStyle, value, true)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public override bool componentDirty { get { return m_ComponentDirty || textStyle.componentDirty; } }
|
||||
@@ -52,7 +52,7 @@ namespace XCharts
|
||||
textStyle.ClearComponentDirty();
|
||||
}
|
||||
|
||||
public Text runtimeText { get; set; }
|
||||
public ChartText runtimeText { get; set; }
|
||||
|
||||
public bool IsInited()
|
||||
{
|
||||
@@ -61,26 +61,28 @@ namespace XCharts
|
||||
|
||||
public void SetActive(bool active)
|
||||
{
|
||||
if (runtimeText)
|
||||
if (runtimeText != null)
|
||||
{
|
||||
ChartHelper.SetActive(runtimeText, active);
|
||||
runtimeText.SetActive(active);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdatePosition(Vector3 pos)
|
||||
{
|
||||
if (runtimeText)
|
||||
if (runtimeText != null)
|
||||
{
|
||||
runtimeText.transform.localPosition = pos + new Vector3(m_TextStyle.offset.x, m_TextStyle.offset.y);
|
||||
runtimeText.SetLocalPosition(pos + new Vector3(m_TextStyle.offset.x, m_TextStyle.offset.y));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetText(string text)
|
||||
{
|
||||
if (runtimeText && !runtimeText.text.Equals(text))
|
||||
if (runtimeText == null) return;
|
||||
var oldText = runtimeText.GetText();
|
||||
if (oldText != null && !oldText.Equals(text))
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(textStyle.color)) runtimeText.color = textStyle.color;
|
||||
runtimeText.text = text;
|
||||
if (!ChartHelper.IsClearColor(textStyle.color)) runtimeText.SetColor(textStyle.color);
|
||||
runtimeText.SetText(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class SubComponent : ChartComponent
|
||||
{
|
||||
}
|
||||
}
|
||||
8
Runtime/Component/Theme.meta
Normal file
8
Runtime/Component/Theme.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf2fdcbe222404d7b869946ef6fee032
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
255
Runtime/Component/Theme/AxisTheme.cs
Normal file
255
Runtime/Component/Theme/AxisTheme.cs
Normal file
@@ -0,0 +1,255 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class BaseAxisTheme : ComponentTheme
|
||||
{
|
||||
[SerializeField] protected LineStyle.Type m_LineType = LineStyle.Type.Solid;
|
||||
[SerializeField] protected float m_LineWidth = 1f;
|
||||
[SerializeField] protected float m_LineLength = 0f;
|
||||
[SerializeField] protected Color32 m_LineColor;
|
||||
[SerializeField] protected LineStyle.Type m_SplitLineType = LineStyle.Type.Dashed;
|
||||
[SerializeField] protected float m_SplitLineWidth = 1f;
|
||||
[SerializeField] protected float m_SplitLineLength = 0f;
|
||||
[SerializeField] protected Color32 m_SplitLineColor;
|
||||
[SerializeField] protected float m_TickWidth = 1f;
|
||||
[SerializeField] protected float m_TickLength = 5f;
|
||||
[SerializeField] protected Color32 m_TickColor;
|
||||
[SerializeField] protected List<Color32> m_SplitAreaColors = new List<Color32>();
|
||||
|
||||
/// <summary>
|
||||
/// the type of line.
|
||||
/// 坐标轴线类型。
|
||||
/// </summary>
|
||||
public LineStyle.Type lineType
|
||||
{
|
||||
get { return m_LineType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of line.
|
||||
/// 坐标轴线宽。
|
||||
/// </summary>
|
||||
public float lineWidth
|
||||
{
|
||||
get { return m_LineWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the length of line.
|
||||
/// 坐标轴线长。
|
||||
/// </summary>
|
||||
public float lineLength
|
||||
{
|
||||
get { return m_LineLength; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of line.
|
||||
/// 坐标轴线颜色。
|
||||
/// </summary>
|
||||
public Color32 lineColor
|
||||
{
|
||||
get { return m_LineColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_LineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the type of split line.
|
||||
/// 分割线线类型。
|
||||
/// </summary>
|
||||
public LineStyle.Type splitLineType
|
||||
{
|
||||
get { return m_SplitLineType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SplitLineType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of split line.
|
||||
/// 分割线线宽。
|
||||
/// </summary>
|
||||
public float splitLineWidth
|
||||
{
|
||||
get { return m_SplitLineWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SplitLineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the length of split line.
|
||||
/// 分割线线长。
|
||||
/// </summary>
|
||||
public float splitLineLength
|
||||
{
|
||||
get { return m_SplitLineLength; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_SplitLineLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of line.
|
||||
/// 分割线线颜色。
|
||||
/// </summary>
|
||||
public Color32 splitLineColor
|
||||
{
|
||||
get { return m_SplitLineColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_SplitLineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the length of tick.
|
||||
/// 刻度线线长。
|
||||
/// </summary>
|
||||
public float tickLength
|
||||
{
|
||||
get { return m_TickLength; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TickLength, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of tick.
|
||||
/// 刻度线线宽。
|
||||
/// </summary>
|
||||
public float tickWidth
|
||||
{
|
||||
get { return m_TickWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TickWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of tick.
|
||||
/// 坐标轴线颜色。
|
||||
/// </summary>
|
||||
public Color32 tickColor
|
||||
{
|
||||
get { return m_TickColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_TickColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public List<Color32> splitAreaColors
|
||||
{
|
||||
get { return m_SplitAreaColors; }
|
||||
set { if (value != null) { m_SplitAreaColors = value; SetVerticesDirty(); } }
|
||||
}
|
||||
|
||||
public BaseAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_FontSize = XChartsSettings.fontSizeLv4;
|
||||
m_LineType = XChartsSettings.axisLineType;
|
||||
m_LineWidth = XChartsSettings.axisLineWidth;
|
||||
m_LineLength = 0;
|
||||
m_SplitLineType = XChartsSettings.axisSplitLineType;
|
||||
m_SplitLineWidth = XChartsSettings.axisSplitLineWidth;
|
||||
m_SplitLineLength = 0;
|
||||
m_TickWidth = XChartsSettings.axisTickWidth;
|
||||
m_TickLength = XChartsSettings.axisTickLength;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_LineColor = ColorUtil.GetColor("#514D4D");
|
||||
m_TickColor = ColorUtil.GetColor("#514D4D");
|
||||
m_SplitLineColor = ColorUtil.GetColor("#51515120");
|
||||
m_SplitAreaColors = new List<Color32>{
|
||||
new Color32(250,250,250,77),
|
||||
new Color32(200,200,200,77)
|
||||
};
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_LineColor = ColorUtil.GetColor("#514D4D");
|
||||
m_TickColor = ColorUtil.GetColor("#514D4D");
|
||||
m_SplitLineColor = ColorUtil.GetColor("#51515120");
|
||||
m_SplitAreaColors = new List<Color32>{
|
||||
new Color32(250,250,250,77),
|
||||
new Color32(200,200,200,77)
|
||||
};
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_LineColor = ColorUtil.GetColor("#B9B8CE");
|
||||
m_TickColor = ColorUtil.GetColor("#B9B8CE");
|
||||
m_SplitLineColor = ColorUtil.GetColor("#484753");
|
||||
m_SplitAreaColors = new List<Color32>{
|
||||
new Color32(255,255,255,(byte)(0.02f * 255)),
|
||||
new Color32(255,255,255,(byte)(0.05f * 255))
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Copy(BaseAxisTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_LineType = theme.lineType;
|
||||
m_LineWidth = theme.lineWidth;
|
||||
m_LineLength = theme.lineLength;
|
||||
m_LineColor = theme.lineColor;
|
||||
m_SplitLineType = theme.splitLineType;
|
||||
m_SplitLineWidth = theme.splitLineWidth;
|
||||
m_SplitLineLength = theme.splitLineLength;
|
||||
m_SplitLineColor = theme.splitLineColor;
|
||||
m_TickWidth = theme.tickWidth;
|
||||
m_TickLength = theme.tickLength;
|
||||
m_TickColor = theme.tickColor;
|
||||
ChartHelper.CopyList(m_SplitAreaColors, theme.splitAreaColors);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class AxisTheme : BaseAxisTheme
|
||||
{
|
||||
public AxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class RadiusAxisTheme : BaseAxisTheme
|
||||
{
|
||||
public RadiusAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class AngleAxisTheme : BaseAxisTheme
|
||||
{
|
||||
public AngleAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class PolarAxisTheme : BaseAxisTheme
|
||||
{
|
||||
public PolarAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class RadarAxisTheme : BaseAxisTheme
|
||||
{
|
||||
public RadarAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_SplitAreaColors.Clear();
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Dark:
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#6f6f6f"));
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#606060"));
|
||||
break;
|
||||
case Theme.Default:
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#f6f6f6"));
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#e7e7e7"));
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#f6f6f6"));
|
||||
m_SplitAreaColors.Add(ChartTheme.GetColor("#e7e7e7"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/AxisTheme.cs.meta
Normal file
11
Runtime/Component/Theme/AxisTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aefd22e76a6f642c9985b1a29e389858
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
527
Runtime/Component/Theme/ChartTheme.cs
Normal file
527
Runtime/Component/Theme/ChartTheme.cs
Normal file
@@ -0,0 +1,527 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Text;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
/// <summary>
|
||||
/// 主题
|
||||
/// </summary>
|
||||
public enum Theme
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认主题。
|
||||
/// </summary>
|
||||
Default,
|
||||
/// <summary>
|
||||
/// 亮主题。
|
||||
/// </summary>
|
||||
Light,
|
||||
/// <summary>
|
||||
/// 暗主题。
|
||||
/// </summary>
|
||||
Dark,
|
||||
/// <summary>
|
||||
/// 自定义主题。
|
||||
/// </summary>
|
||||
Custom,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
/// <summary>
|
||||
/// Theme.
|
||||
/// 主题相关配置。
|
||||
/// </summary>
|
||||
public class ChartTheme : ScriptableObject
|
||||
{
|
||||
[SerializeField] private Theme m_Theme = Theme.Default;
|
||||
[SerializeField] private string m_ThemeName = Theme.Default.ToString();
|
||||
[SerializeField] private Font m_Font;
|
||||
#if dUI_TextMeshPro
|
||||
[SerializeField] private TMP_FontAsset m_TMPFont;
|
||||
#endif
|
||||
|
||||
[SerializeField] private Color32 m_ContrastColor;
|
||||
[SerializeField] private Color32 m_BackgroundColor;
|
||||
|
||||
[SerializeField] private List<Color32> m_ColorPalette = new List<Color32>(13);
|
||||
|
||||
[SerializeField] private ComponentTheme m_Common;
|
||||
[SerializeField] private TitleTheme m_Title;
|
||||
[SerializeField] private SubTitleTheme m_SubTitle;
|
||||
[SerializeField] private LegendTheme m_Legend;
|
||||
[SerializeField] private AxisTheme m_Axis;
|
||||
[SerializeField] private RadiusAxisTheme m_RadiusAxis;
|
||||
[SerializeField] private AngleAxisTheme m_AngleAxis;
|
||||
[SerializeField] private PolarAxisTheme m_Polar;
|
||||
[SerializeField] private GaugeAxisTheme m_Gauge;
|
||||
[SerializeField] private RadarAxisTheme m_Radar;
|
||||
[SerializeField] private TooltipTheme m_Tooltip;
|
||||
[SerializeField] private DataZoomTheme m_DataZoom;
|
||||
[SerializeField] private VisualMapTheme m_VisualMap;
|
||||
[SerializeField] private SerieTheme m_Serie;
|
||||
|
||||
/// <summary>
|
||||
/// the theme of chart.
|
||||
/// 主题类型。
|
||||
/// </summary>
|
||||
public Theme theme
|
||||
{
|
||||
get { return m_Theme; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_Theme, value)) SetComponentDirty(); }
|
||||
}
|
||||
public string themeName
|
||||
{
|
||||
get { return m_ThemeName; }
|
||||
set { if (PropertyUtil.SetClass(ref m_ThemeName, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// the contrast color of chart.
|
||||
/// 对比色。
|
||||
/// </summary>
|
||||
public Color32 contrastColor
|
||||
{
|
||||
get { return m_ContrastColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_ContrastColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the background color of chart.
|
||||
/// 背景颜色。
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The color list of palette. If no color is set in series, the colors would be adopted sequentially and circularly from this list as the colors of series.
|
||||
/// 调色盘颜色列表。如果系列没有设置颜色,则会依次循环从该列表中取颜色作为系列颜色。
|
||||
/// </summary>
|
||||
public List<Color32> colorPalette { get { return m_ColorPalette; } set { m_ColorPalette = value; SetVerticesDirty(); } }
|
||||
public ComponentTheme common { get { return m_Common; } set { m_Common = value; SetComponentDirty(); } }
|
||||
public TitleTheme title { get { return m_Title; } set { m_Title = value; SetComponentDirty(); } }
|
||||
public SubTitleTheme subTitle { get { return m_SubTitle; } set { m_SubTitle = value; SetComponentDirty(); } }
|
||||
public LegendTheme legend { get { return m_Legend; } set { m_Legend = value; SetComponentDirty(); } }
|
||||
public AxisTheme axis { get { return m_Axis; } set { m_Axis = value; SetAllDirty(); } }
|
||||
public RadiusAxisTheme radiusAxis { get { return m_RadiusAxis; } set { m_RadiusAxis = value; SetAllDirty(); } }
|
||||
public AngleAxisTheme angleAxis { get { return m_AngleAxis; } set { m_AngleAxis = value; SetAllDirty(); } }
|
||||
public PolarAxisTheme polar { get { return m_Polar; } set { m_Polar = value; SetAllDirty(); } }
|
||||
public GaugeAxisTheme gauge { get { return m_Gauge; } set { m_Gauge = value; SetAllDirty(); } }
|
||||
public RadarAxisTheme radar { get { return m_Radar; } set { m_Radar = value; SetAllDirty(); } }
|
||||
public TooltipTheme tooltip { get { return m_Tooltip; } set { m_Tooltip = value; SetAllDirty(); } }
|
||||
public DataZoomTheme dataZoom { get { return m_DataZoom; } set { m_DataZoom = value; SetAllDirty(); } }
|
||||
public VisualMapTheme visualMap { get { return m_VisualMap; } set { m_VisualMap = value; SetAllDirty(); } }
|
||||
public SerieTheme serie { get { return m_Serie; } set { m_Serie = value; SetVerticesDirty(); } }
|
||||
#if dUI_TextMeshPro
|
||||
/// <summary>
|
||||
/// the font of chart text。
|
||||
/// 字体。
|
||||
/// </summary>
|
||||
public TMP_FontAsset tmpFont
|
||||
{
|
||||
get { return m_TMPFont; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtil.SetClass(ref m_TMPFont, value))
|
||||
{
|
||||
SetComponentDirty();
|
||||
SyncTMPFontToSubComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/// <summary>
|
||||
/// the font of chart text。
|
||||
/// 字体。
|
||||
/// </summary>
|
||||
public Font font
|
||||
{
|
||||
get { return m_Font; }
|
||||
set
|
||||
{
|
||||
if (PropertyUtil.SetClass(ref m_Font, value))
|
||||
{
|
||||
SetComponentDirty();
|
||||
SyncFontToSubComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[NonSerialized] protected bool m_VertsDirty;
|
||||
[NonSerialized] protected bool m_ComponentDirty;
|
||||
public virtual bool vertsDirty { get { return m_VertsDirty; } }
|
||||
public virtual bool componentDirty { get { return m_ComponentDirty; } }
|
||||
public bool anyDirty { get { return vertsDirty || componentDirty; } }
|
||||
|
||||
public void SetDefaultFont()
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
tmpFont = XChartsSettings.tmpFont;
|
||||
SyncTMPFontToSubComponent();
|
||||
#else
|
||||
font = XChartsSettings.font;
|
||||
SyncFontToSubComponent();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color of the specified index from the palette.
|
||||
/// 获得调色盘对应系列索引的颜色值。
|
||||
/// </summary>
|
||||
/// <param name="index">编号索引</param>
|
||||
/// <returns>the color,or Color.clear when failed.颜色值,失败时返回Color.clear</returns>
|
||||
public Color32 GetColor(int index)
|
||||
{
|
||||
if (index < 0) index = 0;
|
||||
var newIndex = index < m_ColorPalette.Count ? index : index % m_ColorPalette.Count;
|
||||
if (newIndex < m_ColorPalette.Count)
|
||||
return m_ColorPalette[newIndex];
|
||||
else return Color.clear;
|
||||
}
|
||||
|
||||
public void CheckWarning(StringBuilder sb)
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
if (m_TMPFont == null)
|
||||
{
|
||||
sb.AppendFormat("warning:theme->tmpFont is null\n");
|
||||
}
|
||||
#else
|
||||
if (m_Font == null)
|
||||
{
|
||||
sb.AppendFormat("warning:theme->font is null\n");
|
||||
}
|
||||
#endif
|
||||
if (m_ColorPalette.Count == 0)
|
||||
{
|
||||
sb.AppendFormat("warning:theme->colorPalette is empty\n");
|
||||
}
|
||||
for (int i = 0; i < m_ColorPalette.Count; i++)
|
||||
{
|
||||
if (!ChartHelper.IsClearColor(m_ColorPalette[i]) && m_ColorPalette[i].a == 0)
|
||||
sb.AppendFormat("warning:theme->colorPalette[{0}] alpha = 0\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<int, string> _colorDic = new Dictionary<int, string>();
|
||||
/// <summary>
|
||||
/// Gets the hexadecimal color string of the specified index from the palette.
|
||||
/// 获得指定索引的十六进制颜色值字符串。
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public string GetColorStr(int index)
|
||||
{
|
||||
if (index < 0)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
index = index % m_ColorPalette.Count;
|
||||
if (_colorDic.ContainsKey(index)) return _colorDic[index];
|
||||
else
|
||||
{
|
||||
_colorDic[index] = ColorUtility.ToHtmlStringRGBA(GetColor(index));
|
||||
return _colorDic[index];
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyTheme(Theme theme)
|
||||
{
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Dark:
|
||||
CopyTheme(ChartTheme.Dark);
|
||||
break;
|
||||
case Theme.Default:
|
||||
CopyTheme(ChartTheme.Default);
|
||||
break;
|
||||
case Theme.Light:
|
||||
CopyTheme(ChartTheme.Light);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// copy all configurations from theme.
|
||||
/// 复制主题的所有配置。
|
||||
/// </summary>
|
||||
/// <param name="theme"></param>
|
||||
public void CopyTheme(ChartTheme theme)
|
||||
{
|
||||
m_Theme = theme.theme;
|
||||
m_ThemeName = theme.themeName;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPFont = theme.tmpFont;
|
||||
#endif
|
||||
m_Font = theme.m_Font;
|
||||
m_ContrastColor = theme.contrastColor;
|
||||
m_BackgroundColor = theme.m_BackgroundColor;
|
||||
m_Common.Copy(theme.common);
|
||||
m_Legend.Copy(theme.m_Legend);
|
||||
m_Title.Copy(theme.m_Title);
|
||||
m_SubTitle.Copy(theme.m_SubTitle);
|
||||
m_Axis.Copy(theme.axis);
|
||||
m_RadiusAxis.Copy(theme.radiusAxis);
|
||||
m_AngleAxis.Copy(theme.angleAxis);
|
||||
m_Polar.Copy(theme.polar);
|
||||
m_Gauge.Copy(theme.gauge);
|
||||
m_Tooltip.Copy(theme.tooltip);
|
||||
m_DataZoom.Copy(theme.dataZoom);
|
||||
m_VisualMap.Copy(theme.visualMap);
|
||||
m_Serie.Copy(theme.serie);
|
||||
ChartHelper.CopyList(m_ColorPalette, theme.colorPalette);
|
||||
SetAllDirty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all custom configurations.
|
||||
/// 重置,清除所有自定义配置。
|
||||
/// </summary>
|
||||
public void ResetTheme()
|
||||
{
|
||||
switch (m_Theme)
|
||||
{
|
||||
case Theme.Default: CopyTheme(Default); break;
|
||||
case Theme.Light: CopyTheme(Light); break;
|
||||
case Theme.Dark: CopyTheme(Dark); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// default theme.
|
||||
/// 默认主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ChartTheme Default
|
||||
{
|
||||
get
|
||||
{
|
||||
var theme = ScriptableObject.CreateInstance<ChartTheme>();
|
||||
theme.theme = Theme.Default;
|
||||
theme.themeName = Theme.Default.ToString();
|
||||
theme.contrastColor = ColorUtil.GetColor("#514D4D");
|
||||
theme.backgroundColor = new Color32(255, 255, 255, 255);
|
||||
theme.colorPalette = new List<Color32>
|
||||
{
|
||||
new Color32(194, 53, 49, 255),
|
||||
new Color32(47, 69, 84, 255),
|
||||
new Color32(97, 160, 168, 255),
|
||||
new Color32(212, 130, 101, 255),
|
||||
new Color32(145, 199, 174, 255),
|
||||
new Color32(116, 159, 131, 255),
|
||||
new Color32(202, 134, 34, 255),
|
||||
new Color32(189, 162, 154, 255),
|
||||
new Color32(110, 112, 116, 255),
|
||||
new Color32(84, 101, 112, 255),
|
||||
new Color32(196, 204, 211, 255)
|
||||
};
|
||||
InitChartComponentTheme(theme);
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// light theme.
|
||||
/// 亮主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ChartTheme Light
|
||||
{
|
||||
get
|
||||
{
|
||||
var theme = ScriptableObject.CreateInstance<ChartTheme>();
|
||||
theme.theme = Theme.Light;
|
||||
theme.themeName = Theme.Light.ToString();
|
||||
theme.contrastColor = ColorUtil.GetColor("#514D4D");
|
||||
theme.backgroundColor = new Color32(255, 255, 255, 255);
|
||||
theme.colorPalette = new List<Color32>
|
||||
{
|
||||
ColorUtil.GetColor("#37A2DA"),
|
||||
ColorUtil.GetColor("#32C5E9"),
|
||||
ColorUtil.GetColor("#67E0E3"),
|
||||
ColorUtil.GetColor("#9FE6B8"),
|
||||
ColorUtil.GetColor("#FFDB5C"),
|
||||
ColorUtil.GetColor("#ff9f7f"),
|
||||
ColorUtil.GetColor("#fb7293"),
|
||||
ColorUtil.GetColor("#E062AE"),
|
||||
ColorUtil.GetColor("#E690D1"),
|
||||
ColorUtil.GetColor("#e7bcf3"),
|
||||
ColorUtil.GetColor("#9d96f5"),
|
||||
ColorUtil.GetColor("#8378EA"),
|
||||
ColorUtil.GetColor("#96BFFF"),
|
||||
};
|
||||
InitChartComponentTheme(theme);
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// dark theme.
|
||||
/// 暗主题。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public static ChartTheme Dark
|
||||
{
|
||||
get
|
||||
{
|
||||
var theme = ScriptableObject.CreateInstance<ChartTheme>();
|
||||
theme.name = Theme.Dark.ToString();
|
||||
theme.theme = Theme.Dark;
|
||||
theme.themeName = Theme.Dark.ToString();
|
||||
theme.contrastColor = ColorUtil.GetColor("#B9B8CE");
|
||||
theme.backgroundColor = ColorUtil.GetColor("#100C2A");
|
||||
theme.colorPalette = new List<Color32>
|
||||
{
|
||||
ColorUtil.GetColor("#4992ff"),
|
||||
ColorUtil.GetColor("#7cffb2"),
|
||||
ColorUtil.GetColor("#fddd60"),
|
||||
ColorUtil.GetColor("#ff6e76"),
|
||||
ColorUtil.GetColor("#58d9f9"),
|
||||
ColorUtil.GetColor("#05c091"),
|
||||
ColorUtil.GetColor("#ff8a45"),
|
||||
ColorUtil.GetColor("#8d48e3"),
|
||||
ColorUtil.GetColor("#dd79ff"),
|
||||
};
|
||||
InitChartComponentTheme(theme);
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
||||
public static ChartTheme EmptyTheme
|
||||
{
|
||||
get
|
||||
{
|
||||
var theme = ScriptableObject.CreateInstance<ChartTheme>();
|
||||
theme.name = Theme.Custom.ToString();
|
||||
theme.theme = Theme.Custom;
|
||||
theme.themeName = Theme.Custom.ToString();
|
||||
theme.contrastColor = Color.clear;
|
||||
theme.backgroundColor = Color.clear;
|
||||
theme.colorPalette = new List<Color32>();
|
||||
InitChartComponentTheme(theme);
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
|
||||
public void SyncFontToSubComponent()
|
||||
{
|
||||
common.font = font;
|
||||
title.font = font;
|
||||
subTitle.font = font;
|
||||
legend.font = font;
|
||||
axis.font = font;
|
||||
radiusAxis.font = font;
|
||||
angleAxis.font = font;
|
||||
polar.font = font;
|
||||
gauge.font = font;
|
||||
radar.font = font;
|
||||
tooltip.font = font;
|
||||
dataZoom.font = font;
|
||||
visualMap.font = font;
|
||||
}
|
||||
|
||||
#if dUI_TextMeshPro
|
||||
public void SyncTMPFontToSubComponent()
|
||||
{
|
||||
common.tmpFont = tmpFont;
|
||||
title.tmpFont = tmpFont;
|
||||
subTitle.tmpFont = tmpFont;
|
||||
legend.tmpFont = tmpFont;
|
||||
axis.tmpFont = tmpFont;
|
||||
radiusAxis.tmpFont = tmpFont;
|
||||
angleAxis.tmpFont = tmpFont;
|
||||
polar.tmpFont = tmpFont;
|
||||
gauge.tmpFont = tmpFont;
|
||||
radar.tmpFont = tmpFont;
|
||||
tooltip.tmpFont = tmpFont;
|
||||
dataZoom.tmpFont = tmpFont;
|
||||
visualMap.tmpFont = tmpFont;
|
||||
}
|
||||
#endif
|
||||
|
||||
private static void InitChartComponentTheme(ChartTheme theme)
|
||||
{
|
||||
theme.common = new ComponentTheme(theme.theme);
|
||||
theme.title = new TitleTheme(theme.theme);
|
||||
theme.subTitle = new SubTitleTheme(theme.theme);
|
||||
theme.legend = new LegendTheme(theme.theme);
|
||||
theme.axis = new AxisTheme(theme.theme);
|
||||
theme.radiusAxis = new RadiusAxisTheme(theme.theme);
|
||||
theme.angleAxis = new AngleAxisTheme(theme.theme);
|
||||
theme.polar = new PolarAxisTheme(theme.theme);
|
||||
theme.gauge = new GaugeAxisTheme(theme.theme);
|
||||
theme.radar = new RadarAxisTheme(theme.theme);
|
||||
theme.tooltip = new TooltipTheme(theme.theme);
|
||||
theme.dataZoom = new DataZoomTheme(theme.theme);
|
||||
theme.visualMap = new VisualMapTheme(theme.theme);
|
||||
theme.serie = new SerieTheme(theme.theme);
|
||||
theme.SetDefaultFont();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert the html string to color.
|
||||
/// 将字符串颜色值转成Color。
|
||||
/// </summary>
|
||||
/// <param name="hexColorStr"></param>
|
||||
/// <returns></returns>
|
||||
public static Color32 GetColor(string hexColorStr)
|
||||
{
|
||||
Color color;
|
||||
ColorUtility.TryParseHtmlString(hexColorStr, out color);
|
||||
return (Color32)color;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
internal virtual void SetVerticesDirty()
|
||||
{
|
||||
m_VertsDirty = true;
|
||||
}
|
||||
|
||||
internal virtual void ClearVerticesDirty()
|
||||
{
|
||||
m_VertsDirty = false;
|
||||
}
|
||||
|
||||
internal virtual void SetComponentDirty()
|
||||
{
|
||||
m_ComponentDirty = true;
|
||||
}
|
||||
|
||||
internal virtual void ClearComponentDirty()
|
||||
{
|
||||
m_ComponentDirty = false;
|
||||
}
|
||||
|
||||
public virtual void ClearDirty()
|
||||
{
|
||||
ClearVerticesDirty();
|
||||
ClearComponentDirty();
|
||||
}
|
||||
|
||||
public virtual void SetAllDirty()
|
||||
{
|
||||
SetVerticesDirty();
|
||||
SetComponentDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/ChartTheme.cs.meta
Normal file
11
Runtime/Component/Theme/ChartTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f28c6b3fb24d49afbe348cfadd0e1c7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
109
Runtime/Component/Theme/ComponentTheme.cs
Normal file
109
Runtime/Component/Theme/ComponentTheme.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class ComponentTheme : MainComponent
|
||||
{
|
||||
[SerializeField] protected Font m_Font;
|
||||
[SerializeField] protected Color m_TextColor;
|
||||
[SerializeField] protected Color m_TextBackgroundColor;
|
||||
[SerializeField] protected int m_FontSize = 18;
|
||||
#if dUI_TextMeshPro
|
||||
[SerializeField] protected TMP_FontAsset m_TMPFont;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// the font of text。
|
||||
/// 字体。
|
||||
/// </summary>
|
||||
public Font font
|
||||
{
|
||||
get { return m_Font; }
|
||||
set { if (PropertyUtil.SetClass(ref m_Font, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
/// 文本颜色。
|
||||
/// </summary>
|
||||
public Color textColor
|
||||
{
|
||||
get { return m_TextColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_TextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
/// 文本颜色。
|
||||
/// </summary>
|
||||
public Color textBackgroundColor
|
||||
{
|
||||
get { return m_TextBackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_TextBackgroundColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the font size of text.
|
||||
/// 文本字体大小。
|
||||
/// </summary>
|
||||
public int fontSize
|
||||
{
|
||||
get { return m_FontSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_FontSize, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
#if dUI_TextMeshPro
|
||||
/// <summary>
|
||||
/// the font of chart text。
|
||||
/// 字体。
|
||||
/// </summary>
|
||||
public TMP_FontAsset tmpFont
|
||||
{
|
||||
get { return m_TMPFont; }
|
||||
set { if (PropertyUtil.SetClass(ref m_TMPFont, value)) SetComponentDirty(); }
|
||||
}
|
||||
#endif
|
||||
|
||||
public ComponentTheme(Theme theme)
|
||||
{
|
||||
m_FontSize = XChartsSettings.fontSizeLv3;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextColor = ColorUtil.GetColor("#514D4D");
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_TextColor = ColorUtil.GetColor("#514D4D");
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextColor = ColorUtil.GetColor("#B9B8CE");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Copy(ComponentTheme theme)
|
||||
{
|
||||
m_Font = theme.font;
|
||||
m_FontSize = theme.fontSize;
|
||||
m_TextColor = theme.textColor;
|
||||
m_TextBackgroundColor = theme.textBackgroundColor;
|
||||
#if dUI_TextMeshPro
|
||||
m_TMPFont = theme.tmpFont;
|
||||
#endif
|
||||
}
|
||||
|
||||
public virtual void Reset(ComponentTheme defaultTheme)
|
||||
{
|
||||
Copy(defaultTheme);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/ComponentTheme.cs.meta
Normal file
11
Runtime/Component/Theme/ComponentTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e78d1c80572324fc0b5cc5c935a2e34c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Runtime/Component/Theme/DataZoomTheme.cs
Normal file
132
Runtime/Component/Theme/DataZoomTheme.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class DataZoomTheme : ComponentTheme
|
||||
{
|
||||
[SerializeField] protected float m_BorderWidth;
|
||||
[SerializeField] protected float m_DataLineWidth;
|
||||
[SerializeField] protected Color32 m_FillerColor;
|
||||
[SerializeField] protected Color32 m_BorderColor;
|
||||
[SerializeField] protected Color32 m_DataLineColor;
|
||||
[SerializeField] protected Color32 m_DataAreaColor;
|
||||
[SerializeField] protected Color32 m_BackgroundColor;
|
||||
|
||||
/// <summary>
|
||||
/// the width of border line.
|
||||
/// 边框线宽。
|
||||
/// </summary>
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of data line.
|
||||
/// 数据阴影线宽。
|
||||
/// </summary>
|
||||
public float dataLineWidth
|
||||
{
|
||||
get { return m_DataLineWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_DataLineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of dataZoom data area.
|
||||
/// 数据区域颜色。
|
||||
/// </summary>
|
||||
public Color32 fillerColor
|
||||
{
|
||||
get { return m_FillerColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_FillerColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the color of dataZoom border.
|
||||
/// 边框颜色。
|
||||
/// </summary>
|
||||
public Color32 borderColor
|
||||
{
|
||||
get { return m_BorderColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of data area line.
|
||||
/// 数据阴影的线条颜色。
|
||||
/// </summary>
|
||||
public Color32 dataLineColor
|
||||
{
|
||||
get { return m_DataLineColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_DataLineColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of data area line.
|
||||
/// 数据阴影的填充颜色。
|
||||
/// </summary>
|
||||
public Color32 dataAreaColor
|
||||
{
|
||||
get { return m_DataAreaColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_DataAreaColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the background color of datazoom.
|
||||
/// 背景颜色。
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public DataZoomTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_BorderWidth = XChartsSettings.dataZoomBorderWidth;
|
||||
m_DataLineWidth = XChartsSettings.dataZoomDataLineWidth;
|
||||
m_BackgroundColor = Color.clear;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextColor = ColorUtil.GetColor("#333");
|
||||
m_FillerColor = new Color32(167, 183, 204, 110);
|
||||
m_BorderColor = ColorUtil.GetColor("#ddd");
|
||||
m_DataLineColor = ColorUtil.GetColor("#2f4554");
|
||||
m_DataAreaColor = new Color32(47, 69, 84, 85);
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_TextColor = ColorUtil.GetColor("#333");
|
||||
m_FillerColor = new Color32(167, 183, 204, 110);
|
||||
m_BorderColor = ColorUtil.GetColor("#ddd");
|
||||
m_DataLineColor = ColorUtil.GetColor("#2f4554");
|
||||
m_DataAreaColor = new Color32(47, 69, 84, 85);
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextColor = ColorUtil.GetColor("#B9B8CE");
|
||||
m_FillerColor = new Color32(135, 163, 206, (byte)(0.2f * 255));
|
||||
m_BorderColor = ColorUtil.GetColor("#71708A");
|
||||
m_DataLineColor = ColorUtil.GetColor("#71708A");
|
||||
m_DataAreaColor = ColorUtil.GetColor("#71708A");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Copy(DataZoomTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_BorderWidth = theme.borderWidth;
|
||||
m_DataLineWidth = theme.dataLineWidth;
|
||||
m_FillerColor = theme.fillerColor;
|
||||
m_BorderColor = theme.borderColor;
|
||||
m_DataLineColor = theme.dataLineColor;
|
||||
m_DataAreaColor = theme.dataAreaColor;
|
||||
m_BackgroundColor = theme.backgroundColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/DataZoomTheme.cs.meta
Normal file
11
Runtime/Component/Theme/DataZoomTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba535ef75742b4825b3cc2be4df6716f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Runtime/Component/Theme/GaugeAxisTheme.cs
Normal file
83
Runtime/Component/Theme/GaugeAxisTheme.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class GaugeAxisTheme : BaseAxisTheme
|
||||
{
|
||||
[SerializeField] private Color32 m_BarBackgroundColor;
|
||||
[SerializeField]
|
||||
private List<StageColor> m_StageColor = new List<StageColor>()
|
||||
{
|
||||
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||
};
|
||||
/// <summary>
|
||||
/// 进度条背景颜色。
|
||||
/// </summary>
|
||||
public Color32 barBackgroundColor { get { return m_BarBackgroundColor; } set { m_BarBackgroundColor = value; } }
|
||||
/// <summary>
|
||||
/// 阶段颜色。
|
||||
/// </summary>
|
||||
public List<StageColor> stageColor { get { return m_StageColor; } set { m_StageColor = value; } }
|
||||
|
||||
public GaugeAxisTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_LineWidth = XChartsSettings.gaugeAxisLineWidth;
|
||||
m_LineLength = 0;
|
||||
m_SplitLineWidth = XChartsSettings.gaugeAxisSplitLineWidth;
|
||||
m_SplitLineLength = XChartsSettings.gaugeAxisSplitLineLength;
|
||||
m_TickWidth = XChartsSettings.gaugeAxisTickWidth;
|
||||
m_TickLength = XChartsSettings.gaugeAxisTickLength;
|
||||
m_SplitLineColor = Color.white;
|
||||
m_TickColor = Color.white;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_BarBackgroundColor = new Color32(200, 200, 200, 255);
|
||||
m_StageColor = new List<StageColor>()
|
||||
{
|
||||
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||
};
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_BarBackgroundColor = new Color32(200, 200, 200, 255);
|
||||
m_StageColor = new List<StageColor>()
|
||||
{
|
||||
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||
};
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_BarBackgroundColor = new Color32(200, 200, 200, 255);
|
||||
m_StageColor = new List<StageColor>()
|
||||
{
|
||||
new StageColor(0.2f,new Color32(145,199,174,255)),
|
||||
new StageColor(0.8f,new Color32(99,134,158,255)),
|
||||
new StageColor(1.0f,new Color32(194,53,49,255)),
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Copy(GaugeAxisTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_BarBackgroundColor = theme.barBackgroundColor;
|
||||
ChartHelper.CopyList(m_StageColor, theme.stageColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/GaugeAxisTheme.cs.meta
Normal file
11
Runtime/Component/Theme/GaugeAxisTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b38e4b45ec20b4c65a6dc82891c5c39a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
Runtime/Component/Theme/LegendTheme.cs
Normal file
43
Runtime/Component/Theme/LegendTheme.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if dUI_TextMeshPro
|
||||
using TMPro;
|
||||
#endif
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class LegendTheme : ComponentTheme
|
||||
{
|
||||
[SerializeField] protected Color m_UnableColor;
|
||||
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
/// 文本颜色。
|
||||
/// </summary>
|
||||
public Color unableColor
|
||||
{
|
||||
get { return m_UnableColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_UnableColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public void Copy(LegendTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_UnableColor = theme.unableColor;
|
||||
}
|
||||
|
||||
public LegendTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_UnableColor = ColorUtil.GetColor("#cccccc");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/LegendTheme.cs.meta
Normal file
11
Runtime/Component/Theme/LegendTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a86fb06a6b71c4735b87769ee0708293
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Runtime/Component/Theme/SerieTheme.cs
Normal file
93
Runtime/Component/Theme/SerieTheme.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class SerieTheme : MainComponent
|
||||
{
|
||||
[SerializeField] protected float m_LineWidth;
|
||||
[SerializeField] protected float m_LineSymbolSize;
|
||||
[SerializeField] protected float m_LineSymbolSelectedSize;
|
||||
[SerializeField] protected float m_ScatterSymbolSize;
|
||||
[SerializeField] protected float m_ScatterSymbolSelectedSize;
|
||||
[SerializeField] protected float m_PieTooltipExtraRadius;
|
||||
[SerializeField] protected float m_PieSelectedOffset;
|
||||
|
||||
/// <summary>
|
||||
/// the color of text.
|
||||
/// 文本颜色。
|
||||
/// </summary>
|
||||
public float lineWidth
|
||||
{
|
||||
get { return m_LineWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float lineSymbolSize
|
||||
{
|
||||
get { return m_LineSymbolSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineSymbolSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float lineSymbolSelectedSize
|
||||
{
|
||||
get { return m_LineSymbolSelectedSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineSymbolSelectedSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float scatterSymbolSize
|
||||
{
|
||||
get { return m_ScatterSymbolSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ScatterSymbolSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
public float scatterSymbolSelectedSize
|
||||
{
|
||||
get { return m_ScatterSymbolSelectedSize; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_ScatterSymbolSelectedSize, value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 饼图鼠标移到高亮时的额外半径
|
||||
/// </summary>
|
||||
public float pieTooltipExtraRadius
|
||||
{
|
||||
get { return m_PieTooltipExtraRadius; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PieTooltipExtraRadius, value < 0 ? 0f : value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 饼图选中时的中心点偏移
|
||||
/// </summary>
|
||||
public float pieSelectedOffset
|
||||
{
|
||||
get { return m_PieSelectedOffset; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_PieSelectedOffset, value < 0 ? 0f : value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public void Copy(SerieTheme theme)
|
||||
{
|
||||
m_LineWidth = theme.lineWidth;
|
||||
m_LineSymbolSize = theme.lineSymbolSize;
|
||||
m_LineSymbolSelectedSize = theme.lineSymbolSelectedSize;
|
||||
m_ScatterSymbolSize = theme.scatterSymbolSize;
|
||||
m_ScatterSymbolSelectedSize = theme.scatterSymbolSelectedSize;
|
||||
m_PieTooltipExtraRadius = theme.pieTooltipExtraRadius;
|
||||
m_PieSelectedOffset = theme.pieSelectedOffset;
|
||||
}
|
||||
|
||||
public SerieTheme(Theme theme)
|
||||
{
|
||||
m_LineWidth = XChartsSettings.serieLineWidth;
|
||||
m_LineSymbolSize = XChartsSettings.serieLineSymbolSize;
|
||||
m_LineSymbolSelectedSize = XChartsSettings.serieLineSymbolSelectedSize;
|
||||
m_ScatterSymbolSize = XChartsSettings.serieScatterSymbolSize;
|
||||
m_ScatterSymbolSelectedSize = XChartsSettings.serieScatterSymbolSelectedSize;
|
||||
m_PieTooltipExtraRadius = XChartsSettings.pieTooltipExtraRadius;
|
||||
m_PieSelectedOffset = XChartsSettings.pieSelectedOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/SerieTheme.cs.meta
Normal file
11
Runtime/Component/Theme/SerieTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9030b0e4afb164967b4991247947b195
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Runtime/Component/Theme/SubTitleTheme.cs
Normal file
32
Runtime/Component/Theme/SubTitleTheme.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class SubTitleTheme : ComponentTheme
|
||||
{
|
||||
public SubTitleTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_FontSize = XChartsSettings.fontSizeLv2;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextColor = ColorUtil.GetColor("#969696");
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_TextColor = ColorUtil.GetColor("#969696");
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextColor = ColorUtil.GetColor("#B9B8CE");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/SubTitleTheme.cs.meta
Normal file
11
Runtime/Component/Theme/SubTitleTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c642293f2d6674cbb85d1f081b9d89e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Runtime/Component/Theme/TitleTheme.cs
Normal file
31
Runtime/Component/Theme/TitleTheme.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class TitleTheme : ComponentTheme
|
||||
{
|
||||
public TitleTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_FontSize = XChartsSettings.fontSizeLv1;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextColor = ColorUtil.GetColor("#514D4D");
|
||||
break;
|
||||
case Theme.Light:
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextColor = ColorUtil.GetColor("#EEF1FA");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/TitleTheme.cs.meta
Normal file
11
Runtime/Component/Theme/TitleTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6649bc33964624c14a13ce34dd7eae77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
123
Runtime/Component/Theme/TooltipTheme.cs
Normal file
123
Runtime/Component/Theme/TooltipTheme.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class TooltipTheme : ComponentTheme
|
||||
{
|
||||
[SerializeField] protected LineStyle.Type m_LineType = LineStyle.Type.Solid;
|
||||
[SerializeField] protected float m_LineWidth = 1f;
|
||||
[SerializeField] protected Color32 m_LineColor;
|
||||
[SerializeField] protected Color32 m_AreaColor;
|
||||
[SerializeField] protected Color32 m_LabelTextColor;
|
||||
[SerializeField] protected Color32 m_LabelBackgroundColor;
|
||||
|
||||
/// <summary>
|
||||
/// the type of line.
|
||||
/// 坐标轴线类型。
|
||||
/// </summary>
|
||||
public LineStyle.Type lineType
|
||||
{
|
||||
get { return m_LineType; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineType, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the width of line.
|
||||
/// 指示线线宽。
|
||||
/// </summary>
|
||||
public float lineWidth
|
||||
{
|
||||
get { return m_LineWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_LineWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of line.
|
||||
/// 指示线颜色。
|
||||
/// </summary>
|
||||
public Color32 lineColor
|
||||
{
|
||||
get { return m_LineColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_LineColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of line.
|
||||
/// 区域指示的颜色。
|
||||
/// </summary>
|
||||
public Color32 areaColor
|
||||
{
|
||||
get { return m_AreaColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_AreaColor, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the text color of tooltip cross indicator's axis label.
|
||||
/// 十字指示器坐标轴标签的文本颜色。
|
||||
/// </summary>
|
||||
public Color32 labelTextColor
|
||||
{
|
||||
get { return m_LabelTextColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_LabelTextColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the background color of tooltip cross indicator's axis label.
|
||||
/// 十字指示器坐标轴标签的背景颜色。
|
||||
/// </summary>
|
||||
public Color32 labelBackgroundColor
|
||||
{
|
||||
get { return m_LabelBackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_LabelBackgroundColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
public TooltipTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_LineType = LineStyle.Type.Solid;
|
||||
m_LineWidth = XChartsSettings.tootipLineWidth;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#515151C8");
|
||||
m_TextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_AreaColor = ColorUtil.GetColor("#51515120");
|
||||
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
|
||||
m_LineColor = ColorUtil.GetColor("#29292964");
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#515151C8");
|
||||
m_TextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_AreaColor = ColorUtil.GetColor("#51515120");
|
||||
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_LabelBackgroundColor = ColorUtil.GetColor("#292929FF");
|
||||
m_LineColor = ColorUtil.GetColor("#29292964");
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextBackgroundColor = ColorUtil.GetColor("#515151C8");
|
||||
m_TextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_AreaColor = ColorUtil.GetColor("#51515120");
|
||||
m_LabelTextColor = ColorUtil.GetColor("#FFFFFFFF");
|
||||
m_LabelBackgroundColor = ColorUtil.GetColor("#A7A7A7FF");
|
||||
m_LineColor = ColorUtil.GetColor("#eee");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Copy(TooltipTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_LineType = theme.lineType;
|
||||
m_LineWidth = theme.lineWidth;
|
||||
m_LineColor = theme.lineColor;
|
||||
m_AreaColor = theme.areaColor;
|
||||
m_LabelTextColor = theme.labelTextColor;
|
||||
m_LabelBackgroundColor = theme.labelBackgroundColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/TooltipTheme.cs.meta
Normal file
11
Runtime/Component/Theme/TooltipTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f38f041e827e042a88338628b2b2c0db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
93
Runtime/Component/Theme/VisualMapTheme.cs
Normal file
93
Runtime/Component/Theme/VisualMapTheme.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
[Serializable]
|
||||
public class VisualMapTheme : ComponentTheme
|
||||
{
|
||||
[SerializeField] protected float m_BorderWidth;
|
||||
[SerializeField] protected Color32 m_BorderColor;
|
||||
[SerializeField] protected Color32 m_BackgroundColor;
|
||||
[SerializeField] [Range(10, 50)] protected float m_TriangeLen = 20f;
|
||||
|
||||
/// <summary>
|
||||
/// the width of border.
|
||||
/// 边框线宽。
|
||||
/// </summary>
|
||||
public float borderWidth
|
||||
{
|
||||
get { return m_BorderWidth; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_BorderWidth, value)) SetVerticesDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// the color of dataZoom border.
|
||||
/// 边框颜色。
|
||||
/// </summary>
|
||||
public Color32 borderColor
|
||||
{
|
||||
get { return m_BorderColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BorderColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the background color of visualmap.
|
||||
/// 背景颜色。
|
||||
/// </summary>
|
||||
public Color32 backgroundColor
|
||||
{
|
||||
get { return m_BackgroundColor; }
|
||||
set { if (PropertyUtil.SetColor(ref m_BackgroundColor, value)) SetComponentDirty(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// 可视化组件的调节三角形边长。
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float triangeLen
|
||||
{
|
||||
get { return m_TriangeLen; }
|
||||
set { if (PropertyUtil.SetStruct(ref m_TriangeLen, value < 0 ? 1f : value)) SetVerticesDirty(); }
|
||||
}
|
||||
|
||||
public VisualMapTheme(Theme theme) : base(theme)
|
||||
{
|
||||
m_BorderWidth = XChartsSettings.visualMapBorderWidth;
|
||||
m_TriangeLen = XChartsSettings.visualMapTriangeLen;
|
||||
m_FontSize = XChartsSettings.fontSizeLv4;
|
||||
switch (theme)
|
||||
{
|
||||
case Theme.Default:
|
||||
m_TextColor = ColorUtil.GetColor("#333");
|
||||
m_BorderColor = ColorUtil.GetColor("#ccc");
|
||||
m_BackgroundColor = ColorUtil.clearColor32;
|
||||
break;
|
||||
case Theme.Light:
|
||||
m_TextColor = ColorUtil.GetColor("#333");
|
||||
m_BorderColor = ColorUtil.GetColor("#ccc");
|
||||
m_BackgroundColor = ColorUtil.clearColor32;
|
||||
break;
|
||||
case Theme.Dark:
|
||||
m_TextColor = ColorUtil.GetColor("#B9B8CE");
|
||||
m_BorderColor = ColorUtil.GetColor("#ccc");
|
||||
m_BackgroundColor = ColorUtil.clearColor32;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Copy(VisualMapTheme theme)
|
||||
{
|
||||
base.Copy(theme);
|
||||
m_TriangeLen = theme.triangeLen;
|
||||
m_BorderWidth = theme.borderWidth;
|
||||
m_BorderColor = theme.borderColor;
|
||||
m_BackgroundColor = theme.backgroundColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Theme/VisualMapTheme.cs.meta
Normal file
11
Runtime/Component/Theme/VisualMapTheme.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35e5797039b994b23850aaa7ca827766
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,13 +1,12 @@
|
||||
using System;
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -17,49 +16,12 @@ namespace XCharts
|
||||
[DisallowMultipleComponent]
|
||||
public class GaugeChart : BaseChart
|
||||
{
|
||||
private static readonly string s_AxisLabelObjectName = "axis_label";
|
||||
private bool m_UpdateTitleText = false;
|
||||
private bool m_UpdateLabelText = false;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
InitAxisLabel();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
foreach (var serie in m_Series.list)
|
||||
{
|
||||
TitleStyleHelper.CheckTitle(serie, ref m_ReinitTitle, ref m_UpdateTitleText);
|
||||
SerieLabelHelper.CheckLabel(serie, ref m_ReinitLabel, ref m_UpdateLabelText);
|
||||
}
|
||||
UpdateAxisLabel();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (m_UpdateTitleText)
|
||||
{
|
||||
m_UpdateTitleText = false;
|
||||
TitleStyleHelper.UpdateTitleText(m_Series);
|
||||
}
|
||||
if (m_UpdateLabelText)
|
||||
{
|
||||
m_UpdateLabelText = false;
|
||||
SerieLabelHelper.UpdateLabelText(m_Series, m_ThemeInfo, m_LegendRealShowName);
|
||||
UpdateAxisLabel();
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
RemoveData();
|
||||
m_Title.text = "GuageChart";
|
||||
title.text = "GuageChart";
|
||||
var serie = AddSerie(SerieType.Gauge, "serie1");
|
||||
serie.min = 0;
|
||||
serie.max = 100;
|
||||
@@ -78,295 +40,7 @@ namespace XCharts
|
||||
serie.gaugeAxis.axisLabel.show = true;
|
||||
serie.gaugeAxis.axisLabel.margin = 18;
|
||||
AddData(0, UnityEngine.Random.Range(10, 90), "title");
|
||||
InitAxisLabel();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void InitAxisLabel()
|
||||
{
|
||||
var labelObject = ChartHelper.AddObject(s_AxisLabelObjectName, transform, m_ChartMinAnchor,
|
||||
m_ChartMaxAnchor, m_ChartPivot, m_ChartSizeDelta);
|
||||
SerieLabelPool.ReleaseAll(labelObject.transform);
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
var serie = m_Series.list[i];
|
||||
var serieLabel = serie.gaugeAxis.axisLabel;
|
||||
var count = serie.splitNumber > 36 ? 36 : (serie.splitNumber + 1);
|
||||
var startAngle = serie.startAngle;
|
||||
serie.gaugeAxis.ClearLabelObject();
|
||||
SerieHelper.UpdateCenter(serie, chartPosition, chartWidth, chartHeight);
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, i, j);
|
||||
var color = Color.grey;
|
||||
var labelObj = SerieLabelPool.Get(textName, labelObject.transform, serieLabel, m_ThemeInfo.font, color, 100, 100);
|
||||
var iconImage = labelObj.transform.Find("Icon").GetComponent<Image>();
|
||||
var isAutoSize = serieLabel.backgroundWidth == 0 || serieLabel.backgroundHeight == 0;
|
||||
var item = new LabelObject();
|
||||
item.SetLabel(labelObj, isAutoSize, serieLabel.paddingLeftRight, serieLabel.paddingTopBottom);
|
||||
item.SetIcon(iconImage);
|
||||
item.SetIconActive(false);
|
||||
serie.gaugeAxis.AddLabelObject(item);
|
||||
}
|
||||
UpdateAxisLabel(serie);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DrawChart(VertexHelper vh)
|
||||
{
|
||||
base.DrawChart(vh);
|
||||
DrawData(vh);
|
||||
}
|
||||
|
||||
protected override void OnThemeChanged()
|
||||
{
|
||||
base.OnThemeChanged();
|
||||
}
|
||||
|
||||
protected override void OnSizeChanged()
|
||||
{
|
||||
base.OnSizeChanged();
|
||||
InitAxisLabel();
|
||||
}
|
||||
|
||||
private void DrawData(VertexHelper vh)
|
||||
{
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
var serie = m_Series.list[i];
|
||||
if (serie.type != SerieType.Gauge) continue;
|
||||
DrawGauge(vh, serie);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGauge(VertexHelper vh, Serie serie)
|
||||
{
|
||||
SerieHelper.UpdateCenter(serie, chartPosition, chartWidth, chartHeight);
|
||||
var destAngle = GetCurrAngle(serie, true);
|
||||
serie.animation.InitProgress(0, serie.startAngle, destAngle);
|
||||
var currAngle = serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail();
|
||||
DrawProgressBar(vh, serie, currAngle);
|
||||
DrawStageColor(vh, serie);
|
||||
DrawLineStyle(vh, serie);
|
||||
DrawAxisTick(vh, serie);
|
||||
DrawPointer(vh, serie, currAngle);
|
||||
TitleStyleHelper.CheckTitle(serie, ref m_ReinitTitle, ref m_UpdateTitleText);
|
||||
SerieLabelHelper.CheckLabel(serie, ref m_ReinitLabel, ref m_UpdateLabelText);
|
||||
CheckAnimation(serie);
|
||||
if (!serie.animation.IsFinish())
|
||||
{
|
||||
serie.animation.CheckProgress(destAngle - serie.startAngle);
|
||||
RefreshChart();
|
||||
}
|
||||
else if (NeedRefresh(serie))
|
||||
{
|
||||
RefreshChart();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawProgressBar(VertexHelper vh, Serie serie, float currAngle)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.ProgressBar) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisLine.show) return;
|
||||
var color = serie.gaugeAxis.GetAxisLineColor(m_ThemeInfo, serie.index);
|
||||
var backgroundColor = serie.gaugeAxis.GetAxisLineBackgroundColor(m_ThemeInfo, serie.index);
|
||||
var outsideRadius = serie.runtimeInsideRadius + serie.gaugeAxis.axisLine.width;
|
||||
var borderWidth = serie.itemStyle.borderWidth;
|
||||
var borderColor = serie.itemStyle.borderColor;
|
||||
ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
|
||||
backgroundColor, backgroundColor, Color.clear, serie.startAngle, serie.endAngle, 0, Color.clear,
|
||||
0, m_Settings.cicleSmoothness, serie.roundCap);
|
||||
ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
|
||||
color, color, Color.clear, serie.startAngle, currAngle, 0, Color.clear,
|
||||
0, m_Settings.cicleSmoothness, serie.roundCap);
|
||||
}
|
||||
|
||||
private void DrawStageColor(VertexHelper vh, Serie serie)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisLine.show) return;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var tempStartAngle = serie.startAngle;
|
||||
var tempEndAngle = serie.startAngle;
|
||||
var outsideRadius = serie.runtimeInsideRadius + serie.gaugeAxis.axisLine.width;
|
||||
serie.gaugeAxis.runtimeStageAngle.Clear();
|
||||
for (int i = 0; i < serie.gaugeAxis.axisLine.stageColor.Count; i++)
|
||||
{
|
||||
var stageColor = serie.gaugeAxis.axisLine.stageColor[i];
|
||||
tempEndAngle = serie.startAngle + totalAngle * stageColor.percent;
|
||||
serie.gaugeAxis.runtimeStageAngle.Add(tempEndAngle);
|
||||
ChartDrawer.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
|
||||
stageColor.color, stageColor.color, Color.clear, tempStartAngle, tempEndAngle, 0, Color.clear,
|
||||
0, m_Settings.cicleSmoothness);
|
||||
tempStartAngle = tempEndAngle;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPointer(VertexHelper vh, Serie serie, float currAngle)
|
||||
{
|
||||
if (!serie.gaugePointer.show) return;
|
||||
var pointerColor = serie.gaugeAxis.GetPointerColor(m_ThemeInfo, serie.index, currAngle, serie.itemStyle);
|
||||
var pointerToColor = !ChartHelper.IsClearColor(serie.itemStyle.toColor) ? serie.itemStyle.toColor : pointerColor;
|
||||
var len = serie.gaugePointer.length < 1 && serie.gaugePointer.length > -1 ?
|
||||
serie.runtimeInsideRadius * serie.gaugePointer.length :
|
||||
serie.gaugePointer.length;
|
||||
var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle, len);
|
||||
var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle + 180, serie.gaugePointer.width);
|
||||
var p3 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle - 90, serie.gaugePointer.width / 2);
|
||||
var p4 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle + 90, serie.gaugePointer.width / 2);
|
||||
ChartDrawer.DrawTriangle(vh, p2, p3, p1, pointerColor, pointerColor, pointerToColor);
|
||||
ChartDrawer.DrawTriangle(vh, p4, p2, p1, pointerColor, pointerColor, pointerToColor);
|
||||
}
|
||||
|
||||
private void DrawLineStyle(VertexHelper vh, Serie serie)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.splitLine.show) return;
|
||||
if (serie.splitNumber <= 0) return;
|
||||
var splitLine = serie.gaugeAxis.splitLine;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var diffAngle = totalAngle / serie.splitNumber;
|
||||
var outsideRadius = serie.runtimeInsideRadius + serie.gaugeAxis.axisLine.width;
|
||||
var insideRadius = outsideRadius - splitLine.length;
|
||||
var lineWidth = splitLine.lineStyle.width;
|
||||
for (int i = 0; i < serie.splitNumber + 1; i++)
|
||||
{
|
||||
var angle = serie.startAngle + i * diffAngle;
|
||||
var lineColor = serie.gaugeAxis.GetSplitLineColor(m_ThemeInfo, serie.index, angle);
|
||||
var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, insideRadius);
|
||||
var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, outsideRadius);
|
||||
ChartDrawer.DrawLine(vh, p1, p2, lineWidth, lineColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAxisTick(VertexHelper vh, Serie serie)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisTick.show) return;
|
||||
if (serie.splitNumber <= 0) return;
|
||||
var axisTick = serie.gaugeAxis.axisTick;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var diffAngle = totalAngle / serie.splitNumber;
|
||||
var outsideRadius = serie.runtimeInsideRadius + serie.gaugeAxis.axisLine.width;
|
||||
var insideRadius = outsideRadius - (axisTick.length < 1 ? serie.gaugeAxis.axisLine.width * axisTick.length : axisTick.length);
|
||||
var lineWidth = axisTick.lineStyle.width;
|
||||
for (int i = 0; i < serie.splitNumber; i++)
|
||||
{
|
||||
for (int j = 1; j < axisTick.splitNumber; j++)
|
||||
{
|
||||
var angle = serie.startAngle + i * diffAngle + j * (diffAngle / axisTick.splitNumber);
|
||||
var lineColor = serie.gaugeAxis.GetSplitLineColor(m_ThemeInfo, serie.index, angle);
|
||||
var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, insideRadius);
|
||||
var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, outsideRadius);
|
||||
ChartDrawer.DrawLine(vh, p1, p2, lineWidth, lineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool NeedRefresh(Serie serie)
|
||||
{
|
||||
if (serie.type == SerieType.Gauge)
|
||||
{
|
||||
var serieData = serie.GetSerieData(0);
|
||||
if (serieData != null)
|
||||
{
|
||||
var destValue = serieData.GetData(1);
|
||||
var currValue = serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||
return destValue != currValue;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DrawRoundCap(VertexHelper vh, Serie serie, float angle, Color color, bool invert = false)
|
||||
{
|
||||
var radius = serie.gaugeAxis.axisLine.width / 2;
|
||||
var len = serie.runtimeInsideRadius + radius;
|
||||
var pos = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, len);
|
||||
var startAngle = invert ? angle + 180 : angle;
|
||||
var endAngle = invert ? angle + 360 : angle + 180;
|
||||
ChartDrawer.DrawSector(vh, pos, radius, color, startAngle, endAngle);
|
||||
}
|
||||
|
||||
private void CheckAnimation(Serie serie)
|
||||
{
|
||||
var serieData = serie.GetSerieData(0);
|
||||
if (serieData != null)
|
||||
{
|
||||
var value = serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||
var data = serieData.GetData(1);
|
||||
if (value != data) m_RefreshChart = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAxisLabel(Serie serie)
|
||||
{
|
||||
var show = serie.gaugeAxis.show && serie.gaugeAxis.axisLabel.show;
|
||||
serie.gaugeAxis.SetLabelObjectActive(show);
|
||||
if (!show)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var count = serie.splitNumber > 36 ? 36 : serie.splitNumber;
|
||||
var startAngle = serie.startAngle;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var totalValue = serie.max - serie.min;
|
||||
var diffAngle = totalAngle / count;
|
||||
var diffValue = totalValue / count;
|
||||
var radius = serie.runtimeInsideRadius - serie.gaugeAxis.axisLabel.margin;
|
||||
var serieData = serie.GetSerieData(0);
|
||||
var customLabelText = serie.gaugeAxis.axisLabelText;
|
||||
for (int j = 0; j <= count; j++)
|
||||
{
|
||||
var angle = serie.startAngle + j * diffAngle;
|
||||
var value = serie.min + j * diffValue;
|
||||
var pos = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, radius);
|
||||
var text = customLabelText != null && j < customLabelText.Count ? customLabelText[j] :
|
||||
SerieLabelHelper.GetFormatterContent(serie, serieData, value, totalValue, serie.gaugeAxis.axisLabel);
|
||||
serie.gaugeAxis.SetLabelObjectText(j, text);
|
||||
serie.gaugeAxis.SetLabelObjectPosition(j, pos);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAxisLabel()
|
||||
{
|
||||
foreach (var serie in m_Series.list)
|
||||
{
|
||||
if (serie.type == SerieType.Gauge)
|
||||
{
|
||||
UpdateAxisLabel(serie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float GetCurrAngle(Serie serie, bool dest)
|
||||
{
|
||||
if (serie.animation.HasFadeOut())
|
||||
{
|
||||
return serie.animation.GetCurrDetail();
|
||||
}
|
||||
float rangeValue = serie.max - serie.min;
|
||||
float rangeAngle = serie.endAngle - serie.startAngle;
|
||||
float value = 0;
|
||||
float angle = serie.startAngle;
|
||||
if (serie.dataCount > 0)
|
||||
{
|
||||
var serieData = serie.data[0];
|
||||
serieData.labelPosition = serie.runtimeCenterPos + serie.label.offset;
|
||||
value = dest ? serieData.GetData(1) : serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||
value = Mathf.Clamp(value, serie.min, serie.max);
|
||||
}
|
||||
if (rangeValue > 0)
|
||||
{
|
||||
angle += rangeAngle * value / rangeValue;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
protected override void OnRefreshLabel()
|
||||
{
|
||||
//TODO:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -21,54 +21,48 @@ namespace XCharts
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
m_Title.text = "HeatmapChart";
|
||||
m_Tooltip.type = Tooltip.Type.None;
|
||||
m_Grid.left = 100;
|
||||
m_Grid.right = 60;
|
||||
m_Grid.bottom = 60;
|
||||
title.text = "HeatmapChart";
|
||||
tooltip.type = Tooltip.Type.None;
|
||||
grid.left = 100;
|
||||
grid.right = 60;
|
||||
grid.bottom = 60;
|
||||
|
||||
m_XAxises[0].type = Axis.AxisType.Category;
|
||||
m_XAxises[0].boundaryGap = false;
|
||||
m_YAxises[0].type = Axis.AxisType.Category;
|
||||
m_YAxises[0].boundaryGap = false;
|
||||
m_XAxises[0].splitNumber = 10;
|
||||
m_YAxises[0].splitNumber = 10;
|
||||
m_XAxes[0].type = Axis.AxisType.Category;
|
||||
m_XAxes[0].boundaryGap = false;
|
||||
m_YAxes[0].type = Axis.AxisType.Category;
|
||||
m_YAxes[0].boundaryGap = false;
|
||||
m_XAxes[0].splitNumber = 10;
|
||||
m_YAxes[0].splitNumber = 10;
|
||||
RemoveData();
|
||||
var serie = AddSerie(SerieType.Heatmap, "serie1");
|
||||
var heatmapGridWid = 10f;
|
||||
int xSplitNumber = (int)(m_CoordinateWidth / heatmapGridWid);
|
||||
int ySplitNumber = (int)(m_CoordinateHeight / heatmapGridWid);
|
||||
serie.itemStyle.show = true;
|
||||
serie.itemStyle.borderWidth = 1;
|
||||
serie.itemStyle.borderColor = Color.clear;
|
||||
serie.emphasis.show = true;
|
||||
serie.emphasis.itemStyle.show = true;
|
||||
serie.emphasis.itemStyle.borderWidth = 1;
|
||||
serie.emphasis.itemStyle.borderColor = Color.black;
|
||||
int xSplitNumber = (int)(grid.runtimeWidth / heatmapGridWid);
|
||||
int ySplitNumber = (int)(grid.runtimeHeight / heatmapGridWid);
|
||||
|
||||
m_VisualMap.enable = true;
|
||||
m_VisualMap.max = 10;
|
||||
m_VisualMap.range[0] = 0f;
|
||||
m_VisualMap.range[1] = 10f;
|
||||
m_VisualMap.orient = Orient.Vertical;
|
||||
m_VisualMap.calculable = true;
|
||||
m_VisualMap.location.align = Location.Align.BottomLeft;
|
||||
m_VisualMap.location.bottom = 100;
|
||||
m_VisualMap.location.left = 30;
|
||||
SerieTemplate.AddDefaultHeatmapSerie(this, "serie1");
|
||||
|
||||
visualMap.enable = true;
|
||||
visualMap.max = 10;
|
||||
visualMap.range[0] = 0f;
|
||||
visualMap.range[1] = 10f;
|
||||
visualMap.orient = Orient.Vertical;
|
||||
visualMap.calculable = true;
|
||||
visualMap.location.align = Location.Align.BottomLeft;
|
||||
visualMap.location.bottom = 100;
|
||||
visualMap.location.left = 30;
|
||||
var colors = new List<string>{"#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf",
|
||||
"#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"};
|
||||
m_VisualMap.inRange.Clear();
|
||||
visualMap.inRange.Clear();
|
||||
foreach (var str in colors)
|
||||
{
|
||||
m_VisualMap.inRange.Add(ThemeInfo.GetColor(str));
|
||||
visualMap.inRange.Add(ChartTheme.GetColor(str));
|
||||
}
|
||||
for (int i = 0; i < xSplitNumber; i++)
|
||||
{
|
||||
m_XAxises[0].data.Add((i + 1).ToString());
|
||||
m_XAxes[0].data.Add((i + 1).ToString());
|
||||
}
|
||||
for (int i = 0; i < ySplitNumber; i++)
|
||||
{
|
||||
m_YAxises[0].data.Add((i + 1).ToString());
|
||||
m_YAxes[0].data.Add((i + 1).ToString());
|
||||
}
|
||||
for (int i = 0; i < xSplitNumber; i++)
|
||||
{
|
||||
@@ -87,15 +81,15 @@ namespace XCharts
|
||||
|
||||
protected override void UpdateTooltip()
|
||||
{
|
||||
var xData = m_Tooltip.runtimeXValues[0];
|
||||
var yData = m_Tooltip.runtimeYValues[0];
|
||||
var xData = tooltip.runtimeXValues[0];
|
||||
var yData = tooltip.runtimeYValues[0];
|
||||
if (IsCategory() && (xData < 0 || yData < 0)) return;
|
||||
sb.Length = 0;
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
var serie = m_Series.GetSerie(i);
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
var yAxis = m_YAxises[serie.axisIndex];
|
||||
var xAxis = m_XAxes[serie.xAxisIndex];
|
||||
var yAxis = m_YAxes[serie.yAxisIndex];
|
||||
var xCount = xAxis.data.Count;
|
||||
var yCount = yAxis.data.Count;
|
||||
if (serie.show && serie.type == SerieType.Heatmap)
|
||||
@@ -105,8 +99,8 @@ namespace XCharts
|
||||
string key = serie.name;
|
||||
var serieData = serie.data[(int)xData * yCount + (int)yData];
|
||||
var value = serieData.data[2];
|
||||
var color = m_VisualMap.enable ? m_VisualMap.GetColor(value) :
|
||||
m_ThemeInfo.GetColor(serie.index);
|
||||
var color = visualMap.enable ? visualMap.GetColor(value) :
|
||||
m_Theme.GetColor(serie.index);
|
||||
sb.Append("\n")
|
||||
.Append(key).Append(!string.IsNullOrEmpty(key) ? "\n" : "")
|
||||
.Append("<color=#").Append(ChartCached.ColorToStr(color)).Append(">● </color>")
|
||||
@@ -116,15 +110,15 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
TooltipHelper.SetContentAndPosition(tooltip, sb.ToString().Trim(), chartRect);
|
||||
m_Tooltip.SetActive(true);
|
||||
tooltip.SetActive(true);
|
||||
|
||||
for (int i = 0; i < m_XAxises.Count; i++)
|
||||
for (int i = 0; i < m_XAxes.Count; i++)
|
||||
{
|
||||
UpdateAxisTooltipLabel(i, m_XAxises[i]);
|
||||
UpdateAxisTooltipLabel(i, m_XAxes[i]);
|
||||
}
|
||||
for (int i = 0; i < m_YAxises.Count; i++)
|
||||
for (int i = 0; i < m_YAxes.Count; i++)
|
||||
{
|
||||
UpdateAxisTooltipLabel(i, m_YAxises[i]);
|
||||
UpdateAxisTooltipLabel(i, m_YAxes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -56,33 +56,41 @@ namespace XCharts
|
||||
|
||||
private static void CheckTheme(BaseChart chart, StringBuilder sb)
|
||||
{
|
||||
var themeInfo = chart.themeInfo;
|
||||
themeInfo.CheckWarning(sb);
|
||||
var theme = chart.theme;
|
||||
theme.CheckWarning(sb);
|
||||
}
|
||||
|
||||
private static void CheckTitle(BaseChart chart, StringBuilder sb)
|
||||
{
|
||||
var title = chart.title;
|
||||
if (!title.show) return;
|
||||
if (string.IsNullOrEmpty(title.text)) sb.Append("warning:title->text is null\n");
|
||||
if (IsColorAlphaZero(title.textStyle.color))
|
||||
sb.Append("warning:title->textStyle->color alpha is 0\n");
|
||||
if (IsColorAlphaZero(title.subTextStyle.color))
|
||||
sb.Append("warning:title->subTextStyle->color alpha is 0\n");
|
||||
foreach (var title in chart.titles)
|
||||
{
|
||||
if (!title.show) return;
|
||||
if (string.IsNullOrEmpty(title.text)) sb.AppendFormat("warning:title{0}->text is null\n", title.index);
|
||||
if (IsColorAlphaZero(title.textStyle.color))
|
||||
sb.AppendFormat("warning:title{0}->textStyle->color alpha is 0\n", title.index);
|
||||
if (IsColorAlphaZero(title.subTextStyle.color))
|
||||
sb.AppendFormat("warning:title{0}->subTextStyle->color alpha is 0\n", title.index);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckLegend(BaseChart chart, StringBuilder sb)
|
||||
{
|
||||
var legend = chart.legend;
|
||||
if (!legend.show) return;
|
||||
if (IsColorAlphaZero(legend.textStyle.color))
|
||||
sb.Append("warning:legend->textStyle->color alpha is 0\n");
|
||||
var serieNameList = SeriesHelper.GetLegalSerieNameList(chart.series);
|
||||
if (serieNameList.Count == 0) sb.Append("warning:legend need serie.name or serieData.name not empty\n");
|
||||
foreach (var category in legend.data)
|
||||
foreach (var legend in chart.legends)
|
||||
{
|
||||
if (!serieNameList.Contains(category))
|
||||
sb.AppendFormat("warning:legend [{0}] is invalid, must be one of serie.name or serieData.name\n", category);
|
||||
if (!legend.show) return;
|
||||
if (IsColorAlphaZero(legend.textStyle.color))
|
||||
sb.AppendFormat("warning:legend{0}->textStyle->color alpha is 0\n", legend.index);
|
||||
var serieNameList = SeriesHelper.GetLegalSerieNameList(chart.series);
|
||||
if (serieNameList.Count == 0)
|
||||
sb.AppendFormat("warning:legend{0} need serie.name or serieData.name not empty\n", legend.index);
|
||||
foreach (var category in legend.data)
|
||||
{
|
||||
if (!serieNameList.Contains(category))
|
||||
{
|
||||
sb.AppendFormat("warning:legend{0} [{1}] is invalid, must be one of serie.name or serieData.name\n",
|
||||
legend.index, category);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,19 +98,21 @@ namespace XCharts
|
||||
{
|
||||
if (chart is CoordinateChart)
|
||||
{
|
||||
var grid = (chart as CoordinateChart).grid;
|
||||
if (grid.left >= chart.chartWidth)
|
||||
sb.Append("warning:grid->left > chartWidth\n");
|
||||
if (grid.right >= chart.chartWidth)
|
||||
sb.Append("warning:grid->right > chartWidth\n");
|
||||
if (grid.top >= chart.chartHeight)
|
||||
sb.Append("warning:grid->top > chartHeight\n");
|
||||
if (grid.bottom >= chart.chartHeight)
|
||||
sb.Append("warning:grid->bottom > chartHeight\n");
|
||||
if (grid.left + grid.right >= chart.chartWidth)
|
||||
sb.Append("warning:grid.left + grid.right > chartWidth\n");
|
||||
if (grid.top + grid.bottom >= chart.chartHeight)
|
||||
sb.Append("warning:grid.top + grid.bottom > chartHeight\n");
|
||||
foreach (var grid in (chart as CoordinateChart).grids)
|
||||
{
|
||||
if (grid.left >= chart.chartWidth)
|
||||
sb.Append("warning:grid->left > chartWidth\n");
|
||||
if (grid.right >= chart.chartWidth)
|
||||
sb.Append("warning:grid->right > chartWidth\n");
|
||||
if (grid.top >= chart.chartHeight)
|
||||
sb.Append("warning:grid->top > chartHeight\n");
|
||||
if (grid.bottom >= chart.chartHeight)
|
||||
sb.Append("warning:grid->bottom > chartHeight\n");
|
||||
if (grid.left + grid.right >= chart.chartWidth)
|
||||
sb.Append("warning:grid.left + grid.right > chartWidth\n");
|
||||
if (grid.top + grid.bottom >= chart.chartHeight)
|
||||
sb.Append("warning:grid.top + grid.bottom > chartHeight\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,8 +158,6 @@ namespace XCharts
|
||||
switch (serie.type)
|
||||
{
|
||||
case SerieType.Line:
|
||||
if (serie.lineStyle.width == 0)
|
||||
sb.AppendFormat("warning:serie {0} lineStyle->width is 0\n", serie.index);
|
||||
if (serie.lineStyle.opacity == 0)
|
||||
sb.AppendFormat("warning:serie {0} lineStyle->opacity is 0\n", serie.index);
|
||||
if (IsColorAlphaZero(serie.lineStyle.color))
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -34,12 +34,12 @@ namespace XCharts
|
||||
/// <param name="numericFormatter">默认的数字格式化</param>
|
||||
/// <param name="serie">选中的serie</param>
|
||||
/// <param name="series">所有serie</param>
|
||||
/// <param name="themeInfo">用来获取指定index的颜色</param>
|
||||
/// <param name="theme">用来获取指定index的颜色</param>
|
||||
/// <param name="category">选中的类目,一般用在折线图和柱状图</param>
|
||||
/// <param name="dataZoom">dataZoom</param>
|
||||
/// <returns></returns>
|
||||
public static bool ReplaceContent(ref string content, int dataIndex, string numericFormatter, Serie serie, Series series,
|
||||
ThemeInfo themeInfo, string category = null, DataZoom dataZoom = null)
|
||||
ChartTheme theme, string category = null, DataZoom dataZoom = null)
|
||||
{
|
||||
var foundDot = false;
|
||||
var mc = s_Regex.Matches(content);
|
||||
@@ -74,7 +74,7 @@ namespace XCharts
|
||||
var args1Str = args[1].ToString();
|
||||
if (s_RegexN.IsMatch(args1Str)) bIndex = int.Parse(args1Str);
|
||||
}
|
||||
content = content.Replace(old, ChartCached.ColorToDotStr(themeInfo.GetColor(bIndex)));
|
||||
content = content.Replace(old, ChartCached.ColorToDotStr(theme.GetColor(bIndex)));
|
||||
foundDot = true;
|
||||
}
|
||||
else if (p == 'a' || p == 'A')
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace XCharts
|
||||
private static Vector2 s_Vector1And0Dot5 = new Vector2(1f, 0.5f);
|
||||
private static Vector2 s_Vector1And0 = new Vector2(1f, 0);
|
||||
|
||||
internal static Vector2 ResetChartPositionAndPivot(Vector2 minAnchor, Vector2 maxAnchor, float width, float height, ref float chartX,
|
||||
ref float chartY)
|
||||
internal static Vector2 ResetChartPositionAndPivot(Vector2 minAnchor, Vector2 maxAnchor, float width,
|
||||
float height, ref float chartX, ref float chartY)
|
||||
{
|
||||
if (IsLeftTop(minAnchor, maxAnchor))
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
@@ -21,7 +21,8 @@ namespace XCharts
|
||||
/// <param name="min">最小值</param>
|
||||
/// <param name="max">最大值</param>
|
||||
/// <param name="dataZoom">缩放组件,默认null</param>
|
||||
public static void GetMinMaxData(Serie serie, int dimension, out float min, out float max, DataZoom dataZoom = null)
|
||||
public static void GetMinMaxData(Serie serie, int dimension, out float min, out float max,
|
||||
DataZoom dataZoom = null)
|
||||
{
|
||||
max = float.MinValue;
|
||||
min = float.MaxValue;
|
||||
@@ -56,7 +57,9 @@ namespace XCharts
|
||||
var serieData = dataList[i];
|
||||
if (serieData.show)
|
||||
{
|
||||
var count = serie.showDataDimension > serieData.data.Count ? serieData.data.Count : serie.showDataDimension;
|
||||
var count = serie.showDataDimension > serieData.data.Count
|
||||
? serieData.data.Count
|
||||
: serie.showDataDimension;
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
var value = serieData.data[j];
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public class APIException : System.Exception
|
||||
{
|
||||
public APIException() { }
|
||||
public APIException(string message) : base(message) { }
|
||||
public APIException(string message, System.Exception inner) : base(message, inner) { }
|
||||
protected APIException(
|
||||
System.Runtime.Serialization.SerializationInfo info,
|
||||
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62abeafe2ed4141d69bdb9ad76c02e41
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -17,7 +17,13 @@ namespace XCharts
|
||||
IPointerEnterHandler, IPointerExitHandler, IBeginDragHandler, IPointerClickHandler,
|
||||
IDragHandler, IEndDragHandler, IScrollHandler
|
||||
{
|
||||
protected static readonly string s_BackgroundObjectName = "background";
|
||||
[SerializeField] protected bool m_MultiComponentMode = false;
|
||||
[SerializeField] protected bool m_DebugMode = false;
|
||||
[SerializeField] protected bool m_EnableTextMeshPro = false;
|
||||
[SerializeField] protected Background m_Background = Background.defaultBackground;
|
||||
protected Painter m_Painter;
|
||||
protected int m_SiblingIndex;
|
||||
|
||||
protected float m_GraphWidth;
|
||||
protected float m_GraphHeight;
|
||||
@@ -32,6 +38,8 @@ namespace XCharts
|
||||
protected bool m_RefreshChart = false;
|
||||
protected bool m_ForceOpenRaycastTarget;
|
||||
protected bool m_IsControlledByLayout = false;
|
||||
protected bool m_PainerDirty = false;
|
||||
protected bool m_IsOnValidate = false;
|
||||
protected Vector3 m_LastLocalPosition;
|
||||
|
||||
protected Action<PointerEventData, BaseGraph> m_OnPointerClick;
|
||||
@@ -44,20 +52,24 @@ namespace XCharts
|
||||
protected Action<PointerEventData, BaseGraph> m_OnEndDrag;
|
||||
protected Action<PointerEventData, BaseGraph> m_OnScroll;
|
||||
|
||||
protected Vector2 chartAnchorMax { get { return m_GraphMinAnchor; } }
|
||||
protected Vector2 chartAnchorMin { get { return m_GraphMaxAnchor; } }
|
||||
protected Vector2 chartPivot { get { return m_GraphPivot; } }
|
||||
protected HideFlags chartHideFlags { get { return m_DebugMode ? HideFlags.None : HideFlags.HideInHierarchy; } }
|
||||
protected Vector2 graphAnchorMax { get { return m_GraphMinAnchor; } }
|
||||
protected Vector2 graphAnchorMin { get { return m_GraphMaxAnchor; } }
|
||||
protected Vector2 graphPivot { get { return m_GraphPivot; } }
|
||||
internal HideFlags chartHideFlags { get { return m_DebugMode ? HideFlags.None : HideFlags.HideInHierarchy; } }
|
||||
|
||||
private ScrollRect m_ScrollRect;
|
||||
|
||||
|
||||
protected virtual void InitComponent()
|
||||
{
|
||||
InitPainter();
|
||||
InitBackground();
|
||||
}
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
CheckTextMeshPro();
|
||||
m_SiblingIndex = 0;
|
||||
if (transform.parent != null)
|
||||
{
|
||||
m_IsControlledByLayout = transform.parent.GetComponent<LayoutGroup>() != null;
|
||||
@@ -77,13 +89,76 @@ namespace XCharts
|
||||
protected virtual void Update()
|
||||
{
|
||||
CheckSize();
|
||||
CheckComponent();
|
||||
if (m_IsOnValidate)
|
||||
{
|
||||
m_IsOnValidate = false;
|
||||
m_RefreshChart = true;
|
||||
CheckTextMeshPro();
|
||||
InitComponent();
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckComponent();
|
||||
}
|
||||
CheckPointerPos();
|
||||
CheckRefreshChart();
|
||||
CheckRefreshPainter();
|
||||
}
|
||||
|
||||
protected virtual void SetAllComponentDirty()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
m_IsOnValidate = true;
|
||||
Update();
|
||||
}
|
||||
#endif
|
||||
m_PainerDirty = true;
|
||||
m_Background.SetAllDirty();
|
||||
}
|
||||
|
||||
protected virtual void CheckComponent()
|
||||
{
|
||||
CheckComponentDirty(m_Background);
|
||||
if (m_PainerDirty)
|
||||
{
|
||||
InitPainter();
|
||||
m_PainerDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckTextMeshPro()
|
||||
{
|
||||
#if dUI_TextMeshPro
|
||||
var enableTextMeshPro = true;
|
||||
#else
|
||||
var enableTextMeshPro = false;
|
||||
#endif
|
||||
if (m_EnableTextMeshPro != enableTextMeshPro)
|
||||
{
|
||||
m_EnableTextMeshPro = enableTextMeshPro;
|
||||
RemoveChartObject();
|
||||
}
|
||||
}
|
||||
|
||||
protected void CheckComponentDirty(ChartComponent component)
|
||||
{
|
||||
if (component.anyDirty)
|
||||
{
|
||||
if (component.componentDirty)
|
||||
{
|
||||
component.refreshComponent?.Invoke();
|
||||
}
|
||||
if (component.vertsDirty)
|
||||
{
|
||||
if (component.painter != null)
|
||||
{
|
||||
RefreshPainter(component.painter);
|
||||
}
|
||||
}
|
||||
component.ClearDirty();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
@@ -103,6 +178,7 @@ namespace XCharts
|
||||
|
||||
protected override void OnValidate()
|
||||
{
|
||||
m_IsOnValidate = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -114,6 +190,39 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
private void InitBackground()
|
||||
{
|
||||
var backgroundObj = ChartHelper.AddObject(s_BackgroundObjectName, transform, m_GraphMinAnchor,
|
||||
m_GraphMaxAnchor, m_GraphPivot, m_GraphSizeDelta);
|
||||
m_Background.gameObject = backgroundObj;
|
||||
m_Background.painter = m_Painter;
|
||||
m_Background.refreshComponent = delegate ()
|
||||
{
|
||||
if (backgroundObj == null) return;
|
||||
backgroundObj.hideFlags = chartHideFlags;
|
||||
var backgroundImage = ChartHelper.GetOrAddComponent<Image>(backgroundObj);
|
||||
ChartHelper.UpdateRectTransform(backgroundObj, m_GraphMinAnchor,
|
||||
m_GraphMaxAnchor, m_GraphPivot, m_GraphSizeDelta);
|
||||
backgroundImage.sprite = m_Background.image;
|
||||
backgroundImage.type = m_Background.imageType;
|
||||
backgroundImage.color = m_Background.imageColor;
|
||||
backgroundObj.transform.SetSiblingIndex(0);
|
||||
backgroundObj.SetActive(m_Background.show);
|
||||
};
|
||||
m_Background.refreshComponent();
|
||||
}
|
||||
|
||||
protected virtual void InitPainter()
|
||||
{
|
||||
var painterObj = ChartHelper.AddObject("painter_b", transform, m_GraphMinAnchor, m_GraphMaxAnchor,
|
||||
m_GraphPivot, new Vector2(m_GraphWidth, m_GraphHeight));
|
||||
painterObj.transform.SetSiblingIndex(1);
|
||||
painterObj.hideFlags = chartHideFlags;
|
||||
m_Painter = ChartHelper.GetOrAddComponent<Painter>(painterObj);
|
||||
m_Painter.type = Painter.Type.Base;
|
||||
m_Painter.onPopulateMesh = OnDrawPainterBase;
|
||||
}
|
||||
|
||||
private void CheckSize()
|
||||
{
|
||||
var currWidth = rectTransform.rect.width;
|
||||
@@ -198,11 +307,22 @@ namespace XCharts
|
||||
{
|
||||
if (m_RefreshChart)
|
||||
{
|
||||
SetVerticesDirty();
|
||||
m_Painter.Refresh();
|
||||
m_RefreshChart = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CheckRefreshPainter()
|
||||
{
|
||||
m_Painter.CheckRefresh();
|
||||
}
|
||||
|
||||
internal virtual void RefreshPainter(Painter painter)
|
||||
{
|
||||
if (painter == null) return;
|
||||
painter.Refresh();
|
||||
}
|
||||
|
||||
protected virtual void OnSizeChanged()
|
||||
{
|
||||
m_RefreshChart = true;
|
||||
@@ -212,14 +332,14 @@ namespace XCharts
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
protected virtual void OnDrawPainterBase(VertexHelper vh, Painter painter)
|
||||
{
|
||||
vh.Clear();
|
||||
Debug.LogError("OnDrawPainterBase:" + Time.frameCount + "," + painter.name);
|
||||
DrawBackground(vh);
|
||||
DrawGraphic(vh);
|
||||
DrawPainterBase(vh);
|
||||
}
|
||||
|
||||
protected virtual void DrawGraphic(VertexHelper vh)
|
||||
protected virtual void DrawPainterBase(VertexHelper vh)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,48 +1,45 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
public partial class CoordinateChart
|
||||
{
|
||||
protected float m_BarLastOffset = 0;
|
||||
protected Action<PointerEventData, int> m_OnPointerClickBar;
|
||||
|
||||
protected void DrawYBarSerie(VertexHelper vh, Serie serie, int colorIndex, ref List<float> seriesHig)
|
||||
protected void DrawYBarSerie(VertexHelper vh, Serie serie, int colorIndex)
|
||||
{
|
||||
if (!IsActive(serie.name)) return;
|
||||
if (serie.animation.HasFadeOut()) return;
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
var yAxis = m_YAxises[serie.axisIndex];
|
||||
if (!yAxis.show) yAxis = m_YAxises[(serie.axisIndex + 1) % m_YAxises.Count];
|
||||
|
||||
var showData = serie.GetDataList(m_DataZoom);
|
||||
float categoryWidth = AxisHelper.GetDataWidth(yAxis, m_CoordinateHeight, showData.Count, m_DataZoom);
|
||||
var xAxis = m_XAxes[serie.xAxisIndex];
|
||||
var yAxis = m_YAxes[serie.yAxisIndex];
|
||||
var grid = GetSerieGridOrDefault(serie);
|
||||
var showData = serie.GetDataList(dataZoom);
|
||||
float categoryWidth = AxisHelper.GetDataWidth(yAxis, grid.runtimeHeight, showData.Count, dataZoom);
|
||||
float barGap = GetBarGap();
|
||||
float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
|
||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||
float offset = (categoryWidth - totalBarWidth) / 2;
|
||||
float barGapWidth = barWidth + barWidth * barGap;
|
||||
float space = serie.barGap == -1 ? offset : offset + m_BarLastOffset;
|
||||
|
||||
float space = serie.barGap == -1 ? offset : offset + GetBarIndex(serie) * barGapWidth;
|
||||
var isStack = SeriesHelper.IsStack(m_Series, serie.stack, SerieType.Bar);
|
||||
m_StackSerieData.Clear();
|
||||
if (isStack) SeriesHelper.UpdateStackDataList(m_Series, serie, dataZoom, m_StackSerieData);
|
||||
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
if (seriesHig.Count < serie.minShow)
|
||||
{
|
||||
for (int i = 0; i < serie.minShow; i++)
|
||||
{
|
||||
seriesHig.Add(0);
|
||||
}
|
||||
}
|
||||
var isPercentStack = SeriesHelper.IsPercentStack(m_Series, serie.stack, SerieType.Bar);
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
@@ -51,17 +48,13 @@ namespace XCharts
|
||||
var isAllBarEnd = true;
|
||||
for (int i = serie.minShow; i < maxCount; i++)
|
||||
{
|
||||
if (i >= seriesHig.Count)
|
||||
{
|
||||
seriesHig.Add(0);
|
||||
}
|
||||
var serieData = showData[i];
|
||||
if (serie.IsIgnoreValue(serieData.GetData(1)))
|
||||
{
|
||||
serie.dataPoints.Add(Vector3.zero);
|
||||
continue;
|
||||
}
|
||||
var highlight = (m_Tooltip.show && m_Tooltip.IsSelected(i))
|
||||
var highlight = (tooltip.show && tooltip.IsSelected(i))
|
||||
|| serie.data[i].highlighted
|
||||
|| serie.highlighted;
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);
|
||||
@@ -70,28 +63,34 @@ namespace XCharts
|
||||
float value = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse, xMinValue, xMaxValue);
|
||||
float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
if (showData[i].IsDataChanged()) dataChanging = true;
|
||||
float axisLineWidth = (value < 0 ? -1 : 1) * yAxis.axisLine.width;
|
||||
float pX = seriesHig[i] + m_CoordinateX + xAxis.runtimeZeroXOffset + axisLineWidth;
|
||||
float pY = m_CoordinateY + i * categoryWidth;
|
||||
float axisLineWidth = (value < 0 ? -1 : 1) * yAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
|
||||
float pY = grid.runtimeY + i * categoryWidth;
|
||||
if (!yAxis.boundaryGap) pY -= categoryWidth / 2;
|
||||
float pX = grid.runtimeX + xAxis.runtimeZeroXOffset + axisLineWidth;
|
||||
if (isStack)
|
||||
{
|
||||
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
|
||||
{
|
||||
pX += m_StackSerieData[n][i].runtimeStackHig;
|
||||
}
|
||||
}
|
||||
|
||||
var barHig = 0f;
|
||||
var valueTotal = 0f;
|
||||
if (isPercentStack)
|
||||
{
|
||||
valueTotal = GetSameStackTotalValue(serie.stack, i);
|
||||
barHig = valueTotal != 0 ? (value / valueTotal * m_CoordinateWidth) : 0;
|
||||
seriesHig[i] += barHig;
|
||||
barHig = valueTotal != 0 ? (value / valueTotal * grid.runtimeWidth) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
valueTotal = xMaxValue - xMinValue;
|
||||
if (valueTotal != 0)
|
||||
barHig = (xMinValue > 0 ? value - xMinValue : value)
|
||||
/ valueTotal * m_CoordinateWidth;
|
||||
seriesHig[i] += barHig;
|
||||
/ valueTotal * grid.runtimeWidth;
|
||||
}
|
||||
|
||||
serieData.runtimeStackHig = barHig;
|
||||
var isBarEnd = false;
|
||||
float currHig = CheckAnimation(serie, i, barHig, out isBarEnd);
|
||||
if (!isBarEnd) isAllBarEnd = false;
|
||||
@@ -111,11 +110,11 @@ namespace XCharts
|
||||
plb = new Vector3(pX + borderWidth, pY + space + borderWidth);
|
||||
}
|
||||
top = new Vector3(pX + currHig - borderWidth, pY + space + barWidth / 2);
|
||||
plt = ClampInCoordinate(plt);
|
||||
prt = ClampInCoordinate(prt);
|
||||
prb = ClampInCoordinate(prb);
|
||||
plb = ClampInCoordinate(plb);
|
||||
top = ClampInCoordinate(top);
|
||||
plt = ClampInGrid(grid, plt);
|
||||
prt = ClampInGrid(grid, prt);
|
||||
prb = ClampInGrid(grid, prb);
|
||||
plb = ClampInGrid(grid, plb);
|
||||
top = ClampInGrid(grid, top);
|
||||
serie.dataPoints.Add(top);
|
||||
if (serie.show)
|
||||
{
|
||||
@@ -123,27 +122,23 @@ namespace XCharts
|
||||
{
|
||||
case BarType.Normal:
|
||||
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||
pX, pY, plb, plt, prt, prb, true);
|
||||
pX, pY, plb, plt, prt, prb, true, grid);
|
||||
break;
|
||||
case BarType.Zebra:
|
||||
DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||
pX, pY, plb, plt, prt, prb, true);
|
||||
pX, pY, plb, plt, prt, prb, true, grid);
|
||||
break;
|
||||
case BarType.Capsule:
|
||||
DrawCapsuleBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||
pX, pY, plb, plt, prt, prb, true);
|
||||
pX, pY, plb, plt, prt, prb, true, grid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isAllBarEnd) serie.animation.AllBarEnd();
|
||||
if (!SeriesHelper.IsStack(m_Series, serie.stack, SerieType.Bar))
|
||||
{
|
||||
m_BarLastOffset += barGapWidth;
|
||||
}
|
||||
if (dataChanging)
|
||||
{
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,40 +147,34 @@ namespace XCharts
|
||||
float currHig = serie.animation.CheckBarProgress(dataIndex, barHig, serie.dataCount, out isBarEnd);
|
||||
if (!serie.animation.IsFinish())
|
||||
{
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
m_IsPlayingAnimation = true;
|
||||
}
|
||||
return currHig;
|
||||
}
|
||||
|
||||
protected void DrawXBarSerie(VertexHelper vh, Serie serie, int colorIndex, ref List<float> seriesHig)
|
||||
protected void DrawXBarSerie(VertexHelper vh, Serie serie, int colorIndex)
|
||||
{
|
||||
if (!IsActive(serie.index)) return;
|
||||
if (serie.animation.HasFadeOut()) return;
|
||||
var showData = serie.GetDataList(m_DataZoom);
|
||||
var yAxis = m_YAxises[serie.axisIndex];
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
if (!xAxis.show) xAxis = m_XAxises[(serie.axisIndex + 1) % m_XAxises.Count];
|
||||
|
||||
float categoryWidth = AxisHelper.GetDataWidth(xAxis, m_CoordinateWidth, showData.Count, m_DataZoom);
|
||||
var showData = serie.GetDataList(dataZoom);
|
||||
var yAxis = m_YAxes[serie.yAxisIndex];
|
||||
var xAxis = m_XAxes[serie.xAxisIndex];
|
||||
var grid = GetSerieGridOrDefault(serie);
|
||||
var isStack = SeriesHelper.IsStack(m_Series, serie.stack, SerieType.Bar);
|
||||
m_StackSerieData.Clear();
|
||||
if (isStack) SeriesHelper.UpdateStackDataList(m_Series, serie, dataZoom, m_StackSerieData);
|
||||
float categoryWidth = AxisHelper.GetDataWidth(xAxis, grid.runtimeWidth, showData.Count, dataZoom);
|
||||
float barGap = GetBarGap();
|
||||
float totalBarWidth = GetBarTotalWidth(categoryWidth, barGap);
|
||||
float barWidth = serie.GetBarWidth(categoryWidth);
|
||||
float offset = (categoryWidth - totalBarWidth) / 2;
|
||||
float barGapWidth = barWidth + barWidth * barGap;
|
||||
float space = serie.barGap == -1 ? offset : offset + m_BarLastOffset;
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
float space = serie.barGap == -1 ? offset : offset + GetBarIndex(serie) * barGapWidth;
|
||||
int maxCount = serie.maxShow > 0
|
||||
? (serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
|
||||
: showData.Count;
|
||||
|
||||
if (seriesHig.Count < serie.minShow)
|
||||
{
|
||||
for (int i = 0; i < serie.minShow; i++)
|
||||
{
|
||||
seriesHig.Add(0);
|
||||
}
|
||||
}
|
||||
|
||||
var isPercentStack = SeriesHelper.IsPercentStack(m_Series, serie.stack, SerieType.Bar);
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
@@ -194,45 +183,48 @@ namespace XCharts
|
||||
var isAllBarEnd = true;
|
||||
for (int i = serie.minShow; i < maxCount; i++)
|
||||
{
|
||||
if (i >= seriesHig.Count)
|
||||
{
|
||||
seriesHig.Add(0);
|
||||
}
|
||||
var serieData = showData[i];
|
||||
if (serie.IsIgnoreValue(serieData.GetData(1)))
|
||||
{
|
||||
serie.dataPoints.Add(Vector3.zero);
|
||||
continue;
|
||||
}
|
||||
var highlight = (m_Tooltip.show && m_Tooltip.IsSelected(i))
|
||||
var highlight = (tooltip.show && tooltip.IsSelected(i))
|
||||
|| serie.data[i].highlighted
|
||||
|| serie.highlighted;
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);
|
||||
float value = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue);
|
||||
float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
float pX = m_CoordinateX + i * categoryWidth;
|
||||
float zeroY = m_CoordinateY + yAxis.runtimeZeroYOffset;
|
||||
float pX = grid.runtimeX + i * categoryWidth;
|
||||
float zeroY = grid.runtimeY + yAxis.runtimeZeroYOffset;
|
||||
if (!xAxis.boundaryGap) pX -= categoryWidth / 2;
|
||||
float axisLineWidth = (value < 0 ? -1 : 1) * xAxis.axisLine.width;
|
||||
float pY = seriesHig[i] + zeroY + axisLineWidth;
|
||||
float axisLineWidth = (value < 0 ? -1 : 1) * xAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
float pY = zeroY + axisLineWidth;
|
||||
if (isStack)
|
||||
{
|
||||
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
|
||||
{
|
||||
pY += m_StackSerieData[n][i].runtimeStackHig;
|
||||
}
|
||||
}
|
||||
|
||||
var barHig = 0f;
|
||||
var valueTotal = 0f;
|
||||
if (isPercentStack)
|
||||
{
|
||||
valueTotal = GetSameStackTotalValue(serie.stack, i);
|
||||
barHig = valueTotal != 0 ? (value / valueTotal * m_CoordinateHeight) : 0;
|
||||
seriesHig[i] += barHig;
|
||||
barHig = valueTotal != 0 ? (value / valueTotal * grid.runtimeHeight) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
valueTotal = yMaxValue - yMinValue;
|
||||
if (valueTotal != 0)
|
||||
barHig = (yMinValue > 0 ? value - yMinValue : value)
|
||||
/ valueTotal * m_CoordinateHeight;
|
||||
seriesHig[i] += barHig;
|
||||
{
|
||||
barHig = (yMinValue > 0 ? value - yMinValue : value) / valueTotal * grid.runtimeHeight;
|
||||
}
|
||||
}
|
||||
serieData.runtimeStackHig = barHig;
|
||||
var isBarEnd = false;
|
||||
float currHig = CheckAnimation(serie, i, barHig, out isBarEnd);
|
||||
if (!isBarEnd) isAllBarEnd = false;
|
||||
@@ -254,11 +246,11 @@ namespace XCharts
|
||||
top = new Vector3(pX + space + barWidth / 2, pY + currHig - borderWidth);
|
||||
if (serie.clip)
|
||||
{
|
||||
plb = ClampInCoordinate(plb);
|
||||
plt = ClampInCoordinate(plt);
|
||||
prt = ClampInCoordinate(prt);
|
||||
prb = ClampInCoordinate(prb);
|
||||
top = ClampInCoordinate(top);
|
||||
plb = ClampInGrid(grid, plb);
|
||||
plt = ClampInGrid(grid, plt);
|
||||
prt = ClampInGrid(grid, prt);
|
||||
prb = ClampInGrid(grid, prb);
|
||||
top = ClampInGrid(grid, top);
|
||||
}
|
||||
serie.dataPoints.Add(top);
|
||||
if (serie.show && currHig != 0)
|
||||
@@ -267,15 +259,15 @@ namespace XCharts
|
||||
{
|
||||
case BarType.Normal:
|
||||
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||
pX, pY, plb, plt, prt, prb, false);
|
||||
pX, pY, plb, plt, prt, prb, false, grid);
|
||||
break;
|
||||
case BarType.Zebra:
|
||||
DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||
pX, pY, plb, plt, prt, prb, false);
|
||||
pX, pY, plb, plt, prt, prb, false, grid);
|
||||
break;
|
||||
case BarType.Capsule:
|
||||
DrawCapsuleBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||
pX, pY, plb, plt, prt, prb, false);
|
||||
pX, pY, plb, plt, prt, prb, false, grid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -286,30 +278,26 @@ namespace XCharts
|
||||
}
|
||||
if (dataChanging)
|
||||
{
|
||||
RefreshChart();
|
||||
}
|
||||
if (!SeriesHelper.IsStack(m_Series, serie.stack, SerieType.Bar))
|
||||
{
|
||||
m_BarLastOffset += barGapWidth;
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
Vector3 prb, bool isYAxis)
|
||||
Vector3 prb, bool isYAxis, Grid grid)
|
||||
{
|
||||
var areaColor = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
|
||||
var areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis);
|
||||
var areaColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
var areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
|
||||
var borderWidth = itemStyle.runtimeBorderWidth;
|
||||
if (isYAxis)
|
||||
{
|
||||
if (serie.clip)
|
||||
{
|
||||
prb = ClampInCoordinate(prb);
|
||||
plb = ClampInCoordinate(plb);
|
||||
plt = ClampInCoordinate(plt);
|
||||
prt = ClampInCoordinate(prt);
|
||||
prb = ClampInGrid(grid, prb);
|
||||
plb = ClampInGrid(grid, plb);
|
||||
plt = ClampInGrid(grid, plt);
|
||||
prt = ClampInGrid(grid, prt);
|
||||
}
|
||||
var borderColor = itemStyle.borderColor;
|
||||
var itemWidth = Mathf.Abs(prb.x - plt.x);
|
||||
@@ -319,23 +307,25 @@ namespace XCharts
|
||||
{
|
||||
if (ItemStyleHelper.IsNeedCorner(itemStyle))
|
||||
{
|
||||
ChartDrawer.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0, itemStyle.cornerRadius, isYAxis);
|
||||
UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
|
||||
itemStyle.cornerRadius, isYAxis);
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip);
|
||||
CheckClipAndDrawPolygon(vh, plb, plt, prt, prb, areaColor, areaToColor, serie.clip, grid);
|
||||
}
|
||||
ChartDrawer.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, borderColor, 0, itemStyle.cornerRadius, isYAxis);
|
||||
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, borderColor, 0,
|
||||
itemStyle.cornerRadius, isYAxis);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (serie.clip)
|
||||
{
|
||||
prb = ClampInCoordinate(prb);
|
||||
plb = ClampInCoordinate(plb);
|
||||
plt = ClampInCoordinate(plt);
|
||||
prt = ClampInCoordinate(prt);
|
||||
prb = ClampInGrid(grid, prb);
|
||||
plb = ClampInGrid(grid, plb);
|
||||
plt = ClampInGrid(grid, plt);
|
||||
prt = ClampInGrid(grid, prt);
|
||||
}
|
||||
var borderColor = itemStyle.borderColor;
|
||||
var itemWidth = Mathf.Abs(prt.x - plb.x);
|
||||
@@ -345,46 +335,49 @@ namespace XCharts
|
||||
{
|
||||
if (ItemStyleHelper.IsNeedCorner(itemStyle))
|
||||
{
|
||||
ChartDrawer.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0, itemStyle.cornerRadius, isYAxis);
|
||||
UGL.DrawRoundRectangle(vh, center, itemWidth, itemHeight, areaColor, areaToColor, 0,
|
||||
itemStyle.cornerRadius, isYAxis);
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaToColor, serie.clip);
|
||||
CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, areaColor, areaToColor,
|
||||
serie.clip, grid);
|
||||
}
|
||||
ChartDrawer.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, borderColor, 0, itemStyle.cornerRadius, isYAxis);
|
||||
UGL.DrawBorder(vh, center, itemWidth, itemHeight, borderWidth, borderColor, 0,
|
||||
itemStyle.cornerRadius, isYAxis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawZebraBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
Vector3 prb, bool isYAxis)
|
||||
Vector3 prb, bool isYAxis, Grid grid)
|
||||
{
|
||||
var areaColor = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis);
|
||||
var areaColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
|
||||
if (isYAxis)
|
||||
{
|
||||
plt = (plb + plt) / 2;
|
||||
prt = (prt + prb) / 2;
|
||||
CheckClipAndDrawZebraLine(vh, plt, prt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
|
||||
areaColor, serie.clip);
|
||||
areaColor, serie.clip, grid);
|
||||
}
|
||||
else
|
||||
{
|
||||
plb = (prb + plb) / 2;
|
||||
plt = (plt + prt) / 2;
|
||||
CheckClipAndDrawZebraLine(vh, plb, plt, barWidth / 2, serie.barZebraWidth, serie.barZebraGap,
|
||||
areaColor, serie.clip);
|
||||
areaColor, serie.clip, grid);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCapsuleBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||
Vector3 prb, bool isYAxis)
|
||||
Vector3 prb, bool isYAxis, Grid grid)
|
||||
{
|
||||
var areaColor = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
|
||||
var areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis);
|
||||
var areaColor = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
var areaToColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
|
||||
var borderWidth = itemStyle.runtimeBorderWidth;
|
||||
var radius = barWidth / 2 - borderWidth;
|
||||
var isGradient = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);
|
||||
@@ -402,15 +395,17 @@ namespace XCharts
|
||||
var barLen = prt.x - plt.x;
|
||||
var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
|
||||
var rectEndColor = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
|
||||
CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, rectStartColor, rectEndColor, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pcl, radius, areaColor, rectStartColor, 180, 360, 1, isYAxis);
|
||||
ChartDrawer.DrawSector(vh, pcr, radius, rectEndColor, areaToColor, 0, 180, 1, isYAxis);
|
||||
CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, rectStartColor,
|
||||
rectEndColor, serie.clip, grid);
|
||||
UGL.DrawSector(vh, pcl, radius, areaColor, rectStartColor, 180, 360, 1, isYAxis);
|
||||
UGL.DrawSector(vh, pcr, radius, rectEndColor, areaToColor, 0, 180, 1, isYAxis);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, areaColor,
|
||||
areaToColor, serie.clip, grid);
|
||||
UGL.DrawSector(vh, pcl, radius, areaColor, 180, 360);
|
||||
UGL.DrawSector(vh, pcr, radius, areaToColor, 0, 180);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,15 +420,17 @@ namespace XCharts
|
||||
var barLen = plt.x - prt.x;
|
||||
var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
|
||||
var rectEndColor = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
|
||||
CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, rectStartColor, rectEndColor, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pcl, radius, rectStartColor, areaColor, 0, 180, 1, isYAxis);
|
||||
ChartDrawer.DrawSector(vh, pcr, radius, areaToColor, rectEndColor, 180, 360, 1, isYAxis);
|
||||
CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, rectStartColor,
|
||||
rectEndColor, serie.clip, grid);
|
||||
UGL.DrawSector(vh, pcl, radius, rectStartColor, areaColor, 0, 180, 1, isYAxis);
|
||||
UGL.DrawSector(vh, pcr, radius, areaToColor, rectEndColor, 180, 360, 1, isYAxis);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
CheckClipAndDrawPolygon(vh, plb - diff, plt - diff, prt + diff, prb + diff, areaColor,
|
||||
areaToColor, serie.clip, grid);
|
||||
UGL.DrawSector(vh, pcl, radius, areaColor, 0, 180);
|
||||
UGL.DrawSector(vh, pcr, radius, areaToColor, 180, 360);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -452,15 +449,17 @@ namespace XCharts
|
||||
var barLen = plt.y - plb.y;
|
||||
var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
|
||||
var rectEndColor = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
|
||||
CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, rectStartColor, rectEndColor, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pct, radius, rectEndColor, areaToColor, 270, 450, 1, isYAxis);
|
||||
ChartDrawer.DrawSector(vh, pcb, radius, rectStartColor, areaColor, 90, 270, 1, isYAxis);
|
||||
CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, rectStartColor,
|
||||
rectEndColor, serie.clip, grid);
|
||||
UGL.DrawSector(vh, pct, radius, rectEndColor, areaToColor, 270, 450, 1, isYAxis);
|
||||
UGL.DrawSector(vh, pcb, radius, rectStartColor, areaColor, 90, 270, 1, isYAxis);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, areaColor,
|
||||
areaToColor, serie.clip, grid);
|
||||
UGL.DrawSector(vh, pct, radius, areaToColor, 270, 450);
|
||||
UGL.DrawSector(vh, pcb, radius, areaColor, 90, 270);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -475,102 +474,109 @@ namespace XCharts
|
||||
var barLen = plb.y - plt.y;
|
||||
var rectStartColor = Color32.Lerp(areaColor, areaToColor, radius / barLen);
|
||||
var rectEndColor = Color32.Lerp(areaColor, areaToColor, (barLen - radius) / barLen);
|
||||
CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, rectStartColor, rectEndColor, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pct, radius, rectEndColor, areaToColor, 90, 270, 1, isYAxis);
|
||||
ChartDrawer.DrawSector(vh, pcb, radius, rectStartColor, areaColor, 270, 450, 1, isYAxis);
|
||||
CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, rectStartColor,
|
||||
rectEndColor, serie.clip, grid);
|
||||
UGL.DrawSector(vh, pct, radius, rectEndColor, areaToColor, 90, 270, 1, isYAxis);
|
||||
UGL.DrawSector(vh, pcb, radius, rectStartColor, areaColor, 270, 450, 1, isYAxis);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
CheckClipAndDrawPolygon(vh, prb - diff, plb - diff, plt + diff, prt + diff, areaColor,
|
||||
areaToColor, serie.clip, grid);
|
||||
UGL.DrawSector(vh, pct, radius, areaToColor, 90, 270);
|
||||
UGL.DrawSector(vh, pcb, radius, areaColor, 270, 450);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawBarBackground(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
||||
bool highlight, float pX, float pY, float space, float barWidth, bool isYAxis)
|
||||
private void DrawBarBackground(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle,
|
||||
int colorIndex, bool highlight, float pX, float pY, float space, float barWidth, bool isYAxis, Grid grid)
|
||||
{
|
||||
var color = SerieHelper.GetItemBackgroundColor(serie, serieData, m_ThemeInfo, colorIndex, highlight, false);
|
||||
var color = SerieHelper.GetItemBackgroundColor(serie, serieData, m_Theme, colorIndex, highlight, false);
|
||||
if (ChartHelper.IsClearColor(color)) return;
|
||||
if (isYAxis)
|
||||
{
|
||||
var axis = m_YAxises[serie.axisIndex];
|
||||
var axisWidth = axis.axisLine.width;
|
||||
Vector3 plt = new Vector3(m_CoordinateX + axisWidth, pY + space + barWidth);
|
||||
Vector3 prt = new Vector3(m_CoordinateX + axisWidth + m_CoordinateWidth, pY + space + barWidth);
|
||||
Vector3 prb = new Vector3(m_CoordinateX + axisWidth + m_CoordinateWidth, pY + space);
|
||||
Vector3 plb = new Vector3(m_CoordinateX + axisWidth, pY + space);
|
||||
var axis = m_YAxes[serie.yAxisIndex];
|
||||
var axisWidth = axis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
Vector3 plt = new Vector3(grid.runtimeX + axisWidth, pY + space + barWidth);
|
||||
Vector3 prt = new Vector3(grid.runtimeX + axisWidth + grid.runtimeWidth, pY + space + barWidth);
|
||||
Vector3 prb = new Vector3(grid.runtimeX + axisWidth + grid.runtimeWidth, pY + space);
|
||||
Vector3 plb = new Vector3(grid.runtimeX + axisWidth, pY + space);
|
||||
if (serie.barType == BarType.Capsule)
|
||||
{
|
||||
var radius = barWidth / 2;
|
||||
var diff = Vector3.right * radius;
|
||||
var pcl = (plt + plb) / 2 + diff;
|
||||
var pcr = (prt + prb) / 2 - diff;
|
||||
CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, color, color, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pcl, radius, color, 180, 360);
|
||||
ChartDrawer.DrawSector(vh, pcr, radius, color, 0, 180);
|
||||
CheckClipAndDrawPolygon(vh, plb + diff, plt + diff, prt - diff, prb - diff, color, color, serie.clip, grid);
|
||||
UGL.DrawSector(vh, pcl, radius, color, 180, 360);
|
||||
UGL.DrawSector(vh, pcr, radius, color, 0, 180);
|
||||
if (itemStyle.NeedShowBorder())
|
||||
{
|
||||
var borderWidth = itemStyle.borderWidth;
|
||||
var borderColor = itemStyle.borderColor;
|
||||
var smoothness = m_Settings.cicleSmoothness;
|
||||
var smoothness = settings.cicleSmoothness;
|
||||
var inRadius = radius - borderWidth;
|
||||
var outRadius = radius;
|
||||
var p1 = plb + diff + Vector3.up * borderWidth / 2;
|
||||
var p2 = prb - diff + Vector3.up * borderWidth / 2;
|
||||
var p3 = plt + diff - Vector3.up * borderWidth / 2;
|
||||
var p4 = prt - diff - Vector3.up * borderWidth / 2;
|
||||
ChartDrawer.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
|
||||
ChartDrawer.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
|
||||
ChartDrawer.DrawDoughnut(vh, pcl, inRadius, outRadius, borderColor, ChartConst.clearColor32, 180, 360, smoothness);
|
||||
ChartDrawer.DrawDoughnut(vh, pcr, inRadius, outRadius, borderColor, ChartConst.clearColor32, 0, 180, smoothness);
|
||||
UGL.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
|
||||
UGL.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
|
||||
UGL.DrawDoughnut(vh, pcl, inRadius, outRadius, borderColor, ChartConst.clearColor32,
|
||||
180, 360, smoothness);
|
||||
UGL.DrawDoughnut(vh, pcr, inRadius, outRadius, borderColor, ChartConst.clearColor32,
|
||||
0, 180, smoothness);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckClipAndDrawPolygon(vh, ref plb, ref plt, ref prt, ref prb, color, color, serie.clip);
|
||||
CheckClipAndDrawPolygon(vh, ref plb, ref plt, ref prt, ref prb, color, color, serie.clip, grid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var axis = m_XAxises[serie.axisIndex];
|
||||
var axisWidth = axis.axisLine.width;
|
||||
Vector3 plb = new Vector3(pX + space, m_CoordinateY + axisWidth);
|
||||
Vector3 plt = new Vector3(pX + space, m_CoordinateY + m_CoordinateHeight + axisWidth);
|
||||
Vector3 prt = new Vector3(pX + space + barWidth, m_CoordinateY + m_CoordinateHeight + axisWidth);
|
||||
Vector3 prb = new Vector3(pX + space + barWidth, m_CoordinateY + axisWidth);
|
||||
var axis = m_XAxes[serie.xAxisIndex];
|
||||
var axisWidth = axis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
Vector3 plb = new Vector3(pX + space, grid.runtimeY + axisWidth);
|
||||
Vector3 plt = new Vector3(pX + space, grid.runtimeY + grid.runtimeHeight + axisWidth);
|
||||
Vector3 prt = new Vector3(pX + space + barWidth, grid.runtimeY + grid.runtimeHeight + axisWidth);
|
||||
Vector3 prb = new Vector3(pX + space + barWidth, grid.runtimeY + axisWidth);
|
||||
if (serie.barType == BarType.Capsule)
|
||||
{
|
||||
var radius = barWidth / 2;
|
||||
var diff = Vector3.up * radius;
|
||||
var pct = (plt + prt) / 2 - diff;
|
||||
var pcb = (plb + prb) / 2 + diff;
|
||||
CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, color, color, serie.clip);
|
||||
ChartDrawer.DrawSector(vh, pct, radius, color, 270, 450);
|
||||
ChartDrawer.DrawSector(vh, pcb, radius, color, 90, 270);
|
||||
CheckClipAndDrawPolygon(vh, prb + diff, plb + diff, plt - diff, prt - diff, color, color,
|
||||
serie.clip, grid);
|
||||
UGL.DrawSector(vh, pct, radius, color, 270, 450);
|
||||
UGL.DrawSector(vh, pcb, radius, color, 90, 270);
|
||||
if (itemStyle.NeedShowBorder())
|
||||
{
|
||||
var borderWidth = itemStyle.borderWidth;
|
||||
var borderColor = itemStyle.borderColor;
|
||||
var smoothness = m_Settings.cicleSmoothness;
|
||||
var smoothness = settings.cicleSmoothness;
|
||||
var inRadius = radius - borderWidth;
|
||||
var outRadius = radius;
|
||||
var p1 = plb + diff + Vector3.right * borderWidth / 2;
|
||||
var p2 = plt - diff + Vector3.right * borderWidth / 2;
|
||||
var p3 = prb + diff - Vector3.right * borderWidth / 2;
|
||||
var p4 = prt - diff - Vector3.right * borderWidth / 2;
|
||||
ChartDrawer.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
|
||||
ChartDrawer.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
|
||||
ChartDrawer.DrawDoughnut(vh, pct, inRadius, outRadius, borderColor, ChartConst.clearColor32, 270, 450, smoothness);
|
||||
ChartDrawer.DrawDoughnut(vh, pcb, inRadius, outRadius, borderColor, ChartConst.clearColor32, 90, 270, smoothness);
|
||||
UGL.DrawLine(vh, p1, p2, borderWidth / 2, borderColor);
|
||||
UGL.DrawLine(vh, p3, p4, borderWidth / 2, borderColor);
|
||||
UGL.DrawDoughnut(vh, pct, inRadius, outRadius, borderColor, ChartConst.clearColor32,
|
||||
270, 450, smoothness);
|
||||
UGL.DrawDoughnut(vh, pcb, inRadius, outRadius, borderColor, ChartConst.clearColor32,
|
||||
90, 270, smoothness);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color, serie.clip);
|
||||
CheckClipAndDrawPolygon(vh, ref prb, ref plb, ref plt, ref prt, color, color, serie.clip, grid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -658,5 +664,37 @@ namespace XCharts
|
||||
if (barWidth > 1) return barWidth;
|
||||
else return barWidth * categoryWidth;
|
||||
}
|
||||
|
||||
private List<string> tempList = new List<string>();
|
||||
private int GetBarIndex(Serie currSerie)
|
||||
{
|
||||
tempList.Clear();
|
||||
int index = 0;
|
||||
for (int i = 0; i < m_Series.Count; i++)
|
||||
{
|
||||
var serie = m_Series.GetSerie(i);
|
||||
if (serie.type != SerieType.Bar) continue;
|
||||
if (string.IsNullOrEmpty(serie.stack))
|
||||
{
|
||||
if (serie.index == currSerie.index) return index;
|
||||
tempList.Add(string.Empty);
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!tempList.Contains(serie.stack))
|
||||
{
|
||||
if (serie.index == currSerie.index) return index;
|
||||
tempList.Add(serie.stack);
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (serie.index == currSerie.index) return tempList.IndexOf(serie.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
@@ -17,62 +18,62 @@ namespace XCharts
|
||||
|
||||
protected void CheckVisualMap()
|
||||
{
|
||||
if (!m_VisualMap.enable || !m_VisualMap.show) return;
|
||||
if (!visualMap.enable || !visualMap.show) return;
|
||||
Vector2 local;
|
||||
if (canvas == null) return;
|
||||
|
||||
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform,
|
||||
Input.mousePosition, canvas.worldCamera, out local))
|
||||
{
|
||||
if (m_VisualMap.runtimeSelectedIndex >= 0)
|
||||
if (visualMap.runtimeSelectedIndex >= 0)
|
||||
{
|
||||
m_VisualMap.runtimeSelectedIndex = -1;
|
||||
visualMap.runtimeSelectedIndex = -1;
|
||||
RefreshChart();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (local.x < chartX || local.x > chartX + chartWidth ||
|
||||
local.y < chartY || local.y > chartY + chartHeight ||
|
||||
!m_VisualMap.IsInRangeRect(local, chartRect))
|
||||
!visualMap.IsInRangeRect(local, chartRect))
|
||||
{
|
||||
if (m_VisualMap.runtimeSelectedIndex >= 0)
|
||||
if (visualMap.runtimeSelectedIndex >= 0)
|
||||
{
|
||||
m_VisualMap.runtimeSelectedIndex = -1;
|
||||
visualMap.runtimeSelectedIndex = -1;
|
||||
RefreshChart();
|
||||
}
|
||||
return;
|
||||
}
|
||||
var pos1 = Vector3.zero;
|
||||
var pos2 = Vector3.zero;
|
||||
var halfHig = m_VisualMap.itemHeight / 2;
|
||||
var centerPos = chartPosition + m_VisualMap.location.GetPosition(chartWidth, chartHeight);
|
||||
var halfHig = visualMap.itemHeight / 2;
|
||||
var centerPos = chartPosition + visualMap.location.GetPosition(chartWidth, chartHeight);
|
||||
var selectedIndex = -1;
|
||||
var value = 0f;
|
||||
switch (m_VisualMap.orient)
|
||||
switch (visualMap.orient)
|
||||
{
|
||||
case Orient.Horizonal:
|
||||
pos1 = centerPos + Vector3.left * halfHig;
|
||||
pos2 = centerPos + Vector3.right * halfHig;
|
||||
value = m_VisualMap.min + (local.x - pos1.x) / (pos2.x - pos1.x) * (m_VisualMap.max - m_VisualMap.min);
|
||||
selectedIndex = m_VisualMap.GetIndex(value);
|
||||
value = visualMap.min + (local.x - pos1.x) / (pos2.x - pos1.x) * (visualMap.max - visualMap.min);
|
||||
selectedIndex = visualMap.GetIndex(value);
|
||||
break;
|
||||
case Orient.Vertical:
|
||||
pos1 = centerPos + Vector3.down * halfHig;
|
||||
pos2 = centerPos + Vector3.up * halfHig;
|
||||
value = m_VisualMap.min + (local.y - pos1.y) / (pos2.y - pos1.y) * (m_VisualMap.max - m_VisualMap.min);
|
||||
selectedIndex = m_VisualMap.GetIndex(value);
|
||||
value = visualMap.min + (local.y - pos1.y) / (pos2.y - pos1.y) * (visualMap.max - visualMap.min);
|
||||
selectedIndex = visualMap.GetIndex(value);
|
||||
break;
|
||||
}
|
||||
m_VisualMap.runtimeSelectedValue = value;
|
||||
m_VisualMap.runtimeSelectedIndex = selectedIndex;
|
||||
visualMap.runtimeSelectedValue = value;
|
||||
visualMap.runtimeSelectedIndex = selectedIndex;
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
protected void OnDragVisualMapStart()
|
||||
{
|
||||
if (!m_VisualMap.enable || !m_VisualMap.show || !m_VisualMap.calculable) return;
|
||||
var inMinRect = m_VisualMap.IsInRangeMinRect(pointerPos, chartRect, m_Settings.visualMapTriangeLen);
|
||||
var inMaxRect = m_VisualMap.IsInRangeMaxRect(pointerPos, chartRect, m_Settings.visualMapTriangeLen);
|
||||
if (!visualMap.enable || !visualMap.show || !visualMap.calculable) return;
|
||||
var inMinRect = visualMap.IsInRangeMinRect(pointerPos, chartRect, m_Theme.visualMap.triangeLen);
|
||||
var inMaxRect = visualMap.IsInRangeMaxRect(pointerPos, chartRect, m_Theme.visualMap.triangeLen);
|
||||
if (inMinRect || inMaxRect)
|
||||
{
|
||||
if (inMinRect)
|
||||
@@ -88,24 +89,24 @@ namespace XCharts
|
||||
|
||||
protected void OnDragVisualMap()
|
||||
{
|
||||
if (!m_VisualMap.enable || !m_VisualMap.show || !m_VisualMap.calculable) return;
|
||||
if (!visualMap.enable || !visualMap.show || !visualMap.calculable) return;
|
||||
if (!m_VisualMapMinDrag && !m_VisualMapMaxDrag) return;
|
||||
|
||||
var value = m_VisualMap.GetValue(pointerPos, chartRect);
|
||||
var value = visualMap.GetValue(pointerPos, chartRect);
|
||||
if (m_VisualMapMinDrag)
|
||||
{
|
||||
m_VisualMap.rangeMin = value;
|
||||
visualMap.rangeMin = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_VisualMap.rangeMax = value;
|
||||
visualMap.rangeMax = value;
|
||||
}
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
protected void OnDragVisualMapEnd()
|
||||
{
|
||||
if (!m_VisualMap.enable || !m_VisualMap.show || !m_VisualMap.calculable) return;
|
||||
if (!visualMap.enable || !visualMap.show || !visualMap.calculable) return;
|
||||
if (m_VisualMapMinDrag || m_VisualMapMaxDrag)
|
||||
{
|
||||
RefreshChart();
|
||||
@@ -117,19 +118,20 @@ namespace XCharts
|
||||
protected void DrawHeatmapSerie(VertexHelper vh, int colorIndex, Serie serie)
|
||||
{
|
||||
if (serie.animation.HasFadeOut()) return;
|
||||
var yAxis = m_YAxises[serie.axisIndex];
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
var yAxis = m_YAxes[serie.yAxisIndex];
|
||||
var xAxis = m_XAxes[serie.xAxisIndex];
|
||||
var grid = GetSerieGridOrDefault(serie);
|
||||
var xCount = xAxis.data.Count;
|
||||
var yCount = yAxis.data.Count;
|
||||
var xWidth = m_CoordinateWidth / xCount;
|
||||
var yWidth = m_CoordinateHeight / yCount;
|
||||
var xWidth = grid.runtimeWidth / xCount;
|
||||
var yWidth = grid.runtimeHeight / yCount;
|
||||
|
||||
var zeroX = m_CoordinateX;
|
||||
var zeroY = m_CoordinateY;
|
||||
var zeroX = grid.runtimeX;
|
||||
var zeroY = grid.runtimeY;
|
||||
var dataList = serie.GetDataList();
|
||||
var rangeMin = m_VisualMap.rangeMin;
|
||||
var rangeMax = m_VisualMap.rangeMax;
|
||||
var color = m_ThemeInfo.GetColor(serie.index);
|
||||
var rangeMin = visualMap.rangeMin;
|
||||
var rangeMax = visualMap.rangeMax;
|
||||
var color = m_Theme.GetColor(serie.index);
|
||||
var borderWidth = serie.itemStyle.show ? serie.itemStyle.borderWidth : 0;
|
||||
var borderColor = serie.itemStyle.opacity > 0 ? serie.itemStyle.borderColor : ChartConst.clearColor32;
|
||||
borderColor.a = (byte)(borderColor.a * serie.itemStyle.opacity);
|
||||
@@ -145,7 +147,7 @@ namespace XCharts
|
||||
var dataIndex = i * yCount + j;
|
||||
if (dataIndex >= dataList.Count) continue;
|
||||
var serieData = dataList[dataIndex];
|
||||
var dimension = VisualMapHelper.GetDimension(m_VisualMap, serieData.data.Count);
|
||||
var dimension = VisualMapHelper.GetDimension(visualMap, serieData.data.Count);
|
||||
if (serie.IsIgnoreIndex(dataIndex, dimension))
|
||||
{
|
||||
serie.dataPoints.Add(Vector3.zero);
|
||||
@@ -157,32 +159,32 @@ namespace XCharts
|
||||
serie.dataPoints.Add(pos);
|
||||
serieData.canShowLabel = false;
|
||||
if (value == 0) continue;
|
||||
if (m_VisualMap.enable)
|
||||
if (visualMap.enable)
|
||||
{
|
||||
if ((value < rangeMin && rangeMin != m_VisualMap.min)
|
||||
|| (value > rangeMax && rangeMax != m_VisualMap.max))
|
||||
if ((value < rangeMin && rangeMin != visualMap.min)
|
||||
|| (value > rangeMax && rangeMax != visualMap.max))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!m_VisualMap.IsInSelectedValue(value)) continue;
|
||||
color = m_VisualMap.GetColor(value);
|
||||
if (!visualMap.IsInSelectedValue(value)) continue;
|
||||
color = visualMap.GetColor(value);
|
||||
}
|
||||
if (animationIndex >= 0 && i > animationIndex) continue;
|
||||
serieData.canShowLabel = true;
|
||||
var emphasis = (m_Tooltip.show && i == (int)m_Tooltip.runtimeXValues[0] && j == (int)m_Tooltip.runtimeYValues[0])
|
||||
|| m_VisualMap.runtimeSelectedIndex > 0;
|
||||
var emphasis = (tooltip.show && i == (int)tooltip.runtimeXValues[0] && j == (int)tooltip.runtimeYValues[0])
|
||||
|| visualMap.runtimeSelectedIndex > 0;
|
||||
var rectWid = xWidth - 2 * borderWidth;
|
||||
var rectHig = yWidth - 2 * borderWidth;
|
||||
ChartDrawer.DrawPolygon(vh, pos, rectWid / 2, rectHig / 2, color);
|
||||
UGL.DrawRectangle(vh, pos, rectWid / 2, rectHig / 2, color);
|
||||
if (borderWidth > 0 && !ChartHelper.IsClearColor(borderColor))
|
||||
{
|
||||
ChartDrawer.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor);
|
||||
UGL.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor);
|
||||
}
|
||||
if (m_VisualMap.hoverLink && emphasis && serie.emphasis.show && serie.emphasis.itemStyle.borderWidth > 0)
|
||||
if (visualMap.hoverLink && emphasis && serie.emphasis.show && serie.emphasis.itemStyle.borderWidth > 0)
|
||||
{
|
||||
var emphasisBorderWidth = serie.emphasis.itemStyle.borderWidth;
|
||||
var emphasisBorderColor = serie.emphasis.itemStyle.opacity > 0 ? serie.emphasis.itemStyle.borderColor : ChartConst.clearColor32;
|
||||
ChartDrawer.DrawBorder(vh, pos, rectWid, rectHig, emphasisBorderWidth, emphasisBorderColor);
|
||||
UGL.DrawBorder(vh, pos, rectWid, rectHig, emphasisBorderWidth, emphasisBorderColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,32 +192,32 @@ namespace XCharts
|
||||
{
|
||||
serie.animation.CheckProgress(xCount);
|
||||
m_IsPlayingAnimation = true;
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
if (dataChanging)
|
||||
{
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawVisualMap(VertexHelper vh)
|
||||
{
|
||||
if (!m_VisualMap.enable || !m_VisualMap.show) return;
|
||||
var centerPos = chartPosition + m_VisualMap.location.GetPosition(chartWidth, chartHeight);
|
||||
if (!visualMap.enable || !visualMap.show) return;
|
||||
var centerPos = chartPosition + visualMap.location.GetPosition(chartWidth, chartHeight);
|
||||
|
||||
var pos1 = Vector3.zero;
|
||||
var pos2 = Vector3.zero;
|
||||
var dir = Vector3.zero;
|
||||
var halfWid = m_VisualMap.itemWidth / 2;
|
||||
var halfHig = m_VisualMap.itemHeight / 2;
|
||||
var halfWid = visualMap.itemWidth / 2;
|
||||
var halfHig = visualMap.itemHeight / 2;
|
||||
var xRadius = 0f;
|
||||
var yRadius = 0f;
|
||||
var splitNum = m_VisualMap.runtimeInRange.Count;
|
||||
var splitWid = m_VisualMap.itemHeight / (splitNum - 1);
|
||||
var splitNum = visualMap.runtimeInRange.Count;
|
||||
var splitWid = visualMap.itemHeight / (splitNum - 1);
|
||||
var isVertical = false;
|
||||
var colors = m_VisualMap.runtimeInRange;
|
||||
var triangeLen = m_Settings.visualMapTriangeLen;
|
||||
switch (m_VisualMap.orient)
|
||||
var colors = visualMap.runtimeInRange;
|
||||
var triangeLen = m_Theme.visualMap.triangeLen;
|
||||
switch (visualMap.orient)
|
||||
{
|
||||
case Orient.Horizonal:
|
||||
pos1 = centerPos + Vector3.left * halfHig;
|
||||
@@ -224,20 +226,20 @@ namespace XCharts
|
||||
xRadius = splitWid / 2;
|
||||
yRadius = halfWid;
|
||||
isVertical = false;
|
||||
if (m_VisualMap.calculable)
|
||||
if (visualMap.calculable)
|
||||
{
|
||||
var p0 = pos1 + Vector3.right * m_VisualMap.runtimeRangeMinHeight;
|
||||
var p0 = pos1 + Vector3.right * visualMap.runtimeRangeMinHeight;
|
||||
var p1 = p0 + Vector3.up * halfWid;
|
||||
var p2 = p0 + Vector3.up * (halfWid + triangeLen);
|
||||
var p3 = p2 + Vector3.left * triangeLen;
|
||||
var color = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
||||
ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
|
||||
p0 = pos1 + Vector3.right * m_VisualMap.runtimeRangeMaxHeight;
|
||||
var color = visualMap.GetColor(visualMap.rangeMin);
|
||||
UGL.DrawTriangle(vh, p1, p2, p3, color);
|
||||
p0 = pos1 + Vector3.right * visualMap.runtimeRangeMaxHeight;
|
||||
p1 = p0 + Vector3.up * halfWid;
|
||||
p2 = p0 + Vector3.up * (halfWid + triangeLen);
|
||||
p3 = p2 + Vector3.right * triangeLen;
|
||||
color = m_VisualMap.GetColor(m_VisualMap.rangeMax);
|
||||
ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
|
||||
color = visualMap.GetColor(visualMap.rangeMax);
|
||||
UGL.DrawTriangle(vh, p1, p2, p3, color);
|
||||
}
|
||||
break;
|
||||
case Orient.Vertical:
|
||||
@@ -247,32 +249,32 @@ namespace XCharts
|
||||
xRadius = halfWid;
|
||||
yRadius = splitWid / 2;
|
||||
isVertical = true;
|
||||
if (m_VisualMap.calculable)
|
||||
if (visualMap.calculable)
|
||||
{
|
||||
var p0 = pos1 + Vector3.up * m_VisualMap.runtimeRangeMinHeight;
|
||||
var p0 = pos1 + Vector3.up * visualMap.runtimeRangeMinHeight;
|
||||
var p1 = p0 + Vector3.right * halfWid;
|
||||
var p2 = p0 + Vector3.right * (halfWid + triangeLen);
|
||||
var p3 = p2 + Vector3.down * triangeLen;
|
||||
var color = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
||||
ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
|
||||
p0 = pos1 + Vector3.up * m_VisualMap.runtimeRangeMaxHeight;
|
||||
var color = visualMap.GetColor(visualMap.rangeMin);
|
||||
UGL.DrawTriangle(vh, p1, p2, p3, color);
|
||||
p0 = pos1 + Vector3.up * visualMap.runtimeRangeMaxHeight;
|
||||
p1 = p0 + Vector3.right * halfWid;
|
||||
p2 = p0 + Vector3.right * (halfWid + triangeLen);
|
||||
p3 = p2 + Vector3.up * triangeLen;
|
||||
color = m_VisualMap.GetColor(m_VisualMap.rangeMax);
|
||||
ChartDrawer.DrawTriangle(vh, p1, p2, p3, color);
|
||||
color = visualMap.GetColor(visualMap.rangeMax);
|
||||
UGL.DrawTriangle(vh, p1, p2, p3, color);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (m_VisualMap.calculable && (m_VisualMap.rangeMin > m_VisualMap.min
|
||||
|| m_VisualMap.rangeMax < m_VisualMap.max))
|
||||
if (visualMap.calculable && (visualMap.rangeMin > visualMap.min
|
||||
|| visualMap.rangeMax < visualMap.max))
|
||||
{
|
||||
var rangeMin = m_VisualMap.rangeMin;
|
||||
var rangeMax = m_VisualMap.rangeMax;
|
||||
var diff = (m_VisualMap.max - m_VisualMap.min) / (splitNum - 1);
|
||||
var rangeMin = visualMap.rangeMin;
|
||||
var rangeMax = visualMap.rangeMax;
|
||||
var diff = (visualMap.max - visualMap.min) / (splitNum - 1);
|
||||
for (int i = 1; i < splitNum; i++)
|
||||
{
|
||||
var splitMin = m_VisualMap.min + (i - 1) * diff;
|
||||
var splitMin = visualMap.min + (i - 1) * diff;
|
||||
var splitMax = splitMin + diff;
|
||||
if (rangeMin > splitMax || rangeMax < splitMin)
|
||||
{
|
||||
@@ -282,47 +284,47 @@ namespace XCharts
|
||||
{
|
||||
var splitPos = pos1 + dir * (i - 1 + 0.5f) * splitWid;
|
||||
var startColor = colors[i - 1];
|
||||
var toColor = m_VisualMap.IsPiecewise() ? startColor : colors[i];
|
||||
ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical);
|
||||
var toColor = visualMap.IsPiecewise() ? startColor : colors[i];
|
||||
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical);
|
||||
}
|
||||
else if (rangeMin > splitMin && rangeMax >= splitMax)
|
||||
{
|
||||
var p0 = pos1 + dir * m_VisualMap.runtimeRangeMinHeight;
|
||||
var p0 = pos1 + dir * visualMap.runtimeRangeMinHeight;
|
||||
var splitMaxPos = pos1 + dir * i * splitWid;
|
||||
var splitPos = p0 + (splitMaxPos - p0) / 2;
|
||||
var startColor = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
||||
var toColor = m_VisualMap.IsPiecewise() ? startColor : colors[i];
|
||||
var startColor = visualMap.GetColor(visualMap.rangeMin);
|
||||
var toColor = visualMap.IsPiecewise() ? startColor : colors[i];
|
||||
var yRadius1 = Vector3.Distance(p0, splitMaxPos) / 2;
|
||||
if (m_VisualMap.orient == Orient.Vertical)
|
||||
ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
|
||||
if (visualMap.orient == Orient.Vertical)
|
||||
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
|
||||
else
|
||||
ChartDrawer.DrawPolygon(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
|
||||
UGL.DrawRectangle(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
|
||||
}
|
||||
else if (rangeMax < splitMax && rangeMin <= splitMin)
|
||||
{
|
||||
var p0 = pos1 + dir * m_VisualMap.runtimeRangeMaxHeight;
|
||||
var p0 = pos1 + dir * visualMap.runtimeRangeMaxHeight;
|
||||
var splitMinPos = pos1 + dir * (i - 1) * splitWid;
|
||||
var splitPos = splitMinPos + (p0 - splitMinPos) / 2;
|
||||
var startColor = colors[i - 1];
|
||||
var toColor = m_VisualMap.IsPiecewise() ? startColor : m_VisualMap.GetColor(m_VisualMap.rangeMax);
|
||||
var toColor = visualMap.IsPiecewise() ? startColor : visualMap.GetColor(visualMap.rangeMax);
|
||||
var yRadius1 = Vector3.Distance(p0, splitMinPos) / 2;
|
||||
if (m_VisualMap.orient == Orient.Vertical)
|
||||
ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
|
||||
if (visualMap.orient == Orient.Vertical)
|
||||
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
|
||||
else
|
||||
ChartDrawer.DrawPolygon(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
|
||||
UGL.DrawRectangle(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
|
||||
}
|
||||
else
|
||||
{
|
||||
var p0 = pos1 + dir * m_VisualMap.runtimeRangeMinHeight;
|
||||
var p1 = pos1 + dir * m_VisualMap.runtimeRangeMaxHeight;
|
||||
var p0 = pos1 + dir * visualMap.runtimeRangeMinHeight;
|
||||
var p1 = pos1 + dir * visualMap.runtimeRangeMaxHeight;
|
||||
var splitPos = (p0 + p1) / 2;
|
||||
var startColor = m_VisualMap.GetColor(m_VisualMap.rangeMin);
|
||||
var toColor = m_VisualMap.GetColor(m_VisualMap.rangeMax);
|
||||
var startColor = visualMap.GetColor(visualMap.rangeMin);
|
||||
var toColor = visualMap.GetColor(visualMap.rangeMax);
|
||||
var yRadius1 = Vector3.Distance(p0, p1) / 2;
|
||||
if (m_VisualMap.orient == Orient.Vertical)
|
||||
ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
|
||||
if (visualMap.orient == Orient.Vertical)
|
||||
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius1, startColor, toColor, isVertical);
|
||||
else
|
||||
ChartDrawer.DrawPolygon(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
|
||||
UGL.DrawRectangle(vh, splitPos, yRadius1, yRadius, startColor, toColor, isVertical);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -332,45 +334,45 @@ namespace XCharts
|
||||
{
|
||||
var splitPos = pos1 + dir * (i - 1 + 0.5f) * splitWid;
|
||||
var startColor = colors[i - 1];
|
||||
var toColor = m_VisualMap.IsPiecewise() ? startColor : colors[i];
|
||||
ChartDrawer.DrawPolygon(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical);
|
||||
var toColor = visualMap.IsPiecewise() ? startColor : colors[i];
|
||||
UGL.DrawRectangle(vh, splitPos, xRadius, yRadius, startColor, toColor, isVertical);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_VisualMap.rangeMin > m_VisualMap.min)
|
||||
if (visualMap.rangeMin > visualMap.min)
|
||||
{
|
||||
var p0 = pos1 + dir * m_VisualMap.runtimeRangeMinHeight;
|
||||
ChartDrawer.DrawPolygon(vh, pos1, p0, m_VisualMap.itemWidth / 2, m_ThemeInfo.visualMapBackgroundColor);
|
||||
var p0 = pos1 + dir * visualMap.runtimeRangeMinHeight;
|
||||
UGL.DrawRectangle(vh, pos1, p0, visualMap.itemWidth / 2, m_Theme.visualMap.backgroundColor);
|
||||
}
|
||||
if (m_VisualMap.rangeMax < m_VisualMap.max)
|
||||
if (visualMap.rangeMax < visualMap.max)
|
||||
{
|
||||
var p1 = pos1 + dir * m_VisualMap.runtimeRangeMaxHeight;
|
||||
ChartDrawer.DrawPolygon(vh, p1, pos2, m_VisualMap.itemWidth / 2, m_ThemeInfo.visualMapBackgroundColor);
|
||||
var p1 = pos1 + dir * visualMap.runtimeRangeMaxHeight;
|
||||
UGL.DrawRectangle(vh, p1, pos2, visualMap.itemWidth / 2, m_Theme.visualMap.backgroundColor);
|
||||
}
|
||||
|
||||
if (m_VisualMap.hoverLink)
|
||||
if (visualMap.hoverLink)
|
||||
{
|
||||
if (m_VisualMap.runtimeSelectedIndex >= 0)
|
||||
if (visualMap.runtimeSelectedIndex >= 0)
|
||||
{
|
||||
var p0 = pos1 + dir * m_VisualMap.runtimeRangeMinHeight;
|
||||
var p1 = pos1 + dir * m_VisualMap.runtimeRangeMaxHeight;
|
||||
var p0 = pos1 + dir * visualMap.runtimeRangeMinHeight;
|
||||
var p1 = pos1 + dir * visualMap.runtimeRangeMaxHeight;
|
||||
|
||||
if (m_VisualMap.orient == Orient.Vertical)
|
||||
if (visualMap.orient == Orient.Vertical)
|
||||
{
|
||||
var p2 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y + (triangeLen / 2), p0.y, p1.y));
|
||||
var p3 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y - (triangeLen / 2), p0.y, p1.y));
|
||||
var p4 = new Vector3(centerPos.x + halfWid + triangeLen / 2, pointerPos.y);
|
||||
ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.runtimeSelectedIndex]);
|
||||
UGL.DrawTriangle(vh, p2, p3, p4, colors[visualMap.runtimeSelectedIndex]);
|
||||
}
|
||||
else
|
||||
{
|
||||
var p2 = new Vector3(Mathf.Clamp(pointerPos.x + (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
|
||||
var p3 = new Vector3(Mathf.Clamp(pointerPos.x - (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
|
||||
var p4 = new Vector3(pointerPos.x, centerPos.y + halfWid + triangeLen / 2);
|
||||
ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.runtimeSelectedIndex]);
|
||||
UGL.DrawTriangle(vh, p2, p3, p4, colors[visualMap.runtimeSelectedIndex]);
|
||||
}
|
||||
}
|
||||
else if (m_Tooltip.show && m_Tooltip.runtimeXValues[0] >= 0 && m_Tooltip.runtimeYValues[0] >= 0)
|
||||
else if (tooltip.show && tooltip.runtimeXValues[0] >= 0 && tooltip.runtimeYValues[0] >= 0)
|
||||
{
|
||||
// var p0 = pos1 + dir * m_VisualMap.rangeMinHeight;
|
||||
// var p1 = pos1 + dir * m_VisualMap.rangeMaxHeight;
|
||||
@@ -379,14 +381,14 @@ namespace XCharts
|
||||
// var p2 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y + (triangeLen / 2), p0.y, p1.y));
|
||||
// var p3 = new Vector3(centerPos.x + halfWid, Mathf.Clamp(pointerPos.y - (triangeLen / 2), p0.y, p1.y));
|
||||
// var p4 = new Vector3(centerPos.x + halfWid + triangeLen / 2, pointerPos.y);
|
||||
// ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.rtSelectedIndex]);
|
||||
// UGL.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.rtSelectedIndex]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// var p2 = new Vector3(Mathf.Clamp(pointerPos.x + (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
|
||||
// var p3 = new Vector3(Mathf.Clamp(pointerPos.x - (triangeLen / 2), p0.x, p1.x), centerPos.y + halfWid);
|
||||
// var p4 = new Vector3(pointerPos.x, centerPos.y + halfWid + triangeLen / 2);
|
||||
// ChartDrawer.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.rtSelectedIndex]);
|
||||
// UGL.DrawTriangle(vh, p2, p3, p4, colors[m_VisualMap.rtSelectedIndex]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
/******************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/******************************************/
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -16,8 +16,9 @@ namespace XCharts
|
||||
{
|
||||
if (serie.animation.HasFadeOut()) return;
|
||||
if (!serie.show) return;
|
||||
var yAxis = m_YAxises[serie.axisIndex];
|
||||
var xAxis = m_XAxises[serie.axisIndex];
|
||||
var yAxis = m_YAxes[serie.yAxisIndex];
|
||||
var xAxis = m_XAxes[serie.xAxisIndex];
|
||||
var grid = GetSerieGridOrDefault(serie);
|
||||
int maxCount = serie.maxShow > 0 ?
|
||||
(serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow)
|
||||
: serie.dataCount;
|
||||
@@ -27,21 +28,21 @@ namespace XCharts
|
||||
var dataChanging = false;
|
||||
for (int n = serie.minShow; n < maxCount; n++)
|
||||
{
|
||||
var serieData = serie.GetDataList(m_DataZoom)[n];
|
||||
var serieData = serie.GetDataList(dataZoom)[n];
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData);
|
||||
if (!symbol.ShowSymbol(n, maxCount)) continue;
|
||||
var highlight = serie.highlighted || serieData.highlighted;
|
||||
var color = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, colorIndex, highlight);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, highlight);
|
||||
var color = SerieHelper.GetItemColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
var toColor = SerieHelper.GetItemToColor(serie, serieData, m_Theme, colorIndex, highlight);
|
||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, m_Theme, highlight);
|
||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||
float xValue = serieData.GetCurrData(0, dataChangeDuration, xAxis.inverse);
|
||||
float yValue = serieData.GetCurrData(1, dataChangeDuration, yAxis.inverse);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
float pX = m_CoordinateX + xAxis.axisLine.width;
|
||||
float pY = m_CoordinateY + yAxis.axisLine.width;
|
||||
float xDataHig = GetDataHig(xAxis, xValue, m_CoordinateWidth);
|
||||
float yDataHig = GetDataHig(yAxis, yValue, m_CoordinateHeight);
|
||||
float pX = grid.runtimeX + xAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
float pY = grid.runtimeY + yAxis.axisLine.GetWidth(m_Theme.axis.lineWidth);
|
||||
float xDataHig = GetDataHig(xAxis, xValue, grid.runtimeWidth);
|
||||
float yDataHig = GetDataHig(yAxis, yValue, grid.runtimeHeight);
|
||||
var pos = new Vector3(pX + xDataHig, pY + yDataHig);
|
||||
serie.dataPoints.Add(pos);
|
||||
serieData.runtimePosition = pos;
|
||||
@@ -49,11 +50,11 @@ namespace XCharts
|
||||
float symbolSize = 0;
|
||||
if (serie.highlighted || serieData.highlighted)
|
||||
{
|
||||
symbolSize = symbol.GetSelectedSize(datas);
|
||||
symbolSize = symbol.GetSelectedSize(datas, m_Theme.serie.scatterSymbolSelectedSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
symbolSize = symbol.GetSize(datas);
|
||||
symbolSize = symbol.GetSize(datas, m_Theme.serie.scatterSymbolSize);
|
||||
}
|
||||
symbolSize *= rate;
|
||||
if (symbolSize > 100) symbolSize = 100;
|
||||
@@ -65,7 +66,7 @@ namespace XCharts
|
||||
color.a = (byte)(255 * (symbolSize - nowSize) / symbolSize);
|
||||
DrawSymbol(vh, symbol.type, nowSize, symbolBorder, pos, color, toColor, symbol.gap, cornerRadius);
|
||||
}
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -76,11 +77,11 @@ namespace XCharts
|
||||
{
|
||||
serie.animation.CheckProgress(1);
|
||||
m_IsPlayingAnimation = true;
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
if (dataChanging)
|
||||
{
|
||||
RefreshChart();
|
||||
RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
408
Runtime/Internal/DrawSerieGauge.cs
Normal file
408
Runtime/Internal/DrawSerieGauge.cs
Normal file
@@ -0,0 +1,408 @@
|
||||
/************************************************/
|
||||
/* */
|
||||
/* Copyright (c) 2018 - 2021 monitor1394 */
|
||||
/* https://github.com/monitor1394 */
|
||||
/* */
|
||||
/************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using XUGL;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
internal class DrawSerieGauge : IDrawSerie
|
||||
{
|
||||
public BaseChart chart;
|
||||
|
||||
private static readonly string s_SerieLabelObjectName = "label";
|
||||
private static readonly string s_AxisLabelObjectName = "axis_label";
|
||||
private bool m_UpdateTitleText = false;
|
||||
private bool m_UpdateLabelText = false;
|
||||
|
||||
public DrawSerieGauge(BaseChart chart)
|
||||
{
|
||||
this.chart = chart;
|
||||
}
|
||||
|
||||
public void InitComponent()
|
||||
{
|
||||
InitAxisLabel();
|
||||
}
|
||||
|
||||
public void CheckComponent()
|
||||
{
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (m_UpdateTitleText)
|
||||
{
|
||||
m_UpdateTitleText = false;
|
||||
|
||||
foreach (var serie in chart.series.list)
|
||||
{
|
||||
if (serie.type == SerieType.Gauge)
|
||||
{
|
||||
TitleStyleHelper.UpdateTitleText(serie);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_UpdateLabelText)
|
||||
{
|
||||
m_UpdateLabelText = false;
|
||||
foreach (var serie in chart.series.list)
|
||||
{
|
||||
if (serie.type == SerieType.Gauge)
|
||||
{
|
||||
SerieLabelHelper.SetGaugeLabelText(serie);
|
||||
UpdateAxisLabel(serie);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawBase(VertexHelper vh)
|
||||
{
|
||||
}
|
||||
|
||||
public void DrawSerie(VertexHelper vh, Serie serie)
|
||||
{
|
||||
if (serie.type != SerieType.Gauge) return;
|
||||
DrawGauge(vh, serie);
|
||||
}
|
||||
|
||||
public void RefreshLabel()
|
||||
{
|
||||
}
|
||||
|
||||
public bool CheckTootipArea(Vector2 local)
|
||||
{
|
||||
var serie = GetPointerInSerieIndex(chart.series, local);
|
||||
if (serie != null)
|
||||
{
|
||||
chart.tooltip.runtimeDataIndex.Clear();
|
||||
chart.tooltip.runtimeDataIndex.Add(serie.index);
|
||||
chart.tooltip.UpdateContentPos(local + chart.tooltip.offset);
|
||||
UpdateTooltip();
|
||||
return true;
|
||||
}
|
||||
else if (chart.tooltip.IsActive())
|
||||
{
|
||||
chart.tooltip.SetActive(false);
|
||||
chart.RefreshChart();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnLegendButtonClick(int index, string legendName, bool show)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnLegendButtonEnter(int index, string legendName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnLegendButtonExit(int index, string legendName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
}
|
||||
|
||||
private void InitAxisLabel()
|
||||
{
|
||||
if (!SeriesHelper.ContainsSerie(chart.series, SerieType.Gauge)) return;
|
||||
var labelObject = ChartHelper.AddObject(s_AxisLabelObjectName, chart.transform, chart.chartMinAnchor,
|
||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||
labelObject.hideFlags = chart.chartHideFlags;
|
||||
SerieLabelPool.ReleaseAll(labelObject.transform);
|
||||
for (int i = 0; i < chart.series.Count; i++)
|
||||
{
|
||||
var serie = chart.series.list[i];
|
||||
var serieLabel = serie.gaugeAxis.axisLabel;
|
||||
var count = serie.splitNumber > 36 ? 36 : (serie.splitNumber + 1);
|
||||
var startAngle = serie.startAngle;
|
||||
serie.gaugeAxis.ClearLabelObject();
|
||||
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
for (int j = 0; j < count; j++)
|
||||
{
|
||||
var textName = ChartCached.GetSerieLabelName(s_SerieLabelObjectName, i, j);
|
||||
var color = Color.grey;
|
||||
var labelObj = SerieLabelPool.Get(textName, labelObject.transform, serieLabel, color, 100, 100, chart.theme);
|
||||
var iconImage = labelObj.transform.Find("Icon").GetComponent<Image>();
|
||||
var isAutoSize = serieLabel.backgroundWidth == 0 || serieLabel.backgroundHeight == 0;
|
||||
var item = new ChartLabel();
|
||||
item.SetLabel(labelObj, isAutoSize, serieLabel.paddingLeftRight, serieLabel.paddingTopBottom);
|
||||
item.SetIcon(iconImage);
|
||||
item.SetIconActive(false);
|
||||
serie.gaugeAxis.AddLabelObject(item);
|
||||
}
|
||||
UpdateAxisLabel(serie);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAxisLabel()
|
||||
{
|
||||
foreach (var serie in chart.series.list)
|
||||
{
|
||||
if (serie.type == SerieType.Gauge)
|
||||
{
|
||||
UpdateAxisLabel(serie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAxisLabel(Serie serie)
|
||||
{
|
||||
var show = serie.gaugeAxis.show && serie.gaugeAxis.axisLabel.show;
|
||||
serie.gaugeAxis.SetLabelObjectActive(show);
|
||||
if (!show)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var count = serie.splitNumber > 36 ? 36 : serie.splitNumber;
|
||||
var startAngle = serie.startAngle;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var totalValue = serie.max - serie.min;
|
||||
var diffAngle = totalAngle / count;
|
||||
var diffValue = totalValue / count;
|
||||
var radius = serie.runtimeInsideRadius - serie.gaugeAxis.axisLabel.margin;
|
||||
var serieData = serie.GetSerieData(0);
|
||||
var customLabelText = serie.gaugeAxis.axisLabelText;
|
||||
for (int j = 0; j <= count; j++)
|
||||
{
|
||||
var angle = serie.startAngle + j * diffAngle;
|
||||
var value = serie.min + j * diffValue;
|
||||
var pos = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, radius);
|
||||
var text = customLabelText != null && j < customLabelText.Count ? customLabelText[j] :
|
||||
SerieLabelHelper.GetFormatterContent(serie, serieData, value, totalValue, serie.gaugeAxis.axisLabel);
|
||||
serie.gaugeAxis.SetLabelObjectText(j, text);
|
||||
serie.gaugeAxis.SetLabelObjectPosition(j, pos);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawGauge(VertexHelper vh, Serie serie)
|
||||
{
|
||||
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
var destAngle = GetCurrAngle(serie, true);
|
||||
serie.animation.InitProgress(0, serie.startAngle, destAngle);
|
||||
var currAngle = serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail();
|
||||
DrawProgressBar(vh, serie, currAngle);
|
||||
DrawStageColor(vh, serie);
|
||||
DrawLineStyle(vh, serie);
|
||||
DrawAxisTick(vh, serie);
|
||||
DrawPointer(vh, serie, currAngle);
|
||||
TitleStyleHelper.CheckTitle(serie, ref chart.m_ReinitTitle, ref m_UpdateTitleText);
|
||||
SerieLabelHelper.CheckLabel(serie, ref chart.m_ReinitLabel, ref m_UpdateLabelText);
|
||||
CheckAnimation(serie);
|
||||
if (!serie.animation.IsFinish())
|
||||
{
|
||||
serie.animation.CheckProgress(destAngle - serie.startAngle);
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
else if (NeedRefresh(serie))
|
||||
{
|
||||
chart.RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawProgressBar(VertexHelper vh, Serie serie, float currAngle)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.ProgressBar) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisLine.show) return;
|
||||
var color = serie.gaugeAxis.GetAxisLineColor(chart.theme, serie.index);
|
||||
var backgroundColor = serie.gaugeAxis.GetAxisLineBackgroundColor(chart.theme, serie.index);
|
||||
var lineWidth = serie.gaugeAxis.axisLine.GetWidth(chart.theme.gauge.lineWidth);
|
||||
var outsideRadius = serie.runtimeInsideRadius + lineWidth;
|
||||
var borderWidth = serie.itemStyle.borderWidth;
|
||||
var borderColor = serie.itemStyle.borderColor;
|
||||
UGL.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
|
||||
backgroundColor, backgroundColor, Color.clear, serie.startAngle, serie.endAngle, 0, Color.clear,
|
||||
0, chart.settings.cicleSmoothness, serie.roundCap);
|
||||
UGL.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
|
||||
color, color, Color.clear, serie.startAngle, currAngle, 0, Color.clear,
|
||||
0, chart.settings.cicleSmoothness, serie.roundCap);
|
||||
}
|
||||
|
||||
private void DrawStageColor(VertexHelper vh, Serie serie)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisLine.show) return;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var tempStartAngle = serie.startAngle;
|
||||
var tempEndAngle = serie.startAngle;
|
||||
var lineWidth = serie.gaugeAxis.axisLine.GetWidth(chart.theme.gauge.lineWidth);
|
||||
var outsideRadius = serie.runtimeInsideRadius + lineWidth;
|
||||
serie.gaugeAxis.runtimeStageAngle.Clear();
|
||||
for (int i = 0; i < serie.gaugeAxis.axisLine.stageColor.Count; i++)
|
||||
{
|
||||
var stageColor = serie.gaugeAxis.axisLine.stageColor[i];
|
||||
tempEndAngle = serie.startAngle + totalAngle * stageColor.percent;
|
||||
serie.gaugeAxis.runtimeStageAngle.Add(tempEndAngle);
|
||||
UGL.DrawDoughnut(vh, serie.runtimeCenterPos, serie.runtimeInsideRadius, outsideRadius,
|
||||
stageColor.color, stageColor.color, Color.clear, tempStartAngle, tempEndAngle, 0, Color.clear,
|
||||
0, chart.settings.cicleSmoothness);
|
||||
tempStartAngle = tempEndAngle;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPointer(VertexHelper vh, Serie serie, float currAngle)
|
||||
{
|
||||
if (!serie.gaugePointer.show) return;
|
||||
var pointerColor = serie.gaugeAxis.GetPointerColor(chart.theme, serie.index, currAngle, serie.itemStyle);
|
||||
var pointerToColor = !ChartHelper.IsClearColor(serie.itemStyle.toColor) ? serie.itemStyle.toColor : pointerColor;
|
||||
var len = serie.gaugePointer.length < 1 && serie.gaugePointer.length > -1 ?
|
||||
serie.runtimeInsideRadius * serie.gaugePointer.length :
|
||||
serie.gaugePointer.length;
|
||||
var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle, len);
|
||||
var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle + 180, serie.gaugePointer.width);
|
||||
var p3 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle - 90, serie.gaugePointer.width / 2);
|
||||
var p4 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle + 90, serie.gaugePointer.width / 2);
|
||||
UGL.DrawTriangle(vh, p2, p3, p1, pointerColor, pointerColor, pointerToColor);
|
||||
UGL.DrawTriangle(vh, p4, p2, p1, pointerColor, pointerColor, pointerToColor);
|
||||
}
|
||||
|
||||
private void DrawLineStyle(VertexHelper vh, Serie serie)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.splitLine.show) return;
|
||||
if (serie.splitNumber <= 0) return;
|
||||
var splitLine = serie.gaugeAxis.splitLine;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var diffAngle = totalAngle / serie.splitNumber;
|
||||
var lineWidth = serie.gaugeAxis.axisLine.GetWidth(chart.theme.gauge.lineWidth);
|
||||
var splitLineWidth = splitLine.GetWidth(chart.theme.gauge.splitLineWidth);
|
||||
var splitLineLength = splitLine.GetLength(chart.theme.gauge.splitLineLength);
|
||||
var outsideRadius = serie.runtimeInsideRadius + lineWidth;
|
||||
var insideRadius = outsideRadius - splitLineLength;
|
||||
for (int i = 0; i < serie.splitNumber + 1; i++)
|
||||
{
|
||||
var angle = serie.startAngle + i * diffAngle;
|
||||
var lineColor = serie.gaugeAxis.GetSplitLineColor(chart.theme.gauge.splitLineColor, serie.index, angle);
|
||||
var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, insideRadius);
|
||||
var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, outsideRadius);
|
||||
UGL.DrawLine(vh, p1, p2, splitLineWidth, lineColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawAxisTick(VertexHelper vh, Serie serie)
|
||||
{
|
||||
if (serie.gaugeType != GaugeType.Pointer) return;
|
||||
if (!serie.gaugeAxis.show || !serie.gaugeAxis.axisTick.show) return;
|
||||
if (serie.splitNumber <= 0) return;
|
||||
var axisTick = serie.gaugeAxis.axisTick;
|
||||
var totalAngle = serie.endAngle - serie.startAngle;
|
||||
var diffAngle = totalAngle / serie.splitNumber;
|
||||
var lineWidth = serie.gaugeAxis.axisLine.GetWidth(chart.theme.gauge.lineWidth);
|
||||
var tickWidth = axisTick.GetWidth(chart.theme.gauge.tickWidth);
|
||||
var tickLength = axisTick.GetLength(chart.theme.gauge.tickLength);
|
||||
var outsideRadius = serie.runtimeInsideRadius + lineWidth;
|
||||
|
||||
var insideRadius = outsideRadius - (tickLength < 1 ? lineWidth * tickLength : tickLength);
|
||||
for (int i = 0; i < serie.splitNumber; i++)
|
||||
{
|
||||
for (int j = 1; j < axisTick.splitNumber; j++)
|
||||
{
|
||||
var angle = serie.startAngle + i * diffAngle + j * (diffAngle / axisTick.splitNumber);
|
||||
var lineColor = serie.gaugeAxis.GetSplitLineColor(chart.theme.gauge.tickColor, serie.index, angle);
|
||||
var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, insideRadius);
|
||||
var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, angle, outsideRadius);
|
||||
UGL.DrawLine(vh, p1, p2, tickWidth, lineColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float GetCurrAngle(Serie serie, bool dest)
|
||||
{
|
||||
if (serie.animation.HasFadeOut())
|
||||
{
|
||||
return serie.animation.GetCurrDetail();
|
||||
}
|
||||
float rangeValue = serie.max - serie.min;
|
||||
float rangeAngle = serie.endAngle - serie.startAngle;
|
||||
float value = 0;
|
||||
float angle = serie.startAngle;
|
||||
if (serie.dataCount > 0)
|
||||
{
|
||||
var serieData = serie.data[0];
|
||||
serieData.labelPosition = serie.runtimeCenterPos + serie.label.offset;
|
||||
value = dest ? serieData.GetData(1)
|
||||
: serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||
value = Mathf.Clamp(value, serie.min, serie.max);
|
||||
}
|
||||
if (rangeValue > 0)
|
||||
{
|
||||
angle += rangeAngle * value / rangeValue;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
private void CheckAnimation(Serie serie)
|
||||
{
|
||||
var serieData = serie.GetSerieData(0);
|
||||
if (serieData != null)
|
||||
{
|
||||
var value = serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||
var data = serieData.GetData(1);
|
||||
if (value != data) chart.RefreshPainter(serie);
|
||||
}
|
||||
}
|
||||
|
||||
private bool NeedRefresh(Serie serie)
|
||||
{
|
||||
if (serie.type == SerieType.Gauge)
|
||||
{
|
||||
var serieData = serie.GetSerieData(0);
|
||||
if (serieData != null)
|
||||
{
|
||||
var destValue = serieData.GetData(1);
|
||||
var currValue = serieData.GetCurrData(1, serie.animation.GetUpdateAnimationDuration());
|
||||
return destValue != currValue;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Serie GetPointerInSerieIndex(Series series, Vector2 local)
|
||||
{
|
||||
foreach (var serie in series.list)
|
||||
{
|
||||
if (serie.type != SerieType.Gauge) continue;
|
||||
if (!serie.gaugePointer.show) continue;
|
||||
var len = serie.gaugePointer.length < 1 && serie.gaugePointer.length > -1
|
||||
? serie.runtimeInsideRadius * serie.gaugePointer.length
|
||||
: serie.gaugePointer.length;
|
||||
if (Vector3.Distance(local, serie.runtimeCenterPos) > len) continue;
|
||||
var currAngle = serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail();
|
||||
var p1 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle, len);
|
||||
var p2 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle + 180, serie.gaugePointer.width);
|
||||
var p3 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle - 90, serie.gaugePointer.width / 2);
|
||||
var p4 = ChartHelper.GetPosition(serie.runtimeCenterPos, currAngle + 90, serie.gaugePointer.width / 2);
|
||||
if (ChartHelper.IsPointInQuadrilateral(local, p1, p3, p2, p4))
|
||||
{
|
||||
return serie;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void UpdateTooltip()
|
||||
{
|
||||
int index = chart.tooltip.runtimeDataIndex[0];
|
||||
if (index < 0)
|
||||
{
|
||||
chart.tooltip.SetActive(false);
|
||||
return;
|
||||
}
|
||||
var content = TooltipHelper.GetFormatterContent(chart.tooltip, index, chart.series, chart.theme);
|
||||
TooltipHelper.SetContentAndPosition(chart.tooltip, content.TrimStart(), chart.chartRect);
|
||||
chart.tooltip.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Runtime/Internal/DrawSerieGauge.cs.meta
Normal file
11
Runtime/Internal/DrawSerieGauge.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca6e74d36e80c4daabf80b165986dfbb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user