APEX-AT-WORK no image

Handling the 32k problem in APEX charts

Von Tobias Arnhold 4.03.2011
How to handle more then 32k (32768) characters inside your APEX charts: AnyChart gantt with custom xml and more then 32k

Workaround:

- Create your own chart

Info:
- AnyChart documentation: Set XML As String From TextArea

HTML Header:http://www.blogger.com/img/blank.gif

<script src="#APP_IMAGES#anychart_intkit.js" language="javascript"></script>

PL/SQL Region:

/* ... */
htp.p('<textarea cols="65" rows="17" id="rowData" style="display:none;">');

/* Write CLOB through a package function */
P_CLOB := MY_PACKAGE.F_APEX_GANTT_COMPLETE ( P_USER );

dbms_lob.open(P_CLOB, dbms_lob.lob_readonly);

P_LENGTH := dbms_lob.getlength (P_CLOB);

while P_LENGTH > 0 loop

/* Read 32000 characters from CLOB */
dbms_lob.read(P_CLOB, P_CLOB_BUFFER, P_POS, P_SET);

/* Write code in APEX */
htp.prn(P_SET);

/* Increase Counter */
P_POS := P_POS + P_CLOB_BUFFER;
P_LOOP := P_LOOP + 1;

/* Resize CLOB length */
P_LENGTH := P_LENGTH - P_CLOB_BUFFER;

end loop;

dbms_lob.close(P_CLOB);

htp.p('</textarea>');
htp.p('<div id="chartDiv"></div>');

htp.p(
'<script type="text/javascript" language="javascript">' || chr(10) ||
'/* Set default swf path */' || chr(10) ||
'AnyChart.swfFile = ''/i/flashchart/anygantt_4/swf/AnyGantt.swf'';' || chr(10) ||
'/* Create new gantt chart */' || chr(10) ||
'var chart = new AnyChart();' || chr(10) ||
'chart.width="2500";' || chr(10) ||
'chart.height="1400";' || chr(10) ||
'/* Get string data from text area */' || chr(10) ||
'var data = document.getElementById(''rowData'').value.toString();' || chr(10) ||
'/* Set data */' || chr(10) ||
'chart.setData(data);' || chr(10) ||
'/* Write chart to "chart" div */' || chr(10) ||
'chart.write("chartDiv");' || chr(10) ||
'</script>');
/* ... */


I created a region plug-in based on the above code to handle the huge charts! :)

Post Tags: