... : 266 그럼 그냥 사이의 난수를 생성 1-100 동적는 ...과 같이
//Home page Charts...
$(document).ready(function() {
var primary_hue = 266;
var doughnutData = [
{
value: 30,
color:"hsl("+primary_hue+","+(Math.round(Math.random() * 99) + 1)+"%,"+(Math.round(Math.random() * 99) + 1)+"%)",
label: "test",
},
{
value : 50,
color:"hsl("+primary_hue+","+(Math.round(Math.random() * 99) + 1)+"%,"+(Math.round(Math.random() * 99) + 1)+"%)",
label: "test",
},
{
value : 100,
color:"hsl("+primary_hue+","+(Math.round(Math.random() * 99) + 1)+"%,"+(Math.round(Math.random() * 99) + 1)+"%)",
label: "test",
},
{
value : 40,
color:"hsl("+primary_hue+","+(Math.round(Math.random() * 99) + 1)+"%,"+(Math.round(Math.random() * 99) + 1)+"%)",
label: "test",
},
{
value : 120,
color:"hsl("+primary_hue+","+(Math.round(Math.random() * 99) + 1)+"%,"+(Math.round(Math.random() * 99) + 1)+"%)",
label: "test",
},
];
var myDoughnut = new Chart(document.getElementById("best-lure-canvas").getContext("2d")).Doughnut(doughnutData);
});
사용 HSL을 숫자에서 HSV 문자열을 생성하고 L 매개 변수를 다양합니다. 일반적인 16 진수 디코드 및 인코딩 기능이 필요하며 HSL <-> RGB 변환 기능도 필요합니다. Google은 두 가지 모두를 제시해야합니다. – Alnitak
가능한 [Javascript에서 HSB/HSV 색상을 RGB로 정확하게 변환] (http://stackoverflow.com/questions/17242144/javascript-convert-hsb-hsv-color-to-rgb-accurately) – Blazemonger