Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 雷达图上的梯度背景_Javascript_Css_Chart.js - Fatal编程技术网

Javascript 雷达图上的梯度背景

Javascript 雷达图上的梯度背景,javascript,css,chart.js,Javascript,Css,Chart.js,我有雷达图 我不知道如何在区域内设置径向梯度。 在放置当前代码时,默认情况下只使用1种颜色作为背景色 当前代码: let ctx = document.getElementById('chart-0').getContext("2d"); let gradient = ctx.createLinearGradient(0.000, 150.000, 300.000, 150.000); // Add colors gradient.addColorStop(0.035, 'rgba(234,

我有雷达图

我不知道如何在区域内设置径向梯度。 在放置当前代码时,默认情况下只使用1种颜色作为背景色

当前代码:

let ctx = document.getElementById('chart-0').getContext("2d");
let gradient = ctx.createLinearGradient(0.000, 150.000, 300.000, 150.000);

// Add colors
gradient.addColorStop(0.035, 'rgba(234, 25, 78, 1.000)');
gradient.addColorStop(0.225, 'rgba(0, 8, 249, 1.000)');
gradient.addColorStop(0.983, 'rgba(42, 255, 0, 1.000)');

let data = {
    backgroundColor: gradient,
    labels: labelData,
    datasets: [{
        borderColor: presets.red,
        data: [20,20,20,20,20],
        label: labeldata
    }]
};
const options = {
    maintainAspectRatio: true,
    spanGaps: false,
    scale: {
        pointLabels: {
            fontSize: 14
        }
    },
    elements: {
        line: {
            tension: 0.000001
        }
    },
    legend: {
        labels: {
            fontSize: 16
        }
    }
};

 chart = new Chart('chart-0', {
    type: 'radar',
    data: data,
    options: options
});

每个数据集还应包括具有指定渐变值的
backgroundColor
属性。我是根据您的代码创建的。

每个数据集还应该包括
backgroundColor
属性和指定的渐变值。我是根据您的代码创建的。

谢谢您的回答!但是,我正在尝试实现一个带有径向中心梯度的单一数据集,这可能吗?谢谢回答!但是,我正在尝试实现一个带有径向中心梯度的单一数据集,有可能吗?