private void DrawPolarLine(VertexHelper vh, Serie serie) { var m_Polar = GetPolar(serie.polarIndex); if (m_Polar == null) { return; } var m_AngleAxis = GetAngleAxis(m_Polar.index); var m_RadiusAxis = GetRadiusAxis(m_Polar.index); if (m_AngleAxis == null || m_RadiusAxis == null) { return; } var startAngle = m_AngleAxis.runtimeStartAngle; var radius = m_Polar.runtimeRadius; var datas = serie.data; if (datas.Count <= 0) { return; } float dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); float min = m_RadiusAxis.GetCurrMinValue(dataChangeDuration); float max = m_RadiusAxis.GetCurrMaxValue(dataChangeDuration); var firstSerieData = datas[0]; var startPos = GetPolarPos(m_Polar, m_AngleAxis, firstSerieData, min, max, radius); var nextPos = Vector3.zero; var lineColor = SerieHelper.GetLineColor(serie, m_Theme, serie.index, serie.highlighted); var lineWidth = serie.lineStyle.GetWidth(m_Theme.serie.lineWidth); float currDetailProgress = 0; float totalDetailProgress = datas.Count; serie.animation.InitProgress(serie.dataPoints.Count, currDetailProgress, totalDetailProgress); serie.animation.SetDataFinish(0); for (int i = 1; i < datas.Count; i++) { if (serie.animation.CheckDetailBreak(i)) { break; } var serieData = datas[i]; nextPos = GetPolarPos(m_Polar, m_AngleAxis, datas[i], min, max, radius); UGL.DrawLine(vh, startPos, nextPos, lineWidth, lineColor); startPos = nextPos; } if (!serie.animation.IsFinish()) { serie.animation.CheckProgress(totalDetailProgress); serie.animation.CheckSymbol(serie.symbol.GetSize(null, m_Theme.serie.lineSymbolSize)); m_IsPlayingAnimation = true; RefreshChart(); } }
private void DrawSingleRadar(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(); 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.GetDimensionMinMaxData(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 = 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; 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) { ChartDrawer.DrawTriangle(vh, startPoint, toPoint, p, areaColor, areaColor, areaToColor); } if (serie.lineStyle.show) { ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, toPoint, lineColor); } startPoint = toPoint; } serieData.labelPosition = startPoint; pointList.Add(startPoint); if (serie.areaStyle.show && j == endIndex) { ChartDrawer.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor); } if (serie.lineStyle.show && j == endIndex) { ChartDrawer.DrawLineStyle(vh, serie.lineStyle, startPoint, firstPoint, lineColor); } } 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 || (m_Tooltip.show && m_Tooltip.runtimeDataIndex[0] == i && m_Tooltip.runtimeDataIndex[1] == j); var serieIndex = serieData.index; 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); DrawSymbol(vh, serie.symbol.type, symbolSize, symbolBorder, serieData.labelPosition, symbolColor, symbolToColor, serie.symbol.gap, cornerRadius); } } if (!serie.animation.IsFinish()) { serie.animation.CheckProgress(1); RefreshChart(); } if (dataChanging) { RefreshChart(); } }
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(); 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, 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 max = radar.GetIndicatorMax(n); float value = serieData.GetCurrData(n, 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 = (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.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.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); 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(); } }
private void DrawMarkLine(VertexHelper vh, Serie serie) { if (!serie.show || !serie.markLine.show) { return; } if (serie.markLine.data.Count == 0) { return; } var yAxis = chart.GetSerieYAxisOrDefault(serie); var xAxis = chart.GetSerieXAxisOrDefault(serie); var grid = chart.GetSerieGridOrDefault(serie); var dataZoom = DataZoomHelper.GetAxisRelatedDataZoom(xAxis, chart.dataZooms); var animation = serie.markLine.animation; var showData = serie.GetDataList(dataZoom); var sp = Vector3.zero; var ep = Vector3.zero; var colorIndex = chart.GetLegendRealShowNameIndex(serie.name); var serieColor = SerieHelper.GetLineColor(serie, chart.theme, colorIndex, false); animation.InitProgress(1, 0, 1f); ResetTempMarkLineGroupData(serie.markLine); if (m_TempGroupData.Count > 0) { foreach (var kv in m_TempGroupData) { if (kv.Value.Count >= 2) { sp = GetSinglePos(xAxis, yAxis, grid, serie, dataZoom, kv.Value[0], showData.Count); ep = GetSinglePos(xAxis, yAxis, grid, serie, dataZoom, kv.Value[1], showData.Count); kv.Value[0].runtimeStartPosition = sp; kv.Value[1].runtimeEndPosition = ep; DrawMakLineData(vh, kv.Value[0], animation, serie, grid, serieColor, sp, ep); } } } foreach (var data in serie.markLine.data) { if (data.group != 0) { continue; } switch (data.type) { case MarkLineType.Min: data.runtimeValue = SerieHelper.GetMinData(serie, data.dimension, dataZoom); GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep); break; case MarkLineType.Max: data.runtimeValue = SerieHelper.GetMaxData(serie, data.dimension, dataZoom); GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep); break; case MarkLineType.Average: data.runtimeValue = SerieHelper.GetAverageData(serie, data.dimension, dataZoom); GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep); break; case MarkLineType.Median: data.runtimeValue = SerieHelper.GetMedianData(serie, data.dimension, dataZoom); GetStartEndPos(xAxis, yAxis, grid, data.runtimeValue, ref sp, ref ep); break; case MarkLineType.None: if (data.xPosition != 0) { data.runtimeValue = data.xPosition; var pX = grid.runtimeX + data.xPosition; sp = new Vector3(pX, grid.runtimeY); ep = new Vector3(pX, grid.runtimeY + grid.runtimeHeight); } else if (data.yPosition != 0) { data.runtimeValue = data.yPosition; var pY = grid.runtimeY + data.yPosition; sp = new Vector3(grid.runtimeX, pY); ep = new Vector3(grid.runtimeX + grid.runtimeWidth, pY); } else if (data.yValue != 0) { data.runtimeValue = data.yValue; if (yAxis.IsCategory()) { var pY = AxisHelper.GetAxisPosition(grid, yAxis, data.yValue, showData.Count, dataZoom); sp = new Vector3(grid.runtimeX, pY); ep = new Vector3(grid.runtimeX + grid.runtimeWidth, pY); } else { GetStartEndPos(xAxis, yAxis, grid, data.yValue, ref sp, ref ep); } } else { data.runtimeValue = data.xValue; if (xAxis.IsCategory()) { var pX = AxisHelper.GetAxisPosition(grid, xAxis, data.xValue, showData.Count, dataZoom); sp = new Vector3(pX, grid.runtimeY); ep = new Vector3(pX, grid.runtimeY + grid.runtimeHeight); } else { GetStartEndPos(xAxis, yAxis, grid, data.xValue, ref sp, ref ep); } } break; default: break; } data.runtimeStartPosition = sp; data.runtimeEndPosition = ep; DrawMakLineData(vh, data, animation, serie, grid, serieColor, sp, ep); } if (!animation.IsFinish()) { animation.CheckProgress(1f); chart.RefreshTopPainter(); } }