折线对比图

qianming 3 years ago
parent 335645c370
commit 893f623fbe

@ -61,6 +61,7 @@ export default {
xAxis: [
{//
splitNumber: 2,
show: true,
type: 'value',
inverse: true,
axisLine: {//线
@ -92,6 +93,7 @@ export default {
},
{//
gridIndex: 2,
show: true,
type: 'value',
axisLine: {
show: false,
@ -302,6 +304,7 @@ export default {
const xAxisLeft = {
splitNumber: optionsSetup.splitNumberLeft,
type: 'value',
show : optionsSetup.hideXLeft,
inverse: true,
axisLine: {//X线
show: optionsSetup.xLineLeft,
@ -314,7 +317,7 @@ export default {
},
position: 'bottom',
axisLabel: { // x
show: optionsSetup.hideXLeft,
show: true,
textStyle: {
color: optionsSetup.XcolorLeft,
fontSize: optionsSetup.fontSizeXLeft
@ -337,6 +340,7 @@ export default {
const xAxisRight = {
gridIndex: 2,
splitNumber: optionsSetup.splitNumberRight,
show : optionsSetup.hideXRight,
type: 'value',
axisLine: {//X线
show: optionsSetup.xLineRight,
@ -349,7 +353,7 @@ export default {
},
position: 'bottom',
axisLabel: { // x
show: optionsSetup.hideXRight,
show: true,
textStyle: {
color: optionsSetup.XcolorRight,
fontSize: optionsSetup.fontSizeXRight
@ -444,16 +448,6 @@ export default {
this.options.tooltip = tooltip;
},
//
getOptionsBottom(){
const optionsSetup = this.optionsSetup;
let bottom = optionsSetup.marginBottom;
if (optionsSetup.hideXLeft) {
bottom = optionsSetup.marginBottom + 15
}else if (optionsSetup.hideXRight){
bottom = optionsSetup.marginBottom + 15
}
return bottom
},
setOptionsGrid() {
const optionsSetup = this.optionsSetup;
const grid = [
@ -469,7 +463,7 @@ export default {
show: false,
left: "51%",
top: optionsSetup.marginTop,
bottom: this.getOptionsBottom(),
bottom: optionsSetup.marginBottom + 15,
width: '0%'
},
{//

@ -16,13 +16,27 @@ export default {
data() {
return {
options: {
axisPointer: {
link: {
xAxisIndex: "all",
},
},
title: {
//text: '',
x: 'center',
textStyle: {
color: '#ffffff',
},
},
tooltip: {
show: true,
trigger: "axis",
axisPointer: {
type: "line",
lineStyle: {
type: "dashed",
},
},
},
//
grid: [
{//
@ -52,60 +66,92 @@ export default {
{//
gridIndex: 0,
type: 'category',
boundaryGap: false,
axisLine: { //线
onZero: false,
boundaryGap: true, //
axisLine: { //x线
show: true,
lineStyle: {
color: '#ffffff',
}
},
splitNumber: 2,
inverse: true,
axisTick: {
show: false,
axisTick: { //
show: true,
},
//position: 'bottom',
axisLabel: { // x
axisLabel: { // X
show: true,
textStyle: {
color: '#ffffff',
fontSize: 12
fontSize: 14
}
},
data: []
data: [],
},
{//
gridIndex: 1,
type: 'category',
position: 'top',
boundaryGap: false,
axisLine: {
show: false,
boundaryGap: true, //
axisLine: { // x线
show: true,
lineStyle: {
color: '#ffffff',
}
},
axisTick: {
show: false,
axisTick: { //
show: true,
},
//position: 'bottom',
axisLabel: {
show: true,
textStyle: {
color: '#ffffff',
fontSize: 12,
},
show: false,
},
data: [],
},
],
yAxis: [
{
gridIndex: 0,
scale: true,
show: true,
scale: true, // 0,false0
axisLabel: {
show: true,
textStyle: {
color: '#ffffff',
fontSize: 14,
},
},
axisLine: { // 线
show: true,
lineStyle: {
color: '#ffffff',
},
},
splitLine: {
show: false,
lineStyle: {
color: '#ffffff',
},
},
},
{
gridIndex: 1,
scale: true,
inverse: true,
scale: false, // 0
inverse: true, //
axisLabel: {
show: true,
textStyle: {
color: '#ffffff',
fontSize: 14,
},
},
axisLine: { // 线
show: true,
lineStyle: {
color: '#ffffff',
},
},
splitLine: {
show: false,
lineStyle: {
color: '#ffffff',
},
},
},
],
@ -115,32 +161,21 @@ export default {
type: 'line',
xAxisIndex: 0,
yAxisIndex: 0,
smooth: true,
barGap: 20,
barWidth: 15,
/*label: {
normal: {
show: true,
color: 'red',
position: 'insideLeft',
textStyle: {
color: '#ffffff',
}
},
emphasis: {
show: false,
},
},
smooth: true, // 线线
itemStyle: {
normal: {
color: '#36c5e7',
barBorderRadius: [8, 0, 0, 8],
},
emphasis: {
show: false,
},
},*/
color: '#36c5e7',
},
lineStyle: {
color: '#36c5e7',
width: 2,
},
label: {
position: 'top',
distance: 10,
show: true,
color: '#36c5e7',
fontSize: 14,
},
data: [],
},
{
@ -148,28 +183,21 @@ export default {
type: 'line',
xAxisIndex: 1,
yAxisIndex: 1,
smooth: true,
barGap: 20,
barWidth: 15,
/*label: {
normal: {
show: true,
color: 'red',
position: 'insideRight',
textStyle: {
color: '#ffffff',
}
},
},
smooth: true, // 线线
itemStyle: {
normal: {
color: '#e68b55',
barBorderRadius: [0, 8, 8, 0],
},
emphasis: {
show: false,
},
},*/
color: '#e68b55',
},
lineStyle: {
color: '#e68b55',
width: 2,
},
label: {
position: 'bottom',
distance: 10,
show: true,
color: '#e68b55',
fontSize: 16,
},
data: [],
},
]
@ -225,249 +253,249 @@ export default {
this.setOptionsColor();*/
this.setOptionsData();
},
/* // 标题修改
setOptionsTitle() {
const optionsCollapse = this.optionsSetup;
const title = {};
title.text = optionsCollapse.titleText;
title.show = optionsCollapse.isNoTitle;
title.left = optionsCollapse.textAlign;
title.textStyle = {
color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight
};
this.options.title = title;
},
// X
setOptionsXLeft() {
const optionsSetup = this.optionsSetup;
const xAxisLeft = {
splitNumber: optionsSetup.splitNumberLeft,
type: 'value',
inverse: true,
axisLine: {//X线
show: optionsSetup.xLineLeft,
lineStyle: {
color: optionsSetup.lineColorXLeft,
},
},
axisTick: {
show: optionsSetup.tickLineLeft,
/* // 标题修改
setOptionsTitle() {
const optionsCollapse = this.optionsSetup;
const title = {};
title.text = optionsCollapse.titleText;
title.show = optionsCollapse.isNoTitle;
title.left = optionsCollapse.textAlign;
title.textStyle = {
color: optionsCollapse.textColor,
fontSize: optionsCollapse.textFontSize,
fontWeight: optionsCollapse.textFontWeight
};
this.options.title = title;
},
position: 'bottom',
axisLabel: { // x
show: optionsSetup.hideXLeft,
textStyle: {
color: optionsSetup.XcolorLeft,
fontSize: optionsSetup.fontSizeXLeft
// X
setOptionsXLeft() {
const optionsSetup = this.optionsSetup;
const xAxisLeft = {
splitNumber: optionsSetup.splitNumberLeft,
type: 'value',
inverse: true,
axisLine: {//X线
show: optionsSetup.xLineLeft,
lineStyle: {
color: optionsSetup.lineColorXLeft,
},
},
axisTick: {
show: optionsSetup.tickLineLeft,
},
position: 'bottom',
axisLabel: { // x
show: optionsSetup.hideXLeft,
textStyle: {
color: optionsSetup.XcolorLeft,
fontSize: optionsSetup.fontSizeXLeft
}
},
splitLine: { // 线
show: optionsSetup.SplitLineLeft,
lineStyle: {
color: optionsSetup.SplitLineColorLeft,
width: optionsSetup.SplitLinefontSizeLeft,
type: 'solid'
}
}
}
this.options.xAxis[0] = xAxisLeft;
},
splitLine: { // 线
show: optionsSetup.SplitLineLeft,
lineStyle: {
color: optionsSetup.SplitLineColorLeft,
width: optionsSetup.SplitLinefontSizeLeft,
type: 'solid'
// X
setOptionsXRight() {
const optionsSetup = this.optionsSetup;
const xAxisRight = {
gridIndex: 2,
splitNumber: optionsSetup.splitNumberRight,
type: 'value',
axisLine: {//X线
show: optionsSetup.xLineRight,
lineStyle: {
color: optionsSetup.lineColorXRight,
},
},
axisTick: {
show: optionsSetup.tickLineRight,
},
position: 'bottom',
axisLabel: { // x
show: optionsSetup.hideXRight,
textStyle: {
color: optionsSetup.XcolorRight,
fontSize: optionsSetup.fontSizeXRight
}
},
splitLine: { // 线
show: optionsSetup.SplitLineRight,
lineStyle: {
color: optionsSetup.SplitLineColorRight,
width: optionsSetup.SplitLinefontSizeRight,
type: 'solid'
}
}
}
}
}
this.options.xAxis[0] = xAxisLeft;
},
// X
setOptionsXRight() {
const optionsSetup = this.optionsSetup;
const xAxisRight = {
gridIndex: 2,
splitNumber: optionsSetup.splitNumberRight,
type: 'value',
axisLine: {//X线
show: optionsSetup.xLineRight,
lineStyle: {
color: optionsSetup.lineColorXRight,
},
this.options.xAxis[2] = xAxisRight;
},
axisTick: {
show: optionsSetup.tickLineRight,
// Y
setOptionsY() {
const optionsSetup = this.optionsSetup;
const axisLine = {
show: optionsSetup.lineY,
lineStyle: {
color: optionsSetup.lineColorY
}
};
const axisTick = {
show: optionsSetup.tickLineY
};
const axisLabel = {
show: optionsSetup.hideY,
textStyle: {
align: optionsSetup.textAlign,
color: optionsSetup.colorY,
fontSize: optionsSetup.fontSizeY,
}
};
this.options.yAxis[1]['axisLine'] = axisLine;
this.options.yAxis[1]['axisTick'] = axisTick;
this.options.yAxis[1]['axisLabel'] = axisLabel;
},
position: 'bottom',
axisLabel: { // x
show: optionsSetup.hideXRight,
textStyle: {
color: optionsSetup.XcolorRight,
fontSize: optionsSetup.fontSizeXRight
//
setOptionsTop() {
const optionsSetup = this.optionsSetup;
const series = this.options.series;
for (const key in series) {
if (series[key].type == "bar") {
series[0].label = {
normal: {
show: optionsSetup.isShow,
position: 'insideLeft',
textStyle: {
fontSize: optionsSetup.fontSize,
color: optionsSetup.subTextColor,
fontWeight: optionsSetup.fontWeight
}
},
emphasis: {
show: false,
},
},
series[1].label = {
normal: {
show: optionsSetup.isShow,
color: 'red',
position: 'insideRight',
textStyle: {
fontSize: optionsSetup.fontSize,
color: optionsSetup.subTextColor,
fontWeight: optionsSetup.fontWeight
}
},
emphasis: {
show: false,
},
},
series[key].barWidth = optionsSetup.maxWidth;
}
}
this.options.series = series;
},
// tooltip
setOptionsTooltip() {
const optionsSetup = this.optionsSetup;
const tooltip = {
trigger: "item",
show: true,
textStyle: {
color: optionsSetup.lineColor,
fontSize: optionsSetup.fontSize
}
};
this.options.tooltip = tooltip;
},
splitLine: { // 线
show: optionsSetup.SplitLineRight,
lineStyle: {
color: optionsSetup.SplitLineColorRight,
width: optionsSetup.SplitLinefontSizeRight,
type: 'solid'
//
getOptionsBottom(){
const optionsSetup = this.optionsSetup;
let bottom = optionsSetup.marginBottom;
if (optionsSetup.hideXLeft) {
bottom = optionsSetup.marginBottom + 15
}else if (optionsSetup.hideXRight){
bottom = optionsSetup.marginBottom + 15
}
}
}
this.options.xAxis[2] = xAxisRight;
},
// Y
setOptionsY() {
const optionsSetup = this.optionsSetup;
const axisLine = {
show: optionsSetup.lineY,
lineStyle: {
color: optionsSetup.lineColorY
}
};
const axisTick = {
show: optionsSetup.tickLineY
};
const axisLabel = {
show: optionsSetup.hideY,
textStyle: {
align: optionsSetup.textAlign,
color: optionsSetup.colorY,
fontSize: optionsSetup.fontSizeY,
}
};
this.options.yAxis[1]['axisLine'] = axisLine;
this.options.yAxis[1]['axisTick'] = axisTick;
this.options.yAxis[1]['axisLabel'] = axisLabel;
},
//
setOptionsTop() {
const optionsSetup = this.optionsSetup;
const series = this.options.series;
for (const key in series) {
if (series[key].type == "bar") {
series[0].label = {
normal: {
show: optionsSetup.isShow,
position: 'insideLeft',
textStyle: {
fontSize: optionsSetup.fontSize,
color: optionsSetup.subTextColor,
fontWeight: optionsSetup.fontWeight
}
return bottom
},
setOptionsGrid() {
const optionsSetup = this.optionsSetup;
const grid = [
{//
show: optionsSetup.frameLineLeft,
left: optionsSetup.marginLeftRight,
top: optionsSetup.marginTop,
bottom: optionsSetup.marginBottom,
containLabel: true,
width: '40%'
},
emphasis: {
{//
show: false,
left: "51%",
top: optionsSetup.marginTop,
bottom: this.getOptionsBottom(),
width: '0%'
},
},
series[1].label = {
normal: {
show: optionsSetup.isShow,
color: 'red',
position: 'insideRight',
textStyle: {
fontSize: optionsSetup.fontSize,
color: optionsSetup.subTextColor,
fontWeight: optionsSetup.fontWeight
}
},
emphasis: {
show: false,
},
{//
show: optionsSetup.frameLineRight,
right: optionsSetup.marginLeftRight,
top: optionsSetup.marginTop,
bottom: optionsSetup.marginBottom,
containLabel: true,
width: '40%'
},
series[key].barWidth = optionsSetup.maxWidth;
}
}
this.options.series = series;
},
// tooltip
setOptionsTooltip() {
const optionsSetup = this.optionsSetup;
const tooltip = {
trigger: "item",
show: true,
textStyle: {
color: optionsSetup.lineColor,
fontSize: optionsSetup.fontSize
}
};
this.options.tooltip = tooltip;
},
//
getOptionsBottom(){
const optionsSetup = this.optionsSetup;
let bottom = optionsSetup.marginBottom;
if (optionsSetup.hideXLeft) {
bottom = optionsSetup.marginBottom + 15
}else if (optionsSetup.hideXRight){
bottom = optionsSetup.marginBottom + 15
}
return bottom
},
setOptionsGrid() {
const optionsSetup = this.optionsSetup;
const grid = [
{//
show: optionsSetup.frameLineLeft,
left: optionsSetup.marginLeftRight,
top: optionsSetup.marginTop,
bottom: optionsSetup.marginBottom,
containLabel: true,
width: '40%'
},
{//
show: false,
left: "51%",
top: optionsSetup.marginTop,
bottom: this.getOptionsBottom(),
width: '0%'
},
{//
show: optionsSetup.frameLineRight,
right: optionsSetup.marginLeftRight,
top: optionsSetup.marginTop,
bottom: optionsSetup.marginBottom,
containLabel: true,
width: '40%'
},
]
this.options.grid = grid;
},
//
setOptionsLegend() {
const optionsSetup = this.optionsSetup;
const legend = this.options.legend;
legend.show = optionsSetup.isShowLegend;
legend.left = optionsSetup.lateralPosition;
legend.top = optionsSetup.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom =
optionsSetup.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsSetup.layoutFront;
legend.textStyle = {
color: optionsSetup.lengedColor,
fontSize: optionsSetup.lengedFontSize
};
legend.itemWidth = optionsSetup.lengedWidth;
},
//
setOptionsColor() {
const optionsSetup = this.optionsSetup;
const customColor = optionsSetup.customColor;
if (!customColor) return;
const itemStyleLeft = {
normal: {
color: customColor[0].color,
barBorderRadius: [optionsSetup.radius, 0, 0, optionsSetup.radius]
},
emphasis: {
show: false,
]
this.options.grid = grid;
},
}
const itemStyleRight = {
normal: {
color: customColor[1].color,
barBorderRadius: [0, optionsSetup.radius, optionsSetup.radius, 0]
},
emphasis: {
show: false,
//
setOptionsLegend() {
const optionsSetup = this.optionsSetup;
const legend = this.options.legend;
legend.show = optionsSetup.isShowLegend;
legend.left = optionsSetup.lateralPosition;
legend.top = optionsSetup.longitudinalPosition == "top" ? 0 : "auto";
legend.bottom =
optionsSetup.longitudinalPosition == "bottom" ? 0 : "auto";
legend.orient = optionsSetup.layoutFront;
legend.textStyle = {
color: optionsSetup.lengedColor,
fontSize: optionsSetup.lengedFontSize
};
legend.itemWidth = optionsSetup.lengedWidth;
},
}
this.options.series[0].itemStyle = itemStyleLeft;
this.options.series[1].itemStyle = itemStyleRight;
},*/
//
setOptionsColor() {
const optionsSetup = this.optionsSetup;
const customColor = optionsSetup.customColor;
if (!customColor) return;
const itemStyleLeft = {
normal: {
color: customColor[0].color,
barBorderRadius: [optionsSetup.radius, 0, 0, optionsSetup.radius]
},
emphasis: {
show: false,
},
}
const itemStyleRight = {
normal: {
color: customColor[1].color,
barBorderRadius: [0, optionsSetup.radius, optionsSetup.radius, 0]
},
emphasis: {
show: false,
},
}
this.options.series[0].itemStyle = itemStyleLeft;
this.options.series[1].itemStyle = itemStyleRight;
},*/
//
setOptionsData() {
const optionsSetup = this.optionsSetup;
@ -522,6 +550,7 @@ export default {
this.options.series[1]['name'] = arrayList[1].name
this.options.series[1]['data'] = arrayList[1].data
this.options.xAxis[0]['data'] = xAxisList
this.options.xAxis[1]['data'] = xAxisList
},
//
dynamicDataFn(val, refreshTime, optionsSetup) {
@ -543,7 +572,7 @@ export default {
},
renderingFn(optionsSetup, val) {
this.options.yAxis[1]['data'] = val.xAxis
if (val.series[0].type == "bar"){
if (val.series[0].type == "bar") {
this.options.series[0]['name'] = val.series[0].name
this.options.series[0]['data'] = val.series[0].data
this.options.series[1]['name'] = val.series[1].name

@ -180,7 +180,7 @@ export default {
axisLabel: {
show: true,
textStyle: {
color: optionsCollapse.colorY, // x
color: optionsCollapse.colorY, // y
fontSize: optionsCollapse.fontSizeY
}
},

Loading…
Cancel
Save