javascript 如何更改 jqPlot 数据点标签上的颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7026846/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
howto change color on jqPlot datapoint labels
提问by The Bndr
I have a graph generated by jqPlot
.
Data Point Labels are used the show additional information on the graph, like in this example: http://www.jqplot.com/tests/point-labels.php
我有一个由jqPlot
. 数据点标签用于在图形上显示附加信息,如本例所示:http: //www.jqplot.com/tests/point-labels.php
As you can see, the color of the data point labels is always black. But I would like to change the color of the data point labels to the same color as the graph is (by the way: I don't talk about the legend or the tick-label).
如您所见,数据点标签的颜色始终为黑色。但我想将数据点标签的颜色更改为与图表相同的颜色(顺便说一句:我不谈论图例或刻度标签)。
Searching trough the options page (http://www.jqplot.com/docs/files/jqPlotOptions-txt.html) I found no option to change this color.
通过选项页面 ( http://www.jqplot.com/docs/files/jqPlotOptions-txt.html)搜索,我发现没有更改此颜色的选项。
So the question is: Is there a (other) way to change the color of the data point labels?
所以问题是:是否有(其他)方法可以更改数据点标签的颜色?
Thank you.
谢谢你。
回答by dakdad
回答by slypete
In addition to the .jqplot-series-$i
class, reading the source reveals that the .jqplot-data-label
class is also applied to these label items.
除了.jqplot-series-$i
类之外,阅读来源发现.jqplot-data-label
类也适用于这些标签项。
回答by mino
You can do this without CSS.
你可以在没有 CSS 的情况下做到这一点。
for series set
对于系列集
pointLabels:{
show:true,
escapeHTML:false
}
and
和
var label = '<span style="color:red">MyLabel</span>';
var seriesData = [[1,2,label], [3,4,label]];
Of course you can add a span in JavaScript loop.
当然,您可以在 JavaScript 循环中添加一个跨度。
回答by Baig
I was using a donut chat and this is how i changed the target and label color
我正在使用甜甜圈聊天,这就是我更改目标和标签颜色的方式
.jqplot-target{
color: #ffffff !important ;
}
.jqplot-table-legend{
color: #666666 !important ;
}