用echarts画有两条线(柱)的折线(柱状)图
2016-12-28 08:52
316 查看
补登机后台的图表实现:
option = {
title: {
text: '过去七日交易额'
},
tooltip : {
trigger: 'axis'
},
legend: {
data:['交易额','交易量']
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true},
magicType : {show: true, type: ['line', 'bar']},
restore : {show: true},
saveAsImage : {show: true}
}
},
xAxis : [
{
type : 'category',
position: 'bottom',
boundaryGap: true,
axisLine : { // 轴线
show: true,
lineStyle: {
color: 'green',
type: 'solid',
width: 2
}
},
axisTick : { // 轴标记
show:true,
length: 10,
lineStyle: {
color: 'red',
type: 'solid',
width: 2
}
},
axisLabel : {
show:true,
interval: 'auto', // {number}
// rotate: 45,
margin: 8,
formatter: '周{value}',
textStyle: {
color: 'blue',
fontFamily: 'sans-serif',
fontSize: 15,
fontStyle: 'italic',
fontWeight: 'bold'
}
},
splitLine : {
show:true,
lineStyle: {
color: '#483d8b',
type: 'dashed',
width: 1
}
},
splitArea : {
show: true,
areaStyle:{
color:['rgba(144,238,144,0.3)','rgba(135,200,250,0.3)']
}
},
data : [
'一','二','三','四','五','六','日'
]
},
],
yAxis : [
{
type : 'value',
position: 'left',
//min: 0,
//max: 300,
//splitNumber: 5,
boundaryGap: [0,1],
axisLine : { // 轴线
show: true,
lineStyle: {
color: 'red',
type: 'dashed',
width: 2
}
},
axisTick : { // 轴标记
show:true,
length: 20,
lineStyle: {
color: 'green',
type: 'solid',
width: 2
}
},
axisLabel : {
show:true,
interval: 'auto', // {number}
// rotate: -45,
margin: 18,
formatter: '{value}元', // Template formatter!
textStyle: {
color: '#1e90ff',
fontFamily: 'verdana',
fontSize: 10,
fontStyle: 'normal',
fontWeight: 'bold'
}
},
splitLine : {
show:true,
lineStyle: {
color: '#483d8b',
type: 'dotted',
width: 2
}
},
splitArea : {
show: true,
areaStyle:{
color:['rgba(205,92,92,0.3)','rgba(255,215,0,0.3)']
}
}
},
{
type : 'value',
splitNumber: 10,
axisLabel : {
formatter: function (value) {
// Function formatter
return value + '笔'
}
},
splitLine : {
show: false
}
}
],
series : [
{
name: '交易额',
type: 'bar',
itemStyle:{
normal:{
color:"#1eb2b5"
}
},
data:[2000, 2300, 2400, 2500, 3100, 2100, 2800]
},
{
name: '交易量',
type: 'line',
yAxisIndex: 1,
itemStyle:{
normal:{
color:"#9F79EE"
}
},
data: [20, 30, 40, 50, 50, 40, 70]
},
]
};
myChart.setOption(option);
效果:
option = {
title: {
text: '过去七日交易额'
},
tooltip : {
trigger: 'axis'
},
legend: {
data:['交易额','交易量']
},
toolbox: {
show : true,
feature : {
mark : {show: true},
dataView : {show: true},
magicType : {show: true, type: ['line', 'bar']},
restore : {show: true},
saveAsImage : {show: true}
}
},
xAxis : [
{
type : 'category',
position: 'bottom',
boundaryGap: true,
axisLine : { // 轴线
show: true,
lineStyle: {
color: 'green',
type: 'solid',
width: 2
}
},
axisTick : { // 轴标记
show:true,
length: 10,
lineStyle: {
color: 'red',
type: 'solid',
width: 2
}
},
axisLabel : {
show:true,
interval: 'auto', // {number}
// rotate: 45,
margin: 8,
formatter: '周{value}',
textStyle: {
color: 'blue',
fontFamily: 'sans-serif',
fontSize: 15,
fontStyle: 'italic',
fontWeight: 'bold'
}
},
splitLine : {
show:true,
lineStyle: {
color: '#483d8b',
type: 'dashed',
width: 1
}
},
splitArea : {
show: true,
areaStyle:{
color:['rgba(144,238,144,0.3)','rgba(135,200,250,0.3)']
}
},
data : [
'一','二','三','四','五','六','日'
]
},
],
yAxis : [
{
type : 'value',
position: 'left',
//min: 0,
//max: 300,
//splitNumber: 5,
boundaryGap: [0,1],
axisLine : { // 轴线
show: true,
lineStyle: {
color: 'red',
type: 'dashed',
width: 2
}
},
axisTick : { // 轴标记
show:true,
length: 20,
lineStyle: {
color: 'green',
type: 'solid',
width: 2
}
},
axisLabel : {
show:true,
interval: 'auto', // {number}
// rotate: -45,
margin: 18,
formatter: '{value}元', // Template formatter!
textStyle: {
color: '#1e90ff',
fontFamily: 'verdana',
fontSize: 10,
fontStyle: 'normal',
fontWeight: 'bold'
}
},
splitLine : {
show:true,
lineStyle: {
color: '#483d8b',
type: 'dotted',
width: 2
}
},
splitArea : {
show: true,
areaStyle:{
color:['rgba(205,92,92,0.3)','rgba(255,215,0,0.3)']
}
}
},
{
type : 'value',
splitNumber: 10,
axisLabel : {
formatter: function (value) {
// Function formatter
return value + '笔'
}
},
splitLine : {
show: false
}
}
],
series : [
{
name: '交易额',
type: 'bar',
itemStyle:{
normal:{
color:"#1eb2b5"
}
},
data:[2000, 2300, 2400, 2500, 3100, 2100, 2800]
},
{
name: '交易量',
type: 'line',
yAxisIndex: 1,
itemStyle:{
normal:{
color:"#9F79EE"
}
},
data: [20, 30, 40, 50, 50, 40, 70]
},
]
};
myChart.setOption(option);
效果:
相关文章推荐
- Echarts柱状折线图
- ECharts图表之柱状折线混合图
- 笔记:Echarts - 柱状折线图
- Echarts-画柱状,折线图
- echarts初始化怎么加载两个折线图
- echarts折线图更改折线点类型
- gdi+实现多种统计图表(饼状,折线,柱状)支持负坐标
- ASP.net[2.0示例]实现折线,柱状,扇形图--web chart控件
- echarts-设置折线图中折线线条颜色和折线点颜色
- 使用achartengine 画图(折线、柱状、范围图、以及饼图)’
- echarts柱状图,改变柱状颜色
- echarts 折线分段显示不同颜色
- ECharts3.0饼状 柱状退(环形图)------------手把手教你每一项的样式设计
- ECharts实现折线图颜色分段及markline标注
- echarts折线图设置拐点样式,折线样式,折点标注
- ECharts 去掉折线上面的小圆点
- VML 画统计 柱状、饼图、折线
- echarts之(1)折线图
- echarts-单折线图
- 起步平台 WeX5 集成百度echarts实现微信公众号中折线图颜色交错显示