2016-11-15 18 views
0

我想用SVG做折線圖。我有一個bug.xml,我想用一個bug.xsl來描述它,並使用SVG來做一個折線圖。我已經設法做到了,但我不能用一個變量來輸入座標。我在谷歌搜索它,但我不知道如何去做。 這裏是我的.xml:如何使用SVG和XSL做折線圖

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<?xml-stylesheet href="bug.xsl" type="text/xsl"?> 

<root text="Récapitulatif des bugs MD 360"> 
<graph> 
      <item text="3988 (K2) : [MozillaMD] Plantage vidéo de localisation prise OB" severite="K2" importance="" status="" date="15/11/2016"/> 
      <item text="3987 (K2) : [MozillaMD] Plantage vidéo de localisation pris" severite="K3" importance="" status="" date="15/11/2016"/> 
      <item text="3989 (K2) : [MozillaMD] Plantage vidéo de localisationD" severite="K2" importance="" status="" date="15/11/2016"/> 
      <item text="3985 (K2) : [MozillaMD] Plantage vidéo de localisati" severite="K1" importance="" status="" date="15/11/2016"/> 
      <item text="3978 (K2) : [MozillaMD] Plantage vidéo de D" severite="K1" importance="" status="" date="15/11/2016"/> 
      <item text="3982 (K2) : [MozillaMD] Plantage vidéD" severite="K4" importance="" status="" date="15/11/2016"/> 
      <item text="3955 (K2) : [MozillaMD] Plantage vidéo deD" severite="K4" importance="" status="" date="15/11/2016"/> 
      <item text="3976 (K2) : [MozillaMD] PlantagD" severite="K1" importance="" status="" date="15/11/2016"/> 
      <item text="3963 (K2) : [MozillaMD] Plantage vidéo de " severite="K3" importance="" status="" date="15/11/2016"/> 
      <item text="3896 (K2) : [MozillaMD] Plantage vi" severite="K2" importance="" status="" date="15/11/2016"/> 
      <item text="3923 (K2) : [MozillaMD] Plantage " severite="K2" importance="" status="" date="15/11/2016"/> 
</graph> 
</root> 

,這裏是我的實際的.xsl,當我更換由0 $ VAR3它的工作原理,但不能含有$ VAR3,我究竟做錯了什麼?

<?xml version="1.0"?> 
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns="http://www.w3.org/2000/svg"> 
<xsl:output 
    method="xml" 
    indent="yes" 
    standalone="no" 
    doctype-public="-//W3C//DTD SVG 1.1//EN" 
    doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" 
    media-type="image/svg" /> 

<xsl:template match="graph"> 
<svg viewBox="0 0 500 100" class="chart"> 
<xsl:variable name= "var3"><xsl:value-of select="count(graph/item[severite='K2'])"/></xsl:variable>  
<polyline 
fill="none" 
stroke="#0074d9" 
stroke-width="3" 
points=" 
    $var3,120 
    20,60 
    40,80 
    60,20"/> 
</svg> 
</xsl:template> 
</xsl:stylesheet> 

回答

0

<polyline 
fill="none" 
stroke="#0074d9" 
stroke-width="3" 
points=" 
    {$var3},120 
    20,60 
    40,80 
    60,20"/> 
+0

OMG的形式只是使用屬性值模板。謝謝。 :) – Gajiu