折线图坐标文本间距过近

This commit is contained in:
chenjiancheng 2025-02-24 16:13:16 +08:00
parent 091a84294f
commit e0f2bb743b
2 changed files with 18 additions and 11 deletions

View File

@ -319,6 +319,17 @@ const handleEchartData = (res) => {
const chartStatus = ref(0);
const datasetOption = {
tooltip: {
trigger: 'axis',
formatter: function (params) {
// X
let tooltipText = '';
params.forEach(item => {
tooltipText += item.name + ': ' + item.value + '<br>';
});
return tooltipText;
}
},
xAxis: {
type: 'category',
data: [
@ -334,6 +345,7 @@ const datasetOption = {
axisLine: {
show: true,
},
axisLabel: {
show: true,
interval: 0,
@ -342,16 +354,12 @@ const datasetOption = {
formatter(str) {
const contentLength = str.length;
let result;
if (contentLength > 6) {
result = `${str.slice(0, 3)}\n${str.slice(3,5)}...`;
} else {
result = `${str.slice(0, contentLength / 2)}\n${str.slice(contentLength / 2)}`;
// if (contentLength === 4) {
// result = `${str.slice(0, 2)}\n${str.slice(2)}`;
// } else if (contentLength === 6) {
// result = `${str.slice(0, 3)}\n${str.slice(3)}`;
// } else if (contentLength === 8) {
// result = `${str.slice(0, 4)}\n${str.slice(4)}`;
// } else if (contentLength === 7) {
// result = `${str.slice(0, 4)}\n${str.slice(4)}`;
// }
}
return result;
},
fontSize: nowSize(16),

View File

@ -3,7 +3,6 @@
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
// biome-ignore lint: disable
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
@ -83,6 +82,6 @@ declare global {
// for type re-export
declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
import('vue')
}