专注于网站技术与网络营销的博客
« 谈谈MsChart在如何在ASP中使用Javascript获取屏幕分辩率 »

MsChart条形,饼形显示xml数据示例



[MoneyStatistics.xml]
<?xml version="1.0" encoding="utf-8" ?>
<MoneyStatistics name="财务统计">
    <Money value="1000" name="总计额"/>
    <Money value="2000" name="定金"/>
    <Money value="3000" name="尾款"/>
    <Money value="4000" name="结款"/>
    <Money value="5000" name="收入总计"/>
</MoneyStatistics>

[MoneyStatistics.htm]
<html>
    <head>
        <title>MoneyStatistics</title>
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
        <SCRIPT ID="clientEventHandlersJS" LANGUAGE="javascript">
        function DisplayPage(chartType)
        {
            var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
            var nodeMoneyList;
            var t=0,i=0,j=0;
            xmlDoc.async = false;
            xmlDoc.load("MoneyStatistics.xml");
            nodeMoneyList = xmlDoc.selectNodes("MoneyStatistics//Money");
            mschart6.TitleText = "";
            mschart6.ShowLegend =true;
            mschart6.ColumnCount =nodeMoneyList.length;
            mschart6.RowCount =1;
            for (i=0;i<mschart6.RowCount;i++)
            {
                for (j=0;j<mschart6.ColumnCount;j++)
                {  
                    mschart6.Row=i+1;
                    mschart6.Column=j+1;
                    mschart6.ColumnLabel =

nodeMoneyList.item(j).getAttribute("name") +
                                            

": " + nodeMoneyList.item(j).getAttribute("value")+" RMB";
                    if ((mschart6.ColumnCount*mschart6.RowCount)>1)    

                    
                        mschart6.Data =

nodeMoneyList.item(j).getAttribute("value");
                    else
                        mschart6.Data="";
                    t++;
                }
                if (mschart6.RowCount>1)
                    mschart6.RowLabel ="" ;
                else
                {
                    var rootName = xmlDoc.selectSingleNode

("MoneyStatistics").getAttribute("name");
                    mschart6.RowLabel =rootName;
                }
            }
            mschart6.chartType =chartType;
            mschart6.Plot;
        }
        function switchType(){
            var type=14;
            if (switchPoint.value =="条形图"){
                switchPoint.value="饼状图";
                type=1;
            }
            else{
                switchPoint.value ="条形图";
                type=14;        
            }
            DisplayPage(type);
        }
        </SCRIPT>
    </head>
    <body onload="return DisplayPage(14)">
        <div align="center">
            <INPUT id="switchPoint" type="button" value="条形图"

onclick="switchType()">
            <OBJECT id="mschart6" style="WIDTH: 651px; HEIGHT: 326px"

codeBase="mschart.cab">
        </div>
    </body>
</html>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Powered By Z-Blog 1.8 Devo Build 80201

Copyright 2005 - 2008, 完美生活(专注于网站技术与网络营销的博客). Some Rights Reserved.