Пример #1
0
        public void ZingChart_ShouldReturnJSON_When2PieChartsAdded()
        {
            var       javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            ZingChart zingchart            = new ZingChart();
            string    title = "RBF.CLA";

            ZingChart.Chart chart = new ZingChart.Chart(title);
            chart.addSlice(30, "Developer 1");
            chart.addSlice(70, "Developer 2");
            zingchart.addChart(chart);

            title = "HELLO.CLA";
            chart = new ZingChart.Chart(title);
            chart.addSlice(20, "Developer 1");
            chart.addSlice(80, "Developer 2");
            zingchart.addChart(chart);

            var graphset = zingchart.getGraphSet();

            var result = javaScriptSerializer.Serialize(graphset);

            string expected = @"{""graphset"":[{""type"":""pie"",""plot"":{""tooltip"":{""text"":""%t""},""valuebox"":{""fontsize"":0,""placement"":""in"",""text"":""%t"",""offsetR"":""30%"",""rules"":[{""rule"":""%v === 0"",""text"":""""}]}},""title"":{""text"":""RBF.CLA"",""fontsize"":10},""series"":[{""values"":[30],""text"":""Developer 1""},{""values"":[70],""text"":""Developer 2""}]},{""type"":""pie"",""plot"":{""tooltip"":{""text"":""%t""},""valuebox"":{""fontsize"":0,""placement"":""in"",""text"":""%t"",""offsetR"":""30%"",""rules"":[{""rule"":""%v === 0"",""text"":""""}]}},""title"":{""text"":""HELLO.CLA"",""fontsize"":10},""series"":[{""values"":[20],""text"":""Developer 1""},{""values"":[80],""text"":""Developer 2""}]}]}";

            Assert.AreEqual(expected, result);
        }
Пример #2
0
        public void ZingChart_ShouldReturnJSON_WhenPieChartAdded()
        {
            var       javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            ZingChart zingchart            = new ZingChart();

            ZingChart.Chart chart = new ZingChart.Chart();

            zingchart.addChart(chart);

            var graphset = zingchart.getGraphSet();

            var result = javaScriptSerializer.Serialize(graphset);

            string expected = @"{""graphset"":[{""type"":""pie"",""plot"":{""tooltip"":{""text"":""%t""},""valuebox"":{""fontsize"":0,""placement"":""in"",""text"":""%t"",""offsetR"":""30%"",""rules"":[{""rule"":""%v === 0"",""text"":""""}]}},""title"":{""text"":"""",""fontsize"":10},""series"":[]}]}";

            Assert.AreEqual(expected, result);
        }