Chart (one per view row) only rendering first row when identical record is shown multiple times

Created on 30 September 2023, over 1 year ago

Problem/Motivation

Uncaught Error: Canvas is already in use. Chart with ID '0' must be destroyed before the canvas can be reused.

There seems to be no difference whether BigPipe is used or not. I still posted both the results. Maybe it provides information.

Not using BigPipe:

Uncaught Error: Canvas is already in use. Chart with ID '0' must be destroyed before the canvas can be reused.
    Chart https://unpkg.com/chart.js@3.7.1/dist/chart.js:6619
    attach https://mysite/modules/contrib/charts/modules/charts_chartjs/js/charts_chartjs.js?v=1.x:34
    attach https://mysite/modules/contrib/charts/modules/charts_chartjs/js/charts_chartjs.js?v=1.x:21
    attachBehaviors https://mysite/core/misc/drupal.js?v=10.1.4:166
    attachBehaviors https://mysite/core/misc/drupal.js?v=10.1.4:162
    <anonymous> https://mysite/core/misc/drupal.init.js?v=10.1.4:32
    listener https://mysite/core/misc/drupal.init.js?v=10.1.4:20
    domReady https://mysite/core/misc/drupal.init.js?v=10.1.4:26
    <anonymous> https://mysite/core/misc/drupal.init.js?v=10.1.4:31
    <anonymous> https://mysite/core/misc/drupal.init.js?v=10.1.4:34
chart.js:6619:13
    Chart https://unpkg.com/chart.js@3.7.1/dist/chart.js:6619
    attach https://mysite/modules/contrib/charts/modules/charts_chartjs/js/charts_chartjs.js?v=1.x:34
    forEach self-hosted:203
    attach https://mysite/modules/contrib/charts/modules/charts_chartjs/js/charts_chartjs.js?v=1.x:21
    attachBehaviors https://mysite/core/misc/drupal.js?v=10.1.4:166
    forEach self-hosted:203
    attachBehaviors https://mysite/core/misc/drupal.js?v=10.1.4:162
    <anonymous> https://mysite/core/misc/drupal.init.js?v=10.1.4:32
    listener https://mysite/core/misc/drupal.init.js?v=10.1.4:20
    (Async: EventListener.handleEvent)
    domReady https://mysite/core/misc/drupal.init.js?v=10.1.4:26
    <anonymous> https://mysite/core/misc/drupal.init.js?v=10.1.4:31
    <anonymous> https://mysite/core/misc/drupal.init.js?v=10.1.4:34

With BigPipe:

Uncaught Error: Canvas is already in use. Chart with ID '0' must be destroyed before the canvas can be reused.
    Chart https://unpkg.com/chart.js@3.7.1/dist/chart.js:6619
    attach https://mysite/modules/contrib/charts/modules/charts_chartjs/js/charts_chartjs.js?v=1.x:34
    attach https://mysite/modules/contrib/charts/modules/charts_chartjs/js/charts_chartjs.js?v=1.x:21
    attachBehaviors https://mysite/core/misc/drupal.js?v=10.1.4:166
    attachBehaviors https://mysite/core/misc/drupal.js?v=10.1.4:162
    <anonymous> https://mysite/core/modules/big_pipe/js/big_pipe.js?v=10.1.4:118
    <anonymous> https://mysite/core/modules/big_pipe/js/big_pipe.js?v=10.1.4:138
chart.js:6619:13
    Chart https://unpkg.com/chart.js@3.7.1/dist/chart.js:6619
    attach https://mysite/modules/contrib/charts/modules/charts_chartjs/js/charts_chartjs.js?v=1.x:34
    forEach self-hosted:203
    attach https://mysite/modules/contrib/charts/modules/charts_chartjs/js/charts_chartjs.js?v=1.x:21
    attachBehaviors https://mysite/core/misc/drupal.js?v=10.1.4:166
    forEach self-hosted:203
    attachBehaviors https://mysite/core/misc/drupal.js?v=10.1.4:162
    <anonymous> https://mysite/core/modules/big_pipe/js/big_pipe.js?v=10.1.4:118
    <anonymous> https://mysite/core/modules/big_pipe/js/big_pipe.js?v=10.1.4:138

Steps to reproduce

I created a charts block view (s. screenshot) "C", attached it inside a viewfield β†’ "VF" on a content type.

Then I created a second view (block) "B" showing a list of nodes of that content type as table view with two fields: title and the previously created viewfield "VF" containing the chart.
Individually each node shows its' chart.
In views editor everything works. Each row has its' chart.

But: the view block B contains the same row multiple times. Causing the same chart to be displayed in multiple rows.
When I then put the outer view block B as view inside a new viewfield on another content type the above error occurs - only on duplicate rows. Otherwise it works.

chart.js is the only library that works in this scenario. I tried C3, billboard and google which all won't show anything at all.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

5.0

Component

Views integration

Created by

πŸ‡¦πŸ‡ΉAustria maxilein

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

Comments & Activities

Production build 0.71.5 2024