2012-02-01 66 views
0

雖然在線提供的文檔非常少,但我已經能夠使用Raphael.jsgRaphael插件瞭解如何生成下面顯示的圖表。我對我如何設計懸停在每個數據點時出現的標籤樣式感到非常困惑。如何在文本中添加填充?添加填充到gRaphael圖表?

這裏是它的外觀現在:

enter image description here

代碼:

var r = Raphael("graphcontainer"); 
var linec = r.linechart(10,10,300,220,[1,2,3,4,5],[10,20,15,35,30], {colors:["#009933"], symbol:"circle", smooth: false}); 

linec.hoverColumn(function() { 
    this.tags = r.set(); 
    for (var i = 0, ii = this.y.length; i < ii; i++) {   
     this.tags.push(r.tag(this.x + 10, this.y[i], this.values[i]+"tkr", 0, 0).insertBefore(this).attr([{ fill: "#fff" }, { fill: this.symbols[i].attr("fill") }])); 
    } 
}, function() { 
    this.tags && this.tags.remove(); 
}); 

回答

0

我也有類似的問題軸。

您可能需要獲取Raphael對象並將其變爲jQuery對象,然後通過jQuery進行樣式設置。

事情是這樣的:

for (var i = 0, ii = this.y.length; i < ii; i++) {   
    this.tags.push(r.tag(this.x + 10, this.y[i], this.values[i]+"tkr", 0, 0).insertBefore(this).attr([{ fill: "#fff" }, { fill: this.symbols[i].attr("fill") }])); 
    var $jQueryObject = $(this.tags.node); 
    $jQueryObject.css('font-size', '30px') 
} 

請注意,並非所有的CSS屬性與此解決方案的工作。我不確定爲什麼,如果有人對此有一些評論,將不勝感激。

可能需要進行一些調整。讓我們知道你的經驗;)

希望它有幫助!

+1

嗨,嗯,我只是想知道當工具提示標籤出現在頁面上時呈現的html標籤是什麼?由於我嘗試了你的建議,但它不起作用,所以我認爲在整個頁面加載時捕獲標記應該沒問題 – 2012-07-05 18:10:17