Esempio n. 1
0
    private void OrigTargetDiffVal(PlanningOutcomeItem item, float origVal, float currVal, float targetVal)
    {
        float maxDistributionGraphWidth = item.MaxDistributionGraphWidth;
        float origTargetGraphWidth      = maxDistributionGraphWidth;
        float origTargetDiffVal         = Mathf.Abs(origVal - targetVal);
        float minVal            = Mathf.Min(origVal, targetVal);
        float currMinDiffVal    = currVal - minVal;
        float currMinDiffAbsVal = Mathf.Abs(currMinDiffVal);

        if (!origTargetDiffVal.Equals(0.0f))
        {
            float currPercent = currMinDiffVal / origTargetDiffVal, currGraphWidth;
            if (currMinDiffAbsVal > origTargetDiffVal)
            {
                origTargetGraphWidth = origTargetDiffVal / currMinDiffAbsVal * maxDistributionGraphWidth;
                currGraphWidth       = maxDistributionGraphWidth;
            }
            else
            {
                currGraphWidth = Mathf.Abs(currPercent) * maxDistributionGraphWidth;
            }

            item.SetGraphProperties("CurrentGraphBar", currPercent, currGraphWidth);
            item.SetOrigTargetDiffGraphDotProperties(origVal, targetVal, origTargetGraphWidth);

            bool cond = !currMinDiffVal.Equals(0.0f) && !origTargetDiffVal.Equals(0.0f);
            item.ShowGraph("OriginalGraphDot", false);
            item.ShowGraph("CurrentGraphBar", cond);
            item.ShowGraph("TargetGraphDot", false);
            item.ShowGraph("OrigTargetSameGraphDot", false);
            item.ShowOrigTargetDiffGraphDot(cond);
        }
    }
Esempio n. 2
0
    private void HasCurrTargetVals(PlanningOutcomeItem item, float currVal, float targetVal)
    {
        float maxDistributionGraphWidth = item.MaxDistributionGraphWidth;
        float targetGraphWidth          = maxDistributionGraphWidth;

        if (!targetVal.Equals(0.0f))
        {
            float currPercent = currVal / targetVal;
            float currGraphWidth;
            if (currVal > targetVal)
            {
                targetGraphWidth = targetVal / currVal * maxDistributionGraphWidth;
                currGraphWidth   = maxDistributionGraphWidth;
            }
            else
            {
                currGraphWidth = currPercent * maxDistributionGraphWidth;
            }

            item.SetGraphProperties("CurrentGraphBar", currPercent, currGraphWidth);
            item.SetGraphProperties("TargetGraphDot", (targetVal * 0.01f) > 0.0f ? 1.0f : 0.0f, targetGraphWidth);

            bool cond = !currVal.Equals(0.0f) && !targetVal.Equals(0.0f);
            item.ShowGraph("OriginalGraphDot", false);
            item.ShowGraph("CurrentGraphBar", cond);
            item.ShowGraph("TargetGraphDot", cond);
            item.ShowGraph("OrigTargetSameGraphDot", false);
            item.ShowOrigTargetDiffGraphDot(false);
        }
    }
Esempio n. 3
0
    private void OrigTargetSameVal(PlanningOutcomeItem item, float origVal, float currVal)
    {
        float maxDistributionGraphWidth = item.MaxDistributionGraphWidth;
        float origTargetGraphWidth      = maxDistributionGraphWidth;

        if (!origVal.Equals(0.0f))
        {
            float currPercent = currVal / origVal;
            float currGraphWidth;
            if (currVal > origVal)
            {
                origTargetGraphWidth = origVal / currVal * maxDistributionGraphWidth;
                currGraphWidth       = maxDistributionGraphWidth;
            }
            else
            {
                currGraphWidth = currPercent * maxDistributionGraphWidth;
            }

            item.SetGraphProperties("CurrentGraphBar", currPercent, currGraphWidth);
            item.SetGraphProperties("OrigTargetSameGraphDot", 1.0f, origTargetGraphWidth);

            bool cond = !currVal.Equals(0.0f) && !origVal.Equals(0.0f);
            item.ShowGraph("OriginalGraphDot", false);
            item.ShowGraph("CurrentGraphBar", cond);
            item.ShowGraph("TargetGraphDot", false);
            item.ShowGraph("OrigTargetSameGraphDot", cond);
            item.ShowOrigTargetDiffGraphDot(false);
        }
    }
Esempio n. 4
0
    private void UpdatePlanningOutcomeItem(KeyValuePair <string, float> pair, PlanningOutcomeItem item)
    {
        item.SetHeaderValue(pair.Key);

        // Items
        item.SetItemValue("Units", Typology.info[pair.Key].units);

        // Values obtained from data layers existing in site with matching name to attribute
        bool  hasOrigVals = (gridValues != null && gridValues.ContainsKey(pair.Key));
        float origVal     = hasOrigVals ? gridValues[pair.Key] : 0.0f;

        item.SetItemValue("Original", hasOrigVals ? origVal.ToString("#,##0.##") : translator.Get("N/A"));

        // Values obtained from summaryValues
        bool  hasCurrVals = (summaryValues != null && summaryValues.ContainsKey(pair.Key));
        float currVal     = hasCurrVals ? summaryValues[pair.Key] : 0.0f;

        item.SetItemValue("Current", hasCurrVals ? currVal.ToString("#,##0.##") : translator.Get("N/A"));

        // Values obtained from targetValues
        bool  hasTargetVals = (targetValues != null && targetValues.ContainsKey(pair.Key));
        float targetVal     = hasTargetVals ? targetValues[pair.Key] : 0.0f;

        item.SetItemValue("Target", hasTargetVals ? targetVal.ToString("#,##0.##") : translator.Get("N/A"));
        item.ShowItem("Target", hasTargetVals);

        // Graphs
        // Compute percentages and widths
        if (!hasTargetVals)
        {
            if (hasOrigVals)
            {
                HasOrigCurrVals(item, origVal, currVal);
            }
            else
            {
                item.SetGraphProperties("CurrentGraphBar", (currVal * 0.01f) > 0.0f ? 1.0f : 0.0f, item.MaxDistributionGraphWidth, false);

                item.ShowGraph("OriginalGraphDot", false);
                item.ShowGraph("CurrentGraphBar", false);
                item.ShowGraph("TargetGraphDot", false);
                item.ShowGraph("OrigTargetSameGraphDot", false);
                item.ShowOrigTargetDiffGraphDot(false);
            }
        }
        else
        {
            if (hasOrigVals)
            {
                HasOrigCurrTargetVals(item, origVal, currVal, targetVal);
            }
            else
            {
                HasCurrTargetVals(item, currVal, targetVal);
            }
        }
    }