angular中echart的使用
2024-10-21 09:41:40
<div class="ringlike-chart" echarts [options]="options" (chartInit)="onChartInitOne($event)"></div>
// 初始化
public onChartInitOne(value: any): void {
this.qualityControlBar = value;
}
// 值更新的时候重新set
this.qualityControlBar.setOption(this.options, true);
public options = {
backgroundColor: '#fff',
title: { // 标题
text: '漏诊改善趋势',
padding: [5, 0, 12, 30],
textStyle: {
color: '#000000',
fontStyle: 'normal',
fontWeight: 500,
fontFamily: 'Source Han Sans CN',
fontSize: 16,
},
},
tooltip: { // 悬浮提示
trigger: 'axis',
formatter: (params: any) => {
return this.tooltipFormatter(params);
},
},
legend: { // 头部说明
icon: 'rect',
itemHeight: 2,
itemWidth: 16,
x: 'left',
y: 'top',
padding: [40, 0, 0, 30],
textStyle: {
fontSize: '12px',
},
data: []
},
grid: { // 图的布局
left: '3%',
right: '4%',
bottom: '10%',
top: '25%',
containLabel: true
},
toolbox: { // 是否显示下载
feature: {
saveAsImage: {
show: false
}
}
},
dataZoom: [{
type: 'slider',
show: true,
xAxisIndex: [0],
left: '9%',
bottom: 0,
start: 10,
end: 90, // 初始化滚动条
height: 14,
}],
xAxis: {
type: 'category',
boundaryGap: false,
data: [
]
},
yAxis: {
type: 'value',
min: 0, // 配置 Y 轴刻度最小值
max: 100, // 配置 Y 轴刻度最大值
splitNumber: 5, // 配置 Y 轴数值间隔
splitLine: {
show: true,
lineStyle: {
type: 'dashed',
},
},
axisLabel: {
formatter: (res) => {
if (res === 0) {
return 0;
}
return res + '%';
},
},
axisLine: { show: false },
axisTick: { show: false }
},
series: [
]
};
// 此处修改悬浮展示内容
public tooltipFormatter(params: any): string {
const arr = [];
if (params instanceof Array) {
const flag = params.every((item: any) => {
if (typeof item.data === 'undefined') {
return item;
}
});
if (flag) {
return '';
}
params.forEach((item: any) => {
const span = `<span style="width:10px;height:10px;display:inline-block;background:${item.color};margin-right:4px;border-radius:50%;"></span>`;
const value1 = item.value ? item.value + '%' : '0.00%';
const div1 = `<div style="text-align:right;margin-left:20px;">${value1}</div>`;
const div2 = `<div>${span}${item.seriesName}</div>`;
const div3 = `<div style="line-height:20px;display:flex;justify-content: space-between;min-width:200px;">${div2}${div1}</div>`;
const tmp: string = `${div3}`;
arr.push(tmp);
});
}
arr.unshift(`<div>${params[0].axisValueLabel}<div>`);
return arr.join('\n');
}
最新文章
- The Euler function[HDU2824]
- Eclipse Android环境搭建
- electrica writeup
- 【Spring】简单的Spring MVC入门例子
- Linux Free命令各数字含义及Buffer和Cache的区别
- js 模拟ajax方式提交数据
- C和设计原则
- 【加密】C#.NET 各种加密解密
- ∑–△型模数转换器(ADC)简介
- iOS中UITextField 使用全面解析
- 最简单的代码,CURL获取页面
- 剑指offer面试题14-调整数组顺序使奇数位于偶数前面
- SQL 2005/2008 连接SQL 2000报18456错误
- C语言之linux内核--BCD码转二进制与二进制转BCD码(笔试经典)
- windows8.1全角与半角切换快捷键
- 关于WCF服务 http://XXXXXX/XXX/xxx.svc不支持内容类型 application/sop+xml;charset=utf-8 错误解决方法
- 定时备份 MySQL 并上传到七牛
- Python全栈之路----编程基本情况介绍
- APR欺骗
- Series转化为DataFrame数据
热门文章
- python 定时发送邮件
- Hadoop详解(04-1) - 基于hadoop3.1.3配置Windows10本地开发运行环境
- 计算1+2!+3!+...+n!的和
- NET-Core利用etag进行浏览器缓存
- 前端必备基础知识之--------原生JS发送Ajax请求
- Java8Stream流
- 进阶技术:Linux Arm32是如何调用C Main的
- Codeforces Round #849 (Div. 4)
- BIO和NIO的基本用法和API讲解
- Vue 07 js方法Object.defineProperty