protected void DrawLabelBackground(VertexHelper vh, Serie serie, SerieData serieData) { var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); if (!serieLabel.show) { return; } var invert = serie.type == SerieType.Line && SerieHelper.IsDownPoint(serie, serieData.index) && !serie.areaStyle.show; var centerPos = serieData.labelPosition + serieLabel.offset * (invert ? -1 : 1); var labelHalfWid = serieData.labelObject.GetLabelWidth() / 2; var labelHalfHig = serieData.GetLabelHeight() / 2; var p1 = new Vector3(centerPos.x - labelHalfWid, centerPos.y + labelHalfHig); var p2 = new Vector3(centerPos.x + labelHalfWid, centerPos.y + labelHalfHig); var p3 = new Vector3(centerPos.x + labelHalfWid, centerPos.y - labelHalfHig); var p4 = new Vector3(centerPos.x - labelHalfWid, centerPos.y - labelHalfHig); if (serieLabel.rotate > 0) { p1 = ChartHelper.RotateRound(p1, centerPos, Vector3.forward, serieLabel.rotate); p2 = ChartHelper.RotateRound(p2, centerPos, Vector3.forward, serieLabel.rotate); p3 = ChartHelper.RotateRound(p3, centerPos, Vector3.forward, serieLabel.rotate); p4 = ChartHelper.RotateRound(p4, centerPos, Vector3.forward, serieLabel.rotate); } ChartDrawer.DrawPolygon(vh, p1, p2, p3, p4, serieLabel.backgroundColor); if (serieLabel.border) { ChartDrawer.DrawBorder(vh, centerPos, serieData.GetLabelWidth(), serieData.GetLabelHeight(), serieLabel.borderWidth, serieLabel.borderColor, serieLabel.rotate); } }
public void DrawLabelBackground(VertexHelper vh, Serie serie, SerieData serieData) { if (serieData == null || serieData.labelObject == null) { return; } var serieLabel = SerieHelper.GetSerieLabel(serie, serieData); if (!serieLabel.show) { return; } var invert = serieLabel.autoOffset && serie.type == SerieType.Line && SerieHelper.IsDownPoint(serie, serieData.index) && !serie.areaStyle.show; var centerPos = Vector3.zero; if (serie.type == SerieType.Pie) { centerPos = SerieLabelHelper.GetRealLabelPosition(serieData, serieLabel); } else { centerPos = serieData.labelPosition + serieLabel.offset * (invert ? -1 : 1); } var labelHalfWid = serieData.labelObject.GetLabelWidth() / 2; var labelHalfHig = serieData.GetLabelHeight() / 2; var p1 = new Vector3(centerPos.x - labelHalfWid, centerPos.y + labelHalfHig); var p2 = new Vector3(centerPos.x + labelHalfWid, centerPos.y + labelHalfHig); var p3 = new Vector3(centerPos.x + labelHalfWid, centerPos.y - labelHalfHig); var p4 = new Vector3(centerPos.x - labelHalfWid, centerPos.y - labelHalfHig); if (serieLabel.textStyle.rotate > 0) { p1 = ChartHelper.RotateRound(p1, centerPos, Vector3.forward, serieLabel.textStyle.rotate); p2 = ChartHelper.RotateRound(p2, centerPos, Vector3.forward, serieLabel.textStyle.rotate); p3 = ChartHelper.RotateRound(p3, centerPos, Vector3.forward, serieLabel.textStyle.rotate); p4 = ChartHelper.RotateRound(p4, centerPos, Vector3.forward, serieLabel.textStyle.rotate); } UGL.DrawQuadrilateral(vh, p1, p2, p3, p4, serieLabel.textStyle.backgroundColor); if (serieLabel.border) { UGL.DrawBorder(vh, centerPos, serieData.GetLabelWidth(), serieData.GetLabelHeight(), serieLabel.borderWidth, serieLabel.borderColor, serieLabel.textStyle.rotate); } }