1
jQuery flot 플러그인을 처음 사용하고 있으며 점수에 따라 각 막대의 색상을 설정하고 싶습니다. 빨간색 점수에 따라 jQuery flot 막대 색상을 설정하십시오.
점수 용 - 20
- 0 : "나 자신"바의 점수 "You"표시 줄 :
- 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