0

是否可以同时使用图像地图和缓存图表?当我启用缓存时,不再创建图像映射。我需要图像映射,以便在我将鼠标悬停在其上时显示该值,但我希望能够缓存图表以显着减少我的 cpu 负载。我无法在任何地方找到有关此的信息,而且 pChart 论坛一团糟。

4

2 回答 2

0

我能够使用以下代码使其工作。对于论坛的格式和限制,我深表歉意。我还必须修改 pImage.class 以不删除 tmp 文件,因此将它们保存为缓存图像。

if ( $myCache->isInCache($ChartHash)) {
/* Retrieve the image map */
if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) {
$StorageFolder = PCHART_PATH . "/cache/imageMap";
$UniqueID = "AreaChart".$ChartHash;
if (file_exists($StorageFolder."/".$UniqueID.".map")) {
$Handle = @fopen($StorageFolder."/".$UniqueID.".map", "r");
if ($Handle) { while (($Buffer = fgets($Handle, 4096)) !== false) { echo $Buffer; } }
fclose($Handle);
}
}
/* Output cached image */
$myCache->strokeFromCache($ChartHash,"pictures/drawAreaChart.".$ChartHash.".png");
}
于 2014-01-22T12:45:11.153 回答
0

对于当前版本(2.1.3),这是不可能的。图像映射仅在 pChart 实际绘制图像时创建,即稍后当您从缓存中获取图像时,图像映射不可用。

要绕过它,您可以自己缓存图像映射。从http://wiki.pchart.net/doc.imagemaps.fundamentals.html上的示例开始,您可以按照这些方式做一些事情

//initialise the map
$myPicture->initialiseImageMap("ImageMapBarChart", IMAGE_MAP_STORAGE_FILE, "BarChart", "../tmp");
//draw the chart
$Settings = array("RecordImageMap" => TRUE);
$myPicture->drawBarChart($Settings);
//the image map is ready for you here
//so before you output the chart get the map with dumpImageMap() and copy it to YOUR OWN CACHE
$myPicture->dumpImageMap("ImageMapBarChart", IMAGE_MAP_STORAGE_FILE, "BarChart", "../tmp");

我知道这是一个老问题,但我希望这会有所帮助。

于 2013-11-13T15:39:34.633 回答