highcharts / highcharts-vue

Other
686 stars 150 forks source link

Solid-Gauge Uncaught TypeError Loading Module #204

Closed gmalafsky closed 2 years ago

gmalafsky commented 2 years ago

Importing module into a Vue component causes Uncaught TypeError when running preventing App from loading.

import Highcharts from 'highcharts';
import HCExportingInit from 'highcharts/modules/exporting';
import HCOffline from 'highcharts/modules/offline-exporting';
import HCExportData from 'highcharts/modules/export-data';
import HCSolidGauge from 'highcharts/modules/solid-gauge';

HCExportingInit(Highcharts);
HCOffline(Highcharts);
HCExportData(Highcharts);
HCSolidGauge(Highcharts);

In browser (Chrome Version 97.0.4692.99 (Official Build) (64-bit) ):

Uncaught TypeError: Object prototype may only be an Object or null: undefined
    at setPrototypeOf (<anonymous>)
    at a (solid-gauge.js:14:182)
    at solid-gauge.js:14:250
    at solid-gauge.js:15:176
    at solid-gauge.js:18:196
    at f (solid-gauge.js:10:355)
    at solid-gauge.js:13:299
    at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/pages/Sources.vue?vue&type=script&lang=js& (Sources.vue:686:1)
    at __webpack_require__ (bootstrap:848:1)
    at fn (bootstrap:150:1)

Note solid gauge worked fine in different web application not using Vue with loading via script statements in HTML page.

Commenting out SC lines allows App to run properly.

Denyllon commented 2 years ago

Hello @gmalafsky ,

Sorry for replying so late, but it looks you missed the highcharts-more module import and initialization. This module is required to load before using solid gauge.

Here is the demo: https://codesandbox.io/s/unruffled-sea-6ol6y

Kind regards!

gmalafsky commented 2 years ago

Thanks. You are correct and leaving out highcharts-more was an oversight. It works properly with following:

import Highcharts from 'highcharts';
import HCExportingInit from 'highcharts/modules/exporting';
import HCOffline from 'highcharts/modules/offline-exporting';
import HCExportData from 'highcharts/modules/export-data';
import HCMore from 'highcharts/highcharts-more'
import HCSolidGauge from 'highcharts/modules/solid-gauge';

HCExportingInit(Highcharts);
HCOffline(Highcharts);
HCExportData(Highcharts);
HCMore(Highcharts);
HCSolidGauge(Highcharts);