private Vector2 GetLabelPivot(AxisLabelRendererExtry entry) { if (entry.Orientation == AxisOrientation.HORIZONTAL) { switch (entry.Gravity) { case AxisLabelGravity.START: return(PivotValue.TOP_MIDDLE); case AxisLabelGravity.END: return(PivotValue.BOTTOM_MIDDLE); } } else { switch (entry.Gravity) { case AxisLabelGravity.START: return(PivotValue.MIDDLE_RIGHT); case AxisLabelGravity.END: return(PivotValue.MIDDLE_LEFT); } } return(PivotValue.CENTER); }
private TextAnchor GetLabelAlignment(AxisLabelRendererExtry entry) { if (entry.Orientation == AxisOrientation.HORIZONTAL) { switch (entry.Gravity) { case AxisLabelGravity.START: return(TextAnchor.UpperCenter); case AxisLabelGravity.END: return(TextAnchor.LowerCenter); } } else { switch (entry.Gravity) { case AxisLabelGravity.START: return(TextAnchor.MiddleRight); case AxisLabelGravity.END: return(TextAnchor.MiddleLeft); } } return(TextAnchor.MiddleCenter); }
private Vector2 CreateLabelPositionForEntry(AxisLabelRendererExtry entry, Vector2 rendererSize, float margin) { if (entry.Orientation == AxisOrientation.HORIZONTAL) { switch (entry.Gravity) { case AxisLabelGravity.START: return(new Vector2(entry.PositionOnAxis, -margin)); case AxisLabelGravity.END: return(new Vector2(entry.PositionOnAxis, rendererSize.y + margin)); } } else { switch (entry.Gravity) { case AxisLabelGravity.START: return(new Vector2(-margin, entry.PositionOnAxis)); case AxisLabelGravity.END: return(new Vector2(rendererSize.x + margin, entry.PositionOnAxis)); } } return(Vector2.zero); }
private void UpdateLabel(ChartLabel label, AxisLabelConfig config, AxisLabelRendererExtry entry, Vector2 rendererSize) { label.SetLabelColor(config.LabelColor); label.SetLabelTextSize(config.LabelSize); label.SetLabelTextAlignment(GetLabelAlignment(entry)); label.SetLabelText(entry.Text); label.GetComponent <RectTransform> ().pivot = GetLabelPivot(entry); label.transform.localPosition = CreateLabelPositionForEntry(entry, rendererSize, config.LabelMargin); }
public List <AxisLabelRendererExtry> getLabelRendererEntries() { List <AxisLabelRendererExtry> entries = new List <AxisLabelRendererExtry> (); int minLabelIndex = GetMinLabelIndex(); int maxLabelIndex = GetMaxLabelIndex(); for (int i = minLabelIndex; i < minLabelIndex + labelCount; i++) { AxisLabelRendererExtry entry = new AxisLabelRendererExtry(); entry.PositionOnAxis = GetLabelAxisPosition(i, maxLabelIndex); entry.Gravity = labelsGravity; entry.Text = GetLabelValueText(i - minLabelIndex, entry.PositionOnAxis); entry.Orientation = GetEntryAxisOrientation(); entries.Add(entry); } return(entries); }
public List <AxisLabelRendererExtry> getLabelRendererEntries() { List <AxisLabelRendererExtry> entries = new List <AxisLabelRendererExtry> (); if (barChartPositioner == null) { return(entries); } int entriesCount = barChartPositioner.GetVisibleEntriesRange(); int axisFirstVisibleIndex = (int)barChartPositioner.axisBounds.XMin; for (int i = axisFirstVisibleIndex; i < entriesCount + axisFirstVisibleIndex; i++) { AxisLabelRendererExtry entry = new AxisLabelRendererExtry(); entry.PositionOnAxis = barChartPositioner.GetBarCenterPosition(i).x; entry.Gravity = labelsGravity; entry.Text = GetLabelValueText(i, axisFirstVisibleIndex, entriesCount + axisFirstVisibleIndex); entry.Orientation = AxisOrientation.HORIZONTAL; entries.Add(entry); } return(entries); }