首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用react-highcharts绘制钟形曲线

如何使用react-highcharts绘制钟形曲线
EN

Stack Overflow用户
提问于 2020-02-09 11:44:50
回答 2查看 1.1K关注 0票数 0

我正在使用react-highcharts来绘制条形图、圆环图和钟形曲线图。当其他图表正在绘制时,我无法使用react-highcharts绘制钟形曲线图。用于highcharts的React包是https://www.npmjs.com/package/react-highcharts

下面是我的实现:

代码语言:javascript
复制
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;

在运行上面的代码时,我得到的错误是:Cannot read property 'destroy' of undefined

对如何修复这个错误有什么建议吗?

EN

回答 2

Stack Overflow用户

发布于 2020-02-09 19:06:16

钟形曲线需要以下模块modules/histogram-bellcurve.js.here

您应该导入bellcurve

代码语言:javascript
复制
import bellcurve from 'highcharts/modules/histogram-bellcurve';
(bellcurve)(ReactHighCharts.Highcharts)

sample

票数 2
EN

Stack Overflow用户

发布于 2020-02-10 18:17:39

正如上面的答案所提到的,钟形曲线序列需要导入钟形曲线模块。

使用您的配置进行演示:https://codesandbox.io/s/highcharts-react-demo-15ojj

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60133284

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档