2012-05-03 61 views
1

jqplotを使用して、異なる線の色の複数の線を描画しています。jqplotの線色に従った凡例のテキストの色

また、色がの場合はに対応する線色に従う伝説があります。

私は伝説の色に対処する方法がないようです。

どのようなヒントですか?

答えて

3

質問タイトルから取ったシリーズの色に対応する凡例ラベルの色を変更したいと思います。

このため、ラベルの正面にある見本があるので、ラベルに設定した色をつかむために使用することができます。

これは必要なコードのビットです。プロットを描く前にそれを置くことを覚えておく必要があります。

$.jqplot.postDrawHooks.push(function() { 
    var swatches = $('table.jqplot-table-legend tr td.jqplot-table-legend-swatch'); 
    var labels = $('table.jqplot-table-legend tr td.jqplot-table-legend-label'); 
    labels.each(function(index) { 
     //turn the label's text color to the swatch's color 
     var color = $(swatches[index]).find("div div").css('background-color'); 
     $(this).css('color',color); 
    }); 
}); 

You could see the code running live here.

+0

非常に素晴らしいです。ありがとう! – xiaohan2012

関連する問題