SCRIPT1007:预期']'错误

时间:2014-08-13 09:06:37

标签: highcharts

显示Highcharts时出错。错误是:SCRIPT1007:预期']'在第47行,字符4.按下我的头几个小时并试图解决但没有运气:(。真的很感激帮助。谢谢你。詹姆斯

   ==== Class ===

public class HighChartsController3
{
  public String[] total;
  public String[] gettotal()
  {
     String q = 'SELECT count(Id),Name Total FROM Account group by Name';
     AggregateResult[] agr =Database.query(q);
     String[] strarray = new String[agr.size()];
     for (AggregateResult ar : agr)  
     {
         strarray.add(String.valueof(ar.get('Total')));

     }             

     return strarray ;
   } 


 public String[] position;
 public String[] getposition()
 {

     String q = 'SELECT count(Id),Name FROM Opportunity group by Name';
     AggregateResult[] agr =Database.query(q);
     String[] strarray = new String[agr.size()];

      for (AggregateResult ar : agr) 
      {
         strarray.add(string.valueOf(ar.get('Name')));
     }

     return strarray ;
     }
   }


    === Page ===



  <apex:page controller="HighChartsController3">
  <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" />
  <script src="https://code.highcharts.com/highcharts.js"></script>
  <script src="https://code.highcharts.com/modules/exporting.js"></script>

   <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

  <Script>
    $(function () {
     $('#container').highcharts({
     chart: {
        type: 'column'
    },

    title: {
        text: 'Total # of Apllications vs # of Open Jobs'
    },

    xAxis: { 
     categories: {!position}
    // categories: ['abc','parth','hello']         

    },

    yAxis: {
        allowDecimals: false,
        min: 0,
        title: {
            text: 'Number'
        }
    },

    tooltip: {
        formatter: function () {
            return '<b>' + this.x + '</b><br/>' +
                this.series.name + ': ' + this.y + '<br/>' +
                'Total: ' + this.point.stackTotal;
        }
    },

    plotOptions: {
        column: {
            stacking: 'normal'
        }
    },

    series: [{
        name: 'New',
        data: [5, 3, 4, 7, 2],
        stack: 'Application'
    }, {
        name: 'Schedule Interviews',
        data: [3, 4, 4, 2, 5],
        stack: 'Application'
    }, {
        name: 'Hired',
        data: [3, 4, 4, 2, 5],
        stack: 'Application'
    },{
        name: 'Rejected',
        data: [3, 4, 4, 2, 5],
        stack: 'Application'
    },

      {
        name : 'Total Applications',
        data : {!total}            
        //data : [100,200,300],
        stack : 'Total'
        }]
      });
   });

  </script>
 </apex:page>

0 个答案:

没有答案