Page MenuHomePhabricator

Allow editors to control size of charts
Open, Stalled, MediumPublic

Description

Background

We want charts to be readable regardless of whether you are on a mobile device or desktop device, using Vector 2022 limited width or max width. Allowing users to express width and height as we do in thumbnails compromises this goal. In T375240 we removed support for explicit widths and heights and in this ticket we will think carefully about how that should work.

We considered a new boolean option: fullwidth but it was unclear how this would work intuitively inside infoboxes.

User story

As an editor I want flexibility in chart render size in such a way that it doesn't compromise readability in any device platform.

Requirements

  • How do charts render inside infoboxes in a way that's legible across devices?
  • How will editors add floated charts to articles in a way that doesn't compromise the users ability to read the chart.
  • How will readers be able to increase the size of charts if they are too small?
  • How will charts scale with font size controls?

BDD

  • For QA engineer to fill out

Test Steps

  • For QA engineer to fill out

Design

  • Add mockups and design requirements

Acceptance criteria

  • Add acceptance criteria

Communication criteria - does this need an announcement or discussion?

  • Add communication criteria

Rollback plan

  • What is the rollback plan in production for this task if something goes wrong?

This task was created by Version 1.2.0 of the Web team task template using phabulous

Event Timeline

Jdlrobson triaged this task as Medium priority.Oct 11 2024, 10:32 PM
Jdlrobson lowered the priority of this task from Medium to Low.Nov 1 2024, 9:58 PM

This would be very useful. In articles with infobox templates e.g. https://it.wikipedia.org/wiki/Nienburg/Weser, graphs tend to "clear" instead of "floating" next to the infobox.

Current behaviour (on Desktop):

Screenshot 2025-03-15 alle 19.26.16.png (1×2 px, 265 KB)

Expected behaviour:

Screenshot 2025-03-15 alle 19.33.08.png (1×2 px, 382 KB)

Next to the infobox template, not under it leaving blank space.

CCiufo-WMF renamed this task from How should editors control size of charts to Allow editors to control size of charts.May 1 2025, 2:58 AM

Allowing smaller sizes (not necessarily arbitrary, custom sizes - a fixed "thumbnail / preview" size with the option to expand it to fullscreen would be enough) would not only help with infoboxes or the example mentioned above, but also in cases where the chart is not meant to be studied in detail, but only included for illustrative purposes, like most charts in https://de.wikipedia.org/wiki/Stochastische_Analysis : Replacing those with the new charts in fullscreen mode would drastically reduce the readability of the article.

image.png (871×1 px, 363 KB)

I would also very much like to have an option to make it a thumbnail on the side too. I was tried adding a pie chart to https://en.wikipedia.org/wiki/Washington_University_in_St._Louis in the budget section, but having it take up almost the entire page cuts back at readability more than it adds to illustration.

CCiufo-WMF raised the priority of this task from Low to Medium.May 23 2025, 3:43 PM

Is it within the scope of this issue to enable charts to be included in <gallery> s? For an example, see https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Data_Visualization#Examples – I'd like to include that chart in the gallery next to the images.

Is it within the scope of this issue to enable charts to be included in <gallery> s? For an example, see https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Data_Visualization#Examples – I'd like to include that chart in the gallery next to the images.

I would say no, given that galleries are a specific feature designed for images. It's a valid request but outside the scope of this task and unlikely to be prioritized.

This would be very useful. In articles with infobox templates e.g. https://it.wikipedia.org/wiki/Nienburg/Weser, graphs tend to "clear" instead of "floating" next to the infobox.

Current behaviour (on Desktop):Expected behaviour:
Screenshot 2025-03-15 alle 19.26.16.png (1×2 px, 265 KB)
Screenshot 2025-03-15 alle 19.33.08.png (1×2 px, 382 KB)

Next to the infobox template, not under it leaving blank space.

I think I fixed it for you:
https://it.wikipedia.org/w/index.php?title=Nienburg%2FWeser&diff=145107929&oldid=144041306

Also note it might be a good idea to create
{{#chart:Population.Bar.chart}}
And then you can use it in many articles just by defining a data source:
{{#chart:Population.Bar.chart|data=Nienburg/Weser Demografia.tab}}
You can also do that in a template and provide data as a parameter. Template will make it easier to change the chart. For example the community could later decide all population charts should be shown as line charts. You would then change the template and you are done.
{{#chart:Population.Bar.chart|data={{{tab}}} }}
{{#chart:Population.Line.chart|data={{{tab}}} }}

Jdlrobson-WMF changed the task status from Open to Stalled.Jun 4 2025, 8:45 PM
Jdlrobson-WMF subscribed.

We should consider T395490: Support rendering previews of charts as thumbnail images before doing this as my sense is that this will address most of the use cases I'm seeing so far.

This request seems to have been mostly solved through placing the chart into a template with configurable widths.

This request seems to have been mostly solved through placing the chart into a template with configurable widths.

Doing this, we often end up with super thin graphs since the height cannot be changed.

This request seems to have been mostly solved through placing the chart into a template with configurable widths.

Yeah, that's gross. I've done it because I've needed to in the past, never because I wanted to. People want a native solution (and I'm sure skins would better support a native solution as well).

When we looked at this before although it looked like it should be straightforward we found it was very challenging to support this in a way such that charts on a mobile device were actually readable. I think it would be helpful if people could share example URLs to charts which are working around this or would benefit from this (particularly where the axis become unreadable on mobile devices). Having more test cases will be helpful for ultimately getting this addressed.

Well, prior the workaround I used for Graphs which had a similar issue was {{image frame}}. It never ever worked the way I really wanted it to (which was just "magical").

For dealing with mobile, I guess I'm less thinking of the image CSS direction (shrink, perhaps to some minimum width) and more the table CSS direction (overflow-x). I suppose you could combine them with setting a min-width.

I suppose less for me either way is it a concern of "I want to set widths" and more "I want these to take care of themselves from the perspective of CSS and friends". A template that takes care of widths has to be designed to do the CSS part.... and to do it consistently everywhere.

We considered a new boolean option: fullwidth but it was unclear how this would work intuitively inside infoboxes.

In the context particularly of infoboxes, I actually don't see an issue. I'm kind of wondering what the questions in the description are intending.

I think it would be helpful if people could share example URLs to charts which are working around this or would benefit from this (particularly where the axis become unreadable on mobile devices). Having more test cases will be helpful for ultimately getting this addressed.

I cannot provide direct urls because graph usage is mostly through (multiple imbricated) templates, but here are the use cases where specifying width while the aspect ratio remains sane is important:

  1. infoboxes (this currently works AFAIK, but please check multiple wikis)
  2. Inside {{multiple image}} for some reason this *doesn't work* on rowiki, I'll try to get you an example
  3. in short articles with big infoboxes, where the graphs end up on the left of the infobox in desktop view. I know desktop is becoming less and less used, but heavy editors use it even on mobile devices. Example: https://ro.wikipedia.org/wiki/Albano_Vercellese

I would further split the last use-case in two:

  • some templates permit specifying width and height, mostly for historical reasons
  • some pages did not specify any dimensions and would just benefit from the page's in-line styles to have the graph decently sized. This is the use case that seems the most relevant to me in the current world.

in short articles with big infoboxes, where the graphs end up on the left of the infobox in desktop view.

Screenshot 2025-08-29 at 9.20.07 AM.png (1×1 px, 795 KB)

Thanks for the example. I assume in this resolution we'd want the chart to become full width? Not sure right now if this is a template issue or the chart itself. (Note getting the responsive behaviour right here is the main challenge)

Workarounds:
With some CSS hacks, here's what I was able to achieve on Russian Wikipedia: Template:WikidataChart (Lua, CSS). I managed to limit charts width (which otherwise stretch to infinity, producing ugly white space), but it's impossible to do that after some minimal amount about 700-800 px (depends on something?). Currently there's a hack utilizing transform: scale() to scale the graphs (as CSS zoom property messes up mouse events), but this doesn't allow arbitrary sizes (for example, you can't change aspect ratio without getting completely broken labels).

Bugs:
The default size for charts is monstruous, even with width: 800px limit. Ruwiki users are massively complaining about them, calling them ugly and gigantomanic.
They take especially much space when using large browser zoom (e.g. 150% display size). I've noticed that when changing the browser zoom in any direction, charts stay visually the same size, contrary to anything else from images to tables which become smaller when scaled down and larger when scaled up. I don't think this is intendend, and even if it is, please change it.
This is Andy has reported that on mobiles "the graph is able to shrink horizontally to fit into screen", but stays the same vertically and therefore still doesn't fit.

Wellverywell raised the priority of this task from Medium to High.Dec 4 2025, 3:30 AM

This is pretty much the biggest issue for charts in Russian Wikipedia.

in short articles with big infoboxes, where the graphs end up on the left of the infobox in desktop view.

Thanks for the example. I assume in this resolution we'd want the chart to become full width? Not sure right now if this is a template issue or the chart itself. (Note getting the responsive behaviour right here is the main challenge)

I would personally prefer if we could display it next to the infobox and reduce the height accordingly, but I guess the result depends on the available space.

Even with resizing image container templates like image frame, the pie charts at least have way too much whitespace below them. See:

image.png (740×600 px, 97 KB)

Does anyone know of a not-too-messy workaround to fix this?