title: how to give dynamic values to chart from controller to view in code igniter
body: <p>the following is the code am having.in this code am giving values statically. now what i need to do is i need to get the dynamic values and the chart has to be displayed.here into the items variable i have to get the values in the same way from the controller and the chart has to be displayed.thanks. </p>
  
  <pre><code> &lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;head&gt;
        &lt;script src="http://www.amcharts.com/lib/amcharts.js" type="text/javascript"&gt;&lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
    &lt;div id="chartdiv" style="width: 100%; height: 355px;"&gt;&lt;/div&gt;
   &lt;script type="text/javascript" language="javascript"&gt;
  var chart;
  
  var chartData = [{
      year: "FY 2011-12",
      visits: 3025
      },
  {
      year: "FY 2011-12",
      visits: 1882
      },
  {
      year: "FY 2011-12",
      visits: 1809
      },
  {
      year: "FY 2011-12",
      visits: 1322
      }
      }];
  
  
  AmCharts.ready(function() {
      // SERIAL CHART
      chart = new AmCharts.AmSerialChart();
      chart.autoMarginOffset = 0;
      chart.dataProvider = chartData;
      chart.categoryField = "year";
      chart.startDuration = 1;
      chart.depth3D = 20;
      chart.angle = 30;
  
      // AXES
      // category
      var categoryAxis = chart.categoryAxis;
      categoryAxis.labelRotation = 45; // this line makes category values to be rotated
      categoryAxis.gridAlpha = 0;
      categoryAxis.fillAlpha = 1;
      categoryAxis.fillColor = "#FAFAFA";
      categoryAxis.gridPosition = "start";
  
      // value
      var valueAxis = new AmCharts.ValueAxis();
      valueAxis.dashLength = 5;
      valueAxis.title = "Visitors from country";
      valueAxis.axisAlpha = 0;
      chart.addValueAxis(valueAxis);
  
      // GRAPH
      var graph = new AmCharts.AmGraph();
      graph.valueField = "visits";
      graph.colorField = "color";
      graph.balloonText = "[[category]]: [[value]]";
      graph.type = "column";
      graph.lineAlpha = 0;
      graph.fillAlphas = 1;
      chart.addGraph(graph);
  
      // WRITE
      chart.write("chartdiv");
  });
      &lt;/script&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>