0

I am using react-highcharts to plot bar charts,donut charts and bell curve chart. I am not able to plot bell curve chart using react-highcharts while other charts are being plotted. React package used for highcharts is https://www.npmjs.com/package/react-highcharts

Here is my implementation:

import React, { Component } from "react";
import ReactHighCharts from "react-highcharts";

    class BellCurve extends Component {
      constructor(props) {
        super(props);

        this.state = {
          config: {
            title: {
              text: null,
            },

            legend: {
              enabled: false,
            },

            xAxis: [
              {
                title: {
                  text: "Data",
                },
                visible: false,
              },
              {
                title: {
                  text: "Bell curve",
                },
                opposite: true,
                visible: false,
              },
            ],

            yAxis: [
              {
                title: {
                  text: "Data",
                },
                visible: false,
              },
              {
                title: {
                  text: "Bell curve",
                },
                opposite: true,
                visible: false,
              },
            ],

            series: [
              {
                name: "Bell curve",
                type: "bellcurve",
                xAxis: 1,
                yAxis: 1,

                intervals: 4,
                baseSeries: 1,
                zIndex: -1,
                marker: {
                  enabled: true,
                },
              },
              {
                name: "Data",
                type: "scatter",
                data: [
                  0.0,
                  0.0,
                  0.0,
                  1.32,
                  1.0,
                  0.74,
                  0.43,
                  0.48,
                  0.14,
                  -0.21,
                  -0.22,
                  -0.28,
                  0.06,
                  0.04,
                  0.13,
                  0.07,
                  0.07,
                  0.04,
                  -0.05,
                  0.2,
                  0.14,
                  -0.05,
                  -0.11,
                  -0.26,
                  -0.21,
                  -0.02,
                  0.29,
                  0.21,
                ],
                visible: false,
                marker: {
                  radius: 1.5,
                },
              },
            ],
          },
        };
      }

      render() {
        return <ReactHighCharts config={this.state.config} />;
      }
    }

    export default BellCurve;

On running the above code I get error as : Cannot read property 'destroy' of undefined

Any suggestion on how to fix this error?

Nishant_061
  • 87
  • 1
  • 7

2 Answers2

2

The bell curve requires the following module modules/histogram-bellcurve.js.here

You should import bellcurve

import bellcurve from 'highcharts/modules/histogram-bellcurve';
(bellcurve)(ReactHighCharts.Highcharts)

sample

Alex
  • 3,941
  • 1
  • 17
  • 24
1

As it is mentioned in the above answer the bell curve series requires to import the bell-curve module.

Demo with your config: https://codesandbox.io/s/highcharts-react-demo-15ojj

Sebastian Wędzel
  • 11,417
  • 1
  • 6
  • 16