Skip to content

[Question]Coloring bars different colors when plotting 2 series #1198

@divyansh997

Description

@divyansh997

Issue Category

  • Question

Product Versions

  • Please specify what version of the library you are using......: [3.11.0]
  • Please specify what web browser you are using.................: [ Chrome ]

Desired Behavior

When plotting two series bar charts, how do I color the bars individually of different colors?

What I want to achieve is this -

image

I have achieved this -

image

Steps to Reproduce

I tried coloring the bars individually by passing in two arrays inside an array for param chartColors like so -

slide.addChart(pptx.ChartType.bar, data,
        {
          x: 0.15, y: 1.4, w: 8, h: 3.7,
          layout: { x: 0.3, y: 0.05, w: 1, h: 0.8 },
          barDir: "col",
          barGapWidthPct: 80,
          barOverlapPct: 50,
          chartColors: [['e5e5e5'], ['7a86cc', '4ed1e1', '83c786', '7a86cc']],
        });

This does not work, I also tried passsing it as a single array chartColors: ['e5e5e5', '7a86cc', '4ed1e1', '83c786', '7a86cc'] but that does not work either. The second series always picks up the color at index 1('7a86cc') and that color remains for the whole series.
Is this currently supported? And if yes how do i pass the chartColors for it? I couldn't find any relevant documentation for this specific use-case. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions