public PieChartValueIndicator InstantiatePieEntryValueIndicator(string name, Transform parent, Vector2 pivot) { PieChartValueIndicator indicatorView = CreateBaseGameObject(name, parent, pivot) .AddComponent <PieChartValueIndicator> (); indicatorView.GetComponent <RectTransform> ().sizeDelta = new Vector2(1f, 1f); indicatorView.GetComponent <RectTransform> ().anchorMin = new Vector2(0.5f, 0.5f); indicatorView.GetComponent <RectTransform> ().anchorMax = new Vector2(0.5f, 0.5f); return(indicatorView); }
public PieChartValueIndicator InstantiatePieEntryValueIndicator(ChartLabel labelPrafab, string name, Transform parent, Vector2 pivot) { PieChartValueIndicator indicatorView = CreateBaseGameObject(name, parent, pivot) .AddComponent <PieChartValueIndicator> (); indicatorView.labelPrafab = labelPrafab ?? Resources.Load <ChartLabel> ("prefabs/PieChartIndicatorLabelPrafab"); indicatorView.GetComponent <RectTransform> ().sizeDelta = new Vector2(1f, 1f); indicatorView.GetComponent <RectTransform> ().anchorMin = new Vector2(0.5f, 0.5f); indicatorView.GetComponent <RectTransform> ().anchorMax = new Vector2(0.5f, 0.5f); return(indicatorView); }
private void UpdateValueIndicatorView(PieChartValueIndicator view, PieEntry entry, float rotation, float percentValue) { float entryCenterAngle = rotation + (percentValue / 2 * 360); bool leftSide = entryCenterAngle % 360f > 180f; int leftSideMultiplier = leftSide ? -1 : 1; Vector2 position0 = MathUtils.GetPositionOnCircle(entryCenterAngle, GetChartRadius() + ENTRY_INDICATOR_LINE_SPACING + (selectedEntries.Contains(entry) ? SELECTED_ENTRY_OFFSET : 0f)); Vector2 position1 = MathUtils.GetPositionOnCircle(entryCenterAngle, GetChartRadius() + Config.ValueIndicatorLineLength + ENTRY_INDICATOR_LINE_SPACING + (selectedEntries.Contains(entry) ? SELECTED_ENTRY_OFFSET : 0f)); Vector2 position2 = position1 + new Vector2(Config.ValueIndicatorLineLength * leftSideMultiplier, 0f); Vector2 positionLabel = position2 + new Vector2(ENTRY_INDICATOR_LINE_SPACING * leftSideMultiplier, 0f); var linePoints = new List <Vector2> { position0 - positionLabel, position1 - positionLabel, position2 - positionLabel }; view.GetComponent <RectTransform>().anchoredPosition = positionLabel; view.Label = CreateValueIndicatorLabel(entry, percentValue); view.FontSize = Config.ValueIndicatorFontSize; view.IndicatorColor = Config.ValueIndicatorColor; view.LinePoints = linePoints; view.ReversedLabel = leftSide; }