0

I have two similar javascripting challenges I am looking to solve in Cognos with the help of conditional formatting.

I would like to be able to show a data item, for only the item that I am comparing other items to in Cognos. For example, If my chart shows a comparison of Florida to the rest of the US States -- Florida is what I am doing am doing the comparison to within my charts.

So I would like to show the data label for Florida only. Conditional formatting in Cognos will let you either turn all item labels on, or off. I am looking to find a way to turn them all on with conditional formatting, but hide all the values, except the Florida value which is the focus of my report with javascript.

Here is an example of my chart and how it looks with all the data labels showing: https://i.stack.imgur.com/Hq89s.jpg I only need to show the number for Florida. The rest of the numbers make the chart look way too cluttered.

Also - My second challenge is when my mouse hovers over the other labels - I would like to show the values for them (but only on hover). So basically the label will default to showing the Florida label only, but if the user hovers over the United States, or the World values - then the user will be able to see that item.

1 Answers1

1

Yeah conditional rendering unfortunately is not available everywhere, so it's not a viable solution.

Writing JS against a chart is tough, but I suppose not impossible. First, I'd highly recommend the FireBug plugin for Firefox. It will allow you to more easily see the generated HTML for a graph in Cognos. I just looked at a sample bar chart. Unfortunately, none of the elements have individual IDs. You will have to pull the "area" elements by attribute. The hover text for the bars and the label text are both in the TITLE attribute.

I have to put the obligatory "no JS" statement in here as I guarantee such a solution will break between versions of Cognos and potentially browsers.

An alternative may be to hide the standard chart labels and put Singletons below the chart to control the shown information.

If you still need help - can you take a screenshot of this chart? If not - can you elaborate on what type of chart it is and what other data values exist (other than FL, US, World). I think I may not be visualizing this properly.

Community
  • 1
  • 1
toddsonofodin
  • 513
  • 2
  • 4
  • Here is an example image -- I only need the label that shows the amount for Florida. All the other amounts make this chart look way too cluttered http://i.imgur.com/aM4gEYu.jpg – charlotte2483 Jul 23 '13 at 11:49
  • Looking at the underlying HTML some more, I dont think it would be possible to hide the titles as they are not isolated to a given tag. The title field is actually DATA FIELD - VALUE. Its not clear how they're actually populated to me, perhaps there is Cognos JS which parses this out. How about instead create two series, one of FL, one of everything but FL. Make FL red and the others blue (or something similar). Put a text box at the bottom saying red = FL. You could make it dynamic with a prompt and singleton if needed as well. – toddsonofodin Jul 23 '13 at 15:19
  • The center list that powers the chart is dynamic - so if the user selects Florida from a dropdown list, the conditional formatting makes it blue, if the user selects South Carolina from a list - then South Carolina becomes blue. – charlotte2483 Jul 23 '13 at 16:14
  • Yep. Just do it by creating the separate series dynamically using the parameter (perhaps a prompt macro), then put a singleton below the chart with the parameter name. – toddsonofodin Jul 24 '13 at 13:19
  • What is your opinion on publishing the HTML file, going in and attempting to copy the HTML and javascript files that power this chart, deleting out the previous chart, and then pasting the code Cognos generated back into the front end of the report -- in your opinion is this worth a try to be able to have additional control over idividual items within a chart? – charlotte2483 Jul 24 '13 at 15:40
  • Im not sure youd be able to isolate the HTML and JS required. There is a ton of proprietary JS in the header. Doubtful youd be able to retain the dynamic aspects of the report. To some extent the tool is the tool. It will not be able to handle every possible case scenario the business dreams up. Getting into custom HTML/JS solutions ALWAYS turns out to be a nightmare when upgrading. I know people who will be on v8 for years to come because of half baked solutions like this and I have no pity for them :). – toddsonofodin Jul 24 '13 at 19:00
  • So I found out that the data labels are controlled by XML, not by Javascript. Here is the code that turns the labels on within the XML: -- now how to render this code and only turn on the one lable, I still am uncertain, but I thought I'd share – charlotte2483 Jul 26 '13 at 03:36