Exemplo n.º 1
0
    string GetListItem(float newXValue, float newYValue)
    {
        // set significant figures, optional metric unit prefix and formatting in list x and y values
        string xListItem;

        if (xHasMetricFormat)
        {
            xListItem = MathScientific.ToMetric(newXValue, xValueFormat, listNumSigFigs.x);
        }
        else
        {
            xListItem = MathScientific.ToFormattedValue(newXValue, xValueFormat, listNumSigFigs.x);
        }

        string yListItem;

        if (yHasMetricFormat)
        {
            yListItem = MathScientific.ToMetric(newYValue, yValueFormat, listNumSigFigs.y);
        }
        else
        {
            yListItem = MathScientific.ToFormattedValue(newYValue, yValueFormat, listNumSigFigs.y);
        }

        return("X: " + xListItem + ",\n\t Y: " + yListItem);
    }
 // takes a label value, and related varaibles, and returns it formatted to fit the axis formatting
 public string FormatLabel(float value, string valueFormat, int sigFigs)
 {
     if (unitIsMetric)
     {
         return(MathScientific.ToMetric(value, valueFormat, BaseSigFigs + sigFigs, customThsdPow: ThsdPow));
     }
     return(MathScientific.ToFormattedValue(value, valueFormat, BaseSigFigs + sigFigs));
 }
Exemplo n.º 3
0
    // 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));
    }
    ///<summary>adds a new data value to the list</summary>
    public void AddListDataItem(string value)
    {
        // increase data item count by one
        dataCounter++;
        // get item at bottom of list, move it to top and set value to new data value
        Transform newItemTranf = ContentPanel.transform.GetChild(ContentPanel.transform.childCount - 1);

        newItemTranf.SetAsFirstSibling();
        ListItemController itemController = newItemTranf.GetComponent <ListItemController> ();

        itemController.dataText.text = MathScientific.ToMetric((float)dataCounter) + ") " + value;
    }
Exemplo n.º 5
0
    ///<summary>Adds a new value to the Tab, including Graph, Ticker List and dataValues.</summary>
    ///<param name = "newValue">The value to be added to the graph (displayed on y-axis)</param>
    public void AddSingleValue(float newValue)
    {
        dataValues.Add(newValue);
        graphScript.AddPoint(newValue);
        // set decimals in list value
        string newListItem;

        if (yHasMetricFormat)
        {
            newListItem = MathScientific.ToMetric(newValue, valueFormat, listNumSigFigs);
        }
        else
        {
            newListItem = MathScientific.ToFormattedValue(newValue, valueFormat, listNumSigFigs);
        }
        tickerList.GetComponent <ListController> ().AddListDataItem(newListItem);
    }