MCPcopy Create free account
hub / github.com/Rello/analytics / newLegendClickHandler

Function newLegendClickHandler

js/visualization.js:1743–1779  ·  view source on GitHub ↗
(e, legendItem, legend)

Source from the content-addressed store, hash-verified

1741 const defaultLegendClickHandler = Chart.defaults.plugins.legend.onClick;
1742 const pieDoughnutLegendClickHandler = Chart.controllers.doughnut.overrides.plugins.legend.onClick;
1743 const newLegendClickHandler = function (e, legendItem, legend) {
1744 if (legendItem.analyticsDatasetIndexes) {
1745 OCA.Analytics.Visualization.toggleGroupedLegend(legendItem, legend.chart);
1746 OCA.Analytics.Filter.syncChartLegendSelections();
1747 return;
1748 }
1749 const index = legendItem.datasetIndex;
1750 const type = legend.chart.config.type;
1751
1752 OCA.Analytics.unsavedChanges = true;
1753 OCA.Analytics.Filter.toggleSaveButtonDisplay();
1754
1755 if (index === -1) {
1756 if (type === 'doughnut') {
1757 for (let dataIndex = 0; dataIndex < legend.chart.data.labels.length; dataIndex++) {
1758 if (!legend.chart.getDataVisibility(dataIndex)) {
1759 legend.chart.toggleDataVisibility(dataIndex);
1760 }
1761 }
1762 } else {
1763 for (let datasetIndex = 0; datasetIndex < legend.chart.data.datasets.length; datasetIndex++) {
1764 legend.chart.setDatasetVisibility(datasetIndex, true);
1765 }
1766 }
1767 legend.chart.update();
1768 OCA.Analytics.Filter.syncChartLegendSelections();
1769 return;
1770 }
1771
1772 // Do the original logic
1773 if (type === 'pie' || type === 'doughnut') {
1774 pieDoughnutLegendClickHandler(e, legendItem, legend)
1775 } else {
1776 defaultLegendClickHandler(e, legendItem, legend);
1777 }
1778 OCA.Analytics.Filter.syncChartLegendSelections();
1779 };
1780
1781 const defaultGenerateLabels = Chart.defaults.plugins.legend.labels.generateLabels;
1782 const customGenerateLabels = function (chart) {

Callers

nothing calls this directly

Calls 4

getDataVisibilityMethod · 0.80
toggleDataVisibilityMethod · 0.80
setDatasetVisibilityMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected