public void CreatErrorTable(out GoogleVisualizationDataTable dataTable) { dataTable = new GoogleVisualizationDataTable(); dataTable.AddColumn("data", "string"); dataTable.AddColumn("message", "string"); GetErrors(dataTable); }
private GoogleVisualizationDataTable ConstructDataTableArea2(List <VentasSucAnioVsAnioAnterior> data) { var dataTable = new GoogleVisualizationDataTable(); var anios = data.Select(x => x.Anio).Distinct().OrderBy(x => x); // Obtiene los dias del mes a mostrar var meses = data.Select(x => x.Mes).Distinct().OrderBy(x => x); // Define Columna y Tipo de variable dataTable.AddColumn("Año", "number"); foreach (var anio in anios) { dataTable.AddColumn(anio.ToString(), "number"); } foreach (var mes in meses) { var values = new List <object>(new[] { mes.ToString() }); foreach (var anio in anios) { var ventat = data .Where(x => x.Anio == anio && x.Mes == mes) .Select(x => x.VentasTotal) .SingleOrDefault(); values.Add(ventat); } dataTable.AddRow(values); } return(dataTable); }
public void GetDataTableForTeamCheckCorrectResult(int id) { GoogleVisualizationDataTable dataTableForFirstTeam = new GoogleVisualizationDataTable(); dataTableForFirstTeam.AddColumn("Date", "string"); dataTableForFirstTeam.AddColumn("WinRate", "number"); dataTableForFirstTeam.AddRow(new List <object> { "19.11.2016", 100 }); dataTableForFirstTeam.AddRow(new List <object> { "20.11.2016", 100 }); dataTableForFirstTeam.AddRow(new List <object> { "21.11.2016", 100 }); dataTableForFirstTeam.AddRow(new List <object> { "22.11.2016", 75 }); dataTableForFirstTeam.AddRow(new List <object> { "23.11.2016", 60 }); GoogleVisualizationDataTable dataTableForSecondTeam = new GoogleVisualizationDataTable(); dataTableForSecondTeam.AddColumn("Date", "string"); dataTableForSecondTeam.AddColumn("WinRate", "number"); dataTableForSecondTeam.AddRow(new List <object> { "19.11.2016", 0 }); dataTableForSecondTeam.AddRow(new List <object> { "20.11.2016", 0 }); dataTableForSecondTeam.AddRow(new List <object> { "21.11.2016", 0 }); dataTableForSecondTeam.AddRow(new List <object> { "22.11.2016", 25 }); dataTableForSecondTeam.AddRow(new List <object> { "23.11.2016", 40 }); var res = this.chartService.GetDataTableForTeam(id); string recievedResult = JsonConvert.SerializeObject(res); if (id == 1) { string expectedResult = JsonConvert.SerializeObject(dataTableForFirstTeam); Assert.AreEqual(expectedResult, recievedResult); } else if (id == 2) { string expectedResult = JsonConvert.SerializeObject(dataTableForSecondTeam); Assert.AreEqual(expectedResult, recievedResult); } }
protected void GetNames(GoogleVisualizationDataTable dataTable, Dictionary <string, int> tableIndex) { int index = 1; bool addDate = true; TableOperation tableOperation = TableOperation.Retrieve <DynamicTableEntity>("Setting", "Name"); CloudTableClient tableClient = AzureStorageExtension.GetCloudTableClient(AzureStorageConfig); string table0 = string.Format("{0}0", AzureStorageConfig.Container); TableContinuationToken token = new TableContinuationToken(); do { var orphanedTables = tableClient.ListTablesSegmentedAsync(AzureStorageConfig.Container, token).Result; token = orphanedTables.ContinuationToken; foreach (CloudTable cloudTable in orphanedTables.Results) { if (cloudTable.Name == table0) { continue; } DynamicTableEntity tdsTableEntity = (DynamicTableEntity)cloudTable.ExecuteAsync(tableOperation).Result.Result; IDictionary <string, EntityProperty> nameInfos = tdsTableEntity.Properties; string name = ""; foreach (KeyValuePair <string, EntityProperty> pInfo in nameInfos) { if (pInfo.Key != "PartitionKey" && pInfo.Key != "RowKey" && pInfo.Key != "Timestamp") { name = pInfo.Value.StringValue; //.GetValue(tdsTableEntity); if (name == null) { break; } if (pInfo.Key == "ADATE") { if (addDate) { dataTable.AddColumn(name, "datetime"); tableIndex.Add(pInfo.Key, 0); addDate = false; } } else { dataTable.AddColumn(name, "number"); tableIndex.Add(pInfo.Key, index++); } } } } }while (token != null); }
public GoogleVisualizationDataTable GetDataTableForTeam(int id) { GoogleVisualizationDataTable dataTable = new GoogleVisualizationDataTable(); dataTable.AddColumn("Date", "date"); dataTable.AddColumn("WinRate", "number"); // Get existing results for team ordered by date var results = this.unitOfWork.GetRepository <Team>().GetById(id).Results .Where(r => r.Score != -1) .OrderBy(result => result.SportEvent.Date) .ToList(); int winGamesCounter = 0; int totalGamesCounter = 0; foreach (var result in results) { totalGamesCounter++; IList <object> row = new List <object>(2); row.Add(result.SportEvent.Date); var winners = result.SportEvent.Results.Where(r => r.Score == result.SportEvent.Results.Max(mr => mr.Score)).ToList(); int winrate = 0; // If draw - adding last winrate if (winners.Count > 1) { if (dataTable.Rows.Count == 0) { continue; } winrate = int.Parse(dataTable.Rows[dataTable.Rows.Count - 1].C.ElementAt(1).V.ToString()); totalGamesCounter--; } else if (winners.Count == 1 && winners[0].Team.Id == id) { winGamesCounter++; winrate = winGamesCounter * 100 / totalGamesCounter; } else { winrate = winGamesCounter * 100 / totalGamesCounter; } row.Add(winrate); dataTable.AddRow(row); } return(dataTable); }
/// <summary> /// Gets the heart rate. /// </summary> /// <param name="startDate">The start date.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// Heartrate data in JSON format. /// </returns> public async Task <JsonResult> GetHeartRate(string startDate, CancellationToken cancellationToken) { var authResult = await new AuthorizationCodeMvcApp(this, new AppFlowMetadata()) .AuthorizeAsync(cancellationToken); if (authResult.Credential != null) { try { var service = new FitnessService(new BaseClientService.Initializer { ApiKey = GoogleClientSettings.ApiKey, ApplicationName = GoogleClientSettings.ApplicationName, HttpClientInitializer = authResult.Credential }); var date = DateTime.Parse(startDate).Date.ToUniversalTime(); var query = new HeartRateQuery(service); var data = query.QueryHeartRate(date, date.AddDays(1)); var dataTabe = new GoogleVisualizationDataTable(); dataTabe.AddColumn("Time", "string"); dataTabe.AddColumn("Heartrate", "number"); foreach (var dataPoint in data) { var values = new List <object> { dataPoint.TimeStamp.ToLocalTime().ToString("t"), dataPoint.BPM }; dataTabe.AddRow(values); } return(Json(dataTabe, JsonRequestBehavior.AllowGet)); } catch (Exception e) { Debug.WriteLine("e: " + e.Message); return(Json(string.Empty)); } } return(Json(string.Empty)); }
private GoogleVisualizationDataTable ConstructDataTable(MarketSales[] data) { var dataTable = new GoogleVisualizationDataTable(); // Get distinct markets from the data var markets = data.Select(x => x.Market).Distinct().OrderBy(x => x); // Get distinct years from the data var years = data.Select(x => x.Year).Distinct().OrderBy(x => x); // Specify the columns for the DataTable. // In this example, it is Market and then a column for each year. dataTable.AddColumn("", "string"); foreach (var year in years) { dataTable.AddColumn(year.ToString(), "number"); } // Specify the rows for the DataTable. // Each Market will be its own row, containing the total sales for each year. foreach (var market in markets) { var values = new List <object>(new[] { market }); foreach (var year in years) { var totalSales = data .Where(x => x.Market == market) .Select(x => x.Count) .SingleOrDefault(); values.Add(totalSales); } dataTable.AddRow(values); } return(dataTable); }
private GoogleVisualizationDataTable ConstructDataTable(VentasRestaurant[] data) { var dataTable = new GoogleVisualizationDataTable(); // Get distinct markets from the data var markets = data.Select(x => x.Sucursal).Distinct().OrderBy(x => x); // Get distinct years from the data var years = data.Select(x => x.Anio).Distinct().OrderBy(x => x); // Specify the columns for the DataTable. // In this example, it is Sucursal and then a column for each year. dataTable.AddColumn("Sucursal", "string"); foreach (var year in years) { dataTable.AddColumn(year.ToString(), "number"); } // Specify the rows for the DataTable. // Each Sucursal will be its own row, containing the total sales for each year. foreach (var Sucursal in markets) { var values = new List <object>(new[] { Sucursal }); foreach (var year in years) { var totalSales = data .Where(x => x.Sucursal == Sucursal && x.Anio == year) .Select(x => x.VentasTotales) .SingleOrDefault(); values.Add(totalSales); } dataTable.AddRow(values); } return(dataTable); }