New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chart overwriting user supplied options #121
Comments
Hi, Thanks for the report. Could you add a small but complete example that demonstrates the issue and I'll have a look at it. Regards. John. |
Here is a simple example that is probably familiar to you. :{) use Excel::Writer::XLSX;
my $workbook = Excel::Writer::XLSX->new ('trendlinebug.xlsx');
my $worksheet = $workbook->add_worksheet ('Trendline');
my $headings = [ 'Number', 'Batch 1', 'Batch 2' ];
my $bold = $workbook->add_format (bold => 1);
my $data = [
[ 2, 3, 4, 5, 6, 7 ],
[ 10, 40, 50, 20, 10, 50 ],
[ 30, 60, 70, 50, 40, 30 ],
];
my $trend = {
type => 'linear',
line => { color => 'red', dash_type => 'square_dot' }
};
$worksheet->write ('A1', $headings, $bold);
$worksheet->write ('A2', $data);
my $chart = $workbook->add_chart (type => 'line', embedded => 1);
$chart->add_series (
name => '=Trendline!$B$1',
categories => '=Trendline!$A$2:$A$7',
values => '=Trendline!$B$2:$B$7',
trendline => $trend,
);
$chart->add_series (
name => '=Trendline!$C$1',
categories => [ 'Trendline', 1, 6, 0, 0 ],
values => [ 'Trendline', 1, 6, 2, 2 ],
trendline => $trend,
);
$worksheet->insert_chart ( 'D2', $chart);
$workbook->close (); |
Hi, Thanks for the example. It is always easier to understand working code. That is a bug but it should be an easy fix. I'll let you know when it is available. John |
Fix to copy user defined chart properties, such as trendlines, so that they aren't overwritten. Issue #121.
Hi, Sorry, it took a while to get around to fixing this. I've push a fix to master along with a test based on your sample program. If you get a chance you can test it as well. John |
John, I tested the version I downloaded on March 3 and it solved the bug and has not exhibited any other problems. Thank you for resolving this, |
John,
It appears that the
add_series ()
function for charts overwrites the value oftrendline->{line}->{dash_type}
. This doesn't cause a problem if literals are used. However, in my case I want to set a trendline on several charts by passing a hash to the function (see below). This results in a message that says something like"Unknown dash type 'sysDash'"
and the trendline loses all the line values I set.I was able to put a quick patch in Chart.pm that adds the transformed names to
%dash_types
which works around my coding issue. Another solution is to not transform the original hash passed to the function.Would it be possible for you to correct this issue?
Thanks,
Bob
Failing Code
Quickfix Change to Chart.pm
The text was updated successfully, but these errors were encountered: