Module talk:Chart

This is an old revision of this page, as edited by Begoon (talk | contribs) at 15:22, 27 June 2013 ('Y' axis maximum on stacked bar chart: .). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Latest comment: 12 years ago by Begoon in topic 'Y' axis maximum on stacked bar chart

Population graph

I've developed a more automated template for population growth charts (intended for census data on geographical articles) at the Vietnamese Wikipedia. If anyone's interested, I'd be happy to port vi:Mô đun:Thời biểu dân số over to this wiki; just contact me. – Minh Nguyễn (talk, contribs) 16:53, 31 March 2013 (UTC)Reply

i gave it a cursory look. first of all - very nice! second - the Vietnamese version currently is limited to a single dataset, so i am not sure it's The Answer (although it maybe can be used to develop "The Answer"). However, one thing that the Vietnamese module linked above did right (and i went wrong), is actually using mw:Extension:Timeline (i used divs with position:absolute - quite a disaster). for me personally, timeline has one huge deficiency that tramps (almost) anything else: its RTL support sucks (thogh, maybe Lua can help even here? i'll have to ponder it a bit). i am not all that familiar with the "Timeline" syntax, but it may actually be better.
So next mission is to develop a line-graph using the timeline syntax.
peace - קיפודנחש (aka kipod) (talk) 19:55, 31 March 2013 (UTC)Reply
Hmmm. I was actually hoping that your next project would be developing a set of Lua modules to make the EasyTimeline extension obsolete. I've always found its output to be pretty awful (ugly rasterized image). --MZMcBride (talk) 02:05, 1 April 2013 (UTC)Reply
Actually, Thời biểu dân số supports any arbitrary years (even BC), as seen at vi:Bản mẫu:Thời biểu dân số#Thành phố New York. I brought it up because it allows you to enter each data point as | yyyy = nnnn, so editors don't have to learn a special syntax. But obviously you're thinking about broader charting needs, and I would welcome any effort to obsolete EasyTimeline, because its un-antialiased fonts are hideous. – Minh Nguyễn (talk, contribs) 06:31, 2 April 2013 (UTC)Reply
it's understood that it can support any year range,but it's still asingle data set. It can't show, for instance, life expectancy vs. Average weight, or crop size vs. Agriculture area, let alone three or four different variables. קיפודנחש (aka kipod) (talk) 12:39, 2 April 2013 (UTC)Reply

Right align, caption

It would be helpful to have a right align thumbnail option as well as a caption parameter. --JFH (talk) 20:06, 27 April 2013 (UTC)Reply

if you mean containing the whole thing in a right-aligned thumb, i think it's better to do it in a template that uses the module, no? i think that in enwiki the consensus is not to use modules directly in articles and always pipe it through templates, so it makes more sense to me to leave all the enveloping of the actual chart to the template.
if you think it's useful, we can maybe add two new optional parameters for "class" and "style" for the outermost div containing the whole shebang. i'm not so sure about "caption", mainly because it's not clear to me where and how this optional caption should be displayed.
either way, if you can be more specific, neither of these is out of the question. peace - קיפודנחש (aka kipod) (talk) 23:06, 27 April 2013 (UTC)Reply
I don't really know how these things work. I suppose I would like a template that uses this module to create something like template:pie chart. The problem with that template is that everything has to add up to 100. --JFH (talk) 13:16, 28 April 2013 (UTC)Reply
you are correct. {{pie chart}} has several additional limitations which this module overcomes: there is a hard-coded limit to the number of slices (currently 10. it would be easy enough to raise it, e.g. to 15, but limitation of template syntax basically forces a hard coded limit). there is no "hint" (or "tooltip") on the slices, and there is no convenient way to introduce units to the legends.
it should be pretty easy to wrap all this in a template, and if nobody else does it, maybe i will, one of these days...
peace - קיפודנחש (aka kipod) (talk) 17:08, 28 April 2013 (UTC)Reply

'Y' axis maximum on stacked bar chart

Can the 'Y' axis maximum be controlled in a stacked bar?

For instance, see User:Begoon/sandbox/casualties, where the 3rd chart (Total fatalities) has a large amount of "dead space" where it extends to 15,000,000 when 12,500,000 would be ample? I don't really understand why it does that, or if I can prevent it. Thanks. Begoontalk 04:00, 27 June 2013 (UTC)Reply

it's always tricky to select a "round" number to serve as top y. i think anywhere between 1 and 1.5 (or 10 and 15, or 100 and 150 etc.) will use 1.5. the problem here is not just finding the appropriate top value, but also selecting the other y legends: for instance, if we would have selected 13 (or 13 million, for that matter), marking all the values of 1,2,3...12,13 would create too many marks, but nothing else seems very appropriate.
i guess i could teach the module to accept the y-legend values manually, so the editor will be able to force values when the current logic of the module does not produce good results, but this won't happen before the end of the week. peace - קיפודנחש (aka kipod) (talk) 12:52, 27 June 2013 (UTC)Reply
Yeah, I know - I've done a fair few PHP routines to generate charts from SQL databases dynamically on websites I maintain (using things like flashchart). It's a pig to code for when the ranges can be anything from 1 to a zillion without getting odd division markers. No big thing, it's ok as it is really, and that's a prototype with imaginary data - so the final thing might use luckier numbers when I plug them in.
I'm also interested in the question above about thumbnailing. The charts are too big to include in full on the article page, so there'll be a separate chart page. At the moment I'm even thinking I might need to use an image screenshot in the article to link to the page with the full chart, which is OK here, because the data isn't likely to change - but not an ideal way of doing it if the data is regularly updated, because you'd need to update a new thumbnail image each time too. Thanks for the quick reply. Begoontalk 13:27, 27 June 2013 (UTC)Reply
as the charts generated by this module are not images, proper "thumbnailing" will not work.
however, playing with "height" and "width" for the whole chart will produce smaller (or larger) versions. one drawback is that the legends text will still show at normal size, which might cause problems, like overlapping legends and such. maybe it should be possible to embed the whole chart inside a "div" with "style='font-size:50%;' " or somesuch:
 Carrot  and  Peach 
25,000
50,000
75,000
100,000
125,000
150,000
Before
During
After
Post mortem
Blah
Bloh
  •   Apple
  •   Banana
  •   Orange
also, note that the module will refuse to draw a chart if either hight or width are less than 200 (i guess this could be changed...). total result is still somewhat larger than what you would normally call a "thumbnail". i also never found a good way to place the group legends - whatever i tried, i never found a trick to make them appear in the "right place" for all charts - if it works well with one chart, it doesn't with another. the compromise was to place them a bit far away - too far for most cases really, but if i place them closer they sometime overlap with the horizontal legends, and i did not find a good way to make it intelligent. (anyone is welcome to improve it).
peace - קיפודנחש (aka kipod) (talk) 14:11, 27 June 2013 (UTC)Reply
That's very good. I played with something similar, but the font-size and overlap was the killer - never even thought of font-size:x% (duh...). I might be able to make that work. Thanks. The pseudo-thumbnail might not need group legends I suppose. How about an option to not display them "group names=none". Then we could drop coloured boxes/text in the template like:  Blue  and  Gold  if the position was awful - see above ? Begoontalk 14:25, 27 June 2013 (UTC)Reply
Or, I guess I could cheat:
       Apple        Banana        Orange
25,000
50,000
75,000
100,000
125,000
150,000
Before
During
After
Post mortem
Blah
Bloh
  •   Apple
  •   Banana
  •   Orange
Begoontalk 15:00, 27 June 2013 (UTC)Reply