如何从非图表元素的调色板中选择颜色? [英] How to pick colours from a Color palette for non-chart elements?

查看:47
本文介绍了如何从非图表元素的调色板中选择颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为客户开发报告,我们有一个特定的要求,即我们要构建也显示在图表中的项目表.表格中将包含与图表颜色相同的对象(背景 - 有点像图表的手动构建图例).

I'm in the process of developing a report for a client, and we have a specific requirement that we build table of items that are also shown in a chart. The table will have objects in it which are coloured in the same way as the chart (background - kind of like a manually-constructed legend for the chart).

我想从用于图表的调色板中选择颜色,因为这会使其变得简单(只需对数据进行排序,它就会自然地呈现相同的颜色.

I would like to select colours from the colour palette used for the chart, as that would make it simple (just order the data and it'll come out with the same colours naturally.

不幸的是,我找不到任何方法来为表执行此操作.是否有表达式或其他东西可以访问我们可以放入背景颜色表达式字段的调色板?或者另一种方式来解决这个问题?

Unfortunately, I can't find any way to do this for a table. Is there an expression or something to access palettes that we can put into the background colour expression field? Or another way to go about this?

推荐答案

这听起来很复杂:找到正在使用的调色板,找出这些行用于图表的哪个部分,并相应地为它们着色,颜色的顺序会发生变化每次打印图表时.

That sounds complex: find the palette in use, work out what section of the chart these rows are for and colour them accordingly, with the order of the colours changing every time you print the chart.

一种更简单的方法是为您的分组强制执行颜色的一致性.例如,假设您按部门分组,希望 IT 为蓝色,财务为红色,HR 为绿色,等等.现在您可以使用 IIFSWITCH 语句执行此操作:

An easier way would be to enforce consistency of colours for your grouping. For example, let's say you are grouping by department and you want IT to be blue, Finance to be red, HR to be green, and so forth. Now you could do this using a IIF or SWITCH statement:

=Switch(Fields!Dept.Value = "IT", "Blue", Fields!Dept.Value = "Finance", "Red", Fields!Dept.Value = "HR", "Green")

但是,维护起来有点麻烦.在你的部门表上有一个颜色字段会更容易,然后在你的图表中使用它.例如,在条形图中,您可以执行以下操作:

However, that gets a bit messy to maintain. It is easier to have a colour field on your department table, then use this in your charts. For example, in bar graphs you do the following:

  1. 右键单击图表主体并选择属性
  2. 点击数据标签
  3. 在值"部分,点击编辑"按钮
  4. 点击外观标签
  5. 点击系列样式按钮
  6. 点击填充标签
  7. 在颜色文本框中,输入您想要的颜色的表达式.鉴于我们的部门数据库中已经有了这个,我们只需使用:

  1. Right click the chart body and choose Properties
  2. Click the Data tab
  3. In the Values section, click the Edit button
  4. Click on the Appearance tab
  5. Click the Series Style button
  6. Click the Fill tab
  7. In the Color text box, put the expression that you want the colour to be. Given that we have this in our department database already, we simply use:

=Fields!DeptColour.Value

=Fields!DeptColour.Value

然后我们的部门在每个条形图上的颜色都相同.

and then our departments are coloured the same on every bar graph.

对于折线图,您必须执行相同的操作,只是这次将颜色表达式放在系列样式"对话框的边框和线条"选项卡上的颜色"文本框中(而不是在填充"中).

For line graphs, you have to do the same except this time you put the colour expression in the Color text box on the Border and Line tab on the Series Style dialogue (rather than in the Fill).

这篇关于如何从非图表元素的调色板中选择颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆