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

Function newLegendClickHandler

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

Source from the content-addressed store, hash-verified

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