Skip to content

charts demo - bind to model #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion src/z2ui5_cl_demo_app_013.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
DATA mv_sel6 TYPE abap_bool.

DATA mv_tab_donut_active TYPE abap_bool.
DATA total_count TYPE i.

TYPES:
BEGIN OF ty_chart,
text TYPE string,
percent TYPE p LENGTH 3 DECIMALS 2,
END OF ty_chart.

DATA counts TYPE STANDARD TABLE OF ty_chart WITH EMPTY KEY.

METHODS render_tab_donut.
DATA client TYPE REF TO z2ui5_if_client.
Expand All @@ -21,7 +30,7 @@



CLASS z2ui5_cl_demo_app_013 IMPLEMENTATION.
CLASS Z2UI5_CL_DEMO_APP_013 IMPLEMENTATION.


METHOD render_tab_donut.
Expand Down Expand Up @@ -107,6 +116,28 @@
seg->interact_donut_chart_segment( label = 'Design Phase' value = '21.5' displayedvalue = '21.5%' ).
seg->interact_donut_chart_segment( label = 'Test Phase' value = '38.5' displayedvalue = '38.5%' ).

grid->text(
text = 'Model Update Table Data'
class = 'sapUiSmallMargin'
)->get( )->layout_data(
)->grid_data( 'XL12 L12 M12 S12' ).

DATA(donut_chart) = grid->button( text = `update chart` press = client->_event( 'UPDATE_CHART_DATA' ) )->get_parent(

Check failure on line 125 in src/z2ui5_cl_demo_app_013.clas.abap

View check run for this annotation

abaplint / abaplint

Method importing parameter "SEGMENTS" does not exist

https://rules.abaplint.org/check_syntax

Check failure on line 125 in src/z2ui5_cl_demo_app_013.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Method importing parameter "SEGMENTS" does not exist

https://rules.abaplint.org/check_syntax
)->flex_box(
width = '30rem'
height = '18rem'
alignitems = 'Start'
justifycontent = 'SpaceBetween'
)->items(
)->interact_donut_chart( displayedsegments = client->_bind_edit( total_count ) segments = client->_bind_edit( counts ) ).


donut_chart->interact_donut_chart_segment(

Check failure on line 135 in src/z2ui5_cl_demo_app_013.clas.abap

View check run for this annotation

abaplint / abaplint

"donut_chart" not found, findTop

https://rules.abaplint.org/check_syntax

Check failure on line 135 in src/z2ui5_cl_demo_app_013.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

"donut_chart" not found, findTop

https://rules.abaplint.org/check_syntax
label = `{TEXT}`
value = `{PERCENT}`
displayedvalue = `{PERCENT}`
).

client->view_display( container->stringify( ) ).

ENDMETHOD.
Expand All @@ -119,6 +150,15 @@
IF check_initialized = abap_false.
check_initialized = abap_true.


counts = VALUE #(
( text = '1st' percent = '10.0' )
( text = '2nd' percent = '60.0' )
( text = '3rd' percent = '30.0' )
).

total_count = lines( counts ).

* DATA(lv_version) = to_upper( client->get( )-s_config-version ).
* IF lv_version CS `OPEN`.
* client->message_box_display( text = `Charts are not avalaible with OpenUI5, change your UI5 library first` type = `error` ).
Expand All @@ -129,6 +169,18 @@
ENDIF.

CASE client->get( )-event.
WHEN 'UPDATE_CHART_DATA'.
CLEAR counts.
counts = VALUE #(
( text = '1st' percent = '60.0' )
( text = '2nd' percent = '10.0' )
( text = '3rd' percent = '15.0' )
( text = '4th' percent = '15.0' )
).

total_count = lines( counts ).

client->view_model_update( ).

WHEN 'BACK'.
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).
Expand Down