Mercurial > hg
comparison mercurial/templates/spartan/graph.tmpl @ 35407:27ab3150cd50
hgweb: calculate <canvas> width and height client-side
hgweb determines and passes to templates some variables related to graph
appearance, like bg_height, canvaswidth and canvasheight. bg_height was and
still is used for graph.scale() call in graph.tmpl, and the two latter
variables were used in <canvas> element as width and height properties, and
they were set before JS code got to run. Setting these properties server-side
doesn't make a lot of sense, because a graph that has been scaled should
calculate things like width and height on its own when being rendered.
Let's move (re)sizing <canvas> to JavaScript (to Graph.render function) and
stop parsing HTML with regular expressions just to know new width and height.
That extra loop that only counts cols is required because <canvas> can't
be resized after or in the process of rendering (or it gets cleared).
Incidentally, SVG doesn't have this problem and I'm hoping to switch graph to
using it in future.
There also was truecanvasheight, but according to hg grep --all it was never
used, see d490edc71146.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sun, 10 Dec 2017 15:56:22 +0800 |
parents | ad0de63e1d6a |
children | 56854848e485 |
comparison
equal
deleted
inserted
replaced
35406:76dcdc4e707b | 35407:27ab3150cd50 |
---|---|
30 | 30 |
31 <noscript>The revision graph only works with JavaScript-enabled browsers.</noscript> | 31 <noscript>The revision graph only works with JavaScript-enabled browsers.</noscript> |
32 | 32 |
33 <div id="wrapper"> | 33 <div id="wrapper"> |
34 <ul id="nodebgs"></ul> | 34 <ul id="nodebgs"></ul> |
35 <canvas id="graph" width="{canvaswidth}" height="{canvasheight}"></canvas> | 35 <canvas id="graph"></canvas> |
36 <ul id="graphnodes">{nodes%graphentry}</ul> | 36 <ul id="graphnodes">{nodes%graphentry}</ul> |
37 </div> | 37 </div> |
38 | 38 |
39 <script type="text/javascript"{if(nonce, ' nonce="{nonce}"')}> | 39 <script type="text/javascript"{if(nonce, ' nonce="{nonce}"')}> |
40 <!-- hide script content | 40 <!-- hide script content |