FusionCharts JavaScript API - Functions 常用方法整理笔记
FusionCharts JavaScript API - Functions
Home > FusionCharts XT and JavaScript > API Reference > Functions (官方文档的位置)
返回对图表对象的引用
FusionCharts(chartId: string);
var chartReference =FusionCharts("myChartId");
render图标到DOM元素 详细的的参数可以看官方文档
FusionCharts.render(swfUrl, chartId , width, height, renderAt, dataSource, dataFormat, otherParameters: Object) ;
var myChart =FusionCharts.render({ swfUrl :"FusionCharts/Column3D.swf", id :"myChartId", renderAt :"chartContainer", dataSource :"Data.xml"});
注册全局事件
addEventListener(event:string, listener: function);
FusionCharts.addEventListener("Rendered",function(e,p){ alert(e.sender.id );});
将图表对象渲染到DOM元素 可以通过 ID 或者 HTMLNode
render(renderAt: String) or render(renderAt: HTMLNode)
myChart.render("chartContainer"); or myChart.render(document.getElementById ("chartContainer"));
Returns the JSON data of chart as Object. 获取JSON数据
getJSONData()
var myJSONObj =FusionCharts("myChartId").getJSONData();
设置JSON数据
setJSONData(JSON:Object)
or
setJSONData(JSON:String)
myChart.setJSONData( { "chart":{ "caption":"My Chart Caption" }, "data":[ { "value":"100" }, { "value":"200" } ] } ); myChart.setJSONData('{"chart":{ "caption":"My Chart Caption" }, "data":[ {"value":"100" }, { "value":"200" } ] });
改变图表的大小
resizeTo(width:String, height:String)
myChart.resizeTo("500","400") or myChart.resizeTo("80%","100%")
打印
print()
FusionCharts("myChartId").print();
销毁
dispose()
FusionCharts("myChartId").dispose();
是否加载完成
hasRendered()
克隆
clone( [chartParams: Object] )
var newChart = myChart.clone(); or var newChart = myChart.clone({ swfUrl :'Area2D.swf'});