03-23-2011 11:07 AM
Hello,
my goal is to create a Gantt-Chart by using CL_GUI_CHART_ENGINE .
I´ve copied report GRAPHICS_GUI_CE_DEMO and tried to modify its XML data in order to get a Gant-Chart
but I failed. I´ve also used SAP Chart-Designer to get an executable customizing for the chart engine
but this way was unsuccesful too. Every time the chart shows no data...
Is there anyone who has an example (code, docu, xml) to create a Gantt-Chart?
Thank you.
Kind regards,
Oliver
Edited by: Oliver Seifer on Mar 24, 2011 2:16 PM
04-06-2011 12:43 PM
Hi,
Please try this sample code. You'll need a customizing from ChartDesigner to launch it.
I have hardcoded sample data but you can take it further from here.
Please use following settings in the wizard
Step 1
Gantt
Step 2
Series Count 2
Category Count 1
Step 3
Defaults
Step 4
Defaults
Step 5
Defaults
Step 6
Defaults
Step 7
Save as...
DATA lt_cust_text TYPE w3htmltabtype.
DATA lt_data_text TYPE w3htmltabtype.
DATA wa_data_text TYPE w3html.
IF g_ce_container IS INITIAL.
CREATE OBJECT g_ce_container
EXPORTING
container_name = 'CONTAINER'.
CREATE OBJECT g_ce_viewer
EXPORTING
parent = g_ce_container.
ENDIF.
cl_gui_frontend_services=>gui_upload(
EXPORTING
filename = 'path to your customising\gant.xml'
CHANGING
data_tab = lt_cust_text
EXCEPTIONS
OTHERS = 19 ).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
g_ce_viewer->set_customizing( data_table = lt_cust_text ).
APPEND '<?xml version="1.0" encoding="utf-8"?>' TO lt_data_text.
APPEND '<ChartData> ' TO lt_data_text.
APPEND '<Categories><Category>Category 1</Category></Categories>' TO lt_data_text.
APPEND '<Series customizing="Series1">' TO lt_data_text.
APPEND '<Point>' TO lt_data_text.
APPEND '<Value type="time">20000301</Value>' TO lt_data_text.
APPEND '<Value type="time">20000305</Value>' TO lt_data_text.
APPEND '<Value type="time">20000310</Value>' TO lt_data_text.
APPEND '<Value type="time">20000401</Value>' TO lt_data_text.
APPEND '</Point>' TO lt_data_text.
APPEND '</Series>' TO lt_data_text.
APPEND '<Series customizing="Series2">' TO lt_data_text.
APPEND '<Point>' TO lt_data_text.
APPEND '<Value type="time">20000302</Value>' TO lt_data_text.
APPEND '<Value type="time">20000319</Value>' TO lt_data_text.
APPEND '</Point>' TO lt_data_text.
APPEND '</Series>' TO lt_data_text.
APPEND '</ChartData>' TO lt_data_text.
g_ce_viewer->set_data( data_table = lt_data_text ).
g_ce_viewer->render( ).
04-06-2011 12:43 PM
Hi,
Please try this sample code. You'll need a customizing from ChartDesigner to launch it.
I have hardcoded sample data but you can take it further from here.
Please use following settings in the wizard
Step 1
Gantt
Step 2
Series Count 2
Category Count 1
Step 3
Defaults
Step 4
Defaults
Step 5
Defaults
Step 6
Defaults
Step 7
Save as...
DATA lt_cust_text TYPE w3htmltabtype.
DATA lt_data_text TYPE w3htmltabtype.
DATA wa_data_text TYPE w3html.
IF g_ce_container IS INITIAL.
CREATE OBJECT g_ce_container
EXPORTING
container_name = 'CONTAINER'.
CREATE OBJECT g_ce_viewer
EXPORTING
parent = g_ce_container.
ENDIF.
cl_gui_frontend_services=>gui_upload(
EXPORTING
filename = 'path to your customising\gant.xml'
CHANGING
data_tab = lt_cust_text
EXCEPTIONS
OTHERS = 19 ).
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
g_ce_viewer->set_customizing( data_table = lt_cust_text ).
APPEND '<?xml version="1.0" encoding="utf-8"?>' TO lt_data_text.
APPEND '<ChartData> ' TO lt_data_text.
APPEND '<Categories><Category>Category 1</Category></Categories>' TO lt_data_text.
APPEND '<Series customizing="Series1">' TO lt_data_text.
APPEND '<Point>' TO lt_data_text.
APPEND '<Value type="time">20000301</Value>' TO lt_data_text.
APPEND '<Value type="time">20000305</Value>' TO lt_data_text.
APPEND '<Value type="time">20000310</Value>' TO lt_data_text.
APPEND '<Value type="time">20000401</Value>' TO lt_data_text.
APPEND '</Point>' TO lt_data_text.
APPEND '</Series>' TO lt_data_text.
APPEND '<Series customizing="Series2">' TO lt_data_text.
APPEND '<Point>' TO lt_data_text.
APPEND '<Value type="time">20000302</Value>' TO lt_data_text.
APPEND '<Value type="time">20000319</Value>' TO lt_data_text.
APPEND '</Point>' TO lt_data_text.
APPEND '</Series>' TO lt_data_text.
APPEND '</ChartData>' TO lt_data_text.
g_ce_viewer->set_data( data_table = lt_data_text ).
g_ce_viewer->render( ).
04-06-2011 1:51 PM
Hi Tomek,
thank you!!! It works.
Now I have to focus on the customizing of the chart.
Kind regards,
Oliver