cancel
Showing results for 
Search instead for 
Did you mean: 

Business Graphics - Stacked Bar Chart

former_member16322
Participant
0 Kudos

Greetings all!

I am attempting to build a stacked bar chart using the Business Graphics object, and I am not getting the expected results. I was wondering if anyone had links to a good demo/discussion on the Stacked Bar Chart, or if anyone has advice to help with my problem.

As I'm fairly new to ABAP WebDypro, I'm not sure if my context population is incorrect, or my setup/binding to the Business Graphics element is incorrect (or a combination of both of them).

Currently, the Categories for the Stacked Bar chart (Y-Axis) and the Series Descriptions (Legend showing Series) are properly displayed; however, the Data Points do not show up on the graph in the main area.

Here is my current setup:

The context population is handled by a method on the Component Controller of this WebDynpro Component; the view's context is mapped to the Component Controller's context. I'm not sure if it is relevant, but this WebDynpro component is a component implementing a Component Interface which is used by a different component I am building; the view for this Component only contains the Business Graphic Element (and it's sub elements).

Context Definition (defined in Component Controller and mapped to view).

These are the names I've used, too keep it clear with my intended binding. Nodes are bold; all nodes are defined as 0..N cardinality.

  • CONTEXT
    • SERIES
      • LABEL
      • POINTS
        • LABEL
        • VALUES
          • TYPE
          • VALUE
    • CATEGORIES
      • DESCRIPTION

View Elements (elements are bolded)

  • Business Graphics Element
    • chartType = Stacked Bars
    • categorySource = view.CATEGORIES
    • dimension = psuedo_three
    • seriesSource = view.SERIES
    • Category Element
      • description = view.CATEGORIES.DESCRIPTION
    • Series Element
      • label = view.SERIES.LABEL
      • pointSource = view.SERIES.POINTS
      • Point Element
        • label = view.SERIES.POINTS.LABEL
        • valueSource = view.SERIES.POINTS.VALUES
        • Value Element
          • type = view.SERIES.POINTS.VALUES.TYPE
          • value = view.SERIES.POINTS.VALUES.VALUE

Context population code in Component Controller:

DATA:

     lx_nbound       TYPE REF TO zcx_ca_object_not_bound,

     lr_task_dur_rpt TYPE REF TO zcl_plmr277_task_dur_rpt,

     lr_t_qrtr_task  TYPE REF TO zcl_plmr277_task_dur_rpt=>mtt_qrtr_task_avg,

     lr_s_qrtr_task  TYPE REF TO zcl_plmr277_task_dur_rpt=>mts_qrtr_task_avg,

     lt_categories   TYPE wd_this->elements_categories,

     ls_categories   TYPE wd_this->element_categories,

     ls_series       TYPE wd_this->element_series,

     ls_points       TYPE wd_this->element_points,

     ls_values       TYPE wd_this->element_values,

     lr_node         TYPE REF TO if_wd_context_node,

     lr_elem         TYPE REF TO if_wd_context_element,

     lr_node_point   TYPE REF TO if_wd_context_node,

     lr_elem_point   TYPE REF TO if_wd_context_element,

     lr_node_value   TYPE REF TO if_wd_context_node,

     lr_elem_value   TYPE REF TO if_wd_context_element

     .

   TRY .

     " Get the Data from the Business Object

     lr_task_dur_rpt = wd_assist->get_bo( ) .

     " Now get the quarterly average by task

     lr_t_qrtr_task = lr_task_dur_rpt->get_quarterly_by_task( ) .

     " Build the Categories and Series, ensure sorted in order

     " It is assumed, each series will have an entry for each

     " category; even if it is a 0 value.

     SORT:

       lr_t_qrtr_task->* BY task gjahr zzquarter

       .

     " Now we want to create the Series

     lr_node = wd_context->get_child_node(

                 name = wd_this->wdctx_series

                 ) .

     LOOP AT lr_t_qrtr_task->* REFERENCE INTO lr_s_qrtr_task .

       AT NEW task .

         " Create a New Element, and set Static Attributes

         CLEAR:

           ls_series

           .

         lr_elem = lr_node->create_element( ) .

         ls_series-label = lr_s_qrtr_task->*-task .

         lr_elem->set_static_attributes(

           static_attributes = ls_series

           ) .

         " Bind the element

         lr_elem = lr_node->bind_element(

                     new_item             = lr_elem

                     set_initial_elements = abap_false

                     ) .

       ENDAT .

       AT NEW zzquarter .

         " We need to get the child node from the Series

         " element, and create an point Element for it

         CLEAR:

           ls_points

           .

         lr_node_point = lr_elem->get_child_node(

                           name = wd_this->wdctx_points

                           ) .

         lr_elem_point = lr_node_point->create_element( ) .

         CONCATENATE lr_s_qrtr_task->*-task lr_s_qrtr_task->*-gjahr lr_s_qrtr_task->*-zzquarter

           INTO ls_points-label

           SEPARATED BY space .

         lr_elem_point->set_static_attributes(

           static_attributes = ls_points

           ) .

         " Bind the element

         lr_elem_point = lr_node_point->bind_element(

                           new_item             = lr_elem_point

                           set_initial_elements = abap_false

                           ) .

         " Get the Category

         CONCATENATE lr_s_qrtr_task->*-gjahr lr_s_qrtr_task->*-zzquarter

           INTO ls_categories-description

           SEPARATED BY space .

         COLLECT ls_categories INTO lt_categories .

       ENDAT .

       " Now add the value

       CLEAR:

         ls_values

         .

       lr_node_value = lr_elem_point->get_child_node(

                         name = wd_this->wdctx_values

                         ) .

       lr_elem_value = lr_node_value->create_element( ) .

       ls_values-type  = cl_wd_numeric_value=>e_type-x .

       ls_values-value = lr_s_qrtr_task->*-avg .

       lr_elem_value->set_static_attributes(

         static_attributes = ls_values

         ) .

       " Bind the Value Element

       lr_elem_value = lr_node_value->bind_element(

                         new_item             = lr_elem_value

                         set_initial_elements = abap_false

                         ) .

     ENDLOOP .

     " Bind the Categories

     lr_node = wd_context->get_child_node(

                 name = wd_this->wdctx_categories

                 ) .

     lr_node->bind_table(

       new_items            = lt_categories[]

       set_initial_elements = abap_true

       ) .

   CATCH zcx_ca_object_not_bound INTO lx_nbound .

     " This is a program exception, it should be bound at this

     " point. Dump

     MESSAGE x000(zplm) WITH lx_nbound->get_text( ) space space space .

   ENDTRY .

Thank you in advance for all assistance.

Accepted Solutions (1)

Accepted Solutions (1)

former_member16322
Participant
0 Kudos

I found the problem...and it works now.

When assigning the Value, I was using type = cl_wd_numeric_enumeration=>e_type-x; it should have been cl_wd_numeric_enumeration=>e_type-y.

I assumed, since the graph moved horizontally (left to right), we would be setting X values, not Y values; however, it appears that assumption was incorrect.

Lol...I tried changing from X to Y just for grins (and out of desperation)...and what do you know, that ended up being the problem.

Thank you for your consideration.

Answers (0)