Angular使用echarts
安装
npm install echarts --save
npm install @types/echarts --save
基本使用
定义一个dom
<div id="chart" style="min-width: 1500px;min-height:800px;"></div>
定义对象
//数据
eChartDatas: any;
//图例
legends:any;
//echart
echarts: any;
myChart: any;
获得echarts对象
// 基于准备好的dom,初始化echarts实例
this.echarts = require('echarts');
//只能初始化一次:https://www.echartsjs.com/api.html#echarts.init
if (this.myChart == null || this.myChart == undefined) {
this.myChart = this.echarts.init(document.getElementById('chart') as HTMLDivElement);
}
多折线图生成
效果如图
//绘制chart
// 指定图表的配置项和数据
var option = {
//标题
title: {
text: '监测数据统计图',
// left: 'center'
},
//图例
legend: {
data: this.legends
},
tooltip: {
trigger: 'axis',
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
xAxis: {
type: 'time',
splitLine: {
show: false
}
},
yAxis: {
type: 'value',
splitLine: {
show: false
}
},
series: []
};
//循环录入数据
this.eChartDatas.forEach(dataList => {
option.series.push({
name: dataList[0].tip,
type: 'line',
showSymbol: false,
hoverAnimation: false,
data: dataList
});
});
// 使用刚指定的配置项和数据显示图表。
this.myChart.clear();
this.myChart.setOption(option);
示例代码
参考资料
Is it possible to use ECharts Baidu with Angular 2 and TypeScript
Ionic2系列——在Ionic2中使用ECharts
echarts demo
echarts 多折线demo
Angular使用echarts的更多相关文章
- angular使用echarts折线图
echarts是开源的画图工具,在angular框架中引入echarts不能直接使用.需要新建一个directive //echarts基本参数 app.factory('$echartsConfig ...
- 使用angular封装echarts
Echarts是一个开源的图表组件,图表比较丰富,工作中需要用到它来搭建一个数据展示系统.但是系统原有的框架是基于angular的,而echarts是基于原生js的,如果直接使用的话就丢失了angul ...
- Angular+ionic2+Echarts 实现图形制作,以饼图为例
step1:添加插件echart; npm install echarts --save package.json文件中会在dependencies中添加echarts,如下图: step2:运行cm ...
- angular引用echarts插件
方法一 1. 命令行下载 npm install echarts --savenpm install ngx-echarts --save 2. angular.json 配置echarts路径. 2 ...
- angular结合echarts创建图表
原理: 利用angularjs中的指令(directive)将echarts封装. 步骤: 1.封装函数: app.directive('line', function() { return { re ...
- angular 实现 echarts 拖动区域进行放大 方法
实现逻辑: 1.通过鼠标摁下事件 和弹出事件 获取x轴的index 之后去x轴的list中去获取两个坐标点 2.之后将这两个数据作为参数 传到后台更新数据 3.记录下来这两个坐标点 放到lis ...
- angular把echarts封装为指令(配合requirejs)
1.在require中配置echartsjs文件 2.在directives下定义指令(定义为全局的指令,任何页面调用都可以) define(['app','echarts'],function(ap ...
- Angular 项目中如何使用 ECharts
在有些使用 ECharts 库的 Angular 项目中,通常除了安装 npm 包之外,还会在 angular.json 中配置 “build.options.scripts”,将 “node_mod ...
- angular的中文文档在这里。。
链接 仿ant-design的 angular组件 echarts文档
随机推荐
- 【36.86%】【codeforces 558B】Amr and The Large Array
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- ios开发缓存处理类NSCash类的了解与使用
一:NSCash的基本了解 #import "ViewController.h" @interface ViewController ()<NSCacheDelegate&g ...
- Hadoop配置文件 分类: A1_HADOOP 2014-08-19 12:48 1157人阅读 评论(1) 收藏
部分内容参考:http://www.linuxqq.net/archives/964.html http://slaytanic.blog.51cto.com/2057708/1100974/ ha ...
- 百度富文本编辑器ueditor使用启示
百度富文本编辑器ueditor使用启示 一.总结 一句话总结:使用工具,多去看官方demo,非常详细. 二.百度富文本编辑器ueditor使用启示 官方完整demo 官方完整demo对应的源代码 &l ...
- poj 2689 Prime Distance(大区间筛素数)
http://poj.org/problem?id=2689 题意:给出一个大区间[L,U],分别求出该区间内连续的相差最小和相差最大的素数对. 由于L<U<=2147483647,直接筛 ...
- [CSS] Get up and running with CSS Grid Layout
We’ll discuss the display values pertinent to CSS Grid Layout – grid, inline-grid, and subgrid. Then ...
- Struts2之配置使用
重要声明:此次学习struts2使用的版本号为:struts-2.3.15.3.假设是用的其它版本号出现的问题能够联系我. 一. 1.首先就是打开myeclipse创建project名为:struts ...
- 单个和多个checkbox选中事件怎么写
单个和多个checkbox选中事件怎么写 一.总结 一句话总结: 1.checkbox的事件方法的话主要是change和click 2.checkbox的属性判断的话主要是prop(判断checked ...
- hdfs的基本原理和基本操作总结
hdfs基本原理 Hadoop分布式文件系统(HDFS)被设计成适合执行在通用硬件(commodity hardware)上的分布式文件系统.它和现有的分布式文件系统有非常多共同点. 但同一时候,它和 ...
- Graphics processing architecture employing a unified shader
FIELD OF THE INVENTION The present invention generally relates to graphics processors and, more part ...