The bar color changes in the diagram.

Issue #1233 open
Magnus Schieder
created an issue

Hello, I got a file where openpyxl (v2.6.1) unfortunately changes the bar color in the charts. I couldn't create a charts myself with the same effects.

After reading and writing there are two places where the idx values are wrong.

1)

original/xl/charts/chart1.xml

     <c:barChart>                                                               
        <c:barDir val="bar"/>                                                    
        <c:grouping val="percentStacked"/>                                       
        <c:varyColors val="0"/>                                                  
        <c:ser>                                                                  
          <c:idx val="1"/>                                                       
          <c:order val="0"/>                                                     
          <c:tx>                                                                 
            <c:strRef>

edited/xl/charts/chart1.xml

      <barChart>                                                                 
        <barDir val="bar"/>                                                      
        <grouping val="percentStacked"/>                                         
        <varyColors val="0"/>                                                    
        <ser>                                                                    
          <idx val="0"/>                                                         
          <order val="0"/>                                                       
          <tx>                                                                   
            <strRef>

2)

original/xl/charts/chart1.xml

        </c:ser>                                                                 
        <c:ser>                                                                  
          <c:idx val="2"/>                                                       
          <c:order val="1"/>                                                     
          <c:tx>                                                                 
            <c:strRef>

edited/xl/charts/chart1.xml

      </ser>                                                                   
        <ser>                                                                    
          <idx val="1"/>                                                         
          <order val="1"/>                                                       
          <tx>                                                                   
            <strRef>

original:

original.PNG

edited:

edited.PNG

Comments (7)

  1. CharlieC

    A closer look at this suggests that this is comination of the introduction of colour palettes (in Excel 2013, I think) and the index of the data series. There is no documented correlation between the index and the colour in the OOXML specification.

  2. Magnus Schieder reporter

    Hello, thanks for the patch.

    In this chart the colors are unfortunately still mixed up.

    original /xl/charts/chart1.xml

            <c:ser>    
              <c:idx val="0"/>
              <c:order val="1"/>
              <c:tx>
                <c:strRef>
    

    before the patch /xl/charts/chart1.xml

            <ser>
              <idx val="1"/>
              <order val="1"/>
              <tx>
                <strRef>
    

    after the patch /xl/charts/chart1.xml

            <ser>
              <idx val="1"/>
              <order val="1"/>
              <tx>
                <strRef>
    

    original:

    original2.PNG

    edited:

    edited2.PNG

  3. Log in to comment