1

我正在尝试创建一个示例饼图,该饼图从 Web 服务(vb.net)中获取值,但我被卡住了,因为该图表没有正确创建。

这是我的代码。函数图表(){

     alert("clicked");

     $.ajax({
         type: "POST",
         url: "Service1.asmx/GetChart",
         contentType: "application/json; charset=utf-8",

         data: "{'sDB':'" + "sDB" + "'}",
         dataType: "json",

         success: OnGetMemberSuccess2,
         failure: function (errMsg) {
             $('#errorMessage').text(errMsg);
         }

     });

     function OnGetMemberSuccess2(data, status) {


       //RenderPieChart('container', [['Firefox', 45.0]]);
         RenderPieChart('container', [[data.d]]);
         alert(data.d);

 }


 function RenderPieChart(elementId, dataList) {

         new Highcharts.Chart({
             chart: {
                renderTo: dataList,
                 plotBackgroundColor: null,
                 plotBorderWidth: null,
                 plotShadow: false
             }, title: {
                 text: 'Browser market shares at a specific website, 2010'
             },
             tooltip: {
                 formatter: function () {
                    return '<b>' + this.point.name + '</b>: ' + this.percentage + ' %';
                     alert(tooltip);
                 }
             },
                             plotOptions: {
                                  pie: {
                                      allowPointSelect: true,
                                      cursor: 'pointer',
                                      dataLabels: {
                                          enabled: true,
                                          color: '#000000',
                                          connectorColor: '#000000',
                                          formatter: function () {
                                              return '<b>' + this.point.name + '</b>: ' + this.percentage + ' %';
                                          }
                                      }
                                 }
                              },
             series: [{
                 type: 'pie',
                 name: 'Browser share',
                 data: dataList
             }]
         });
     };
 }

网络服务代码:

    Public Function GetChart(ByVal sDB As String)
    Dim oSB As New StringBuilder

    '  oSB.Insert(42, "Firefox")
    oSB.Append("Firefox")
    oSB.Append(",")
    oSB.Append("45.0")
    'oSB.Append("'Safari', 6.5")
    'oSB.Append("'Opera', 8.2")

    'oSB.Append("'Others', 0.7")

    Return oSB.ToString
End Function

如果我给出,我会创建图表

    RenderPieChart('container', [['Firefox', 45.0]]); 

代替

    RenderPieChart('container', [[data.d]]);

谁能帮我解决这个问题。

干杯。

4

0 回答 0