我期待在我的网页上使用highcharts-react-official库呈现一个highcharts漏斗图。然而,当我尝试这样做时,我得到了highchartsReact错误#17。从文档中看,我似乎还必须导入'highcharts/modules/funnel.js'。我相信这是非常简单的,但我有点迷失在如何在我的组件中做到这一点。下面是我正在使用的代码。配置在codepen编辑器中似乎工作正常
import { render } from 'react-dom';
import Highcharts from 'highcharts';
import HighchartsReact from 'highcharts-react-official';
import React, { Component } from 'react';
const funnelChartOptions = {
chart: {
type: 'funnel',
spacing: [10, 10, 15, 10]
},
backgroundColor: 'transparent',
title: {
text: 'Sales funnel'
},
funnel: {
showInLegend: true
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>',
shadow: true,
backgroundColor: 'rgba(22,50,92,1)',
borderColor: 'rgba(22,50,92,1)',
borderRadius: 2,
style: {
color: 'white'
}
},
plotOptions: {
series: {
dataLabels: {
enabled: false
},
center: ['40%', '50%'],
neckWidth: '30%',
neckHeight: '0%',
width: '50%'
}
},
legend:{
align: 'right',
verticalAlign: 'top',
floating: true,
layout: 'vertical',
x: 0,
y: 100,
margin: 1
},
series: [{
name: 'Unique users',
data: [
['Website visits', 15654],
['Downloads', 4064],
['Requested price list', 1987],
['Invoice sent', 976],
['Finalized', 846]
],
showInLegend: true
}]
};
export default class FunnelChart extends Component {
render(){
return(
<div>
<HighchartsReact
highcharts={Highcharts}
options={funnelChartOptions} />
</div>);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
2条答案
按热度按时间hrysbysz1#
wgeznvg72#
实际上我不得不做:
因为上面的评论给了我“找不到名字'ReactHighcharts'。你是说“海查特”吗ts(2552)”
但是我在这里发布的一个工作!