Home >Backend Development >PHP Tutorial >Highcharts 怎么给data:赋值

Highcharts 怎么给data:赋值

WBOY
WBOYOriginal
2016-06-23 13:04:021041browse

nbsp;HTML>

    


        
        图表展示

        <script></script>
        
        <script> <br />$(function () { <br /> var data = $("#key").val(); <br /> var data1 = $("#value").val(); <br /> $('#container').highcharts({ <br /> title: { <br /> text: '交易额展示', <br /> x: -20 //center <br /> }, <br /> subtitle: { <br /> text: '', <br /> x: -20 <br /> }, <br /> xAxis: { <br /> categories: ['0-2', '2-4', '4-6', '6-8', '8-10', '10-12', <br /> '12-14', '14-16', '16-18', '18-20', '20-22', '22-24'] <br /> }, <br /> yAxis: { <br /> title: { <br /> text: '交易金额(元)' <br /> }, <br /> plotLines: [{ <br /> value: 0, <br /> width: 1, <br /> color: '#808080' <br /> }] <br /> }, <br /> tooltip: { <br /> valueSuffix: '元' <br /> }, <br /> legend: { <br /> layout: 'vertical', <br /> align: 'right', <br /> verticalAlign: 'middle', <br /> borderWidth: 0 <br /> }, <br /> series: [{ <br /> name: '今天', <br /> //data: [1,2,3,4,5,6,7,8,9]//手册上的 <br /> data: data <br /> }, { <br /> name: '昨天', <br /> //data: [2,3,4,5,6,7,8,9,10]//手册上的 <br /> data: data1 <br /> }] <br /> }); <br />}); <br /> <br /> </script>
    
    
<script></script>
<script></script>


Highcharts 怎么给data:赋值



    


回复讨论(解决方案)

$data = '2,3,4,5,6,7,8,9,10';


data: [<?php echo $data;?>]


这样不就行了?

大哥它里面是不解析的

看你是ajax返回?还是直接echo?

ajax试过没成功,我就直接把他发送到页面了  $shu = '';
        $data = array();//今日交易额
        $a = '';
        for($i=0;$i            $shu = $today+$i*7200;
            $re = $num->where("`time_end` > $today and `time_end` select();
            for($m=0;$m                $a += $re[$m]['total_fee']/100;
            }
            //var_dump($re);exit;
            //echo $num->getlastsql();
            $data[] =$a;
        }
        
        //var_dump($data);//exit;
        $shu1 = '';
        $b = '';
        $data1 = array();//昨日交易额
        for($j=0;$j            $shu1 = $yesterday+$j*7200;
            $re1 = $num->where("`time_end` > $yesterday and `time_end` select();
            for($n=0;$n                $b += $re1[$n]['total_fee']/100; 
            }
            $data1[] =$b;
        } 
        
        $data = implode(',',$data);
        //$data = json_encode($data);
        $data1 = implode(',',$data1);
        //$data1 = json_encode($data1);
        // var_dump($data);
        // var_dump($data1);exit;
        $this->assign('data',$data);
        $this->assign('data1',$data1);
        $this->display();

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn