forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morr...@apache.org
Subject cvs commit: xml-forrest/charts GUMP-graph.xsl GUMP-sampledata.xml
Date Sat, 23 Feb 2002 15:44:23 GMT
morrijr     02/02/23 07:44:23

  Added:       charts   GUMP-graph.xsl GUMP-sampledata.xml
  Log:
  Possible graphs for GUMP builds?
  
  Revision  Changes    Path
  1.1                  xml-forrest/charts/GUMP-graph.xsl
  
  Index: GUMP-graph.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xlink="http://www.w3.org/1999/xlink">
  
  <xsl:variable name="graph_width">500</xsl:variable>
  <xsl:variable name="graph_height">150</xsl:variable>
  <xsl:variable name="graph_margin">50</xsl:variable>
  
  <xsl:variable name="num_points" select="count(/graph/data/datum)"/>
  
  <xsl:variable name="x_scale" select="$graph_width div ($num_points - 1)"/>
  <xsl:variable name="y_scale" select="$graph_height div 100"/>
  
  <xsl:template match="graph">
    <svg
      width="{$graph_margin + $graph_width + $graph_margin}"
      height="{$graph_margin + $graph_height + $graph_margin}">
  
      <title>Forrest GUMP Graphing</title>
  
      <style type="text/css">
        text {
          font-family: 'Verdana';
          font-size: 10px;
          stroke: none;
          fill: #000088; }
        .tick {
          fill:none;
          stroke: #000088;
          stroke-width: 1px; }
        #border {
          fill: rgb(0,192,0);
          stroke: #000088;
          stroke-width: 1px; }
        #graph-dependancy {
          fill: rgb(255,255,90);
          stroke: #000088;
          stroke-width: 1px; }
        #graph-failed {
          fill: rgb(255,0,0);
          stroke: #000088;
          stroke-width: 1px; }
        #horizontalRuler {
          fill: #000088; }
      </style>
  
      <defs>
        <line id="week" class="tick" x1="0" y1="0" x2="0" y2="3"/>
        <line id="month" class="tick" x1="0" y1="0" x2="0" y2="5"/>
      </defs>
  
      <xsl:apply-templates select="data"/>
  
    </svg>
  </xsl:template>
  
  <xsl:template match="data">
    <g transform="translate({$graph_margin} {$graph_margin})">
  
      <rect id="border" x="0" y="0" width="{$graph_width}" height="{$graph_height}"/>
  
      <g id="graph" transform="matrix(1 0 0 -1 0 {$graph_height})">
        <!-- Those projects which failed due to a dependancy problem -->
        <xsl:variable name="dependancy">
          <xsl:value-of select="$graph_width"/><xsl:text>,0 0,0</xsl:text>
          <xsl:for-each select="datum">
            <xsl:text> </xsl:text>
            <xsl:value-of select="(position() - 1) * $x_scale"/>
            <xsl:text>,</xsl:text>
            <xsl:value-of select="(@dependancy + @failed) * ($graph_height div (@passed
+ @dependancy + @failed))"/>
          </xsl:for-each>
        </xsl:variable>
        <polygon id="graph-dependancy" points="{$dependancy}"/>
  
        <!-- Those projects which failed to compile -->
        <xsl:variable name="failed">
          <xsl:value-of select="$graph_width"/><xsl:text>,0 0,0</xsl:text>
          <xsl:for-each select="datum">
            <xsl:text> </xsl:text>
            <xsl:value-of select="(position() - 1) * $x_scale"/>
            <xsl:text>,</xsl:text>
            <xsl:value-of select="@failed * ($graph_height div (@passed + @dependancy +
@failed))"/>
          </xsl:for-each>
        </xsl:variable>
        <polygon id="graph-failed" points="{$failed}"/>
      </g>
  
      <g id="horizontalRuler">
        <g transform="matrix(1 0 0 -1 0 {$graph_height - 2})">
          <xsl:for-each select="datum">
            <use x="{(position() -1) * $x_scale}" xlink:href="#week"/>
          </xsl:for-each>
        </g>
        <!-- Question: how do we 'translate' weeks into a month? -->
      </g>
    </g>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  1.1                  xml-forrest/charts/GUMP-sampledata.xml
  
  Index: GUMP-sampledata.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <graph>
    <data>
      <datum week="2001-23" passed="100" dependancy="0" failed="0"/>
      <datum week="2001-24" passed="0" dependancy="100" failed="0"/>
      <datum week="2001-25" passed="0" dependancy="0" failed="100"/>
      <datum week="2001-26" passed="33.3" dependancy="33.3" failed="33.3"/>
      <datum week="2001-27" passed="100" dependancy="46" failed="25"/>
      <datum week="2001-28" passed="100" dependancy="43" failed="1"/>
      <datum week="2001-29" passed="100" dependancy="6" failed="2"/>
      <datum week="2001-30" passed="100" dependancy="14" failed="41"/>
      <datum week="2001-31" passed="100" dependancy="13" failed="10"/>
      <datum week="2001-32" passed="100" dependancy="1" failed="12"/>
      <datum week="2001-33" passed="100" dependancy="1" failed="1"/>
      <datum week="2001-34" passed="100" dependancy="2" failed="23"/>
      <datum week="2001-35" passed="100" dependancy="4" failed="3"/>
      <datum week="2001-36" passed="100" dependancy="4" failed="2"/>   
    </data>
  </graph>
  
  
  

Mime
View raw message