2013-04-08 54 views
0

是否可以使用圖像映射並同時緩存圖表? 當我啓用緩存時,圖像映射不再被創建。 我需要有圖像映射,以便將鼠標懸停在圖像上時顯示該值,但我希望能夠緩存圖表以顯着減少我的cpu負載。 我一直無法找到有關這個地方的信息,pChart論壇是一團糟。pChart 2.0圖像地圖和緩存在同一時間?

回答

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"); 

我知道這是一個老問題,但我希望這有助於。

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"); 
}