Bug 150036 - Add option to align legend entries with data on chart (improving chart readability)
Summary: Add option to align legend entries with data on chart (improving chart readab...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Chart (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Chart-Labels Chart-Legends
  Show dependency treegraph
 
Reported: 2022-07-18 06:25 UTC by Arthur Fragoso
Modified: 2023-12-12 14:27 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Example (26.06 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-11-22 08:47 UTC, Heiko Tietze
Details
sample ODS with line charts (to test comment 1 workaround) (22.79 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-11-22 15:38 UTC, Stéphane Guillou (stragu)
Details
screenshot of feature in Google Sheets (100.73 KB, image/png)
2023-12-11 16:53 UTC, Stéphane Guillou (stragu)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur Fragoso 2022-07-18 06:25:14 UTC
Description:
Hello,

A thing I like about Google Docs that I could not do yet in LibreOffice is connecting the Legend to the Chart like in this pie chart: https://i.imgur.com/pyNZcKM.png

It's much easier to understand/read the chart in that way.

Also, it is already difficult for us to read charts with a lot of entries, and I have to worry if color blind people will be able to read it.

I know we can also use gradients and patterns to help readability, but those lines are much more readable in my opinion.

But I would also like a similar feature for Area and Line charts. (Google Docs also does not have for those, only for pie charts)

Like for this example the chart is very difficult to read and associate the data and the fields:

https://i.imgur.com/22uepCp.png

The closest alternative (workaround) I got is by right clicking in the area > "Insert Data Labels", then "Format Data Label" > unchecking "Value as number" and checking "Series name". It inserts the label, but it gets repeated for each data entry.

Some example on how it could be:

https://i.imgur.com/NSQgQEm.png

https://i.imgur.com/KgSIlJD.png

Thank you.

Steps to Reproduce:
Feature Request

Actual Results:
Feature Request

Expected Results:
Feature Request


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
Feature Request
Comment 1 Stéphane Guillou (stragu) 2023-10-31 15:00:12 UTC
I guess there's two requests here:
- connecting legend with callouts, which is already possible by using data labels and the options "leader lines"
- aligning the legend to the data series, which I focus on below.

Its true that it's hard to adapt the Series data label implemented for bug 94235 to cover this common use case:

0. Don't add a classic legend
1. Add data label to whole chart
2. Change settings to "Series name" and "Legend key"
3. Change Placement to "right"
4. Click twice (slowly) on each duplicate data labels to select them individually and Delete.

Step 4 is completely impractical for more than a handful of labels.

With what we currently have, we should be able to add a setting that acts as a shortcut for the above, for example in the Wizard's "Chart elements":

[X] Display legend
 ° Left
 ° Right
 ° Top
 ° Bottom
 ° Label the series

... but it would be a hack that would likely conflict with other data label settings. (i.e. what happens if one wants to use this new setting, but also label the data points with values? It would require two "layers" of labels.)

UX/Design team, what do you think?
Comment 2 Heiko Tietze 2023-10-31 15:12:37 UTC
Sounds very specific and rather suited for a macro (advanced graphics should be done with specialized apps like R). Can you share an example to make testing easier?
Comment 3 Heiko Tietze 2023-11-22 08:47:21 UTC
Created attachment 190959 [details]
Example

(In reply to Stéphane Guillou (stragu) from comment #1)
> 1. Add data label to whole chart
It's not available in the context menu (which would be a good enhancement) but in the main menu under Insert)
> 2. Change settings to "Series name" and "Legend key"
> 3. Change Placement to "right"
> 4. Click twice (slowly) on each duplicate data labels to select them
> individually and Delete.
Don't get this
> - connecting legend with callouts, which is already possible by using data
> labels and the options "leader lines"
Missing the connector lines. And it would be rather with the Attribute Options > Placement in the Data Labels dialog.

I wonder if the Data Label tip helps Arthur. Is this what you were looking for? What should we improve?
Comment 4 Stéphane Guillou (stragu) 2023-11-22 15:38:23 UTC
Created attachment 190972 [details]
sample ODS with line charts (to test comment 1 workaround)

See my sample ODS for my suggested workaround. My steps applied to a line chart, you can start from the chart titled "original". As you can see, a tedious workaround, even with only 20 datapoints.

(In reply to Heiko Tietze from comment #3)
> (In reply to Stéphane Guillou (stragu) from comment #1)
> > 4. Click twice (slowly) on each duplicate data labels to select them
> > individually and Delete.
> Don't get this
This is because clicking once on a label will select the whole series of labels, and double-clicking opens the dialog. Click a second time on a label to select it individually, so you can remove it.
> > - connecting legend with callouts, which is already possible by using data
> > labels and the options "leader lines"
> Missing the connector lines. And it would be rather with the Attribute
> Options > Placement in the Data Labels dialog.
They only appear once a certain distance from the series is reached. In your sample file, try moving an individual point away from the pie to make it appear.
I think they should remain separate from the "Placement" setting, as one can define a default position for labels and then decide if yes or no leader lines are displayed when a labelled is moved away by hand.
Comment 5 Heiko Tietze 2023-11-23 07:45:15 UTC
(In reply to Stéphane Guillou (stragu) from comment #4)
> See my sample ODS for my suggested workaround.
Now I understand, you abuse the last data label as legend. This will very likely fail for many reasons (last data points are very close, inappropriate y scaling like logarithmic hides the last data point, reverse x direction, RTL, other chart types). But as you said, it's a workaround.

(In reply to Stéphane Guillou (stragu) from comment #4)
> [X] Display legend
We are talking about Legend > Properties > Position?
>  ° Left, Top, Right, Bottom
>  ° Label the series
It might be very welcome by the users but I don't see how we label series in a callout style for every type of chart and all situations.

And again: what do you think, Arthur? Is Insert > Data Labels sufficient for you?
Comment 6 Stéphane Guillou (stragu) 2023-11-23 08:30:45 UTC
(In reply to Heiko Tietze from comment #5)
> Now I understand, you abuse the last data label as legend. This will very
> likely fail for many reasons (last data points are very close, inappropriate
> y scaling like logarithmic hides the last data point, reverse x direction,
> RTL, other chart types). But as you said, it's a workaround.
Indeed!
> We are talking about Legend > Properties > Position?
Either in Wizard > Chart Elements > Display legend, or in Insert > Legend > Position
> >  ° Label the series
> It might be very welcome by the users but I don't see how we label series in
> a callout style for every type of chart and all situations.
True. Actually, I think what would be doable and simplest:

[X] Display legend
 ° Left
 ° Right
 ° Top
 ° Bottom
 [ ] Align with data

The last option (only available if Display Legend is on) would:
- for each series, take the x or y value of the data point closest to the legend (depending on position option)
- use that value to position each corresponding legend entry
- offset them if there are overlaps
- update the position on each data or chart change
This should suit most charts (but there will always be visualisations where such an option would not be useful, comes down to user choice).
And potentially an extra option to add "[ ] Leader lines" to the chart area's edge. (Useful if position was offset for avoiding overlap.)
Comment 7 Stéphane Guillou (stragu) 2023-11-23 08:32:17 UTC
(In reply to Stéphane Guillou (stragu) from comment #6)
> And potentially an extra option to add "[ ] Leader lines" to the chart
> area's edge.
Sorry, should be "chart wall's edge".
Comment 8 Heiko Tietze 2023-12-11 16:11:32 UTC
Since Arthur doesn't respond the final call is for you, Stephane.
Comment 9 Stéphane Guillou (stragu) 2023-12-11 16:50:31 UTC
OK, I changed the summary accordingly.
If someone wants to pick it up (and depending on what ODF can do, I presume), please see comment 6.

In Google Sheets, the equivalent for a Pie chart is using Legend > Position > Labeled. For this chart, it splits the legend on left and right of the pie, aligns the entries with the data (but avoids overlap) and draws leader lines.
As Arthur mentioned, this option is greyed out for other chart types.
An export of such a chart to XLSX or ODS results in the default legend, at the right of the pie. (Same for a re-import into Google Sheets.)
Comment 10 Stéphane Guillou (stragu) 2023-12-11 16:53:57 UTC
Created attachment 191363 [details]
screenshot of feature in Google Sheets

What it looks like for Pie charts in Google Sheets.
Even though this is only available for Pie charts in Google Sheets, this feature should be available for other chart types like Line charts or Area charts.