从mysql中在php中绘制多个折线图 [英] draw multiple line chart in php from mysql

查看:95
本文介绍了从mysql中在php中绘制多个折线图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是html文件



this is html file

<!DOCTYPE html PUBLIC "-//W3C//DTD X<code></code>HTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="js/modernizr-2.5.3.min.js"></script>
<script language="javascript" src="jquery/jquery-1.9.0.min.js"></script>
<script language="javascript">
$(document).ready(function(){
    $("#sub").click(function(){
        var str="";
        $("input[type=checkbox]:Checked").each(function(){
            a = $(this).val();
            str=str+a+"#";
        })
        str1=str.substr(0,str.length-1);
        alert(str);
        $.ajax({
             type: "POST",
             url: "chart-multiple.php",
             data:{str1:str1},
             success: function(data){
                alert(data);
                $("#chart-table").empty();
                $("#chart-table").append(data);
             }
         });

       });
});
</script>
</head>

<body>
<form id="frm1">
<input type="checkbox" id="ins1" value="SHC-I-01" />SHC-I-01
<input type="checkbox" id="ins2" value="SHC-I-02" />SHC-I-02
<a href="#" name="sub" id="sub">Generate</a>
<!--<input type="submit" name="submit" value="Generate" id="submit"/>-->
<table id="chart-table">

</table>
</form>

</body>
</html>





chart-multiple.php文件。





chart-multiple.php file this is.

<?php
    //include "libchart/classes/libchart.php";
    include("dbconnection.php");
    require_once ('src/jpgraph.php');
    require_once ('src/jpgraph_line.php');
    $ins_instalid=$_REQUEST['str1'];
    $strarray=explode('#',$ins_instalid);
    $sel_date = mysql_query("select distinct ReadingDate from trn_1");
    while($row_date=mysql_fetch_array($sel_date)){
        $date[] = $row_date['ReadingDate'];
    }
    $i=0;
    $j=0;
    foreach($strarray as $col){
        $sql = mysql_query("select * from trn_1 where InstallInstrumentId='$col'");
        while($row=mysql_fetch_array($sql)){
            $x = $row["ReadingDate"];
            if(in_array($x,$date,true))
            {
                $data[$i][$j] = $row["CumulativeChange"];

            }
            $j++;
        }
        $i++;
    }
    
    $graph = new Graph(400,600);
    $graph->SetScale("textlin");

    $theme_class=new UniversalTheme;

    $graph->SetTheme($theme_class);
    $graph->img->SetAntiAliasing(false);
    $graph->title->Set('Filled Y-grid');
    $graph->SetBox(false);

    $graph->img->SetAntiAliasing();

    $graph->yaxis->HideZeroLabel();
    $graph->yaxis->HideLine(false);
    $graph->yaxis->HideTicks(false,false);

    $graph->xgrid->Show();
    $graph->xgrid->SetLineStyle("solid");
    $graph->xaxis->SetTickLabels($date);
    $graph->xgrid->SetColor('#E3E3E3');
    
    $p1 = new LinePlot($data);
    $graph->Add($p1);
    $p1->mark->SetType(MARK_FILLEDCIRCLE,'',1.0);
    $p1->mark->SetColor('#6495ED');
    $p1->SetLegend('Line1');
    $graph->legend->SetFrameWeight(1);
    $graph->Stroke();
    

?>





i想在一个折线图中绘制多个折线图。我使用jgpgraph。我试试这段代码。但是图表没有得到正确的解决。请帮我。我有输出但是输出有一些符号



i want to draw multiple line graph in one line chart.. Iam using jgpgraph. I try this code. But graph did not come properly. Please help me. i got output but output is coming some symbols

推荐答案

(文件).ready(function(){
(document).ready(function(){


(# sub)。click(function(){
var str =;
("#sub").click(function(){ var str="";


(input [type = checkbox]:Checked)。each(function(){
a =
("input[type=checkbox]:Checked").each(function(){ a =


这篇关于从mysql中在php中绘制多个折线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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