public static Serie AddDefaultCategoryGanttSerie(BaseChart chart, string serieName, int dataCount = 0, int min = 0, int max = 0) { var serie = chart.AddSerie(SerieType.Gantt, serieName); serie.showDataName = true; serie.showDataDimension = 2; for (int i = 0; i < dataCount; i++) { var start = Random.Range(min, max); var end = Random.Range(start + 1, max); serie.AddXYData(start, end, "task-" + (i + 1)); } return(serie); }
public static string CheckChart(BaseChart chart) { var sb = ChartHelper.sb; sb.Length = 0; CheckName(chart, sb); CheckSize(chart, sb); CheckTheme(chart, sb); CheckTitle(chart, sb); CheckLegend(chart, sb); CheckGrid(chart, sb); CheckSerie(chart, sb); return(sb.ToString()); }
public void AddChart(BaseChart chart) { var sameNameChart = GetChart(chart.chartName); if (sameNameChart != null) { var path = ChartHelper.GetFullName(sameNameChart.transform); Debug.LogError("A chart named `" + chart.chartName + "` already exists:" + path); } if (!ContainsChart(chart)) { m_ChartList.Add(chart); } }
public static string CheckChart(BaseChart chart) { var sb = ChartHelper.sb; sb.Length = 0; //sb.AppendFormat("version:{0}_{1}\n", XChartsMgr.version, XChartsMgr.date); CheckSize(chart, sb); CheckTheme(chart, sb); CheckTitle(chart, sb); CheckLegend(chart, sb); CheckGrid(chart, sb); CheckSerie(chart, sb); return(sb.ToString()); }
public static int AddDefaultCandlestickSerie(BaseChart chart, string serieName) { var serie = chart.AddSerie(SerieType.Candlestick, serieName); var defaultDataCount = 5; for (int i = 0; i < defaultDataCount; i++) { var open = Random.Range(20, 60); var close = Random.Range(40, 90); var lowest = Random.Range(0, 50); var heighest = Random.Range(50, 100); chart.AddData(serie.index, open, close, lowest, heighest); } return(defaultDataCount); }
public static Serie AddDefaultTimeGanttSerie(BaseChart chart, string serieName, int dataCount = 0) { var serie = chart.AddSerie(SerieType.Gantt, serieName); serie.showDataName = true; serie.showDataDimension = 2; var timestamp = DateTimeUtil.GetTimestamp(); for (int i = 0; i < dataCount; i++) { var start = timestamp + Random.Range(1, 6) * 3600 * 24; var end = start + Random.Range(1, 10) * 3600 * 24; serie.AddXYData(start, end, "task-" + (i + 1)); } return(serie); }
protected virtual void OnEnable() { m_Target = (BaseChart)target; m_Script = serializedObject.FindProperty("m_Script"); m_Theme = serializedObject.FindProperty("m_Theme"); m_ThemeInfo = serializedObject.FindProperty("m_ThemeInfo"); m_Title = serializedObject.FindProperty("m_Title"); m_Legend = serializedObject.FindProperty("m_Legend"); m_Tooltip = serializedObject.FindProperty("m_Tooltip"); m_Series = serializedObject.FindProperty("m_Series"); m_Large = serializedObject.FindProperty("m_Large"); m_MinShowDataNumber = serializedObject.FindProperty("m_MinShowDataNumber"); m_MaxShowDataNumber = serializedObject.FindProperty("m_MaxShowDataNumber"); m_MaxCacheDataNumber = serializedObject.FindProperty("m_MaxCacheDataNumber"); }
public static void AddDefaultLiquidSerie(BaseChart chart, string serieName) { if (chart.vessels.Count == 0) { chart.AddVessel(Vessel.defaultVessel); } var serie = chart.AddSerie(SerieType.Liquid, serieName); serie.min = 0; serie.max = 100; serie.label.show = true; serie.label.textStyle.fontSize = 40; serie.label.formatter = "{d}%"; serie.label.textStyle.color = new Color32(70, 70, 240, 255); chart.AddData(serie.index, UnityEngine.Random.Range(0, 100)); }
public static void SwitchTheme(BaseChart chart, string themeName) { #if UNITY_EDITOR if (XChartsMgr.Instance.m_ThemeDict.Count == 0) { ReloadThemeList(); } #endif if (!XChartsMgr.Instance.m_ThemeDict.ContainsKey(themeName)) { Debug.LogError("SwitchTheme ERROR: not exist theme:" + themeName); return; } var target = XChartsMgr.Instance.m_ThemeDict[themeName]; chart.UpdateTheme(target); }
protected virtual void OnEnable() { m_Target = (BaseChart)target; m_Script = serializedObject.FindProperty("m_Script"); m_ChartWidth = serializedObject.FindProperty("m_ChartWidth"); m_ChartHeight = serializedObject.FindProperty("m_ChartHeight"); m_Theme = serializedObject.FindProperty("m_Theme"); m_ThemeInfo = serializedObject.FindProperty("m_ThemeInfo"); m_Title = serializedObject.FindProperty("m_Title"); m_Legend = serializedObject.FindProperty("m_Legend"); m_Tooltip = serializedObject.FindProperty("m_Tooltip"); m_Series = serializedObject.FindProperty("m_Series"); m_Large = serializedObject.FindProperty("m_Large"); m_Settings = serializedObject.FindProperty("m_Settings"); }
private string[] GetChartSerieTypeNames(BaseChart chart) { var list = System.Enum.GetNames(typeof(SerieType)); for (int i = 0; i < list.Length; i++) { if (list[i].Equals("Custom")) { var customName = chart.GetCustomSerieTypeName(); if (!string.IsNullOrEmpty(customName)) { list[i] = customName; } } } return(list); }
public static void AddDefaultRingSerie(BaseChart chart, string serieName) { var serie = chart.AddSerie(SerieType.Ring, serieName); serie.roundCap = true; serie.radius = new float[] { 0.3f, 0.35f }; serie.titleStyle.show = false; serie.titleStyle.textStyle.offset = new Vector2(0, 30); serie.label.show = true; serie.label.position = SerieLabel.Position.Center; serie.label.formatter = "{d:f0}%"; serie.label.textStyle.fontSize = 28; var value = Random.Range(30, 90); var max = 100; chart.AddData(serie.index, value, max, "data1"); }
private static void InitDefaultContent(ref StringBuilder sb, Tooltip tooltip, Serie serie, int index, BaseChart chart, DataZoom dataZoom = null, bool isCartesian = false, Radar radar = null) { switch (serie.type) { case SerieType.Line: case SerieType.Bar: case SerieType.Candlestick: InitCoordinateTooltip(ref sb, tooltip, serie, index, chart.theme, isCartesian, dataZoom); break; case SerieType.Scatter: case SerieType.EffectScatter: InitScatterTooltip(ref sb, tooltip, serie, index, chart.theme); break; case SerieType.Radar: InitRadarTooltip(ref sb, tooltip, serie, radar, chart.theme); break; case SerieType.Pie: InitPieTooltip(ref sb, tooltip, serie, index, chart.theme); break; case SerieType.Ring: InitRingTooltip(ref sb, tooltip, serie, index, chart.theme); break; case SerieType.Heatmap: break; case SerieType.Gauge: InitGaugeTooltip(ref sb, tooltip, serie, index, chart.theme); break; case SerieType.Gantt: InitGanttTooltip(ref sb, tooltip, serie, index, chart.theme); break; case SerieType.Custom: chart.InitCustomSerieTooltip(ref sb, serie, index); break; } }
public static Color GetIconColor(BaseChart chart, int readIndex, string legendName, bool active) { if (active) { var legend = chart.legend; if (legend.itemAutoColor || legend.GetIcon(readIndex) == null) { return(SeriesHelper.GetNameColor(chart, readIndex, legendName)); } else { return(Color.white); } } else { return(chart.theme.legend.unableColor); } }
public static void AddDefaultRadarSerie(BaseChart chart, string serieName) { if (chart.radars.Count == 0) { chart.AddRadar(Radar.defaultRadar); } var serie = chart.AddSerie(SerieType.Radar, serieName); serie.symbol.show = true; serie.symbol.type = SerieSymbolType.EmptyCircle; serie.symbol.size = 4; serie.symbol.selectedSize = 6; serie.showDataName = true; List <float> data = new List <float>(); for (int i = 0; i < 5; i++) { data.Add(Random.Range(20, 90)); } chart.AddData(serie.index, data, "legendName"); }
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"); } }
/// <summary> /// 获得所有系列名,不包含空名字。 /// </summary> /// <returns></returns> public static void UpdateSerieNameList(BaseChart chart, ref List <string> serieNameList) { serieNameList.Clear(); for (int n = 0; n < chart.series.list.Count; n++) { var serie = chart.series.GetSerie(n); if (serie.type == SerieType.Pie || serie.type == SerieType.Radar || serie.type == SerieType.Ring || (serie.type == SerieType.Custom && chart.GetCustomSerieDataNameForColor())) { for (int i = 0; i < serie.data.Count; i++) { if (serie.type == SerieType.Pie && serie.IsIgnoreValue(serie.data[i])) { continue; } if (string.IsNullOrEmpty(serie.data[i].name)) { serieNameList.Add(ChartCached.IntToStr(i)); } else if (!serieNameList.Contains(serie.data[i].name)) { serieNameList.Add(serie.data[i].name); } } } else { if (string.IsNullOrEmpty(serie.name)) { serieNameList.Add(ChartCached.IntToStr(n)); } else if (!serieNameList.Contains(serie.name)) { serieNameList.Add(serie.name); } } } }
public static Color GetNameColor(BaseChart chart, int index, string name) { Serie destSerie = null; SerieData destSerieData = null; var series = chart.series; for (int n = 0; n < series.list.Count; n++) { var serie = series.GetSerie(n); if (serie.type == SerieType.Pie || serie.type == SerieType.Radar || serie.type == SerieType.Ring || (serie.type == SerieType.Custom && chart.GetCustomSerieDataNameForColor())) { bool found = false; for (int i = 0; i < serie.data.Count; i++) { if (name.Equals(serie.data[i].name)) { destSerie = serie; destSerieData = serie.data[i]; found = true; break; } } if (found) { break; } } else { if (name.Equals(serie.name)) { destSerie = serie; destSerieData = null; break; } } } return(SerieHelper.GetItemColor(destSerie, destSerieData, chart.theme, index, false)); }
private static void CheckTitle(BaseChart chart, StringBuilder sb) { 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); } } }
public static void AddDefaultGaugeSerie(BaseChart chart, string serieName) { var serie = chart.AddSerie(SerieType.Gauge, serieName); serie.min = 0; serie.max = 100; serie.startAngle = -125; serie.endAngle = 125; serie.center[0] = 0.5f; serie.center[1] = 0.5f; serie.radius[0] = 80; serie.splitNumber = 5; serie.animation.dataChangeEnable = true; serie.titleStyle.show = true; serie.titleStyle.textStyle.offset = new Vector2(0, 20); serie.label.show = true; serie.label.offset = new Vector3(0, -30); serie.itemStyle.show = true; serie.gaugeAxis.axisLabel.show = true; serie.gaugeAxis.axisLabel.margin = 18; chart.AddData(serie.index, UnityEngine.Random.Range(10, 90), "title"); }
public static void SwitchTheme(BaseChart chart, string themeName) { Debug.Log("SwitchTheme:" + themeName); if (chart.theme.themeName.Equals(themeName)) { return; } #if UNITY_EDITOR if (Instance.m_ThemeDict.Count == 0) { Instance.LoadThemesFromResources(); } #endif if (!Instance.m_ThemeDict.ContainsKey(themeName)) { Debug.LogError("SwitchTheme ERROR: not exist theme:" + themeName); return; } var target = Instance.m_ThemeDict[themeName]; chart.theme.CopyTheme(target); chart.RefreshAllComponent(); }
void Awake() { chart = gameObject.GetComponent <BaseChart>(); }
public DrawSeriePie(BaseChart chart) { this.chart = chart; }
private static void CheckSerie(BaseChart chart, StringBuilder sb) { var allDataIsEmpty = true; var allDataIsZero = true; var allSerieIsHide = true; foreach (var serie in chart.series.list) { if (serie.show) { allSerieIsHide = false; } if (serie.dataCount > 0) { allDataIsEmpty = false; for (int i = 0; i < serie.dataCount; i++) { var serieData = serie.GetSerieData(i); for (int j = 1; j < serieData.data.Count; j++) { if (serieData.GetData(j) != 0) { allDataIsZero = false; break; } } } var dataCount = serie.GetSerieData(0).data.Count; if (serie.showDataDimension > 1 && serie.showDataDimension != dataCount) { sb.AppendFormat("warning:serie {0} serieData.data.count[{1}] not match showDataDimension[{2}]\n", serie.index, dataCount, serie.showDataDimension); } } else { sb.AppendFormat("warning:serie {0} no data\n", serie.index); } if (IsColorAlphaZero(serie.itemStyle.color)) { sb.AppendFormat("warning:serie {0} itemStyle->color alpha is 0\n", serie.index); } if (serie.itemStyle.opacity == 0) { sb.AppendFormat("warning:serie {0} itemStyle->opacity is 0\n", serie.index); } if (serie.itemStyle.borderWidth != 0 && IsColorAlphaZero(serie.itemStyle.borderColor)) { sb.AppendFormat("warning:serie {0} itemStyle->borderColor alpha is 0\n", serie.index); } 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)) { sb.AppendFormat("warning:serie {0} lineStyle->color alpha is 0\n", serie.index); } break; case SerieType.Bar: if (serie.barWidth == 0) { sb.AppendFormat("warning:serie {0} barWidth is 0\n", serie.index); } break; case SerieType.Pie: if (serie.radius.Length >= 2 && serie.radius[1] == 0) { sb.AppendFormat("warning:serie {0} radius[1] is 0\n", serie.index); } break; case SerieType.Scatter: case SerieType.EffectScatter: if (!serie.symbol.show) { sb.AppendFormat("warning:serie {0} symbol type is None\n", serie.index); } break; } } if (allDataIsEmpty) { sb.Append("warning:all serie data is empty\n"); } if (!allDataIsEmpty && allDataIsZero) { sb.Append("warning:all serie data is 0\n"); } if (allSerieIsHide) { sb.Append("warning:all serie is hide\n"); } }
private static void CheckTheme(BaseChart chart, StringBuilder sb) { var themeInfo = chart.themeInfo; themeInfo.CheckWarning(sb); }
public static string GetFormatterContent(Tooltip tooltip, int dataIndex, BaseChart chart, DataZoom dataZoom = null, bool isCartesian = false, Radar radar = null) { if (string.IsNullOrEmpty(tooltip.formatter)) { var sb = ChartHelper.sb; var title = tooltip.titleFormatter; var formatTitle = !string.IsNullOrEmpty(title); var titleIsIgnroe = false; var needCategory = false; var first = true; var isScatter = false; sb.Length = 0; if ("{i}".Equals(tooltip.titleFormatter)) { title = string.Empty; formatTitle = false; titleIsIgnroe = true; } for (int i = 0; i < chart.series.Count; i++) { var serie = chart.series.GetSerie(i); if (tooltip.runtimeGridIndex >= 0 && serie.runtimeGridIndex != tooltip.runtimeGridIndex) { continue; } if (serie.type == SerieType.Scatter || serie.type == SerieType.EffectScatter) { if (serie.show && IsSelectedSerie(tooltip, serie.index)) { isScatter = true; var itemFormatter = GetItemFormatter(tooltip, serie, null); if (string.IsNullOrEmpty(itemFormatter)) { if (!first) { sb.Append(FormatterHelper.PH_NN); } InitDefaultContent(ref sb, tooltip, serie, dataIndex, chart.theme, dataZoom, isCartesian, radar); first = false; continue; } var itemTitle = title; if (!string.IsNullOrEmpty(itemTitle)) { FormatterHelper.ReplaceContent(ref itemTitle, dataIndex, tooltip.numericFormatter, serie, chart, dataZoom); sb.Append(itemTitle).Append(FormatterHelper.PH_NN); } var dataIndexList = tooltip.runtimeSerieIndex[serie.index]; foreach (var tempIndex in dataIndexList) { string content = itemFormatter; var foundDot = FormatterHelper.ReplaceContent(ref content, tempIndex, tooltip.numericFormatter, serie, chart, dataZoom); if (!foundDot) { sb.Append(ChartCached.ColorToDotStr(chart.theme.GetColor(serie.index))); } sb.Append(content).Append(FormatterHelper.PH_NN); } } } else if (IsNeedTooltipSerie(serie, tooltip)) { var itemFormatter = string.Empty; if (serie.type == SerieType.Gauge) { var serieData = serie.GetSerieData(0, dataZoom); if (serieData == null) { continue; } itemFormatter = GetItemFormatter(tooltip, serie, serieData); } else { var serieData = serie.GetSerieData(dataIndex, dataZoom); if (serieData == null) { continue; } itemFormatter = GetItemFormatter(tooltip, serie, serieData); } needCategory = needCategory || (serie.type == SerieType.Line || serie.type == SerieType.Bar); if (formatTitle) { FormatterHelper.ReplaceContent(ref title, dataIndex, tooltip.numericFormatter, serie, chart, dataZoom); } if (serie.show) { if (string.IsNullOrEmpty(itemFormatter) || serie.type == SerieType.Radar) { if (!first) { sb.Append(FormatterHelper.PH_NN); } InitDefaultContent(ref sb, tooltip, serie, dataIndex, chart.theme, dataZoom, isCartesian, radar); first = false; continue; } string content = itemFormatter; FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, serie, chart, dataZoom); if (!first) { sb.Append(FormatterHelper.PH_NN); } var dotColorIndex = serie.type == SerieType.Pie || serie.type == SerieType.Radar || serie.type == SerieType.Ring ? dataIndex : i; sb.Append(ChartCached.ColorToDotStr(chart.theme.GetColor(dotColorIndex))); sb.Append(content); first = false; } } } if (isScatter) { return(FormatterHelper.TrimAndReplaceLine(sb)); } else if (string.IsNullOrEmpty(title)) { if (needCategory && !titleIsIgnroe) { var category = (chart as CoordinateChart).GetTooltipCategory(dataIndex, dataZoom); return(category + FormatterHelper.PH_NN + FormatterHelper.TrimAndReplaceLine(sb)); } else { return(FormatterHelper.TrimAndReplaceLine(sb)); } } else { title = FormatterHelper.TrimAndReplaceLine(title); return(title + FormatterHelper.PH_NN + FormatterHelper.TrimAndReplaceLine(sb)); } } else { string content = tooltip.formatter; FormatterHelper.ReplaceContent(ref content, dataIndex, tooltip.numericFormatter, null, chart, dataZoom); return(content); } }
public bool ContainsChart(BaseChart chart) { return(m_ChartList.Contains(chart)); }
public VisualMapHandler(BaseChart chart) { this.chart = chart; }
public DrawSerieGauge(BaseChart chart) { this.chart = chart; }
public DrawSerieRadar(BaseChart chart) { this.chart = chart; }