echarts柱状图线形图例子
2015-10-22 12:10
218 查看
<script type='text/javascript' src="http://echarts.baidu.com/build/dist/echarts.js"></script>
var myChartbar;
var myChartline;
//bar
require(['echarts','echarts/theme/macarons','echarts/chart/bar'], function (ec){
myChartbar = ec.init(document.getElementById('bar'),'macarons');
var option = {
//标题
title : {
text: '柱状图',
//字体 颜色 大小
textStyle: {fontWeight: 'normal',color: '#009999'},
subtext: ''
},
tooltip : {
trigger: 'axis'
},
//图例
legend: {
selectedMode:false,
//文字颜色
textStyle: {color: '#009999'},
data:['图例1', '图例2']
},
toolbox: {
show : true,
},
calculable : true,
//格子
grid:{borderWidth:0},
xAxis : [
{
type : 'category',
//不顶行显示
boundaryGap : true,
//X轴名称设置
name:'日期',
nameTextStyle:{color:'#009999'},
//X轴文字字体颜色设置
textStyle:{color:'#009999'},
axisLabel:{textStyle: {color:'#009999',fontSize: 8,},},
//不显示分行线
splitLine: {show: false},
//X轴数据
data : ['1','2','3','4','5']
}
],
yAxis : [
{
type : 'value',
//Y轴名称
name:'次',
nameTextStyle:{color:'#009999'},
//Y轴字体颜色大小
axisLabel:{textStyle: {color:'#009999',},},
splitLine: {show: false},
}
],
series : [
{
name:'图例1',
type:'bar',
stack: 'sum',
barCategoryGap: '30%',
//设置柱形图的颜色,文字颜色
itemStyle : { normal: {color: '#009999',label : {show: true, position: 'insideTop',textStyle: {color: '#cce8cf'}} }},
//Y轴数据
data:['23','1','20','13','14']
},
{
name:'图例2',
type:'bar',
stack: 'sum',
itemStyle: {
normal: {
color: '#00688B',}
},
//Y轴数据
data:['3','2','21','3','4']
}
]
};
//line
myChartbar.setOption(option);
});
require(['echarts','echarts/theme/macarons','echarts/chart/line'], function (ec){
myChartline = ec.init(document.getElementById('line'),'macarons');
var option1 = {
//线形图颜色(可以是多个)
color: ['#009999'],
//标题
title : {
text: '线形图',
textStyle: {fontWeight: 'normal',color: '#009999'},
//副标题
subtext: ''
},
tooltip : {
trigger: 'axis'
},
legend: {
textStyle: {color: '#009999'},
data:['图例']
},
toolbox: {
show : true,
},
calculable : true,
grid:{borderWidth:0},
xAxis : [
{
type : 'category',
//顶行显示
boundaryGap : false,
splitLine: {show: false},
data:['1','2','3','4','5']
}
],
yAxis : [
{
type : 'value',
splitLine: {show: false},
}
],
series : [
{
name:'图例',
type:'line',
smooth:true,
data: data:['3','2','21','3','4'],
itemStyle:{
normal:{
// a(系列名称),b(类目值),c(数值), d(无)
label:{show:true,position:'top',formatter:'{c}'},
areaStyle: {type: 'default'},
label : {
show: true,
position: 'top',
textStyle: {
color: '#99ff00'
}
}
}
}
}
]
};
myChartline.setOption(option1);
});
var myChartbar;
var myChartline;
//bar
require(['echarts','echarts/theme/macarons','echarts/chart/bar'], function (ec){
myChartbar = ec.init(document.getElementById('bar'),'macarons');
var option = {
//标题
title : {
text: '柱状图',
//字体 颜色 大小
textStyle: {fontWeight: 'normal',color: '#009999'},
subtext: ''
},
tooltip : {
trigger: 'axis'
},
//图例
legend: {
selectedMode:false,
//文字颜色
textStyle: {color: '#009999'},
data:['图例1', '图例2']
},
toolbox: {
show : true,
},
calculable : true,
//格子
grid:{borderWidth:0},
xAxis : [
{
type : 'category',
//不顶行显示
boundaryGap : true,
//X轴名称设置
name:'日期',
nameTextStyle:{color:'#009999'},
//X轴文字字体颜色设置
textStyle:{color:'#009999'},
axisLabel:{textStyle: {color:'#009999',fontSize: 8,},},
//不显示分行线
splitLine: {show: false},
//X轴数据
data : ['1','2','3','4','5']
}
],
yAxis : [
{
type : 'value',
//Y轴名称
name:'次',
nameTextStyle:{color:'#009999'},
//Y轴字体颜色大小
axisLabel:{textStyle: {color:'#009999',},},
splitLine: {show: false},
}
],
series : [
{
name:'图例1',
type:'bar',
stack: 'sum',
barCategoryGap: '30%',
//设置柱形图的颜色,文字颜色
itemStyle : { normal: {color: '#009999',label : {show: true, position: 'insideTop',textStyle: {color: '#cce8cf'}} }},
//Y轴数据
data:['23','1','20','13','14']
},
{
name:'图例2',
type:'bar',
stack: 'sum',
itemStyle: {
normal: {
color: '#00688B',}
},
//Y轴数据
data:['3','2','21','3','4']
}
]
};
//line
myChartbar.setOption(option);
});
require(['echarts','echarts/theme/macarons','echarts/chart/line'], function (ec){
myChartline = ec.init(document.getElementById('line'),'macarons');
var option1 = {
//线形图颜色(可以是多个)
color: ['#009999'],
//标题
title : {
text: '线形图',
textStyle: {fontWeight: 'normal',color: '#009999'},
//副标题
subtext: ''
},
tooltip : {
trigger: 'axis'
},
legend: {
textStyle: {color: '#009999'},
data:['图例']
},
toolbox: {
show : true,
},
calculable : true,
grid:{borderWidth:0},
xAxis : [
{
type : 'category',
//顶行显示
boundaryGap : false,
splitLine: {show: false},
data:['1','2','3','4','5']
}
],
yAxis : [
{
type : 'value',
splitLine: {show: false},
}
],
series : [
{
name:'图例',
type:'line',
smooth:true,
data: data:['3','2','21','3','4'],
itemStyle:{
normal:{
// a(系列名称),b(类目值),c(数值), d(无)
label:{show:true,position:'top',formatter:'{c}'},
areaStyle: {type: 'default'},
label : {
show: true,
position: 'top',
textStyle: {
color: '#99ff00'
}
}
}
}
}
]
};
myChartline.setOption(option1);
});
相关文章推荐
- 虚拟键值转化,为什么 GetKeyState(VK_SHIFT) & 0x8000;
- nginx负载均衡+keeplived
- Redis 启动警告错误解决[转]
- 操作jQuery集合——过滤操作
- 我就是要用MD5!不用不行!那么,怎么防止被拖库后泄露用户密码?
- MR源码学习(二)
- Node.JS 学习路线图
- 批处理读取ini文件
- 关于使用gradle构建的java项目中使用到rt.jar不能编译通过的处理
- Android判断设备网络连接状态及判断连接方式的方法
- Multimedia Programming Guide--多媒体编程指南
- Android SDK在线更新 下载Google源码 免翻墙
- 【Unity】连接sqlite数据库操作C#版
- “office for mac”模板文件的目录
- 使用forever运行nodejs应用
- 学习资源 网站
- 教你如何将txt转换成pdf格式的文件
- 透明窗体的编写
- 词法分析
- SQL技巧