JQplot - jqplotToImageStr - 如何将生成的字符串转换回图表

JQplot - jqplotToImageStr - How to convert the generated string back into a chart

我可以创建图表、显示它、生成图像并使用 jqplotToImageStr 转换图像,然后将其发布到另一个 php 页面。

我希望能够将字符串转换回图像并将其显示在 php 页面上,然后我可以将其转换为 pdf。我试过使用这个 php 代码

$img = $_POST['hidImage'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
return $data;

(在片段中使用 modx 2.5.1)

但它不会呈现为图像 - 该图像显示了生成的源代码(总共 345 行)的顶部和底部部分。

在我的理智终于离开之前,我非常感谢任何帮助或建议:-(

您需要为图像类型设置headers。 检查 this answer 供您参考。

header('Content-type: image/png');