|
@@ -264,7 +264,8 @@ const selectshuju = (listcbval,listcbval2,dataheader, data) => {
|
|
|
|
|
|
const xAxisLabel = dataheader.find(item => item.prop === xColumns[0])?.label || xColumns[0];
|
|
|
const yAxisLabel = getFormattedYLabels(yColumns, dataheader);
|
|
|
- const chartTitle = `${xAxisLabel} - ${yAxisLabel}`;
|
|
|
+ const yAxisLabel1 = getFormattedYLabels1(yColumns, dataheader);
|
|
|
+ const chartTitle = `${xAxisLabel} - ${yAxisLabel1}`;
|
|
|
|
|
|
myChart.setOption({
|
|
|
title: {
|
|
@@ -303,12 +304,26 @@ const getFormattedYLabels = (columns, header, maxLength = 20) => {
|
|
|
|
|
|
return fullLabel;
|
|
|
};
|
|
|
+// 不换行
|
|
|
+const getFormattedYLabels1 = (columns, header, maxLength = 20) => {
|
|
|
+ const labels = columns.map(col => {
|
|
|
+ return header.find(item => item.prop === col)?.label || col;
|
|
|
+ });
|
|
|
+ const fullLabel = labels.join(',');
|
|
|
+
|
|
|
+ // 若总字符数超出 maxLength,则截断
|
|
|
+ if (fullLabel.length > maxLength) {
|
|
|
+ return fullLabel.slice(0, maxLength) + '...';
|
|
|
+ }
|
|
|
+
|
|
|
+ return fullLabel;
|
|
|
+};
|
|
|
|
|
|
const setOptionfunc = async () => {
|
|
|
option.value = {
|
|
|
title: {
|
|
|
text: "",
|
|
|
- left: "7%",
|
|
|
+ left: "center",
|
|
|
top: "5%",
|
|
|
textStyle: {
|
|
|
color: "#333333",
|