angular6使用Echarts插件

本文详细介绍了如何在Angular6项目中集成Echarts图表插件。从安装Echarts开始,到在HTML文件中添加图表组件,再到CSS样式定义及TS文件中配置图表选项,一步步引导读者完成图表的展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

angular6使用Echarts插件
1、在angular6项目下,使用npm安装echarts
npm install echarts --save
安装查看angular.json文件,会出现引入了echart.min.js
在这里插入图片描述
2、在相应的html文件里面写

<div echarts [options]="chartOption" class="chartDom"></div>

3、在对应的css文件里定义echart图宽和高才能显现图表

.chartDom{
width:100px;
height:100px;
}

4、在对应ts文件里写配置即可

export class AccDashboardComponent implements OnInit {
  tmEchart = {};
ngOnInit() {
	  this.tmEchart = {
                tooltip: {
                    trigger: 'item',
                    formatter: "{b}: {c}"
                },
                calculable: false,
                series: [
                    {
                        name: '',
                        type: 'treemap',
                        breadcrumb: false,//是否显示面包屑
                        itemStyle: {
                            normal: {
                                label: {
                                    show: true,
                                    formatter: "{b}"
                                },
                                borderWidth: 1
                            },
                            emphasis: {
                                label: {
                                    show: true
                                }
                            }
                        },
                        data: [
                            {
                                name: 'Excess Stock',
                                value: res[1].TOTAL,
                                itemStyle: { normal: { color: '#00B0F0' } },
                                label: { normal: { color: "#000" } }
                            },
                            {
                                name: 'Obsolete Stock',
                                value: res[2].TOTAL,
                                itemStyle: { normal: { color: '#FFFF00' } },
                                label: { normal: { color: "#000" } }
                            },
                            {
                                name: 'Risk Stock',
                                value: res[3].TOTAL,
                                itemStyle: { normal: { color: '#E1140A' } },
                                label: { normal: { color: "#000" } }
                            },
                            {
                                name: 'Healthy Stock',
                                value: res[4].TOTAL,
                                itemStyle: { normal: { color: '#6AC346' } },
                                label: { normal: { color: "#000" } }
                            }
                        ]
                    }
                ]
            };

        })
}
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值