(chart)
| 1780 | |
| 1781 | const defaultGenerateLabels = Chart.defaults.plugins.legend.labels.generateLabels; |
| 1782 | const customGenerateLabels = function (chart) { |
| 1783 | let labels; |
| 1784 | |
| 1785 | // Chart.js does not generate category labels for doughnuts when only |
| 1786 | // a single dataset without label is present. Build them manually. |
| 1787 | if (chart.config.type === 'doughnut') { |
| 1788 | const data = chart.data; |
| 1789 | const dataset = data.datasets[0] || {}; |
| 1790 | const colors = dataset.backgroundColor || []; |
| 1791 | labels = data.labels.map((label, index) => ({ |
| 1792 | text: label, |
| 1793 | fillStyle: colors[index], |
| 1794 | strokeStyle: colors[index], |
| 1795 | hidden: !chart.getDataVisibility(index), |
| 1796 | datasetIndex: 0, |
| 1797 | index: index |
| 1798 | })); |
| 1799 | } else { |
| 1800 | labels = OCA.Analytics.Visualization.getGroupedChartLegend(chart) || defaultGenerateLabels(chart); |
| 1801 | } |
| 1802 | |
| 1803 | const showAllNeeded = labels.length > 4 && labels.some(label => label.hidden); |
| 1804 | if (showAllNeeded) { |
| 1805 | labels.push({ |
| 1806 | text: t('analytics', 'Show all'), |
| 1807 | fillStyle: 'transparent', |
| 1808 | strokeStyle: 'transparent', |
| 1809 | hidden: false, |
| 1810 | datasetIndex: -1 |
| 1811 | }); |
| 1812 | } |
| 1813 | return labels; |
| 1814 | }; |
| 1815 | |
| 1816 | this.showElement('tableSeparatorContainer'); |
| 1817 | this.showElement('chartContainer'); |
nothing calls this directly
no test coverage detected