void UpdateExampleChart() { v1 = (Mathf.Sin(Time.time) + 1) / 4; v2 = (Mathf.Cos(Time.time) + 1) / 4; v3 = 1 - (v1 + v2); _rChart.SetValues(v1, v2, v3); }
/// <summary> /// either update of the panel or let base processing update the panel /// </summary> /// <returns>whether or not to do base processing</returns> public static bool Prefix() { // assume do base processing bool doBaseProcessing = true; // check if should exclude mail if (!ExcludeMailLoading.IncludeMail()) { // do processing with mail set to zero // logic copied from OutsideConnectionsInfoViewPanel.UpdatePanel and then mail was set to zero // do imports DistrictManager instance = Singleton <DistrictManager> .instance; int importOil = (int)(instance.m_districts.m_buffer[0].m_importData.m_averageOil + 99) / 100; int importOre = (int)(instance.m_districts.m_buffer[0].m_importData.m_averageOre + 99) / 100; int importForestry = (int)(instance.m_districts.m_buffer[0].m_importData.m_averageForestry + 99) / 100; int importGoods = (int)(instance.m_districts.m_buffer[0].m_importData.m_averageGoods + 99) / 100; int importFarming = (int)(instance.m_districts.m_buffer[0].m_importData.m_averageAgricultural + 99) / 100; int importMail = 0; int importTotal = importOil + importOre + importForestry + importGoods + importFarming + importMail; _importTotalLabel.text = StringUtils.SafeFormat(ColossalFramework.Globalization.Locale.Get(_importTotalLabel.localeID), importTotal); _importChart.SetValues( GetValue(importOil, importTotal), GetValue(importOre, importTotal), GetValue(importForestry, importTotal), GetValue(importGoods, importTotal), GetValue(importFarming, importTotal), GetValue(importMail, importTotal)); // do exports int exportOil = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageOil + 99) / 100; int exportOre = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageOre + 99) / 100; int exportForestry = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageForestry + 99) / 100; int exportGoods = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageGoods + 99) / 100; int exportFarming = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageAgricultural + 99) / 100; int exportMail = 0; int exportFish = (int)(instance.m_districts.m_buffer[0].m_exportData.m_averageFish + 99) / 100; int exportTotal = exportOil + exportOre + exportForestry + exportGoods + exportFarming + exportMail + exportFish; _exportTotalLabel.text = StringUtils.SafeFormat(ColossalFramework.Globalization.Locale.Get(_exportTotalLabel.localeID), exportTotal); _exportChart.SetValues( GetValue(exportOil, exportTotal), GetValue(exportOre, exportTotal), GetValue(exportForestry, exportTotal), GetValue(exportGoods, exportTotal), GetValue(exportFarming, exportTotal), GetValue(exportMail, exportTotal), GetValue(exportFish, exportTotal)); // everything was performed here, skip base processing doBaseProcessing = false; } // return whether or not to do the base processing return(doBaseProcessing); }
public static UIRadialChart CreateExampleTwoSlicedRadialChart(UIComponent parent, string name) { UIRadialChart radialChart = parent.AddUIComponent <UIRadialChart>(); radialChart.name = name; radialChart.size = new Vector3(150f, 150f); radialChart.spriteName = "PieChartBg"; radialChart.AddSlice(); UIRadialChart.SliceSettings slice = radialChart.GetSlice(0); Color32 colorYellow = new Color32(255, 255, 0, 128); slice.outterColor = colorYellow; slice.innerColor = colorYellow; radialChart.AddSlice(); UIRadialChart.SliceSettings slice1 = radialChart.GetSlice(1); Color32 colorRed = new Color32(255, 0, 0, 128); slice1.outterColor = colorRed; slice1.innerColor = colorRed; radialChart.AddSlice(); UIRadialChart.SliceSettings slice2 = radialChart.GetSlice(2); Color32 colorGreen = new Color32(0, 255, 0, 128); slice2.outterColor = colorGreen; slice2.innerColor = colorGreen; radialChart.SetValues(0.2f, 0.3f, 0.5f); radialChart.tooltip = "Some message when hover the chart"; return(radialChart); }