• Chart.js legend labels type dash?

    @BarabanObivan Автор вопроса
    вот ответ

    labels: {
                        usePointStyle: true,
                        color: '#283d4a',
                        generateLabels: function (chart) {
                            let data = chart.data;
                            if (data.labels.length && data.datasets.length) {
                                let labels = [];
                                data.datasets.forEach(function (dataset, i) {
                                    if (dataset.label) {
                                        const lineDash =
                                            dataset.borderDash && dataset.borderDash.length > 0 ? dataset.borderDash : [];
                                        labels.push({
                                            text: dataset.label,
                                            color: dataset.borderColor,
                                            strokeStyle: dataset.borderColor,
                                            fillStyle: dataset.borderColor,
                                            lineDash: lineDash.length ? [3, 3] : [],
                                            hidden: !chart.isDatasetVisible(i),
                                            index: i,
                                            usePointStyle: true,
                                            pointStyle: 'line',
                                            pointStyleWidth: 40,
                                        });
                                    }
                                });
                                return labels;
                            }
                            return null;
                        },
                    },
    Ответ написан
    Комментировать