private void DrawMutipleRadar(VertexHelper vh, Serie serie, int i) { if (!serie.show) { return; } var radar = chart.GetRadar(serie.radarIndex); if (radar == null) { return; } var startPoint = Vector3.zero; var toPoint = Vector3.zero; var firstPoint = Vector3.zero; var indicatorNum = radar.indicatorList.Count; var angle = 2 * Mathf.PI / indicatorNum; var centerPos = radar.runtimeCenterPos; var serieNameCount = -1; serie.animation.InitProgress(1, 0, 1); if (!chart.IsActive(i) || serie.animation.HasFadeOut()) { return; } var rate = serie.animation.GetCurrRate(); var dataChanging = false; var dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); SerieHelper.GetAllMinMaxData(serie, radar.ceilRate); for (int j = 0; j < serie.data.Count; j++) { var serieData = serie.data[j]; int key = i * 1000 + j; if (!radar.runtimeDataPosList.ContainsKey(key)) { radar.runtimeDataPosList.Add(i * 1000 + j, new List <Vector3>(serieData.data.Count)); } else { radar.runtimeDataPosList[key].Clear(); } string dataName = serieData.name; int serieIndex = 0; if (string.IsNullOrEmpty(dataName)) { serieNameCount++; serieIndex = serieNameCount; } else if (!serieNameSet.ContainsKey(dataName)) { serieNameSet.Add(dataName, serieNameCount); serieNameCount++; serieIndex = serieNameCount; } else { serieIndex = serieNameSet[dataName]; } if (!serieData.show) { continue; } var isHighlight = IsHighlight(radar, serie, serieData, j, 0); var areaColor = SerieHelper.GetAreaColor(serie, chart.theme, serieIndex, isHighlight); var areaToColor = SerieHelper.GetAreaToColor(serie, chart.theme, serieIndex, isHighlight); var lineColor = SerieHelper.GetLineColor(serie, chart.theme, serieIndex, isHighlight); var lineWidth = serie.lineStyle.GetWidth(chart.theme.serie.lineWidth); int dataCount = radar.indicatorList.Count; List <Vector3> pointList = radar.runtimeDataPosList[key]; for (int n = 0; n < dataCount; n++) { if (n >= serieData.data.Count) { break; } var max = radar.GetIndicatorMax(n); var value = serieData.GetCurrData(n, dataChangeDuration); if (serieData.IsDataChanged()) { dataChanging = true; } if (max == 0) { max = serie.runtimeDataMax; } var radius = (float)(max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max : radar.runtimeDataRadius * value / max); var currAngle = (n + (radar.positionType == Radar.PositionType.Between ? 0.5f : 0)) * angle; radius *= rate; if (n == 0) { startPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle), centerPos.y + radius * Mathf.Cos(currAngle)); firstPoint = startPoint; } else { toPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle), centerPos.y + radius * Mathf.Cos(currAngle)); if (serie.areaStyle.show) { UGL.DrawTriangle(vh, startPoint, toPoint, centerPos, areaColor, areaColor, areaToColor); } if (serie.lineStyle.show) { ChartDrawer.DrawLineStyle(vh, serie.lineStyle.type, lineWidth, startPoint, toPoint, lineColor); } startPoint = toPoint; } pointList.Add(startPoint); } if (serie.areaStyle.show) { UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor); } if (serie.lineStyle.show) { ChartDrawer.DrawLineStyle(vh, serie.lineStyle.type, lineWidth, startPoint, firstPoint, lineColor); } if (serie.symbol.show && serie.symbol.type != SerieSymbolType.None) { for (int m = 0; m < pointList.Count; m++) { var point = pointList[m]; isHighlight = IsHighlight(radar, serie, serieData, j, m); var symbolSize = isHighlight ? serie.symbol.GetSelectedSize(null, chart.theme.serie.lineSymbolSelectedSize) : serie.symbol.GetSize(null, chart.theme.serie.lineSymbolSize); var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight); var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight); var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight); var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight); chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor, symbolToColor, serie.symbol.gap, cornerRadius); } } } if (!serie.animation.IsFinish()) { serie.animation.CheckProgress(1); chart.RefreshPainter(serie); } if (dataChanging) { chart.RefreshPainter(serie); } }
private void DrawRadar(VertexHelper vh, Radar radar) { if (!radar.splitLine.show && !radar.splitArea.show) { return; } float insideRadius = 0, outsideRadius = 0; float block = radar.runtimeRadius / radar.splitNumber; int indicatorNum = radar.indicatorList.Count; Vector3 p1, p2, p3, p4; Vector3 p = radar.runtimeCenterPos; float angle = 2 * Mathf.PI / indicatorNum; var lineColor = radar.axisLine.GetColor(chart.theme.radar.lineColor); var lineWidth = radar.axisLine.GetWidth(chart.theme.radar.lineWidth); var lineType = radar.axisLine.GetType(chart.theme.radar.lineType); var splitLineColor = radar.splitLine.GetColor(chart.theme.radar.splitLineColor); var splitLineWidth = radar.splitLine.GetWidth(chart.theme.radar.splitLineWidth); var splitLineType = radar.splitLine.GetType(chart.theme.radar.splitLineType); for (int i = 0; i < radar.splitNumber; i++) { var isLast = i == radar.splitNumber - 1; var color = radar.splitArea.GetColor(i, chart.theme.radar); outsideRadius = insideRadius + block; p1 = new Vector3(p.x + insideRadius * Mathf.Sin(0), p.y + insideRadius * Mathf.Cos(0)); p2 = new Vector3(p.x + outsideRadius * Mathf.Sin(0), p.y + outsideRadius * Mathf.Cos(0)); for (int j = 0; j <= indicatorNum; j++) { float currAngle = j * angle; p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle), p.y + outsideRadius * Mathf.Cos(currAngle)); p4 = new Vector3(p.x + insideRadius * Mathf.Sin(currAngle), p.y + insideRadius * Mathf.Cos(currAngle)); if (radar.splitArea.show) { UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, color); } if (radar.splitLine.NeedShow(i)) { if (isLast) { ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, p2, p3, lineColor); } else { ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p2, p3, splitLineColor); } } p1 = p4; p2 = p3; } insideRadius = outsideRadius; } for (int j = 0; j <= indicatorNum; j++) { float currAngle = j * angle; p3 = new Vector3(p.x + outsideRadius * Mathf.Sin(currAngle), p.y + outsideRadius * Mathf.Cos(currAngle)); if (radar.splitLine.show) { ChartDrawer.DrawLineStyle(vh, splitLineType, splitLineWidth, p, p3, splitLineColor); } } }
protected void DrawAxisSplit(VertexHelper vh, AxisTheme theme, DataZoom dataZoom, Orient orient, float startX, float startY, float axisLength, float splitLength, Axis relativedAxis = null) { Axis axis = component; var lineColor = axis.splitLine.GetColor(theme.splitLineColor); var lineWidth = axis.splitLine.GetWidth(theme.lineWidth); var lineType = axis.splitLine.GetType(theme.splitLineType); var size = AxisHelper.GetScaleNumber(axis, axisLength, dataZoom); if (axis.IsTime()) { size += 1; if (!ChartHelper.IsEquals(axis.GetLastLabelValue(), axis.context.maxValue)) { size += 1; } } var current = orient == Orient.Horizonal ? startX : startY; for (int i = 0; i < size; i++) { var scaleWidth = AxisHelper.GetScaleWidth(axis, axisLength, axis.IsTime() ? i : i + 1, dataZoom); if (axis.boundaryGap && axis.axisTick.alignWithLabel) { current -= scaleWidth / 2; } if (axis.splitArea.show && i <= size - 1) { if (orient == Orient.Horizonal) { UGL.DrawQuadrilateral(vh, new Vector2(current, startY), new Vector2(current, startY + splitLength), new Vector2(current + scaleWidth, startY + splitLength), new Vector2(current + scaleWidth, startY), axis.splitArea.GetColor(i, theme)); } else { UGL.DrawQuadrilateral(vh, new Vector2(startX, current), new Vector2(startX + splitLength, current), new Vector2(startX + splitLength, current + scaleWidth), new Vector2(startX, current + scaleWidth), axis.splitArea.GetColor(i, theme)); } } if (axis.splitLine.show) { if (axis.splitLine.NeedShow(i)) { if (orient == Orient.Horizonal) { if (relativedAxis == null || !MathUtil.Approximately(current, GetAxisLineXOrY())) { ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, new Vector3(current, startY), new Vector3(current, startY + splitLength), lineColor); } } else { if (relativedAxis == null || !MathUtil.Approximately(current, GetAxisLineXOrY())) { ChartDrawer.DrawLineStyle(vh, lineType, lineWidth, new Vector3(startX, current), new Vector3(startX + splitLength, current), lineColor); } } } } current += scaleWidth; } }
private void DrawSingleRadar(VertexHelper vh, Serie serie, int i) { var startPoint = Vector3.zero; var toPoint = Vector3.zero; var firstPoint = Vector3.zero; var radar = chart.radars[serie.radarIndex]; var indicatorNum = radar.indicatorList.Count; var angle = 2 * Mathf.PI / indicatorNum; var centerPos = radar.runtimeCenterPos; var serieNameCount = -1; serie.animation.InitProgress(1, 0, 1); if (!chart.IsActive(i) || serie.animation.HasFadeOut()) { return; } var rate = serie.animation.GetCurrRate(); var dataChanging = false; var dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); int key = i * 1000; if (!radar.runtimeDataPosList.ContainsKey(key)) { radar.runtimeDataPosList.Add(i * 1000, new List <Vector3>(serie.dataCount)); } else { radar.runtimeDataPosList[key].Clear(); } var pointList = radar.runtimeDataPosList[key]; var startIndex = GetStartShowIndex(serie); var endIndex = GetEndShowIndex(serie); SerieHelper.UpdateMinMaxData(serie, 1, radar.ceilRate); for (int j = 0; j < serie.data.Count; j++) { var serieData = serie.data[j]; serieData.index = j; string dataName = serieData.name; int serieIndex = 0; if (string.IsNullOrEmpty(dataName)) { serieNameCount++; serieIndex = serieNameCount; } else if (!serieNameSet.ContainsKey(dataName)) { serieNameSet.Add(dataName, serieNameCount); serieNameCount++; serieIndex = serieNameCount; } else { serieIndex = serieNameSet[dataName]; } if (!serieData.show) { serieData.labelPosition = Vector3.zero; continue; } var isHighlight = IsHighlight(radar, serie, serieData, j, 0); var areaColor = SerieHelper.GetAreaColor(serie, chart.theme, serieIndex, isHighlight); var areaToColor = SerieHelper.GetAreaToColor(serie, chart.theme, serieIndex, isHighlight); var lineColor = SerieHelper.GetLineColor(serie, chart.theme, serieIndex, isHighlight); int dataCount = radar.indicatorList.Count; var index = serieData.index; var p = radar.runtimeCenterPos; var max = radar.GetIndicatorMax(index); var value = serieData.GetCurrData(1, dataChangeDuration); if (serieData.IsDataChanged()) { dataChanging = true; } if (max == 0) { max = serie.runtimeDataMax; } var radius = max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max : radar.runtimeDataRadius * value / max; var currAngle = (index + (radar.positionType == Radar.PositionType.Between ? 0.5f : 0)) * angle; radius *= rate; if (index == startIndex) { startPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle), p.y + radius * Mathf.Cos(currAngle)); firstPoint = startPoint; } else { toPoint = new Vector3(p.x + radius * Mathf.Sin(currAngle), p.y + radius * Mathf.Cos(currAngle)); if (serie.areaStyle.show) { UGL.DrawTriangle(vh, startPoint, toPoint, p, areaColor, areaColor, areaToColor); } if (serie.lineStyle.show) { ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, toPoint, lineColor, chart.theme.serie.lineWidth, LineStyle.Type.Solid); } startPoint = toPoint; } serieData.labelPosition = startPoint; pointList.Add(startPoint); if (serie.areaStyle.show && j == endIndex) { UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor); } if (serie.lineStyle.show && j == endIndex) { ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, firstPoint, lineColor, chart.theme.serie.lineWidth, LineStyle.Type.Solid); } } if (serie.symbol.show && serie.symbol.type != SerieSymbolType.None) { for (int j = 0; j < serie.data.Count; j++) { var serieData = serie.data[j]; if (!serieData.show) { continue; } var isHighlight = serie.highlighted || serieData.highlighted || (chart.tooltip.show && chart.tooltip.runtimeDataIndex[0] == i && chart.tooltip.runtimeDataIndex[1] == j); var serieIndex = serieData.index; var symbolSize = isHighlight ? serie.symbol.GetSelectedSize(serieData.data, chart.theme.serie.lineSymbolSelectedSize) : serie.symbol.GetSize(serieData.data, chart.theme.serie.lineSymbolSize); var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieIndex, isHighlight); var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieIndex, isHighlight); var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight); var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight); chart.DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.labelPosition, symbolColor, symbolToColor, serie.symbol.gap, cornerRadius); } } if (!serie.animation.IsFinish()) { serie.animation.CheckProgress(1); chart.RefreshPainter(serie); } if (dataChanging) { chart.RefreshPainter(serie); } }
private void DrawMutipleRadar(VertexHelper vh, Serie serie, int i) { var startPoint = Vector3.zero; var toPoint = Vector3.zero; var firstPoint = Vector3.zero; var radar = m_Radars[serie.radarIndex]; var indicatorNum = radar.indicatorList.Count; var angle = 2 * Mathf.PI / indicatorNum; var centerPos = radar.runtimeCenterPos; var serieNameCount = -1; serie.animation.InitProgress(1, 0, 1); if (!IsActive(i) || serie.animation.HasFadeOut()) { return; } var rate = serie.animation.GetCurrRate(); var dataChanging = false; var dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); for (int j = 0; j < serie.data.Count; j++) { var serieData = serie.data[j]; int key = i * 1000 + j; if (!radar.runtimeDataPosList.ContainsKey(key)) { radar.runtimeDataPosList.Add(i * 1000 + j, new List <Vector3>(serieData.data.Count)); } else { radar.runtimeDataPosList[key].Clear(); } string dataName = serieData.name; int serieIndex = 0; if (string.IsNullOrEmpty(dataName)) { serieNameCount++; serieIndex = serieNameCount; } else if (!serieNameSet.ContainsKey(dataName)) { serieNameSet.Add(dataName, serieNameCount); serieNameCount++; serieIndex = serieNameCount; } else { serieIndex = serieNameSet[dataName]; } if (!serieData.show) { continue; } var isHighlight = serie.highlighted || serieData.highlighted || (m_Tooltip.show && m_Tooltip.runtimeDataIndex[0] == i && m_Tooltip.runtimeDataIndex[1] == j); var areaColor = SerieHelper.GetAreaColor(serie, m_ThemeInfo, serieIndex, isHighlight); var areaToColor = SerieHelper.GetAreaToColor(serie, m_ThemeInfo, serieIndex, isHighlight); var lineColor = SerieHelper.GetLineColor(serie, m_ThemeInfo, serieIndex, isHighlight); int dataCount = radar.indicatorList.Count; List <Vector3> pointList = radar.runtimeDataPosList[key]; for (int n = 0; n < dataCount; n++) { if (n >= serieData.data.Count) { break; } float min = radar.GetIndicatorMin(n); float max = radar.GetIndicatorMax(n); float value = serieData.GetCurrData(n, dataChangeDuration); if (serieData.IsDataChanged()) { dataChanging = true; } if (max == 0) { serie.GetMinMaxData(n, out min, out max); min = radar.GetIndicatorMin(n); } var radius = max < 0 ? radar.runtimeDataRadius - radar.runtimeDataRadius * value / max : radar.runtimeDataRadius * value / max; var currAngle = (n + (radar.positionType == Radar.PositionType.Between ? 0.5f : 0)) * angle; radius *= rate; if (n == 0) { startPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle), centerPos.y + radius * Mathf.Cos(currAngle)); firstPoint = startPoint; } else { toPoint = new Vector3(centerPos.x + radius * Mathf.Sin(currAngle), centerPos.y + radius * Mathf.Cos(currAngle)); if (serie.areaStyle.show) { ChartDrawer.DrawTriangle(vh, startPoint, toPoint, centerPos, areaColor, areaColor, areaToColor); } if (serie.lineStyle.show) { ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, toPoint, lineColor); } startPoint = toPoint; } pointList.Add(startPoint); } if (serie.areaStyle.show) { ChartDrawer.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor); } if (serie.lineStyle.show) { ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, firstPoint, lineColor); } if (serie.symbol.type != SerieSymbolType.None) { var symbolSize = (isHighlight ? serie.symbol.selectedSize : serie.symbol.size); var symbolColor = SerieHelper.GetItemColor(serie, serieData, m_ThemeInfo, serieIndex, isHighlight); var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, m_ThemeInfo, serieIndex, isHighlight); var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, isHighlight); var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight); foreach (var point in pointList) { DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, point, symbolColor, symbolToColor, serie.symbol.gap, cornerRadius); } } } if (!serie.animation.IsFinish()) { serie.animation.CheckProgress(1); RefreshChart(); } if (dataChanging) { RefreshChart(); } }