2

I want to be able to have, instead of 1 - 10 on the y axis have pictures instead, my example is smiley faces. A happy one for 10 and a sad one for 1.

Is there any way to set images as the ticks, has anyone managed this at all, or does anyone know how to use hooks or custom renderers to do this?

Thanks

Tom

4

1 に答える 1

2

軸の目盛りは、グラフのdiv内の単なるdivです。それらのコレクションを取得して、それらのHTMLを独自のものに置き換えることができます。たとえば、「smiley-XX.png」という名前の画像があり、XXが番号であるとすると、次のようになります。

var i = 0;
$('#id-of-jqplot-div').find('.jqplot-yaxis').find('div.jqplot-axis-tick').each(function(){
   $(this).html('<img src="smiley-'+i+'.png">');
   i++;
});
于 2011-09-17T14:09:17.493 に答える