首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用PHP包含命令的多个高级图表

使用PHP包含命令的多个高级图表
EN

Stack Overflow用户
提问于 2015-06-07 00:56:21
回答 1查看 174关注 0票数 2

如何使用php include命令将多个图表包含到同一个页面?

我试过了,但没有用:

代码语言:javascript
运行
复制
$y=$objective;
$n=count($objective);
    for($i=0; $i<$n; $i++){
        $count[]=$i;
    }
$x=$count;
include("graph.php");
$y=$temp;
$n=count($temp);
for($i=0; $i<$n; $i++){
    $count[]=$i;
}
$x=$count;
include("graph.php");

在"graph.php“中,我有这样的说法:

代码语言:javascript
运行
复制
<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Highcharts Example</title>

        <script type="text/javascript" src="../js/jquery.js"></script>

        <style type="text/css">
${demo.css}
        </style>
        <script type="text/javascript">

        var x_data = <?php echo json_encode($x); ?>;
        var y_data = <?php echo json_encode($y); ?>;
$(function () {
    $('#container').highcharts({
        chart: {
            zoomType: 'x'
        },
        title: {
            text: 'Title'
        },
        subtitle: {
            text: document.ontouchstart === undefined ?
                    'Click and drag in the plot area to zoom in' :
                    'Pinch the chart to zoom in'
        },
        xAxis: {
            //type: 'datetime',
           // minRange: 14 * 24 * 3600000 // fourteen days
           x_data
        },
        yAxis: {
            title: {
                text: 'Variable'
            }
        },
        legend: {
            enabled: false
        },
        plotOptions: {
            area: {
                fillColor: {
                    linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1},
                    stops: [
                        [0, Highcharts.getOptions().colors[0]],
                        [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
                    ]
                },
                marker: {
                    radius: 2
                },
                lineWidth: 1,
                states: {
                    hover: {
                        lineWidth: 1
                    }
                },
                threshold: null
            }
        },

        series: [{
            type: 'area',
            name: 'Data',
           // pointInterval: 24 * 3600 * 1000,
            //pointStart: Date.UTC(2006, 0, 1),
            data: y_data
        }]
    });
});
        </script>
    </head>
    <body>
<script src="Highchart/js/highcharts.js"></script>
<script src="Highchart/js/exporting.js"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

    </body>
</html>

如果不可能,我该如何解决这个问题呢?还有什么其他方法我可以用吗?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-07 15:53:40

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

尝试使每个包含的id值不同。

$divId = 'container_' . mt_rand( 1, 1000 );

$('#<?php echo $divId;?>').highcharts...

<div id="<?php echo $divId;?>" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30689011

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档