0

Hello I need to add chart in my view

I still confusing, there are many chart example in internet but using javascript, and a little using table as chart base value...

I need your help to input my value on database and table to my chart

here my View:

<table><?php   if($query): foreach($query as $post) ?>
<tr>
<th> Number </th> <th> Jenis </th> <th> Hasil </th>
</tr>
<tr>
<td> 01 </td> <td> <? echo $post->jenis1; </td> <td> <? echo $post->hasil1; ?> </td>
<td> 02 </td> <td> <? echo $post->jenis2; </td> <td> <? echo $post->hasil2; ?> </td>
....etc
</tr><?php  endforeach;?>
</table><?php endif ?>

Here My Javascript script for graphic on below

<script lang="javascript" type="text/javascript">
    $(document).ready(function () {
        $('#jqChart').jqChart({
            title: { text: 'Grafik Masalah Individu' },
            axes: [
                    {
                        location: 'left',
                        minimum: 0,
                        maximum: 100,
                        interval: 5
                    }
                  ],
            series: [
                        {
                            type: 'column',
                            data: [['Kesehatan',3], ['Ekonomi', 14], ['Keluarga', 65], ['Agama & Moral', 85 ], ['Pribadi', 76], ['Hubungan Sosial', 43]]
                        } /* I want to insert my database value there  */
                    ]
        });
    });
</script>
4

1 回答 1

0

我希望这有帮助

<script lang="javascript" type="text/javascript">
        $(document).ready(function () {
            $('#jqChart').jqChart({
                title: { text: 'Your graph name' },
                axes: [
                        {
                            location: 'left',
                            minimum: 0,
                            maximum: 100,
                            interval: 5
                        }
                      ],
                series: [
                            {
                                type: 'column',
                                data: [[<? echo $post->jenis1; ?>], <? echo $post->hasil1; ?>], [<? echo $post->jenis2; ?>], <? echo $post->hasil2; ?>], ...etc]
                            }
                        ]
            });
        });
    </script>
于 2013-08-17T02:27:29.913 回答