元のファイル(SVG ファイル、512 × 789 ピクセル、ファイルサイズ: 13キロバイト)

概要

解説
English: Graphical representation of the Gordon Brown cabinet.
日付
原典 投稿者自身による著作物
作者 TimR
SVG 開発
InfoField
 
このベクター画像のソースコードは 正しくありません。エラーが2件あります.
 
このW3C-無効 統計図表は別のSVGツールで作成されました。
 
 このSVG統計図表は埋込み文を用いており,テキストエディタを用いて容易に翻訳することができますいます。
ソースコード
InfoField

SVG code

This is the source code for generating this image. It is made available under the terms of the GNU General Public License, Version 3.
#!/usr/bin/perl -w

############################################################################
# Version 1.1, 3 October 2009
#
# Copyright 2009 TimR. All rights reserved.
############################################################################

############################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
############################################################################

use strict;

my @colours = qw(
  blue
  blueviolet
  brown
  burlywood
  cadetblue
  chartreuse
  crimson
  darkblue
  darkcyan
  darkgreen
  darkgrey
  darkmagenta
  darkorange
  deepskyblue
  dimgrey
  forestgreen
  gold
  goldenrod
  hotpink
  indianred
  indigo
  khaki
  lawngreen
  lightblue
  lightcoral
  lightgreen
  lightgrey
  lightpink
  lightsalmon
  lightskyblue
  lightslategrey
  lightsteelblue
  lime
  limegreen
  magenta
  maroon
  mediumblue
  mediumorchid
  mediumpurple
  mediumseagreen
  mediumslateblue
  mediumspringgreen
  mediumturquoise
  mediumvioletred
  mistyrose
  moccasin
  navajowhite
  navy
  oldlace
  olive
  olivedrab
  orange
  orangered
  orchid
  palegoldenrod
  palegreen
  paleturquoise
  palevioletred
  papayawhip
  peachpuff
  peru
  pink
  plum
  powderblue
  purple
  red
  rosybrown
  royalblue
  saddlebrown
  salmon
  sandybrown
  seagreen
  seashell
  sienna
  silver
  skyblue
  slateblue
  slategray
  slategrey
  snow
  springgreen
  steelblue
  tan
  teal
  thistle
  tomato
  turquoise
  violet
  wheat
  white
  whitesmoke
  yellow
  yellowgreen
);

my @headers =                 ("Jun 07",  "Jan 08",  "Oct 08",  "Jun 09");
                            
my @rawdata = (             
  [ "Lord Adonis",          qw(-          -          -          trans      )],
  [ "Bob Ainsworth",        qw(-          -          -          defence    )],
  [ "Douglas Alexander",    qw(id         id         id         id         )],
  [ "Valerie Amos",         qw(-          -          -          -          )],
  [ "Hilary Armstrong",     qw(-          -          -          -          )],
  [ "Lady Ashton",          qw(lhol       -          -          -          )],
  [ "Margaret Beckett",     qw(-          -          house      -          )],
  [ "Ed Balls",             qw(csf        csf        csf        csf        )],
  [ "Hilary Benn",          qw(efra       efra       efra       efra       )],
  [ "Tony Blair",           qw(-          -          -          -          )],
  [ "Hazel Blears",         qw(clg        clg        clg        -          )],
  [ "David Blunkett",       qw(-          -          -          -          )],
  [ "Paul Boateng",         qw(-          -          -          -          )],
  [ "Ben Bradshaw",         qw(-          -          -          cms        )],
  [ "Gordon Brown",         qw(pm         pm         pm         pm         )],
  [ "Nick Brown",           qw(-          -          whip       whip       )],
  [ "Des Browne",           qw(defence    defence    -          -          )],
  [ "Andy Burnham",         qw(treas      cms        cms        health     )],
  [ "Liam Byrne",           qw(-          cab        cab        treas      )],
  [ "Charles Clarke",       qw(-          -          -          -          )],
  [ "Yvette Cooper",        qw(house      treas      treas      work       )],
  [ "Alistair Darling",     qw(chan       chan       chan       chan       )],
  [ "John Denham",          qw(ius        ius        ius        clg        )],
  [ "Charles Falconer",     qw(-          -          -          -          )],
  [ "Caroline Flint",       qw(-          house      europe     -          )],
  [ "Peter Hain",           qw(work       -          -          wales      )],
  [ "Harriet Harman",       qw(lhoc       lhoc       lhoc       lhoc       )],
  [ "Patricia Hewett",      qw(-          -          -          -          )],
  [ "Geoff Hoon",           qw(whip       whip       trans      -          )],
  [ "John Hutton",          qw(bis        bis        defence    -          )],
  [ "Alan Johnson",         qw(health     health     health     home       )],
  [ "Tessa Jowell",         qw(-          olymp      olymp      cab        )],
  [ "Ruth Kelly",           qw(trans      trans      -          -          )],
  [ "Lady Kinnock",         qw(-          -          -          europe     )],
  [ "Dennis MacShane",      qw(-          -          -          -          )],
  [ "Lord Mandelson",       qw(-          -          bis        bis        )],
  [ "David Miliband",       qw(fs         fs         fs         fs         )],
  [ "Ed Miliband",          qw(cab        energy     energy     energy     )],
  [ "Jim Murphy",           qw(europe     europe     -          scot       )],
  [ "Paul Murphy",          qw(-          wales      wales      -          )],
  [ "James Purnell",        qw(cms        work       work       -          )],
  [ "John Reid",            qw(-          -          -          -          )],
  [ "Lady Royall",          qw(-          lhol       lhol       lhol       )],
  [ "Chris Smith",          qw(-          -          -          -          )],
  [ "Jacqui Smith",         qw(home       home       home       -          )],
  [ "Jack Straw",           qw(lchan      lchan      lchan      lchan      )],
  [ "Stephen Timms",        qw(-          -          -          -          )],
  [ "Shaun Woodward",       qw(ni         ni         ni         ni         )],
);

my @cats = (
  pm      => "Prime Minister",
  lhoc    => "Leader of the House of Commons",
  chan    => "Chancellor",
  fs      => "Foreign Secretary",
  lchan   => "Lord Chancellor",
  home    => "Home Secretary",
  efra    => "Environment, Food and Rural Affairs",
  id      => "International Development",
  clg     => "Communities and Local Government",
  ius     => "Innovation, Universities and Skills",
  csf     => "Children, Schools and Families",
  energy  => "Energy and Climate Change",
  health  => "Health",
  ni      => "Northern Ireland",
  lhol    => "Leader of the House of Lords",
  cab     => "Cabinet Office",
  olymp   => "Olympics",
  scot    => "Scotland",
  work    => "Work and Pensions",
  cms     => "Culture, Media and Sport",
  treas   => "Chief Secretary to the Treasury",
  wales   => "Wales",
  bis     => "Business, Innovation and Skills",
  defence => "Defence",
  trans   => "Transport",
  europe  => "Europe",
);

my %cats;
my @catmap;
for (my $n=0; $n*2<@cats; $n++) {
  my $tag = $cats[$n*2];
  $cats{$tag} = {
                  tag    => $tag,
                  index  => $n,
                  name   => $cats[$n*2+1],
                };
  $catmap[$n] = $cats{$tag};
}

my @data = map {
                 {
                   name   => $_->[0],
                   positions => [ map { $cats{$_}->{index} }
                                      @{$_}[1 .. @$_-1]
                                ],
                 }
               } @rawdata;

$_->{colour} = shift @colours
  foreach @data;

my $numbercolumns;
my $numberrows;
my $minposition;
my $maxposition;

foreach (@data) {
  $numbercolumns = @{$_->{positions} }
    if !defined $numbercolumns ┃┃
       $numbercolumns < @{$_->{positions} };

  foreach (@{$_->{positions} }) {
    $minposition = $_
      if defined $_ &&
         (!defined $minposition ┃┃
          $_ < $minposition);
    $maxposition = $_
      if defined $_ &&
         (!defined $maxposition ┃┃
          $_ > $maxposition);
  }
}
$numberrows = $maxposition - $minposition + 1;

my $leftmargin        = 10;
my $rightmargin       = 10;
my $topmargin         = 10;
my $bottommargin      = 10;
my $spacer            = 20;
my $lefttextboxwidth  = 480;
my $righttextboxwidth = 300;
my $colwidth          = 120;
my $rowheight         = 70;
my $lefttextvoffset   = 8;
my $textvoffset       = -8;
my $blobradius        = 10;
my $linewidth         = 10;
my $headerheight      = 40;

my $chartxoffset = $leftmargin + $lefttextboxwidth + $spacer;
my $chartyoffset = $topmargin + $headerheight;

my $chartwidth = $blobradius +
                 ($numbercolumns - 1) * $colwidth +
                 $blobradius;
my $totalwidth = $leftmargin + $lefttextboxwidth + $spacer +
                 $blobradius +
                 ($numbercolumns - 1) * $colwidth +
                 $blobradius +
                 $spacer +
                 $righttextboxwidth + $rightmargin;
my $totalheight = $topmargin +
                  $headerheight +
                  $numberrows * $rowheight +
                  $bottommargin;

print <<EOF;
<?xml version='1.0'?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 
  'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
<svg xwidth='5cm' xheight='4cm'
     version='1.1'
     xmlns='http://www.w3.org/2000/svg'
     viewBox='0 0 $totalwidth $totalheight'>
  <desc>Cabinet chart</desc>



  <rect x='0' y='0' width='$totalwidth' height='$totalheight'
        fill='white' stroke='none' stroke-width='2'/>

EOF

########################################################################
# Print grid
########################################################################
print "  <g fill='none' stroke='grey' stroke-width='1'>\n";
for (my $i=0; $i<$numberrows; $i++) {
  printf "    <line x1='%s' y1='%s' x2='%s' y2='%s'/>\n",
        0, $chartyoffset + $i * $rowheight,
        $totalwidth, $chartyoffset + $i * $rowheight;
}
printf "    <line x1='%s' y1='%s' x2='%s' y2='%s'/>\n",
      0, $chartyoffset + $numberrows * $rowheight,
      $totalwidth, $chartyoffset + $numberrows * $rowheight;
print "  </g>\n";
print "\n";

########################################################################
# Print headers
########################################################################
print "  <g font-size='20' fill='black' font-family='sans-serif'>\n";
for (my $i=0; $i<@headers; $i++) {
  printf "    <text x='%s' y='%s'>%s</text>\n",
         $chartxoffset + $blobradius + $i * $colwidth - 20,
         $headerheight - 10,
         $headers[$i];
}
print "  </g>\n";
print "\n";

########################################################################
# Calculate segments
########################################################################
my @newsegments;
for (my $i=@data-1; $i>=0; $i--) {
  my $item = $data[$i];

  for (my $start=0; $start<$numbercolumns; $start++) {
    if (defined $item->{positions}[$start]) {
      my $end = $start;
      while ($end+1<$numbercolumns &&
             defined $item->{positions}[$end+1]) {
        $end ++;
      }

      my @coords;
      foreach ($start .. $end) {
        push @coords, $chartxoffset + $blobradius + $colwidth * $_,
                      $chartyoffset +
                      ($item->{positions}[$_] - $minposition) * $rowheight +
                      $rowheight/2 + 10;
      }

      push @newsegments, {
                           item   => $item,
                           start  => $start,
                           end    => $end,
                           coords => \@coords,
                         };
      $start = $end + 1;
    }
  }
}

########################################################################
# Print lines, blobs
########################################################################
print "  <g stroke-width='$linewidth' stroke-linecap='round' fill='none'>\n";
foreach my $segment (@newsegments) {
    my @coords = @{$segment->{coords} };
    my @points = @coords;
    push @points, $chartxoffset + $chartwidth + $spacer + $righttextboxwidth,
                  $points[-1]
      if $segment->{end} == $numbercolumns-1;

    printf "    <polyline stroke='%s' points='%s'/>\n",
           $segment->{item}{colour},
           join(" ", @points);

    while (@coords > 1) {
      my $x = shift @coords;
      my $y = shift @coords;
      printf "    <circle cx='%s' cy='%s' r='%s' fill='%s'/>\n",
            $x, $y, $blobradius, $segment->{item}{colour};
    }
}
print "  </g>\n";
print "\n";

########################################################################
# Print labels
########################################################################
print "  <g font-size='24' fill='black' font-family='sans-serif' font-weight='bold'>\n";
foreach my $segment (@newsegments) {
    my @coords = @{$segment->{coords} };
    my ($x, $y);
    if ($segment->{end} == $numbercolumns-1) {
      $x = $coords[-2] + 60;
      $y = $coords[-1] - 15;
    } else {
      $x = $coords[0] - 10;
      $y = $coords[1] - 20;
    }

    printf "    <text x='%s' y='%s'>%s</text>\n",
          $x, $y, $segment->{item}{name} #. " " .  $segment->{item}{colour}
          ;
}
print "  </g>\n";
print "\n";

########################################################################
# Print text columns
########################################################################
print "  <g font-size='24' fill='black' font-family='sans-serif' font-weight='bold'>\n";

for (my $i=0; $i<$numberrows; $i++) {
  printf "    <text x='%s' y='%s'>%s</text>\n",
        $leftmargin,
        $chartyoffset + $i * $rowheight + $rowheight/2 + $lefttextvoffset,
        $catmap[$i]->{name} #. " " .  $catmap[$i]->{tag}
        ;
}
print "  </g>\n";

print <<EOF;
</svg>
EOF

To show the perl source code there, several || and }} had to be replaced. See User:TimR/BrownCabinetSVGSourcecode for the correct sourcecode.

ライセンス

この作品の著作権者である私は、この作品を以下のライセンスで提供します。
w:ja:クリエイティブ・コモンズ
表示 継承
このファイルはクリエイティブ・コモンズ 表示-継承 3.0 非移植ライセンスのもとに利用を許諾されています。
あなたは以下の条件に従う場合に限り、自由に
  • 共有 – 本作品を複製、頒布、展示、実演できます。
  • 再構成 – 二次的著作物を作成できます。
あなたの従うべき条件は以下の通りです。
  • 表示 – あなたは適切なクレジットを表示し、ライセンスへのリンクを提供し、変更があったらその旨を示さなければなりません。これらは合理的であればどのような方法で行っても構いませんが、許諾者があなたやあなたの利用行為を支持していると示唆するような方法は除きます。
  • 継承 – もしあなたがこの作品をリミックスしたり、改変したり、加工した場合には、あなたはあなたの貢献部分を元の作品とこれと同一または互換性があるライセンスの下に頒布しなければなりません。
GNU head この文書は、フリーソフトウェア財団発行のGNUフリー文書利用許諾書 (GNU Free Documentation License) 1.2またはそれ以降のバージョンの規約に基づき、複製や再配布、改変が許可されます。不可変更部分、表紙、背表紙はありません。このライセンスの複製は、GNUフリー文書利用許諾書という章に含まれています。
あなたは上記のライセンスから、どれか一つ以上を選択できます。

キャプション

このファイルの内容を1行で記述してください

このファイルに描写されている項目

題材

7 6 2009

6f60e5e9ee316c2923c19817506b04e108246bec

13,652 バイト

789 ピクセル

512 ピクセル

ファイルの履歴

過去の版のファイルを表示するには、その版の日時をクリックしてください。

日付と時刻サムネイル寸法利用者コメント
現在の版2009年6月18日 (木) 19:122009年6月18日 (木) 19:12時点における版のサムネイル512 × 789 (13キロバイト)WereonAndy Burnham (if Balls and Miliband can have "Ed"...)
2009年6月18日 (木) 19:062009年6月18日 (木) 19:06時点における版のサムネイル512 × 789 (13キロバイト)Wereonpeerage titles
2009年6月7日 (日) 11:202009年6月7日 (日) 11:20時点における版のサムネイル512 × 789 (13キロバイト)TimRLord Adonis -> Andrew Adonis; wider to improve text layout
2009年6月7日 (日) 11:172009年6月7日 (日) 11:17時点における版のサムネイル512 × 859 (13キロバイト)TimRWhite background
2009年6月7日 (日) 11:152009年6月7日 (日) 11:15時点における版のサムネイル512 × 859 (13キロバイト)TimRRemoved helvetica; white background
2009年6月7日 (日) 11:092009年6月7日 (日) 11:09時点における版のサムネイル512 × 859 (13キロバイト)TimR{{Information |Description={{en|1=Graphical representation of the wikipedia:Gordon Brown cabinet.}} |Source=Own work by uploader |Author=TimR |Date=2009-06-07 |Permission= |other_versions= }} <!--{{ImageUpload|full}}--> [[Category:Gover

以下のページがこのファイルを使用しています:

メタデータ