开发者

Flot: Subscript text in label

I have already asked this question in offical Flot google groups, but got no answear. Maybe because it is more javascript oriented, here is the question:

I have added the following code in my code:

var j = "d";
j = j.sub();

plot1 = $.plot($("#grafTemp"), [
{label: "Rosišče (°C): T" + j + "(t) = ---.---°C"

.... the rest does not matter.

And:

legends.eq(i).text(series.label.replace(/=.*/, "= " + y.toFixed(2)  +"°C"));

I was using this example: http://people.iola.dk/olau/flot/examples/tracking.html

Now, the subscript works ok, it displays T_d fine. But when I update the graph (when user moves mouse over graph), then it displays

<sub>d</sub>

I know that the problem is at the legends.eq(i).text....., where it returns pure string, with literal:

<sub>

I would like to know, how it would be possible to fix this issue. S开发者_如何学编程o it would use html element sub properly?


Glancing at the code, it looks like you'd replace the use of text (e.g., legends.eq(i).text(...)) with html (legends.eq(i).html(...)). But you'd need to be sure that there aren't other generated bits of it that would be a problem (for instance, if this stuff generated a string that had a < or & in it, that would need to be converted to &lt; / &amp; respectively before being fed into the html function).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜