2014-03-26 54 views
1

什麼是打印在Grails的一個XML字符串在這種情況下,最好的辦法:在Grails中將xml字符串打印到FusionCharts的最佳方法是什麼?

控制器DashboardController.groovy:

package vs3 

//import vs3.Navbar 

class DashboardController { 
    def index() {  
     def sinistralidadePSChartData = new String()   
     sinistralidadePSChartData = '<chart labelStep="2" caption="Monthly Report" subCaption="Unique Visitors" yAxisName="Visitor Count" xAxisName="Date" showValues="0" showShadow="0" formatNumberScale="0" showLimits="0" canvasBorderAlpha="0" showBorder="0" divLineAlpha="30" anchorRadius="4" anchorBgColor="0377D0" anchorBorderColor="FFFFFF" anchorBorderThickness="1" anchorAlpha="90" showPlotBorder="1" plotBorderThickness="4" plotBorderColor="0377D0" plotFillColor="0377D0" plotGradientColor="" plotFillAlpha="20" bgColor="FFFFFF" showAlternateHGridColor="0" numVDivLines="2" toolTipBgColor ="DEF1FF" toolTipBorderColor ="2C516D"><set label="1 March 2014" value="490" /><set label="2 March 2014" value="510" /><set label="3 March 2014" value="1546" /><set label="4 March 2014" value="1250" /><set label="5 March 2014" value="1000" /><set label="6 March 2014" value="540" /><set label="7 March 2014" value="560" /><set label="8 March 2014" value="580" /><set label="9 March 2014" value="600" /><set label="10 March 2014" value="620" /><set label="11 March 2014" value="640" /><set label="12 March 2014" value="660" /><set label="13 March 2014" value="680" /><set label="14 March 2014" value="700" /></chart>'   
     render(view:'/templates/dashboard',model:[sinistralidadePSChartData:sinistralidadePSChartData]) 
    } 
} 

查看/模板:

<g:applyLayout name="page"> 
    <h3>Dashboard</h3> 

    <script type="text/javascript" src="/vs3/FusionCharts_XT_Evaluation/Charts/FusionCharts.js"></script>  

    <div id="chartdiv" align="left">Chart will load here</div> 

    <script type="text/javascript"> 
     var chart = new FusionCharts("Area2D", "ChartId","580", "400", "0", "0");   
     chart.setXMLData('${sinistralidadePSChartData}'); 
     chart.render("chartdiv"); 
    </script> 

    <g:link url="/vs3">Voltar</g:link> 
</g:applyLayout> 

但它根本無法打印所有報價,我可以有一個嚴重的xml /字符串嚴重打印在我的網頁中,例如:

chart.setXMLData('&lt;chart labelStep=&quot;2&quot; caption=&quot;Monthly Report&quot; subCaption=&quot;Unique Visitors&quot; (...) 

我該如何處理這個問題?

+1

你的意思是這樣的:'chart.setXMLData( '$ {原料(sinistralidadePSChartData)}') ;' –

+0

沒錯。非常感謝你! –

+1

酷:-)添加爲答案,並鏈接到更多選項。祝你好運! –

回答

3

如果你需要的原始未經輸出,你可以這樣做:

chart.setXMLData('${raw(sinistralidadePSChartData)}'); 

See here for more options :-)

相關問題