Label Text Width Fit Feature Request

Abierto
#21,607 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
typescript

Línea de trabajo

El issue no nombra archivos, tests ni puntos de entrada. Empieza localizando las rutas de renderizado de labels y rich text; después, define y valida una API de ajuste horizontal de texto para labels de ancho fijo en markPoint y componentes relacionados. El trabajo estará terminado cuando el comportamiento y la API estén documentados y cubiertos por tests.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

new-feature
What problem does this feature solve?

Currently, ECharts provides width and overflow properties (like truncate or break) for labels in markPoint, markLine, and other components. However, there is no native way to force text to fit a specific container width by stretching or narrowing the glyphs themselves (horizontal scaling).

In many UI designs—specifically when using markPoint with custom symbols like pins or boxes—we have a fixed-width area for text.

  1. Truncation (truncate) hides important information.
  2. Wrapping (break) often breaks the visual layout or overflows the symbol vertically.
  3. Font-size reduction is a common workaround, but it requires manual calculation of string lengths and doesn't guarantee a "flush" look on both sides.

I am looking for a feature similar to the SVG attribute textLength with lengthAdjust="spacingAndGlyphs" or the CSS text-stretch property. This would allow the text to horizontally scale to fill the exact width provided without changing the font height.

What does the proposed API look like?

I propose adding a property to the label or rich text styles, perhaps called fontStretch or an option within overflow.

Option A (New Property):

label: {
  show: true,
  width: 50,
  // This would stretch or compress the text to be exactly 50px wide
  fontStretch: 'fit' 
}

**Option B (Enhancing Overflow):**
label: {
  show: true,
  width: 50,
  overflow: 'fit' // A new option that scales the text width to match the defined width
}
Lenguaje dominante
TypeScript
Estrellas
67.7k
Forks
19.9k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/echarts

Todos los issues de apache/echarts

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.