예제 #1
0
        public HttpResponseMessage DrawMultiLinearChart()
        {
            LinearChart[] charts = new LinearChart[2];

            charts[0]             = new Models.LinearChart();
            charts[0].name        = "set1";
            charts[0].startColor  = "#f15c80";
            charts[0].endColor    = "#FFFFFF";
            charts[0].circleColor = "#51BBD1";
            charts[0].borderColor = "#8085e9";

            charts[0].points = new List <Point> {
                new Point {
                    x = "Rome", y = "72"
                }, new Point {
                    x = "London", y = "84"
                }, new Point {
                    x = "Paris", y = "105"
                }, new Point {
                    x = "Bern", y = "57"
                }
            };

            charts[1]             = new Models.LinearChart();
            charts[1].name        = "set2";
            charts[1].startColor  = "#7cb5ec";
            charts[1].endColor    = "#434348";
            charts[1].circleColor = "#90ed7d";
            charts[1].borderColor = "#2b908f";
            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"
                }
            };

            LinearChartData chartData = new LinearChartData();

            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"));
            }
        }
예제 #2
0
        public HttpResponseMessage DrawLinearChart()
        {
            LinearChart[] charts = new LinearChart[1];

            charts[0]             = new Models.LinearChart();
            charts[0].name        = "set1";
            charts[0].startColor  = "#f15c80";
            charts[0].endColor    = "#FFFFFF";
            charts[0].circleColor = "#51BBD1";
            charts[0].borderColor = "#8085e9";
            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"
                }
            };

            LinearChartData chartData = new LinearChartData();

            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"));
            }
        }