我想要做的就是每天要執行的功能,產生highcharts圖形和服務器中的文件夾中保存爲圖像。從Highchart在PHP
我不能想出如何做的是產生從PHP一個highchart並保存爲圖像。
我發現這個代碼
$url = 'http://export.highcharts.com/';
$data = array('filename' => 'chart' , 'type' => 'image/jpeg' , 'svg' => '<svg xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" xmlns="http://www.w3.org/2000/svg" width="600" height="400"><desc>Created with Highcharts 3.0.4</desc><defs><linearGradient x1="0" y1="0" x2="1" y2="1" id="highcharts-13"><stop offset="0" stop-color="rgb(255, 255, 255)" stop-opacity="1"></stop><stop offset="1" stop-color="rgb(240, 240, 255)" stop-opacity="1"></stop></linearGradient><clipPath id="highcharts-14"><rect fill="none" x="1" y="1" width="550" height="304"></rect></clipPath></defs><rect rx="0" ry="0" fill="url(#highcharts-13)" x="1" y="1" width="598" height="398" stroke="#4572A7" stroke-width="2"></rect><rect rx="0" ry="0" fill="none" x="38" y="40" width="552" height="306" fill-opacity="0.9" stroke="black" stroke-opacity="0.049999999999999996" stroke-width="5" transform="translate(1, 1)"></rect><rect rx="0" ry="0" fill="none" x="38" y="40" width="552" height="306" fill-opacity="0.9" stroke="black" stroke-opacity="0.09999999999999999" stroke-width="3" transform="translate(1, 1)"></rect><rect rx="0" ry="0" fill="none" x="38" y="40" width="552" height="306" fill-opacity="0.9" stroke="black" stroke-opacity="0.15" stroke-width="1" transform="translate(1, 1)"></rect><rect rx="0" ry="0" fill="rgb(255,255,255)" x="38" y="40" width="552" height="306" fill-opacity="0.9"></rect><g class="highcharts-grid" ></g><g class="highcharts-grid" ></g><rect rx="0" ry="0" fill="none" x="38.5" y="40.5" width="551" height="305" stroke="#C0C0C0" stroke-width="1" ></rect><g class="highcharts-axis" ><path fill="none" d="M 38 345.5 L 590 345.5" stroke="#000" stroke-width="1" visibility="visible"></path></g><g class="highcharts-axis" ><text x="28" y="193" style="font-family:trebuchet ms, verdana, sans-serif;font-size:12px;color:#333;font-weight:bold;fill:#333;" text-anchor="middle" transform="translate(0,0) rotate(270 28 193)" visibility="visible"><tspan x="28">Temperatura °C</tspan></text><path fill="none" d="M 38.5 40 L 38.5 346" stroke="#000" stroke-width="1" visibility="visible"></path></g><g class="highcharts-series-group" ><g class="highcharts-series" visibility="visible" transform="translate(38,40) scale(1 1)" clip-path="url(#highcharts-14)"></g><g class="highcharts-markers" visibility="visible" transform="translate(38,40) scale(1 1)" clip-path="none"><path fill="none" d="M 0 0" class="highcharts-tracker" stroke-linejoin="round" visibility="visible" stroke-opacity="0.0001" stroke="rgb(192,192,192)" stroke-width="22" style=""></path></g><g class="highcharts-series" visibility="visible" transform="translate(38,40) scale(1 1)" clip-path="url(#highcharts-14)"></g><g class="highcharts-markers" visibility="visible" transform="translate(38,40) scale(1 1)" clip-path="none"><path fill="none" d="M 0 0" class="highcharts-tracker" stroke-linejoin="round" visibility="visible" stroke-opacity="0.0001" stroke="rgb(192,192,192)" stroke-width="22" style=""></path></g><g class="highcharts-series" visibility="visible" transform="translate(38,40) scale(1 1)" clip-path="url(#highcharts-14)"></g><g class="highcharts-markers" visibility="visible" transform="translate(38,40) scale(1 1)" clip-path="none"><path fill="none" d="M 0 0" class="highcharts-tracker" stroke-linejoin="round" visibility="visible" stroke-opacity="0.0001" stroke="rgb(192,192,192)" stroke-width="22" style=""></path></g></g><text x="300" y="25" style="font-family:\'lucida grande\', \'lucida sans unicode\', verdana, arial, helvetica, sans-serif;font-size:16px;color:#000;font:bold 16px \'trebuchet ms\', verdana, sans-serif;fill:#000;width:536px;" text-anchor="middle" class="highcharts-title" ><tspan x="300">Grafica en tiempo real del equipo "Equipo 1" de la última hora</tspan></text><g class="highcharts-legend" transform="translate(182,356)"><rect rx="5" ry="5" fill="none" x="0.5" y="0.5" width="235" height="28" stroke="#909090" stroke-width="1" visibility="visible"></rect><g ><g><g class="highcharts-legend-item" transform="translate(8,3)"><path fill="none" d="M 0 11 L 16 11" stroke="#058DC7" stroke-width="2"></path><path fill="#058DC7" d="M 8 7 C 13.328 7 13.328 15 8 15 C 2.6719999999999997 15 2.6719999999999997 7 8 7 Z"></path><text x="21" y="15" style="font-family:\'lucida grande\', \'lucida sans unicode\', verdana, arial, helvetica, sans-serif;font-size:12px;cursor:pointer;color:black;font:9pt trebuchet ms, verdana, sans-serif;fill:black;" text-anchor="start" ><tspan x="21">Sensor 1</tspan></text></g><g class="highcharts-legend-item" transform="translate(84,3)"><path fill="none" d="M 0 11 L 16 11" stroke="#50B432" stroke-width="2"></path><path fill="#50B432" d="M 8 7 L 12 11 8 15 4 11 Z"></path><text x="21" y="15" style="font-family:\'lucida grande\', \'lucida sans unicode\', verdana, arial, helvetica, sans-serif;font-size:12px;cursor:pointer;color:black;font:9pt trebuchet ms, verdana, sans-serif;fill:black;" text-anchor="start" ><tspan x="21">Sensor 2</tspan></text></g><g class="highcharts-legend-item" transform="translate(160,3)"><path fill="none" d="M 0 11 L 16 11" stroke="#ED561B" stroke-width="2"></path><path fill="#ED561B" d="M 4 7 L 12 7 12 15 4 15 Z"></path><text x="21" y="15" style="font-family:\'lucida grande\', \'lucida sans unicode\', verdana, arial, helvetica, sans-serif;font-size:12px;cursor:pointer;color:black;font:9pt trebuchet ms, verdana, sans-serif;fill:black;" text-anchor="start" ><tspan x="21">Sensor 3</tspan></text></g></g></g></g><g class="highcharts-axis-labels" ></g><g class="highcharts-axis-labels" ></g><g class="highcharts-tooltip" style="cursor:default;padding:0;white-space:nowrap;" visibility="hidden" transform="translate(0,0)"><rect rx="3" ry="3" fill="none" x="0.5" y="0.5" width="16" height="16" fill-opacity="0.85" stroke="black" stroke-opacity="0.049999999999999996" stroke-width="5" transform="translate(1, 1)"></rect><rect rx="3" ry="3" fill="none" x="0.5" y="0.5" width="16" height="16" fill-opacity="0.85" stroke="black" stroke-opacity="0.09999999999999999" stroke-width="3" transform="translate(1, 1)"></rect><rect rx="3" ry="3" fill="none" x="0.5" y="0.5" width="16" height="16" fill-opacity="0.85" stroke="black" stroke-opacity="0.15" stroke-width="1" transform="translate(1, 1)"></rect><rect rx="3" ry="3" fill="rgb(255,255,255)" x="0.5" y="0.5" width="16" height="16" fill-opacity="0.85"></rect><text x="8" y="21" style="font-family:\'lucida grande\', \'lucida sans unicode\', verdana, arial, helvetica, sans-serif;font-size:12px;color:#333333;fill:#333333;" ></text></g><text x="590" y="395" style="font-family:\'lucida grande\', \'lucida sans unicode\', verdana, arial, helvetica, sans-serif;font-size:9px;cursor:pointer;color:#909090;fill:#909090;" text-anchor="end" ><tspan x="590">Highcharts.com</tspan></text></svg>');
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
));
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
但是,「當我這樣做,我收到
「字符串(20221)」 ÿØÿàJFIFHHÿÛC$。 」,#(7),01444'9 = 82 <.342ÿÛC
2 !!22222222222222222222222222222222222222222222222222ÿÀX 「雅
ÿÄμ} 1AQa」 q2'¡#乙±ARND $ 3房, %&「()* 456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ 「...†‡‰S'‘’•--~™的¢¤£¥|§¨©ª²³'μ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ
ÿÄμw!1AQaq「2B'¡±A#3RðbrÑ $ 4 á%N &「()* 56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz,ƒ「...†‡‰S'?‘’•--~™的¢¤£¥|§¨©ª²³'μ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚâãäåæçèéêòóôõö÷øùúÿÚï¼ !Tíμí> q & YIC:CAP€VCUÿgþG-YS£AO $ißöÓÿF5tμ½Z³Si7¹:PPZ×üÿ gþG-YS£þÐ3ÿ#ËÿÅWKIQíj3/Ùò9¿ø@ < 1Y @ IU /ÿIÿ†èÿ'åÿâ«¥®{A ^4Ñüonúœ 「<×/²ÞÖÞ?2i>ñWñqÔzÑíj3gÈþÐ3ÿ#ËÿÅQÿ†èÿ'åÿâ©<5ã[ ÔïuB4†ÎßÌKtf¾CBŒ,N£ÚÔþfÎ'7ü ÿ gþG-YS£þÐ3ÿ#ËÿÅV‡‡õ¿øH4϶ÿeêzoÎSÈÔü™XI·'ƒžμ«Gμ©UI =œ;#SY「ÃôÿÈòÿñTÂáúäyøªéi(緣分™‡³‡DSD €øcþŸù_þ*ø@ | 1Y @Ïü'ÿ]%{ZŸÌÃÙò9¿ø@ | 1Y @Ïü'ÿGüÿgþG「YSE»¨ìl§»~''®@歐盟£ 'UV4±½ðRø§M²Ôμ7ÿWoio¾âLIå©' OEIC &ŸμŸó0öpìƒþÐ3ÿ#ÉÿÅQÿ†?èÿ'äÿâ«〜Ú'ÚÃ?•$^J +ùr®×LOEA ‡b; S-kSù~{8vG7ÿ†èÿ'äÿâ¨ÿ?「ÃôÿÈòñUÒQGμ©UI =œ;#> Y‘ÃôÿÈòñTŸð€øcþŸùOþ*ºZJ=OæaìáÙßü ÿgþG’YS£þÿÐ3ÿ#ÉÿÅWIEÖ」
當我在Google上搜索'產生從PHP一個highchart並保存爲image',我得到這個[如何保存highcharts服務器上的圖表的圖像?](http://stackoverflow.com/q/8802528)也許這很有幫助 –