File:Eishockey Saisonverlauf Nati A 2005-06.svg
This script generates chart diagrams, like the one shown on the right. It's highly configurable (see Explanation section below). Output files are in SVG format. What you need to do to run it:
Install AHK , the Scripting language for MS-Windows from www.autohotkey.com (sorry guys, Windows only!)
Save the script below to anything.ahk
Create an input file like the one below and save it to your hard disk
Run the script by double-clicking it, select input and output files
Done.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License , Version 1.2 or any later version published by the Free Software Foundation ; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License .http://www.gnu.org/copyleft/fdl.html GFDL GNU Free Documentation License true true
This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license.
You are free:
to share – to copy, distribute and transmit the work
to remix – to adapt the work
Under the following conditions:
attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
This licensing tag was added to this file as part of the GFDL licensing update . http://creativecommons.org/licenses/by-sa/3.0/ CC BY-SA 3.0 Creative Commons Attribution-Share Alike 3.0 true true
#NoTrayIcon
FileSelectFile, INI, 3,,Select input file
;FileSelectFile, INI, 3,,Eingabedatei wählen
if INI=
exitapp
FileSelectFile, SVG, S16,,Select output file,*.svg
;FileSelectFile, SVG, S16,,Ausgabedatei wählen,*.svg
if SVG=
ExitApp
IfExist, %SVG%
FileDelete %SVG%
IniRead,numberofcharts,%INI%,General,numberofcharts
IniRead,minlevel,%INI%,General,minlevel
IniRead,maxlevel,%INI%,General,maxlevel
IniRead,usemarkers,%INI%,General,usemarkers,1
IniRead,markersize,%INI%,General,markersize,2
IniRead,linewd,%INI%,General,linewd,.5
IniRead,diagramwidth,%INI%,General,diagramwidth
IniRead,background,%INI%,General,background
IniRead,inverted,%INI%,General,inverted
IniRead,label,%INI%,Axes,labelx
StringSplit,labelx,label,`,
IniRead,label,%INI%,Axes,labely
StringSplit,labely,label,`,
IniRead,fontsizex,%INI%,Axes,fontsizex,2
IniRead,fontsizey,%INI%,Axes,fontsizey,2
IniRead,fontsizelegend,%INI%,Legend,fontsize
Loop, %numberofcharts%
{
IniRead,legend%a_index%,%INI%,Legend,%a_index%
IniRead,data,%INI%,Data,%a_index%
StringSplit,data%a_index%_,data,`,
IniRead,colour,%INI%,Colors,%a_index%
StringSplit,colour%a_index%_,colour,`,
}
height:= maxlevel - minlevel + 7
width:= diagramwidth + 15
browsewidth:=width/height*800
FileAppend,
(
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg>
<svg version="1.1" baseProfile="full"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
preserveAspectRatio="xMidYMid meet" zoomAndPan="magnify"
viewBox="-10 -50 %width%0 %height%0"
width="%browsewidth%" height="800" >`n`n<defs>
<clipPath id="upper">
<rect x="-1" y="0" width="2" height="1"/>
</clipPath>
<clipPath id="lower">
<rect x="-1" y="-1" width="2" height="1"/>
</clipPath>`n
),%SVG%
Loop, %numberofcharts%
{
colour1 := colour%a_index%_2
if colour1 =
colour1 := colour%a_index%_1
colour2 := colour%a_index%_3
if usemarkers=1
{
FileAppend,
(
<g id="symbol%a_index%" transform="rotate(-45) scale(%markersize%)">
<circle r="1.2" fill="%background%"/>
<circle r="1"/>`n
),%SVG%
if colour2 =
FileAppend,<circle r=".8" fill="%colour1%"/>`n</g>`n,%SVG%
else
FileAppend,
(
<circle r=".8" fill="%colour1%" clip-path="url(#lower)"/>
<circle r=".8" fill="%colour2%" clip-path="url(#upper)"/>
</g>`n
),%SVG%
} else
FileAppend <g id="symbol%a_index%"></g>,%SVG%
}
FileAppend,
(
</defs>`n
<rect width="100`%" height="100`%" fill="%background%" x="-10" y="-50"/>`n
),%SVG%
h := maxlevel - minlevel + 1
Loop, %h%
{
FileAppend,
(
<line x1="10" x2="%diagramwidth%0"
y1="%a_index%0" y2="%a_index%0"
stroke="lightgray" stroke-width=".1"/>`n
),%SVG%
}
offset:=fontsizey/3
FileAppend, <g transform="translate(0`,%offset%)">`n,%SVG%
Loop, %h%
{
if inverted=1
text:=labely%a_index%
else
{
t:= h-a_index+1
text:=labely%t%
}
FileAppend,<text x="0" y="%a_index%0" font-size="%fontsizey%" text-anchor="end">%text%</text>`n,%SVG%
}
FileAppend, </g>`n<g fill="none" stroke-linecap="round" stroke-linejoin="round">`n,%SVG%
Loop, %numberofcharts%
{
i:= numberofcharts - a_index + 1
backwd:=2*linewd
FileAppend,<polyline stroke="%background%" stroke-width="%backwd%" points=",%SVG%
Loop
{
y := data%i%_%a_index%
if y=
break
if inverted!=1
y := 2 + maxlevel - minlevel - y
FileAppend %a_index%0`,%y%0 %a_space%,%SVG%
}
FileAppend,"/>`n,%SVG%
col:=colour%i%_1
FileAppend,<polyline stroke="%col%" stroke-width="%linewd%" points=",%SVG%
Loop
{
y := data%i%_%a_index%
if y=
break
if inverted!=1
y := 2 + maxlevel - minlevel - y
FileAppend %a_index%0`,%y%0 %a_space%,%SVG%
}
FileAppend,"/>`n,%SVG%
}
FileAppend,</g>`n,%SVG%
Loop, %numberofcharts%
{
i:= numberofcharts - a_index +1
Loop
{
y := data%i%_%a_index%
if y=
break
if inverted!=1
y := height-y
FileAppend,<use xlink:href="#symbol%i%" transform="translate(%a_index%0`,%y%0)"/>`n,%SVG%
}
}
offset:=fontsizex/3
FileAppend,`n<g transform="translate(%offset%) rotate(-90)">`n,%SVG%
Loop, %width%
{
text:=labelx%a_index%
FileAppend,<text x="0" y="%a_index%0" font-size="%fontsizex%">%text%</text>`n,%SVG%
}
FileAppend,</g>`n,%SVG%
Loop, %numberofcharts%
{
y:= 10+(a_index-1)*fontsizelegend*1.2
ytext:=y+fontsizelegend/3
x:=10*(diagramwidth+2)
x1:=x-2*markersize
x2:=x+2*markersize
xtext:=x+4*markersize
col:=colour%a_index%_1
text:=legend%a_index%
FileAppend,
(
<line x1="%x1%" x2="%x2%" y1="%y%" y2="%y%" stroke="%col%" stroke-width="%linewd%"/>
<use xlink:href="#symbol%a_index%" transform="translate(%x%,%y%)"/>
<text x="%xtext%" y="%ytext%" font-size="%fontsizelegend%">%text%</text>`n
),%SVG%
}
FileAppend,</svg>`n,%SVG%
[General]
background=white
numberofcharts=12
diagramwidth=52
minlevel=1
maxlevel=12
inverted=1
usemarkers=1
markersize=1.5
linewd=.8
[Axes]
labelx=Saisonstart,,10.09.2005,,17.09.2005,,17.09.2005,,01.10.2005,,08.10.2005,,16.10.2005,,23.10.2005,,30.10.2005,,05.11.2005,,19.11.2005,,26.11.2005,,29.11.2005,,04.12.2005,,11.12.2005,,23.12.2005,,06.01.2006,,14.01.2006,,21.01.2006,,27.01.2006,,03.02.2006,,28.02.2006,,05.03.2006,,Viertelfinal,,Halbfinal,,Final
labely=1,2,3,4,5,6,7,8,9,10,11,12
fontsizex=6
fontsizey=6
[Legend]
fontsize=7
1=HC Davos
2=ZSC Lions
3=SC Bern
4=EV Zug
5=Rapperswil-Jona Lakers
6=HC Lugano
7=HC Ambri-Piotta
8=HC Servette Genève
9=Kloten Flyers
10=Fribourg-Gottéron
11=SCL Tigers
12=EHC Basel
[Colors]
1=#f8e30e,#353d90
2=#5063aa,white
3=#e44120,#f8e30e
4=#abd8da,#5063aa
5=#353d90,#e44120
6=black,#f8e30e
7=#c0c0bf,#353d90,white
8=#7d2519
9=#e44120,#5bc0e9,white
10=#e44120,#abd8da
11=#f8e30e,black,#e44120
12=black,#e44120,white
[Data]
1=1,7,7,5,9,8,9,7,5,6,7,8,5,5,5,5,4,5,4,4,3,3,4,4,5,4,4,3,3,3,3,3,3,3,3,3,3,4,3,3,3,3,3,3,3,3
2=2,8,4,9,7,3,4,6,4,5,4,4,4,4,4,4,6,7,8,8,5,7,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,7,8,9,10,10
3=3,4,6,7,5,1,1,2,1,1,1,2,2,2,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,2,2,2,2,1,1,1
4=4,2,2,2,2,2,2,1,2,2,3,3,3,3,2,2,2,2,2,3,4,4,3,3,3,3,3,4,4,5,5,6,8,8,9,9,6,8,9,8,6,6,7,5,5
5=5,7,3,8,4,7,6,9,10,8,9,9,10,7,8,8,7,6,6,6,7,5,7,7,7,6,5,5,5,4,4,4,4,4,5,4,4,3,4,4,4,4,4,4,4,4
6=6,9,9,6,6,9,5,3,3,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,1,1,1,1,2,2,2,2
7=7,1,5,4,8,6,7,8,8,10,10,10,9,6,6,7,8,8,9,9,9,8,5,5,6,7,6,6,6,7,7,7,6,6,6,6,7,5,5,5,5,5,5,6,6
8=8,3,1,1,3,4,8,5,6,4,5,5,8,8,7,6,5,4,5,5,6,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11
9=9,6,8,3,1,5,3,4,7,7,6,7,7,9,9,9,9,10,7,7,8,6,6,6,4,5,7,7,7,6,6,5,5,5,4,5,5,7,6,6,8,10,9,8,8,8
10=10,11,11,11,12,12,12,12,12,11,12,12,12,12,12,12,11,11,11,10,10,10,10,10,9,8,8,8,8,8,8,8,7,7,7,7,8,6,7,7,9,8,10,10,9,9
11=11,10,12,12,11,11,11,11,11,12,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12
12=12,12,10,10,10,10,10,10,9,9,8,6,6,10,10,10,10,9,10,11,11,11,11,11,11,11,11,11,11,11,11,10,10,9,8,8,9,9,8,9,7,9,6,7,7
background: define the global background color here. Colors can be given by name or by their RGB values. See Wikipedia for details.
numberofcharts: this defines how much of the Legend , Colors and Data sections will be read and drawn.
diagramwidth: Guess what - the desired width of the diagram; must be an integer
minlevel/maxlevel: the top and bottom boundaries of the diagram; must be integers
inverted: if this equals 1, the diagram will be drawn top-to-bottom; otherwise bottom-to-top
usemarkers: if this equals 0, markers are omitted
markersize: this also affects the width of the lines in the legend, even if usemarkers is 0
linewd: the width of the lines connecting the (virtual) markers
labelx: Comma separated list of labels to be shown on top of the diagram
labely: Comma separated list of labels to be shown to the left of the diagram (ascending order)
no need to explain this, I hope
x=color1,color2,color3 or x=color1,color2: Colors of diagram #x - color1 is the color of the lines, color2 and color3 give the color(s) of the markers.
a=a1,a2,a3,...: Values taken by diagram #a; these can be floating point numbers