已以Flash格式实现了Fusion Chart。是否可以将其转换为纯JavaScript形式?如果是,请详细说明操作方法,即在哪里进行更改。

最佳答案

如果您使用的是最新版本的FusionCharts(3.3.0及更高版本),只需将../Column3D.swf替换为Column3D即可解决问题!确保与FusionCharts.HC.js位于同一文件夹中的FusionCharts.HC.Charts.jsFusionCharts.js。您的代码看起来像...

<html>
  <head>
    <title>My First chart using FusionCharts XT - Using pure JavaScript</title>
    <script type="text/javascript" src="../FusionCharts.js"></script>
  </head>
  <body>
    <div id="chartContainer">FusionCharts XT will load here!</div>
    <script type="text/javascript">
       var myChart = new FusionCharts("Column3D", "myChartId", "400", "300");
       myChart.setXMLUrl("Data.xml");
       myChart.render("chartContainer");
    </script>
  </body>
</html>


但是,我还建议使用更具可读性的代码,例如...

<html>
  <head>
    <title>My First chart using FusionCharts XT - Using pure JavaScript</title>
    <script type="text/javascript" src="../FusionCharts.js"></script>
    <script type="text/javascript">
       FusionCharts.addEventListener("ready", function () {
           var myChart = new FusionCharts({
               type: "column3d",
               id: "myChartId",
               width: "400",
               height: "300",
               renderAt: "chartContainer",
               dataSource: "Data.xml",
               dataFormat: "xmlurl"
           }).render();
       });
    </script>
  </head>
  <body>
    <div id="chartContainer">FusionCharts XT will load here!</div>
  </body>
</html>

10-08 15:44