首先要用安装highcharts-3d
npm i -S highcharts-3d
引入的时候要注意:
import highcharts3d from 'highcharts/highcharts-3d';
highcharts3d(ReactHighcharts.Highcharts);
完整代码:
import ReactHighcharts from 'react-highcharts';
import highcharts3d from 'highcharts/highcharts-3d';
highcharts3d(ReactHighcharts.Highcharts);
render() {
const {title } = this.props;
const config = {
chart: {
type: 'pie',
options3d: {
enabled: true,
alpha: 45,
beta: 0,
},
},
title: {
text: title,
},
colors: ['#629ef8', '#51d89d', '#a79ae7'],
},
series: [{
name: '用餐次数',
data: [
{name: '1', y: 400},
{name: '2', y: 1000},
{name: '3', y: 100},
],
}],
};
return <ReactHighcharts config={config} ref="chart" />;
}
网友评论