templates/frontend/dataset/_chart.html.twig line 1

Open in your IDE?
  1. {# <div style="position: relative; overflow-x: auto;"> #}
  2. <div id="linechart_test" style="width: 100%; height: 400px; margin: 0 auto"></div>
  3. <script src="{{ asset('frontend/js/jquery.min.js') }}"></script>
  4. <script type="text/javascript">
  5.     jQuery(document).ready(function(){
  6.         getDataChart();
  7.     });
  8.     function getDataChart() {
  9.         var periode = $('#periode').val()+' '+$('#tahunx').val();
  10.         $.ajax({
  11.             type: "GET",
  12.             dataType: "json",
  13.             url: "{{ path('dataset_chart_json', {id: publikasi.id}) }}",
  14.             data: {
  15.                 periode: periode
  16.             },
  17.             success    :    function(r){
  18.                 chartHighchart(r.columns, r.datas);
  19.                 console.log(r.datas);
  20.             }
  21.         });
  22.     }
  23.     function chartHighchart(columnx, datax) {
  24.         var chartx = new Highcharts.Chart({
  25.             chart: {
  26.                 "renderTo": "linechart_test",
  27.                 "type": "{{ grafik_info['tipe'] }}"
  28.             },
  29.             series: datax, 
  30.             title: {
  31.                 "text": "{{ grafik.judul }}"
  32.             },
  33.             xAxis: {
  34.                 "title": {
  35.                     "text":"{{ grafik_info['varX'] }}"
  36.                 },
  37.                 "categories": columnx
  38.             },
  39.             yAxis: {
  40.                 "title": {
  41.                     "text": ""
  42.                 }
  43.             },
  44.             credits: {
  45.                 enabled: false
  46.             }
  47.         });
  48.     };
  49. </script>
  50. {# </div> #}