2013-03-18 161 views
0

我正在使用highcharts和high roller組合來渲染圖表。Highcharts - Highroller包括JavaScript功能

定義屬性在高輥圖表它通常是非常簡單的:

$this->chart->xAxis->labels->rotation= 55; 
$this->chart->xAxis->labels->align= 'left'; 

變得像這樣:

"labels":{"rotation":55,"align":"left"} 

的問題是,我想有一個js函數,像這樣:

events: { 
    load: Highcharts.drawTable 
}, 

問題是,如果我包含一個函數就像我會爲任何其他財產highroller將包裹在引號。我認爲這是因爲它在技術上是一個字符串。 對於整數看起來highcharts刪除引號。

所以問題簡而言之:如何使用highroller在events-> load中添加一個函數。

我想用它來呈現數據表與圖表。

回答

0

雖然與加載函數不完全相同,但Highroller有一個如何添加工具提示格式化函數的示例。相同的方法應該適用於加載函數。基本的方法是在JavaScript中而不是在php中添加函數。 https://github.com/jmaclabs/HighRoller/blob/master/README.md

var myChartOptions = <?php echo $linechart->getChartOptionsObject()?> 

    // define your own formatter for tooltip 
    myChartOptions.tooltip.formatter = function() { 
    return '<b>' + this.series.name + '</b><br/>' + 
     Highcharts.dateFormat('%b %e', this.x) + ': ' + Highcharts.numberFormat(this.y, 0, ',') + ' views'; 
    }; 
0

代碼鑽進了引號,因爲JSON編碼功能使周圍eeeeverything報價。

由於highroller不再處於開發階段,因此在給出參數時,我冒昧給highroller添加一個自定義部分。