最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

powerbi - color of bars change when publishing to power bi service from power bi desktop - Stack Overflow

programmeradmin3浏览0评论

This bug has been around for a while. I'm thinking about just building the charts in deneb because I can hard code the colors and not worry about BS like this. Does anyone else have any solutions? Is there a way to hard code bar chart colors in DAX? (this is a clustered column chart)

Power BI Desktop:

Power BI Service:

Here's the theme file

{
  "name": "whaleTheme",
  "dataColors": [
    "#00437B", "#F37021", "#FDB515", "#789904", "#C4D4A4",
    "#6DB6F4", "#FDDD15", "#FAC9AC", "#3599B8", "#DFBFBF",
    "#4AC5BB", "#5F6B6D", "#FB8281", "#F4D25A", "#7F898A",
    "#A4DDEE", "#FDAB89", "#B687AC", "#28738A", "#A78F8F",
    "#168980", "#293537", "#BB4A4A", "#B59525", "#475052",
    "#6A9FB0", "#BD7150", "#7B4F71", "#1B4D5C", "#706060",
    "#0F5C55", "#1C2325"
  ],
  "visualStyles": {
    "*": {
      "*": {
        "*": [
          {
            "fontFamily": "Arial",
            "color": {
              "solid": {}
            }
          }
        ]
      }
    },
    "barChart": {
      "*": {}
    },
    "clusteredBarChart": {
      "*": {}
    },
    "clusteredColumnChart": {
      "*": {}
    },
    "columnChart": {
      "*": {}
    },
    "hundredPercentStackedBarChart": {
      "*": {}
    },
    "hundredPercentStackedColumnChart": {
      "*": {}
    },
    "lineStackedColumnComboChart": {
      "*": {}
    },
    "lineClusteredColumnComboChart": {
      "*": {}
    },
    "scatterChart": {
      "*": {}
    },
    "pivotTable": {
      "*": {
        "total": [
          {
            "fontFamily": "Arial"
          }
        ]
      }
    },
    "ribbonChart": {
      "*": {}
    },
    "areaChart": {
      "*": {}
    },
    "lineChart": {
      "*": {}
    },
    "stackedAreaChart": {
      "*": {}
    },
    "waterfallChart": {
      "*": {}
    },
    "tableEx": {
      "*": {}
    },
    "slicer": {
      "*": {}
    },
    "filterSlicer": {
      "*": {}
    },
    "multiRowCard": {
      "*": {}
    }
  },
  "textClasses": {
    "label": {
      "fontFace": "'Segoe UI', wf_segoe-ui_normal, helvetica, arial, sans-serif"
    },
    "callout": {
      "fontFace": "'Segoe UI', wf_segoe-ui_normal, helvetica, arial, sans-serif"
    },
    "title": {
      "fontFace": "'Segoe UI', wf_segoe-ui_normal, helvetica, arial, sans-serif"
    },
    "header": {
      "fontFace": "'Segoe UI', wf_segoe-ui_normal, helvetica, arial, sans-serif"
    }
  }
}

This bug has been around for a while. I'm thinking about just building the charts in deneb because I can hard code the colors and not worry about BS like this. Does anyone else have any solutions? Is there a way to hard code bar chart colors in DAX? (this is a clustered column chart)

Power BI Desktop:

Power BI Service:

Here's the theme file

{
  "name": "whaleTheme",
  "dataColors": [
    "#00437B", "#F37021", "#FDB515", "#789904", "#C4D4A4",
    "#6DB6F4", "#FDDD15", "#FAC9AC", "#3599B8", "#DFBFBF",
    "#4AC5BB", "#5F6B6D", "#FB8281", "#F4D25A", "#7F898A",
    "#A4DDEE", "#FDAB89", "#B687AC", "#28738A", "#A78F8F",
    "#168980", "#293537", "#BB4A4A", "#B59525", "#475052",
    "#6A9FB0", "#BD7150", "#7B4F71", "#1B4D5C", "#706060",
    "#0F5C55", "#1C2325"
  ],
  "visualStyles": {
    "*": {
      "*": {
        "*": [
          {
            "fontFamily": "Arial",
            "color": {
              "solid": {}
            }
          }
        ]
      }
    },
    "barChart": {
      "*": {}
    },
    "clusteredBarChart": {
      "*": {}
    },
    "clusteredColumnChart": {
      "*": {}
    },
    "columnChart": {
      "*": {}
    },
    "hundredPercentStackedBarChart": {
      "*": {}
    },
    "hundredPercentStackedColumnChart": {
      "*": {}
    },
    "lineStackedColumnComboChart": {
      "*": {}
    },
    "lineClusteredColumnComboChart": {
      "*": {}
    },
    "scatterChart": {
      "*": {}
    },
    "pivotTable": {
      "*": {
        "total": [
          {
            "fontFamily": "Arial"
          }
        ]
      }
    },
    "ribbonChart": {
      "*": {}
    },
    "areaChart": {
      "*": {}
    },
    "lineChart": {
      "*": {}
    },
    "stackedAreaChart": {
      "*": {}
    },
    "waterfallChart": {
      "*": {}
    },
    "tableEx": {
      "*": {}
    },
    "slicer": {
      "*": {}
    },
    "filterSlicer": {
      "*": {}
    },
    "multiRowCard": {
      "*": {}
    }
  },
  "textClasses": {
    "label": {
      "fontFace": "'Segoe UI', wf_segoe-ui_normal, helvetica, arial, sans-serif"
    },
    "callout": {
      "fontFace": "'Segoe UI', wf_segoe-ui_normal, helvetica, arial, sans-serif"
    },
    "title": {
      "fontFace": "'Segoe UI', wf_segoe-ui_normal, helvetica, arial, sans-serif"
    },
    "header": {
      "fontFace": "'Segoe UI', wf_segoe-ui_normal, helvetica, arial, sans-serif"
    }
  }
}
Share Improve this question edited Jan 20 at 13:39 zach asked Jan 19 at 15:12 zachzach 1,2311 gold badge14 silver badges27 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can specify each category colour in the chart properties. Switch the series to each one and specify the desired formatting.

Unfortunately, setting the values via DAX & Conditional Formatting is only possible without a Legend.


I've managed to reproduce the same behaviour as you are experiencing. You do need to set each column colour as above for every category. Even though it preselects a colour from the theme, you do need to select it for each one.

Seems Power BI Desktop also has some kind of visual theme cache going on. If you export your theme, and then re-import it (via Browse for themes), then PBI Desktop will reflect what is published to PBI Service. Saving, closing, and re-opening PBI Desktop does the same.

So take aways are:

  • Do manually select every column colour (even those that may be filtered).
  • Re-importing your theme (or restarting) clears whatever theme cache/calculation is going on, and this will be what you'll see in PBI Service.
发布评论

评论列表(0)

  1. 暂无评论