Calling highcharts libraries from custom block

Created on 29 March 2021, about 4 years ago
Updated 7 April 2025, 24 days ago

I have a page that displays multiple charts using highcharts, some originating from views, some from charts blocks/fields, and some that use a manual implementation of highcharts in a custom block (code below).

When the custom block is included on a page with other charts from views or charts blocks/fields, only the custom block works and console gives highcharts error #16: https://www.highcharts.com/errors/16/

How can I successfully display highcharts charts from both the drupal charts module and my custom block on the same page?

<script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/modules/data.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/modules/exporting.js"></script>
<script type="text/javascript" src="https://code.highcharts.com/modules/export-data.js"></script>

<div id="chart-container" class="highcharts-container" style="width:100%; height:400px;"></div>
<script>
Highcharts.chart('chart-container', {
    chart: {
        type: 'column'
    },
    data: {
        csvURL: "https://www.mysite.com/sites/default/files/datafiles/testing.csv"
    },
    title: {
        text: 'Fruit Consumption'
    },
    yAxis: {
        title: {
            text: 'Units'
        }
    },
    credits: {
    enabled: false
  }
});
</script>
πŸ’¬ Support request
Status

Active

Version

5.0

Component

Highcharts integration

Created by

πŸ‡ΊπŸ‡ΈUnited States playful

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024