Applying custom colors to bar charts in Cognos11 - cognos

I have a requirement to show a stacked and clustered bar chart in specific color given by the users in Cognos11 report studio. I have tried using the color palette options given in the chart properties but not able to apply my preferred color. Is there any way to achieve this in Cognos 11 Report Studio?

I'm not sure if this will work but:
In conditional formatting in Cognos you can use the RGB range to specify a precise colour.
You can also use hexadecimal colours - obviously that is a bit more complicated, and so you probably wouldn't, but if RGB doesn't work on a bar chart, maybe hexadecimal would
You can use Excel's DectoHex formula to convert an RGB colour to hexadecimal if you need to

Related

Using Excel VBA to individually color y-axis lables

I'm trying to figure out how to change the color of individual y-axis labels programmatically for a bar chart. Here's what the chart currently looks like:
Here's how I'd like it to look. (The colors on the "RX 5700 XT" lines are in red -- this is via a hasty PhotoShop hack, so this isn't set in stone, just an example of where I'm headed).
The problem is, I can't seem to find a way to programmatically get at the individual text labels. The actual text isn't necessarily hard-coded, but based on matching some pattern I want to change the text colors -- a secondary coding of data, if you will.
Background: This is for my charts at Tom's Hardware, for GPU reviews specifically. In this case, I have all GPUs tested with one CPU colored one way (lighter grey and red), and all GPUs tested with a different CPU colored a different way (darker grey and red). However, I also want to potentially differentiate between AMD and Nvidia GPUs -- so highlight the AMD GPUs in Dark Red text as an example.
There are about 60 charts total, so manually changing colors on each chart after generation would be extremely inefficient. I could just use different bar chart colors, but that also gets messy. Theoretically, I want to get at myChart.Axes(xlCategory).Format.TextFrame2.TextRange ... but TextFrame2 is a read-only property. I recorded a macro where I changed the axis font color, but even that macro fails to play back properly. :\
The axis labels on a chart cannot be colored individually. The axis font color applies to all text in the axis. Individual axis labels cannot be formatted differently. Not in the GUI and not with VBA.
Side note: You may want to review your color choices for the charts. The black/red/white in such close proximity is very hard on the eyes and causes eye strain and flimmer for some people.

Add extra labels to a chart

I'm using Excel 2016 and wanted to know how I can make a chart that represents a spectrum from left to right with labels on both sides, and a marker in the middle. Essentially I want to represent the Myers Briggs Type Indicator.
What I've tried so far is to make a horizontal bar chart with a marker, but I can't seem to get labels to the left and right. How might I be able to achieve this?
You just need to add text boxes from drawing tools and put them on top of the chart. Set their backgrounds to transparent by choosing no fill.

Define Excel custom number format color via HEX or RGB

Is it possible to define a custom number format via HEX or RGB, as in the following?
[Black][>5]0.0;[Red][<0]-0.0;[Color34]0.0
I'm looking for a dark orange color (#FF9900), and [Orange] doesn't work.
I've tried the full spectrum of 56 colors, as suggested by this article, or the few built in by name but none are even close to the correct shade of orange.
The few Excel has built in don't include orange:
[BLACK][GREEN][RED][BLUE][CYAN][MAGENTA][WHITE][YELLOW]
Making comments to an answer:
The only ways I know to achieve different font colors depending on values are:
Specifying colors in number formats - for this Microsoft itself documents only the 8 named ones [Black]...[Red], even [ColorNN] is an undocumented hack.
Conditional formatting.
Using VBA.
To specifying colors in number formats one needs to know the guidelines for customizing a number format. There only the 8 named colors [Black], [Green], [White], [Blue], [Magenta], [Yellow], [Cyan], [Red] are documented. But using [ColorNN] with NN being the color index is also possible for 56 indexed colors. To determine which colors are indexed with which index, one could using the following VBA macro:
Sub UDColorNumberFormats()
With ActiveSheet
For i = 1 To 56
sNumberFormat = "[Color" & i & "]0"
.Cells(i, 1).Value = sNumberFormat
.Cells(i, 2).NumberFormat = sNumberFormat
.Cells(i, 2).Value = 888888
.Cells(i, 3).Interior.ColorIndex = i
Next
End With
End Sub
Running this macro in Excel for Windows (versions 2007 up to 2016 tested) will show, that the [Color45] for example is orange color. But if we take a look at the Microsoft documentation of ColorIndex Property, we must see, that even Microsoft shows different indexed colors. Maybe simply not updated since earlier versions?
As #Zephyr Mays had to realize, Excel for Mac also uses different indexed colors. So Excel for Mac and Excel for Windows are not 100% compatible in this point. But the macro should run in Excel for Mac also. So one could check whether the indexed colors, which Excel for Mac uses, are the ones which are shown in documentation for ColorIndex Property. If so, then Excel for Mac uses a default color palette from earlier versions than Excel for Windows uses. This could be called a bug in my opinion and could be reported to Microsoft as such.
As I noted in comments above, the color indices used in [COLORNN] are different in Libreoffice/Openoffice Calc also. There they are even different from the interior color indices. And they are dependent on the platform (64-bit or 32-bit) also. For me, Libreoffice in 64-bit Ubuntu has 64 color indices (1-64) available while Libreoffice in 32-bit Windows has only 32 color indices (1-32) available. But this behavior is not a bug since Libreoffice/Openoffice Calc is not 100% Excel compatible and does not want it to be.
What about using:
Cells(1, 1).Interior.Color = RGB(&HFF, &H99, &H0)
I've looked through many threads like this, but the simplest solution for coloring numbers in CELLS is to use conditional formatting.
But for CHARTS, the easiest way is to use the basic font formatting option -- you can specify any hex value there. If you want to colorize only negative numbers, say, you can override the font formatting for positives by editing it in the number format code.
For instance: I want to color negative numbers on my chart scale Dark Red (a color that isn't one of the 56 colors Excel precoded).
select the chart's y-axis, go to font options in the toolbar, and turned the whole axis Dark Red.
To turn positive numbers black again, go to format axis -> axis options -> number -> format code.
Then specify positive numbers to be black "[Color1]#,##0%;-#,##0%".
Voila - only the negative numbers retain the Dark Red, while positives are hard coded to be black.
You still have to have one of your colors be one of the 56 Excel presets, but this allows you to set one to a different color.
Looks like excel uses ABGR (Alpha, Red, Green, Blue) instead of RGBA (Red, Green, Blue, Alpha).
Dark orange color, #FF9900 in RGB should be written with #0099FF in excel (#FF0099FF with alpha).
Cells(1, 1).Interior.Color = &hFF0099FF

How to change chart colors in VBA

I have to change the colors of a pie chart in VBA. I 'managed' to change the font color, which is not what I wanted, this way:
ActiveChart.Legend.LegendEntries(1).Border.ColorIndex = 6
I want to change the color of the actual piece of pie.
I also have to set specific colors, which are part of the standard palette. The 6 above gives me a flashy yellow but I want the colors highlighted here
When faced with problems like this, I usually record a macro and examine what Excel does. I'd try this:
ActiveChart.SeriesCollection(1).Points(1).Interior.ColorIndex = 6
For colors, check out the RGB(red,green,blue) function.

Is there a way to use logic in Excel to change fonts?

So I've been working with excel to change characters and colors within cells based on where numbers fall. For example when looking at values less than 10 a symbol will appear as red down arrows and values higher than 30 will be create a green up arrow. This is all well and good and I'm using the Wingdings 3 font on the cells along with various rules to change color. The problem is the middle range. I am attempting to have a circle of varying color appear when the cells being looked at contain values greater than 9 and less than 30 (currently it displays as a horizontal double headed arrow). The problem is the Wingdings 3 font does not include any circle symbols and I can't figure out how to use the Conditional Formatting to change the font based on numerical value.
Hopefully there is a fix to this so that I can continue working on this project.
Below is what my spread sheet currently produces:
Just kidding about the image I don't have enough reputation to do that yet.
Alright so the best way to do this (for my problem) was to go into the Conditional Formatting section of Excel and instead of using the IF function by cell just use the icon sets and manage the rules associated with them. I only needed a red and green arrows and circles and with some toying around with the settings a 4 symbol icon set with my chosen shapes did the trick. It ended up being simpler than the IF logic along with rule application I was attempting at the beginning. Just know that there are few symbol choices and no way to add more in the current version of Excel.

Resources