|
@@ -110,22 +110,27 @@ export default {
|
|
// 标题修改
|
|
// 标题修改
|
|
setOptionsTitle() {
|
|
setOptionsTitle() {
|
|
const optionsSetup = this.optionsSetup;
|
|
const optionsSetup = this.optionsSetup;
|
|
- const title = {};
|
|
|
|
- title.text = optionsSetup.titleText;
|
|
|
|
- title.show = optionsSetup.isNoTitle;
|
|
|
|
- title.left = optionsSetup.textAlign;
|
|
|
|
- title.textStyle = {
|
|
|
|
- color: optionsSetup.textColor,
|
|
|
|
- fontSize: optionsSetup.textFontSize,
|
|
|
|
- fontWeight: optionsSetup.textFontWeight,
|
|
|
|
- fontStyle: optionsSetup.textFontStyle,
|
|
|
|
- };
|
|
|
|
- title.subtext = optionsSetup.subText;
|
|
|
|
- title.subtextStyle = {
|
|
|
|
- color: optionsSetup.subTextColor,
|
|
|
|
- fontWeight: optionsSetup.subTextFontWeight,
|
|
|
|
- fontSize: optionsSetup.subTextFontSize,
|
|
|
|
- fontStyle: optionsSetup.subTextFontStyle,
|
|
|
|
|
|
+ const title = {
|
|
|
|
+ text: optionsSetup.text,
|
|
|
|
+ show: optionsSetup.isShowTitle,
|
|
|
|
+ left: optionsSetup.titleLeft,
|
|
|
|
+ top: optionsSetup.titleTop + "%",
|
|
|
|
+ itemGap: optionsSetup.titleItemGap,
|
|
|
|
+ textStyle: {
|
|
|
|
+ color: optionsSetup.textColor,
|
|
|
|
+ fontSize: optionsSetup.textFontSize,
|
|
|
|
+ fontWeight: optionsSetup.textFontWeight,
|
|
|
|
+ fontStyle: optionsSetup.textFontStyle,
|
|
|
|
+ fontFamily: optionsSetup.textFontFamily,
|
|
|
|
+ },
|
|
|
|
+ subtext: optionsSetup.subtext,
|
|
|
|
+ subtextStyle: {
|
|
|
|
+ color: optionsSetup.subtextColor,
|
|
|
|
+ fontWeight: optionsSetup.subtextFontWeight,
|
|
|
|
+ fontSize: optionsSetup.subtextFontSize,
|
|
|
|
+ fontStyle: optionsSetup.subtextFontStyle,
|
|
|
|
+ fontFamily: optionsSetup.subtextFontFamily
|
|
|
|
+ },
|
|
};
|
|
};
|
|
this.options.title = title;
|
|
this.options.title = title;
|
|
},
|
|
},
|
|
@@ -135,33 +140,52 @@ export default {
|
|
const xAxis = {
|
|
const xAxis = {
|
|
type: "category",
|
|
type: "category",
|
|
// 坐标轴是否显示
|
|
// 坐标轴是否显示
|
|
- show: optionsSetup.hideX,
|
|
|
|
|
|
+ show: optionsSetup.isShowX,
|
|
|
|
+ position: optionsSetup.positionX,
|
|
|
|
+ offset: optionsSetup.offsetX,
|
|
// 坐标轴名称
|
|
// 坐标轴名称
|
|
name: optionsSetup.nameX,
|
|
name: optionsSetup.nameX,
|
|
|
|
+ nameLocation: optionsSetup.nameLocationX,
|
|
nameTextStyle: {
|
|
nameTextStyle: {
|
|
color: optionsSetup.nameColorX,
|
|
color: optionsSetup.nameColorX,
|
|
fontSize: optionsSetup.nameFontSizeX,
|
|
fontSize: optionsSetup.nameFontSizeX,
|
|
|
|
+ fontWeight: optionsSetup.nameFontWeightX,
|
|
|
|
+ fontStyle: optionsSetup.nameFontStyleX,
|
|
|
|
+ fontFamily: optionsSetup.nameFontFamilyX,
|
|
},
|
|
},
|
|
// 轴反转
|
|
// 轴反转
|
|
inverse: optionsSetup.reversalX,
|
|
inverse: optionsSetup.reversalX,
|
|
axisLabel: {
|
|
axisLabel: {
|
|
- show: true,
|
|
|
|
- interval: optionsSetup.textInterval,
|
|
|
|
|
|
+ show: optionsSetup.isShowAxisLabelX,
|
|
|
|
+ interval: optionsSetup.textIntervalX,
|
|
// 文字角度
|
|
// 文字角度
|
|
rotate: optionsSetup.textAngleX,
|
|
rotate: optionsSetup.textAngleX,
|
|
textStyle: {
|
|
textStyle: {
|
|
// 坐标文字颜色
|
|
// 坐标文字颜色
|
|
- color: optionsSetup.colorX,
|
|
|
|
- fontSize: optionsSetup.fontSizeX,
|
|
|
|
|
|
+ color: optionsSetup.textColorX,
|
|
|
|
+ fontSize: optionsSetup.textFontSizeX,
|
|
|
|
+ fontWeight: optionsSetup.textFontWeightX,
|
|
|
|
+ fontStyle: optionsSetup.textFontStyleX,
|
|
|
|
+ fontFamily: optionsSetup.textFontFamilyX,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ // X轴线
|
|
axisLine: {
|
|
axisLine: {
|
|
- show: true,
|
|
|
|
|
|
+ show: optionsSetup.isShowAxisLineX,
|
|
lineStyle: {
|
|
lineStyle: {
|
|
color: optionsSetup.lineColorX,
|
|
color: optionsSetup.lineColorX,
|
|
width: optionsSetup.lineWidthX,
|
|
width: optionsSetup.lineWidthX,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ // X轴刻度线
|
|
|
|
+ axisTick: {
|
|
|
|
+ show: optionsSetup.isShowAxisLineX,
|
|
|
|
+ lineStyle: {
|
|
|
|
+ color: optionsSetup.lineColorX,
|
|
|
|
+ width: optionsSetup.lineWidthX,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ // X轴分割线
|
|
splitLine: {
|
|
splitLine: {
|
|
show: optionsSetup.isShowSplitLineX,
|
|
show: optionsSetup.isShowSplitLineX,
|
|
lineStyle: {
|
|
lineStyle: {
|
|
@@ -169,6 +193,7 @@ export default {
|
|
width: optionsSetup.splitLineWidthX,
|
|
width: optionsSetup.splitLineWidthX,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+
|
|
};
|
|
};
|
|
this.options.xAxis = xAxis;
|
|
this.options.xAxis = xAxis;
|
|
},
|
|
},
|
|
@@ -183,26 +208,43 @@ export default {
|
|
splitNumber: optionsSetup.splitNumberY,
|
|
splitNumber: optionsSetup.splitNumberY,
|
|
// 坐标轴是否显示
|
|
// 坐标轴是否显示
|
|
show: optionsSetup.isShowY,
|
|
show: optionsSetup.isShowY,
|
|
|
|
+ position: optionsSetup.positionY,
|
|
|
|
+ offset: optionsSetup.offsetY,
|
|
// 坐标轴名称
|
|
// 坐标轴名称
|
|
name: optionsSetup.textNameY,
|
|
name: optionsSetup.textNameY,
|
|
|
|
+ nameLocation: optionsSetup.nameLocationY,
|
|
nameTextStyle: {
|
|
nameTextStyle: {
|
|
color: optionsSetup.nameColorY,
|
|
color: optionsSetup.nameColorY,
|
|
fontSize: optionsSetup.nameFontSizeY,
|
|
fontSize: optionsSetup.nameFontSizeY,
|
|
|
|
+ fontWeight: optionsSetup.nameFontWeightY,
|
|
|
|
+ fontStyle: optionsSetup.nameFontStyleY,
|
|
|
|
+ fontFamily: optionsSetup.nameFontFamilyY,
|
|
},
|
|
},
|
|
// 轴反转
|
|
// 轴反转
|
|
inverse: optionsSetup.reversalY,
|
|
inverse: optionsSetup.reversalY,
|
|
axisLabel: {
|
|
axisLabel: {
|
|
- show: true,
|
|
|
|
|
|
+ show: optionsSetup.isShowAxisLabelY,
|
|
// 文字角度
|
|
// 文字角度
|
|
rotate: optionsSetup.textAngleY,
|
|
rotate: optionsSetup.textAngleY,
|
|
|
|
+ //interval: optionsSetup.textIntervalY,
|
|
textStyle: {
|
|
textStyle: {
|
|
// 坐标文字颜色
|
|
// 坐标文字颜色
|
|
- color: optionsSetup.colorY,
|
|
|
|
- fontSize: optionsSetup.fontSizeY,
|
|
|
|
|
|
+ color: optionsSetup.textColorY,
|
|
|
|
+ fontSize: optionsSetup.textFontSizeY,
|
|
|
|
+ fontWeight: optionsSetup.textFontWeightY,
|
|
|
|
+ fontStyle: optionsSetup.textFontStyleY,
|
|
|
|
+ fontFamily: optionsSetup.textFontFamilyY,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
axisLine: {
|
|
axisLine: {
|
|
- show: true,
|
|
|
|
|
|
+ show: optionsSetup.isShowAxisLineY,
|
|
|
|
+ lineStyle: {
|
|
|
|
+ color: optionsSetup.lineColorY,
|
|
|
|
+ width: optionsSetup.lineWidthY,
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ axisTick: {
|
|
|
|
+ show: optionsSetup.isShowAxisLineY,
|
|
lineStyle: {
|
|
lineStyle: {
|
|
color: optionsSetup.lineColorY,
|
|
color: optionsSetup.lineColorY,
|
|
width: optionsSetup.lineWidthY,
|
|
width: optionsSetup.lineWidthY,
|
|
@@ -224,12 +266,15 @@ export default {
|
|
const tooltip = {
|
|
const tooltip = {
|
|
show: optionsSetup.isShowTooltip,
|
|
show: optionsSetup.isShowTooltip,
|
|
trigger: optionsSetup.tooltipTrigger,
|
|
trigger: optionsSetup.tooltipTrigger,
|
|
- axisPointer:{
|
|
|
|
|
|
+ axisPointer: {
|
|
type: optionsSetup.tooltipAxisPointerType,
|
|
type: optionsSetup.tooltipAxisPointerType,
|
|
},
|
|
},
|
|
textStyle: {
|
|
textStyle: {
|
|
- color: optionsSetup.tipsColor,
|
|
|
|
- fontSize: optionsSetup.tipsFontSize,
|
|
|
|
|
|
+ color: optionsSetup.tooltipColor,
|
|
|
|
+ fontSize: optionsSetup.tooltipFontSize,
|
|
|
|
+ fontWeight: optionsSetup.tooltipFontWeight,
|
|
|
|
+ fontStyle: optionsSetup.tooltipFontStyle,
|
|
|
|
+ fontFamily: optionsSetup.tooltipFontFamily,
|
|
},
|
|
},
|
|
};
|
|
};
|
|
this.options.tooltip = tooltip;
|
|
this.options.tooltip = tooltip;
|
|
@@ -249,17 +294,24 @@ export default {
|
|
// 图例操作 legend
|
|
// 图例操作 legend
|
|
setOptionsLegend() {
|
|
setOptionsLegend() {
|
|
const optionsSetup = this.optionsSetup;
|
|
const optionsSetup = this.optionsSetup;
|
|
- const legend = this.options.legend;
|
|
|
|
- legend.show = optionsSetup.isShowLegend;
|
|
|
|
- legend.left = optionsSetup.lateralPosition;
|
|
|
|
- legend.top = optionsSetup.longitudinalPosition;
|
|
|
|
- legend.bottom = optionsSetup.longitudinalPosition;
|
|
|
|
- legend.orient = optionsSetup.layoutFront;
|
|
|
|
- legend.textStyle = {
|
|
|
|
- color: optionsSetup.legendColor,
|
|
|
|
- fontSize: optionsSetup.legendFontSize,
|
|
|
|
|
|
+ const legend = {
|
|
|
|
+ show: optionsSetup.isShowLegend,
|
|
|
|
+ left: optionsSetup.lateralPosition,
|
|
|
|
+ //right: optionsSetup.lateralPosition,
|
|
|
|
+ top: optionsSetup.longitudinalPosition,
|
|
|
|
+ //bottom: optionsSetup.longitudinalPosition,
|
|
|
|
+ orient: optionsSetup.layoutFront,
|
|
|
|
+ textStyle: {
|
|
|
|
+ color: optionsSetup.legendColor,
|
|
|
|
+ fontSize: optionsSetup.legendFontSize,
|
|
|
|
+ fontWeight: optionsSetup.legendFontWeight,
|
|
|
|
+ fontStyle: optionsSetup.legendFontStyle,
|
|
|
|
+ fontFamily: optionsSetup.legendFontFamily,
|
|
|
|
+ },
|
|
|
|
+ itemHeight: optionsSetup.legendHeight,
|
|
|
|
+ itemWidth: optionsSetup.legendWidth,
|
|
};
|
|
};
|
|
- legend.itemWidth = optionsSetup.legendWidth;
|
|
|
|
|
|
+ this.options.legend = legend;
|
|
},
|
|
},
|
|
// 图例名称设置
|
|
// 图例名称设置
|
|
setOptionsLegendName(name) {
|
|
setOptionsLegendName(name) {
|
|
@@ -280,6 +332,15 @@ export default {
|
|
this.options.legend["data"] = arr;
|
|
this.options.legend["data"] = arr;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ //获取堆叠样式
|
|
|
|
+ getStackStyle() {
|
|
|
|
+ const optionsSetup = this.optionsSetup;
|
|
|
|
+ let style = "";
|
|
|
|
+ if (optionsSetup.stackStyle == "upDown") {
|
|
|
|
+ style = "total";
|
|
|
|
+ }
|
|
|
|
+ return style;
|
|
|
|
+ },
|
|
// 数据解析
|
|
// 数据解析
|
|
setOptionsData(e, paramsConfig) {
|
|
setOptionsData(e, paramsConfig) {
|
|
const optionsSetup = this.optionsSetup;
|
|
const optionsSetup = this.optionsSetup;
|
|
@@ -347,6 +408,7 @@ export default {
|
|
return {
|
|
return {
|
|
name: item.name,
|
|
name: item.name,
|
|
type: "bar",
|
|
type: "bar",
|
|
|
|
+ stack: this.getStackStyle(),
|
|
data: item.list.map((item) => item.data),
|
|
data: item.list.map((item) => item.data),
|
|
barGap: optionsSetup.barGap + "%",
|
|
barGap: optionsSetup.barGap + "%",
|
|
barMinHeight: optionsSetup.minHeight,
|
|
barMinHeight: optionsSetup.minHeight,
|
|
@@ -356,12 +418,14 @@ export default {
|
|
position: optionsSetup.fontPosition,
|
|
position: optionsSetup.fontPosition,
|
|
distance: optionsSetup.fontDistance,
|
|
distance: optionsSetup.fontDistance,
|
|
fontSize: optionsSetup.fontSize,
|
|
fontSize: optionsSetup.fontSize,
|
|
- color: optionsSetup.dataColor,
|
|
|
|
|
|
+ color: optionsSetup.fontColor,
|
|
fontWeight: optionsSetup.fontWeight,
|
|
fontWeight: optionsSetup.fontWeight,
|
|
formatter: (row) => {
|
|
formatter: (row) => {
|
|
const dataIndex = row.dataIndex;
|
|
const dataIndex = row.dataIndex;
|
|
return `${fontDataName[0]}:${item.list[dataIndex].plan}\n${fontDataName[1]}:${item.list[dataIndex].real}\n${fontDataName[2]}:${item.list[dataIndex].data}%`;
|
|
return `${fontDataName[0]}:${item.list[dataIndex].plan}\n${fontDataName[1]}:${item.list[dataIndex].real}\n${fontDataName[2]}:${item.list[dataIndex].data}%`;
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ fontStyle: optionsSetup.fontStyle,
|
|
|
|
+ fontFamily: optionsSetup.fontFamily,
|
|
},
|
|
},
|
|
//颜色,圆角属性
|
|
//颜色,圆角属性
|
|
itemStyle: {
|
|
itemStyle: {
|
|
@@ -385,16 +449,19 @@ export default {
|
|
})
|
|
})
|
|
this.options.series = series;
|
|
this.options.series = series;
|
|
// 根据图表的宽度 x轴的字体大小、长度来估算X轴的label能展示多少个字
|
|
// 根据图表的宽度 x轴的字体大小、长度来估算X轴的label能展示多少个字
|
|
- const rowsNum = optionsSetup.textRowsNum !== "" ? optionsSetup.textRowsNum : parseInt((this.optionsStyle.width / axisList.length) / optionsSetup.fontSizeX);
|
|
|
|
|
|
+ const rowsNum = optionsSetup.textRowsNum !== "" ? optionsSetup.textRowsNum : parseInt((this.optionsStyle.width / axisList.length) / optionsSetup.textFontSizeX);
|
|
const axisLabel = {
|
|
const axisLabel = {
|
|
- show: true,
|
|
|
|
- interval: optionsSetup.textInterval,
|
|
|
|
|
|
+ show: optionsSetup.isShowAxisLabelX,
|
|
|
|
+ interval: optionsSetup.textIntervalX,
|
|
// 文字角度
|
|
// 文字角度
|
|
rotate: optionsSetup.textAngleX,
|
|
rotate: optionsSetup.textAngleX,
|
|
textStyle: {
|
|
textStyle: {
|
|
// 坐标文字颜色
|
|
// 坐标文字颜色
|
|
- color: optionsSetup.colorX,
|
|
|
|
- fontSize: optionsSetup.fontSizeX,
|
|
|
|
|
|
+ color: optionsSetup.textColorX,
|
|
|
|
+ fontSize: optionsSetup.textFontSizeX,
|
|
|
|
+ fontWeight: optionsSetup.textFontWeightX,
|
|
|
|
+ fontStyle: optionsSetup.textFontStyleX,
|
|
|
|
+ fontFamily: optionsSetup.textFontFamilyX,
|
|
},
|
|
},
|
|
// 自动换行
|
|
// 自动换行
|
|
formatter: function (value, index) {
|
|
formatter: function (value, index) {
|
|
@@ -449,6 +516,7 @@ export default {
|
|
return {
|
|
return {
|
|
name: item.name,
|
|
name: item.name,
|
|
type: "bar",
|
|
type: "bar",
|
|
|
|
+ stack: this.getStackStyle(),
|
|
data: item.list.map((item) => item.data),
|
|
data: item.list.map((item) => item.data),
|
|
barGap: optionsSetup.barGap + "%",
|
|
barGap: optionsSetup.barGap + "%",
|
|
barMinHeight: optionsSetup.minHeight,
|
|
barMinHeight: optionsSetup.minHeight,
|
|
@@ -458,12 +526,14 @@ export default {
|
|
position: optionsSetup.fontPosition,
|
|
position: optionsSetup.fontPosition,
|
|
distance: optionsSetup.fontDistance,
|
|
distance: optionsSetup.fontDistance,
|
|
fontSize: optionsSetup.fontSize,
|
|
fontSize: optionsSetup.fontSize,
|
|
- color: optionsSetup.dataColor,
|
|
|
|
|
|
+ color: optionsSetup.fontColor,
|
|
fontWeight: optionsSetup.fontWeight,
|
|
fontWeight: optionsSetup.fontWeight,
|
|
formatter: (row) => {
|
|
formatter: (row) => {
|
|
const dataIndex = row.dataIndex;
|
|
const dataIndex = row.dataIndex;
|
|
return `${fontDataName[0]}:${item.list[dataIndex].display1}\n${fontDataName[1]}:${item.list[dataIndex].display2}\n${fontDataName[2]}:${item.list[dataIndex].data}%`;
|
|
return `${fontDataName[0]}:${item.list[dataIndex].display1}\n${fontDataName[1]}:${item.list[dataIndex].display2}\n${fontDataName[2]}:${item.list[dataIndex].data}%`;
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ fontStyle: optionsSetup.fontStyle,
|
|
|
|
+ fontFamily: optionsSetup.fontFamily,
|
|
},
|
|
},
|
|
//颜色,圆角属性
|
|
//颜色,圆角属性
|
|
itemStyle: {
|
|
itemStyle: {
|
|
@@ -487,16 +557,19 @@ export default {
|
|
})
|
|
})
|
|
// 根据图表的宽度 x轴的字体大小、长度来估算X轴的label能展示多少个字
|
|
// 根据图表的宽度 x轴的字体大小、长度来估算X轴的label能展示多少个字
|
|
const xAxisDataLength = val.length !== 0 ? val.xAxis.length : 1;
|
|
const xAxisDataLength = val.length !== 0 ? val.xAxis.length : 1;
|
|
- const rowsNum = optionsSetup.textRowsNum !== "" ? optionsSetup.textRowsNum : parseInt((this.optionsStyle.width / xAxisDataLength) / optionsSetup.fontSizeX);
|
|
|
|
|
|
+ const rowsNum = optionsSetup.textRowsNum !== "" ? optionsSetup.textRowsNum : parseInt((this.optionsStyle.width / xAxisDataLength) / optionsSetup.textFontSizeX);
|
|
const axisLabel = {
|
|
const axisLabel = {
|
|
- show: true,
|
|
|
|
- interval: optionsSetup.textInterval,
|
|
|
|
|
|
+ show: optionsSetup.isShowAxisLabelX,
|
|
|
|
+ interval: optionsSetup.textIntervalX,
|
|
// 文字角度
|
|
// 文字角度
|
|
rotate: optionsSetup.textAngleX,
|
|
rotate: optionsSetup.textAngleX,
|
|
textStyle: {
|
|
textStyle: {
|
|
// 坐标文字颜色
|
|
// 坐标文字颜色
|
|
- color: optionsSetup.colorX,
|
|
|
|
- fontSize: optionsSetup.fontSizeX,
|
|
|
|
|
|
+ color: optionsSetup.textColorX,
|
|
|
|
+ fontSize: optionsSetup.textFontSizeX,
|
|
|
|
+ fontWeight: optionsSetup.textFontWeightX,
|
|
|
|
+ fontStyle: optionsSetup.textFontStyleX,
|
|
|
|
+ fontFamily: optionsSetup.textFontFamilyX,
|
|
},
|
|
},
|
|
// 自动换行
|
|
// 自动换行
|
|
formatter: function (value, index) {
|
|
formatter: function (value, index) {
|