highcharts + sharepoint 2010 - 呈现空白页面

时间:2016-06-07 12:01:19

标签: javascript jquery sharepoint highcharts sharepoint-2010

我在使用SP服务的sharepoint 2010中使用highcharts时遇到问题;由于某种原因,我根本无法渲染图表,而是留下了一个完全空白的页面。我试图擦除代码的错误,但似乎无法找到任何明显的。我已经使用自己的代码进行了测试,并且拥有相同的空白页面,现在我们已经尝试使用他们注意到在他们的环境中工作的其他人,这产生了相同的结果。任何见解都会非常感激。提前谢谢你。

<script type="text/javascript">
$(document).ready(function() {
  $().SPServices({
    operation: "GetListItems",
    CAMLQuery: "<Query><OrderBy><FieldRef Name='Phase'/></OrderBy></Query>",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title'/></ViewFields>",
    listName: "{5C783CEC-4E49-4DAD-B833-CD1F049C114D}",
    completefunc: processData
  });


function processData(xData, status) {
  var progData = [];

  $(xData.responseXML).SPFilterNode("z:row").each(function() {
    progData.push({
      project: $(this).attr('ows_Title'),
      phase: $(this).attr('ows_Phase'),
      status: $(this).attr('ows_Status'),

    });
  });

  var chartData = [];
  var phaseData = _.groupBy(progData, 'phase');

  _.each(phaseData, function(row) {
    var phaseCount = row.length;

    chartData.push({
      name: row[0].phase,
      y: phaseCount
    });

  });

  renderChart(chartData);
});

function renderChart(data) {
  var chart = new Highcharts.Chart({
    chart: {
      renderTo: 'programchart',
      plotBackgroundColor: null,
      plotBorderWidth: null,
      plotShadow: false
    },
    credits: {
      enabled: true
    },
    title: {
      text: 'Program by Phase'
    },
    plotOptions: {
      pie: {
        allowPointSelect: true,
        cursor: 'pointer',
        dataLabels: {
          enabled: true,
          color: '#000000',
          connectorColor: '#000000',
          formatter: function() {
            return '<b>' + this.point.name + '</b>: ' + this.y + ' Times';
          }
        },
      }
    },
    series: [{
      type: 'pie',
      name: 'Phase Count',
      data: data
    }]
  });
});



});

</script>
<div id="programchart"></div>

如果它有所作为,我使用的是jquery 1.8和spservices 2014。

0 个答案:

没有答案