Bug 113572 - Copying a chart converts data ranges to data table
Summary: Copying a chart converts data ranges to data table
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.2 all versions
Hardware: All All
: medium normal
Assignee: Vasily Melenchuk (CIB)
URL:
Whiteboard: target:6.1.0
Keywords: needsUXEval
Depends on:
Blocks: Chart-Data
  Show dependency treegraph
 
Reported: 2017-11-01 16:08 UTC by Samuel Mehrbrodt (CIB)
Modified: 2018-11-19 10:41 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Example document (14.39 KB, application/vnd.oasis.opendocument.spreadsheet)
2017-11-01 16:08 UTC, Samuel Mehrbrodt (CIB)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Mehrbrodt (CIB) 2017-11-01 16:08:26 UTC
Created attachment 137422 [details]
Example document

1. Open the attached document
2. The chart has a data range defined (right-click chart, "Edit", then click "Data ranges" in the toolbar).
3. Leave chart editing mode (Esc) and copy and paste the chart into an empty document.

Then try to find the data range and adjust it.
It's no longer there, the data range has been converted to a data table.

The advantage of this behavior is that the chart looks the same wherever you paste it because its data is attached to it.

However, if you want to change the chart to use a data range instead as before, there's no obvious way to do this. You can drag+drop the cells you want to use as data range onto the diagram.

We should make this easier. I don't think we should change the default since it probably does makes sense in most cases to have the data attached to the chart when copying it.

But we should
1) Enable the button "Data ranges" even when the chart has a data table. The user should be warned that he will lose the data table when he decides to use a data range instead. This should also be possible using the context menu.
2) As a second step, ask the user when pasting a chart whether he wants to 
  - paste the chart with the original data converted to a data table (as it is now, should stay the default)
  - paste only the chart and use the data from the sheet he pastes into (might make sense when one has similiar sheets and wants to use the same chart everywhere)
Comment 1 m.a.riosv 2017-11-02 00:52:10 UTC
Doing some test,
- Copying and pasting including the ranges with the chart data, copy data ranges on the source file, but with a wrong path.
- Copying the sheet to a new file (right-click on the sheet tab), seems copy data range fine.

Bug https://bugs.documentfoundation.org/show_bug.cgi?id=101653 is about this matter.
Comment 2 Heiko Tietze 2017-11-02 08:46:55 UTC
(In reply to Samuel Mehrbrodt (CIB) from comment #0)
> The advantage of this behavior is that the chart looks the same wherever you
> paste it because its data is attached to it.

It's not only the look and feel but to have the data at all. When you paste the chart in the same document it will keep the range. But in a completely new document or at Writer there are no referenced data.

What you suggest is to take the chart as a 'template' and use the data from the other sheet instead of the original. The use case would be to customize a certain chart and use this at different sources. That could be done per paste special, as referenced in comment 1.

Actually I think we have a good working solution for most users and any dialog is rather annoying.
Comment 3 Heiko Tietze 2017-11-02 09:30:42 UTC
(In reply to Samuel Mehrbrodt (CIB) from comment #0)
> 1) Enable the button "Data ranges" even when the chart has a data table. The
> user should be warned that he will lose the data table when he decides to
> use a data range instead. This should also be possible using the context
> menu.

And about this: having only one button for either data range or data table depending what's actually in the chart makes sense for the Benjamins. But people who are a little bit more familiar with the processing likely not accept this mix-up (if possible at all). 

Actually your idea is more about how to deal with the situation when not going with the paste special solution. Too complicated IMHO.
Comment 4 Regina Henschel 2017-12-21 17:19:37 UTC
Hi all, I do not understand the purpose of this "new feature". If you have got a chart, which has an own data table, e.g. by copying from a different spreadsheet file, and you want to make this chart taking the data from a cell range, that is very easy. Mark the cell range and drag&drop it onto the chart. You get a dialog to decide, whether the first row or column is a label. And that's all. After drag&drop the chart is linked to that area.
Comment 5 Regina Henschel 2017-12-21 18:47:53 UTC
Recording it as macro shows the associated uno-command and its parameters, e.g.

dim args2(3) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Name"
args2(0).Value = "Object 1"
args2(1).Name = "Range"
args2(1).Value = "$Sheet1.$B$1:$C$4"
args2(2).Name = "ColHeaders"
args2(2).Value = true
args2(3).Name = "RowHeaders"
args2(3).Value = false
dispatcher.executeDispatch(document, ".uno:ChangeChartData", "", 0, args2())

There is "Object 1" the chart.
Comment 6 Commit Notification 2018-01-10 00:25:04 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=0074951704022d173a5fdb9df933f47be1dcbb91

tdf#113572: allow switching to data range in copypasted chart

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2018-01-21 18:23:00 UTC
Vasily Melenchuk committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c18d183c9fdadea3d3d28a14b417f5c9620eb439

tdf#113572: removed redundant calc service

It will be available in 6.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 8 Heiko Tietze 2018-01-22 11:04:25 UTC
(In reply to Commit Notification from comment #7)
> Affected users are encouraged to test the fix and report feedback.

How is the range of the converted chart supposed to work? The references are invalid, and when I create new data the graph is updated. In other words, what use case is solved with the patch?
Comment 9 Samuel Mehrbrodt (CIB) 2018-01-30 13:06:43 UTC
(In reply to Regina Henschel from comment #4)
> Hi all, I do not understand the purpose of this "new feature". If you have
> got a chart, which has an own data table, e.g. by copying from a different
> spreadsheet file, and you want to make this chart taking the data from a
> cell range, that is very easy. Mark the cell range and drag&drop it onto the
> chart. You get a dialog to decide, whether the first row or column is a
> label. And that's all. After drag&drop the chart is linked to that area.

Hi Regina, what you find "very easy", I find very hard to discover.
I didn't know about this "feature". So what we did is made this feature easier to discover by enabling the "Data Range" button even if the chart has a data table. So you can click the "Data Range" button on such a chart, and define the data range there.

Does this make sense?
Comment 10 Samuel Mehrbrodt (CIB) 2018-01-30 13:09:42 UTC
(In reply to Heiko Tietze from comment #8)
> (In reply to Commit Notification from comment #7)
> > Affected users are encouraged to test the fix and report feedback.
> 
> How is the range of the converted chart supposed to work? The references are
> invalid, and when I create new data the graph is updated. In other words,
> what use case is solved with the patch?

Hi Heiko, I don't quite get your question. When you click the data range button on a chart that has a data table, you are asked if you want to drop the data table and define a range instead. Then you can define the range in the dialog that appears.

The use case is as described in comment 0, you want to use a chart in another document just with different data.
As mentioned in comment 9, this feature existed before, we just made it easier to use.
Comment 11 Regina Henschel 2018-01-30 14:36:10 UTC
Hi Samuel, it is OK for me to have this possibility. User will likely use it to carry over styling. In this sense it is a workaround for a chart template.

In testing it with an XY-chart, I get this problem:
If the source data has two series and you only set current values for one series, then the second series is still shown in the graph. Only when you save and reload the document the second series is removed. This might cause confusion, if the user thinks, this feature allows to mix internal data table and sheet range.

And a minor problem: The data labels field has the entry "categories". That should be red too. If the word "categories" remains, the data labels at the data points show 1, 2, 3, ... and it is not clear to the user, what this means.
Comment 12 Regina Henschel 2018-01-30 14:50:27 UTC
And next problem: Working with this tool produces lu****.tmp files on my desktop, which are not removed. I have used a debug build for testing; Version: 6.1.0.0.alpha0+ (x64)
Build ID: 21a15d5106bf081d3c896f9f1b01702b2c61d135
CPU threads: 8; OS: Windows 10.0; UI render: default; 
Locale: de-DE (de_DE); Calc: CL
Comment 13 Heiko Tietze 2018-01-30 15:43:07 UTC
(In reply to Samuel Mehrbrodt (CIB) from comment #10)
> > How is the range of the converted chart supposed to work? 
> 
> Then you can define the range in the dialog that appears.

Thing is that I have to recreate the chart completely new. Every single data point is lost and the user has to fiddle around with the data. The benefit of identical charts is contradicted by this tedious workflow. 
I would expect that data are taken from the current sheet, ie. $Old_Sheet$A1:A10 becomes $New_Sheet$A1:A10 after confirming your conversion. Copy/paste works differently... hm, so how about a paste special? I guess that's what users want.
Comment 14 Samuel Mehrbrodt (CIB) 2018-01-31 14:37:42 UTC
(In reply to Heiko Tietze from comment #13)
> I would expect that data are taken from the current sheet, ie.
> $Old_Sheet$A1:A10 becomes $New_Sheet$A1:A10 after confirming your
> conversion. Copy/paste works differently... hm, so how about a paste
> special? I guess that's what users want.

This used to be the case in OpenOffice.org. It was then changed in LO to hold the data in a data table. I don't know the exact reasons for this, but I guess it's so that you can copy the chart anywhere (Writer, Impress) and not lose the data.

When thinking about further improvements, we need to consider this.