Kreporter 3.1 is no longer displaying Google Charts

I have the code to make this work for Kreporter 3.1.

Edit the file: modules/KReports/Plugins/Visualization/googlecharts/kGoogleCharts.php

Lines 24-31 (function getHeader()):
public function getHeader() {`
// STIC 14/05/2020: Update regarding the loading of the Google Graphic libraries
// $coreString = “”;
$coreString = “”;
return $coreString;
}
Lines 45-71 (function getItem()):
public function getItem($thisDivId, $thisReport, $thisParams, $addReportParams = array()) {

    $googleData = $this->getChartData($thisReport, $thisParams, 0, $addReportParams);
    $chartData = $this->wrapGoogleData($googleData, $thisDivId, $thisParams, 0 , $addReportParams);

    $chartDataString = '<script type="text/javascript">';

    // STIC 14/05/2020: Update regarding the loading of the Google Graphic libraries
    $chartDataString .= "google.charts.load('current'); ";
    $chartDataString .= "google.charts.setOnLoadCallback(drawVisualization); ";
    $chartDataString .= "function drawVisualization() { ";
    // STIC 14/05/2020: End of update

    $chartDataString .= $thisParams['uid'] . " = new Object({
            uid: '" . $thisParams['uid'] . "',
            chartWrapper: new google.visualization.ChartWrapper(" . json_encode($chartData) . "), 
            update: function(chartData){
                this.chartWrapper.setDataTable(chartData);
                this.chartWrapper.draw();
            }
            });
            document.addEventListener('load', " . $thisParams['uid'] . ".chartWrapper.draw());";
    $chartDataString .= "}"; // STIC Update 14/05/2020
    $chartDataString .= '</script>';

    return $chartDataString;
}

You can see the changes where STIC updates comments are.

@maretval could you please check my topic? Kreporter 3.1 and Security Groups filtering records

Thanks

1 Like