on 12-24-2015 5:56 PM
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.
View Elements (elements are bolded)
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.