$ .getJSON未将值显示为折线图 [英] $.getJSON is not getting the values to show as a line graph

查看:94
本文介绍了$ .getJSON未将值显示为折线图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文件



searh_journal.php



I have two files

searh_journal.php

<script type="text/javascript">
function submitForm() {

    var form = document.myform;

    var dataString = $(form).serialize();

    $.ajax({
        type: 'POST',
        url: 'journal_table/get_data_journ.php',
        data: dataString,
        success: function (data) {
            $('#container_journal').html(data);

            var options = {
                chart: {
                    renderTo: 'container_journal',
                    plotBackgroundColor: null,
                    plotBorderWidth: null,
                    plotShadow: false
                },

                xAxis: {
                    title: {
                        text: 'Year'
                    },
                    categories: []
                },

                yAxis: {
                    title: {
                        text: 'Number of Citations'
                    },
                    plotLines: [{
                        value: 0,
                        width: 1,
                        color: '#808080'
                    }]
                },

                series: [{
                    type: 'line',
                    color: '#0066FF',
                    name: 'Citations',
                    data: []
                }]
            }

            $.getJSON("journal_table/get_data_journ.php", function (data) {
                $.each(data, function (key, value) {
                    $.each(value, function (key, value) {
                        options.series[0].data = value;
                    });
                });

                chart = new Highcharts.Chart(options);
            });


        }
    });
    return false;
}
</script>







<div id="container_journal"></div>





get_data_journ.php





get_data_journ.php

include '../connect.php';


$hello = $_POST['checkedname'];
foreach($hello as $key = > $values) {
    $result_journ = mysql_query("SELECT year, citations, jour_id FROM journ_graph WHERE jour_id = '$values'");

    $rows_journ = array();
    while ($r_journ = mysql_fetch_array($result_journ)) {
        $row_journ[0] = $r_journ[0];
        $row_journ[1] = $r_journ[1];
        array_push($rows_journ, $row_journ);
    }


    print json_encode($rows_journ, JSON_NUMERIC_CHECK);

}







<br />
The output is like this<br />
<br />
            | Journal Name | Edgefactor |<br />
    Checkbox| journal1     | 0.56       |<br />
    Checkbox| journal2     | 0.34       |<br />
    Checkbox| journal3     | 0.32       |<br />
    Checkbox| journal4     | 0.14       |<br />
    Checkbox| journal5     | 0.54       |<br />



比较日记按钮

如果用户选择两种期刊并且他想比较两种期刊,他可以点击比较日记按钮,然后必须显示这两个日记的图表。



这里的html部分工作我的意思是显示简单的html json数据,但是图表没有显示,问题出在$ .getJson()行中我想。


Compare Journal button
Here if the user chooses two journals and he wants to compare two journals, he can click on the compare journal button, then the graph must be shown for that two journals.

Here the html part is working i mean the plain html json data is shown, but the graph is not showing, the problem is in the $.getJson() line I guess.

推荐答案

(表格).serialize();
(form).serialize();


.ajax({
type:' POST'
url:' journal_table / get_data_journ.php'
data:dataString,
成功: function (data){
.ajax({ type: 'POST', url: 'journal_table/get_data_journ.php', data: dataString, success: function (data) {


' #container_journal')。html(data);

var options = {
chart:{
renderTo:' container_journal'
plotBackgroundColor: null
plotBorderWidth: null
plotShadow: false
},

xAxis: {
title:{
text:' Year'
} ,
类别:[]
},

yAxis:{
title:{
text:' 引文数
},
plotLines:[{
value: 0
width: 1
color:' #808080'
}]
},

系列:[{
类型:' line'
color:' #0066FF'
name:' Citations'
data:[]
}]
}
('#container_journal').html(data); var options = { chart: { renderTo: 'container_journal', plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }, xAxis: { title: { text: 'Year' }, categories: [] }, yAxis: { title: { text: 'Number of Citations' }, plotLines: [{ value: 0, width: 1, color: '#808080' }] }, series: [{ type: 'line', color: '#0066FF', name: 'Citations', data: [] }] }


这篇关于$ .getJSON未将值显示为折线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆