1
我是jQuery flot插件的新手,我想根據分數設置每個酒吧的顏色。根據分數設置jQuery flot酒吧顏色
對於得分的 「我」 欄:
- 0 - 20:紅色
- 20 - 70:黃色
- 70 - 100:綠色
對於得分「你」吧:
- 0 - 20:藍色
- 20 - 70:黑
- 70 - 100:橙
代碼段:
$.plot(
$("#placeholder"),[{
data: [[1, 81], [3.5, 33]],
label: 'Myself',
bars: {
show: true,
barWidth: 1,
lineWidth: 0,
fill: true,
fillColor: {
colors: [{brightness: 1}, {brightness: 0.5}],
horizontal: true
},
align: "center"
}
},{
data: [[2, 18], [4.5, 75]],
label: 'You',
color: 'red',
bars: {
show: true,
barWidth: 1,
lineWidth: 0,
fill: true,
fillColor: {
colors: [{brightness: 1}, {brightness: 0.5}],
horizontal: true
},
align: "center"
}
}],{
xaxis: {
ticks: [[1.5, '1st half'], [4, '2nd half']],
min: 0,
max: 5.5,
tickLength: 0
},
yaxis: {tickLength: 0},
grid: {
backgroundColor: "#ffffff",
borderWidth: 0,
markings: [{xaxis: {from: 0, to: 0}, color: "#909090"}, {yaxis: {from: 0, to: 0}, color: "#909090"}]
},
legend: {backgroundOpacity: 0.6, position: 'ne', margin: [-10, 0]},
valueLabels: {show: true, truncateValue: 2}
});
甲上面的代碼的jsfiddle是here。我非常感謝你的幫助。
我試圖修復該鏈接的格式,它不會讓你添加一個工作的jsfiddle鏈接沒有一些代碼,所以我補充說。盡我所能縮小它... – Xiaofu