Chartjs-How to send data from struts2 to a javascript function to draw a chart

1👍

you can use by two ways
1. take a list in action with setter, getter and add data in this list. In jsp page use strcts tag library and in javascript variable put list data. Then call chartjs library function with data like

<script type="text/javascript">
var a = new Array();
<s:iterator var="newsVar" value="newsList" status="newsStatus">
a[<s:property value="#newsStatus.index"/>]='<s:property value="id"/>';
</s:iterator>
$(document).ready(function(){
 chartjsfunction(a);
});
</script>
  1. send ajax call for data to action and send data to chartjs library function.

Leave a comment