Karsa 1 year ago
parent
commit
48b84b3ee5
3 changed files with 17 additions and 11 deletions
  1. 2 1
      src/components/chart.vue
  2. 15 7
      src/hooks/chart/useChartRender.ts
  3. 0 3
      src/views/chartShow/index.less

+ 2 - 1
src/components/chart.vue

@@ -64,7 +64,8 @@ export default defineComponent({
 				},
 				chart: {
 					...defaultOpts.chart,
-					...chartTheme.drawOption
+					...chartTheme.drawOption,
+          spacing: chartTheme.legendOptions.verticalAlign==='bottom' ? [23,10,2,10] : [2,10,2,10],//图例在底部顶部空间留大点给单位
 				},
 				colors: chartTheme.colorsOptions
 			}

+ 15 - 7
src/hooks/chart/useChartRender.ts

@@ -164,7 +164,7 @@ const setDefaultLineOptions = () => {
         },
         align: 'high',
         rotation: 0,
-        y: -15,
+        y: -12,
         x: (item.IsAxis===0 && rightTwoIndex>-1) ? -chartData[rightTwoIndex].Unit.length*12 : 0,
         textAlign: item.IsAxis===1 ? 'left' : 'right',
         reserveSpace: false
@@ -342,7 +342,7 @@ const setSeasonOptions = () => {
       text:language.value=='ch'?`${chartData.Unit}`:chartData.UnitEn,
       align: 'high',
       rotation: 0,
-      y: -15,
+      y: -12,
       x: 0,
       textAlign: 'left',
       reserveSpace: false,
@@ -462,7 +462,7 @@ const setStackOrCombinChart = () => {
         // text: null,
         align: 'high',
         rotation: 0,
-        y: -15,
+        y: -12,
         x: (item.IsAxis===0 && rightTwoIndex>-1) ? -chartData[rightTwoIndex].Unit.length*12 : 0,
         textAlign: item.IsAxis===1 ? 'left' : 'right',
         reserveSpace: false,
@@ -754,7 +754,7 @@ const setBarChart = () => {
       text:  language.value==='ch' ? chartInfo.Unit : chartInfo.UnitEn,
       align: 'high',
       rotation: 0,
-      y: -15,
+      y: -12,
       x:0,
       textAlign: 'left',
       reserveSpace: false,
@@ -1067,7 +1067,7 @@ const setCommodityChart = () => {
       text: language.value === 'ch' ? commodityEdbList[0].Unit : commodityEdbList[0].UnitEn,
       align: 'high',
       rotation: 0,
-      y: -15,
+      y: -12,
       textAlign: 'left',
       reserveSpace: false,
       style:{
@@ -1241,7 +1241,7 @@ const initRelevanceChartData=(data)=>{
       text: language.value=='ch'?'相关性系数':'Correlation coefficient',
       align: 'high',
       rotation: 0,
-      y: -15,
+      y: -12,
       textAlign: 'left',
       reserveSpace: false,
       style:{
@@ -1356,7 +1356,7 @@ const setStatisticFrequency = () => {
         text: language.value === 'ch' ? item.Unit : item.UnitEn,
         align: 'high',
         rotation: 0,
-        y: -15,
+        y: -12,
         reserveSpace: false,
         style:{
           ...chartTheme&&chartTheme.yAxisOptions.style
@@ -1775,6 +1775,13 @@ const setAxisPlotAreas = (axis: number, axisType: any = null) => {
       toMarkerValue = Number(_.toValue);
     }
 
+    //默认label有些偏移 重新归正下
+    let positionMapValue = {
+      'top': 12,
+      'middle': 0,
+      'bottom': -10
+    }
+
     return {
       from: fromMarkerValue,
       to: toMarkerValue,
@@ -1782,6 +1789,7 @@ const setAxisPlotAreas = (axis: number, axisType: any = null) => {
       label: {
         text: _.text || "",
         verticalAlign: _.textPosition,
+        y: positionMapValue[_.textPosition],
         style: {
           color: _.textColor,
           fontSize: _.textFontSize,

+ 0 - 3
src/views/chartShow/index.less

@@ -31,9 +31,6 @@
 			min-height: 40px;
 			// line-height: 40px;
 			line-height: 1.5;
-			display: flex;
-			justify-content: space-between;
-			align-items: center;
 			.chart-title {
 				// flex: 1;
 				&:hover {