mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-30 05:08:48 +00:00
3.0 - bar chart
This commit is contained in:
@@ -38,6 +38,7 @@ namespace XCharts.Editor
|
|||||||
PropertyField("m_Large");
|
PropertyField("m_Large");
|
||||||
PropertyField("m_LargeThreshold");
|
PropertyField("m_LargeThreshold");
|
||||||
PropertyField("m_Clip");
|
PropertyField("m_Clip");
|
||||||
|
PropertyField("m_PlaceHolder");
|
||||||
});
|
});
|
||||||
PropertyField("m_ItemStyle");
|
PropertyField("m_ItemStyle");
|
||||||
PropertyField("m_Animation");
|
PropertyField("m_Animation");
|
||||||
|
|||||||
@@ -160,6 +160,8 @@ namespace XCharts.Editor
|
|||||||
{
|
{
|
||||||
editor.serie.AddExtraComponent(type);
|
editor.serie.AddExtraComponent(type);
|
||||||
RefreshEditors();
|
RefreshEditors();
|
||||||
|
chart.RefreshAllComponent();
|
||||||
|
EditorUtility.SetDirty(chart);
|
||||||
}, size == 0));
|
}, size == 0));
|
||||||
}
|
}
|
||||||
foreach (var type in attribute.types)
|
foreach (var type in attribute.types)
|
||||||
@@ -169,6 +171,8 @@ namespace XCharts.Editor
|
|||||||
{
|
{
|
||||||
editor.serie.RemoveExtraComponent(type);
|
editor.serie.RemoveExtraComponent(type);
|
||||||
RefreshEditors();
|
RefreshEditors();
|
||||||
|
chart.RefreshAllComponent();
|
||||||
|
EditorUtility.SetDirty(chart);
|
||||||
}, size > 0));
|
}, size > 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
--- !u!114 &11400000
|
--- !u!114 &11400000
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_PrefabParentObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
m_PrefabInternal: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 0}
|
m_GameObject: {fileID: 0}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
@@ -134,7 +135,7 @@ MonoBehaviour:
|
|||||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
m_TextColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
m_TextBackgroundColor: {r: 1, g: 1, b: 1, a: 1}
|
m_TextBackgroundColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
m_FontSize: 22
|
m_FontSize: 20
|
||||||
m_LineType: 0
|
m_LineType: 0
|
||||||
m_LineWidth: 0.8
|
m_LineWidth: 0.8
|
||||||
m_LineColor:
|
m_LineColor:
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
|
using UnityEngine;
|
||||||
using UnityEngine;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
using System;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@@ -214,6 +213,8 @@ namespace XCharts
|
|||||||
Debug.LogError("UpdateTheme: not support switch to Custom theme.");
|
Debug.LogError("UpdateTheme: not support switch to Custom theme.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (m_Theme.sharedTheme == null)
|
||||||
|
m_Theme.sharedTheme = XCThemeMgr.GetTheme(ThemeType.Default);
|
||||||
m_Theme.sharedTheme.CopyTheme(theme);
|
m_Theme.sharedTheme.CopyTheme(theme);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -488,17 +488,46 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float GetAxisPosition(GridCoord grid, Axis axis, float scaleWidth, double value)
|
/// <summary>
|
||||||
|
/// 获得数值value在坐标轴上的坐标位置
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="grid"></param>
|
||||||
|
/// <param name="axis"></param>
|
||||||
|
/// <param name="scaleWidth"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static float GetAxisValuePosition(GridCoord grid, Axis axis, float scaleWidth, double value)
|
||||||
{
|
{
|
||||||
return GetAxisPositionInternal(grid, axis, scaleWidth, value, true);
|
return GetAxisPositionInternal(grid, axis, scaleWidth, value, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数值value在坐标轴上相对起点的距离
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="grid"></param>
|
||||||
|
/// <param name="axis"></param>
|
||||||
|
/// <param name="scaleWidth"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static float GetAxisValueDistance(GridCoord grid, Axis axis, float scaleWidth, double value)
|
||||||
|
{
|
||||||
|
return GetAxisPositionInternal(grid, axis, scaleWidth, value, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得数值value在坐标轴上对于的长度
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="grid"></param>
|
||||||
|
/// <param name="axis"></param>
|
||||||
|
/// <param name="scaleWidth"></param>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)
|
public static float GetAxisValueLength(GridCoord grid, Axis axis, float scaleWidth, double value)
|
||||||
{
|
{
|
||||||
return GetAxisPositionInternal(grid, axis, scaleWidth, value, false);
|
return GetAxisPositionInternal(grid, axis, scaleWidth, value, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float GetAxisPositionInternal(GridCoord grid, Axis axis, float scaleWidth, double value, bool includeGridXY)
|
private static float GetAxisPositionInternal(GridCoord grid, Axis axis, float scaleWidth, double value, bool includeGridXY, bool realLength)
|
||||||
{
|
{
|
||||||
var isY = axis is YAxis;
|
var isY = axis is YAxis;
|
||||||
var gridHeight = isY ? grid.context.height : grid.context.width;
|
var gridHeight = isY ? grid.context.height : grid.context.width;
|
||||||
@@ -521,8 +550,14 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var yDataHig = (axis.context.minMaxRange == 0) ? 0f :
|
var yDataHig = 0f;
|
||||||
(float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
|
if (axis.context.minMaxRange != 0)
|
||||||
|
{
|
||||||
|
if (!realLength || (realLength && axis.context.minValue > 0))
|
||||||
|
yDataHig = (float)((value - axis.context.minValue) / axis.context.minMaxRange * gridHeight);
|
||||||
|
else
|
||||||
|
yDataHig = (float)(value / axis.context.minMaxRange * gridHeight);
|
||||||
|
}
|
||||||
return includeGridXY
|
return includeGridXY
|
||||||
? gridXY + yDataHig
|
? gridXY + yDataHig
|
||||||
: yDataHig;
|
: yDataHig;
|
||||||
|
|||||||
@@ -22,10 +22,19 @@ namespace XCharts
|
|||||||
tooltip.numericFormatter, null, chart);
|
tooltip.numericFormatter, null, chart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = tooltip.context.data.param.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
var param = tooltip.context.data.param[i];
|
||||||
|
if (TooltipHelper.IsIgnoreItemFormatter(param.itemFormatter))
|
||||||
|
{
|
||||||
|
tooltip.context.data.param.RemoveAt(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach (var param in tooltip.context.data.param)
|
foreach (var param in tooltip.context.data.param)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(param.itemFormatter))
|
if (!string.IsNullOrEmpty(param.itemFormatter))
|
||||||
{
|
{
|
||||||
|
param.columns.Clear();
|
||||||
var content = param.itemFormatter;
|
var content = param.itemFormatter;
|
||||||
FormatterHelper.ReplaceSerieLabelContent(ref content,
|
FormatterHelper.ReplaceSerieLabelContent(ref content,
|
||||||
param.numericFormatter,
|
param.numericFormatter,
|
||||||
@@ -35,9 +44,6 @@ namespace XCharts
|
|||||||
param.category,
|
param.category,
|
||||||
param.serieData.name,
|
param.serieData.name,
|
||||||
param.color);
|
param.color);
|
||||||
|
|
||||||
param.columns.Clear();
|
|
||||||
|
|
||||||
foreach (var item in content.Split('|'))
|
foreach (var item in content.Split('|'))
|
||||||
{
|
{
|
||||||
param.columns.Add(item);
|
param.columns.Add(item);
|
||||||
@@ -46,6 +52,11 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsIgnoreItemFormatter(string itemFormatter)
|
||||||
|
{
|
||||||
|
return "-".Equals(itemFormatter);
|
||||||
|
}
|
||||||
|
|
||||||
public static void LimitInRect(Tooltip tooltip, Rect chartRect)
|
public static void LimitInRect(Tooltip tooltip, Rect chartRect)
|
||||||
{
|
{
|
||||||
if (tooltip.view == null)
|
if (tooltip.view == null)
|
||||||
|
|||||||
@@ -76,8 +76,12 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
var item = GetItem(i);
|
var item = GetItem(i);
|
||||||
var param = data.param[i];
|
var param = data.param[i];
|
||||||
|
if (param.columns.Count <= 0)
|
||||||
|
{
|
||||||
|
item.gameObject.SetActive(false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
item.gameObject.SetActive(true);
|
item.gameObject.SetActive(true);
|
||||||
|
|
||||||
for (int j = 0; j < param.columns.Count; j++)
|
for (int j = 0; j < param.columns.Count; j++)
|
||||||
{
|
{
|
||||||
var column = GetItemColumn(item, j);
|
var column = GetItemColumn(item, j);
|
||||||
@@ -135,7 +139,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(title.text.text))
|
if (!string.IsNullOrEmpty(title.GetText()))
|
||||||
maxHig += tooltip.titleHeight;
|
maxHig += tooltip.titleHeight;
|
||||||
maxHig += tooltip.itemHeight * tooltip.context.data.param.Count;
|
maxHig += tooltip.itemHeight * tooltip.context.data.param.Count;
|
||||||
maxHig += tooltip.paddingTopBottom * 2;
|
maxHig += tooltip.paddingTopBottom * 2;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace XCharts
|
|||||||
for (int n = 0; n < series.Count; n++)
|
for (int n = 0; n < series.Count; n++)
|
||||||
{
|
{
|
||||||
var serie = series[n];
|
var serie = series[n];
|
||||||
|
if (serie.placeHolder) continue;
|
||||||
if (serie.useDataNameForColor)
|
if (serie.useDataNameForColor)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < serie.data.Count; i++)
|
for (int i = 0; i < serie.data.Count; i++)
|
||||||
@@ -52,6 +53,7 @@ namespace XCharts
|
|||||||
for (int n = 0; n < chart.series.Count; n++)
|
for (int n = 0; n < chart.series.Count; n++)
|
||||||
{
|
{
|
||||||
var serie = chart.series[n];
|
var serie = chart.series[n];
|
||||||
|
if (serie.placeHolder) continue;
|
||||||
if (serie.useDataNameForColor)
|
if (serie.useDataNameForColor)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < serie.data.Count; i++)
|
for (int i = 0; i < serie.data.Count; i++)
|
||||||
@@ -81,6 +83,7 @@ namespace XCharts
|
|||||||
for (int n = 0; n < series.Count; n++)
|
for (int n = 0; n < series.Count; n++)
|
||||||
{
|
{
|
||||||
var serie = series[n];
|
var serie = series[n];
|
||||||
|
if (serie.placeHolder) continue;
|
||||||
if (serie.useDataNameForColor)
|
if (serie.useDataNameForColor)
|
||||||
{
|
{
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|||||||
@@ -788,9 +788,9 @@ namespace XCharts
|
|||||||
Debug.LogError("Serie no Handler:" + serie.GetType());
|
Debug.LogError("Serie no Handler:" + serie.GetType());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var attrubte = serie.GetType().GetAttribute<SerieHandlerAttribute>();
|
var attribute = serie.GetType().GetAttribute<SerieHandlerAttribute>();
|
||||||
var handler = (SerieHandler)Activator.CreateInstance(attrubte.handler);
|
var handler = (SerieHandler)Activator.CreateInstance(attribute.handler);
|
||||||
handler.attribute = attrubte;
|
handler.attribute = attribute;
|
||||||
handler.chart = this;
|
handler.chart = this;
|
||||||
handler.SetSerie(serie);
|
handler.SetSerie(serie);
|
||||||
serie.handler = handler;
|
serie.handler = handler;
|
||||||
|
|||||||
@@ -73,16 +73,5 @@ namespace XCharts
|
|||||||
if (handler != null)
|
if (handler != null)
|
||||||
handler.RefreshLabelNextFrame();
|
handler.RefreshLabelNextFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
protected virtual void Reset()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnValidate()
|
|
||||||
{
|
|
||||||
SetAllDirty();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -653,8 +653,9 @@ namespace XCharts
|
|||||||
count++;
|
count++;
|
||||||
intvalue = (int)(max * Mathf.Pow(10, count));
|
intvalue = (int)(max * Mathf.Pow(10, count));
|
||||||
}
|
}
|
||||||
if (max > 0) return 1 / Mathf.Pow(10, count - 1);
|
var pow = Mathf.Pow(10, count);
|
||||||
else return -1 / Mathf.Pow(10, count);
|
if (max > 0) return (int)((max * pow + 1)) / pow;
|
||||||
|
else return (int)((max * pow - 1)) / pow;
|
||||||
}
|
}
|
||||||
if (ceilRate == 0)
|
if (ceilRate == 0)
|
||||||
{
|
{
|
||||||
@@ -694,8 +695,9 @@ namespace XCharts
|
|||||||
count++;
|
count++;
|
||||||
intvalue = (int)(min * Mathf.Pow(10, count));
|
intvalue = (int)(min * Mathf.Pow(10, count));
|
||||||
}
|
}
|
||||||
if (min > 0) return 1 / Mathf.Pow(10, count);
|
var pow = Mathf.Pow(10, count);
|
||||||
else return -1 / Mathf.Pow(10, count - 1);
|
if (min > 0) return (int)((min * pow + 1)) / pow;
|
||||||
|
else return (int)((min * pow - 1)) / pow;
|
||||||
}
|
}
|
||||||
if (ceilRate == 0)
|
if (ceilRate == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ namespace XCharts
|
|||||||
public static bool AddCustomTheme(Theme theme)
|
public static bool AddCustomTheme(Theme theme)
|
||||||
{
|
{
|
||||||
if (theme == null) return false;
|
if (theme == null) return false;
|
||||||
|
if (Instance == null || Instance.m_CustomThemes == null) return false;
|
||||||
if (!Instance.m_CustomThemes.Contains(theme))
|
if (!Instance.m_CustomThemes.Contains(theme))
|
||||||
{
|
{
|
||||||
Instance.m_CustomThemes.Add(theme);
|
Instance.m_CustomThemes.Add(theme);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace XCharts
|
|||||||
typeof(LabelStyle),
|
typeof(LabelStyle),
|
||||||
typeof(IconStyle),
|
typeof(IconStyle),
|
||||||
typeof(Emphasis))]
|
typeof(Emphasis))]
|
||||||
public class Bar : Serie, INeedSerieContainer, ISimplifiedSerie
|
public class Bar : Serie, INeedSerieContainer
|
||||||
{
|
{
|
||||||
public int containerIndex { get; internal set; }
|
public int containerIndex { get; internal set; }
|
||||||
public int containterInstanceId { get; internal set; }
|
public int containterInstanceId { get; internal set; }
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using XUGL;
|
using XUGL;
|
||||||
@@ -32,6 +31,21 @@ namespace XCharts
|
|||||||
DrawBarSerie(vh, serie, serie.context.colorIndex);
|
DrawBarSerie(vh, serie, serie.context.colorIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label)
|
||||||
|
{
|
||||||
|
switch (label.position)
|
||||||
|
{
|
||||||
|
case LabelStyle.Position.Bottom:
|
||||||
|
var center = serieData.context.rect.center;
|
||||||
|
return new Vector3(center.x, center.y - serieData.context.rect.height / 2);
|
||||||
|
case LabelStyle.Position.Center:
|
||||||
|
case LabelStyle.Position.Inside:
|
||||||
|
return serieData.context.rect.center;
|
||||||
|
default:
|
||||||
|
return serieData.context.position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateSerieContext()
|
private void UpdateSerieContext()
|
||||||
{
|
{
|
||||||
if (m_SerieGrid == null)
|
if (m_SerieGrid == null)
|
||||||
@@ -129,7 +143,6 @@ namespace XCharts
|
|||||||
return;
|
return;
|
||||||
if (m_SerieGrid == null)
|
if (m_SerieGrid == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var dataZoom = chart.GetDataZoomOfAxis(axis);
|
var dataZoom = chart.GetDataZoomOfAxis(axis);
|
||||||
var showData = serie.GetDataList(dataZoom);
|
var showData = serie.GetDataList(dataZoom);
|
||||||
|
|
||||||
@@ -137,6 +150,7 @@ namespace XCharts
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var axisLength = isY ? m_SerieGrid.context.height : m_SerieGrid.context.width;
|
var axisLength = isY ? m_SerieGrid.context.height : m_SerieGrid.context.width;
|
||||||
|
var relativedAxisLength = isY ? m_SerieGrid.context.width : m_SerieGrid.context.height;
|
||||||
var axisXY = isY ? m_SerieGrid.context.y : m_SerieGrid.context.x;
|
var axisXY = isY ? m_SerieGrid.context.y : m_SerieGrid.context.x;
|
||||||
|
|
||||||
var isStack = SeriesHelper.IsStack<Bar>(chart.series, serie.stack);
|
var isStack = SeriesHelper.IsStack<Bar>(chart.series, serie.stack);
|
||||||
@@ -200,7 +214,7 @@ namespace XCharts
|
|||||||
if (isPercentStack)
|
if (isPercentStack)
|
||||||
{
|
{
|
||||||
var valueTotal = chart.GetSerieSameStackTotalValue<Bar>(serie.stack, i);
|
var valueTotal = chart.GetSerieSameStackTotalValue<Bar>(serie.stack, i);
|
||||||
barHig = valueTotal != 0 ? (float)(relativedValue / valueTotal * axisLength) : 0;
|
barHig = valueTotal != 0 ? (float)(relativedValue / valueTotal * relativedAxisLength) : 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -208,7 +222,6 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||||
|
|
||||||
Vector3 plb, plt, prt, prb, top;
|
Vector3 plb, plt, prt, prb, top;
|
||||||
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, space, borderWidth, barWidth, currHig,
|
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, space, borderWidth, barWidth, currHig,
|
||||||
out plb, out plt, out prt, out prb, out top);
|
out plb, out plt, out prt, out prb, out top);
|
||||||
@@ -216,25 +229,24 @@ namespace XCharts
|
|||||||
serieData.context.position = top;
|
serieData.context.position = top;
|
||||||
serieData.context.rect = Rect.MinMaxRect(plb.x, plb.y, prb.x, prt.y);
|
serieData.context.rect = Rect.MinMaxRect(plb.x, plb.y, prb.x, prt.y);
|
||||||
serie.context.dataPoints.Add(top);
|
serie.context.dataPoints.Add(top);
|
||||||
if (serie.show && currHig != 0)
|
if (serie.show && currHig != 0 && !serie.placeHolder)
|
||||||
{
|
{
|
||||||
switch (serie.barType)
|
switch (serie.barType)
|
||||||
{
|
{
|
||||||
case BarType.Normal:
|
case BarType.Normal:
|
||||||
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||||
pX, pY, plb, plt, prt, prb, false, m_SerieGrid, areaColor, areaToColor);
|
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
||||||
break;
|
break;
|
||||||
case BarType.Zebra:
|
case BarType.Zebra:
|
||||||
DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||||
pX, pY, plb, plt, prt, prb, false, m_SerieGrid, areaColor, areaToColor);
|
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
||||||
break;
|
break;
|
||||||
case BarType.Capsule:
|
case BarType.Capsule:
|
||||||
DrawCapsuleBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
DrawCapsuleBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
|
||||||
pX, pY, plb, plt, prt, prb, false, m_SerieGrid, areaColor, areaToColor);
|
pX, pY, plb, plt, prt, prb, isY, m_SerieGrid, axis, areaColor, areaToColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serie.animation.CheckDetailBreak(top, isY))
|
if (serie.animation.CheckDetailBreak(top, isY))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -265,7 +277,7 @@ namespace XCharts
|
|||||||
if (axis.context.minMaxRange <= 0) pY = grid.context.y;
|
if (axis.context.minMaxRange <= 0) pY = grid.context.y;
|
||||||
else pY = grid.context.y + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.height - barWidth);
|
else pY = grid.context.y + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.height - barWidth);
|
||||||
}
|
}
|
||||||
pX = AxisHelper.GetAxisPosition(grid, relativedAxis, categoryWidth, 0);
|
pX = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
|
||||||
if (isStack)
|
if (isStack)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
|
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
|
||||||
@@ -283,7 +295,7 @@ namespace XCharts
|
|||||||
if (axis.context.minMaxRange <= 0) pX = grid.context.x;
|
if (axis.context.minMaxRange <= 0) pX = grid.context.x;
|
||||||
else pX = grid.context.x + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.width - barWidth);
|
else pX = grid.context.x + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.width - barWidth);
|
||||||
}
|
}
|
||||||
pY = AxisHelper.GetAxisPosition(grid, relativedAxis, categoryWidth, 0);
|
pY = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
|
||||||
if (isStack)
|
if (isStack)
|
||||||
{
|
{
|
||||||
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
|
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
|
||||||
@@ -319,8 +331,8 @@ namespace XCharts
|
|||||||
if (yValue < 0)
|
if (yValue < 0)
|
||||||
{
|
{
|
||||||
plb = new Vector3(pX + space + borderWidth, pY - borderWidth);
|
plb = new Vector3(pX + space + borderWidth, pY - borderWidth);
|
||||||
plt = new Vector3(pX + space + borderWidth, pY + currHig + borderWidth);
|
plt = new Vector3(pX + space + borderWidth, pY + currHig - borderWidth);
|
||||||
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig + borderWidth);
|
prt = new Vector3(pX + space + barWidth - borderWidth, pY + currHig - borderWidth);
|
||||||
prb = new Vector3(pX + space + barWidth - borderWidth, pY - borderWidth);
|
prb = new Vector3(pX + space + barWidth - borderWidth, pY - borderWidth);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -344,10 +356,9 @@ namespace XCharts
|
|||||||
|
|
||||||
private void DrawNormalBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
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,
|
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||||
Vector3 prb, bool isYAxis, GridCoord grid, Color32 areaColor, Color32 areaToColor)
|
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 areaColor, Color32 areaToColor)
|
||||||
{
|
{
|
||||||
|
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid, axis);
|
||||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
|
|
||||||
var borderWidth = itemStyle.runtimeBorderWidth;
|
var borderWidth = itemStyle.runtimeBorderWidth;
|
||||||
if (isYAxis)
|
if (isYAxis)
|
||||||
{
|
{
|
||||||
@@ -410,9 +421,9 @@ namespace XCharts
|
|||||||
|
|
||||||
private void DrawZebraBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
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,
|
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||||
Vector3 prb, bool isYAxis, GridCoord grid, Color32 barColor, Color32 barToColor)
|
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 barColor, Color32 barToColor)
|
||||||
{
|
{
|
||||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
|
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid, axis);
|
||||||
if (isYAxis)
|
if (isYAxis)
|
||||||
{
|
{
|
||||||
plt = (plb + plt) / 2;
|
plt = (plb + plt) / 2;
|
||||||
@@ -431,9 +442,9 @@ namespace XCharts
|
|||||||
|
|
||||||
private void DrawCapsuleBar(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle, int colorIndex,
|
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,
|
bool highlight, float space, float barWidth, float pX, float pY, Vector3 plb, Vector3 plt, Vector3 prt,
|
||||||
Vector3 prb, bool isYAxis, GridCoord grid, Color32 areaColor, Color32 areaToColor)
|
Vector3 prb, bool isYAxis, GridCoord grid, Axis axis, Color32 areaColor, Color32 areaToColor)
|
||||||
{
|
{
|
||||||
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid);
|
DrawBarBackground(vh, serie, serieData, itemStyle, colorIndex, highlight, pX, pY, space, barWidth, isYAxis, grid, axis);
|
||||||
var borderWidth = itemStyle.runtimeBorderWidth;
|
var borderWidth = itemStyle.runtimeBorderWidth;
|
||||||
var radius = barWidth / 2 - borderWidth;
|
var radius = barWidth / 2 - borderWidth;
|
||||||
var isGradient = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);
|
var isGradient = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor);
|
||||||
@@ -548,13 +559,13 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void DrawBarBackground(VertexHelper vh, Serie serie, SerieData serieData, ItemStyle itemStyle,
|
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, GridCoord grid)
|
int colorIndex, bool highlight, float pX, float pY, float space, float barWidth, bool isYAxis,
|
||||||
|
GridCoord grid, Axis axis)
|
||||||
{
|
{
|
||||||
var color = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false);
|
var color = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, colorIndex, highlight, false);
|
||||||
if (ChartHelper.IsClearColor(color)) return;
|
if (ChartHelper.IsClearColor(color)) return;
|
||||||
if (isYAxis)
|
if (isYAxis)
|
||||||
{
|
{
|
||||||
var axis = chart.GetChartComponent<YAxis>(serie.yAxisIndex);
|
|
||||||
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
||||||
Vector3 plt = new Vector3(grid.context.x + axisWidth, pY + space + barWidth);
|
Vector3 plt = new Vector3(grid.context.x + axisWidth, pY + space + barWidth);
|
||||||
Vector3 prt = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + space + barWidth);
|
Vector3 prt = new Vector3(grid.context.x + axisWidth + grid.context.width, pY + space + barWidth);
|
||||||
@@ -595,7 +606,6 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var axis = chart.GetChartComponent<XAxis>(serie.xAxisIndex);
|
|
||||||
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
var axisWidth = axis.axisLine.GetWidth(chart.theme.axis.lineWidth);
|
||||||
Vector3 plb = new Vector3(pX + space, grid.context.y + axisWidth);
|
Vector3 plb = new Vector3(pX + space, grid.context.y + axisWidth);
|
||||||
Vector3 plt = new Vector3(pX + space, grid.context.y + grid.context.height + axisWidth);
|
Vector3 plt = new Vector3(pX + space, grid.context.y + grid.context.height + axisWidth);
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ namespace XCharts
|
|||||||
var pY = 0f;
|
var pY = 0f;
|
||||||
UpdateXYPosition(m_SerieGrid, isY, axis, relativedAxis, i, categoryWidth, barWidth, value, ref pX, ref pY);
|
UpdateXYPosition(m_SerieGrid, isY, axis, relativedAxis, i, categoryWidth, barWidth, value, ref pX, ref pY);
|
||||||
|
|
||||||
var barHig = AxisHelper.GetAxisValueLength(m_SerieGrid, relativedAxis, categoryWidth, relativedValue);
|
var barHig = AxisHelper.GetAxisValueDistance(m_SerieGrid, relativedAxis, categoryWidth, relativedValue);
|
||||||
var currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
var currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||||
|
|
||||||
Vector3 plb, plt, prt, prb, top;
|
Vector3 plb, plt, prt, prb, top;
|
||||||
@@ -233,7 +233,7 @@ namespace XCharts
|
|||||||
if (axis.context.minMaxRange <= 0) pY = grid.context.y;
|
if (axis.context.minMaxRange <= 0) pY = grid.context.y;
|
||||||
else pY = grid.context.y + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.height - barWidth);
|
else pY = grid.context.y + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.height - barWidth);
|
||||||
}
|
}
|
||||||
pX = AxisHelper.GetAxisPosition(grid, relativedAxis, categoryWidth, 0);
|
pX = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -246,7 +246,7 @@ namespace XCharts
|
|||||||
if (axis.context.minMaxRange <= 0) pX = grid.context.x;
|
if (axis.context.minMaxRange <= 0) pX = grid.context.x;
|
||||||
else pX = grid.context.x + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.width - barWidth);
|
else pX = grid.context.x + (float)((value - axis.context.minValue) / axis.context.minMaxRange) * (grid.context.width - barWidth);
|
||||||
}
|
}
|
||||||
pY = AxisHelper.GetAxisPosition(grid, relativedAxis, categoryWidth, 0);
|
pY = AxisHelper.GetAxisValuePosition(grid, relativedAxis, categoryWidth, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace XCharts
|
|||||||
|
|
||||||
public bool TryGetValue(ref float value, ref bool interacting, float animationDuration = 250)
|
public bool TryGetValue(ref float value, ref bool interacting, float animationDuration = 250)
|
||||||
{
|
{
|
||||||
if (!m_ValueEnable || m_PreviousValue == 0)
|
if (!IsValueEnable() || m_PreviousValue == 0)
|
||||||
return false;
|
return false;
|
||||||
if (m_UpdateFlag)
|
if (m_UpdateFlag)
|
||||||
{
|
{
|
||||||
@@ -99,7 +99,7 @@ namespace XCharts
|
|||||||
|
|
||||||
public bool TryGetColor(ref Color32 color, ref bool interacting, float animationDuration = 250)
|
public bool TryGetColor(ref Color32 color, ref bool interacting, float animationDuration = 250)
|
||||||
{
|
{
|
||||||
if (!m_ValueEnable)
|
if (!IsValueEnable())
|
||||||
return false;
|
return false;
|
||||||
if (m_UpdateFlag)
|
if (m_UpdateFlag)
|
||||||
{
|
{
|
||||||
@@ -124,7 +124,7 @@ namespace XCharts
|
|||||||
|
|
||||||
public bool TryGetColor(ref Color32 color, ref Color32 toColor, ref bool interacting, float animationDuration = 250)
|
public bool TryGetColor(ref Color32 color, ref Color32 toColor, ref bool interacting, float animationDuration = 250)
|
||||||
{
|
{
|
||||||
if (!m_ValueEnable)
|
if (!IsValueEnable())
|
||||||
return false;
|
return false;
|
||||||
if (m_UpdateFlag)
|
if (m_UpdateFlag)
|
||||||
{
|
{
|
||||||
@@ -150,7 +150,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
public bool TryGetValueAndColor(ref float value, ref Color32 color, ref Color32 toColor, ref bool interacting, float animationDuration = 250)
|
public bool TryGetValueAndColor(ref float value, ref Color32 color, ref Color32 toColor, ref bool interacting, float animationDuration = 250)
|
||||||
{
|
{
|
||||||
if (!m_ValueEnable)
|
if (!IsValueEnable())
|
||||||
return false;
|
return false;
|
||||||
if (m_UpdateFlag)
|
if (m_UpdateFlag)
|
||||||
{
|
{
|
||||||
@@ -181,5 +181,14 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
m_ValueEnable = false;
|
m_ValueEnable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsValueEnable()
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if (!Application.isPlaying)
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
return m_ValueEnable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,6 @@ namespace XCharts
|
|||||||
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, serie.index, highlight, false);
|
var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, serie.index, highlight, false);
|
||||||
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight);
|
||||||
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight);
|
||||||
|
|
||||||
chart.DrawClipSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
chart.DrawClipSymbol(vh, symbol.type, symbolSize, symbolBorder, pos,
|
||||||
symbolColor, symbolToColor, symbolEmptyColor, symbol.gap, clip, cornerRadius, m_SerieGrid,
|
symbolColor, symbolToColor, symbolEmptyColor, symbol.gap, clip, cornerRadius, m_SerieGrid,
|
||||||
i > 0 ? serie.context.dataPoints[i - 1] : m_SerieGrid.context.position);
|
i > 0 ? serie.context.dataPoints[i - 1] : m_SerieGrid.context.position);
|
||||||
@@ -410,14 +409,14 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
float xPos, yPos;
|
float xPos, yPos;
|
||||||
var gridXY = isY ? grid.context.x : grid.context.y;
|
var gridXY = isY ? grid.context.x : grid.context.y;
|
||||||
|
var valueHig = 0f;
|
||||||
if (isY)
|
if (isY)
|
||||||
{
|
{
|
||||||
var valueHig = AxisHelper.GetAxisValueLength(grid, relativedAxis, scaleWid, yValue);
|
valueHig = AxisHelper.GetAxisValueDistance(grid, relativedAxis, scaleWid, yValue);
|
||||||
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
|
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
|
||||||
|
|
||||||
xPos = gridXY + valueHig;
|
xPos = gridXY + valueHig;
|
||||||
yPos = AxisHelper.GetAxisPosition(grid, axis, scaleWid, xValue);
|
yPos = AxisHelper.GetAxisValuePosition(grid, axis, scaleWid, xValue);
|
||||||
|
|
||||||
if (isStack)
|
if (isStack)
|
||||||
{
|
{
|
||||||
@@ -428,11 +427,11 @@ namespace XCharts
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
var valueHig = AxisHelper.GetAxisValueLength(grid, relativedAxis, scaleWid, yValue);
|
valueHig = AxisHelper.GetAxisValueDistance(grid, relativedAxis, scaleWid, yValue);
|
||||||
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
|
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
|
||||||
|
|
||||||
yPos = gridXY + valueHig;
|
yPos = gridXY + valueHig;
|
||||||
xPos = AxisHelper.GetAxisPosition(grid, axis, scaleWid, xValue);
|
xPos = AxisHelper.GetAxisValuePosition(grid, axis, scaleWid, xValue);
|
||||||
|
|
||||||
if (isStack)
|
if (isStack)
|
||||||
{
|
{
|
||||||
@@ -441,7 +440,7 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
np = new Vector3(xPos, yPos);
|
np = new Vector3(xPos, yPos);
|
||||||
return yPos;
|
return valueHig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,20 +259,20 @@ namespace XCharts
|
|||||||
|
|
||||||
if (isY)
|
if (isY)
|
||||||
{
|
{
|
||||||
var valueHig = AxisHelper.GetAxisValueLength(grid, relativedAxis, scaleWid, yValue);
|
var valueHig = AxisHelper.GetAxisValueDistance(grid, relativedAxis, scaleWid, yValue);
|
||||||
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
|
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
|
||||||
|
|
||||||
xPos = gridXY + valueHig;
|
xPos = gridXY + valueHig;
|
||||||
yPos = AxisHelper.GetAxisPosition(grid, axis, scaleWid, xValue);
|
yPos = AxisHelper.GetAxisValuePosition(grid, axis, scaleWid, xValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
var valueHig = AxisHelper.GetAxisValueLength(grid, relativedAxis, scaleWid, yValue);
|
var valueHig = AxisHelper.GetAxisValueDistance(grid, relativedAxis, scaleWid, yValue);
|
||||||
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
|
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
|
||||||
|
|
||||||
yPos = gridXY + valueHig;
|
yPos = gridXY + valueHig;
|
||||||
xPos = AxisHelper.GetAxisPosition(grid, axis, scaleWid, xValue);
|
xPos = AxisHelper.GetAxisValuePosition(grid, axis, scaleWid, xValue);
|
||||||
}
|
}
|
||||||
np = new Vector3(xPos, yPos);
|
np = new Vector3(xPos, yPos);
|
||||||
return yPos;
|
return yPos;
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ namespace XCharts
|
|||||||
[SerializeField] private int m_LargeThreshold = 200;
|
[SerializeField] private int m_LargeThreshold = 200;
|
||||||
[SerializeField] private bool m_AvoidLabelOverlap = false;
|
[SerializeField] private bool m_AvoidLabelOverlap = false;
|
||||||
[SerializeField] private RadarType m_RadarType = RadarType.Multiple;
|
[SerializeField] private RadarType m_RadarType = RadarType.Multiple;
|
||||||
|
[SerializeField] private bool m_PlaceHolder = false;
|
||||||
|
|
||||||
[SerializeField] private SerieDataSortType m_DataSortType = SerieDataSortType.Descending;
|
[SerializeField] private SerieDataSortType m_DataSortType = SerieDataSortType.Descending;
|
||||||
[SerializeField] private Orient m_Orient = Orient.Vertical;
|
[SerializeField] private Orient m_Orient = Orient.Vertical;
|
||||||
@@ -231,16 +232,10 @@ namespace XCharts
|
|||||||
[SerializeField] private bool m_InsertDataToHead;
|
[SerializeField] private bool m_InsertDataToHead;
|
||||||
|
|
||||||
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
|
[SerializeField] private LineStyle m_LineStyle = new LineStyle();
|
||||||
//[SerializeField] private AreaStyle m_AreaStyle = AreaStyle.defaultAreaStyle;
|
|
||||||
[SerializeField] private SymbolStyle m_Symbol = new SymbolStyle();
|
[SerializeField] private SymbolStyle m_Symbol = new SymbolStyle();
|
||||||
//[SerializeField] private LabelStyle m_Label = new LabelStyle();
|
|
||||||
//[SerializeField] private LabelLine m_LabelLine = new LabelLine();
|
|
||||||
[SerializeField] private AnimationStyle m_Animation = new AnimationStyle();
|
[SerializeField] private AnimationStyle m_Animation = new AnimationStyle();
|
||||||
//[SerializeField] private LineArrow m_LineArrow = new LineArrow();
|
|
||||||
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
|
[SerializeField] private ItemStyle m_ItemStyle = new ItemStyle();
|
||||||
//[SerializeField] private Emphasis m_Emphasis = new Emphasis();
|
|
||||||
[SerializeField] private TitleStyle m_TitleStyle = new TitleStyle();
|
[SerializeField] private TitleStyle m_TitleStyle = new TitleStyle();
|
||||||
//[SerializeField] private IconStyle m_IconStyle = new IconStyle();
|
|
||||||
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
[SerializeField] private List<SerieData> m_Data = new List<SerieData>();
|
||||||
|
|
||||||
[NonSerialized] internal int m_FilterStart;
|
[NonSerialized] internal int m_FilterStart;
|
||||||
@@ -861,6 +856,14 @@ namespace XCharts
|
|||||||
set { if (PropertyUtil.SetStruct(ref m_Align, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_Align, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 占位模式。占位模式时,数据有效但不参与渲染和显示。
|
||||||
|
/// </summary>
|
||||||
|
public bool placeHolder
|
||||||
|
{
|
||||||
|
get { return m_PlaceHolder; }
|
||||||
|
set { if (PropertyUtil.SetStruct(ref m_PlaceHolder, value)) SetAllDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
/// 系列中的数据内容数组。SerieData可以设置1到n维数据。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<SerieData> data { get { return m_Data; } }
|
public List<SerieData> data { get { return m_Data; } }
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ namespace XCharts
|
|||||||
public virtual void OnScroll(PointerEventData eventData) { }
|
public virtual void OnScroll(PointerEventData eventData) { }
|
||||||
public virtual void RefreshLabelNextFrame() { }
|
public virtual void RefreshLabelNextFrame() { }
|
||||||
public virtual void RefreshLabelInternal() { }
|
public virtual void RefreshLabelInternal() { }
|
||||||
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, string marker, string itemFormatter, string numericFormatter, ref List<SerieParams> paramList, ref string title) { }
|
public virtual void UpdateTooltipSerieParams(int dataIndex, bool showCategory, string category, string marker,
|
||||||
|
string itemFormatter, string numericFormatter, ref List<SerieParams> paramList, ref string title)
|
||||||
|
{ }
|
||||||
public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }
|
public virtual void OnLegendButtonClick(int index, string legendName, bool show) { }
|
||||||
public virtual void OnLegendButtonEnter(int index, string legendName) { }
|
public virtual void OnLegendButtonEnter(int index, string legendName) { }
|
||||||
public virtual void OnLegendButtonExit(int index, string legendName) { }
|
public virtual void OnLegendButtonExit(int index, string legendName) { }
|
||||||
@@ -43,6 +45,7 @@ namespace XCharts
|
|||||||
private static readonly string s_SerieTitleObjectName = "serie";
|
private static readonly string s_SerieTitleObjectName = "serie";
|
||||||
protected GameObject m_SerieRoot;
|
protected GameObject m_SerieRoot;
|
||||||
protected bool m_InitedLabel;
|
protected bool m_InitedLabel;
|
||||||
|
protected bool m_NeedInitComponent;
|
||||||
protected bool m_RefreshLabel;
|
protected bool m_RefreshLabel;
|
||||||
protected bool m_LastCheckContextFlag = false;
|
protected bool m_LastCheckContextFlag = false;
|
||||||
protected bool m_LegendEnter = false;
|
protected bool m_LegendEnter = false;
|
||||||
@@ -54,9 +57,15 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
this.serie = (T)serie;
|
this.serie = (T)serie;
|
||||||
this.serie.context.param.serieType = typeof(T);
|
this.serie.context.param.serieType = typeof(T);
|
||||||
|
m_NeedInitComponent = true;
|
||||||
}
|
}
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
if (m_NeedInitComponent)
|
||||||
|
{
|
||||||
|
m_NeedInitComponent = false;
|
||||||
|
InitComponent();
|
||||||
|
}
|
||||||
if (m_RefreshLabel)
|
if (m_RefreshLabel)
|
||||||
{
|
{
|
||||||
m_RefreshLabel = false;
|
m_RefreshLabel = false;
|
||||||
@@ -99,6 +108,7 @@ namespace XCharts
|
|||||||
|
|
||||||
public override void InitComponent()
|
public override void InitComponent()
|
||||||
{
|
{
|
||||||
|
m_InitedLabel = false;
|
||||||
InitRoot();
|
InitRoot();
|
||||||
InitSerieLabel();
|
InitSerieLabel();
|
||||||
InitSerieTitle();
|
InitSerieTitle();
|
||||||
@@ -138,7 +148,7 @@ namespace XCharts
|
|||||||
|
|
||||||
private void InitRoot()
|
private void InitRoot()
|
||||||
{
|
{
|
||||||
m_InitedLabel = false;
|
if (m_SerieRoot != null) return;
|
||||||
var objName = s_SerieTitleObjectName + "_" + serie.index;
|
var objName = s_SerieTitleObjectName + "_" + serie.index;
|
||||||
m_SerieRoot = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
m_SerieRoot = ChartHelper.AddObject(objName, chart.transform, chart.chartMinAnchor,
|
||||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||||
@@ -151,8 +161,8 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (m_SerieRoot == null)
|
if (m_SerieRoot == null)
|
||||||
InitRoot();
|
InitRoot();
|
||||||
var serieLabelRoot = ChartHelper.AddObject(s_SerieLabelObjectName, m_SerieRoot.transform, chart.chartMinAnchor,
|
var serieLabelRoot = ChartHelper.AddObject(s_SerieLabelObjectName, m_SerieRoot.transform,
|
||||||
chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
chart.chartMinAnchor, chart.chartMaxAnchor, chart.chartPivot, chart.chartSizeDelta);
|
||||||
serieLabelRoot.hideFlags = chart.chartHideFlags;
|
serieLabelRoot.hideFlags = chart.chartHideFlags;
|
||||||
SerieLabelPool.ReleaseAll(serieLabelRoot.transform);
|
SerieLabelPool.ReleaseAll(serieLabelRoot.transform);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -218,7 +228,9 @@ namespace XCharts
|
|||||||
if (m_SerieRoot == null)
|
if (m_SerieRoot == null)
|
||||||
InitRoot();
|
InitRoot();
|
||||||
var textStyle = serie.titleStyle.textStyle;
|
var textStyle = serie.titleStyle.textStyle;
|
||||||
var titleColor = ChartHelper.IsClearColor(textStyle.color) ? chart.theme.GetColor(serie.index) : (Color32)textStyle.color;
|
var titleColor = ChartHelper.IsClearColor(textStyle.color)
|
||||||
|
? chart.theme.GetColor(serie.index)
|
||||||
|
: (Color32)textStyle.color;
|
||||||
var anchorMin = new Vector2(0.5f, 0.5f);
|
var anchorMin = new Vector2(0.5f, 0.5f);
|
||||||
var anchorMax = new Vector2(0.5f, 0.5f);
|
var anchorMax = new Vector2(0.5f, 0.5f);
|
||||||
var pivot = new Vector2(0.5f, 0.5f);
|
var pivot = new Vector2(0.5f, 0.5f);
|
||||||
@@ -244,20 +256,19 @@ namespace XCharts
|
|||||||
{
|
{
|
||||||
if (!m_InitedLabel)
|
if (!m_InitedLabel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
|
var colorIndex = chart.GetLegendRealShowNameIndex(serie.legendName);
|
||||||
var total = serie.yTotal;
|
var total = serie.yTotal;
|
||||||
foreach (var serieData in serie.data)
|
foreach (var serieData in serie.data)
|
||||||
{
|
{
|
||||||
if (serieData.labelObject == null)
|
if (serieData.labelObject == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
|
||||||
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
var iconStyle = SerieHelper.GetIconStyle(serie, serieData);
|
||||||
var isIgnore = serie.IsIgnoreIndex(serieData.index);
|
var isIgnore = serie.IsIgnoreIndex(serieData.index);
|
||||||
serieData.labelObject.SetPosition(serieData.context.position);
|
serieData.labelObject.SetPosition(serieData.context.position);
|
||||||
serieData.labelObject.UpdateIcon(iconStyle);
|
serieData.labelObject.UpdateIcon(iconStyle);
|
||||||
if (serie.show && serieLabel != null && serieLabel.show && serieData.context.canShowLabel && !isIgnore)
|
if (serie.show && serieLabel != null
|
||||||
|
&& serieLabel.show && serieData.context.canShowLabel && !isIgnore)
|
||||||
{
|
{
|
||||||
var value = serieData.GetData(1);
|
var value = serieData.GetData(1);
|
||||||
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
|
var content = SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
|
||||||
@@ -266,9 +277,11 @@ namespace XCharts
|
|||||||
&& serie is Line
|
&& serie is Line
|
||||||
&& SerieHelper.IsDownPoint(serie, serieData.index)
|
&& SerieHelper.IsDownPoint(serie, serieData.index)
|
||||||
&& (serie.areaStyle == null || !serie.areaStyle.show);
|
&& (serie.areaStyle == null || !serie.areaStyle.show);
|
||||||
|
var labelPosition = GetSerieDataLabelPosition(serieData, serieLabel);
|
||||||
SerieLabelHelper.ResetLabel(serieData.labelObject.label, serieLabel, chart.theme);
|
SerieLabelHelper.ResetLabel(serieData.labelObject.label, serieLabel, chart.theme);
|
||||||
serieData.SetLabelActive(!isIgnore);
|
serieData.SetLabelActive(!isIgnore);
|
||||||
serieData.labelObject.SetPosition(serieData.context.position + (invert ? -serieLabel.offset : serieLabel.offset));
|
serieData.labelObject.SetPosition(labelPosition
|
||||||
|
+ (invert ? -serieLabel.offset : serieLabel.offset));
|
||||||
serieData.labelObject.SetText(content);
|
serieData.labelObject.SetText(content);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -278,6 +291,11 @@ namespace XCharts
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual Vector3 GetSerieDataLabelPosition(SerieData serieData, LabelStyle label)
|
||||||
|
{
|
||||||
|
return serieData.context.position;
|
||||||
|
}
|
||||||
|
|
||||||
protected void UpdateCoordSerieParams(ref List<SerieParams> paramList, ref string title,
|
protected void UpdateCoordSerieParams(ref List<SerieParams> paramList, ref string title,
|
||||||
int dataIndex, bool showCategory, string category, string marker,
|
int dataIndex, bool showCategory, string category, string marker,
|
||||||
string itemFormatter, string numericFormatter)
|
string itemFormatter, string numericFormatter)
|
||||||
@@ -292,6 +310,10 @@ namespace XCharts
|
|||||||
if (serieData == null)
|
if (serieData == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||||
|
if (TooltipHelper.IsIgnoreItemFormatter(itemFormatter))
|
||||||
|
return;
|
||||||
|
|
||||||
var param = serie.context.param;
|
var param = serie.context.param;
|
||||||
param.serieName = serie.serieName;
|
param.serieName = serie.serieName;
|
||||||
param.serieIndex = serie.index;
|
param.serieIndex = serie.index;
|
||||||
@@ -302,7 +324,7 @@ namespace XCharts
|
|||||||
param.total = serie.yTotal;
|
param.total = serie.yTotal;
|
||||||
param.color = chart.GetLegendRealShowNameColor(serie.serieName);
|
param.color = chart.GetLegendRealShowNameColor(serie.serieName);
|
||||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
param.itemFormatter = itemFormatter;
|
||||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);
|
||||||
param.columns.Clear();
|
param.columns.Clear();
|
||||||
|
|
||||||
@@ -327,6 +349,10 @@ namespace XCharts
|
|||||||
if (serieData == null)
|
if (serieData == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||||
|
if (TooltipHelper.IsIgnoreItemFormatter(itemFormatter))
|
||||||
|
return;
|
||||||
|
|
||||||
var param = serie.context.param;
|
var param = serie.context.param;
|
||||||
param.serieName = serie.serieName;
|
param.serieName = serie.serieName;
|
||||||
param.serieIndex = serie.index;
|
param.serieIndex = serie.index;
|
||||||
@@ -337,7 +363,7 @@ namespace XCharts
|
|||||||
param.total = SerieHelper.GetMaxData(serie, dimension);
|
param.total = SerieHelper.GetMaxData(serie, dimension);
|
||||||
param.color = chart.theme.GetColor(dataIndex);
|
param.color = chart.theme.GetColor(dataIndex);
|
||||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
param.itemFormatter = itemFormatter;
|
||||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); ;
|
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); ;
|
||||||
param.columns.Clear();
|
param.columns.Clear();
|
||||||
|
|
||||||
|
|||||||
@@ -104,12 +104,6 @@ namespace XCharts
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
m_TMPFont = value;
|
m_TMPFont = value;
|
||||||
if(value)
|
|
||||||
{
|
|
||||||
m_TMPFontName = value.name;
|
|
||||||
m_TMPFontInstanceId = value.GetInstanceID();
|
|
||||||
}
|
|
||||||
SetComponentDirty();
|
|
||||||
SyncTMPFontToSubComponent();
|
SyncTMPFontToSubComponent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,11 +358,7 @@ namespace XCharts
|
|||||||
subTitle.tmpFont = tmpFont;
|
subTitle.tmpFont = tmpFont;
|
||||||
legend.tmpFont = tmpFont;
|
legend.tmpFont = tmpFont;
|
||||||
axis.tmpFont = tmpFont;
|
axis.tmpFont = tmpFont;
|
||||||
radiusAxis.tmpFont = tmpFont;
|
|
||||||
angleAxis.tmpFont = tmpFont;
|
|
||||||
polar.tmpFont = tmpFont;
|
|
||||||
gauge.tmpFont = tmpFont;
|
gauge.tmpFont = tmpFont;
|
||||||
radar.tmpFont = tmpFont;
|
|
||||||
tooltip.tmpFont = tmpFont;
|
tooltip.tmpFont = tmpFont;
|
||||||
dataZoom.tmpFont = tmpFont;
|
dataZoom.tmpFont = tmpFont;
|
||||||
visualMap.tmpFont = tmpFont;
|
visualMap.tmpFont = tmpFont;
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ namespace XCharts
|
|||||||
public void CheckWarning(StringBuilder sb)
|
public void CheckWarning(StringBuilder sb)
|
||||||
{
|
{
|
||||||
#if dUI_TextMeshPro
|
#if dUI_TextMeshPro
|
||||||
if (m_Profile.tmpFont == null)
|
if (sharedTheme.tmpFont == null)
|
||||||
{
|
{
|
||||||
sb.AppendFormat("warning:theme->tmpFont is null\n");
|
sb.AppendFormat("warning:theme->tmpFont is null\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user