ECharts 官网示例调试如下:
同样的参数,写到react 组件中效果如下:
组件完整代码如下:
import React, { Component } from "react";
import * as echarts from 'echarts';
import styles from './main.scss';
export default class LineEcharts extends Component {
constructor(props) {
super(props);
this.state = {
loading: true,
}
this.myChart3 = null;
}
option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'value'
},
yAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu']
},
series: [
{
name: 'Direct',
type: 'bar',
stack: 'total',
label: {
show: true
},
emphasis: {
focus: 'series'
},
data: [320, 302, 301, 334],
itemStyle:{
borderRadius:[0,50,50,0],
},
},
{
name: 'Mail Ad',
type: 'bar',
stack: 'total',
label: {
show: true
},
emphasis: {
focus: 'series'
},
data: [120, 132, 101, 134],
itemStyle:{
borderRadius:[5,20,50,90],
},
},
{
name: 'Affiliate Ad',
type: 'bar',
stack: 'total',
label: {
show: true
},
emphasis: {
focus: 'series'
},
data: [220, 182, 191, 234]
},
]
};
componentDidMount() {
this.myChart3 = null;
this.refreshMyChar3()
}
refreshMyChar3 = () => {
let _this = this;
let chartDom = document.getElementById('lineEcharts3');
this.myChart3 = echarts.init(chartDom);
this.myChart3.showLoading({
text: '数据加载中',
zlevel: 99,
})
setTimeout(() => {
_this.myChart3.hideLoading();
_this.myChart3.setOption(this.option);
_this.myChart3.resize();
}, 100);
}
render() {
return (
<div className={styles.echartsbox}>
<div id="lineEcharts3"><div style={{ paddingTop: "70px", textAlign: 'center', fontSize:'14px'}}>数据加载中</div></div>
</div >
)
}
};
我现在不确定是不是因为版本造成的 项目中使用的 ECharts 版本是 4.9.0 ,但是没有查到 itemStyle.borderRadius 配置项是从什么版本引入的。。。
有没有有经验的大佬指导一下。。。帮忙给看看是那里的问题?
你项目
4
的版本,就是你搜索的字段barBorderRadius
,5
的版本是borderRadius
;而你用的是5
的配置字段,字段有调整,你更改一下