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

Function newLegendClickHandler

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

Source from the content-addressed store, hash-verified

1447 const defaultLegendClickHandler = Chart.defaults.plugins.legend.onClick;
1448 const pieDoughnutLegendClickHandler = Chart.controllers.doughnut.overrides.plugins.legend.onClick;
1449 const newLegendClickHandler = function (e, legendItem, legend) {
1450 const index = legendItem.datasetIndex;
1451 const type = legend.chart.config.type;
1452
1453 OCA.Analytics.unsavedChanges = true;
1454 OCA.Analytics.Filter.toggleSaveButtonDisplay();
1455
1456 if (index === -1) {
1457 if (type === 'doughnut') {
1458 for (let dataIndex = 0; dataIndex < legend.chart.data.labels.length; dataIndex++) {
1459 if (!legend.chart.getDataVisibility(dataIndex)) {
1460 legend.chart.toggleDataVisibility(dataIndex);
1461 }
1462 }
1463 } else {
1464 for (let datasetIndex = 0; datasetIndex < legend.chart.data.datasets.length; datasetIndex++) {
1465 legend.chart.setDatasetVisibility(datasetIndex, true);
1466 }
1467 }
1468 legend.chart.update();
1469 OCA.Analytics.Filter.syncChartLegendSelections();
1470 return;
1471 }
1472
1473 // Do the original logic
1474 if (type === 'pie' || type === 'doughnut') {
1475 pieDoughnutLegendClickHandler(e, legendItem, legend)
1476 } else {
1477 defaultLegendClickHandler(e, legendItem, legend);
1478 }
1479 OCA.Analytics.Filter.syncChartLegendSelections();
1480 };
1481
1482 const defaultGenerateLabels = Chart.defaults.plugins.legend.labels.generateLabels;
1483 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