cancel
Showing results for 
Search instead for 
Did you mean: 

Buisness graphics dynamic PIE chart event id

Former Member
0 Kudos

HI all,

I'm trying to create dynamic PIE chart :

Link to sdn document *

First I declared in the context node a table ( 0…n )

PIE – 0…N  with attributes :

Categorty – type string

Series – type i

Then I'm creating the business graphics :

DATA:lr_graph TYPE REF TO cl_wd_business_graphics,

lr_cat TYPE REF TO cl_wd_category,

lr_series TYPE REF TO cl_wd_simple_series,

lr_container TYPE REF TO cl_wd_uielement_container,

lr_flow TYPE REF TO cl_wd_flow_data.

lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

lr_graph = cl_wd_business_graphics=>new_business_graphics(

bind_series_source = 'NODE_DYN'

chart_type = cl_wd_business_graphics=>e_chart_type-pie

height = 340

width = 750

id = 'GRAPH' ).

lr_flow = cl_wd_flow_data=>new_flow_data( element = lr_graph ).

lr_container->add_child( lr_graph ) .

wd_this->value_cs ?= lr_graph.

wd_this->mr_view ?= view.

Now I'm creating the category and series :

wd_this->value_cs =? Lr_graph

wd_this->mr_view ?= view.

Series :

DATA: lr_bgr_ss TYPE REF TO cl_wd_simple_series.

lr_bgr_ss = cl_wd_simple_series=>new_simple_series(

bind_value = ‘NODE_DYN.SERIES’

label = ‘Series_1’

event_id = ‘Series_1’

id       = ‘Series_1’

view = wd_this->mr_view ).

Wd_this->value_cs->add_series( lr_bgr_ss ).

Category :

DATA: lr_bgr_cs TYPE REF TO cl_wd_category.

lr_bgr_cs = cl_wd_category=>new_category(

view = wd_this->mr_view

event_id = ‘Series_1’

id       = ‘Series_1’

bind_description = 'NODE_DYN.CATEGORY').

wd_this->value_cs->set_category( lr_bgr_cs ).

Now I'm binding the data :

Data : ls_pie type wd_this->element_pie.

Data : lt_pie type table of element_pie.

ls_pie-category = 'test_category1'.

ls_pie-series = '34'.

Append ls_pie to lt_pie.

ls_pie-category = 'test_category2'.

ls_pie-series = '73'.

Append ls_pie to lt_pie.

Data : lo_nd_pie type ref to if_Wd_context_node.

Data : lo_el_pie type ref to if_wd_context_element.

Lo_nd_pie = wd_context->get_child_node(

Name = wd_this-> wdctx_pie.

The above is the only way that I succeeded to create 2 categories for the pie chart but I cant isolate the event id for every category.

I tried also to create another series with the same id and other event id but still got the same problem.

Please suggest a solution for creating dynamic pie chart with event id for every category or series .

Regards,

Arie.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

any one ?

ramakrishnappa
Active Contributor
0 Kudos

Hi Arie,

You need to use the parameter BIND_EVENT_ID of method NEW_CATEGORY and you can bind it to the attribute of the node where each record can have, event id of its own.

For series:

Try to use the class CL_WD_SERIES instead of CL_WD_SIMPLE_SERIES, because in simple series you do not have the option for binding event id to the context attribute.

lr_bgr_cs = cl_wd_category=>new_category(

view = wd_this->mr_view

bind_event_id = 'NODE_DYN.SERIES'

id       = ‘Series_1’

bind_description = 'NODE_DYN.CATEGORY').

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Hi Rama,

Thank you for your reply ,

I added the BIND_EVEND_ID = 'NODE_DYN.SERIES'  and it worked fine.

I'm trying now to get rid of the static context element.

I've declared the following :

DATA : NODE_INFO TYPE REF TO IF_WD_CONTEXT_NODE_INFO ,

              STRUCT_TYPE TYPE REF TO CL_ABAP_STRUCDESCR ,

              TABLE_TYPE REF TO CL_ABAPDESCR=>COMPONENT_TABLE,

             COMP LIKE LINE OF COMP_TAB.

COMP-NAME = 'CATEGORY'.

COMP_TYPE ?= CL_ABAP_DATADESCR=>DESCRIBE_BY_NAME( 'STRING' ).

APPEND COMP TO COMP_TAB.

COMP-NAME = 'SERIES'.

COMP_TYPE ?= CL_ABAP_DATADESCR=>DESCRIBE_BY_NAME( 'I' ).

APPEND COMP TO COMP_TAB.

STRUCT_TYPE = CL_ABAP_STRUCTDESCR=>CREATE( COMP_TAB ).

NODE_INFO = WD_CONTEXT->GET_NODE_INFO( ).

NODE_INFO = NODE_INFO->ADD_NEW_CHILD_NODE (

NAME = 'NODE_DYN'

IS_MANDTORY = ABAP_FALSE

IS_MULTIPLE = ABAP_TRUE

STATIC_ELEMENT_RTTI = STRUCT_TYPE

IS_STATIC = ABAP_FALSE) .

FIELD-SYMBOLS  <TABLE> TYPE TABLE.

FIELD-SYMBOLS  <WA> TYPE WA.

DATA : TABLE TYPE REF TO DATA.

DATA : WA TYPE REF TO DATA.

CREATE DATA TABLE LIKE TABLE OF STRUCT_TYPE.

ASSIGN TABLE->* TO TABLE.

TODO ?? - Add data to FS <TABLE>

*Binding :

DATA : DYN_NODE TYPE REF TO IF_WD_CONTEXT_NODE.

DYN_NODE = WD_CONTEXT->GET_CHILD_NODE( NAME = 'NODE_DYN').

DYN_NODE->BIND_TABLE( <TABLE> ).

How do I append data to FS <table> with the relevant components ?

Is there any  other efficient way to append the data and bind  ?

Regards,

Arie.

ramakrishnappa
Active Contributor
0 Kudos

Hi Arie,

Modify the code as below


DATA : table TYPE REF TO data.

 

  FIELD-SYMBOLS  <table> TYPE table.

  FIELD-SYMBOLS  <wa> TYPE any.

  FIELD-SYMBOLS <LV_VALUE> TYPE ANY.

 

  CREATE DATA table TYPE TABLE OF STRUCT_TYPE.

  APPEND INITIAL LINE TO <table> ASSIGNING <wa>.

  IF <wa> IS ASSIGNED.

    ASSIGN COMPONENT 'CATEGORY' OF STRUCTURE <wa>  TO <lv_value>.

   

    IF <LV_VAlUE> IS ASSIGNED.

      <LV_VALUE> = 'CAT1'.

    ENDIF.

   

    ASSIGN COMPONENT 'SERIES' OF STRUCTURE <wa>  TO <lv_value>.

   

    IF <LV_ValUE> IS ASSIGNED.

      <LV_VALUE> = '1'.

    ENDIF.

  ENDIF.

"Similarly you can append record by record

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Hi Rama ,

I'm getting a dump -> Field symbol has not been assigned yet

in line :   APPEND INITIAL LINE TO <table> ASSIGNING <wa>.

I tried to add :

assign table->* to <table> .

assign wa->* to <table>.

but i'm getting RC 4 on :

ASSIGN COMPONENT 'CATEGORY' OF STRUCTURE <wa>  TO <lv_value>.

Please advise.

Regards,

Arie.

Former Member
0 Kudos

Hi Rama,

One more thing :

I'm trying to change the series class from simple_series to series.

How can I pass the value to the series  ?

I tried with the bind_point_source but I got "access via null ref is not possible" .

Many thanks,

Arie.

Former Member
0 Kudos

Found the solution here => http://scn.sap.com/thread/823018

need to add point & numeric class.


ramakrishnappa
Active Contributor
0 Kudos

Hi Arie,

Oh, missed a statement after:

CREATE DATA table TYPE TABLE OF STRUCT_TYPE.

you need to add the below line

         

assign table->* to <table>

Hope this helps you.

Regards,

Rama

Answers (0)