2013-03-29 3 views
0

아래 코드가 있습니다. 각 막대가 여러 datapoints 포함 된 Google 시각화 칼럼 차트를 만들려고합니다. 그러나 시각화 차트가 표시되지 않습니다. ReferenceError : convertToISO가 정의되지 않았습니다. 오류입니까? 도와주세요.시각화 차트가 표시되지 않습니다.

<script type="text/javascript" src="http://google.com/jsapi"></script>  
<script src="/soap/ajax/19.0/connection.js" type="text/javascript" /> 
<script type="text/javascript">  
formatCurrencyLabel = function(value)  
{ 
    return "$" +  String(value); 
} 
google.load("visualization" , "1" , {package:["ColumnChart"]}); 
google.setOnLoadCallback(Chart); 

function Chart() 
{ 
    data.addColumn(‘string’, ‘Timeframe’);   
    data.addColumn(‘number’, ‘Gold’); 
    data.addColumn(‘number’, ‘Platinum’); 
    data.addColumn(‘number’, ‘Millinium’);       
    sforce.connection.sessionId = ‘{!$Api.Session_ID}’; 
    var date = new Date(); 
    var dateMin = date.setMonth(date.getMonth() -13);     
    var date = new Date();     
    var dateMax = date.setMonth(date.getMonth() +1);     
    var soql = "Select id,name,GOLD_Policies_InForce__c, MNS_Policies_InForce__c, 
     PLAT_Policies_InForce__c, Producer_Name__c, Type__c, Producer_Code__c from 
     Analytics__c where Producer_Name__c ='TestABC2' and Period__c ='21' and CreatedDate <" 
     + convertToISO(dateMax) + " and convertToISO(CreatedDate) > " + dateMin + " Order by 
     CreatedDate asc ";     //console.log(soql);   

    result = sforce.connection.query(soql);     
    var it = new sforce.QueryResultIterator(result);   
     while(it.hasNext()) 
    {     
    var record = it.next(); 
      data.addRow(['record.CreatedDate', 
    {v:parseFloat(record.PLAT_Policies_InForce__c), f: 
    formatCurrencyLabel(record.PLAT_Policies_InForce__c)},  
{v:parseFloat(record.PLAT_Policies_InForce__c), f: 
formatCurrencyLabel(record.PLAT_Policies_InForce__c)},   
{v:parseFloat(record.GOLD_Policies_InForce__c), f: 
formatCurrencyLabel(record.GOLD_Policies_InForce__c)}   ]);          
    } 
    var options = {'title':'Policies Inforce Rolling 13 Months' , legend: 'left' ,       
'width':560,      'height':228,      'colors' : 
    ['green','orange','#B5C5D7']     
}; 
    var chart = new google.visualization.ColumnChart(document.getElementById('chart')); 
    chart.draw(data , options); 
};  
</script>  
    <body><div id="chart"></div></body> 

답변

0

문제는 대신 SQL 쿼리의 일부 코드의 다음 줄에, 당신은 자바 스크립트 함수 호출로 convertToISO(dateMax)를 실행하는 데 노력하고 있다는 점이다.

var soql = "Select id,name,GOLD_Policies_InForce__c, MNS_Policies_InForce__c, 
    PLAT_Policies_InForce__c, Producer_Name__c, Type__c, Producer_Code__c from 
    Analytics__c where Producer_Name__c ='TestABC2' and Period__c ='21' and CreatedDate < 
    convertToISO(" + dateMax + ") and convertToISO(CreatedDate) > " + dateMin + " Order by  
    CreatedDate asc "; 
+0

여전히 차트가 표시되지 않는 : 당신은 이러한 기능 때문에 자바 스크립트 엔진은 당신이 수해야

var soql = "Select id,name,GOLD_Policies_InForce__c, MNS_Policies_InForce__c, PLAT_Policies_InForce__c, Producer_Name__c, Type__c, Producer_Code__c from Analytics__c where Producer_Name__c ='TestABC2' and Period__c ='21' and CreatedDate <" + convertToISO(dateMax) + " and convertToISO(CreatedDate) > " + dateMin + " Order by CreatedDate asc "; 

을 정의되지 않은 기능을 실행하려고하고 있다는 불평 정의하지 않은 . 그리고 또한 나는 당신의 질의에 약간의 변경을 가했다. 나는 오류를 얻고있다. var date = new Date(); 변수 날짜가 인수를 다시 선언합니다. 제발 도와주세요. –

관련 문제