public HttpResponseMessage DrawMultiBarChart() { BarChart[] charts = new BarChart[2]; charts[0] = new Models.BarChart(); charts[0].name = "set1"; charts[0].setColor = new List <string> { "#004D40", "#8085e9", "#f15c80", "#e4d354", "#434348", "#90ed7d", "#f7a35c" }; charts[0].points = new List <Point> { new Point { x = "Rome", y = "11" }, new Point { x = "London", y = "43" }, new Point { x = "Paris", y = "167" }, new Point { x = "Bern", y = "17" } }; charts[1] = new Models.BarChart(); charts[1].name = "set2"; charts[1].setColor = new List <string> { "#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9", "#f15c80", "#e4d354" }; charts[1].points = new List <Point> { new Point { x = "Rome", y = "12" }, new Point { x = "London", y = "24" }, new Point { x = "Paris", y = "125" }, new Point { x = "Bern", y = "7" } }; BarChartData chartData = new BarChartData(); chartData.datasets = charts; string json = JsonConvert.SerializeObject(chartData); using (JsonTextReader reader = new JsonTextReader(new StringReader(json))) { JObject o2 = (JObject)JToken.ReadFrom(reader); return(this.Request.CreateResponse(HttpStatusCode.OK, o2, "application/json")); } }
public HttpResponseMessage DrawBarChart() { BarChart[] charts = new BarChart[1]; charts[0] = new Models.BarChart(); charts[0].name = "set1"; charts[0].setColor = new List <string> { "#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9", "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1" }; charts[0].points = new List <Point> { new Point { x = "USA", y = "24" }, new Point { x = "Fiji", y = "38" }, new Point { x = "UK", y = "77" }, new Point { x = "Italy", y = "17" }, new Point { x = "PR", y = "53" }, new Point { x = "IR", y = "19" }, new Point { x = "India", y = "99" } }; BarChartData chartData = new BarChartData(); chartData.datasets = charts; string json = JsonConvert.SerializeObject(chartData); using (JsonTextReader reader = new JsonTextReader(new StringReader(json))) { JObject o2 = (JObject)JToken.ReadFrom(reader); return(this.Request.CreateResponse(HttpStatusCode.OK, o2, "application/json")); } }