Power BI 中颜色格式设置的提示和技巧Tips and tricks for color formatting in Power BI

Power BI 提供了自定义仪表板和报表的多种方法。Power BI provides many different ways to customize your dashboards and reports. 本文详细介绍了一些技巧,可以让你的 Power BI 可视化效果更引人注目、生动有趣,并可根据你的需求进行自定义。This article details a collection of tips that can make your Power BI visualizations more compelling, interesting, and customized to your needs.

本文提供以下技巧。The following tips are provided. 还有更好的技巧?Have another great tip? 太棒了!Great! 请将其发送给我们,我们会考虑将其添加到此列表中。Send it our way and we’ll see about adding it to this list.

  • 更改单个数据点的颜色Change the color of a single data point
  • 根据数值设置图表的颜色Base the colors of a chart on a numeric value
  • 根据字段值设置数据点的颜色Base the color of data points on a field value
  • 在色阶中自定义使用的颜色Customize colors used in the color scale
  • 使用发散色阶Use diverging color scales
  • 如何在 Power BI 中撤消操作How to undo in Power BI

要进行任何更改都必须编辑报表:从我的工作区窗格中选择报表,然后从顶部的菜单区域选择编辑报表,如下图所示。To make any changes, you must be editing a report: select your Report from the My Workspace pane, then select Edit Report from the top menu area, as shown in the following image.

可视化效果窗格出现在报表画布的右侧时,即可开始进行自定义操作。When the Visualizations pane appears along the right side of the Report canvas, you’re ready to start customizing.

更改单个数据点的颜色Change the color of a single data point

有时你想突出显示某个特定的数据点。Sometimes you want to highlight one particular data point. 该数据点可能是推出的新产品的销售数据,或是推出新计划后增加的质量分数。Perhaps it’s sales figures for the launch of a new product, or increased quality scores after launching a new program. 使用 Power BI 可以通过更改其颜色来突出显示某个特定的数据点。With Power BI, you can highlight a particular data point by changing its color.

以下可视化效果按生活费用对各个州进行了排序。The following visualization ranks states in terms of cost of living.

现在假设你想通过使用颜色来快速显示出华盛顿在该排名列表中的位置。Now imagine you want to quickly show where Washington lands in that ranked list, by using color. 步骤如下:Here are the steps:

展开数据颜色部分。Expand the Data Colors section. 将出现以下内容。The following appears.

显示全部设置为开启Set Show All to On. 此操作将显示可视化效果中每个数据元素的颜色。This displays the colors for each data element in the visualization. 将鼠标悬停在数据点上时,将启用滚动,此时你可以修改任何数据点。When you hover over the data points, scrolling is enabled so you can modify any of the data points.

在本案例中,我们将华盛顿更改为绿色。In this case, let’s change Washington to green. 向下滚动到华盛顿并选择其颜色框中的向下箭头,之后将出现颜色选择窗口。We scroll down to Washington and select the down arrow inside its color box, and the color selection window appears.

选择颜色后,华盛顿数据点将显示为美丽的绿色阴影,自然就很显眼了。Once selected, the Washington data point is a nice shade of green, and certainly stands out.

即使更改了可视化效果类型,返回时 Power BI 仍会记住你的选择,并将华盛顿保留为绿色。Even if you change visualization types, then return, Power BI remembers your selection and keeps Washington green.

你也可以更改多个数据元素的数据点的颜色。You can change the color of a data point for more than one data element, too. 在下图中,亚利桑那为红色,华盛顿仍为绿色。In the following image, Arizona is red, and Washington is still green.

可以使用颜色进行各种操作。There are all sorts of things you can do with colors. 在下一部分中,我们将来了解渐变。In the next section, we take a look at gradients.

根据数值设置图表的颜色Base the colors of a chart on a numeric value

可以根据字段的数值动态设置颜色,这样可以让图表发挥出巨大作用。Charts often benefit from dynamically setting color based on the numeric value of a field. 通过执行此操作,除了表示条形图大小的数值之外,还能显示其他的值,并且可以在一个图表中显示两个值。By doing this, you could show a different value than what’s used to for the size of a bar, and show two values on a single graph. 或者可以通过此操作来突出显示高于(或低于)特定值的数据点 - 例如突出显示盈利能力较低的区域。Or you can use this to highlight data points over (or under) a certain value – perhaps highlighting areas of low profitability.

以下部分演示了根据数值设置颜色的不同方式。The following sections demonstrate different ways to base color on a numeric value.

根据数值设置数据点的颜色Base the color of data points on a value

若要根据数值更改颜色,请将你想设置颜色的字段拖动到字段窗格中的色彩饱和度区域。To change color based on a value, drag the field you want to base color on into the Color Saturation area in the Field pane. 在下图中,已将税前收益拖动到色彩饱和度区域中。In the following image, Profit before tax has been dragged into Color Saturation. 可以看到,尽管维络城具有更高的总销售额(该列更高),但阿马里亚具有更大的税前收益(该列的颜色饱和度更大)。As can see that, although Velo has higher Gross Sales (its column is higher), Amarilla has a larger Profit before tax (its column has more color saturation).

在色阶中自定义使用的颜色Customize the colors used in the color scale

你还可以在色阶中自定义使用的颜色。You can customize colors used in the color scale, too. 展开数据颜色,你会看到让数据出现可视化效果的颜色渐变。Expand Data Colors and you see a gradient of colors used for visualizing your data. 默认情况下,数据中的最低值对应饱和度最小的颜色,而最高值对应饱和度最大的颜色。By default, the lowest value in your data is mapped to the least saturated color, and the highest value to the most saturated color.

色域通过渐变栏进行显示,显示介于最小值最大值的颜色值之间的色谱。最小值的颜色位于左侧,最大值的颜色位于右侧。The color range is shown in a gradient bar that displays the spectrum between Minimum and Maximum color values, with the Minimum value color on the left, and Maximum value color to the right.

若要更改色阶以使用其他的色域,请选择最小值最大值旁边的颜色下拉菜单并选择一种颜色。To change the scale to use a different range of colors, select the color drop-down beside Minimum or Maximum, and select a color. 下图展示了将“最大值”颜色更改为黑色。渐变栏展示了介于“最小值”到“最大值”之间的新色谱。The following image shows the Maximum color changed to black, and the gradient bar shows the new color spectrum between Minimum and Maximum.

你还可以更改数值对应这些颜色的方式。You can also change the way the values map to these colors. 在下图中,已分别将最小值最大值设置为橙色和绿色。In the following image, the colors for Minimum and Maximum are set to orange and green, respectively.

在第一张图片中,请注意图表中的条形图是如何反映渐变栏中的渐变的;最高的值为绿色,最低的值为橙色,中间的条形图都以介于绿色和橙色之间的色谱着色。In this first image, notice how the bars in the chart reflect the gradient shown in the bar; the highest value is green, the lowest is orange, and each bar between is colored with a shade of the spectrum between green and orange.

现在我们来看如果在最小值最大值框中输入数值将会发生什么。该框位于最小值最大值颜色选择器的下方。(如下图所示))Now, let’s see what happens if we provide numeric values in the Minimum and Maximum value boxes, which are below the Minimum and Maximum color selectors (shown in the following image). 我们将最小值设置为 20,000,000,并将最大值设置为 20,000,000。Let’s set Minimum to 20,000,000, and set Maximum to 20,000,000.

设置这两个值后,渐变将不再应用于图表上低于最小值或高于最大值的值;任何高于最大值的条形图都会以绿色显示,并且任何低于最小值的条形如都会以红色显示。By setting those values, gradient is no longer applied to values on the chart that are below Minimum or above Maximum; any bar with a value over Maximum value is colored green, and any bar with a value under Minimum value is colored red.

使用发散色阶Use Diverging color scales

有时你的数据可能有自然的发散色阶。Sometimes your data may have a naturally diverging scale. 例如,温度范围有自然的中间点(冻结点),盈利能力分数有自然的中间点(零)。For example, a temperate range has a natural center at freezing point, and a profitability score has a natural mid-point (zero).

若要使用发散色阶,请将发散滑块滑动到开启的位置。To use diverging color scales, slide the Diverging slider to On. 发散处于开启状态时,将出现另一个颜色选择器和数值框,两者都被称为中间点When Diverging is turned on, an additional color selector and value box, both called Center, appear, as shown in the following image.

发散处于开启状态时,你可以单独设置最小值最大值中间点的颜色。When the Diverging slider is on, you can set the colors for Minimum, Maximum and Center separately. 下图中,中间点设置为 1,因此值高于 1 的条形图将显示为渐变的绿色,值低于 1 的条形图则显示为红色。In the following image, Center is set to one, so bars with values above one are a gradient shade of green, and bars below one are shades of red.

如何在 Power BI 中撤消操作How to undo in Power BI

与许多其他 Microsoft 服务和软件相类似,Power BI 提供了撤消上一项命令的简单方法。Like many other Microsoft services and software, Power BI provides an easy way to undo your last command. 例如,假设你更改了某个数据点或一系列数据点的颜色,但当其出现在可视化效果中时你不喜欢该颜色。For example, let’s say you change the color of a data point, or a series of data points, and you don’t like the color when it appears in the visualization. 你不记得之前它是什么颜色,但是你知道你想用回之前的颜色!You don’t recall exactly which color it was before, but you know you want that color back!

若要撤消上一次操作,或最近几次操作,只需要:To undo your last action, or the last few actions, all you have to do is:

  • 按 CTRL+ZType CTRL+Z

反馈Feedback

你是否拥有想要共享的技巧?Do you have a tip you’d like to share? 请将其发送给我们,我们会考虑将其列在此处。Please send it our way, and we’ll see about including it here.

备注

这些颜色、轴以及相关的自定义项在选中“格式”图标时可用,在 Power BI Desktop 中也可用。These color, axis, and related customizations, available when the Format icon is selected, are also available in Power BI Desktop.

后续步骤Next steps

颜色格式设置和轴属性入门Getting started with color formatting and axis properties