dtkvlj5386 2010-08-26 22:55
浏览 41
已采纳

如何存储$ chart-> draw()的结果; 变量?

I'm using the succinctly named googlechartseasyphpclass script to generate google charts from numbers I'm grabbing from a database. After the charts are generated, I want to put the results in a different table. The way you generate a Google Charts URL using the easyphpclass script is like this:

$chart=new googleChart(null,'line',$title,'500x200');
$chart->loadData($chartData);
$chart->setLabels($axislabel);
$chart->draw(); 

That last line is tripping me up. I can't shove the URL it produces into a variable so I can put it in a database table. It just draws the chart on the screen. Is there a good way of taking that value and making it something I can use? Thanks!

  • 写回答

1条回答 默认 最新

  • dongleiqiao4906 2010-08-26 22:59
    关注

    From the documentation you linked, it'll echo a <img> tag if the first parameter is true (which it is by default) and will return a url if the first parameter is false. Thus you could do something like:

    $chart_url = $chart->draw(false);
    

    Or capture the entire <img> tag:

    $chart_img_tag = '<img src="' . $chart->draw(false) . '" />';
    

    You could use output buffering but for something like this it's really unnecessary overkill because it's trivial to output your own <img> tag.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记