<?php function buatrp($angka) { $jadi = "" . number_format($angka,0,',','.'); return $jadi; } ?>

<div class="row">
    <div class="col-md-12">
        <div class="box">
            <div class="box-header with-border">
                <h3 class="box-title">10 Besar Penggunaan Obat</h3>
                <div class="box-tools pull-right">
                    <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                    <a href="<?php echo base_url('admin/home'); ?>" class="btn btn-box-tool"><i class="fa fa-times"></i></a>
                </div>
            </div>
            <div class="box-body">
                <div id="obat" class="chart"></div>
            </div>
            <div class="box-footer">
                <i class="fa fa-clock-o"></i> Data realtime
            </div>
        </div>
    </div>
</div>

<script>
var chartData = [ 
    <?php
    $i = 0;
    foreach ($chart_obat as $content) {
        $i++;
        ?>
        {
            "country" : "<?php echo $content->item_code_desc; ?>",
            "visits" : <?php echo $content->Qty; ?>,
            "color": "<?php echo color($i) ?>"
        },
        <?php
    }
    ?>
];


var obat = AmCharts.makeChart( "obat", {
  "theme": "light",
  "type": "serial",
  "dataProvider": chartData,
  "categoryField": "country",
  "depth3D": 20,
  "angle": 30,

  "categoryAxis": {
    "labelRotation": 90,
    "gridPosition": "start"
  },

  "valueAxes": [ {
    "title": "10 Besar Penggunaan Obat"
  } ],

  "graphs": [ {
    "valueField": "visits",
    "colorField": "color",
    "type": "column",
    "lineAlpha": 0.1,
    "fillAlphas": 1,
    "balloonText": "[[category]]: <b>[[visits]]</b>"
  } ],

  "chartCursor": {
    "cursorAlpha": 0,
    "zoomable": false,
    "categoryBalloonEnabled": false
  },

  "export": {
    "enabled": true
  }
} );
     
</script>