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); } }
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); } }
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); } }
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); } } }
private void NewPlanningOutcomeItem(KeyValuePair <string, float> pair) { PlanningOutcomeItem item = Instantiate(planningOutcomeItemPrefab, planningOutcomesContainer, false); item.Init(); UpdatePlanningOutcomeItem(pair, item); planningOutcomeItems.Add(pair.Key, item); }
private void HasOrigCurrTargetVals(PlanningOutcomeItem item, float origVal, float currVal, float targetVal) { if (origVal.Equals(targetVal)) { OrigTargetSameVal(item, origVal, currVal); } else { OrigTargetDiffVal(item, origVal, currVal, targetVal); } }