替代高图-更多

时间:2018-07-20 12:19:57

标签: highcharts react-highcharts

根据npm,highcharts-more.js已弃用,我们只需要从highcharts文件夹中导入相应的模块。但是,当我尝试删除高图表更多的依赖项时,我得到了error。我们正在尝试使用react-highcharts v16.0.2构建箱形图。

我什至尝试从他们的演示中删除highcharts-more.js导入,并看到它失败。

我在实现方面缺少任何内容吗?

2 个答案:

答案 0 :(得分:2)

将所需依赖项导入为

import ReactHighchart from 'react-highcharts';
import HighchartMore from 'highcharts/highcharts-more';
HighchartMore(ReactHighchart.Highcharts);

StackBlitz演示

没有不推荐的依赖项

答案 1 :(得分:0)

尝试用highcharts-react-official代替react-highcharts

import React from "react";
import { render } from "react-dom";
// Import Highcharts
import Highcharts from "highcharts";
import HighchartSankey from "highcharts/modules/sankey";
import HighchartsWheel from "highcharts/modules/dependency-wheel";
import HighchartsReact from "highcharts-react-official";

HighchartSankey(Highcharts);
HighchartsWheel(Highcharts);

const Viz = () => {
  return (
    <HighchartsReact
      highcharts={Highcharts}
      options={{
        series: [{
          type: "dependencywheel",
          data: [{
            from: "Category1",
            to: "Category2",
            weight: 2
          }, {
            from: "Category1",
            to: "Category3",
            weight: 5
          }]
        }]
      }}
    />
  );
};

render(<Viz />, document.getElementById("root"));