/** * Raw encode/decode when the subject is json encoded for render */ public function testRawRender() { $testData = array('foo' => Raw::encode('bar')); //expect the property 'bar' to be rendered as raw string and not wrapped //in the JSON standard quotes after being JSON encoded $expected = '{"foo":bar}'; $this->assertEquals($expected, Raw::decode(json_encode($testData))); }
/** * Returns the plottable chart data formatter as js Date * @param Array $seriesData Series data as supplied by the user * @return Array */ public function getFormattedChartData(array $seriesData) { $ret = array(); foreach ($seriesData as $date => $value) { //render the js Date obect as raw $ret[] = Raw::encode('[' . $this->_convertStringToJsDate($date) . ',' . $value . ']'); } return $ret; }
/** * Creates and returns the JavaScript variables and Highcharts instance * @param Chart $chart Instance of Phighchart\Chart * @param Array $options The full set of options for this chart * @return String $ret The JSON string to display the complete chart */ public function outputJavaScript(Chart $chart, array $options) { // use the renderTo id as the JS variable name $jsVar = $this->getRenderTo($chart); return Raw::decode("var " . $jsVar . "; " . $jsVar . " = new Highcharts.Chart(" . json_encode($options) . ");"); }