cancel
Showing results for 
Search instead for 
Did you mean: 

Different color in business graphics

Former Member
0 Kudos

Dear All,

Please tell me how to change the color of the graph .

I have created one graph in that i want to change the color based on the condition.

Regards,

Arun

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Have you checked in the EDIT CUSTOMIZING for that graph.

Regards,

Lekha.

Former Member
0 Kudos

Hai,

In EDIT CUSTOMIZING what i want to check.

Kindly explain me.

Regards,

Arun

Former Member
0 Kudos

Hi,

Where you want to apply colors, for series, catorgory or entire plot area.

what is the chart type you are using.

Regards,

Lekha.

Former Member
0 Kudos

I want to change the color for categary. my chart type is COLUMNS.

Regards,

Arun

Former Member
0 Kudos

Hi Arun,

Do you want to set different colors in same graph depending on values?

If that is the case, it is not possible.

And if u want to apply different colors on different condition for whole graph for one particular series, then it is possible.

But tell me are there many conditions

For Eg,

If 1st cond: Apply Red

If 2nd Cond: Apply Blue

How many colors needs to be applied?

If only 2/3 colors are there, then u can create those many customized file for ur graph, with those many color settings and bind each file accordingly to the series on selection.

And if not then u need to do it dynamically using XSLT transformations.

Thanks,

Tejaswini

Former Member
0 Kudos

Hai,

Please tell me how to do it dynamically using XSLT transformations.

is there any option in ALV to do the same.

Regards,

Arun

Former Member
0 Kudos

Hi,

To work with XSLT, you need to create an XSLT transformation using your customized XML file of Graph.


<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="COLOR"/>                  "Dynamic Parameter for Color
<tt:template>
  <SAPChartCustomizing version="1.0">  "Whole XML content needs to be passed here
      <GlobalSettings>
        <Dimension>Two</Dimension>
        <TransparentColor>None</TransparentColor>
        <ColorPalette>Tradeshow</ColorPalette>
        <ColorOrder>Default</ColorOrder>
    <Gaps>
Void</Gaps>
        <EqualizeValueAxes>
false</EqualizeValueAxes>
............
        <Series id="Series1">
          <Visibility>true<Visibility>
          <ChartType>Lines</ChartType>
          <XAxisId>
Primary</XAxisId>
          <YAxisId>Primary</YAxisId>
          <LineType>Direct</LineType>
          <ShowInLegend>
Automatic</ShowInLegend>
          <ShowLabel>false</ShowLabel>
          <Format>$Label</Format>
          <LineColor><tt:value ref="COLOR"/></LineColor>    "Passed Parameter
............
        </Series>
      </Values>
      <Images/>
    </SAPChartCustomizing>
  </tt:template>
</tt:transform>

This transformation needs to b called evrytime for condition passing colors accordingly as follows to create modified XML file


l_color = 'RGB(255,0,0)'.   "Red
  CALL TRANSFORMATION zxslt_graph
    SOURCE color = l_color  "RGB color in string variable
    RESULT XML l_xml_file.

Now this updated l_xml_file needs to be bound to graph as follows by passing it in an attribute and setting direct customziing for graph:


*Define Business Graphics and set customizing path for it
* supply the customizing xml via BG method handler
    lr_business_graphics ?= view->get_element( 'BG_TEST' ).
    lr_bg_method_handler ?= lr_business_graphics->_method_handler.
    lr_bg_method_handler->add_direct_customizing(
      i_customizing_ctx_path = 'CA_CUST_XML'                         "Attribute holding contents of XML file(XSTRING)
      i_customizing_ctx_type = if_wd_busin_graphics_mtd_hndl=>mc_add_cust_xml_xstring ).

Hope this helps u!

Thanks,

Tejaswini

Answers (0)