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

Function newLegendClickHandler

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

Source from the content-addressed store, hash-verified

1483 const defaultLegendClickHandler = Chart.defaults.plugins.legend.onClick;
1484 const pieDoughnutLegendClickHandler = Chart.controllers.doughnut.overrides.plugins.legend.onClick;
1485 const newLegendClickHandler = function (e, legendItem, legend) {
1486 const index = legendItem.datasetIndex;
1487 const type = legend.chart.config.type;
1488
1489 OCA.Analytics.unsavedChanges = true;
1490 OCA.Analytics.Filter.toggleSaveButtonDisplay();
1491
1492 if (index === -1) {
1493 if (type === 'doughnut') {
1494 for (let dataIndex = 0; dataIndex < legend.chart.data.labels.length; dataIndex++) {
1495 if (!legend.chart.getDataVisibility(dataIndex)) {
1496 legend.chart.toggleDataVisibility(dataIndex);
1497 }
1498 }
1499 } else {
1500 for (let datasetIndex = 0; datasetIndex < legend.chart.data.datasets.length; datasetIndex++) {
1501 legend.chart.setDatasetVisibility(datasetIndex, true);
1502 }
1503 }
1504 legend.chart.update();
1505 OCA.Analytics.Filter.syncChartLegendSelections();
1506 return;
1507 }
1508
1509 // Do the original logic
1510 if (type === 'pie' || type === 'doughnut') {
1511 pieDoughnutLegendClickHandler(e, legendItem, legend)
1512 } else {
1513 defaultLegendClickHandler(e, legendItem, legend);
1514 }
1515 OCA.Analytics.Filter.syncChartLegendSelections();
1516 };
1517
1518 const defaultGenerateLabels = Chart.defaults.plugins.legend.labels.generateLabels;
1519 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