我想将动态数据从数据库传递到甜甜圈图

时间:2019-06-01 03:09:09

标签: javascript chart.js

我有一些要动态传递到Chart.js库的甜甜圈图的数据,但是我尝试制作它,但是它不起作用。

  <script>
  var OrganizationsPriceRanges= 
     @Html.Raw(Json.Encode(ViewBag.OrganizationsPriceRanges));
   var PriceRangesList=  @Html.Raw(Json.Encode(ViewBag.PriceRangesList));


       var doughnutData = [
            {
                value: OrganizationsPriceRanges,
                color:["#F7464A","#FDB45C","#4D5360"],
                highlight: "#FF5A5E",
                label: PriceRangesList
            },



        ];


            var ctx = 
           document.getElementById("PriceRanges").getContext("2d");
            window.myDoughnut = new 
       Chart(ctx).Doughnut(doughnutData, {responsive : true});
         </script>

0 个答案:

没有答案