From f47569ed891acc25ac252ec19438c8984f2b563d Mon Sep 17 00:00:00 2001 From: Jim Brandt Date: Wed, 4 Dec 2024 10:54:27 -0500 Subject: [PATCH] Update RT code for Chart.js API changes Most of the big changes were in version 3, noted in the migration guide. https://www.chartjs.org/docs/latest/migration/v3-migration.html --- share/html/Search/JSChart | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/share/html/Search/JSChart b/share/html/Search/JSChart index b9a02e7e77e..3c44b525554 100644 --- a/share/html/Search/JSChart +++ b/share/html/Search/JSChart @@ -122,23 +122,23 @@ var searchChart = new Chart(ctx, { } }, scales: { - xAxes: [{ + x: { stacked: <% $stacked ? 'true' : 'false' %>, - scaleLabel: { + title: { display: true, labelString: <% join(' - ', map $report->Label( $_), @{ $columns{'Groups'} }) |n,j %> }, - gridLines: { + grid: { display: false } - }], - yAxes: [{ + }, + y: { stacked: <% $stacked ? 'true' : 'false' %>, - scaleLabel: { + title: { display: true, labelString: <% $report->Label( $columns{'Functions'}[0] ) |n,j %> }, - gridLines: { + grid: { drawTicks: true, drawOnChartArea: false }, @@ -155,7 +155,7 @@ var searchChart = new Chart(ctx, { % } } } - }] + } } % } } @@ -165,17 +165,17 @@ var group_by = <% JSON( \@GroupBy ) |n %>; var data_queries = <% JSON( \@data_queries ) |n %>; jQuery('[id="<% $id |n %>"]').click(function(e) { - var slice = searchChart.getElementAtEvent(e); - if ( !slice[0] ) return; + let slice = searchChart.getElementsAtEventForMode(e, 'nearest', { intersect: true }, true); + if ( !slice[0] ) return; var query; % if ( $stacked ) { # data_queries is array of array for stacked charts - if ( data_queries[slice[0]._datasetIndex][slice[0]._index] ) { - query = data_queries[slice[0]._datasetIndex][slice[0]._index]; + if ( data_queries[slice[0].datasetIndex][slice[0].index] ) { + query = data_queries[slice[0].datasetIndex][slice[0].index]; } % } else { - if ( data_queries[slice[0]._index] ) { - query = data_queries[slice[0]._index]; + if ( data_queries[slice[0].index] ) { + query = data_queries[slice[0].index]; } % } window.open(RT.Config.WebPath + '/Search/Results.html?' + query);