/// <summary> /// 移除并重新创建所有图表的Object。 /// </summary> public void RebuildChartObject() { ChartHelper.DestroyAllChildren(transform); SetAllComponentDirty(); }
public static bool IsColorAlphaZero(Color color) { return(!ChartHelper.IsClearColor(color) && color.a == 0); }
public void Update() { if (clickChartCount > 2) { m_ShowDebugInfo = !m_ShowDebugInfo; ChartHelper.SetActive(m_Label.transform, m_ShowDebugInfo); clickChartCount = 0; m_LastCheckShowTime = Time.realtimeSinceStartup; return; } if (Time.realtimeSinceStartup - m_LastCheckShowTime > 0.5f) { m_LastCheckShowTime = Time.realtimeSinceStartup; clickChartCount = 0; } if (!m_ShowDebugInfo || m_Label == null) { return; } m_FrameCount++; if (Time.realtimeSinceStartup - m_LastTime >= INTERVAL) { fps = m_FrameCount / (Time.realtimeSinceStartup - m_LastTime); m_FrameCount = 0; m_LastTime = Time.realtimeSinceStartup; if (m_LastRefreshCount == refreshCount) { m_LastRefreshCount = 0; refreshCount = 0; } m_LastRefreshCount = refreshCount; if (m_FpsList.Count > MAXCACHE) { m_FpsList.RemoveAt(0); } m_FpsList.Add(fps); avgFps = GetAvg(m_FpsList); if (m_Label != null) { s_Sb.Length = 0; s_Sb.AppendFormat("v{0}\n", XChartsMgr.version); s_Sb.AppendFormat("fps : {0:f0} / {1:f0}\n", fps, avgFps); s_Sb.AppendFormat("draw : {0}\n", refreshCount); var dataCount = m_Chart.GetAllSerieDataCount(); SetValueWithKInfo(s_Sb, "data", dataCount); var vertCount = 0; foreach (var serie in m_Chart.series) { vertCount += serie.context.vertCount; } SetValueWithKInfo(s_Sb, "b-vert", m_Chart.m_BasePainterVertCount); SetValueWithKInfo(s_Sb, "s-vert", vertCount); SetValueWithKInfo(s_Sb, "t-vert", m_Chart.m_TopPainterVertCount, false); m_Label.SetText(s_Sb.ToString()); } } }
private void DrawLinePoint(VertexHelper vh, Serie serie) { if (!serie.show || serie.IsPerformanceMode()) { return; } if (m_SerieGrid == null) { return; } var count = serie.context.dataPoints.Count; var clip = SeriesHelper.IsAnyClipSerie(chart.series); var theme = chart.theme; var interacting = false; var lineArrow = serie.lineArrow; var visualMap = chart.GetVisualMapOfSerie(serie); var isVisualMapGradient = VisualMapHelper.IsNeedLineGradient(visualMap); Axis axis; Axis relativedAxis; var isY = chart.GetSerieGridCoordAxis(serie, out axis, out relativedAxis); for (int i = 0; i < count; i++) { var serieData = serie.GetSerieData(i); if (serieData == null) { continue; } if (serieData.context.isClip) { continue; } var symbol = SerieHelper.GetSerieSymbol(serie, serieData); if (!symbol.show || !symbol.ShowSymbol(i, count)) { continue; } var pos = serie.context.dataPoints[i]; if (lineArrow != null && lineArrow.show) { if (lineArrow.position == LineArrow.Position.Start && i == 0) { continue; } if (lineArrow.position == LineArrow.Position.End && i == count - 1) { continue; } } if (ChartHelper.IsIngore(pos)) { continue; } var highlight = serie.data[i].context.highlight || serie.highlight; var symbolSize = highlight ? theme.serie.lineSymbolSelectedSize : theme.serie.lineSymbolSize; if (!serieData.interact.TryGetValue(ref symbolSize, ref interacting)) { symbolSize = highlight ? symbol.GetSelectedSize(serieData.data, symbolSize) : symbol.GetSize(serieData.data, symbolSize); serieData.interact.SetValue(ref interacting, symbolSize); symbolSize = serie.animation.GetSysmbolSize(symbolSize); } var symbolColor = SerieHelper.GetItemColor(serie, serieData, theme, serie.index, highlight); var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, theme, serie.index, highlight); var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, theme, serie.index, highlight, false); if (isVisualMapGradient) { symbolColor = VisualMapHelper.GetLineGradientColor(visualMap, pos, m_SerieGrid, axis, relativedAxis, symbolColor); symbolToColor = symbolColor; } var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, theme, highlight); var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, theme, highlight); var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, highlight); chart.DrawClipSymbol(vh, symbol.type, symbolSize, symbolBorder, pos, symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, clip, cornerRadius, m_SerieGrid, i > 0 ? serie.context.dataPoints[i - 1] : m_SerieGrid.context.position); } if (interacting) { if (SeriesHelper.IsStack(chart.series)) { chart.RefreshTopPainter(); } else { chart.RefreshPainter(serie); } } }
private void DrawPieLabelLine(VertexHelper vh, Serie serie, SerieData serieData, Color color) { var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); var labelLine = SerieHelper.GetSerieLabelLine(serie, serieData); if (serieLabel != null && serieLabel.show && labelLine != null && labelLine.show && (serieLabel.IsDefaultPosition(LabelStyle.Position.Outside))) { var insideRadius = serieData.context.insideRadius; var outSideRadius = serieData.context.outsideRadius; var center = serie.context.center; var currAngle = serieData.context.halfAngle; if (!ChartHelper.IsClearColor(labelLine.lineColor)) { color = labelLine.lineColor; } else if (labelLine.lineType == LabelLine.LineType.HorizontalLine) { color *= color; } float currSin = Mathf.Sin(currAngle * Mathf.Deg2Rad); float currCos = Mathf.Cos(currAngle * Mathf.Deg2Rad); var radius1 = labelLine.lineType == LabelLine.LineType.HorizontalLine ? serie.context.outsideRadius : outSideRadius; var radius3 = insideRadius + (outSideRadius - insideRadius) / 2; if (radius1 < serie.context.insideRadius) { radius1 = serie.context.insideRadius; } radius1 -= 0.1f; var pos0 = new Vector3(center.x + radius3 * currSin, center.y + radius3 * currCos); var pos1 = new Vector3(center.x + radius1 * currSin, center.y + radius1 * currCos); var pos2 = serieData.context.labelPosition; Vector3 pos4, pos6; var horizontalLineCircleRadius = labelLine.lineWidth * 4f; var lineCircleDiff = horizontalLineCircleRadius - 0.3f; var startAngle = serie.context.startAngle; if (currAngle < 90) { var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3; r4 += labelLine.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.right * lineCircleDiff; pos4 = pos6 + Vector3.right * r4; } else if (currAngle < 180) { var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos * radius3, 2)) - currSin * radius3; r4 += labelLine.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.right * lineCircleDiff; pos4 = pos6 + Vector3.right * r4; } else if (currAngle < 270) { var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad); var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad); var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3; r4 += labelLine.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.left * lineCircleDiff; pos4 = pos6 + Vector3.left * r4; } else { var currSin1 = Mathf.Sin((360 - currAngle) * Mathf.Deg2Rad); var currCos1 = Mathf.Cos((360 - currAngle) * Mathf.Deg2Rad); var r4 = Mathf.Sqrt(radius1 * radius1 - Mathf.Pow(currCos1 * radius3, 2)) - currSin1 * radius3; r4 += labelLine.lineLength1 - lineCircleDiff; pos6 = pos0 + Vector3.left * lineCircleDiff; pos4 = pos6 + Vector3.left * r4; } var pos5X = (currAngle - startAngle) % 360 > 180 ? pos2.x - labelLine.lineLength2 : pos2.x + labelLine.lineLength2; var pos5 = new Vector3(pos5X, pos2.y); var angle = Vector3.Angle(pos1 - center, pos2 - pos1); if (angle > 15) { UGL.DrawLine(vh, pos1, pos5, labelLine.lineWidth, color); } else { switch (labelLine.lineType) { case LabelLine.LineType.BrokenLine: UGL.DrawLine(vh, pos1, pos2, pos5, labelLine.lineWidth, color); break; case LabelLine.LineType.Curves: UGL.DrawCurves(vh, pos1, pos5, pos1, pos2, labelLine.lineWidth, color, chart.settings.lineSmoothness); break; case LabelLine.LineType.HorizontalLine: UGL.DrawCricle(vh, pos0, horizontalLineCircleRadius, color); UGL.DrawLine(vh, pos6, pos4, labelLine.lineWidth, color); break; } } } }
public void SetActive(bool flag) { ChartHelper.SetActive(gameObject, flag); }
public void Copy(AxisSplitArea splitArea) { show = splitArea.show; color.Clear(); ChartHelper.CopyList(color, splitArea.color); }
public void SetBackground(ImageStyle imageStyle) { ChartHelper.SetBackground(m_Background, imageStyle); }
public Color32 GetColor(Color32 defaultColor) { return(ChartHelper.IsClearColor(m_Color) ? defaultColor : m_Color); }
private void DrawHeatmapSerie(VertexHelper vh, Heatmap serie) { if (serie.animation.HasFadeOut()) { return; } XAxis xAxis; YAxis yAxis; if (!chart.TryGetChartComponent <XAxis>(out xAxis, serie.xAxisIndex)) { return; } if (!chart.TryGetChartComponent <YAxis>(out yAxis, serie.yAxisIndex)) { return; } m_SerieGrid = chart.GetChartComponent <GridCoord>(xAxis.gridIndex); xAxis.boundaryGap = true; yAxis.boundaryGap = true; var visualMap = chart.GetVisualMapOfSerie(serie); var emphasisItemStyle = serie.emphasisItemStyle; var xCount = xAxis.data.Count; var yCount = yAxis.data.Count; var xWidth = m_SerieGrid.context.width / xCount; var yWidth = m_SerieGrid.context.height / yCount; var zeroX = m_SerieGrid.context.x; var zeroY = m_SerieGrid.context.y; var rangeMin = visualMap.rangeMin; var rangeMax = visualMap.rangeMax; var color = chart.theme.GetColor(serie.index); var borderWidth = serie.itemStyle.show ? serie.itemStyle.borderWidth : 0; var rectWid = xWidth - 2 * borderWidth; var rectHig = yWidth - 2 * borderWidth; var borderColor = serie.itemStyle.opacity > 0 ? serie.itemStyle.borderColor : ChartConst.clearColor32; borderColor.a = (byte)(borderColor.a * serie.itemStyle.opacity); var borderToColor = serie.itemStyle.opacity > 0 ? serie.itemStyle.borderToColor : ChartConst.clearColor32; borderToColor.a = (byte)(borderToColor.a * serie.itemStyle.opacity); serie.context.dataPoints.Clear(); serie.animation.InitProgress(0, xCount); var animationIndex = serie.animation.GetCurrIndex(); var dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); var dataChanging = false; serie.containerIndex = m_SerieGrid.index; serie.containterInstanceId = m_SerieGrid.instanceId; for (int n = 0; n < serie.dataCount; n++) { var serieData = serie.data[n]; serieData.index = n; var i = (int)serieData.GetData(0); var j = (int)serieData.GetData(1); var dimension = VisualMapHelper.GetDimension(visualMap, serieData.data.Count); if (serie.IsIgnoreValue(serieData, dimension)) { serie.context.dataPoints.Add(Vector3.zero); continue; } var value = serieData.GetCurrData(dimension, dataChangeDuration, yAxis.inverse, yAxis.context.minValue, yAxis.context.maxValue); if (serieData.IsDataChanged()) { dataChanging = true; } var pos = new Vector3(zeroX + (i + (xAxis.boundaryGap ? 0.5f : 0)) * xWidth, zeroY + (j + (yAxis.boundaryGap ? 0.5f : 0)) * yWidth); serie.context.dataPoints.Add(pos); serieData.context.position = pos; serieData.context.canShowLabel = false; serieData.context.rect = new Rect(pos.x - rectWid / 2, pos.y - rectHig / 2, rectWid, rectHig); if (value == 0) { continue; } if ((value < rangeMin && rangeMin != visualMap.min) || (value > rangeMax && rangeMax != visualMap.max)) { continue; } if (!visualMap.IsInSelectedValue(value)) { continue; } if (animationIndex >= 0 && i > animationIndex) { continue; } color = visualMap.GetColor(value); if (serieData.context.highlight) { color = ChartHelper.GetHighlightColor(color); } serieData.context.canShowLabel = true; serieData.context.color = color; var highlight = (serieData.context.highlight) || visualMap.context.pointerIndex > 0; //UGL.DrawRectangle(vh, pos, rectWid / 2, rectHig / 2, color); UGL.DrawRectangle(vh, serieData.context.rect, color); if (borderWidth > 0 && !ChartHelper.IsClearColor(borderColor)) { UGL.DrawBorder(vh, pos, rectWid, rectHig, borderWidth, borderColor, borderToColor); } if (visualMap.hoverLink && highlight && emphasisItemStyle != null && emphasisItemStyle.borderWidth > 0) { var emphasisBorderWidth = emphasisItemStyle.borderWidth; var emphasisBorderColor = emphasisItemStyle.opacity > 0 ? emphasisItemStyle.borderColor : ChartConst.clearColor32; var emphasisBorderToColor = emphasisItemStyle.opacity > 0 ? emphasisItemStyle.borderToColor : ChartConst.clearColor32; UGL.DrawBorder(vh, pos, rectWid, rectHig, emphasisBorderWidth, emphasisBorderColor, emphasisBorderToColor); } } if (!serie.animation.IsFinish()) { serie.animation.CheckProgress(xCount); chart.RefreshPainter(serie); } if (dataChanging) { chart.RefreshPainter(serie); } }
private void DrawMutipleRadar(VertexHelper vh) { if (!serie.show) { return; } m_RadarCoord = chart.GetChartComponent <RadarCoord>(serie.radarIndex); if (m_RadarCoord == null) { return; } serie.containerIndex = m_RadarCoord.index; serie.containterInstanceId = m_RadarCoord.instanceId; var startPoint = Vector3.zero; var toPoint = Vector3.zero; var firstPoint = Vector3.zero; var indicatorNum = m_RadarCoord.indicatorList.Count; var angle = 2 * Mathf.PI / indicatorNum; var centerPos = m_RadarCoord.context.center; serie.animation.InitProgress(0, 1); if (!serie.show || serie.animation.HasFadeOut()) { return; } var rate = serie.animation.GetCurrRate(); var dataChanging = false; var interacting = false; var dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); SerieHelper.GetAllMinMaxData(serie, m_RadarCoord.ceilRate); for (int j = 0; j < serie.data.Count; j++) { var serieData = serie.data[j]; string dataName = serieData.name; if (!serieData.show) { continue; } var lineStyle = SerieHelper.GetLineStyle(serie, serieData); var areaStyle = SerieHelper.GetAreaStyle(serie, serieData); var symbol = SerieHelper.GetSerieSymbol(serie, serieData); var isHighlight = serieData.context.highlight; var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName); var areaColor = SerieHelper.GetAreaColor(serie, serieData, chart.theme, colorIndex, isHighlight); var areaToColor = SerieHelper.GetAreaToColor(serie, serieData, chart.theme, colorIndex, isHighlight); var lineColor = SerieHelper.GetLineColor(serie, serieData, chart.theme, colorIndex, isHighlight); var lineWidth = lineStyle.GetWidth(chart.theme.serie.lineWidth); int dataCount = m_RadarCoord.indicatorList.Count; serieData.context.dataPoints.Clear(); for (int n = 0; n < dataCount; n++) { if (n >= serieData.data.Count) { break; } var min = m_RadarCoord.GetIndicatorMin(n); var max = m_RadarCoord.GetIndicatorMax(n); var value = serieData.GetCurrData(n, dataChangeDuration); if (serieData.IsDataChanged()) { dataChanging = true; } if (max == 0) { if (serie.data.Count > 1) { SerieHelper.GetMinMaxData(serie, n, out min, out max); min = ChartHelper.GetMinDivisibleValue(min, 0); max = ChartHelper.GetMaxDivisibleValue(max, 0); if (min > 0) { min = 0; } } else { max = serie.context.dataMax; } } var radius = (float)(m_RadarCoord.context.dataRadius * (value - min) / (max - min)); var currAngle = (n + (m_RadarCoord.positionType == RadarCoord.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 (areaStyle != null && areaStyle.show) { UGL.DrawTriangle(vh, startPoint, toPoint, centerPos, areaColor, areaColor, areaToColor); } if (lineStyle.show) { ChartDrawer.DrawLineStyle(vh, lineStyle.type, lineWidth, startPoint, toPoint, lineColor); } startPoint = toPoint; } serieData.context.dataPoints.Add(startPoint); } if (areaStyle != null && areaStyle.show) { UGL.DrawTriangle(vh, startPoint, firstPoint, centerPos, areaColor, areaColor, areaToColor); } if (lineStyle.show) { ChartDrawer.DrawLineStyle(vh, lineStyle.type, lineWidth, startPoint, firstPoint, lineColor); } if (symbol.show && symbol.type != SymbolType.None) { for (int m = 0; m < serieData.context.dataPoints.Count; m++) { var point = serieData.context.dataPoints[m]; var symbolSize = isHighlight ? symbol.GetSelectedSize(null, chart.theme.serie.lineSymbolSelectedSize) : symbol.GetSize(null, chart.theme.serie.lineSymbolSize); if (!serieData.interact.TryGetValue(ref symbolSize, ref interacting)) { symbolSize = isHighlight ? symbol.GetSelectedSize(serieData.data, symbolSize) : symbol.GetSize(serieData.data, symbolSize); serieData.interact.SetValue(ref interacting, symbolSize); symbolSize = serie.animation.GetSysmbolSize(symbolSize); } var symbolColor = SerieHelper.GetItemColor(serie, serieData, chart.theme, j, isHighlight); var symbolToColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, j, isHighlight); var symbolEmptyColor = SerieHelper.GetItemBackgroundColor(serie, serieData, chart.theme, j, isHighlight, false); var symbolBorder = SerieHelper.GetSymbolBorder(serie, serieData, chart.theme, isHighlight); var borderColor = SerieHelper.GetSymbolBorderColor(serie, serieData, chart.theme, isHighlight); var cornerRadius = SerieHelper.GetSymbolCornerRadius(serie, serieData, isHighlight); chart.DrawSymbol(vh, symbol.type, symbolSize, symbolBorder, point, symbolColor, symbolToColor, symbolEmptyColor, borderColor, symbol.gap, cornerRadius); } } } if (!serie.animation.IsFinish()) { serie.animation.CheckProgress(1); chart.RefreshPainter(serie); } if (dataChanging || interacting) { chart.RefreshPainter(serie); } }
private static void DrawSerieLineNormalArea(VertexHelper vh, Serie serie, bool isY, float zero, float min, float max, Color32 areaColor, Color32 areaToColor, VisualMap visualMap, Axis axis, Axis relativedAxis, GridCoord grid) { var points = serie.context.drawPoints; var count = points.Count; if (count < 2) { return; } var isBreak = false; var lp = Vector3.zero; var isVisualMapGradient = VisualMapHelper.IsNeedAreaGradient(visualMap); var areaLerp = !ChartHelper.IsValueEqualsColor(areaColor, areaToColor); var zsp = isY ? new Vector3(zero, points[0].position.y) : new Vector3(points[0].position.x, zero); var zep = isY ? new Vector3(zero, points[count - 1].position.y) : new Vector3(points[count - 1].position.x, zero); var lastDataIsIgnore = false; for (int i = 0; i < points.Count; i++) { var tp = points[i].position; var isIgnore = points[i].isIgnoreBreak; var color = areaColor; var toColor = areaToColor; var lerp = areaLerp; if (serie.animation.CheckDetailBreak(tp, isY)) { isBreak = true; var progress = serie.animation.GetCurrDetail(); var ip = Vector3.zero; var axisStartPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000); var axisEndPos = isY ? new Vector3(10000, progress) : new Vector3(progress, 10000); if (UGLHelper.GetIntersection(lp, tp, axisStartPos, axisEndPos, ref ip)) { tp = ip; } } var zp = isY ? new Vector3(zero, tp.y) : new Vector3(tp.x, zero); if (isVisualMapGradient) { color = VisualMapHelper.GetLineGradientColor(visualMap, zp, grid, axis, relativedAxis, areaColor); toColor = VisualMapHelper.GetLineGradientColor(visualMap, tp, grid, axis, relativedAxis, areaToColor); lerp = true; } if (i > 0) { if ((lp.y - zero > 0 && tp.y - zero < 0) || (lp.y - zero < 0 && tp.y - zero > 0)) { var ip = Vector3.zero; if (UGLHelper.GetIntersection(lp, tp, zsp, zep, ref ip)) { if (lerp) { AddVertToVertexHelperWithLerpColor(vh, ip, ip, color, toColor, isY, min, max, i > 0); } else { if (lastDataIsIgnore) { UGL.AddVertToVertexHelper(vh, ip, ip, ColorUtil.clearColor32, true); } UGL.AddVertToVertexHelper(vh, ip, ip, toColor, color, i > 0); if (isIgnore) { UGL.AddVertToVertexHelper(vh, ip, ip, ColorUtil.clearColor32, true); } } } } } if (lerp) { AddVertToVertexHelperWithLerpColor(vh, tp, zp, color, toColor, isY, min, max, i > 0); } else { if (lastDataIsIgnore) { UGL.AddVertToVertexHelper(vh, tp, zp, ColorUtil.clearColor32, true); } UGL.AddVertToVertexHelper(vh, tp, zp, toColor, color, i > 0); if (isIgnore) { UGL.AddVertToVertexHelper(vh, tp, zp, ColorUtil.clearColor32, true); } } lp = tp; lastDataIsIgnore = isIgnore; if (isBreak) { break; } } }
private static void DrawSerieLineStackArea(VertexHelper vh, Serie serie, Serie lastStackSerie, bool isY, float zero, float min, float max, Color32 color, Color32 toColor, VisualMap visualMap) { if (lastStackSerie == null) { return; } var upPoints = serie.context.drawPoints; var downPoints = lastStackSerie.context.drawPoints; var upCount = upPoints.Count; var downCount = downPoints.Count; if (upCount <= 0 || downCount <= 0) { return; } var lerp = !ChartHelper.IsValueEqualsColor(color, toColor); var ltp = upPoints[0].position; var lbp = downPoints[0].position; if (lerp) { AddVertToVertexHelperWithLerpColor(vh, ltp, lbp, color, toColor, isY, min, max, false); } else { UGL.AddVertToVertexHelper(vh, ltp, lbp, color, false); } int u = 1, d = 1; var isBreakTop = false; var isBreakBottom = false; while ((u < upCount || d < downCount)) { var tp = u < upCount ? upPoints[u].position : upPoints[upCount - 1].position; var bp = d < downCount ? downPoints[d].position : downPoints[downCount - 1].position; var tnp = (u + 1) < upCount ? upPoints[u + 1].position : upPoints[upCount - 1].position; var bnp = (d + 1) < downCount ? downPoints[d + 1].position : downPoints[downCount - 1].position; if (serie.animation.CheckDetailBreak(tp, isY)) { isBreakTop = true; var progress = serie.animation.GetCurrDetail(); var ip = Vector3.zero; if (UGLHelper.GetIntersection(ltp, tp, new Vector3(progress, -10000), new Vector3(progress, 10000), ref ip)) { tp = ip; } else { tp = new Vector3(progress, tp.y); } } if (serie.animation.CheckDetailBreak(bp, isY)) { isBreakBottom = true; var progress = serie.animation.GetCurrDetail(); var ip = Vector3.zero; if (UGLHelper.GetIntersection(lbp, bp, new Vector3(progress, -10000), new Vector3(progress, 10000), ref ip)) { bp = ip; } else { bp = new Vector3(progress, bp.y); } } if (lerp) { AddVertToVertexHelperWithLerpColor(vh, tp, bp, color, toColor, isY, min, max, true); } else { UGL.AddVertToVertexHelper(vh, tp, bp, color, true); } u++; d++; if (bp.x < tp.x && bnp.x < tp.x) { u--; } if (tp.x < bp.x && tnp.x < bp.x) { d--; } ltp = tp; lbp = bp; if (isBreakTop && isBreakBottom) { break; } } }
/// <summary> /// 是否需要显示边框。 /// </summary> public bool NeedShowBorder() { return(borderWidth != 0 && !ChartHelper.IsClearColor(borderColor)); }
private void UpdateRuntimeData(Serie serie) { var data = serie.data; serie.context.dataMax = serie.yMax; serie.context.startAngle = GetStartAngle(serie); var runtimePieDataTotal = serie.yTotal; SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight); float startDegree = serie.context.startAngle; float totalDegree = 0; float zeroReplaceValue = 0; int showdataCount = 0; foreach (var sd in serie.data) { if (sd.show && serie.pieRoseType == RoseType.Area) { showdataCount++; } sd.context.canShowLabel = false; } float dataChangeDuration = serie.animation.GetUpdateAnimationDuration(); bool isAllZeroValue = SerieHelper.IsAllZeroValue(serie, 1); var dataTotalFilterMinAngle = runtimePieDataTotal; if (isAllZeroValue) { totalDegree = 360; zeroReplaceValue = totalDegree / data.Count; serie.context.dataMax = zeroReplaceValue; runtimePieDataTotal = 360; dataTotalFilterMinAngle = 360; } else { dataTotalFilterMinAngle = GetTotalAngle(serie, runtimePieDataTotal, ref totalDegree); } for (int n = 0; n < data.Count; n++) { var serieData = data[n]; serieData.index = n; var value = isAllZeroValue ? zeroReplaceValue : serieData.GetCurrData(1, dataChangeDuration); serieData.context.startAngle = startDegree; serieData.context.toAngle = startDegree; serieData.context.halfAngle = startDegree; serieData.context.currentAngle = startDegree; if (!serieData.show) { continue; } float degree = serie.pieRoseType == RoseType.Area ? (totalDegree / showdataCount) : (float)(totalDegree * value / dataTotalFilterMinAngle); if (serie.minAngle > 0 && degree < serie.minAngle) { degree = serie.minAngle; } serieData.context.toAngle = startDegree + degree; if (serieData.radius > 0) { serieData.context.outsideRadius = ChartHelper.GetActualValue(serieData.radius, Mathf.Min(chart.chartWidth, chart.chartHeight)); } else { serieData.context.outsideRadius = serie.pieRoseType > 0 ? serie.context.insideRadius + (float)((serie.context.outsideRadius - serie.context.insideRadius) * value / serie.context.dataMax) : serie.context.outsideRadius; } if (serieData.context.highlight) { serieData.context.outsideRadius += chart.theme.serie.pieTooltipExtraRadius; } var offset = 0f; if (serie.pieClickOffset && serieData.selected) { offset += chart.theme.serie.pieSelectedOffset; } if (serie.animation.CheckDetailBreak(serieData.context.toAngle)) { serieData.context.currentAngle = serie.animation.GetCurrDetail(); } else { serieData.context.currentAngle = serieData.context.toAngle; } var halfDegree = (serieData.context.toAngle - startDegree) / 2; serieData.context.halfAngle = startDegree + halfDegree; serieData.context.offsetCenter = serie.context.center; serieData.context.insideRadius = serie.context.insideRadius; if (offset > 0) { var currRad = serieData.context.halfAngle * Mathf.Deg2Rad; var currSin = Mathf.Sin(currRad); var currCos = Mathf.Cos(currRad); serieData.context.offsetRadius = 0; serieData.context.insideRadius -= serieData.context.offsetRadius; serieData.context.outsideRadius -= serieData.context.offsetRadius; if (serie.pieClickOffset && serieData.selected) { serieData.context.offsetRadius += chart.theme.serie.pieSelectedOffset; if (serieData.context.insideRadius > 0) { serieData.context.insideRadius += chart.theme.serie.pieSelectedOffset; } serieData.context.outsideRadius += chart.theme.serie.pieSelectedOffset; } serieData.context.offsetCenter = new Vector3( serie.context.center.x + serieData.context.offsetRadius * currSin, serie.context.center.y + serieData.context.offsetRadius * currCos); } serieData.context.canShowLabel = serieData.context.currentAngle >= serieData.context.halfAngle; startDegree = serieData.context.toAngle; SerieLabelHelper.UpdatePieLabelPosition(serie, serieData); } SerieLabelHelper.AvoidLabelOverlap(serie, chart.theme.common); }
public bool IsNeedGradient() { return(!ChartHelper.IsClearColor(m_ToColor) || !ChartHelper.IsClearColor(m_ToColor2)); }
/// <summary> /// 调整最大最小值 /// </summary> /// <param name="minValue"></param> /// <param name="maxValue"></param> public static void AdjustMinMaxValue(Axis axis, ref double minValue, ref double maxValue, bool needFormat, int ceilRate = 0) { if (axis.type == Axis.AxisType.Log) { int minSplit = 0; int maxSplit = 0; maxValue = ChartHelper.GetMaxLogValue(maxValue, axis.logBase, axis.logBaseE, out maxSplit); minValue = ChartHelper.GetMinLogValue(minValue, axis.logBase, axis.logBaseE, out minSplit); axis.splitNumber = (minSplit > 0 && maxSplit > 0) ? (maxSplit + minSplit - 1) : (maxSplit + minSplit); return; } if (axis.type == Axis.AxisType.Time) { } else if (axis.minMaxType == Axis.AxisMinMaxType.Custom) { if (axis.min != 0 || axis.max != 0) { if (axis.inverse) { minValue = -axis.max; maxValue = -axis.min; } else { minValue = axis.min; maxValue = axis.max; } } } else { if (ceilRate == 0) { ceilRate = axis.ceilRate; } switch (axis.minMaxType) { case Axis.AxisMinMaxType.Default: if (minValue == 0 && maxValue == 0) { } else if (minValue > 0 && maxValue > 0) { minValue = 0; maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue, ceilRate) : maxValue; } else if (minValue < 0 && maxValue < 0) { minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue, ceilRate) : minValue; maxValue = 0; } else { minValue = needFormat ? ChartHelper.GetMinDivisibleValue(minValue, ceilRate) : minValue; maxValue = needFormat ? ChartHelper.GetMaxDivisibleValue(maxValue, ceilRate) : maxValue; } break; case Axis.AxisMinMaxType.MinMax: minValue = ceilRate != 0 ? ChartHelper.GetMinDivisibleValue(minValue, ceilRate) : minValue; maxValue = ceilRate != 0 ? ChartHelper.GetMaxDivisibleValue(maxValue, ceilRate) : maxValue; break; } } }