0

我正在使用 fusionCharts 套件中的 fusionmaps。我已经搜索了他们所有的文档和知识库以了解如何做到这一点,但没有运气,所以我正在与你们联系。

我有一个地图(swf 文件),它从 xml 文档中获取数据来构建其数据。在该 xml 中,对于特定实体,我可以进行 javascript 调用。在 swf 所在的文件中,我有我的 JS 和 jquery 库。我最终试图让另一个 swf 文件在 UI 对话框中弹出。如果可能的话,我不知道该怎么做。我弹出对话框,但它是空的。我希望在其中放置的 swf 文件加载在我的其他 swf 文件之上。有什么建议么?

这是我的一些代码。

<script type="text/javascript"><!--
$(document).ready(function() { 
    $("#dialogContainer").dialog({
        bgiframe: true,
        height: 500,
        width: 600,
        modal: true,
        autoOpen: false,
        buttons: { "Close": function() { $(this).dialog("close"); }},
        show: 'fold',
        hide: 'fold'
    });
}); //Close ready function  


function loadDialog(continent) {
    //var url = 'showDetails.cfm?region=' + continent;
    //$("#dialogContainer").html('Loading. Please wait...');
    $.ajax({
        type: "post",
        url: 'showDetails.cfm',
        cache: false,
        //dataType: 'html',
        data: 'region=' + continent,
        beforeSend: function() {$('#dialogContainer').html('Loading. Please wait...').dialog('open');},
        success: function(msg) {$('#dialogContainer').html(msg);},
        error: function(msg) {$('#dialogContainer').html(msg);} 
    });
}

我的 fusionmap 通话

<script type="text/javascript">
var map = new FusionMaps("Maps/FCMap_World8.swf", "Map1Id", "500", "300", "0", "0");
map.setDataURL("WorldData2.xml");
map.render("mapdiv");     
</script>

我知道这是一个很长的问题,但只是希望。感谢您的浏览以及您可能有的任何建议。

克里斯

4

2 回答 2

0

如果您使用 FusionCharts 3.2 之前的版本,您需要将图表的 wmode 设置为不透明或透明。

这里有一个示例可以提供帮助:

http://www.igcomm.com/show/maps/drill/jQuery

这里使用了 3.1 FusionMaps 和 3.1.1 FusionCharts。截图如下:

jQuery 对话框中的 FusionCharts 在单击地图实体后打开为向下钻取

代码如下:

<html>
  <head>
    <!-- Load FusionMaps 3.1 JavaScript wrapper -->
    <script language="JavaScript" src="FusionMaps.js"></script>
    <!-- Load FusionCharts 3.1.1 JavaScript wrapper -->
    <script language="JavaScript" src="FusionCharts.js"></script>
    <!-- Load jQuery UI resources to load jQuery dialog -->
    <link href="jquery.ui/jquery-ui.css" rel="stylesheet" type="text/css" />
    <script src="jquery.ui/jquery.min.js" type="text/javascript"></script>
    <script src="jquery.ui/jquery-ui.min.js" type="text/javascript"></script>
  </head>
  <body>
    <!-- Declare map and chart container DIVs -->
    <div id="mapdiv" align="center">FusionMaps will load here!</div>
    <div id="chartContainer" style="width:300px;height:300px;">FusionCharts will load here!</div>

    <script type="text/javascript"><!--

       // Declare jQuery dialog on the chart container
       var dialog;
       $(document).ready(function() {
            dialog = $('#chartContainer').dialog({
                autoOpen: false,
                width: 340,
                height: 370,
            });
        });

       // Define and render map of World
       // In the XML data of the map each entity is linked to a JavaScript function showChart 
       // where respective entity id is passed
       var map = new FusionMaps("FCMap_World.swf", "Map1Id", "700", "450", "0", "0");
       // set map to opaque mode
       map.setTransparent(false);
       // If you wish you can set map to transparent mode uncommenting the line below
       //map.setTransparent(true);
       map.setDataURL("mapdata.xml");          
       map.render("mapdiv");


      // This function is called when a Map entity is clicked
      // It takes id as parameter where respective entity id is passed         
      function showChart(id)
      {

        // Stores the full name of each entity with resepct to the id
        var mapNames = {"NA" : "Noth America" , "SA" : "South America" , "AS" : "Asia" , "EU" : "Europe", "AF" : "Africa", "AU" : "Australia"};

        // Render chart
        var chart = new FusionMaps("Pie2D.swf", "chartId", "300", "300", "0", "0");

        // Set chart to opaque mode
        chart.setTransparent(false);
        // f you wish you can set chart to transparent mode uncommenting the line below
        //chart.setTransparent(true);

        // In this simple same detailed data for each map is stored in different files
        // The files are named as per the id
        chart.setDataURL(id+"Chart.xml");          
        chart.render("chartContainer");

        // Sets the dialog's title with the full name of the clicked entity
        dialog.dialog( "option", "title", 'Chart of ' + mapNames[id] );
        // Show the jQuery dialog which contains the chart
        dialog.dialog('open');
      }
    // -->   
    </script>
  </body>
</html>

也有源码下载:http ://www.igcomm.com/show/maps/drill/jQuery/download.zip 。

于 2011-06-03T11:20:28.623 回答
0

我可以向您转发在 jQuery 模态窗口(对话框)上呈现 FusionCharts 所需的资源和示例代码。

PowerCharts代码示例文档中已经提出了 FusionCharts 相同(使用 LinkedCharts)功能的一个非常不同的实现。

在 jQuery Dialog 中渲染 FusionCharts 所需的步骤

第 1 步:创建 HTML 对话框容器

在页面的任何地方,创建一个空白 <div> 并为其指定一个唯一 ID。

<div id="chart-container"></div>

第二步:创建 jQuery Dialog 和 FusionCharts 对象

在页面加载(jQuery 文档准备好)时,将之前创建的分区转换为 jQuery 对话框。

<script type="text/javascript"><!--

// 全局可访问的变量供以后使用
var jqDialog;

// 在文档准备好时创建对话框。
$(文档).ready(函数() {
    jqDialog = $('#chart-container').dialog({
        自动打开:假,
        宽度:550,
        身高:320,
        title : 'jQuery 对话框中的 FusionCharts'
    });
});

var myChart = new FusionCharts({
    swfUrl: '图表/Column2D.swf',
    宽度:'100%',高度:'100%',
    renderAt: '图表容器'
});

// --></script>

第 3 步:创建一个函数来加载 FusionCharts

现在,我们创建一个加载 FusionCharts 并打开对话框的 JavaScript 函数。

<script type="text/javascript"><!--

函数 loadChartInDialog () {
    jqDialog.dialog('打开'); // 打开对话框
    myChart.setXMLUrl('Data.xml'); // 设置图表数据
    myChart.render(); // 渲染图表。
}
//--></script>

现在,当需要时,用户可以调用此loadChartInDialog函数来打开对话框并加载图表。

于 2011-03-21T07:49:11.070 回答