Empty statistics and JS console errors

Created on 6 November 2024, 6 months ago

Problem/Motivation

I tested the module on simplytest.me with core 10.3.6
I created an Image type Advertisment and placed to content region as SimpleAds block. After clicking on the advertisment the "All Time", "Last 30 days" and "Last week" charts on the /admin/content/simpleads/1 are empty and there are some JS errors in console:
Invalid scale configuration for scale: xAxes
Invalid scale configuration for scale: yAxes

Steps to reproduce

1. start a test on simplytest.me with core 10.3.6 and Simpleads 2.0.11
2. create an Image type Advertisment on /admin/content/simpleads/add page
3. place the SimpleAds anywhere
4. click on the image of the advertisment
5. go to /admin/content/simpleads/1

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇭🇺Hungary fox mulder

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @fox mulder
  • 🇮🇳India dineshkumarbollu

    Hi @fox mulder

    I Tested the issue in Simpletest.me, i am not getting any error related to JS.

  • 🇩🇰Denmark Steven Snedker

    I had the error. I corrected it.

    In /simpleads/js/simpleads.charts.js

    It says

    function getLineChartOptions(xAxesLabel, yAxesLabel) {
        return {
          type: 'line',
          data: {
            labels: [],
            datasets: []
          },
          options: {
            responsive: true,
            tooltips: {
              mode: 'index',
              intersect: false,
            },
            hover: {
              mode: 'nearest',
              intersect: true
            },
            scales: {
              xAxes: [{
                display: true,
                scaleLabel: {
                  display: true,
                  labelString: xAxesLabel
                }
              }],
              yAxes: [{
                display: true,
                scaleLabel: {
                  display: true,
                  labelString: yAxesLabel
                }
              }]
            }
          }
        };
      };

    Guided by the Chart-js 3.x migration docs, I changed it to

    function getLineChartOptions(xAxesLabel, yAxesLabel) {
        return {
            type: 'line',
            data: {
                labels: [],
                datasets: []
            },
            options: {
                responsive: true,
                plugins: {
                    tooltip: {
                        mode: 'index',
                        intersect: false
                    }
                },
                hover: {
                    mode: 'nearest',
                    intersect: true
                },
                scales: {
                    x: {
                        display: true,
                        title: {
                            display: true,
                            text: xAxesLabel
                        }
                    },
                    y: {
                        display: true,
                        title: {
                            display: true,
                            text: yAxesLabel
                        }
                    }
                }
            }
        };
    }
    

    and it worked.

    It should probably be further updated, but doing this, I got rid of the js errors.

Production build 0.71.5 2024