For the distribution of seats among political parties in local governments and parliaments, the Swedish Wikipedia has used repeated 5px images of different colours (red, red,... blue), which is both inefficient and hard to edit.
To improve this, I created a template that uses tables with bgcolor and width. I'm happy with calling this template, the article text is now very friendly to edit,
http://sv.wikipedia.org/w/index.php?title=Kumla_kommun&diff=8619386
For this typical article, the length was reduced from 21 kbytes to 5 kbytes.
The template parameters are Swedish political party abbreviations (s, m, c, fp, ...) that are used for looking up the right colour, interlaced with the number of seats for that party.
But is the template implementation optimal, or would you use some other technique? For very long bars or very narrow browser windows, the math gets distorted. Should I use divs instead of tables? I guess SVG would be the best, but can SVG images be generated inline from a template?
http://sv.wikipedia.org/wiki/Mall:Mandatstapel
The name is derived from mandat (= seat) and stapel (= bar).
Lars Aronsson wrote:
Should I use divs instead of tables?
You could and it would avoid the flak from one cranky bug submitter. I'm not so sure that tables that are *not* nested are significantly more efficient than equivalent divs. I can see that under certain circumstances, it would appear that nested divs would be similar in performance to nested tables - both require the browser to load the entire pack of info to the end of the outermost enclosing element before they can render.
I've used both tables and divs for bar charts and can't notice a performance difference. I haven't seen any benchmarks nor have I run any - I'd be interested in seeing if these assumptions of mine are valid or if there are other factors that I haven't considered.
I guess SVG would be the best, but can SVG images be generated inline from a template?
SVG would be interesting if it could be directly rendered. Not so great if it has to be converted to png first (except that it's server load instead of browser load).
Mike
-----Original Message----- But is the template implementation optimal, or would you use some other technique
-- Lars Aronsson (lars@aronsson.se) Aronsson Datateknik - http://aronsson.se _______________________________________________
Hi Lars,
I doubt it's more efficient, but we use JpGraph (http://www.aditus.nu/jpgraph/) to turn data into bar graphs on our wikis. We have a couple of extensions that use this library to make different types of charts for a couple different datasets. Ours are small wikis that are used for reports so having this complexity is good for us, I don't know if it would be helpful to you though.
-Courtney
wikitech-l@lists.wikimedia.org