Você está na página 1de 15

Proven Practice

Create Custom Chart Palettes for IBM Cognos 8 Report Studio


Product(s): IBM Cognos 8 Report Studio Area of Interest: Customization

Create Custom Chart Palettes for IBM Cognos 8 Report Studio

Copyright and Trademarks Licensed Materials - Property of IBM. Copyright IBM Corp. 2009 IBM, the IBM logo, and Cognos are trademarks or registered trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at http://www.ibm.com/legal/copytrade.shtml While every attempt has been made to ensure that the information in this document is accurate and complete, some typographical errors or technical inaccuracies may exist. IBM does not accept responsibility for any kind of loss resulting from the use of information contained in this document. The information contained in this document is subject to change without notice. This document is maintained by the Best Practices, Product and Technology team. You can send comments, suggestions, and additions to cscogpp@ca.ibm.com.

Create Custom Chart Palettes for IBM Cognos 8 Report Studio

Contents
1 1.1 1.2 1.3 1.4 2 2.1 3 4 5 6 INTRODUCTION ............................................................................................ 4 PURPOSE ................................................................................................................ 4 APPLICABILITY ......................................................................................................... 4 ASSUMPTIONS.......................................................................................................... 4 EXCLUSIONS AND EXCEPTIONS ..................................................................................... 4 OVERVIEW .................................................................................................... 4 CREATE A NEW PALETTE ENTRY IN THE CHARTPALETTES.XML FILE ........................................ 7 ADD THE NAME AND SCREEN TIP ENTRIES IN THE REPORTSTUDIO_XX.XML FILES.................................................................. 10 CREATE A NEW GIF IMAGE (IBM COGNOS 8.4).......................................... 12 CONCLUSION .............................................................................................. 14 APPENDIX - SINGLE PRODUCT LANGUAGE ENVIRONMENT....................... 15

Create Custom Chart Palettes for IBM Cognos 8 Report Studio

1 Introduction
1.1 Purpose This article describes the process by which you can add new chart palettes or customize existing chart palettes for use in IBM Cognos 8 Report Studio. Applicability This document was written using a single-server install of IBM Cognos 8.4, but may apply to other versions of IBM Cognos 8. However, file locations and processes may differ slightly in older versions of the product and palette gif images are new in IBM Cognos 8.4. Assumptions This document assumes familiarity with XML. Exclusions and Exceptions The process described in this document may change in future releases of the product. Be sure to document code changes and maintain copies of the code in the event an update or upgrade of IBM Cognos 8 overwrites modified files.

1.2

1.3

1.4

2 Overview
Chart palettes are used to apply different color schemes, gradients, or patterns to charts when the report runs. Some customers may want to use specific colors for their chart palettes that suit their corporate colors. By editing two IBM Cognos 8 system XML files (ChartPalettes.xml and reportstudio_xx.xml, where xx represents a language code) and a gif image, it is possible to change existing chart palettes as well as create new palettes. The ChartPalettes.xml file contains palette entries which identify the palette and define how a palette will appear. The reportstudio_xx.xml files (where xx represents a language value) contain string values for Report Studio UI elements. These files are used to support multiple product languages.

Create Custom Chart Palettes for IBM Cognos 8 Report Studio To apply a chart palette in Report Studio: 1. Add a chart to the report. 2. Select the chart in the report layout. 3. In the Properties pane, under the Color & Background section, click the ellipses for the Palette property to open the Palette dialog box.

The Palette dialog box appears as shown below displaying the Default palette:

Create Custom Chart Palettes for IBM Cognos 8 Report Studio A chart report with the Default palette applied appears similar to the report shown below:

In this document, the default palette will be used as a template to create a new palette.

Create Custom Chart Palettes for IBM Cognos 8 Report Studio

2.1 Create a New Palette Entry in the ChartPalettes.xml File Again, the ChartPalettes.xml file contains palette entries which identify the palette and define how a palette will appear. 1. Navigate to <IBM Cognos 8.4 install location>\webcontent\pat\res, and then open the ChartPalettes.xml file in Notepad or an XML editor. 2. Copy the section bolded below:
<resources> <xmlFragment id="NamedChartPalettes"> <namedChartPalettes> <namedChartPalette id="normalDefault" smallIcon="chart/palette/normal/default.gif" idsLabel="IDS_PAL_NAME_default" idsTooltip="IDS_PAL_TOOLTIP_default"> <chartPalette> <chartColor value="#333399"/> <chartColor value="#CC9933"/> <chartColor value="#993333"/> <chartColor value="#CCCC00"/> <chartColor value="#336633"/> <chartColor value="#6699CC"/> <chartColor value="#FF0033"/> <chartColor value="#FF6633"/> <chartColor value="#CC0099"/> <chartColor value="#66CC00"/> <chartColor value="#0033FF"/> <chartColor value="#6666FF"/> <chartColor value="#9900FF"/> <chartColor value="#339966"/> <chartColor value="#FFCC00"/> <chartColor value="#6633CC"/> <chartColor value="#999999"/> </chartPalette> </namedChartPalette>

This section represents one chart palette entry in the XML document. This section will be reused as a template for a new palette.

Create Custom Chart Palettes for IBM Cognos 8 Report Studio 3. Paste the copied section below the original.
<resources> <xmlFragment id="NamedChartPalettes"> <namedChartPalettes> <namedChartPalette id="normalDefault" smallIcon="chart/palette/normal/default.gif" idsLabel="IDS_PAL_NAME_default" idsTooltip="IDS_PAL_TOOLTIP_default"> <chartPalette> <chartColor value="#333399"/> <chartColor value="#CC9933"/> <chartColor value="#993333"/> <chartColor value="#CCCC00"/> <chartColor value="#336633"/> <chartColor value="#6699CC"/> <chartColor value="#FF0033"/> <chartColor value="#FF6633"/> <chartColor value="#CC0099"/> <chartColor value="#66CC00"/> <chartColor value="#0033FF"/> <chartColor value="#6666FF"/> <chartColor value="#9900FF"/> <chartColor value="#339966"/> <chartColor value="#FFCC00"/> <chartColor value="#6633CC"/> <chartColor value="#999999"/> </chartPalette> </namedChartPalette> <namedChartPalette id="normalDefault" smallIcon="chart/palette/normal/default.gif" idsLabel="IDS_PAL_NAME_default" idsTooltip="IDS_PAL_TOOLTIP_default"> <chartPalette> <chartColor value="#333399"/> <chartColor value="#CC9933"/> <chartColor value="#993333"/> <chartColor value="#CCCC00"/> <chartColor value="#336633"/> <chartColor value="#6699CC"/> <chartColor value="#FF0033"/> <chartColor value="#FF6633"/> <chartColor value="#CC0099"/> <chartColor value="#66CC00"/> <chartColor value="#0033FF"/> <chartColor value="#6666FF"/> <chartColor value="#9900FF"/> <chartColor value="#339966"/> <chartColor value="#FFCC00"/> <chartColor value="#6633CC"/> <chartColor value="#999999"/> </chartPalette> </namedChartPalette>

The XML file now has two identical namedChartPalette entries with an id attribute of normalDefault (shown above). The order in which the palettes are listed in this file will be the same order they appear in Report Studio.

Create Custom Chart Palettes for IBM Cognos 8 Report Studio Next, the second entry will be modified to create the new palette.

The new palette in this example will be called My Corporate. The name and screen tip are applied in the reportstudio_xx.xml files, which is covered in section 3 of this document. 4. To reflect the new palette name, in the new entry created, change the namedChartPalette tag as shown below:
<namedChartPalette id="myCorporate" smallIcon="chart/palette/normal/myCorporate.gif" idsLabel="IDS_PAL_NAME_myCorporate" idsTooltip="IDS_PAL_TOOLTIP_myCorporate">

Take note of the idsLabel and idsTooltip values as entries for these will be required in the reportstudio_xx.xml files which handle multiple product language strings. 5. Next, the colors for the palette are modified by changing the hexadecimal color values like the ones bolded below (there can be fewer or more colors as required):
<namedChartPalette id="myCorporate" smallIcon="chart/palette/normal/myCorporate.gif" idsLabel="IDS_PAL_NAME_myCorporate" idsTooltip="IDS_PAL_TOOLTIP_myCorporate"> <chartPalette> <chartColor value="#9999FF"/> <chartColor value="#999999"/> <chartColor value="#999966"/> <chartColor value="#999900"/> <chartColor value="#996600"/> <chartColor value="#993300"/> <chartColor value="#990000"/> <chartColor value="#0000CC"/> <chartColor value="#000066"/> <chartColor value="#000033"/> <chartColor value="#000000"/> <chartColor value="#FFFFCC"/> <chartColor value="#FFFF66"/> <chartColor value="#FFCC33"/> <chartColor value="#FFCC00"/> <chartColor value="#FFFF00"/> <chartColor value="#333333"/> </chartPalette> </namedChartPalette>

6. Once each value is modified to reflect the required colors, save and close the ChartPalettes.xml file.

Create Custom Chart Palettes for IBM Cognos 8 Report Studio

10

3 Add the Name and Screen Tip Entries in the reportstudio_xx.xml files
The reportstudio_xx.xml files (where xx represents a language value) contain string values for Report Studio UI elements. There is one file for every supported language in the IBM Cognos 8 environment. For example: reportstudio_en.xml contains English strings reportstudio_fr.xml contains French strings reportstudio_de.xml contains German strings and so on

The reportstudio_xx.xml file used when Report Studio is started is based on the Product language setting applied in IBM Cognos Connection. For example, to change the product language: 1. Open IBM Cognos Connection 2. Click My Area, and then click My Preferences.

Create Custom Chart Palettes for IBM Cognos 8 Report Studio 3. Under Regional options, change the Product language setting to the desired language.

11

4. Click OK. The product UI will now be displayed in the language chosen. In the next steps, the English version of the reportstudio_xx.xml file will be modified. To add the name and screen tip to the reportstudio_en.xml file: 1. In the <IBM Cognos 8.4 install location>\webcontent\pat\res directory, open the reportstudio_en.xml file in Notepad or an XML editor. In order to create a new palette entry in this XML document, new tags need to be created. To find the location to create the new tags, it is easiest to search on a string found for an existing palette entry. In this case the value IDS_PAL_NAME_default will be used from the idsLabel attribute of the namedChartPalette tag in the ChartPalettes.xml file. This is the default palette entry used as a starting point in section 2.1. 2. In the reportstudio_en.xml file, search for IDS_PAL_NAME_default. 3. Once found, copy the XML string tags bolded below:
<string id="IDS_PAL_NAME_default" type="Control Label">Default</string> <string id="IDS_PAL_TOOLTIP_default" type="Control Label">Default style palette.</string> <string id="IDS_PAL_NAME_corporate" type="Control Label">Corporate</string> <string id="IDS_PAL_TOOLTIP_corporate" type="Control Label">Corporate style palette.</string>

Create Custom Chart Palettes for IBM Cognos 8 Report Studio 4. Paste the copied tags directly below the original tags and then change the values as shown below in bolded text:
<string id="IDS_PAL_NAME_default" type="Control Label">Default</string> <string id="IDS_PAL_TOOLTIP_default" type="Control Label">Default style palette.</string> <string id="IDS_PAL_NAME_myCorporate" type="Control Label">My Corporate</string> <string id="IDS_PAL_TOOLTIP_myCorporate" type="Control Label">My corporate palette.</string> <string id="IDS_PAL_NAME_corporate" type="Control Label">Corporate</string>

12

<string id="IDS_PAL_TOOLTIP_corporate" type="Control Label">Corporate style palette.</string>

Notice that the id attributes use the idsLabel and idsTooltip attribute values from section 2.1. The name of the palette in the Report Studio UI will be My Corporate, and the tool tip will be My corporate palette. 5. Save and close the reportstudio_en.xml file. 6. Repeat this process to add the tags to any other required reportstudio_xx.xml language file. The id attribute values will be the same in each file, but the actual values will be the appropriate language translation.

4 Create a New GIF Image (IBM Cognos 8.4)


The quickest way to create a new palette GIF image is to use a copy of an existing one and edit it in a graphics application. Palette GIF images can also be created from scratch but should use the same dimensions in order to maintain consistency in the Report Studio UI. 1. In the <IBM Cognos 8.4 install location>\webcontent\pat\images\ chart\palette\normal directory, make a copy of the default.gif file and name the copy myCorporate.gif. This is the file name provided for the smallIcon attribute of the namedChartPalette XML tag in section 2.1 of this document.

Create Custom Chart Palettes for IBM Cognos 8 Report Studio

13

2. Edit the myCorporate.gif file in a graphics editing application so that it represents the colors of the new palette. In this case the palette colors would appear as shown below:

3. Save the changes to the gif image. Now that all appropriate items have been edited, the new palette will appear in the Palette dialog box the next time Report Studio is started as shown below:

Create Custom Chart Palettes for IBM Cognos 8 Report Studio When a chart report is run with this new palette applied, it appears similar to the report shown below:

14

5 Conclusion
Using the technique described in this document, existing palettes can be edited or new palettes can be created. The same principles illustrated in this example can be applied to gradient and pattern palettes as well as map chart palettes and gauge chart palettes.

Create Custom Chart Palettes for IBM Cognos 8 Report Studio

15

6 Appendix - Single Product Language Environment


If an IBM Cognos 8 environment will only use one language, for example, English, then there is an alternate method that can be used in the ChartPalette.xml file and does not require any modifications to the reportstudio_xx.xml files. Simply change the namedChartPalette tag as shown below:
<namedChartPalette id="myCorporate" smallIcon="chart/palette/normal/myCorporate.gif" label="My Corporate" tooltip="My corporate palette">

Notice that the "idsLabel" and "idsTooltip" attributes are changed to "label" and "tooltip" respectively. The values for these attributes are used in the Report Studio UI to display the name and tooltip for the palette.

Você também pode gostar