string customYAxisLabelLabeler(WMG_Axis axis, int labelIndex) { float num = axis.AxisMinValue + labelIndex * (axis.AxisMaxValue - axis.AxisMinValue) / (axis.axisLabels.Count - 1); yAxisNumberFormatInfo.CurrencyDecimalDigits = axis.numDecimalsAxisLabels; return(num.ToString("C", yAxisNumberFormatInfo)); }
string customAxisLabelLabelerToE(WMG_Axis axis, int labelIndex) { float num = axis.AxisMinValue + labelIndex * (axis.AxisMaxValue - axis.AxisMinValue) / (axis.axisLabels.Count - 1); yAxisNumberFormatInfo.CurrencyDecimalDigits = axis.numDecimalsAxisLabels; string str = num.ToString("E", yAxisNumberFormatInfo); string strStart = str.Substring(0, 3); string strEnd = str.Substring(7, str.Length - 7); return(strStart + strEnd); }
// custom update function for labelling any axis with metric units public string GetMetricAxisLabel(WMG_Axis axis, int labelIndex, string valueFormat, int sigFigs, AxisAutoFunctions autoAxisParams = null) { // map label value to min/max float num = axis.AxisMinValue + labelIndex * (axis.AxisMaxValue - axis.AxisMinValue) / (axis.axisLabels.Count - 1); if (autoAxisParams == null) { return(MathScientific.ToMetric(num, valueFormat, sigFigs)); } return(autoAxisParams.FormatLabel(num, valueFormat, sigFigs)); }
// single functions to change a label into a metric, formatted axis label. Is passed to the Graphing Asset Labeller. string CustomXAxisLabelLabeler(WMG_Axis axis, int labelIndex) { string xLabel = GetMetricAxisLabel(axis, labelIndex, xValueFormat, (int)(numSigFigs.x), xAutoFuncts); return(xLabel); }
// single functions to change a label into a metric, formatted axis label. Is passed to the Graphing Asset Labeller. string CustomYAxisLabelLabeler(WMG_Axis axis, int labelIndex) { string yLabel = GetMetricAxisLabel(axis, labelIndex, yValueFormat, (int)(numSigFigs.y), yAutoFuncts); return(yLabel); }
private void Awake() { X_Axis = Axis.xAxis; Y_Axis = Axis.yAxis; }
// void setLabelUsingSkipIntervalAndSkipStart(int labelIndex, string label) { // axisLabels.SetValNoCb(labelIndex, ((labelIndex - AxisLabelSkipStart) % (AxisLabelSkipInterval + 1) == 0) ? (labelIndex >= AxisLabelSkipStart ? label : "") : "", ref _axisLabels); // } string defaultAxisLabelLabeler(WMG_Axis axis, int labelIndex) { if (axis.LabelType == WMG_Axis.labelTypes.groups) { // for groups return the string defined at the graph level for groups, respects skip settings return ((labelIndex - axis.AxisLabelSkipStart) % (axis.AxisLabelSkipInterval + 1) == 0) ? (labelIndex >= axis.AxisLabelSkipStart ? axis.graph.groups[labelIndex] : "") : ""; } else { // all other label types if (axis.SetLabelsUsingMaxMin) { // if setting based on axis max and min values float num = axis.AxisMinValue + labelIndex * (axis.AxisMaxValue - axis.AxisMinValue) / (axis.axisLabels.Count-1); if (labelIndex == 0) num = axis.AxisMinValue; if (axis.graph.graphType == WMG_Axis_Graph.graphTypes.bar_stacked_percent && ((axis.isY && axis.graph.orientationType == WMG_Axis_Graph.orientationTypes.vertical) || (!axis.isY && axis.graph.orientationType == WMG_Axis_Graph.orientationTypes.horizontal))) { num = labelIndex / (axis.axisLabels.Count-1f) * 100f; } float numberToMult = Mathf.Pow(10f, axis.numDecimalsAxisLabels); string returnString = ((labelIndex - axis.AxisLabelSkipStart) % (axis.AxisLabelSkipInterval + 1) == 0) ? (labelIndex >= axis.AxisLabelSkipStart ? (Mathf.Round(num*numberToMult)/numberToMult).ToString() : "") : ""; if (axis.graph.graphType == WMG_Axis_Graph.graphTypes.bar_stacked_percent && ((axis.isY && axis.graph.orientationType == WMG_Axis_Graph.orientationTypes.vertical) || (!axis.isY && axis.graph.orientationType == WMG_Axis_Graph.orientationTypes.horizontal))) { return string.IsNullOrEmpty(returnString) ? "" : (returnString + "%"); } else { return returnString; } } else { // otherwise just return the label that is in the string list return axis.axisLabels[labelIndex]; } } }
public void Init(WMG_Axis otherAxis, bool isY) { if (hasInit) return; hasInit = true; changeObjs.Add(graphC); changeObjs.Add(seriesC); this.otherAxis = otherAxis; this.isY = isY; axisLabels.SetList (_axisLabels); axisLabels.Changed += axisLabelsChanged; graphC.OnChange += GraphChanged; seriesC.OnChange += SeriesChanged; axisLabelLabeler = defaultAxisLabelLabeler; setOriginalPropertyValues(); PauseCallbacks(); }
string customYAxisLabelLabeler(WMG_Axis axis, int labelIndex) { float num = axis.AxisMinValue + labelIndex * (axis.AxisMaxValue - axis.AxisMinValue) / (axis.axisLabels.Count-1); yAxisNumberFormatInfo.CurrencyDecimalDigits = axis.numDecimalsAxisLabels; return num.ToString("C", yAxisNumberFormatInfo); }
// single functions to change a label into a metric, formatted axis label. Is passed to the Graphing Asset Labeller. string CustomXAxisLabelLabeler(WMG_Axis axis, int labelIndex) { string xLabel = GetMetricAxisLabel(axis, labelIndex, "*", 3); return(xLabel); }
// constructor method public AxisFormatting(WMG_Axis axis) { this.axis = axis; }