Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Single data set with a custom color should not create legends for each category #821

Merged
merged 9 commits into from
Jan 3, 2021

Conversation

tvt
Copy link
Contributor

@tvt tvt commented Aug 7, 2020

When creating a bar chart with a single data set and setting custom colors each category gets a legend-entry. See #285 for last time that happened.

I guess the idea is that if you pass in an array of colors to a single data set, that means that you want each category to have a different color.

I think it would make more sense if creating legend entries for categories were an option that could be set.
This solution instead add a check to avoid trying to color each category, if only a single color is passed.

…h category

When creating a bar chart with a single data set and setting custom colors each category gets a legend-entry. See gitbrent#285 for last time that happened.

I guess the idea is that if you pass in an array of colors to a single data set, that means that you want each category to have a different color.

I think it would make more sense if creating legend entries for categories were an option that could be set.
This solution instead add a check to avoid trying to color each category, if only a single color is passed.
@gitbrent gitbrent self-assigned this Aug 9, 2020
@gitbrent gitbrent added this to the 3.4.0 milestone Aug 9, 2020
@tvt
Copy link
Contributor Author

tvt commented Nov 13, 2020

Hi @gitbrent, anything else you need from me to help get this merged?

@gitbrent
Copy link
Owner

@tvt - got any test cases?

@tvt
Copy link
Contributor Author

tvt commented Dec 28, 2020

@gitbrent sure:

const slide = pptx.addNewSlide();
var data = [
    {
        name: 'Sample',
        labels: [0, 1],
        values: [2, 5],
    },
];

slide.addChart(pptx.charts.BAR, data, { showLegend: true, chartColors: ['0000FF'] });
pptx.writeFile();

Gives the output in Powerpoint 2016:
screenshot_2020-12-28-105836

@gitbrent gitbrent merged commit 1150446 into gitbrent:master Jan 3, 2021
@gitbrent
Copy link
Owner

gitbrent commented Jan 3, 2021

Thanks @tvt !

gitbrent added a commit that referenced this pull request Jan 3, 2021
@tvt tvt deleted the patch-1 branch January 3, 2021 19:23
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bar chart with one series displays broken if chartColors argument is given
2 participants