1. 将Y周设置为百分比 %

  1. yAxis: {
  2. axisLabel: {
  3. show: true,
  4. interval: 'auto',
  5. formatter: '{value} %'
  6. },
  7. },

2. 将折线图的提示值设置为百分比

  1. series:[{
  2. type: 'line',
  3. label:{
  4. formatter:'{c} %'
  5. }
  6. }]

3. 线图下载

  1. // 直接保存图片
  2. option:{
  3. toolbox: {
  4. show: true,
  5. feature: {
  6. dataZoom: { // 区域缩放
  7. yAxisIndex: 'none'
  8. },
  9. dataView: {readOnly: false}, // 查看数据
  10. magicType: {type: ['line', 'bar']}, // 图形切换
  11. restore: {}, //刷新
  12. saveAsImage: {} //保存图片
  13. }
  14. },
  15. }
  16. //将图转为base64——JS写法
  17. var myChart = echarts.init(document.getElementById(element));
  18. myChart.setOption(option);
  19. var myChartPic = myChart.getDataURL({
  20. pixelRatio: 2,
  21. backgroundColor: '#fff'
  22. })

4 待整理

echarts
1. 修改坐标轴颜色
aAxis:{
axisLine:{
lineStyle:{
color:’#fff’
}
}
}
2. 修改柱图颜色
series:[
{
color:’’, //图实体颜色
backgroundStyle:{
color:’’, // 图背景色
}
}
]
3. 修改坐标轴字体大小
aAxis:{
axisLabel:{
fontSize:18
}
}
4. 设置柱状图每一条的宽度
series:{
barWidth:10
}
5. canvas的背景大小会影响位置,通过绝对定位确认位置
option={this.getOption()}
style={{position:’absolute’,top:-1,left:-1}}
/>
6. 给饼图设置颜色
series: [
{
type: ‘pie’,

data: [
{value: 335, name: ‘直接访问’,itemStyle:{normal:{color:’#FE0000’}}},
{value: 310, name: ‘邮件营销’,itemStyle:{normal:{color:’#F29700’}}},
{value: 234, name: ‘联盟广告’,itemStyle:{normal:{color:’#F29700’}}},
]
}
]
7. 设置行线(分隔线)样式
yAxis:{
splitLine:{
lineStyle:{
type:’dashed’,
}
},
}