<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>无标题页</title>

<script type="text/javascript" src="../FusionCharts/FusionCharts.js"></script>
<script type="text/javascript" src="../FusionCharts/FusionChartsExportComponent.js"></script>
<script type="text/javascript">
   function FC_ExportReady(DOMId)
   {    
        if( getChartFromId("fcExporter1") && getChartFromId("fcExporter1").isReady && getChartFromId("fcExporter1").isReady())
        {
            return;
        }    
        var myExportComponent = new FusionChartsExportObject("fcExporter1", "../FusionCharts/FCExporter.swf");
        myExportComponent.componentAttributes.saveMode='individual';
        myExportComponent.componentAttributes.showAllowedTypes = '1';
        myExportComponent.componentAttributes.width = '200';
        myExportComponent.componentAttributes.height = '100';
        myExportComponent.Render("fcExportDiv");
   }
</script>
<script type="text/javascript">
    function exportHandler()
    {
    
        if( getChartFromId("fcExporter1") && getChartFromId("fcExporter1").isReady && getChartFromId("fcExporter1").isReady())
        {
            getChartFromId("fcExporter1").reset();
        }

        var chart = FusionCharts("chart1Id");
        if (chart.hasRendered() == true){
            chart.exportChart();
        }else{
            alert("Please wait for the chart to finish rendering before you can invoke exporting");
        }
    }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
         <div style="text-align:center;" id="clientSideChart" >Loading Chart</div>
      <p align="center"><input type="button" class="button" onclick="exportHandler();" value="Export Chart" style="display:none;" /></p>
      <div id="fcExportDiv" align="center" >&nbsp;</div>
        </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>
     <input type='button' value='Column' onclick="javaScript:updateChart('../FusionCharts/Column3D.swf');" name='btnColumn' />        

      <input type='button' value='Line' onclick="javaScript:updateChart('../FusionCharts/Line.swf');" name='btnLine' />        

      <input type='button' value='Pie' onclick="javaScript:updateChart('../FusionCharts/Pie3D.swf');" name='btnPie' />  
        <input type='button' value='Area2D' onclick="javaScript:updateChart('../FusionCharts/Area2D.swf');" name='btnArea2D' />  
        <input type='button' value='Doughnut3D' onclick="javaScript:updateChart('../FusionCharts/Doughnut3D.swf');" name='btnDoughnut3D' />  
        <input type='button' value='Pareto3D' onclick="javaScript:updateChart('../FusionCharts/Pareto3D.swf');" name='btnPareto3D' /> 
        <input type='button' value='SSGrid' onclick="javaScript:updateChart('../FusionCharts/SSGrid.swf');" name='btnSSGrid' /> 
        <input type='button' value='Bar2D' onclick="javaScript:updateChart('../FusionCharts/Bar2D.swf');" name='btnBar2D' /> 
        <input type='button' value='Column2D' onclick="javaScript:updateChart('../FusionCharts/Column2D.swf');" /> 
         <input type='button' value='Doughnut2D' onclick="javaScript:updateChart('../FusionCharts/Doughnut2D.swf');" /> 
         <input type='button' value='Pie2D' onclick="javaScript:updateChart('../FusionCharts/Pie2D.swf');" /> 
         <input type='button' value='Spline' onclick="javaScript:updateChart('../FusionCharts/Spline.swf');" />
          <input type='button' value='SplineArea' onclick="javaScript:updateChart('../FusionCharts/SplineArea.swf');" />
           <input type='button' value='Pyramid' onclick="javaScript:updateChart('../FusionCharts/Pyramid.swf');" />
            <input type='button' value='Funnel' onclick="javaScript:updateChart('../FusionCharts/Funnel.swf');" />
        </ContentTemplate>
        </asp:UpdatePanel>
<script type="text/javascript" >
 function updateChart(chartSWF){        
var chart1 = new FusionCharts(chartSWF, "chart1Id", "600", "400", "0", "1");
    //var chart1 = new FusionCharts("../FusionCharts/Column3D.swf", "chart1Id", "600", "400", "0", "1");
    chart1.setDataXML("<%=CreateCharts() %>");
//    chart1.setXMLUrl("Data/dataclient.xml");
    chart1.render("clientSideChart");
    }
</script>

 </div>
<!-- Google Analytics Tracker Code Starts -->
<%--<script type="text/javascript">
// analytics
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost 
    + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
if (typeof(_gat) == "object") {
    var pageTracker = _gat._getTracker("UA-215295-3"); pageTracker._initData(); pageTracker._trackPageview();
}
</script>--%>
   
    </form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public string CreateCharts()
    {
        //labelDisplay='ROTATE' :X轴标签对齐方式为旋转。
//slantLabels='1' :仅当labelDisplay='ROTATE'时该属性才有效,这个属性设置标签显示为倾斜或完全垂直。(1表示倾斜、0表示垂直)
        string strXML;
        strXML = "";
        strXML += "<graph caption='FusionChartsDemo' xAxisName='月份' yAxisName='个数' decimalPrecision='0' formatNumberScale='0' exportEnabled='1' exportAtClient='1' exportHandler='fcExporter1'  baseFontSize ='13' labelDisplay='ROTATE' slantLabels='1' >";
        strXML += "<set name='一月' value='462' color='AFD8F8' />";
        strXML += "<set name='二月' value='857' color='F6BD0F' />";
        strXML += "<set name='三月' value='671' color='8BBA00' />";
        strXML += "<set name='四月' value='494' color='FF8E46'/>";
        strXML += "<set name='五月' value='761' color='008E8E'/>";
        strXML += "<set name='六月' value='960' color='D64646'/>";
        strXML += "<set name='契约' value='629' color='8E468E'/>";
        strXML += "<set name='八月' value='622' color='588526'/>";
        strXML += "<set name='九月' value='376' color='B3AA00'/>";
        strXML += "<set name='十月' value='494' color='008ED6'/>";
        strXML += "<set name='十一月' value='761' color='9D080D'/>";
        strXML += "</graph>";
        return strXML;

    }
}

 

 posted on 2012-05-18 17:22  纳米程序员  阅读(4589)  评论(0编辑  收藏  举报