From: tla Date: Wed, 14 Mar 2012 15:20:41 +0000 (+0100) Subject: properly display & scale stemma graphs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5a7e26a907032c98237756247791aa569487e7d7;p=scpubgit%2Fstemmatology.git properly display & scale stemma graphs --- diff --git a/lib/Text/Tradition/Stemma.pm b/lib/Text/Tradition/Stemma.pm index 42f27e3..16dad09 100644 --- a/lib/Text/Tradition/Stemma.pm +++ b/lib/Text/Tradition/Stemma.pm @@ -274,12 +274,10 @@ sub as_svg { push( @cmd, $dotfile->filename ); run( \@cmd, ">", binary(), \$svg ); # HACK: Parse the SVG and change the dimensions. - # Convert width from pt to px, and remove height to allow scaling. + # Get rid of width and height attributes to allow scaling. my $parser = XML::LibXML->new(); my $svgdoc = $parser->parse_string( decode_utf8( $svg ) ); - my $dval = $svgdoc->documentElement->getAttribute('width'); - $dval =~ s/pt/px/; - $svgdoc->documentElement->setAttribute( 'width', $dval ); + $svgdoc->documentElement->removeAttribute('width'); $svgdoc->documentElement->removeAttribute('height'); # Return the result return decode_utf8( $svgdoc->toString ); diff --git a/stemmaweb/root/js/componentload.js b/stemmaweb/root/js/componentload.js index 01663da..e881f84 100644 --- a/stemmaweb/root/js/componentload.js +++ b/stemmaweb/root/js/componentload.js @@ -12,12 +12,7 @@ function loadTradition( textid, textname ) { // Then get and load the actual content. // TODO: scale #stemma_grpah both horizontally and vertically // TODO: load svgs from SVG.Jquery (to make scaling react in Safari) - $('#stemma_graph').load( basepath + "/stemma/" + textid , function() { - if( $('#stemma_graph svg').size() != 0 ) { - var stemma_svg_element = $('#stemma_graph svg').svg().svg('get').root(); - stemma_svg_element.height.baseVal.value = $('#stemma_graph').height(); - } - }); + $('#stemma_graph').load( basepath + "/stemma/" + textid ); $('#variant_graph').load( basepath + "/variantgraph/" + textid , function() { var variant_svg_element = $('#variant_graph svg').svg().svg('get').root(); var svg_height = variant_svg_element.height.baseVal.value;