在 Power BI Desktop 报表中使用网格线和对齐网格Use gridlines and snap-to-grid in Power BI Desktop reports

Power BI Desktop 报表画布提供网格线功能,以便你可以在报表页上巧妙地对齐视觉对象,并使用对齐网格功能,以便报表中的视觉对象清晰整齐且均匀分布。The Power BI Desktop report canvas provides gridlines that let you neatly align visuals on a report page and use snap-to-grid functionality so the visuals in your report look clean, aligned, and evenly spaced.

在 Power BI Desktop 中,还可以调整报表上对象的 z 顺序(上移一层、下移一层),并能在画布上对齐或均匀分布选定的视觉对象。In Power BI Desktop, you can also adjust the z-order (bring forward, send backward) of objects on a report and align or evenly distribute selected visuals on the canvas.

报表画布的屏幕截图,其中显示了如何在 Power BI Desktop 报表中使用网格线和对齐网格。

启用网格线和对齐网格Enabling gridlines and snap-to-grid

若要启用网格线和与网格对齐功能,请选择“视图”功能区,然后选中“显示网格线”和“将对象与网格对齐”复选框。To enable gridlines and snap-to-grid, select the View ribbon, then enable the checkboxes for Show gridlines and Snap objects to grid. 你可选择一个或两个选项,它们将独立运行。You can select one or both options; they operate independently.

报表画布的屏幕截图,其中显示了如何在Power BI Desktop 报表中启用网格线和对齐网格。

备注

如果禁用了“显示网格线”和“对象与网格对齐”,则连接到任何数据源可启用这两个选项。If Show gridlines and Snap objects to grid are disabled, connect to any data source and they become enabled.

使用网格线Using gridlines

网格线是可见的指南,可帮助你对齐视觉对象。Gridlines are visible guides that help you align your visuals. 尝试确定两个(或更多)视觉对象是否水平或垂直对齐时,可使用网格线来确定其边框是否对齐。When you're trying to determine whether two (or more) visuals are aligned horizontally or vertically, use the gridlines to determine whether their borders align.

可以通过按住 Ctrl 并单击来一次性选择多个视觉对象,该操作可显示所有所选视觉对象的边框,并显示视觉对象是否正确对齐。Use Ctrl+Click to select more than one visual at a time, which displays all selected visuals' borders and shows whether the visuals are properly aligned.

报表画布的屏幕截图,其中显示了如何使用网格线对齐视觉对象。

在视觉对象中使用网格线Using gridlines inside visuals

Power BI 的视觉对象中也有网格线,提供用于比较数据点和值的视觉引导。In Power BI there are also gridlines inside visuals that provide visible guides for comparing data points and values. 从 2017 年 9 月发行版 Power BI Desktop 开始,现在可以使用“可视化效果”窗格“格式”部分中的“X 轴”或“Y 轴”卡(具体根据视觉对象类型而定)管理视觉对象中的网格线。Beginning with the September 2017 release of Power BI Desktop, you can now manage the gridlines within visuals using the X-Axis or Y-Axis card (as appropriate based on visual type), found in the Format section of the Visualizations pane. 可以在视觉对象中管理网格线的下列元素:You can manage the following elements of gridlines within a visual:

  • 打开或关闭网格线Turn gridlines on or off
  • 更改网格线的颜色Change the color of gridlines
  • 调整网格线的笔划(宽度)Adjust the stroke (the width) of gridlines
  • 选择视觉对象中网格线的线型,如实线、虚线或点线Select the line style of the gridlines in the visual, such as solid, dashed, or dotted

修改网格线的某些元素对于视觉对象使用深色背景的报表特别有用。Modifying certain elements of gridlines can be especially useful in reports where dark backgrounds are used for visuals. 下图显示了“Y 轴”卡中的“网格线”部分 。The following image shows the Gridlines section in the Y-Axis card.

视觉对象的屏幕截图,其中显示了“Y 轴”卡中的“网格线”部分。

使用对齐网格Using snap-to-grid

启用“对象与网格对齐”后,你在 Power BI Desktop 画布上移动(或调整大小)的所有视觉对象将自动对齐到最近的网格轴,从而大大简化了确保两个或多个视觉对象对齐到相同水平或垂直位置或大小的过程。When you enable Snap objects to grid, all visuals on the Power BI Desktop canvas that you move (or resize) are automatically aligned to the nearest grid axis, making it much easier to ensure two or more visuals align to the same horizontal or vertical location or size.

报表画布的屏幕截图,其中显示了网格线和对齐网格如何确保报表中的视觉对象完全对齐。

这就是使用“网格线”和“对齐网格”来确保报表中的视觉对象完全对齐的全部过程 。And, that's all there is to using gridlines and snap-to-grid to ensure the visuals in your reports are neatly aligned.

使用 z 顺序、对齐和分布Using z-order, align, and distribute

可以管理报表中视觉对象的从前向后顺序,通常将这称为元素的 z 顺序。You can manage the front-to-back order of visuals in a report, often referred to as the z-order of elements. 通过此功能,你可以任何所需的方式重叠视觉对象,然后调整每个视觉对象的从前向后顺序。This feature lets you overlap visuals in any way you want, then adjust the front-to-back order of each. 可使用“上移一层”和“下移一层”按钮设置视觉对象的顺序,这些按钮位于“格式”功能区的“排列”部分中 。You set the order of your visuals using the Bring Forward and Send Backward buttons, found in the Arrange section of Format ribbon. 选择页面上的一个或多个视觉对象后,“格式”功能区随即出现。The Format ribbon appears as soon as you select one or more visuals on the page.

报表画布的屏幕截图,其中显示了如何管理报表中视觉对象的从前向后顺序。

“格式”功能区可让你通过多种不同的方式对齐视觉对象,确保视觉对象以最合适的外观和方式在页面中对齐显示。The Format ribbon lets you align your visuals in many different ways, which ensures your visuals appear on the page in the alignment that looks and works best.

报表画布的屏幕截图,其中显示了如何通过多种不同的方式对齐视觉对象。

使用“对齐”按钮,可将选定视觉对象与报表画布的边缘(或中心)对齐,如下图所示。The Align button aligns a selected visual to the edge (or center) of the report canvas, as shown in the following image.

报表画布的屏幕截图,其中显示了如何使用“对齐”按钮将选定的视觉对象与画布的边缘(或中心)对齐。

选择两个或多个视觉对象后,可以将它们一起与所有选定视觉对象的现有对齐边界对齐。When two or more visuals are selected, they are aligned together and use the existing aligned boundary of the visuals for their alignment. 例如,如果你选择了两个视觉对象,然后选择了“左对齐”按钮,那么这两个视觉对象会与所有选定视觉对象的最左边界对齐。For example, if you select two visuals and choose the Align Left option, the visuals then align to the left-most boundary of all selected visuals.

报表画布的屏幕截图,其中显示了如何使用“左对齐”选项将两个视觉对象对齐。

还可以在报表画布中均匀地分布视觉对象,无论是垂直分布还是水平分布。You can also distribute your visuals evenly across the report canvas, either vertically or horizontally. 只需使用“格式”功能区中的“分布”按钮即可。Just use the Distribute button from the Format ribbon.

报表画布的屏幕截图,其中显示了如何使用“分布”选项在画布上均匀地分布视觉对象。

选择相应的网格线、对齐方式和分布工具后,报表将按你希望的方式呈现。With a few selections from these gridlines, alignment, and distribution tools, your reports will look just how you want them to.