在vue项目 使用echarts图表&&解决渲染图表文字模糊问题

通过 npm 安装 echarts

npm install echarts --save

引入使用

注意:使用svg渲染,解决渲染图表文字模糊问题

<template>
  <div class="dashboard-container">
    <div id="chartBox" style="width: 80%;height:50vh;"></div>
  </div>
</template>

<script>
import echarts from 'echarts' //引入
export default {
 name: 'Dashboard',
 mounted(){
  // this.lineChart = echarts.init(document.getElementById('chartBox'));
  //svg渲染,更清晰
this.lineChart= echarts.init(document.getElementById('chartBox'), null, {renderer: 'svg'});  
         // 指定图表的配置项和数据
  		var option = {
				color: ['rgb(85, 153, 254, 1)', 'rgb(68, 203, 187, 1)'],  //同组柱子的颜色
				legend: {},
				tooltip: {},
				dataset: {
					dimensions: ['product', '甲', '乙'],
					source: [{
							product: '2020-01-12',
							'甲': 43.3,
							'乙': 85.8,
						},
						{
							product: '2020-01-13',
							'甲': 83.1,
							'乙': 73.4,
						},
						{
							product: '2020-01-14',
							'甲': 86.4,
							'乙': 65.2,
						},
						{
							product: '2021-01-15',
							'甲': 72.4,
							'乙': 53.9,
						}
					]
				},
				xAxis: {
					type: 'category'
				},
				yAxis: {},
				series: [{
						type: 'bar',
						barWidth: 50, //柱子的宽度
						barGap: '0%',/*多个并排柱子设置柱子之间的间距*/
					},
					{
						type: 'bar',
						barWidth: 50,
					}
				]
			};
			// 使用刚指定的配置项和数据显示图表。
			this.lineChart.setOption(option);
		},
}
</script>

效果展示:
在这里插入图片描述

echarts官网

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值