public void GivenChartExist(int serviceUserId, int chartId) { chart = new Chart(); chart.ChartId = chartId; chart.serviceUserId = serviceUserId; chart.Type = ChartType.Line; }
public ChartDrawService() { listChart=new List<Chart>(); var chartMatrix = new List<ChartCoordinate>(); chartData = new Chart(); chartData.serviceUserId= 1; chartData.ChartId = 1; chartMatrix.Add(new ChartCoordinate(DateTime.Parse("01-May-2011").Date, 70)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("02-May-2011").Date, 50)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("03-May-2011").Date, 55)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("04-May-2011").Date, 85)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("05-May-2011").Date, 45)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("06-May-2011").Date, 95)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("07-May-2011").Date, 78)); chartData.chartCoordinatesData = chartMatrix; chartData.Type = ChartType.Bar; listChart.Add(chartData); chartData = new Chart(); chartData.serviceUserId = 2; chartData.ChartId = 1; chartMatrix = new List<ChartCoordinate>(); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("01-May-2014").Date, 55)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("02-May-2014").Date, 70)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("03-May-2014").Date, 45)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("04-May-2014").Date, 85)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("05-May-2014").Date, 95)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("06-May-2014").Date, 76)); chartMatrix.Add(new ChartCoordinate(DateTime.Parse("07-May-2014").Date, 70)); chartData.chartCoordinatesData = chartMatrix; chartData.Type = ChartType.Bar; listChart.Add(chartData); }
public string DrawChart(Guid ServiceUserId) { try { chartData = new Chart(); chartData.serviceUserId = ServiceUserId; chartData.chartCoordinatesData = new List<ChartCoordinate>(); var listData = _repository.Query<Measurment>().Where(x => x.ServiceUserID == ServiceUserId); if (listData != null) { foreach (var measurment in listData) { var chartCoOrdiante = new ChartCoordinate(measurment.MeasurmentDate.ToString(), measurment.MeasurmentValue); chartData.chartCoordinatesData.Add(chartCoOrdiante); } } var jsonSerialiser = new JavaScriptSerializer(); var json = jsonSerialiser.Serialize(chartData.chartCoordinatesData); return json; } catch (Exception e) { var x = 0; throw; } //chartData = listChart.Where(a=>a.ChartId==ChartId && a.serviceUserId==ServiceUserId).FirstOrDefault(); //var json = JsonConvert.SerializeObject(chartData, Formatting.Indented, // new JsonSerializerSettings { ContractResolver = jsonResolver }); //return json; }