-
Notifications
You must be signed in to change notification settings - Fork 652
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
Bar chart with one series displays broken if chartColors argument is given #285
Comments
Hi @andrei-cs, I'm not quite sure what the chart you're trying to produce would look like, but Using an array of colors with a single array is a specialized feature, any "normal" chart would just use something like this: chartColors: ['0088CC', '99FFCC'], Have you looked through the chart code in |
Maybe I wasn't clear enough explaining my problem. The following code:
generates the graph below with the correct legend being the Series name Adding chartColors to it:
Generates it like in the picture below - with the legend not being correct |
@gitbrent Have you had time to look this over ? |
Not really. I've looked through the code a few times and while i intuitively understand that the use of this color array must be creating new series or something, i'm not seeing it. The Legend is a straight toggle in XML. It's there or it isn't - i'm not adding "rows" or items to, therefore, the |
I experienced the same issue: in my case I am not using a legend, but negative values in a bar or column chart product different colours. One possible source of this could be in the chart styles that PowerPoint is using. Have a look at the attached screen shot. In the bar above, you see suggested layouts: some of them have different colours for negative values, others not. Selecting the entire data series in PowerPoint and applying a different colour to them, only changes the positive bars. Opening the data in Excel shows just one data series. Selecting the data series in PowerPoint activates all the bars, not just the positive ones. Selecting a different chart style, gets you the same colour initially, but as soon as you apply a new series colour, then you are back to the old same problem. (I thought this could be possible fix in the code, by setting the chart style somehow before applying formatting) @gitbrent I think the only solution is to expose PowerPoint's feature to colour individual data points in the API? A temporary workout is to render these type of charts as stacked bar or column charts, and split data series with negative numbers into 2: one positive, one negative, and apply colours to them separately. |
Any update on this? I am unable to correctly display legend for barchart with just one series + set chartColors. If I don't set the chartColor legend displays correctly. |
I'll look into it for 3.1 |
Hi @andrei-cs What's happening is that PowerPoint creates this unique "1 legend item for every category" legend when you use different colors for the bars. Here is PowerPoint 2019 creating a bar chart from scratch and adding distinct colors:
|
@Slidemagic - thanks for the details. This issue is fixed in master; target v3.1.0 |
…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.
Same issue in 3.12.0. |
Creating a bar chart with one series and providing a chartColors array seems results in a graph looking like this:
Removing the chartColors param displays it correctly but I can't find another way of setting the color.
The problem is exactly as in this issue - #225
Providing a single element in the chartColors array solves the color problem but still creates a legend with all the values in the labels array.
Looking through the code it seems like it is somewhat of an intended behaviour:
PptxGenJS/dist/pptxgen.js
Lines 2691 to 2695 in e4c4602
How would one set a custom color for a bar chart ?
The text was updated successfully, but these errors were encountered: