Jan Ivar priority asked 2 years ago


Expected behavior Be able to get information on clicked bar chart to show more details Actual behavior nothing happens on click, get error in edge console Uncaught TypeError: myChart.getElementsAtEvent is not a function Resources (screenshots, code snippets etc.)

var myChart = new mdb.Chart(canvas, { type: 'bar', data: { labels: aDaysList, datasets: [{ label: 'Antall innlogginer', data: aData, backgroundColor: aBackgroundColor, borderColor: aBorderColor, borderWidth: 1 }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero:true, steps: 10, stepValue: 5, max: iMaxLogin
} }] } } });

    canvas.addEventListener("click", function(evt) {
        var activePoints = myChart.getElementsAtEvent(evt);
        if (activePoints[0]) {
            var chartData = activePoints[0]['_chart'].config.data;
            var idx = activePoints[0]['_index'];

            var label = chartData.labels[idx];
            var value = chartData.datasets[0].data[idx];
            var color = chartData.datasets[0].backgroundColor[idx];

Jan Ivar priority commented 2 years ago

And canvas in instanciated further up.


Kamila Pieńkowska staff commented 2 years ago

Can you create a snippet to recreate this error?



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Opened

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 4.2.0
  • Device: Laptop
  • Browser: Edge
  • OS: Windows
  • Provided sample code: No
  • Provided link: No