新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论SVG, GML, X3D, VRML, VML, XAML, AVALON, Batik等基于XML的图形技术,以及有关GIS的应用。
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - 高级XML应用『 SVG/GML/VRML/X3D/XAML 』 → 各位高手清出招(在线等)无法正常显示直方图qq:383743748 msn:leomayleomay@hotmail.com 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 2771 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 各位高手清出招(在线等)无法正常显示直方图qq:383743748 msn:leomayleomay@hotmail.com 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     leomay 帅哥哟,离线,有人找我吗?
      
      
      等级:大二期末(数据结构考了98分!)
      文章:55
      积分:354
      门派:XML.ORG.CN
      注册:2005/2/14

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给leomay发送一个短消息 把leomay加入好友 查看leomay的个人资料 搜索leomay在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 点击这里发送电邮给leomay 引用回复这个贴子 回复这个贴子 查看leomay的博客楼主
    发贴心情 各位高手清出招(在线等)无法正常显示直方图qq:383743748 msn:leomayleomay@hotmail.com

    XSL文件
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="xml" indent="yes" encoding="UTF-8" version="1.0" standalone="no" media-type="image/svg+xml"/>

    <xsl:variable name="bar_width" select="number(80)"/>

    <xsl:variable name="bar_spacing" select="number(10)"/>

    <xsl:variable name="graph_height" select="number(500)"/>

    <xsl:variable name="left_margin" select="number(100)"/>

    <xsl:template match="/">

    <svg id="body" viewBox="0 0 -100 {$graph_height + 100}">

    <script type="text/ECMAScript">
    <![CDATA[
    function On_MouseOver(evt,HideShow_ID){

    var target = evt.getTarget();
    var doc = target.getOwnerDocument();  
    var HideShow = doc.getElementById(HideShow_ID);
    HideShow.setAttribute('style', 'visibility:visible');
    }
    function On_MouseOut(evt,HideShow_ID){
    var target = evt.getTarget();
    var doc = target.getOwnerDocument();
    var HideShow = doc.getElementById(HideShow_ID);
    HideShow.setAttribute('style', 'visibility:hidden');
    }
    ]]>
    </script>
    <title>BarChart</title>

    <g id="barChart" transform="translate(10, 10)" fill-rule="nonzero" clip-rule="nonzero" stroke="none" class="legend"
    stroke-width="1" stroke-linecap="square" stroke-miterlimit="1" style="text-anchor:start" shape-rendering="crispEdges">

    <xsl:apply-templates select="sales_summary"/>
    <text text-anchor="middle" transform="matrix(2 0 0 2{$left_margin + 150} {$graph_height + 70})">Month Sale Record of the company</text>
    </g>
    </svg>
    </xsl:template>

    <xsl:template match="sales_summary">

    <xsl:variable name="weeks_count" select="count(Month_sales)"/>

    <xsl:variable name="max_week_sales_value">
    <xsl:for-each select="Month_sales">
    <xsl:sort select="sum(product_sales/@value)" data-type="number" order="descending"/>
    <xsl:if test="position() = 1">
    <xsl:value-of select="sum(product_sales/@value)"/>
    </xsl:if>
    </xsl:for-each>
    </xsl:variable>

    <xsl:variable name="max_graph_height" select="floor(($max_week_sales_value + 99) div 100) * 100"/>

    <xsl:call-template name="draw_graph">
    <xsl:with-param name="max_graph_height" select="$max_graph_height"/>
    <xsl:with-param name="bar_count" select="$weeks_count"/>
    </xsl:call-template>

    <xsl:apply-templates select="Month_sales">
    <xsl:sort select="Month_sales/@Month_no" data-type="number"/>
    <xsl:with-param name="max_graph_height" select="$max_graph_height"/>
    </xsl:apply-templates>
    </xsl:template>

    <xsl:template name="draw_graph">
    <xsl:param name="max_graph_height"/>
    <xsl:param name="bar_count"/>
    <xsl:variable name="actual_width" select="($bar_count * ($bar_width + $bar_spacing)) + $bar_spacing"/>
    <g id="GridAndLegend" style="stroke:#00FF00;" shape-rendering="crispEdges" stroke-width="1">

    <path fill="rgb(255, 235, 205)" stroke="#000099" d="M {$left_margin},{$graph_height + 20} h{$actual_width} v-{$graph_height + 10} h-{$actual_width} v{$graph_height +10}"/>

    <path fill="none" stroke="#FF0000" d="M {$left_margin - 10},{$graph_height + 20} h10"/>
    <text text-anchor="end" baseline-shift="-3" transform="matrix(1 0 0 1 {$left_margin - 15} {$graph_height + 20})">0</text>

    <xsl:call-template name="draw_graph_vertical_legends">
    <xsl:with-param name="max" select="$max_graph_height"/>
    <xsl:with-param name="legend_threshold" select="$max_graph_height div $graph_height"/>
    <xsl:with-param name="actual_width" select="$actual_width"/>
    </xsl:call-template>
    </g>
    </xsl:template>

    <xsl:template name="draw_graph_vertical_legends">
    <xsl:param name="max"/>
    <xsl:param name="legend_threshold"/>
    <xsl:param name="actual_width"/>

    <xsl:param name="start" select="number(100)"/>
    <xsl:param name="step" select="number(100)"/>
    <xsl:param name="prev_marked_start" select="number(0)"/>

    <xsl:variable name="prev_vert_posn" select="($prev_marked_start div $max) * $graph_height"/>
    <xsl:variable name="vert_posn" select="($start div $max) * $graph_height"/>

    <xsl:variable name="new_marked_start">
    <xsl:choose>
    <xsl:when test="($vert_posn - $prev_vert_posn) >= $legend_threshold">
    <xsl:value-of select="$start"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$prev_marked_start"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>

    <xsl:if test="$new_marked_start = $start">
    <path fill="none" stroke="#FF0000" d="M {$left_margin - 10},{$graph_height + 20 - floor($vert_posn)} h{$actual_width + 10}"/>
    <text text-anchor="end" baseline-shift="-3" transform="matrix(1 0 0 1 {$left_margin - 15} {$graph_height + 20 - floor($vert_posn)})">
    <xsl:value-of select="$start"/>
    </text>
    </xsl:if>

    <xsl:if test="$start &lt; $max">
    <xsl:call-template name="draw_graph_vertical_legends">
    <xsl:with-param name="max" select="$max"/>
    <xsl:with-param name="legend_threshold" select="$legend_threshold"/>
    <xsl:with-param name="actual_width" select="$actual_width"/>
    <xsl:with-param name="start" select="$start + $step"/>
    <xsl:with-param name="step" select="$step"/>
    <xsl:with-param name="prev_marked_start" select="$new_marked_start"/>
    </xsl:call-template>
    </xsl:if>
    </xsl:template>

    <xsl:template match="Month_sales">
    <xsl:param name="max_graph_height"/>

    <xsl:variable name="sales_value" select="sum(product_sales/@value)"/>
    <xsl:variable name="bar_height" select="floor(($sales_value div $max_graph_height) * $graph_height)"/>
    <xsl:variable name="bar_left" select="((position() - 1) * ($bar_width + $bar_spacing)) + $bar_spacing"/>

    <path fill="#0066FF" stroke="none" d="M {$bar_left + $left_margin},{$graph_height + 19} h{$bar_width} v-{$bar_height} h-{$bar_width} v{$bar_height}"
    onmouseover="On_MouseOver(evt,'HideShow_{Month_sales/@Month_no}')" onmouseout="On_MouseOut(evt,'HideShow_{Month_sales/@Month_no}')"/>

    <text text-anchor="middle" transform="matrix(1.5 0 0 1.5 {$left_margin + $bar_left + ($bar_width div 2)} {$graph_height + 40})">
    <xsl:value-of select="Month_sales/@Month_no"/>
    <xsl:text>Month</xsl:text>
    </text>

    <g id="HideShow_{Month_sales/@Month_no}" style="visibility: hidden;">

    <path fill="none" stroke="red" d="M {$left_margin - 10},{$graph_height + 20 - $bar_height} h{$bar_left + 10}"/>

    <text transform="matrix(1 0 0 1 {$left_margin + $bar_left + 2} {($graph_height + 30) - $bar_height})">
    <xsl:value-of select="format-number($sales_value,'#,##0')"/>
    </text>
    </g>
    </xsl:template>
    </xsl:stylesheet>


    xml文件
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="C:\Inetpub\wwwroot\XSLTToGraph.xsl"?>
    <sales_summary>
    <Month_sales Month_no="1">
    <product_sales product_id="PC_INTEL_001" quantity="5" value="5000.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="1500.00"/>
    </Month_sales>
    <Month_sales Month_no="2">
    <product_sales product_id="PC_INTEL_001" quantity="4" value="4000.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="3000.00"/>
    <product_sales product_id="PC_AMD_001" quantity="20" value="1500.00"/>
    <product_sales product_id="PC_AMD_002" quantity="20" value="1800.00"/>
    <product_sales product_id="PC_DIGITAL_001" quantity="11" value="50.00"/>
    <product_sales product_id="PC_DIGITAL_002" quantity="18" value="600.00"/>
    </Month_sales>
    <Month_sales Month_no="3">
    <product_sales product_id="PC_INTEL_001" quantity="4" value="4000.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="3000.00"/>
    <product_sales product_id="PC_AMD_001" quantity="20" value="1500.00"/>
    <product_sales product_id="PC_AMD_002" quantity="20" value="1800.00"/>
    <product_sales product_id="PC_DIGITAL_001" quantity="11" value="50.00"/>
    <product_sales product_id="PC_DIGITAL_002" quantity="18" value="600.00"/>
    </Month_sales>
    <Month_sales Month_no="4">
    <product_sales product_id="PC_INTEL_001" quantity="4" value="4000.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="3000.00"/>
    <product_sales product_id="PC_AMD_001" quantity="20" value="1500.00"/>
    <product_sales product_id="PC_AMD_002" quantity="20" value="1800.00"/>
    <product_sales product_id="PC_DIGITAL_001" quantity="11" value="50.00"/>
    <product_sales product_id="PC_DIGITAL_002" quantity="18" value="600.00"/>
    </Month_sales>
    <Month_sales Month_no="5">
    <product_sales product_id="PC_INTEL_001" quantity="4" value="4000.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="3000.00"/>
    <product_sales product_id="PC_AMD_001" quantity="20" value="1500.00"/>
    <product_sales product_id="PC_AMD_002" quantity="20" value="1800.00"/>
    <product_sales product_id="PC_DIGITAL_001" quantity="11" value="50.00"/>
    <product_sales product_id="PC_DIGITAL_002" quantity="18" value="600.00"/>
    </Month_sales>
    <Month_sales Month_no="6">
    <product_sales product_id="PC_INTEL_001" quantity="4" value="4000.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="3000.00"/>
    <product_sales product_id="PC_AMD_001" quantity="20" value="1500.00"/>
    <product_sales product_id="PC_AMD_002" quantity="20" value="1800.00"/>
    <product_sales product_id="PC_DIGITAL_001" quantity="11" value="50.00"/>
    <product_sales product_id="PC_DIGITAL_002" quantity="18" value="600.00"/>
    </Month_sales>
    <Month_sales Month_no="7">
    <product_sales product_id="PC_INTEL_001" quantity="4" value="4000.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="3000.00"/>
    <product_sales product_id="PC_AMD_001" quantity="20" value="1500.00"/>
    <product_sales product_id="PC_AMD_002" quantity="20" value="1800.00"/>
    <product_sales product_id="PC_DIGITAL_001" quantity="11" value="50.00"/>
    <product_sales product_id="PC_DIGITAL_002" quantity="18" value="600.00"/>
    </Month_sales>
    <Month_sales Month_no="8">
    <product_sales product_id="PC_INTEL_001" quantity="4" value="4000.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="3000.00"/>
    <product_sales product_id="PC_AMD_001" quantity="20" value="1500.00"/>
    <product_sales product_id="PC_AMD_002" quantity="20" value="1800.00"/>
    <product_sales product_id="PC_DIGITAL_001" quantity="11" value="50.00"/>
    <product_sales product_id="PC_DIGITAL_002" quantity="18" value="600.00"/>
    </Month_sales>
    <Month_sales Month_no="9">
    <product_sales product_id="PC_INTEL_001" quantity="4" value="4000.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="3000.00"/>
    <product_sales product_id="PC_AMD_001" quantity="20" value="1500.00"/>
    <product_sales product_id="PC_AMD_002" quantity="20" value="1800.00"/>
    <product_sales product_id="PC_DIGITAL_001" quantity="11" value="50.00"/>
    <product_sales product_id="PC_DIGITAL_002" quantity="18" value="600.00"/>
    </Month_sales>
    <Month_sales Month_no="10">
    <product_sales product_id="PC_INTEL_001" quantity="4" value="4000.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="3000.00"/>
    <product_sales product_id="PC_AMD_001" quantity="20" value="1500.00"/>
    <product_sales product_id="PC_AMD_002" quantity="20" value="1800.00"/>
    <product_sales product_id="PC_DIGITAL_001" quantity="11" value="50.00"/>
    <product_sales product_id="PC_DIGITAL_002" quantity="18" value="600.00"/>
    </Month_sales>
    <Month_sales Month_no="11">
    <product_sales product_id="PC_INTEL_001" quantity="4" value="4000.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="3000.00"/>
    <product_sales product_id="PC_AMD_001" quantity="20" value="1500.00"/>
    <product_sales product_id="PC_AMD_002" quantity="20" value="1800.00"/>
    <product_sales product_id="PC_DIGITAL_001" quantity="11" value="50.00"/>
    <product_sales product_id="PC_DIGITAL_002" quantity="18" value="600.00"/>
    </Month_sales>
    <Month_sales Month_no="12">
    <product_sales product_id="PC_INTEL_001" quantity="56" value="200.00"/>
    <product_sales product_id="PC_INTEL_002" quantity="10" value="500.00"/>
    <product_sales product_id="PC_AMD_001" quantity="61" value="1500.00"/>
    <product_sales product_id="PC_AMD_002" quantity="8" value="2100.00"/>
    <product_sales product_id="PC_DIGITAL_001" quantity="2" value="500.00"/>
    <product_sales product_id="PC_DIGITAL_002" quantity="6" value="1200.00"/>
    </Month_sales>
    </sales_summary>

    无法正常显示直方图


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/6/11 14:32:00
     
     leomay 帅哥哟,离线,有人找我吗?
      
      
      等级:大二期末(数据结构考了98分!)
      文章:55
      积分:354
      门派:XML.ORG.CN
      注册:2005/2/14

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给leomay发送一个短消息 把leomay加入好友 查看leomay的个人资料 搜索leomay在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 点击这里发送电邮给leomay 引用回复这个贴子 回复这个贴子 查看leomay的博客2
    发贴心情 
    没人回贴,郁闷中。。。。。。。。。。。。。。
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/6/14 8:55:00
     
     leomay 帅哥哟,离线,有人找我吗?
      
      
      等级:大二期末(数据结构考了98分!)
      文章:55
      积分:354
      门派:XML.ORG.CN
      注册:2005/2/14

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给leomay发送一个短消息 把leomay加入好友 查看leomay的个人资料 搜索leomay在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 点击这里发送电邮给leomay 引用回复这个贴子 回复这个贴子 查看leomay的博客3
    发贴心情 
    who can help me??
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/6/14 10:24:00
     
     leomay 帅哥哟,离线,有人找我吗?
      
      
      等级:大二期末(数据结构考了98分!)
      文章:55
      积分:354
      门派:XML.ORG.CN
      注册:2005/2/14

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给leomay发送一个短消息 把leomay加入好友 查看leomay的个人资料 搜索leomay在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 点击这里发送电邮给leomay 引用回复这个贴子 回复这个贴子 查看leomay的博客4
    发贴心情 
    快崩溃了
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/6/14 10:25:00
     
     leomay 帅哥哟,离线,有人找我吗?
      
      
      等级:大二期末(数据结构考了98分!)
      文章:55
      积分:354
      门派:XML.ORG.CN
      注册:2005/2/14

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给leomay发送一个短消息 把leomay加入好友 查看leomay的个人资料 搜索leomay在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 点击这里发送电邮给leomay 引用回复这个贴子 回复这个贴子 查看leomay的博客5
    发贴心情 
    give me a chance ,back u a miracle
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/6/14 10:26:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 SVG/GML/VRML/X3D/XAML 』的所有贴子 点击这里发送电邮给Google AdSense 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2025/7/25 11:36:58

    本主题贴数5,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    7,375.000ms