How to pick colours from a Color palette for non-chart elements?

瘦欲@ 提交于 2019-12-12 01:11:20

问题


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?


回答1:


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.

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. 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

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).



来源:https://stackoverflow.com/questions/17268046/how-to-pick-colours-from-a-color-palette-for-non-chart-elements

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!