PrimeFaces Polararea图表 - 网格线颜色更改



我的应用程序中有一个p:polarAreaChart图表,我使用 PrimeFaces PrimeFaces-7.0.rc1与JSF2 。。

我想更改每个圆的线颜色(Gridline)。我尝试了以下代码,但根本没有起作用。

gridLines.setDisplay(true);
gridLines.setColor("rgb(255, 255, 255)");
gridLines.setLineWidth(10);
radialScales.setGridLines(gridLines);
options.setScales(radialScales);
polarAreaMode.setOptions(options);

请让我知道我在这里做错了什么?

看起来您可以轻松地做。请参阅此示例:https://www.chartjs.org/samples/latest/charts/polar-area.html

在该页面的视图源中使用" backgroundColor":

        var randomScalingFactor = function() {
            return Math.round(Math.random() * 100);
        };
        var chartColors = window.chartColors;
        var color = Chart.helpers.color;
        var config = {
            data: {
                datasets: [{
                    data: [
                        randomScalingFactor(),
                        randomScalingFactor(),
                        randomScalingFactor(),
                        randomScalingFactor(),
                        randomScalingFactor(),
                    ],
                    backgroundColor: [
                        color(chartColors.red).alpha(0.5).rgbString(),
                        color(chartColors.orange).alpha(0.5).rgbString(),
                        color(chartColors.yellow).alpha(0.5).rgbString(),
                        color(chartColors.green).alpha(0.5).rgbString(),
                        color(chartColors.blue).alpha(0.5).rgbString(),
                    ],
                    label: 'My dataset' // for legend
                }],
                labels: [
                    'Red',
                    'Orange',
                    'Yellow',
                    'Green',
                    'Blue'
                ]
            },
            options: {
                responsive: true,
                legend: {
                    position: 'right',
                },
                title: {
                    display: true,
                    text: 'Chart.js Polar Area Chart'
                },
                scale: {
                    ticks: {
                        beginAtZero: true
                    },
                    reverse: false
                },
                animation: {
                    animateRotate: false,
                    animateScale: true
                }
            }
        };

查看PolarareachArt的PrimeFaces源代码,我看到BackgroundColor列出了RGB字符串的字符串列表。

public class PolarAreaChartDataSet extends ChartDataSet {
    private static final long serialVersionUID = 1L;
    private List<Number> data;
    private List<String> backgroundColor;
    private List<String> borderColor;
    private List<Number> borderWidth;
    private List<String> hoverBackgroundColor;
    private List<String> hoverBorderColor;
    private List<Number> hoverBorderWidth;

最新更新