基于html表单响应的绘图图像

时间:2018-10-15 16:59:08

标签: php html

我有一个html表单,可以选择用户可以查看的报告类型。我将结果传递给一个php脚本,该脚本将所有JPGraph制作的图表组合在一起,创建图像,并打开一个新选项卡以显示图像。我需要将此图像显示在HTML页面本身中,而不是在新标签中显示。一种解决方案是将其保存到服务器,然后从html打开图像,但是我没有写权限。

这是HTML表单,用于决定要在页面上显示哪些报告。

 <form action ="DrawGraphs.php "method="POST">
                Start Date:
                    <input type ="date" name ="startDate" value="2012-01-04"/>
                 <p> </p>
                 End Date: &nbsp
                    <input type ="date" name ="endDate" value= <?php echo date('Y-m-d'); ?> >
                <br>
                <br>
                Report Type
                <br>
                    &nbsp<input type="checkbox" name = "session" value="session"> Longest Sessions
                <br>
                    &nbsp<input type="checkbox" name = "export" value="export"> Export Data
                <br>
                    &nbsp<input type="checkbox" name = "format" value="format"> Format Data
                <br>
                    &nbsp<input type="checkbox" name = "scan" value="scan"> Scan Data
                <br>
                <br>
                 <input type="submit" name="submit" value="Search"/>
            </form>

这是php脚本,用于获取图形并将请求的图形放入单个图像中。

DrawGraphs.php:

    $x_axis = 0;
    $y_axis = 0;
    $image = imagecreatetruecolor(2500,1900);
    if(isset($_POST['session'])){

        $handle1 = (TopTenLongestSessionsGraph($start,$end));
        imagecopy($image, $handle1,$x_axis, $y_axis, 0, 0, 2300,1400);
        $x_axis += 1500;
        $y_axis += 0;
    }

    if(isset($_POST['scan'])) {
        $handle2 = ScanDataGraph($start, $end);
        imagecopy($image, $handle2, $x_axis, $y_axis, 0, 0, 750, 825);
        $x_axis = 0;
        $y_axis += 900;
    }

    if(isset($_POST['format'])){
        $handle3 = drawFormatDataGraph($start,$end);
        imagecopy($image, $handle3,$x_axis,$y_axis,0,0,1800,1400);
        $x_axis = 1300;
    }

    if(isset($_POST['export'])){
        $handle4 =  DrawDataExportGraph($start,$end);
        imagecopy($image, $handle4,$x_axis,$y_axis,0,0,1100,1100);
    }

    header("Content-type: image/png");
    imagepng ($image);

在此先感谢您,如果需要更多信息,请告诉我。

0 个答案:

没有答案