jqplot图表图例中的标签等元素可以通过css进行修改,即使jqplot插件本身不支持它也是如此。但是,由于jqPlot使用canvas绘制这些图表,因此x和y轴标签看起来有点棘手。我尝试使用jqpuery来抓取canvas元素并更改它的font属性,如下所示,但它没有产生任何结果。在剧情呈现之后,我正在这样做,我做错了吗?
// this gets the correct canvas element and even highlights on the page in debugger mode
var canvas = $('#Chart8Bar .jqplot-yaxis .jqplot-yaxis-tick').get(0);
// however when I call this getContext method, it no longer shows up highlighted in debugger mode but none the less comes back with the context element
var ctx = canvas.getContext("2d");
// this correctly sets the font and is reflected in the debugger but nothing happens on the page.
ctx.font = "italic 10px Courier";